1 diff -urN linux.old/drivers/net/avalanche_cpmac/cpcommon_cpmac.c linux.dev/drivers/net/avalanche_cpmac/cpcommon_cpmac.c
2 --- linux.old/drivers/net/avalanche_cpmac/cpcommon_cpmac.c 1970-01-01 01:00:00.000000000 +0100
3 +++ linux.dev/drivers/net/avalanche_cpmac/cpcommon_cpmac.c 2005-07-12 02:48:41.996601000 +0200
5 +#ifndef _INC_CPCOMMON_C
6 +#define _INC_CPCOMMON_C
9 +#include "cpremap_cpmac.c"
13 +#include "cpremap_cpaal5.c"
17 +#include "cpremap_cpsar.c"
21 +#include "cpremap_cpaal2.c"
25 +@defgroup Common_Config_Params Common Configuration Parameters
27 +This section documents the configuration parameters that are valid across
31 +/** This is the debug level. The field is bit defined, such that the user
32 +should set to 1 all the bits corresponding to desired debug outputs. The following
33 +are the meanings for each debug bit:
34 +- bit0 (LSB): CPHAL Function Trace
35 +- b1 : OS Function call trace
36 +- b2 : Critical section entry/exit
37 +- b3 : Memory allocation/destruction
38 +- b4 : Detailed information in Rx path
39 +- b5 : Detailed information in Tx path
40 +- b6 : Extended error information
43 +static const char pszDebug[] = "debug";
44 +/** CPU Frequency. */
45 +/*static const char pszCpuFreq[] = "CpuFreq";*/ /*MJH-030403*/
46 +/** Base address for the module. */
47 +static const char pszBase[] = "base";
48 +/** Reset bit for the module. */
49 +static const char pszResetBit[] = "reset_bit";
50 +/** Reset base address for the module. */
51 +static const char pszResetBase[] = "ResetBase";
52 +/** Interrupt line for the module. */
53 +static const char pszIntLine[] = "int_line";
54 +/** VLYNQ offset for the module. Disregard if not using VLYNQ. */
55 +static const char pszOffset[] = "offset";
56 +/** The OS may "Get" this parameter, which is a pointer
57 + to a character string that indicates the version of CPHAL. */
58 +static const char pszVer[] = "Version";
62 +@defgroup Common_Control_Params Common Keys for [os]Control()
64 +This section documents the keys used with the OS @c Control() interface that
65 +are required by CPHAL devices.
69 +/** Used to wait for an integer number of clock ticks, given as an integer
70 + pointer in the @p Value parameter. No actions are defined. */
71 +static const char pszSleep[] = "Sleep";
72 +/** Requests the OS to flush it's IO buffers. No actions are defined. */
73 +static const char pszSioFlush[] = "SioFlush";
76 +static const char pszStateChange[] = "StateChange";
77 +static const char pszStatus[] = "Status";
79 +static const char pszGET[] = "Get";
80 +static const char pszSET[] = "Set";
81 +static const char pszCLEAR[] = "Clear";
82 +static const char pszNULL[] = "";
83 +static const char pszLocator[] = "Locator";
84 +static const char pszOff[] = "Off";
85 +static const char pszOn[] = "On";
86 +static const char hcMaxFrags[] = "MaxFrags";
90 +/* New method for string constants */
91 +const char hcClear[] = "Clear";
92 +const char hcGet[] = "Get";
93 +const char hcSet[] = "Set";
95 +const char hcTick[] = "Tick";
97 +static const CONTROL_KEY KeyCommon[] =
99 + {"" , enCommonStart},
100 + {pszStatus , enStatus},
103 + {pszDebug , enDebug},
104 + {hcCpuFrequency , enCpuFreq}, /*MJH~030403*/
110 +@defgroup Common_Statistics Statistics
112 +A broad array of module statistics is available. Statistics values are accessed
113 +through the @c Control() interface of the CPHAL. There are 5 different levels
114 +of statistics, each of which correspond to a unique set of data. Furthermore,
115 +certain statistics data is indexed by using a channel number and Tx queue number.
116 +The following is a brief description of each statistics level, along with the
117 +indexes used for the level:
119 +- Level 0: Hardware Statistics (index with channel)
120 +- Level 1: CPHAL Software Statistics (channel, queue)
121 +- Level 2: CPHAL Flags (channel, queue)
122 +- Level 3: CPHAL Channel Configuration (channel)
123 +- Level 4: CPHAL General Configuration (no index)
125 +The caller requests statistics information by providing a Key string to the
126 +@c Control() API in the following format: "Stats;[Level #];[Ch #];[Queue #]".
127 +The only valid Action parameter for statistics usage is "Get".
131 +unsigned int *StatsData;
133 +# Get Level 0 stats for Channel 1
134 +HalFunc->Control(OsDev->HalDev, "Stats;0;1", "Get", &StatsData);
136 +# Get Level 2 stats for Channel 0, Queue 0
137 +HalFunc->Control(OsDev->HalDev, "Stats;2;0;0", "Get", &StatsData);
140 +HalFunc->Control(OsDev->HalDev, "Stats;4", "Get", &StatsData);
143 +The information returned in the Value parameter of @c Control() is an
144 +array of pointers to strings. The pointers are arranged in pairs.
145 +The first pointer is a pointer to a name string for a particular statistic.
146 +The next pointer is a pointer to a string containing the representation of
147 +the integer statistic value corresponding to the first pointer. This is followed
148 +by another pair of pointers, and so on, until a NULL pointer is encountered. The
149 +following is example code for processing the statistics data. Note that the OS
150 +is responsible for freeing the memory passed back through the Value parameter of
154 +unsigned int *StatsData;
156 +# Get Level 0 stats for Channel 1
157 +HalFunc->Control(OsDev->HalDev, "Stats;0;1", "Get", &StatsData);
159 +# output Statistics data
160 +PrintStats(StatsData);
162 +# the upper layer is responsible for freeing stats info
167 +void PrintStats(unsigned int *StatsPtr)
171 + printf("%20s:", (char *)*StatsPtr);
173 + printf("%11s\n", (char *)*StatsPtr);
180 +Within each statistics level, there are several statistics defined. The statistics that
181 +are common to every CPPI module are listed below. In addition, each module may define
182 +extra statistics in each level, which will be documented within the module-specific
183 +documentation appendices.
185 +- Level 0 Statistics
186 + - All level 0 statistics are module-specific.
187 +- Level 1 Statistics (CPHAL Software Statistics)
188 + - DmaLenErrors: Incremented when the port DMA's more data than expected (per channel). (AAL5 Only)
189 + - TxMisQCnt: Incremented when host queues a packet for transmission as the port finishes
190 +transmitting the previous last packet in the queue (per channel and queue).
191 + - RxMisQCnt: Incremented when host queues adds buffers to a queue as the port finished the
192 +reception of the previous last packet in the queue (per channel).
193 + - TxEOQCnt: Number of times the port has reached the end of the transmit queue (per channel and queue).
194 + - RxEOQCnt: Number of times the port has reached the end of the receive queue (per channel).
195 + - RxPacketsServiced: Number of received packets (per channel).
196 + - TxPacketsServiced: Number of transmitted packets (per channel and queue).
197 + - RxMaxServiced: Maximum number of packets that the CPHAL receive interrupt has serviced at a time (per channel).
198 + - TxMaxServiced: Maximum number of packets that the CPHAL transmit interrupt has serviced at a time (per channel and queue).
199 + - RxTotal: Total number of received packets, all channels.
200 + - TxTotal: Total number of transmitted packets, all channels and queues.
201 +- Level 2 Statistics (CPHAL Flags)
202 + - RcbPool: Pointer to receive descriptor pool (per channel).
203 + - RxActQueueCount: Number of buffers currently available for receive (per channel).
204 + - RxActQueueHead: Pointer to first buffer in receive queue (per channel).
205 + - RxActQueueTail: Pointer to last buffer in receive queue (per channel).
206 + - RxActive: 0 if inactive (no buffers available), or 1 if active (buffers available).
207 + - RcbStart: Pointer to block of receive descriptors.
208 + - RxTeardownPending: 1 if Rx teardown is pending but incomplete, 0 otherwise.
209 + - TcbPool: Pointer to transmit descriptor pool (per channel and queue).
210 + - TxActQueueCount: Number of buffers currently queued to be transmitted (per channel and queue).
211 + - TxActQueueHead: Pointer to first buffer in transmit queue (per channel and queue).
212 + - TxActQueueTail: Pointer to last buffer in transmit queue (per channel and queue).
213 + - TxActive: 0 if inactive (no buffers to send), or 1 if active (buffers queued to send).
214 + - TcbStart: Pointer to block of transmit descriptors.
215 + - TxTeardownPending: 1 if Tx teardown is pending but incomplete, 0 otherwise.
216 +- Level 3 Statistics (CPHAL Channel Configuration)
217 + - RxBufSize: Rx buffer size.
218 + - RxBufferOffset: Rx buffer offset.
219 + - RxNumBuffers: Number of Rx buffers.
220 + - RxServiceMax: Maximum number of receive packets to service at a time.
221 + - TxNumBuffers: Number of Tx buffer descriptors.
222 + - TxNumQueues: Number of Tx queues to use.
223 + - TxServiceMax: Maximum number of transmit packets to service at a time.
224 +- Level 4 Statistics (CPHAL General Configuration)
225 + - Base Address: Base address of the module.
226 + - Offset (VLYNQ): VLYNQ relative module offset.
227 + - Interrupt Line: Interrupt number.
228 + - Debug: Debug flag, 1 to enable debug.
229 + - Inst: Instance number.
233 + Data Type 0 = int display
234 + Data Type 1 = hex display
235 + Data Type 2 = channel structure, int display
236 + Data Type 3 = queue index and int display
237 + Data Type 4 = queue index and hex display
239 +#if (defined(_CPHAL_AAL5) || defined(_CPHAL_CPMAC)) /* +GSG 030307 */
240 +static STATS_TABLE StatsTable0[] =
243 + /* Name , Data Ptr, Data Type */
244 + {"Crc Errors", 0, 0},
245 + {"Len Errors", 0, 0},
246 + {"Abort Errors", 0, 0},
247 + {"Starv Errors", 0, 0}
250 + {"Rx Good Frames", 0, 0}
254 +static STATS_TABLE StatsTable1[] =
256 + /* Name , Data Ptr, Data Type */
257 + {"DmaLenErrors", 0, 0},
258 + {"TxMisQCnt", 0, 3},
259 + {"RxMisQCnt", 0, 0},
260 + {"TxEOQCnt", 0, 3},
261 + {"RxEOQCnt", 0, 0},
262 + {"RxPacketsServiced", 0, 0},
263 + {"TxPacketsServiced", 0, 3},
264 + {"RxMaxServiced", 0, 0},
265 + {"TxMaxServiced", 0, 3},
270 +static STATS_TABLE StatsTable2[] =
272 + /* Name , Data Ptr, Data Type */
274 + {"RxActQueueCount", 0, 0},
275 + {"RxActQueueHead", 0, 1},
276 + {"RxActQueueTail", 0, 1},
277 + {"RxActive", 0, 0},
278 + {"RcbStart", 0, 1},
279 + {"RxTeardownPending", 0, 0},
281 + {"TxActQueueCount", 0, 3},
282 + {"TxActQueueHead", 0, 4},
283 + {"TxActQueueTail", 0, 4},
284 + {"TxActive", 0, 3},
285 + {"TcbStart", 0, 4},
286 + {"TxTeardownPending", 0, 0}
289 +static STATS_TABLE StatsTable3[] =
291 + /* Name , Data Ptr, Data Type */
292 + {"RxBufSize", 0, 2},
293 + {"RxBufferOffset", 0, 2},
294 + {"RxNumBuffers", 0, 2},
295 + {"RxServiceMax", 0, 2},
296 + {"TxNumBuffers", 0, 2},
297 + {"TxNumQueues", 0, 2},
298 + {"TxServiceMax", 0, 2},
305 + {"Priority", 0, 2},
309 + {"CellRate", 0, 2},
316 +static STATS_TABLE StatsTable4[] =
318 + {"Base Address", 0, 1},
319 + {"Offset (VLYNQ)", 0, 0},
320 + {"Interrupt Line", 0, 0},
322 + {"Instance", 0, 0},
328 +static STATS_DB StatsDb[] =
330 + {(sizeof(StatsTable0)/sizeof(STATS_TABLE)), StatsTable0},
331 + {(sizeof(StatsTable1)/sizeof(STATS_TABLE)), StatsTable1},
332 + {(sizeof(StatsTable2)/sizeof(STATS_TABLE)), StatsTable2},
333 + {(sizeof(StatsTable3)/sizeof(STATS_TABLE)), StatsTable3},
334 + {(sizeof(StatsTable4)/sizeof(STATS_TABLE)), StatsTable4}
336 +#endif /* +GSG 030307 */
338 +#ifdef _CPHAL_CPMAC /* +RC 3.02 */
339 +static void resetWait(HAL_DEVICE *HalDev)
341 + const int TickReset=64;
342 + osfuncSleep((int*)&TickReset);
344 +#endif /* +RC 3.02 */
346 +/* I only define the reset base function for the modules
347 + that can perform a reset. The AAL5 and AAL2 modules
348 + do not perform a reset, that is done by the shared module
350 +#if defined(_CPHAL_CPSAR) || defined(_CPHAL_CPMAC) || defined(_CPHAL_VDMAVT)
352 + * Determines the reset register address to be used for a particular device.
353 + * It will search the current device entry for Locator information. If the
354 + * device is a root device, there will be no Locator information, and the
355 + * function will find and return the root reset register. If a Locator value
356 + * is found, the function will search each VLYNQ device entry in the system
357 + * looking for a matching Locator. Once it finds a VLYNQ device entry with
358 + * a matching Locator, it will extract the "ResetBase" parameter from that
359 + * VLYNQ device entry (thus every VLYNQ entry must have the ResetBase parameter).
361 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
362 + * @param ResetBase Pointer to integer address of reset register.
364 + * @return 0 OK, Non-zero not OK
366 +static int ResetBaseGet(HAL_DEVICE *HalDev, bit32u *ResetBase)
368 + char *DeviceInfo = HalDev->DeviceInfo;
369 + char *MyLocator, *NextLocator;
373 +#ifdef __CPHAL_DEBUG
376 + dbgPrintf("[cpcommon]ResetBaseGet(HalDev:%08x, ResetBase:%08x)\n", (bit32u)HalDev, ResetBase);
381 + error_code = HalDev->OsFunc->DeviceFindParmValue(DeviceInfo, "Locator", &MyLocator);
384 + /* if no Locator value, device is on the root, so get the "reset" device */
385 + error_code = HalDev->OsFunc->DeviceFindInfo(0, "reset", &DeviceInfo);
388 + return(EC_VAL_DEVICE_NOT_FOUND);
391 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, "base", ResetBase);
394 + return(EC_VAL_BASE_ADDR_NOT_FOUND);
397 + *ResetBase = ((bit32u)PhysToVirtNoCache(*ResetBase));
399 + /* found base address for root device, so we're done */
400 + return (EC_NO_ERRORS);
404 + /* we have a Locator value, so the device is remote */
406 + /* Find a vlynq device with a matching locator value */
407 + while ((HalDev->OsFunc->DeviceFindInfo(Inst, "vlynq", &DeviceInfo)) == EC_NO_ERRORS)
409 + error_code = HalDev->OsFunc->DeviceFindParmValue(DeviceInfo, "Locator", &NextLocator);
412 + /* no Locator value for this VLYNQ, so move on */
415 + if (HalDev->OsFunc->Strcmpi(MyLocator, NextLocator)==0)
417 + /* we have found a VLYNQ with a matching Locator, so extract the ResetBase */
418 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, "ResetBase", ResetBase);
421 + return(EC_VAL_BASE_ADDR_NOT_FOUND);
423 + *ResetBase = ((bit32u)PhysToVirtNoCache(*ResetBase));
425 + /* found base address for root device, so we're done */
426 + return (EC_NO_ERRORS);
432 + return (EC_NO_ERRORS);
436 +#ifndef _CPHAL_AAL2 /* + RC 3.02 */
437 +static bit32u ConfigGetCommon(HAL_DEVICE *HalDev)
441 + char *DeviceInfo = HalDev->DeviceInfo;
443 +#ifdef __CPHAL_DEBUG
446 + dbgPrintf("[cpcommon]ConfigGetCommon(HalDev:%08x)\n", (bit32u)HalDev);
451 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszBase, &ParmValue);
454 + return(EC_FUNC_HAL_INIT|EC_VAL_BASE_ADDR_NOT_FOUND);
456 + HalDev->dev_base = ((bit32u)PhysToVirtNoCache(ParmValue));
460 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszResetBit, &ParmValue);
463 + return(EC_FUNC_HAL_INIT|EC_VAL_RESET_BIT_NOT_FOUND);
465 + HalDev->ResetBit = ParmValue;
467 + /* Get reset base address */
468 + error_code = ResetBaseGet(HalDev, &ParmValue);
470 + return(EC_FUNC_HAL_INIT|EC_VAL_RESET_BASE_NOT_FOUND);
471 + HalDev->ResetBase = ParmValue;
475 +#ifndef _CPHAL_CPSAR
476 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszIntLine,&ParmValue);
479 + return(EC_FUNC_HAL_INIT|EC_VAL_INTERRUPT_NOT_FOUND);
481 + HalDev->interrupt = ParmValue;
484 + /* only look for the offset if there is a Locator field, which indicates that
485 + the module is a VLYNQ module */
486 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszLocator,&ParmValue);
489 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszOffset,&ParmValue);
492 + return(EC_FUNC_HAL_INIT|EC_VAL_OFFSET_NOT_FOUND);
494 + HalDev->offset = ParmValue;
497 + HalDev->offset = 0;
499 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszDebug, &ParmValue);
500 + if (!error_code) HalDev->debug = ParmValue;
502 + return (EC_NO_ERRORS);
504 +#endif /* +RC 3.02 */
506 +#ifdef _CPHAL_CPMAC /* +RC 3.02 */
507 +static void StatsInit(HAL_DEVICE *HalDev) /* +() RC3.02 */
509 + /* even though these statistics may be for multiple channels and
510 + queues, i need only configure the pointer to the beginning
511 + of the array, and I can index from there if necessary */
514 + StatsTable0[0].StatPtr = &HalDev->Stats.CrcErrors[0];
515 + StatsTable0[1].StatPtr = &HalDev->Stats.LenErrors[0];
516 + StatsTable0[2].StatPtr = &HalDev->Stats.AbortErrors[0];
517 + StatsTable0[3].StatPtr = &HalDev->Stats.StarvErrors[0];
519 + StatsTable1[0].StatPtr = &HalDev->Stats.DmaLenErrors[0];
520 + StatsTable1[1].StatPtr = &HalDev->Stats.TxMisQCnt[0][0];
521 + StatsTable1[2].StatPtr = &HalDev->Stats.RxMisQCnt[0];
522 + StatsTable1[3].StatPtr = &HalDev->Stats.TxEOQCnt[0][0];
523 + StatsTable1[4].StatPtr = &HalDev->Stats.RxEOQCnt[0];
524 + StatsTable1[5].StatPtr = &HalDev->Stats.RxPacketsServiced[0];
525 + StatsTable1[6].StatPtr = &HalDev->Stats.TxPacketsServiced[0][0];
526 + StatsTable1[7].StatPtr = &HalDev->Stats.RxMaxServiced;
527 + StatsTable1[8].StatPtr = &HalDev->Stats.TxMaxServiced[0][0];
528 + StatsTable1[9].StatPtr = &HalDev->Stats.RxTotal;
529 + StatsTable1[10].StatPtr = &HalDev->Stats.TxTotal;
532 +#if (defined(_CPHAL_AAL5) || defined(_CPHAL_CPMAC))
533 + StatsTable2[0].StatPtr = (bit32u *)&HalDev->RcbPool[0];
534 + StatsTable2[1].StatPtr = &HalDev->RxActQueueCount[0];
535 + StatsTable2[2].StatPtr = (bit32u *)&HalDev->RxActQueueHead[0];
536 + StatsTable2[3].StatPtr = (bit32u *)&HalDev->RxActQueueTail[0];
537 + StatsTable2[4].StatPtr = &HalDev->RxActive[0];
538 + StatsTable2[5].StatPtr = (bit32u *)&HalDev->RcbStart[0];
539 + StatsTable2[6].StatPtr = &HalDev->RxTeardownPending[0];
540 + StatsTable2[7].StatPtr = (bit32u *)&HalDev->TcbPool[0][0];
541 + StatsTable2[8].StatPtr = &HalDev->TxActQueueCount[0][0];
542 + StatsTable2[9].StatPtr = (bit32u *)&HalDev->TxActQueueHead[0][0];
543 + StatsTable2[10].StatPtr = (bit32u *)&HalDev->TxActQueueTail[0][0];
544 + StatsTable2[11].StatPtr = &HalDev->TxActive[0][0];
545 + StatsTable2[12].StatPtr = (bit32u *)&HalDev->TcbStart[0][0];
546 + StatsTable2[13].StatPtr = &HalDev->TxTeardownPending[0];
548 + StatsTable3[0].StatPtr = &HalDev->ChData[0].RxBufSize;
549 + StatsTable3[1].StatPtr = &HalDev->ChData[0].RxBufferOffset;
550 + StatsTable3[2].StatPtr = &HalDev->ChData[0].RxNumBuffers;
551 + StatsTable3[3].StatPtr = &HalDev->ChData[0].RxServiceMax;
552 + StatsTable3[4].StatPtr = &HalDev->ChData[0].TxNumBuffers;
553 + StatsTable3[5].StatPtr = &HalDev->ChData[0].TxNumQueues;
554 + StatsTable3[6].StatPtr = &HalDev->ChData[0].TxServiceMax;
556 + StatsTable3[7].StatPtr = &HalDev->ChData[0].CpcsUU;
557 + StatsTable3[8].StatPtr = &HalDev->ChData[0].Gfc;
558 + StatsTable3[9].StatPtr = &HalDev->ChData[0].Clp;
559 + StatsTable3[10].StatPtr = &HalDev->ChData[0].Pti;
560 + StatsTable3[11].StatPtr = &HalDev->ChData[0].DaMask;
561 + StatsTable3[12].StatPtr = &HalDev->ChData[0].Priority;
562 + StatsTable3[13].StatPtr = &HalDev->ChData[0].PktType;
563 + StatsTable3[14].StatPtr = &HalDev->ChData[0].Vci;
564 + StatsTable3[15].StatPtr = &HalDev->ChData[0].Vpi;
565 + StatsTable3[16].StatPtr = &HalDev->ChData[0].TxVc_CellRate;
566 + StatsTable3[17].StatPtr = &HalDev->ChData[0].TxVc_QosType;
567 + StatsTable3[18].StatPtr = &HalDev->ChData[0].TxVc_Mbs;
568 + StatsTable3[19].StatPtr = &HalDev->ChData[0].TxVc_Pcr;
572 + StatsTable4[0].StatPtr = &HalDev->dev_base;
573 + StatsTable4[1].StatPtr = &HalDev->offset;
574 + StatsTable4[2].StatPtr = &HalDev->interrupt;
575 + StatsTable4[3].StatPtr = &HalDev->debug;
576 + StatsTable4[4].StatPtr = &HalDev->Inst;
578 +#endif /* +RC 3.02 */
580 +#ifndef _CPHAL_CPSAR /* +RC 3.02 */
581 +#ifndef _CPHAL_AAL2 /* +RC 3.02 */
583 + * Returns statistics information.
585 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
589 +static int StatsGet(HAL_DEVICE *HalDev, void **StatPtr, int Index, int Ch, int Queue)
594 + STATS_TABLE *StatsTable;
595 + int i, NumberOfStats;
597 +#ifdef __CPHAL_DEBUG
600 + dbgPrintf("[cpcommon]StatsGet(HalDev:%08x, StatPtr:%08x)\n",
601 + (bit32u)HalDev, (bit32u)StatPtr);
606 + StatsTable = StatsDb[Index].StatTable;
607 + NumberOfStats = StatsDb[Index].NumberOfStats;
609 + Size = sizeof(bit32u)*((NumberOfStats*2)+1);
610 + Size += (NumberOfStats*11);
611 + *StatPtr = (bit32u *)HalDev->OsFunc->Malloc(Size);
613 + AddrPtr = (bit32u *) *StatPtr;
614 + DataPtr = (char *)AddrPtr;
615 + DataPtr += sizeof(bit32u)*((NumberOfStats*2)+1);
617 + for (i=0; i<NumberOfStats; i++)
619 + *AddrPtr++ = (bit32u)StatsTable[i].StatName;
620 + *AddrPtr++ = (bit32u)DataPtr;
621 + if (&StatsTable[i].StatPtr[Ch] != 0)
623 + switch(StatsTable[i].DataType)
626 + HalDev->OsFunc->Sprintf(DataPtr, "%d", (bit32u *)StatsTable[i].StatPtr[Ch]);
629 + HalDev->OsFunc->Sprintf(DataPtr, "0x%x", (bit32u *)StatsTable[i].StatPtr[Ch]);
632 + HalDev->OsFunc->Sprintf(DataPtr, "%d", *((bit32u *)StatsTable[i].StatPtr + (Ch * (sizeof(CHANNEL_INFO)/4))));
635 + HalDev->OsFunc->Sprintf(DataPtr, "%d", *((bit32u *)StatsTable[i].StatPtr + (Ch*MAX_QUEUE)+Queue));
638 + HalDev->OsFunc->Sprintf(DataPtr, "0x%x", *((bit32u *)StatsTable[i].StatPtr + (Ch*MAX_QUEUE)+Queue));
641 + /* invalid data type, due to CPHAL programming error */
647 + /* invalid statistics pointer, probably was not initialized */
649 + DataPtr += HalDev->OsFunc->Strlen(DataPtr) + 1;
652 + *AddrPtr = (bit32u) 0;
654 + return (EC_NO_ERRORS);
656 +#endif /* +RC 3.02 */
657 +#endif /* +RC 3.02 */
660 +static void gpioFunctional(int base, int bit)
662 + bit32u GpioEnr = base + 0xC;
663 + /* To make functional, set to zero */
664 + *(volatile bit32u *)(GpioEnr) &= ~(1 << bit); /*+RC3.02*/
669 +/* Common function, Checks to see if GPIO should be in functional mode */
670 +static void gpioCheck(HAL_DEVICE *HalDev, void *moduleDeviceInfo)
675 + char pszMuxBit[20];
682 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
684 + rc = OsFunc->DeviceFindParmValue(moduleDeviceInfo, "gpio_mux",&pszTmp);
686 + /* gpio entry found, get GPIO register info and make functional */
688 + /* temp copy until FinParmValue fixed */
689 + ptr = &szMuxBit[0];
690 + while ((*ptr++ = *pszTmp++));
692 + pszMuxBits = &szMuxBit[0];
694 + rc = OsFunc->DeviceFindInfo(0,"gpio",&DeviceInfo);
697 + rc = OsFunc->DeviceFindParmUint(DeviceInfo, "base",&base);
700 + rc = OsFunc->DeviceFindParmUint(DeviceInfo, "reset_bit",&reset_bit);
703 + /* If GPIO still in reset, then exit */
704 + if((VOLATILE32(HalDev->ResetBase) & (1 << reset_bit)) == 0)
706 + /* format for gpio_mux is gpio_mux = <int>;<int>;<int>...*/
707 + while (*pszMuxBits)
709 + pszTmp = &pszMuxBit[0];
710 + if(*pszMuxBits == ';') pszMuxBits++;
711 + while ((*pszMuxBits != ';') && (*pszMuxBits != '\0'))
714 + /*If value not a number, skip */
715 + if((*pszMuxBits < '0') || (*pszMuxBits > '9'))
718 + *pszTmp++ = *pszMuxBits++;
721 + bit = OsFunc->Strtoul(pszMuxBit, &pszTmp, 10);
722 + gpioFunctional(base, bit);
723 + resetWait(HalDev); /* not sure if this is needed */
729 +const char hcSarFrequency[] = "SarFreq";
733 diff -urN linux.old/drivers/net/avalanche_cpmac/cpcommon_cpmac.h linux.dev/drivers/net/avalanche_cpmac/cpcommon_cpmac.h
734 --- linux.old/drivers/net/avalanche_cpmac/cpcommon_cpmac.h 1970-01-01 01:00:00.000000000 +0100
735 +++ linux.dev/drivers/net/avalanche_cpmac/cpcommon_cpmac.h 2005-07-12 02:48:41.996601000 +0200
737 +#ifndef _INC_CPCOMMON_H
738 +#define _INC_CPCOMMON_H
740 +#define VOLATILE32(addr) (*(volatile bit32u *)(addr))
742 +#define dbgPrintf HalDev->OsFunc->Printf
745 +#define ChannelUpdate(Field) if(HalChn->Field != 0xFFFFFFFF) HalDev->ChData[Ch].Field = HalChn->Field
747 +#define DBG(level) (HalDev->debug & (1<<(level)))
749 +#define DBG0() DBG(0)
750 +#define DBG1() DBG(1)
751 +#define DBG2() DBG(2)
752 +#define DBG3() DBG(3)
753 +#define DBG4() DBG(4)
754 +#define DBG5() DBG(5)
755 +#define DBG6() DBG(6)
756 +#define DBG7() DBG(7)
760 + * List of defined actions for use with Control().
764 + enGET=0, /**< Get the value associated with a key */
765 + enSET, /**< Set the value associates with a key */
766 + enCLEAR, /**<Clear the value */
767 + enNULL /**< No data action, used to initiate a service or send a message */
771 + * Enumerated hardware states.
775 + enConnected=1, enDevFound, enInitialized, enOpened
782 + enOff, enOn, enDebug,
783 + /* Module General */
791 + const char *strKey;
798 + unsigned int *StatPtr;
799 + int DataType; /* 0: int, 1: hex int, 2:channel data */
805 + STATS_TABLE *StatTable;
808 +#define osfuncSioFlush() HalDev->OsFunc->Control(HalDev->OsDev,"SioFlush",pszNULL,0)
809 +#define osfuncSleep(Ticks) HalDev->OsFunc->Control(HalDev->OsDev,pszSleep,pszNULL,Ticks)
810 +#define osfuncStateChange() HalDev->OsFunc->Control(HalDev->OsDev,pszStateChange,pszNULL,0)
812 +#define CHANNEL_NAMES {"Ch0","Ch1","Ch2","Ch3","Ch4","Ch5","Ch6","Ch7","Ch8","Ch9","Ch10","Ch11","Ch12","Ch13","Ch14","Ch15"}
816 diff -urN linux.old/drivers/net/avalanche_cpmac/cpmac.c linux.dev/drivers/net/avalanche_cpmac/cpmac.c
817 --- linux.old/drivers/net/avalanche_cpmac/cpmac.c 1970-01-01 01:00:00.000000000 +0100
818 +++ linux.dev/drivers/net/avalanche_cpmac/cpmac.c 2005-07-12 03:21:00.298934472 +0200
820 +/******************************************************************************
821 + * FILE PURPOSE: CPMAC Linux Network Device Driver Source
822 + ******************************************************************************
823 + * FILE NAME: cpmac.c
825 + * DESCRIPTION: CPMAC Network Device Driver Source
827 + * REVISION HISTORY:
829 + * Date Description Author
830 + *-----------------------------------------------------------------------------
831 + * 27 Nov 2002 Initial Creation Suraj S Iyer
832 + * 09 Jun 2003 Updates for GA Suraj S Iyer
833 + * 30 Sep 2003 Updates for LED, Reset stats Suraj S Iyer
835 + * (C) Copyright 2003, Texas Instruments, Inc
836 + *******************************************************************************/
837 +#include <linux/kernel.h>
838 +#include <linux/module.h>
839 +#include <linux/init.h>
840 +#include <linux/netdevice.h>
841 +#include <linux/etherdevice.h>
842 +#include <linux/delay.h>
843 +#include <linux/spinlock.h>
844 +#include <linux/proc_fs.h>
845 +#include <linux/ioport.h>
848 +#include <linux/skbuff.h>
850 +#include <asm/mips-boards/prom.h>
851 +#include <linux/string.h>
852 +#include <asm/uaccess.h>
853 +#include <linux/config.h>
854 +#include <asm/ar7/if_port.h>
856 +extern void build_psp_config(void);
857 +extern void psp_config_cleanup(void);
859 +#include "cpmacHalLx.h"
862 +static struct net_device *last_cpmac_device = NULL;
863 +static int cpmac_devices_installed = 0;
865 +void xdump( u_char* cp, int length, char* prefix );
867 +unsigned int cpmac_cpu_freq = 0;
869 +char cpmac_version[] = "1.5";
871 +char l3_align_array[] = {0x02, 0x01, 0x00, 0x03};
872 +#define L3_ALIGN(i) l3_align_array[i]
874 +char add_for_4byte_align[] = {0x04, 0x03, 0x02, 0x05};
875 +#define ADD_FOR_4BYTE_ALIGN(i) add_for_4byte_align[i]
879 +#define IS_802_1Q_FRAME(byte_ptr) (*(unsigned short*)byte_ptr == TPID)
880 +#define TPID_START_OFFSET 12
881 +#define TCI_START_OFFSET 14
882 +#define TCI_LENGTH 2
883 +#define TPID_LENGTH 2
884 +#define TPID_END_OFFSET (TPID_START_OFFSET + TPID_LENGTH)
885 +#define TCI_END_OFFSET (TCI_START_OFFSET + TCI_LENGTH)
886 +#define IS_VALID_VLAN_ID(byte_ptr) ((*(unsigned short*)byte_ptr) && 0xfff != 0)
887 +#define MAX_CLASSES 8
888 +#define MAX_USER_PRIORITY 8
889 +#define CONTROL_802_1Q_SIZE (TCI_LENGTH + TPID_LENGTH)
891 +unsigned char user_priority_to_traffic_class_map[MAX_CLASSES][MAX_USER_PRIORITY] =
893 + {0, 0, 0, 1, 1, 1, 1, 2},
894 + {0, 0, 0, 0, 0, 0, 0, 0},
895 + {0, 0, 0, 0, 0, 0, 0, 1},
896 + {0, 0, 0, 1, 1, 2, 2, 3},
897 + {0, 1, 1, 2, 2, 3, 3, 4},
898 + {0, 1, 1, 2, 3, 4, 4, 5},
899 + {0, 1, 2, 3, 4, 5, 5, 6},
900 + {0, 1, 2, 3, 4, 5, 6, 7}
903 +#define GET_802_1P_CHAN(x,y) user_priority_to_traffic_class_map[x][(y & 0xe0)]
905 +#if defined(CONFIG_MIPS_SEAD2)
906 +unsigned long temp_base_address[2] = {0xa8610000, 0xa8612800};
907 +unsigned long temp_reset_value[2] = { 1<< 17,1<<21};
908 +#define RESET_REG_PRCR (*(volatile unsigned int *)((0xa8611600 + 0x0)))
909 +#define VERSION(base) (*(volatile unsigned int *)(((base)|0xa0000000) + 0x0))
912 +MODULE_AUTHOR("Maintainer: Suraj S Iyer <ssiyer@ti.com>");
913 +MODULE_DESCRIPTION("Driver for TI CPMAC");
915 +static int cfg_link_speed = 0;
916 +MODULE_PARM(cfg_link_speed, "i");
917 +MODULE_PARM_DESC(cfg_link_speed, "Fixed speed of the Link: <100/10>");
919 +static char *cfg_link_mode = NULL;
920 +MODULE_PARM(cfg_link_mode, "1-3s");
921 +MODULE_PARM_DESC(cfg_link_mode, "Fixed mode of the Link: <fd/hd>");
923 +int cpmac_debug_mode = 0;
924 +MODULE_PARM(debug_mode, "i");
925 +MODULE_PARM_DESC(debug_mode, "Turn on the debug info: <0/1>. Default is 0 (off)");
927 +#define dbgPrint if (cpmac_debug_mode) printk
928 +#define errPrint printk
930 +static int g_cfg_start_link_params = CFG_START_LINK_SPEED;
931 +static int g_init_enable_flag = 0;
932 +static int cfg_start_link_speed;
933 +static int cpmac_max_frame_size;
935 +static struct net_device *g_dev_array[2];
936 +static struct proc_dir_entry *gp_stats_file = NULL;
938 +//-----------------------------------------------------------------------------
939 +// Statistics related private functions.
940 +//-----------------------------------------------------------------------------
941 +static int cpmac_p_update_statistics(struct net_device *p_dev, char *buf, int limit, int *len);
942 +static int cpmac_p_read_rfc2665_stats(char *buf, char **start, off_t offset, int count, int *eof, void *data);
943 +static int cpmac_p_read_link(char *buf, char **start, off_t offset, int count, int *eof, void *data);
944 +static int cpmac_p_read_stats(char* buf, char **start, off_t offset, int count, int *eof, void *data);
945 +static int cpmac_p_write_stats (struct file *fp, const char * buf, unsigned long count, void * data);
946 +static int cpmac_p_reset_statistics (struct net_device *p_dev);
947 +static int cpmac_p_get_version(char *buf, char **start, off_t offset, int count, int *eof, void *data);
949 +static int cpmac_p_detect_manual_cfg(int, char*, int);
950 +static int cpmac_p_process_status_ind(CPMAC_PRIVATE_INFO_T *p_cpmac_priv);
952 +//-----------------------------------------------------------------------------
953 +// Timer related private functions.
954 +//-----------------------------------------------------------------------------
955 +static int cpmac_p_timer_init(CPMAC_PRIVATE_INFO_T *p_cpmac_priv);
956 +// static int cpmac_timer_cleanup(CPMAC_PRIVATE_INFO_T *p_cpmac_priv);
957 +static void cpmac_p_tick_timer_expiry(unsigned long p_cb_param);
958 +inline static int cpmac_p_start_timer(struct timer_list *p_timer, unsigned int delay_ticks);
959 +static int cpmac_p_stop_timer(struct timer_list *p_timer);
961 +//------------------------------------------------------------------------------
962 +// Device configuration and setup related private functions.
963 +//------------------------------------------------------------------------------
964 +static int cpmac_p_probe_and_setup_device(CPMAC_PRIVATE_INFO_T *p_cpmac_priv, unsigned long *p_dev_flags);
965 +static int cpmac_p_setup_driver_params(CPMAC_PRIVATE_INFO_T *p_cpmac_priv);
966 +inline static int cpmac_p_rx_buf_setup(CPMAC_RX_CHAN_INFO_T *p_rx_chan);
968 +//-----------------------------------------------------------------------------
969 +// Net device related private functions.
970 +//-----------------------------------------------------------------------------
971 +static int cpmac_dev_init(struct net_device *p_dev);
972 +static int cpmac_dev_open( struct net_device *dev );
973 +static int cpmac_dev_close(struct net_device *p_dev);
974 +static void cpmac_dev_mcast_set(struct net_device *p_dev);
975 +static int cpmac_dev_set_mac_addr(struct net_device *p_dev,void * addr);
976 +static int cpmac_dev_tx( struct sk_buff *skb, struct net_device *p_dev);
977 +static struct net_device_stats *cpmac_dev_get_net_stats (struct net_device *dev);
979 +static int cpmac_p_dev_enable( struct net_device *p_dev);
983 +/* Max. Reserved headroom in front of each packet so that the headers can be added to
984 + * a packet. Worst case scenario would be PPPoE + 2684 LLC Encapsulation + Ethernet
986 +#define MAX_RESERVED_HEADROOM 20
988 +/* This is the MAX size of the static buffer for pure data. */
989 +#define MAX_SIZE_STATIC_BUFFER 1600
991 +typedef struct DRIVER_BUFFER
993 + /* Pointer to the allocated data buffer. This is the static data buffer
994 + * allocated for the TI-Cache. 60 bytes out of the below buffer are required
995 + * by the SKB shared info. We always reserve at least MAX_RESERVED_HEADROOM bytes
996 + * so that the packets always have sufficient headroom. */
997 + char ptr_buffer[MAX_SIZE_STATIC_BUFFER + MAX_RESERVED_HEADROOM + 60];
999 + /* List of the driver buffers. */
1000 + struct DRIVER_BUFFER* ptr_next;
1003 +typedef struct DRIVER_BUFFER_MCB
1005 + /* List of the driver buffers. */
1006 + DRIVER_BUFFER* ptr_available_driver_buffers;
1008 + /* The number of available buffers. */
1009 + int num_available_buffers;
1010 +}DRIVER_BUFFER_MCB;
1012 +DRIVER_BUFFER_MCB driver_mcb;
1013 +int hybrid_mode = 0;
1016 + struct sk_buff_head list;
1017 + char pad[SMP_CACHE_BYTES];
1018 +} skb_head_pool[NR_CPUS];
1020 +/**************************************************************************
1021 + * FUNCTION NAME : ti_release_skb
1022 + **************************************************************************
1024 + * This function is called from the ti_alloc_skb when there were no more
1025 + * data buffers available. The allocated SKB had to released back to the
1026 + * data pool. The reason why this function was moved from the fast path
1027 + * below was because '__skb_queue_head' is an inline function which adds
1028 + * a large code chunk on the fast path.
1031 + * This function is called with interrupts disabled.
1032 + **************************************************************************/
1033 +static void ti_release_skb (struct sk_buff_head* list, struct sk_buff* skb)
1035 + __skb_queue_head(list, skb);
1039 +/**************************************************************************
1040 + * FUNCTION NAME : ti_alloc_skb
1041 + **************************************************************************
1043 + * The function is called to allocate memory from the static allocated
1044 + * TI-Cached memory pool.
1047 + * Allocated static memory buffer - Success
1049 + **************************************************************************/
1050 +struct sk_buff *ti_alloc_skb(unsigned int size,int gfp_mask)
1052 + register struct sk_buff* skb;
1053 + unsigned long flags;
1054 + struct sk_buff_head* list;
1055 + DRIVER_BUFFER* ptr_node = NULL;
1057 + /* Critical Section Begin: Lock out interrupts. */
1058 + local_irq_save(flags);
1060 + /* Get the SKB Pool list associated with the processor and dequeue the head. */
1061 + list = &skb_head_pool[smp_processor_id()].list;
1062 + skb = __skb_dequeue(list);
1064 + /* Align the data size. */
1065 + size = SKB_DATA_ALIGN(size);
1067 + /* Did we get one. */
1070 + /* YES. Now get a data block from the head of statically allocated block. */
1071 + ptr_node = driver_mcb.ptr_available_driver_buffers;
1072 + if (ptr_node != NULL)
1074 + /* YES. Got a data block. Advance the free list pointer to the next available buffer. */
1075 + driver_mcb.ptr_available_driver_buffers = ptr_node->ptr_next;
1076 + ptr_node->ptr_next = NULL;
1078 + /* Decrement the number of available data buffers. */
1079 + driver_mcb.num_available_buffers = driver_mcb.num_available_buffers - 1;
1083 + /* NO. Was unable to get a data block. So put the SKB back on the free list.
1084 + * This is slow path. */
1086 + printk ("DEBUG: No Buffer memory available: Number of free buffer:%d.\n",
1087 + driver_mcb.num_available_buffers);
1089 + ti_release_skb (list, skb);
1093 + /* Critical Section End: Unlock interrupts. */
1094 + local_irq_restore(flags);
1096 + /* Did we get an SKB and data buffer. Proceed only if we were succesful in getting both else drop */
1097 + if (skb != NULL && ptr_node != NULL)
1099 + /* XXX: does not include slab overhead */
1100 + skb->truesize = size + sizeof(struct sk_buff);
1102 + /* Load the data pointers. */
1103 + skb->head = ptr_node->ptr_buffer;
1104 + skb->data = ptr_node->ptr_buffer + MAX_RESERVED_HEADROOM;
1105 + skb->tail = ptr_node->ptr_buffer + MAX_RESERVED_HEADROOM;
1106 + skb->end = ptr_node->ptr_buffer + size + MAX_RESERVED_HEADROOM;
1108 + /* Set up other state */
1111 + skb->data_len = 0;
1113 + /* Mark the SKB indicating that the SKB is from the TI cache. */
1116 + atomic_set(&skb->users, 1);
1117 + atomic_set(&(skb_shinfo(skb)->dataref), 1);
1118 + skb_shinfo(skb)->nr_frags = 0;
1119 + skb_shinfo(skb)->frag_list = NULL;
1124 + /* Control comes here only when there is no statically allocated data buffers
1125 + * available. This case is handled using the mode selected
1128 + * In that case lets jump to the old allocation code. This way we
1129 + * can allocate a small number of data buffers upfront and the rest will hit
1130 + * this portion of the code, which is slow path. Note the number of hits here
1131 + * should be kept as low as possible to satisfy performance requirements.
1133 + * 2. Pure Static Mode.
1134 + * Return NULL the user should have tuned the number of static buffers for
1135 + * worst case scenario. So return NULL and let the drivers handle the error. */
1136 + if (hybrid_mode == 1)
1138 + /* Hybrid Mode: Old allocation. */
1139 + return dev_alloc_skb(size);
1143 + /* Pure Static Mode: No buffers available. */
1149 +/**************************************************************************
1150 + * FUNCTION NAME : ti_skb_release_fragment
1151 + **************************************************************************
1153 + * This function is called to release fragmented packets. This is NOT in
1154 + * the fast path and this function requires some work.
1155 + **************************************************************************/
1156 +static void ti_skb_release_fragment(struct sk_buff *skb)
1158 + if (skb_shinfo(skb)->nr_frags)
1160 + /* PANKAJ TODO: This portion has not been tested. */
1163 + printk ("DEBUG: Releasing fragments in TI-Cached code.\n");
1165 + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
1166 + printk ("DEBUG: Fragmented Page = 0x%p.\n", skb_shinfo(skb)->frags[i].page);
1169 + /* Check if there were any fragments present and if so clean all the SKB's.
1170 + * This is required to recursivly clean the SKB's. */
1171 + if (skb_shinfo(skb)->frag_list)
1172 + skb_drop_fraglist(skb);
1177 +/**************************************************************************
1178 + * FUNCTION NAME : ti_skb_release_data
1179 + **************************************************************************
1181 + * The function is called to release the SKB back into the TI-Cached static
1183 + **************************************************************************/
1184 +static void ti_skb_release_data(struct sk_buff *skb)
1186 + DRIVER_BUFFER* ptr_node;
1187 + unsigned long flags;
1189 + /* The SKB data can be cleaned only if the packet has not been cloned and we
1190 + * are the only one holding a reference to the data. */
1191 + if (!skb->cloned || atomic_dec_and_test(&(skb_shinfo(skb)->dataref)))
1193 + /* Are there any fragments associated with the SKB ?*/
1194 + if ((skb_shinfo(skb)->nr_frags != 0) || (skb_shinfo(skb)->frag_list != NULL))
1196 + /* Slow Path: Try and clean up the fragments. */
1197 + ti_skb_release_fragment (skb);
1200 + /* Cleanup the SKB data memory. This is fast path. */
1201 + ptr_node = (DRIVER_BUFFER *)skb->head;
1203 + /* Critical Section: Lock out interrupts. */
1204 + local_irq_save(flags);
1206 + /* Add the data buffer to the list of available buffers. */
1207 + ptr_node->ptr_next = driver_mcb.ptr_available_driver_buffers;
1208 + driver_mcb.ptr_available_driver_buffers = ptr_node;
1210 + /* Increment the number of available data buffers. */
1211 + driver_mcb.num_available_buffers = driver_mcb.num_available_buffers + 1;
1213 + /* Criticial Section: Unlock interrupts. */
1214 + local_irq_restore(flags);
1222 +static unsigned char str2hexnum(unsigned char c)
1224 + if(c >= '0' && c <= '9')
1226 + if(c >= 'a' && c <= 'f')
1227 + return c - 'a' + 10;
1228 + if(c >= 'A' && c <= 'F')
1229 + return c - 'A' + 10;
1233 +static void str2eaddr(unsigned char *ea, unsigned char *str)
1236 + unsigned char num;
1237 + for(i = 0; i < 6; i++) {
1238 + if((*str == '.') || (*str == ':'))
1240 + num = str2hexnum(*str++) << 4;
1241 + num |= (str2hexnum(*str++));
1246 +//-----------------------------------------------------------------------------
1247 +// Statistics related private functions.
1248 +//-----------------------------------------------------------------------------
1249 +static int cpmac_p_update_statistics(struct net_device *p_dev, char *buf, int limit, int *p_len)
1252 + unsigned long rx_hal_errors = 0;
1253 + unsigned long rx_hal_discards = 0;
1254 + unsigned long tx_hal_errors = 0;
1255 + unsigned long ifOutDiscards = 0;
1256 + unsigned long ifInDiscards = 0;
1257 + unsigned long ifOutErrors = 0;
1258 + unsigned long ifInErrors = 0;
1260 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_dev->priv;
1261 + CPMAC_DRV_HAL_INFO_T *p_drv_hal = p_cpmac_priv->drv_hal;
1262 + CPMAC_DEVICE_MIB_T *p_device_mib = p_cpmac_priv->device_mib;
1263 + CPMAC_DRV_STATS_T *p_stats = p_cpmac_priv->stats;
1264 + CPMAC_DEVICE_MIB_T local_mib;
1265 + CPMAC_DEVICE_MIB_T *p_local_mib = &local_mib;
1267 + struct net_device_stats *p_net_dev_stats = &p_cpmac_priv->net_dev_stats;
1270 + int dev_mib_elem_count = 0;
1272 + /* do not access the hardware if it is in the reset state. */
1273 + if(!test_bit(0, &p_cpmac_priv->set_to_close))
1275 + if(p_drv_hal->hal_funcs->Control(p_drv_hal->hal_dev, "StatsDump", "Get",
1276 + p_local_mib) != 0)
1278 + errPrint("The stats dump for %s is failing.\n", p_dev->name);
1282 + p_drv_hal->hal_funcs->Control(p_drv_hal->hal_dev, "StatsClear", "Set", NULL);
1284 + dev_mib_elem_count = sizeof(CPMAC_DEVICE_MIB_T)/sizeof(unsigned long);
1286 + /* Update the history of the stats. This takes care of any reset of the
1287 + * device and stats that might have taken place during the life time of
1290 + while(dev_mib_elem_count--)
1292 + *((unsigned long*) p_device_mib + dev_mib_elem_count) +=
1293 + *((unsigned long*) p_local_mib + dev_mib_elem_count);
1297 + /* RFC2665, section 3.2.7, page 9 */
1298 + rx_hal_errors = p_device_mib->ifInFragments +
1299 + p_device_mib->ifInCRCErrors +
1300 + p_device_mib->ifInAlignCodeErrors +
1301 + p_device_mib->ifInJabberFrames;
1304 + rx_hal_discards = p_device_mib->ifRxDMAOverruns;
1306 + /* RFC2665, section 3.2.7, page 9 */
1307 + tx_hal_errors = p_device_mib->ifExcessiveCollisionFrames +
1308 + p_device_mib->ifLateCollisions +
1309 + p_device_mib->ifCarrierSenseErrors +
1310 + p_device_mib->ifOutUnderrun;
1312 + /* if not set, the short frames (< 64 bytes) are considered as errors */
1313 + if(!p_cpmac_priv->flags & IFF_PRIV_SHORT_FRAMES)
1314 + rx_hal_errors += p_device_mib->ifInUndersizedFrames;
1316 + /* if not set, the long frames ( > 1518) are considered as errors
1317 + * RFC2665, section 3.2.7, page 9. */
1318 + if(!p_cpmac_priv->flags & IFF_PRIV_JUMBO_FRAMES)
1319 + rx_hal_errors += p_device_mib->ifInOversizedFrames;
1321 + /* if not in promiscous, then non addr matching frames are discarded */
1322 + /* CPMAC 2.0 Manual Section 2.8.1.14 */
1323 + if(!p_dev->flags & IFF_PROMISC)
1325 + ifInDiscards += p_device_mib->ifInFilteredFrames;
1328 + /* total rx discards = hal discards + driver discards. */
1329 + ifInDiscards = rx_hal_discards + p_net_dev_stats->rx_dropped;
1330 + ifInErrors = rx_hal_errors;
1332 + ifOutErrors = tx_hal_errors;
1333 + ifOutDiscards = p_net_dev_stats->tx_dropped;
1335 + /* Let us update the net device stats struct. To be updated in the later releases.*/
1336 + p_cpmac_priv->net_dev_stats.rx_errors = ifInErrors;
1337 + p_cpmac_priv->net_dev_stats.collisions = p_device_mib->ifCollisionFrames;
1339 + if(buf == NULL || limit == 0)
1345 + len+= sprintf(buf + len, "%-35s: %ld\n", "ifSpeed", (long)p_cpmac_priv->link_speed);
1347 + len+= sprintf(buf + len, "%-35s: %lu\n", "dot3StatsDuplexStatus", (long)p_cpmac_priv->link_mode);
1349 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifAdminStatus", (long)(p_dev->flags & IFF_UP ? 1:2));
1351 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifOperStatus", (long)(((p_dev->flags & IFF_UP) && netif_carrier_ok(p_dev)) ? 1:2));
1353 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifLastChange", p_stats->start_tick);
1355 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifInDiscards", ifInDiscards);
1357 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifInErrors", ifInErrors);
1359 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifOutDiscards", ifOutDiscards);
1361 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifOutErrors", ifOutErrors);
1363 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifInGoodFrames", p_device_mib->ifInGoodFrames);
1365 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifInBroadcasts", p_device_mib->ifInBroadcasts);
1367 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifInMulticasts", p_device_mib->ifInMulticasts);
1369 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifInPauseFrames", p_device_mib->ifInPauseFrames);
1371 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifInCRCErrors", p_device_mib->ifInCRCErrors);
1373 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifInAlignCodeErrors", p_device_mib->ifInAlignCodeErrors);
1375 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifInOversizedFrames", p_device_mib->ifInOversizedFrames);
1377 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifInJabberFrames", p_device_mib->ifInJabberFrames);
1379 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifInUndersizedFrames", p_device_mib->ifInUndersizedFrames);
1381 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifInFragments", p_device_mib->ifInFragments);
1383 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifInFilteredFrames", p_device_mib->ifInFilteredFrames);
1385 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifInQosFilteredFrames", p_device_mib->ifInQosFilteredFrames);
1387 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifInOctets", p_device_mib->ifInOctets);
1389 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifOutGoodFrames", p_device_mib->ifOutGoodFrames);
1391 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifOutBroadcasts", p_device_mib->ifOutBroadcasts);
1393 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifOutMulticasts", p_device_mib->ifOutMulticasts);
1395 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifOutPauseFrames", p_device_mib->ifOutPauseFrames);
1397 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifDeferredTransmissions", p_device_mib->ifDeferredTransmissions);
1399 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifCollisionFrames", p_device_mib->ifCollisionFrames);
1401 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifSingleCollisionFrames", p_device_mib->ifSingleCollisionFrames);
1403 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifMultipleCollisionFrames", p_device_mib->ifMultipleCollisionFrames);
1405 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifExcessiveCollisionFrames", p_device_mib->ifExcessiveCollisionFrames);
1407 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifLateCollisions", p_device_mib->ifLateCollisions);
1409 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifOutUnderrun", p_device_mib->ifOutUnderrun);
1411 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifCarrierSenseErrors", p_device_mib->ifCarrierSenseErrors);
1413 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifOutOctets", p_device_mib->ifOutOctets);
1415 + len+= sprintf(buf + len, "%-35s: %lu\n", "if64OctetFrames", p_device_mib->if64OctetFrames);
1417 + len+= sprintf(buf + len, "%-35s: %lu\n", "if65To127POctetFrames", p_device_mib->if65To127OctetFrames);
1419 + len+= sprintf(buf + len, "%-35s: %lu\n", "if128To255OctetFrames", p_device_mib->if128To255OctetFrames);
1421 + len+= sprintf(buf + len, "%-35s: %lu\n", "if256To511OctetFrames", p_device_mib->if256To511OctetFrames);
1423 + len+= sprintf(buf + len, "%-35s: %lu\n", "if512To1023OctetFrames", p_device_mib->if512To1023OctetFrames);
1425 + len+= sprintf(buf + len, "%-35s: %lu\n", "if1024ToUpOctetFrames", p_device_mib->if1024ToUPOctetFrames);
1427 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifNetOctets", p_device_mib->ifNetOctets);
1429 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifRxSofOverruns", p_device_mib->ifRxSofOverruns);
1431 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifRxMofOverruns", p_device_mib->ifRxMofOverruns);
1433 + len+= sprintf(buf + len, "%-35s: %lu\n", "ifRxDMAOverruns", p_device_mib->ifRxDMAOverruns);
1441 +static int cpmac_p_read_rfc2665_stats(char* buf, char **start, off_t offset,
1442 + int count, int *eof, void *data)
1444 + int limit = count - 80;
1446 + struct net_device *p_dev = (struct net_device*)data;
1448 + cpmac_p_update_statistics(p_dev, buf, limit, &len);
1455 +static int cpmac_p_read_link(char *buf, char **start, off_t offset, int count,
1456 + int *eof, void *data)
1460 + struct net_device *p_dev;
1461 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv;
1462 + struct net_device *cpmac_dev_list[cpmac_devices_installed];
1463 + CPMAC_DRV_HAL_INFO_T *p_drv_hal;
1466 + int phy; /* what phy are we using? */
1468 + len += sprintf(buf+len, "CPMAC devices = %d\n",cpmac_devices_installed);
1470 + p_dev = last_cpmac_device;
1472 + /* Reverse the the device link list to list eth0,eth1...in correct order */
1473 + for(i=0; i< cpmac_devices_installed; i++)
1475 + cpmac_dev_list[cpmac_devices_installed -(i+1)] = p_dev;
1476 + p_cpmac_priv = p_dev->priv;
1477 + p_dev = p_cpmac_priv->next_device;
1480 + for(i=0; i< cpmac_devices_installed; i++)
1482 + p_dev = cpmac_dev_list[i];
1483 + p_cpmac_priv = p_dev->priv;
1484 + p_drv_hal = p_cpmac_priv->drv_hal;
1486 + /* This prints them out from high to low because of how the devices are linked */
1487 + if(netif_carrier_ok(p_dev))
1489 + p_drv_hal->hal_funcs->Control(p_drv_hal->hal_dev, "PhyNum", "Get", &phy);
1492 + len += sprintf(buf+len,"eth%d: Link State: %s Phy:0x%x, Speed = %s, Duplex = %s\n",
1493 + p_cpmac_priv->instance_num, "UP", phy,
1494 + (p_cpmac_priv->link_speed == 100000000) ? "100":"10",
1495 + (p_cpmac_priv->link_mode == 2) ? "Half":"Full");
1499 + len += sprintf(buf+len,"eth%d: Link State: DOWN\n",p_cpmac_priv->instance_num);
1501 + p_dev = p_cpmac_priv->next_device;
1508 +static int cpmac_p_read_stats(char* buf, char **start, off_t offset, int count,
1509 + int *eof, void *data)
1511 + struct net_device *p_dev = last_cpmac_device;
1513 + int limit = count - 80;
1515 + struct net_device *cpmac_dev_list[cpmac_devices_installed];
1516 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv;
1517 + CPMAC_DEVICE_MIB_T *p_device_mib;
1519 + /* Reverse the the device link list to list eth0,eth1...in correct order */
1520 + for(i=0; i< cpmac_devices_installed; i++)
1522 + cpmac_dev_list[cpmac_devices_installed - (i+1)] = p_dev;
1523 + p_cpmac_priv = p_dev->priv;
1524 + p_dev = p_cpmac_priv->next_device;
1527 + for(i=0; i< cpmac_devices_installed; i++)
1529 + p_dev = cpmac_dev_list[i];
1535 + cpmac_p_update_statistics(p_dev, NULL, 0, NULL);
1537 + p_cpmac_priv = p_dev->priv;
1538 + p_device_mib = p_cpmac_priv->device_mib;
1540 + /* Transmit stats */
1542 + len+= sprintf(buf+len, "\nCpmac %d, Address %lx\n",i+1, p_dev->base_addr);
1544 + len+= sprintf(buf+len, " Transmit Stats\n");
1546 + len+= sprintf(buf+len, " Tx Valid Bytes Sent :%lu\n",p_device_mib->ifOutOctets);
1548 + len+= sprintf(buf+len, " Good Tx Frames (Hardware) :%lu\n",p_device_mib->ifOutGoodFrames);
1550 + len+= sprintf(buf+len, " Good Tx Frames (Software) :%lu\n",p_cpmac_priv->net_dev_stats.tx_packets);
1552 + len+= sprintf(buf+len, " Good Tx Broadcast Frames :%lu\n",p_device_mib->ifOutBroadcasts);
1554 + len+= sprintf(buf+len, " Good Tx Multicast Frames :%lu\n",p_device_mib->ifOutMulticasts);
1556 + len+= sprintf(buf+len, " Pause Frames Sent :%lu\n",p_device_mib->ifOutPauseFrames);
1558 + len+= sprintf(buf+len, " Collisions :%lu\n",p_device_mib->ifCollisionFrames);
1560 + len+= sprintf(buf+len, " Tx Error Frames :%lu\n",p_cpmac_priv->net_dev_stats.tx_errors);
1562 + len+= sprintf(buf+len, " Carrier Sense Errors :%lu\n",p_device_mib->ifCarrierSenseErrors);
1564 + len+= sprintf(buf+len, "\n");
1567 + /* Receive Stats */
1569 + len+= sprintf(buf+len, "\nCpmac %d, Address %lx\n",i+1,p_dev->base_addr);
1571 + len+= sprintf(buf+len, " Receive Stats\n");
1573 + len+= sprintf(buf+len, " Rx Valid Bytes Received :%lu\n",p_device_mib->ifInOctets);
1575 + len+= sprintf(buf+len, " Good Rx Frames (Hardware) :%lu\n",p_device_mib->ifInGoodFrames);
1577 + len+= sprintf(buf+len, " Good Rx Frames (Software) :%lu\n",p_cpmac_priv->net_dev_stats.rx_packets);
1579 + len+= sprintf(buf+len, " Good Rx Broadcast Frames :%lu\n",p_device_mib->ifInBroadcasts);
1581 + len+= sprintf(buf+len, " Good Rx Multicast Frames :%lu\n",p_device_mib->ifInMulticasts);
1583 + len+= sprintf(buf+len, " Pause Frames Received :%lu\n",p_device_mib->ifInPauseFrames);
1585 + len+= sprintf(buf+len, " Rx CRC Errors :%lu\n",p_device_mib->ifInCRCErrors);
1587 + len+= sprintf(buf+len, " Rx Align/Code Errors :%lu\n",p_device_mib->ifInAlignCodeErrors);
1589 + len+= sprintf(buf+len, " Rx Jabbers :%lu\n",p_device_mib->ifInOversizedFrames);
1591 + len+= sprintf(buf+len, " Rx Filtered Frames :%lu\n",p_device_mib->ifInFilteredFrames);
1593 + len+= sprintf(buf+len, " Rx Fragments :%lu\n",p_device_mib->ifInFragments);
1595 + len+= sprintf(buf+len, " Rx Undersized Frames :%lu\n",p_device_mib->ifInUndersizedFrames);
1597 + len+= sprintf(buf+len, " Rx Overruns :%lu\n",p_device_mib->ifRxDMAOverruns);
1608 +static int cpmac_p_write_stats (struct file *fp, const char * buf, unsigned long count, void * data)
1610 + char local_buf[31];
1615 + printk("Error : Buffer Overflow\n");
1616 + printk("Use \"echo 0 > cpmac_stat\" to reset the statistics\n");
1620 + copy_from_user(local_buf,buf,count);
1621 + local_buf[count-1]='\0'; /* Ignoring last \n char */
1624 + if(strcmp("0",local_buf)==0)
1626 + struct net_device *p_dev = last_cpmac_device;
1628 + struct net_device *cpmac_dev_list[cpmac_devices_installed];
1629 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv;
1631 + /* Valid command */
1632 + printk("Resetting statistics for CPMAC interface.\n");
1634 + /* Reverse the the device link list to list eth0,eth1...in correct order */
1635 + for(i=0; i< cpmac_devices_installed; i++)
1637 + cpmac_dev_list[cpmac_devices_installed - (i+1)] = p_dev;
1638 + p_cpmac_priv = p_dev->priv;
1639 + p_dev = p_cpmac_priv->next_device;
1642 + for(i=0; i< cpmac_devices_installed; i++)
1644 + p_dev = cpmac_dev_list[i];
1647 + ret_val = -EFAULT;
1651 + cpmac_p_reset_statistics(p_dev);
1656 + printk("Error: Unknown operation on cpmac statistics\n");
1657 + printk("Use \"echo 0 > cpmac_stats\" to reset the statistics\n");
1664 +static int cpmac_p_reset_statistics(struct net_device *p_dev)
1667 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_dev->priv;
1668 + CPMAC_DRV_HAL_INFO_T *p_drv_hal = p_cpmac_priv->drv_hal;
1670 + memset(p_cpmac_priv->device_mib, 0, sizeof(CPMAC_DEVICE_MIB_T));
1671 + memset(p_cpmac_priv->stats, 0, sizeof(CPMAC_DRV_STATS_T));
1672 + memset(&p_cpmac_priv->net_dev_stats, 0, sizeof(struct net_device_stats));
1674 + p_drv_hal->hal_funcs->Control(p_drv_hal->hal_dev, "StatsClear", "Set", NULL);
1679 +static int cpmac_p_get_version(char* buf, char **start, off_t offset, int count,int *eof, void *data)
1682 + int limit = count - 80;
1683 + char *hal_version = NULL;
1684 + struct net_device *p_dev = last_cpmac_device;
1685 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_dev->priv;
1686 + CPMAC_DRV_HAL_INFO_T *p_drv_hal = p_cpmac_priv->drv_hal;
1688 + p_drv_hal->hal_funcs->Control(p_drv_hal->hal_dev, "Version", "Get", &hal_version);
1690 + len += sprintf(buf+len, "Texas Instruments CPMAC driver version: %s\n", cpmac_version);
1692 + if(len <= limit && hal_version)
1693 + len += sprintf(buf+len, "Texas Instruments CPMAC HAL version: %s\n", hal_version);
1698 +static struct net_device_stats *cpmac_dev_get_net_stats (struct net_device *p_dev)
1700 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = (CPMAC_PRIVATE_INFO_T *) p_dev->priv;
1702 + cpmac_p_update_statistics(p_dev, NULL, 0, NULL);
1704 + return &p_cpmac_priv->net_dev_stats;
1707 +static int cpmac_p_detect_manual_cfg(int link_speed, char* link_mode, int debug)
1709 + char *pSpeed = NULL;
1713 + cpmac_debug_mode = 1;
1714 + dbgPrint("Enabled the debug print.\n");
1717 + if(!link_speed && !link_mode)
1719 + dbgPrint("No manual link params, defaulting to auto negotiation.\n");
1723 + if(!link_speed || (link_speed != 10 && link_speed != 100))
1725 + dbgPrint("Invalid or No value of link speed specified, defaulting to auto speed.\n");
1728 + else if(link_speed == 10)
1730 + g_cfg_start_link_params &= ~(_CPMDIO_100);
1731 + pSpeed = "10 Mbps";
1735 + g_cfg_start_link_params &= ~(_CPMDIO_10);
1736 + pSpeed = "100 Mbps";
1739 + if(!link_mode || (!strcmp(link_mode, "fd") && !strcmp(link_mode, "hd")))
1741 + dbgPrint("Invalid or No value of link mode specified, defaulting to auto mode.\n");
1743 + else if(!strcmp(link_mode, "hd"))
1745 + g_cfg_start_link_params &= ~(_CPMDIO_FD);
1749 + g_cfg_start_link_params &= ~(_CPMDIO_HD);
1752 + dbgPrint("Link is manually set to the speed of %s speed and %s mode.\n",
1753 + pSpeed, link_mode ? link_mode : "auto");
1758 +//------------------------------------------------------------------------------
1759 +// Call back from the HAL.
1760 +//------------------------------------------------------------------------------
1761 +static int cpmac_p_process_status_ind(CPMAC_PRIVATE_INFO_T *p_cpmac_priv)
1763 + struct net_device *p_dev = p_cpmac_priv->owner;
1764 + CPMAC_DRV_HAL_INFO_T *p_drv_hal = p_cpmac_priv->drv_hal;
1767 + p_drv_hal->hal_funcs->Control(p_drv_hal->hal_dev, "Status", "Get", &status);
1769 + /* We do not reflect the real link status if in loopback.
1770 + * After all, we want the packets to reach the hardware so
1771 + * that Send() should work. */
1772 + if(p_dev->flags & IFF_LOOPBACK)
1774 + dbgPrint("Maintaining the link up loopback for %s.\n", p_dev->name);
1775 + netif_carrier_on(p_dev);
1777 +//#if defined (CONFIG_MIPS_AVALANCHE_LED)
1778 +// avalanche_led_action(p_cpmac_priv->led_handle, CPMAC_LINK_ON);
1784 + if(status & CPMAC_STATUS_ADAPTER_CHECK) /* ???? */
1786 + ; /* what to do ? */
1790 + if(!netif_carrier_ok(p_dev))
1792 + netif_carrier_on(p_cpmac_priv->owner);
1794 +//#if defined (CONFIG_MIPS_AVALANCHE_LED)
1795 +// avalanche_led_action(p_cpmac_priv->led_handle, CPMAC_LINK_ON);
1797 + dbgPrint("Found the Link for the CPMAC instance %s.\n", p_dev->name);
1800 + if(netif_running(p_dev) & netif_queue_stopped(p_dev))
1802 + netif_wake_queue(p_dev);
1805 + p_cpmac_priv->link_speed = status & CPMAC_STATUS_LINK_SPEED ? 100000000:10000000;
1806 + p_cpmac_priv->link_mode = status & CPMAC_STATUS_LINK_DUPLEX? 3:2;
1811 + if(netif_carrier_ok(p_dev))
1813 + /* do we need to register synchronization issues with stats here. */
1814 + p_cpmac_priv->link_speed = 100000000;
1815 + p_cpmac_priv->link_mode = 1;
1817 + netif_carrier_off(p_dev);
1819 +//#if defined (CONFIG_MIPS_AVALANCHE_LED)
1820 +// avalanche_led_action(p_cpmac_priv->led_handle, CPMAC_LINK_OFF);
1823 + dbgPrint("Lost the Link for the CPMAC for %s.\n", p_dev->name);
1826 + if(!netif_queue_stopped(p_dev))
1828 + netif_stop_queue(p_dev); /* So that kernel does not keep on xmiting pkts. */
1835 +//-----------------------------------------------------------------------------
1836 +// Timer related private functions.
1837 +//-----------------------------------------------------------------------------
1838 +static int cpmac_p_timer_init(CPMAC_PRIVATE_INFO_T *p_cpmac_priv)
1840 + struct timer_list *p_timer = p_cpmac_priv->timer;
1842 + init_timer(p_timer);
1844 + p_timer = p_cpmac_priv->timer + TICK_TIMER;
1845 + p_timer->expires = 0;
1846 + p_timer->data = (unsigned long)p_cpmac_priv;
1847 + p_timer->function = cpmac_p_tick_timer_expiry;
1853 +static int cpmac_timer_cleanup(CPMAC_PRIVATE_INFO_T *p_cpmac_priv)
1855 + struct timer_list *p_timer;
1857 + p_timer = p_cpmac_priv->timer + TICK_TIMER;
1859 + /* use spin lock to establish synchronization with the dispatch */
1860 + if(p_timer->function) del_timer_sync(p_timer);
1861 + p_timer->function = NULL;
1867 +static int cpmac_p_start_timer(struct timer_list *p_timer, unsigned int delay_ticks)
1869 + p_timer->expires = jiffies + delay_ticks;
1871 + if(p_timer->function)
1873 + add_timer(p_timer);
1879 +static void cpmac_p_tick_timer_expiry(unsigned long p_cb_param)
1881 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = (CPMAC_PRIVATE_INFO_T*) p_cb_param;
1882 + CPMAC_DRV_HAL_INFO_T *p_drv_hal = p_cpmac_priv->drv_hal;
1883 + struct timer_list *p_timer = p_cpmac_priv->timer + TICK_TIMER;
1885 + if(test_bit(0, &p_cpmac_priv->set_to_close))
1890 + p_drv_hal->hal_funcs->Tick(p_drv_hal->hal_dev);
1892 + cpmac_p_start_timer(p_timer, p_cpmac_priv->delay_ticks);
1895 +static int cpmac_p_stop_timer(struct timer_list *p_timer)
1897 + /* Ideally we need to a set flag indicating not to start the timer again
1898 + before del_timer_sync() is called up. But here we assume that the
1899 + caller has set the p_cpmac_priv->set_to_close (ok for now). */
1900 + del_timer_sync(p_timer);
1905 +//------------------------------------------------------------------------------
1906 +// Device configuration and setup related private functions.
1907 +//------------------------------------------------------------------------------
1908 +static int cpmac_p_probe_and_setup_device(CPMAC_PRIVATE_INFO_T *p_cpmac_priv,
1909 + unsigned long *p_dev_flags)
1911 + CPMAC_DRV_HAL_INFO_T *p_drv_hal = p_cpmac_priv->drv_hal;
1912 + HAL_FUNCTIONS *p_hal_funcs = p_drv_hal->hal_funcs;
1913 + HAL_DEVICE *p_hal_dev = p_drv_hal->hal_dev;
1914 + CPMAC_ABILITY_INFO_T *p_capability= p_cpmac_priv->ability_info;
1915 + unsigned int val = 0;
1918 + p_cpmac_priv->flags = 0;
1920 + p_capability->promiscous = CFG_PROMISCOUS;
1921 + p_capability->broadcast = CFG_BROADCAST;
1922 + p_capability->multicast = CFG_MULTICAST;
1923 + p_capability->all_multi = CFG_ALL_MULTI;
1924 + p_capability->jumbo_frames = CFG_JUMBO_FRAMES;
1925 + p_capability->short_frames = CFG_SHORT_FRAMES;
1926 + p_capability->auto_negotiation = CFG_AUTO_NEGOTIATION;
1927 + p_capability->link_speed = cfg_start_link_speed;
1928 + p_capability->loop_back = CFG_LOOP_BACK;
1929 + p_capability->tx_flow_control = CFG_TX_FLOW_CNTL;
1930 + p_capability->rx_flow_control = CFG_RX_FLOW_CNTL;
1931 + p_capability->tx_pacing = CFG_TX_PACING;
1932 + p_capability->rx_pass_crc = CFG_RX_PASS_CRC;
1933 + p_capability->qos_802_1q = CFG_QOS_802_1Q;
1934 + p_capability->tx_num_chan = CFG_TX_NUM_CHAN;
1936 + /* Lets probe the device for the configured capabilities (netdev specific).*/
1938 + /* Following are set in the set_multi_list, when indicated by the kernel
1939 + * Promiscous and all multi.
1942 + if(p_capability->broadcast)
1946 + if((p_hal_funcs->Control(p_hal_dev, pszRX_BROAD_EN, pszSet, &val) == 0) &&
1947 + (p_hal_funcs->Control(p_hal_dev, pszRX_BROAD_CH, pszSet, &channel) == 0))
1948 + *p_dev_flags |= IFF_BROADCAST;
1950 + p_capability->broadcast = 0; /* no broadcast capabilities */
1953 + if(p_capability->multicast)
1957 + if((p_hal_funcs->Control(p_hal_dev, pszRX_MULT_EN, pszSet, &val) == 0) &&
1958 + (p_hal_funcs->Control(p_hal_dev, pszRX_MULT_CH, pszSet, &channel) == 0))
1959 + *p_dev_flags |= IFF_MULTICAST;
1962 + p_capability->multicast = 0;
1963 + p_capability->all_multi = 0; /* no multicast, no all-multi. */
1967 + if(p_capability->loop_back)
1969 + ; /* We do not put the device in loopback, if required use ioctl */
1972 + /* Lets probe the device for the configured capabilities (Non net device specific).*/
1974 + if(p_capability->jumbo_frames)
1977 + if(p_hal_funcs->Control(p_hal_dev, pszRX_NO_CHAIN, pszSet, &val) == 0)
1978 + p_cpmac_priv->flags |= IFF_PRIV_JUMBO_FRAMES;
1980 + p_capability->jumbo_frames = 0;
1983 + if(p_capability->short_frames)
1986 + if(p_hal_funcs->Control(p_hal_dev, pszRX_CSF_EN, pszSet, &val) == 0)
1987 + p_cpmac_priv->flags |= IFF_PRIV_SHORT_FRAMES;
1989 + p_capability->short_frames = 0;
1992 + val = g_cfg_start_link_params;
1994 +#ifdef CONFIG_AR7_MDIX
1995 + if( avalanche_is_mdix_on_chip() )
1997 + val |= _CPMDIO_AUTOMDIX;
2001 + if(p_hal_funcs->Control(p_hal_dev,pszMdioConnect,pszSet, &val) !=0)
2003 + p_capability->link_speed = 0;
2007 + if(g_cfg_start_link_params & (_CPMDIO_100 | _CPMDIO_HD | _CPMDIO_FD | _CPMDIO_10))
2008 + p_cpmac_priv->flags |= IFF_PRIV_AUTOSPEED;
2009 + else if(g_cfg_start_link_params & (_CPMDIO_100 | _CPMDIO_HD))
2010 + p_cpmac_priv->flags |= IFF_PRIV_LINK100_HD;
2011 + else if(g_cfg_start_link_params & (_CPMDIO_100 | _CPMDIO_FD))
2012 + p_cpmac_priv->flags |= IFF_PRIV_LINK100_FD;
2013 + else if(g_cfg_start_link_params & (_CPMDIO_10 | _CPMDIO_HD))
2014 + p_cpmac_priv->flags |= IFF_PRIV_LINK10_HD;
2015 + else if(g_cfg_start_link_params & (_CPMDIO_10 | _CPMDIO_FD))
2016 + p_cpmac_priv->flags |= IFF_PRIV_LINK10_FD;
2021 + if(p_capability->tx_flow_control)
2024 + if(p_hal_funcs->Control(p_hal_dev,pszTX_FLOW_EN, pszSet, &val) ==0)
2025 + p_cpmac_priv->flags |= IFF_PRIV_TX_FLOW_CNTL;
2027 + p_capability->tx_flow_control = 0;
2030 + if(p_capability->rx_flow_control)
2033 + if(p_hal_funcs->Control(p_hal_dev, pszRX_FLOW_EN, pszSet, &val) ==0)
2034 + p_cpmac_priv->flags |= IFF_PRIV_RX_FLOW_CNTL;
2036 + p_capability->rx_flow_control = 0;
2039 + if(p_capability->tx_pacing)
2042 + if(p_hal_funcs->Control(p_hal_dev, pszTX_PACE, pszSet, &val) ==0)
2043 + p_cpmac_priv->flags |= IFF_PRIV_TX_PACING;
2045 + p_capability->tx_pacing = 0;
2048 + if(p_capability->rx_pass_crc)
2051 + if(p_hal_funcs->Control(p_hal_dev, pszRX_PASS_CRC, pszSet, &val) == 0)
2052 + p_cpmac_priv->flags |= IFF_PRIV_RX_PASS_CRC;
2054 + p_capability->rx_pass_crc = 0;
2057 + if(p_capability->qos_802_1q)
2060 + if(p_hal_funcs->Control(p_hal_dev, pszRX_QOS_EN, pszSet, &val) == 0)
2061 + p_cpmac_priv->flags |= IFF_PRIV_8021Q_EN;
2064 + p_capability->qos_802_1q = 0;
2065 + p_capability->tx_num_chan= 1;
2069 + if(p_capability->tx_num_chan > 1)
2071 + int cfg_tx_num_chan = p_capability->tx_num_chan;
2074 + if(p_hal_funcs->Control(p_hal_dev, pszTX_NUM_CH, pszGet, &val) == 0)
2075 + cfg_tx_num_chan = cfg_tx_num_chan > val ? val : cfg_tx_num_chan;
2077 + cfg_tx_num_chan = 1;
2079 + p_capability->tx_num_chan = cfg_tx_num_chan;
2085 +static int cpmac_p_setup_driver_params(CPMAC_PRIVATE_INFO_T *p_cpmac_priv)
2088 + int threshold = CFG_TX_NUM_BUF_SERVICE;
2090 + char *tx_threshold_ptr = prom_getenv("threshold");
2092 + CPMAC_TX_CHAN_INFO_T *p_tx_chan_info = p_cpmac_priv->tx_chan_info;
2093 + CPMAC_RX_CHAN_INFO_T *p_rx_chan_info = p_cpmac_priv->rx_chan_info;
2094 + CPMAC_ABILITY_INFO_T *p_capability = p_cpmac_priv->ability_info;
2097 + p_cpmac_priv->timer_count = 1; /* should be < or = the MAX TIMER */
2098 + p_cpmac_priv->timer_created = 0;
2099 + p_cpmac_priv->timer_access_hal = 1;
2101 + for(i=0; i < MAX_TIMER; i++)
2102 + p_cpmac_priv->timer[i].function = NULL;
2104 + p_cpmac_priv->enable_802_1q = p_capability->qos_802_1q;
2106 + /* Tx channel related.*/
2107 + p_tx_chan_info->cfg_chan = p_capability->tx_num_chan;
2108 + p_tx_chan_info->opened_chan = 0;
2110 + if(tx_threshold_ptr)
2111 + threshold = simple_strtol(tx_threshold_ptr, (char **)NULL, 10);
2113 + if((threshold <= 0) && tx_threshold_ptr) /* If threshold set to 0 then Enable the TX interrupt */
2115 + threshold = CFG_TX_NUM_BUF_SERVICE;
2116 + p_tx_chan_info->tx_int_disable = 0;
2121 + p_tx_chan_info->tx_int_disable = CFG_TX_INT_DISABLE;
2124 + for(i=0; i < MAX_TX_CHAN; i++)
2129 + p_tx_chan_info->chan[i].state = CHAN_CLOSE;
2130 + p_tx_chan_info->chan[i].num_BD = CFG_TX_NUM_BUF_DESC;
2131 + p_tx_chan_info->chan[i].buffer_size = cpmac_max_frame_size;
2132 + p_tx_chan_info->chan[i].buffer_offset = CFG_TX_BUF_OFFSET;
2136 + p_tx_chan_info->chan[i].service_max = threshold;
2139 + if (p_tx_chan_info->tx_int_disable)
2140 + printk("Cpmac driver Disable TX complete interrupt setting threshold to %d.\n",threshold);
2142 + printk("Cpmac driver Enable TX complete interrupt\n");
2145 + /* Assuming just one rx channel for now */
2146 + p_rx_chan_info->cfg_chan = 1;
2147 + p_rx_chan_info->opened_chan = 0;
2148 + p_rx_chan_info->chan->state = CHAN_CLOSE;
2149 + p_rx_chan_info->chan->num_BD = CFG_RX_NUM_BUF_DESC;
2150 + p_rx_chan_info->chan->buffer_size = cpmac_max_frame_size;
2151 + p_rx_chan_info->chan->buffer_offset = CFG_RX_BUF_OFFSET;
2152 + p_rx_chan_info->chan->service_max = CFG_RX_NUM_BUF_SERVICE;
2154 + /* Set as per RFC 2665 */
2155 + p_cpmac_priv->link_speed = 100000000;
2156 + p_cpmac_priv->link_mode = 1;
2158 + p_cpmac_priv->loop_back = 0;
2163 +inline static int cpmac_p_rx_buf_setup(CPMAC_RX_CHAN_INFO_T *p_rx_chan)
2165 + /* Number of ethernet packets & max pkt length */
2166 + p_rx_chan->chan->tot_buf_size = p_rx_chan->chan->buffer_size +
2167 + 2*(CONTROL_802_1Q_SIZE) +
2168 + p_rx_chan->chan->buffer_offset +
2169 + ADD_FOR_4BYTE_ALIGN(p_rx_chan->chan->buffer_offset & 0x3);
2171 + p_rx_chan->chan->tot_reserve_bytes = CONTROL_802_1Q_SIZE +
2172 + p_rx_chan->chan->buffer_offset +
2173 + L3_ALIGN(p_rx_chan->chan->buffer_offset & 0x3);
2178 +//-----------------------------------------------------------------------------
2179 +// Net device related private functions.
2180 +//-----------------------------------------------------------------------------
2182 +/***************************************************************
2186 + * 0 on success, error code otherwise.
2188 + * dev The structure of the device to be
2191 + * This function completes the initialization of the
2192 + * device structure and driver. It reserves the IO
2193 + * addresses and assignes the device's methods.
2196 + **************************************************************/
2198 +static int cpmac_dev_init(struct net_device *p_dev)
2201 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_dev->priv;
2202 + int instance_num = p_cpmac_priv->instance_num;
2203 + unsigned long net_flags = 0;
2204 + char *mac_name = NULL;
2205 + char *mac_string = NULL;
2207 + CPMAC_TX_CHAN_INFO_T *p_tx_chan_info;
2208 + CPMAC_RX_CHAN_INFO_T *p_rx_chan_info;
2209 + CPMAC_DRV_HAL_INFO_T *p_drv_hal;
2212 + int mem_size = sizeof(CPMAC_DRV_HAL_INFO_T)
2213 + + sizeof(CPMAC_TX_CHAN_INFO_T)
2214 + + sizeof(CPMAC_RX_CHAN_INFO_T)
2215 + + sizeof(CPMAC_ABILITY_INFO_T)
2216 + + sizeof(CPMAC_DEVICE_MIB_T)
2217 + + sizeof(CPMAC_DRV_STATS_T);
2220 +#if defined(CONFIG_MIPS_SEAD2)
2221 + int prev_reset_val = RESET_REG_PRCR;
2222 + /* Bring the module out of reset */
2223 + RESET_REG_PRCR |= temp_reset_value[p_cpmac_priv->instance_num];
2225 + /* Read the version id of the device to check if the device really exists */
2226 + if( VERSION(temp_base_address[p_cpmac_priv->instance_num]) == 0)
2228 + printk(" CPMAC:Device not found\n");
2229 + RESET_REG_PRCR = prev_reset_val;
2233 + RESET_REG_PRCR = prev_reset_val;
2237 + if((p_drv_hal = kmalloc(mem_size, GFP_KERNEL)) == NULL)
2239 + errPrint("Failed to allocate memory; rewinding.\n");
2243 + memset(p_drv_hal, 0, mem_size);
2245 + /* build the cpmac private object */
2246 + p_cpmac_priv->drv_hal = p_drv_hal;
2247 + p_cpmac_priv->tx_chan_info = p_tx_chan_info
2248 + = (CPMAC_TX_CHAN_INFO_T*)((char*)p_drv_hal
2249 + + sizeof(CPMAC_DRV_HAL_INFO_T));
2250 + p_cpmac_priv->rx_chan_info = p_rx_chan_info
2251 + = (CPMAC_RX_CHAN_INFO_T*)((char *)p_tx_chan_info
2252 + + sizeof(CPMAC_TX_CHAN_INFO_T));
2253 + p_cpmac_priv->ability_info = (CPMAC_ABILITY_INFO_T *)((char *)p_rx_chan_info
2254 + + sizeof(CPMAC_RX_CHAN_INFO_T));
2255 + p_cpmac_priv->device_mib = (CPMAC_DEVICE_MIB_T *)((char *)p_cpmac_priv->ability_info
2256 + + sizeof(CPMAC_ABILITY_INFO_T));
2257 + p_cpmac_priv->stats = (CPMAC_DRV_STATS_T *)((char *)p_cpmac_priv->device_mib
2258 + + sizeof(CPMAC_DEVICE_MIB_T));
2260 + p_drv_hal->owner = p_cpmac_priv;
2263 + switch(instance_num)
2269 + /* Also setting port information */
2270 + p_dev->if_port = AVALANCHE_CPMAC_LOW_PORT_ID;
2277 + /* Also setting port information */
2278 + p_dev->if_port = AVALANCHE_CPMAC_HIGH_PORT_ID;
2284 + mac_string=prom_getenv(mac_name);
2288 + mac_string="08.00.28.32.06.02";
2289 + printk("Error getting mac from Boot enviroment for %s\n",p_dev->name);
2290 + printk("Using default mac address: %s\n",mac_string);
2293 + printk("Use Bootloader command:\n");
2294 + printk(" setenv %s xx.xx.xx.xx.xx.xx\n","<env_name>");
2295 + printk("to set mac address\n");
2299 + str2eaddr(p_cpmac_priv->mac_addr,mac_string);
2301 + for (i=0; i <= ETH_ALEN; i++)
2303 + /* This sets the hardware address */
2304 + p_dev->dev_addr[i] = p_cpmac_priv->mac_addr[i];
2307 + p_cpmac_priv->set_to_close = 1;
2308 + p_cpmac_priv->non_data_irq_expected = 0;
2310 +//#if defined (CONFIG_MIPS_AVALANCHE_LED)
2311 +// if((p_cpmac_priv->led_handle = avalanche_led_register("cpmac", instance_num)) == NULL)
2313 +// errPrint("Could not allocate handle for CPMAC[%d] LED.\n", instance_num);
2314 +// goto cpmac_init_mod_error;
2318 + if(cpmac_drv_init_module(p_drv_hal, p_dev, instance_num) != 0)
2320 + errPrint("Could not initialize the HAL for %s.\n", p_dev->name);
2321 + goto cpmac_init_mod_error;
2324 + /* initialize the CPMAC device */
2325 + if (cpmac_drv_init(p_drv_hal) == -1)
2327 + errPrint("HAL init failed for %s.\n", p_dev->name);
2328 + goto cpmac_init_device_error;
2331 + if(cpmac_p_probe_and_setup_device(p_cpmac_priv, &net_flags) == -1)
2333 + errPrint("Failed to configure up %s.\n", p_dev->name);
2334 + goto cpmac_init_device_error;
2337 + if(cpmac_p_setup_driver_params(p_cpmac_priv) == -1)
2339 + errPrint("Failed to set driver parameters for %s.\n", p_dev->name);
2340 + goto cpmac_init_device_error;
2343 + cpmac_p_rx_buf_setup(p_rx_chan_info);
2345 + /* initialize the timers for the net device */
2346 + if(cpmac_p_timer_init(p_cpmac_priv) == -1)
2348 + errPrint("Failed to set timer(s) for %s.\n", p_dev->name);
2349 + goto cpmac_timer_init_error;
2352 + p_dev->addr_len = 6;
2354 + p_dev->open = &cpmac_dev_open; /* i.e. Start Device */
2355 + p_dev->hard_start_xmit = &cpmac_dev_tx;
2356 + p_dev->stop = &cpmac_dev_close;
2357 + p_dev->get_stats = &cpmac_dev_get_net_stats;
2359 + p_dev->set_multicast_list = &cpmac_dev_mcast_set;
2360 + p_dev->set_mac_address = cpmac_dev_set_mac_addr;
2361 + /* Knocking off the default broadcast and multicast flags. Allowing the
2362 + device configuration to control the flags. */
2363 + p_dev->flags &= ~(IFF_BROADCAST | IFF_MULTICAST);
2364 + p_dev->flags |= net_flags;
2366 + netif_carrier_off(p_dev);
2368 +//#if defined (CONFIG_MIPS_AVALANCHE_LED)
2369 +// avalanche_led_action(p_cpmac_priv->led_handle, CPMAC_LINK_OFF);
2372 + /* Tasklet is initialized at the isr registeration time. */
2373 + p_drv_hal->hal_funcs->Control(p_drv_hal->hal_dev, "CpmacBase", "Get", &p_dev->base_addr);
2374 + p_drv_hal->hal_funcs->Control(p_drv_hal->hal_dev, "CpmacSize", "Get", &p_cpmac_priv->dev_size);
2376 + request_mem_region(p_dev->base_addr, p_cpmac_priv->dev_size, p_dev->name);
2380 + if(g_init_enable_flag)
2381 + cpmac_p_dev_enable(p_dev);
2385 +cpmac_timer_init_error:
2386 +cpmac_init_device_error :
2387 + cpmac_drv_cleanup(p_drv_hal);
2389 +cpmac_init_mod_error:
2394 +} /* cpmac_dev_init */
2397 +/***************************************************************
2398 + * cpmac_p_dev_enable
2401 + * 0 on success, error code otherwise.
2403 + * dev Structure of device to be opened.
2405 + * This routine puts the driver and CPMAC adapter in a
2406 + * state where it is ready to send and receive packets.
2409 + **************************************************************/
2410 +int cpmac_p_dev_enable( struct net_device *p_dev)
2415 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_dev->priv;
2416 + CPMAC_DRV_HAL_INFO_T *p_drv_hal = p_cpmac_priv->drv_hal;
2417 + CPMAC_RX_CHAN_INFO_T *p_rx_chan_info = p_cpmac_priv->rx_chan_info;
2418 + int max_length = p_rx_chan_info->chan->tot_buf_size;
2420 + p_cpmac_priv->set_to_close = 0;
2422 + if((ret_val = cpmac_drv_start(p_drv_hal, p_cpmac_priv->tx_chan_info,
2423 + p_cpmac_priv->rx_chan_info, CHAN_SETUP))==-1)
2425 + errPrint("%s error: failed to start the device.\n", p_dev->name);
2428 + else if(p_drv_hal->hal_funcs->Control(p_drv_hal->hal_dev,"RX_UNICAST_SET",
2429 + "Set", &channel)!=0)
2431 + errPrint("%s error: device chan 0 could not be enabled.\n", p_dev->name);
2434 + else if(p_drv_hal->hal_funcs->Control(p_drv_hal->hal_dev, pszRX_MAXLEN, pszSet, &max_length) != 0)
2436 + errPrint(" CPMAC registers can't be written \n");
2439 + else if(p_drv_hal->hal_funcs->Control(p_drv_hal->hal_dev, "TxIntDisable", "Set",
2440 + &p_cpmac_priv->tx_chan_info->tx_int_disable) != 0)
2442 + errPrint(" CPMAC registers can't be written \n");
2447 + ; // Every thing went OK.
2451 +} /* cpmac_dev_enable */
2454 +static int cpmac_dev_open(struct net_device *p_dev)
2456 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_dev->priv;
2457 + CPMAC_ISR_INFO_T *p_isr_cb_param = &p_cpmac_priv->cpmac_isr;
2459 + if(!g_init_enable_flag)
2460 + cpmac_p_dev_enable(p_dev);
2462 + if(request_irq(p_isr_cb_param->intr, cpmac_hal_isr, SA_INTERRUPT,
2463 + "Cpmac Driver", p_isr_cb_param))
2465 + errPrint("Failed to register the irq %d for Cpmac %s.\n",
2466 + p_isr_cb_param->intr, p_dev->name);
2470 + netif_start_queue(p_dev);
2472 + MOD_INC_USE_COUNT;
2473 + p_cpmac_priv->stats->start_tick = jiffies;
2474 + dbgPrint("Started the network queue for %s.\n", p_dev->name);
2478 +/***************************************************************
2479 + * cpmac_p_dev_disable
2484 + * dev The device structure of the device to
2487 + * This function shuts down the adapter.
2489 + **************************************************************/
2490 +int cpmac_p_dev_disable(struct net_device *p_dev)
2493 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_dev->priv;
2494 + CPMAC_DRV_HAL_INFO_T *p_drv_hal = p_cpmac_priv->drv_hal;
2496 + set_bit(0, &p_cpmac_priv->set_to_close);
2497 + set_bit(0, &p_cpmac_priv->non_data_irq_expected);
2499 + /* The driver does not re-schedule the tasklet after kill is called. So, this
2500 + should take care of the bug in the kernel. */
2501 + tasklet_kill(&p_cpmac_priv->cpmac_isr.tasklet);
2503 + if(cpmac_drv_stop(p_drv_hal, p_cpmac_priv->tx_chan_info,
2504 + p_cpmac_priv->rx_chan_info,
2505 + CHAN_TEARDOWN | FREE_BUFFER | BLOCKING | COMPLETE) == -1)
2511 + /* hope that the HAL closes down the tick timer.*/
2513 + dbgPrint("Device %s Closed.\n", p_dev->name);
2514 + p_cpmac_priv->stats->start_tick = jiffies;
2516 + p_cpmac_priv->link_speed = 100000000;
2517 + p_cpmac_priv->link_mode = 1;
2518 + netif_carrier_off(p_dev);
2520 +//#if defined (CONFIG_MIPS_AVALANCHE_LED)
2521 +// avalanche_led_action(p_cpmac_priv->led_handle, CPMAC_LINK_OFF);
2524 + clear_bit(0, &p_cpmac_priv->non_data_irq_expected);
2530 +} /* cpmac_dev_close */
2533 +/***************************************************************
2539 + * dev The device structure of the device to
2542 + * This function shuts down the adapter.
2544 + **************************************************************/
2545 +static int cpmac_dev_close(struct net_device *p_dev)
2547 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_dev->priv;
2548 + CPMAC_ISR_INFO_T *p_isr_cb_param = &p_cpmac_priv->cpmac_isr;
2550 + /* inform the upper layers. */
2551 + netif_stop_queue(p_dev);
2553 + if(!g_init_enable_flag)
2554 + cpmac_p_dev_disable(p_dev);
2556 + free_irq(p_isr_cb_param->intr, p_isr_cb_param);
2558 + MOD_DEC_USE_COUNT;
2563 +static void cpmac_dev_mcast_set(struct net_device *p_dev)
2565 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_dev->priv;
2566 + CPMAC_DRV_HAL_INFO_T *p_drv_hal = p_cpmac_priv->drv_hal;
2567 + CPMAC_ABILITY_INFO_T *p_capability = p_cpmac_priv->ability_info;
2568 + HAL_FUNCTIONS *p_hal_funcs = p_drv_hal->hal_funcs;
2569 + HAL_DEVICE *p_hal_dev = p_drv_hal->hal_dev;
2573 +//#if defined (CONFIG_MIPS_AVALANCHE_LED)
2574 +// if(netif_carrier_ok(p_dev))
2575 +// avalanche_led_action(p_cpmac_priv->led_handle, CPMAC_LINK_ON);
2578 + if(p_dev->flags & IFF_PROMISC)
2580 + if(p_capability->promiscous)
2582 + /* multi mode in the HAL, check this */
2584 + p_hal_funcs->Control(p_hal_dev, pszRX_MULTI_ALL, "Clear", &val);
2587 + /* set the promiscous mode in the HAL */
2588 + p_hal_funcs->Control(p_hal_dev, pszRX_CAF_EN, pszSet, &val);
2589 + p_hal_funcs->Control(p_hal_dev, pszRX_PROM_CH, pszSet, &channel);
2591 + dbgPrint("%s set in the Promisc mode.\n", p_dev->name);
2595 + errPrint("%s not configured for Promisc mode.\n", p_dev->name);
2598 + else if(p_dev->flags & IFF_ALLMULTI)
2600 + if(p_capability->all_multi)
2603 + /* disable the promiscous mode in the HAL */
2604 + p_hal_funcs->Control(p_hal_dev, pszRX_CAF_EN, "Clear", &val);
2607 + /* set the all multi mode in the HAL */
2608 + p_hal_funcs->Control(p_hal_dev, pszRX_MULTI_ALL, pszSet, &val);
2609 + p_hal_funcs->Control(p_hal_dev, pszRX_MULT_CH, pszSet, &channel);
2611 + dbgPrint("%s has been set to the ALL_MULTI mode.\n", p_dev->name);
2615 + errPrint("%s not configured for ALL MULTI mode.\n", p_dev->name);
2618 + else if(p_dev->mc_count)
2620 + if(p_capability->multicast)
2622 + struct dev_mc_list *p_dmi = p_dev->mc_list;
2626 + /* clear all the previous data, we are going to populate new ones.*/
2627 + p_hal_funcs->Control(p_hal_dev, pszRX_MULTI_ALL, "Clear", &val);
2628 + /* disable the promiscous mode in the HAL */
2629 + p_hal_funcs->Control(p_hal_dev, pszRX_CAF_EN, pszSet, &val);
2631 + for(count = 0; count < p_dev->mc_count; count++, p_dmi = p_dmi->next)
2633 + p_hal_funcs->Control(p_hal_dev, "RX_MULTI_SINGLE", "Set", p_dmi->dmi_addr);
2636 + dbgPrint("%s configured for %d multicast addresses.\n", p_dev->name, p_dev->mc_count);
2640 + errPrint("%s has not been configuted for multicast handling.\n", p_dev->name);
2646 + /* clear all the previous data, we are going to populate new ones.*/
2647 + p_hal_funcs->Control(p_hal_dev, pszRX_MULTI_ALL, "Clear", &val);
2648 + /* disable the promiscous mode in the HAL */
2649 + p_hal_funcs->Control(p_hal_dev, pszRX_CAF_EN, pszSet, &val);
2650 + dbgPrint("Dev set to Unicast mode.\n");
2654 +static int cpmac_dev_set_mac_addr(struct net_device *p_dev,void * addr)
2656 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_dev->priv;
2657 + CPMAC_DRV_HAL_INFO_T *p_drv_hal = p_cpmac_priv->drv_hal;
2658 + HAL_FUNCTIONS *p_hal_funcs = p_drv_hal->hal_funcs;
2659 + HAL_DEVICE *p_hal_dev = p_drv_hal->hal_dev;
2660 + struct sockaddr *sa = addr;
2662 + memcpy(p_cpmac_priv->mac_addr,sa->sa_data,p_dev->addr_len);
2663 + memcpy(p_dev->dev_addr,sa->sa_data,p_dev->addr_len);
2664 + p_hal_funcs->Control(p_hal_dev, pszMacAddr, pszSet, p_cpmac_priv->mac_addr);
2670 +/* VLAN is handled by vlan/vconfig support. Here, we just check for the
2671 + * 802.1q configuration of the device and en-queue the packet accordingly.
2672 + * We do not do any 802.1q processing here.
2674 +static int cpmac_dev_tx( struct sk_buff *skb, struct net_device *p_dev)
2676 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_dev->priv;
2677 + CPMAC_DRV_HAL_INFO_T *p_drv_hal = p_cpmac_priv->drv_hal;
2680 + FRAGLIST send_frag_list[1];
2682 +#ifdef CPMAC_8021Q_SUPPORT
2683 + if(skb->len < TCI_END_OFFSET)
2685 + /* Whee, frame shorter than 14 bytes !! We need to copy
2686 + * fragments to understand the frame. Too much work.
2687 + * Hmm, dump it. */
2689 + /* Free the buffer */
2690 + goto cpmac_dev_tx_drop_pkt;
2693 + /* 802.1p/q stuff */
2694 + if(IS_802_1Q_FRAME(skb->data + TPID_START_OFFSET))
2696 + /* IEEE 802.1q, section 8.8 and section 8.11.9 */
2697 + if(!p_cpmac_priv->enable_802_1q)
2699 + /* free the buffer */
2700 + goto cpmac_dev_tx_drop_pkt;
2703 + channel = GET_802_1P_CHAN(p_cpmac_priv->tx_chan_info->opened_chan,
2704 + skb->data[TCI_START_OFFSET]);
2707 + /* sending a non 802.1q frame, when configured for 802.1q: dump it.*/
2708 + else if(p_cpmac_priv->enable_802_1q)
2710 + /* free the buffer */
2711 + goto cpmac_dev_tx_drop_pkt;
2715 + ;/* it is the good old non 802.1q */
2719 + send_frag_list->len = skb->len;
2720 + send_frag_list->data = skb->data;
2723 + xdump(skb->data, skb->len, "send");
2726 + dma_cache_wback_inv((unsigned long)skb->data, skb->len);
2728 + if(p_drv_hal->hal_funcs->Send(p_drv_hal->hal_dev, send_frag_list, 1,
2729 + skb->len, skb, channel) != 0)
2731 + /* code here to stop the queue, when allowing tx timeout, perhaps next release.*/
2732 + p_cpmac_priv->net_dev_stats.tx_errors++;
2733 +#ifndef TI_SLOW_PATH
2734 + /* Free the skb in case of Send return error */
2735 + dev_kfree_skb_any(skb);
2736 + p_cpmac_priv->net_dev_stats.tx_dropped++;
2739 + goto cpmac_dev_tx_drop_pkt;
2742 +//#if defined (CONFIG_MIPS_AVALANCHE_LED)
2743 +// avalanche_led_action(p_cpmac_priv->led_handle, CPMAC_TX_ACTIVITY);
2748 +cpmac_dev_tx_drop_pkt:
2750 + p_cpmac_priv->net_dev_stats.tx_dropped++;
2754 +} /*cpmac_dev_tx */
2757 +//------------------------------------------------------------------------------
2758 +// Public functions : Called by outsiders to this file.
2759 +//------------------------------------------------------------------------------
2762 +void *cpmac_hal_malloc_buffer(unsigned int size, void* mem_base, unsigned int mem_range,
2763 + OS_SETUP *p_os_setup, HAL_RECEIVEINFO *HalReceiveInfo,
2764 + OS_RECEIVEINFO **osReceiveInfo, OS_DEVICE *p_dev)
2766 + CPMAC_RX_CHAN_INFO_T *p_rx_chan_info = (CPMAC_RX_CHAN_INFO_T *)p_os_setup;
2767 + int tot_buf_size = p_rx_chan_info->chan->tot_buf_size;
2768 + int tot_reserve_bytes = p_rx_chan_info->chan->tot_reserve_bytes;
2769 + struct sk_buff *p_skb;
2772 + /* use TI SKB private pool */
2773 + p_skb = dev_alloc_skb(tot_buf_size);
2777 + errPrint("Failed to allocate skb for %s.\n", ((struct net_device*)p_dev)->name);
2781 + p_skb->dev = p_dev;
2782 + skb_reserve(p_skb, tot_reserve_bytes);
2784 + *osReceiveInfo = p_skb;
2786 + ret_ptr = skb_put(p_skb, p_rx_chan_info->chan->buffer_size);
2791 +void cpmac_hal_isr(int irq, void *p_param, struct pt_regs *regs)
2793 + CPMAC_ISR_INFO_T *p_cb_param = (CPMAC_ISR_INFO_T*) p_param;
2794 + CPMAC_DRV_HAL_INFO_T *p_drv_hal = p_cb_param->owner;
2795 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_drv_hal->owner;
2796 + int pkts_to_handle = 0;
2798 + if(p_cpmac_priv->non_data_irq_expected)
2800 + p_cb_param->hal_isr(p_drv_hal->hal_dev, &pkts_to_handle);
2801 + p_drv_hal->hal_funcs->PacketProcessEnd(p_drv_hal->hal_dev);
2803 + else if(!p_cpmac_priv->set_to_close)
2804 + tasklet_schedule(&((CPMAC_ISR_INFO_T*) p_param)->tasklet);
2806 + ; // back off from doing anything more. We are closing down.
2809 +void cpmac_handle_tasklet(unsigned long data)
2811 + CPMAC_ISR_INFO_T *p_cb_param = (CPMAC_ISR_INFO_T*) data;
2812 + CPMAC_DRV_HAL_INFO_T *p_drv_hal = p_cb_param->owner;
2813 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_drv_hal->owner;
2814 + int pkts_to_handle;
2816 + p_cb_param->hal_isr(p_drv_hal->hal_dev, &pkts_to_handle);
2818 + if(test_bit(0, &p_cpmac_priv->non_data_irq_expected) || !pkts_to_handle)
2819 + p_drv_hal->hal_funcs->PacketProcessEnd(p_drv_hal->hal_dev);
2820 + else if(!test_bit(0, &p_cpmac_priv->set_to_close))
2821 + tasklet_schedule(&p_cb_param->tasklet);
2823 + ; // Back off from processing packets we are closing down.
2826 +int cpmac_hal_control(OS_DEVICE *p_dev, const char *key,
2827 + const char *action, void *value)
2829 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_dev->priv;
2834 + dbgPrint("Encountered NULL key.\n");
2838 + if(cpmac_ci_strcmp(key, "Sleep") == 0 && value != NULL)
2840 + unsigned int clocks_per_tick = cpmac_cpu_freq/HZ;
2841 + unsigned int requested_clocks = *(unsigned int*)value;
2842 + unsigned int requested_ticks = (requested_clocks + clocks_per_tick - 1)/clocks_per_tick;
2843 + mdelay(requested_ticks);
2846 + else if(cpmac_ci_strcmp(key, "StateChange") == 0)
2848 + ret_val = cpmac_p_process_status_ind(p_cpmac_priv);
2850 + else if(cpmac_ci_strcmp(key, "Tick") == 0 && action != NULL)
2852 + if(cpmac_ci_strcmp(action, "Set") == 0 && value != NULL)
2854 + if(*(unsigned int*)value == 0)
2856 + cpmac_p_stop_timer(p_cpmac_priv->timer + TICK_TIMER);
2861 + unsigned int clocks_per_tick = cpmac_cpu_freq/HZ;
2862 + unsigned int requested_clocks = *(unsigned int*)value;
2863 + unsigned int requested_ticks = (requested_clocks + clocks_per_tick - 1)/clocks_per_tick;
2865 + p_cpmac_priv->delay_ticks = requested_ticks; /* save it for re-triggering */
2866 + ret_val = cpmac_p_start_timer(p_cpmac_priv->timer + TICK_TIMER,
2867 + p_cpmac_priv->delay_ticks);
2870 + else if(cpmac_ci_strcmp(action, "Clear") == 0)
2872 + ret_val = cpmac_p_stop_timer(p_cpmac_priv->timer + TICK_TIMER);
2877 + else if(cpmac_ci_strcmp(key, "MacAddr") == 0 && action != NULL)
2879 + if(cpmac_ci_strcmp(action, "Get") == 0 && value != NULL)
2881 + *(char **)value = p_cpmac_priv->mac_addr;
2885 + else if(cpmac_ci_strcmp(key, "CpuFreq") == 0)
2887 + if(cpmac_ci_strcmp(action, "Get") == 0 && value != NULL)
2889 + *(unsigned int *)value = cpmac_cpu_freq;
2890 + dbgPrint("Cpu frequency for cpmacs is %u\n",cpmac_cpu_freq);
2894 + else if(cpmac_ci_strcmp(key, "SioFlush") == 0)
2899 + else if(cpmac_ci_strcmp(key, "CpmacFrequency") == 0)
2901 + /* For Sangam cpmac clock is off the PBUS */
2902 + /* OS Needs to supply CORRECT frequency */
2903 + if(cpmac_ci_strcmp(action, "Get") == 0 && value != NULL)
2905 + *(unsigned int *)value = CONFIG_AR7_SYS_FREQUENCY * 1000 * 1000;
2909 + /* For now, providing back the default values. */
2910 + else if(cpmac_ci_strcmp(key, "MdioClockFrequency") == 0)
2912 + if(cpmac_ci_strcmp(action, "Get") == 0 && value != NULL)
2914 + *(unsigned int *)value = 2200000; /*DEFAULT */
2918 + /* For now, providing back the default values. */
2919 + else if(cpmac_ci_strcmp(key, "MdioBusFrequency") == 0)
2921 + /* For Sangam MdioBusFreq is off the PBUS */
2922 + if(cpmac_ci_strcmp(action, "Get") == 0 && value != NULL)
2924 + *(unsigned int *)value = CONFIG_AR7_SYS_FREQUENCY * 1000 * 1000;
2930 +#if defined(CONFIG_AVALANCHE_AUTO_MDIX)
2931 + /* supporting Mdio Mdix switching */
2932 + else if(cpmac_ci_strcmp(key, hcMdioMdixSwitch) == 0)
2934 + /* For Sangam Mdio-switching action should be always "set"*/
2935 + if(cpmac_ci_strcmp(action, hcSet) == 0 && value != NULL )
2937 + unsigned int mdix = *((unsigned int *) value) ;
2940 + avalanche_set_phy_into_mdix_mode();
2943 + avalanche_set_phy_into_mdi_mode();
2951 + else if(cpmac_ci_strcmp(key, hcMdioMdixSwitch) == 0)
2953 + /* For Sangam Mdio-switching action should be always "set"*/
2954 + if(cpmac_ci_strcmp(action, hcSet) == 0 && value != NULL )
2956 + unsigned int mdix = *((unsigned int *) value) ;
2958 +#ifdef CONFIG_AR7_MDIX
2959 + avalanche_set_mdix_on_chip(0xa8610000 , mdix ? 1: 0);
2971 +int cpmac_hal_receive(OS_DEVICE *p_dev, FRAGLIST *fragList,
2972 + unsigned int fragCount,
2973 + unsigned int packet_size,
2974 + HAL_RECEIVEINFO *hal_receive_info,
2975 + unsigned int mode)
2977 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_dev->priv;
2978 + CPMAC_DRV_HAL_INFO_T *p_drv_hal = p_cpmac_priv->drv_hal;
2979 + struct sk_buff *p_skb = fragList[0].OsInfo;
2980 + p_skb->len = fragList[0].len;
2982 + /* invalidate the cache. */
2983 + dma_cache_inv((unsigned long)p_skb->data, fragList[0].len);
2985 + xdump(p_skb->data, p_skb->len, "recv");
2987 +#ifdef CPMAC_8021Q_SUPPORT
2988 + /* 802.1q stuff, just does the basic checking here. */
2989 + if(!p_cpmac_priv->enable_802_1q &&
2990 + p_skb->len > TCI_END_OFFSET &&
2991 + IS_802_1Q_FRAME(p_skb->data + TPID_START_OFFSET))
2993 + goto cpmac_hal_recv_frame_mismatch;
2999 + struct sk_buff *p_temp_skb;
3000 + CPMAC_RX_CHAN_INFO_T *p_rx_chan_info = p_cpmac_priv->rx_chan_info;
3003 + dbgPrint("Recv: It is multifragment for %s.\n", p_dev->name);
3005 + p_skb = dev_alloc_skb(packet_size +
3006 + p_rx_chan_info->chan->tot_reserve_bytes);
3009 + p_cpmac_priv->net_dev_stats.rx_errors++;
3010 + goto cpmac_hal_recv_alloc_failed;
3013 + p_skb->dev = p_dev;
3014 + skb_reserve(p_skb, p_rx_chan_info->chan->tot_reserve_bytes);
3016 + for(count = 0; count < fragCount; count++)
3018 + p_temp_skb = fragList[count].OsInfo;
3019 + len = fragList[count].len;
3021 + dma_cache_inv((unsigned long)p_temp_skb->data, len);
3023 + memcpy(skb_put(p_skb, len), p_temp_skb->data, len);
3024 + dev_kfree_skb_any(p_temp_skb);
3029 +#if defined(CONFIG_MIPS_AVALANCHE_MARVELL)
3030 + /* Fetch the receiving port information from EGRESS TRAILOR Bytes*/
3031 + p_dev->if_port = (unsigned char)p_skb->data[packet_size -(EGRESS_TRAILOR_LEN-1)] + AVALANCHE_MARVELL_BASE_PORT_ID;
3032 + skb_trim(p_skb, packet_size - EGRESS_TRAILOR_LEN);
3034 + /* set length & tail */
3035 + skb_trim(p_skb, packet_size);
3038 +#ifndef TI_SLOW_PATH
3039 + /* TI Optimization: This is NOT required if the ethernet resides below the bridge. But is
3040 + * required only if the ethernet is directly connected to the IP stack. */
3041 + if (p_dev->br_port == NULL)
3043 + p_skb->protocol = eth_type_trans(p_skb, p_dev);
3047 +//#if defined (CONFIG_MIPS_AVALANCHE_LED)
3048 +// avalanche_led_action(p_cpmac_priv->led_handle, CPMAC_RX_ACTIVITY);
3051 + p_cpmac_priv->net_dev_stats.rx_packets++;
3052 + p_cpmac_priv->net_dev_stats.rx_bytes += packet_size;
3054 + p_drv_hal->hal_funcs->RxReturn(hal_receive_info,1);
3058 +cpmac_hal_recv_alloc_failed:
3060 +#ifdef CPMAC_8021Q_SUPPORT
3061 +cpmac_hal_recv_frame_mismatch:
3068 + dev_kfree_skb_any(fragList[fragCount].OsInfo);
3070 + while(fragCount--);
3072 + p_cpmac_priv->net_dev_stats.rx_dropped++;
3075 +} /*cpmac_receive*/
3078 +void cpmac_hal_tear_down_complete(OS_DEVICE*a, int b, int ch)
3080 + dbgPrint("what to do with this.\n");
3084 +int cpmac_hal_send_complete(OS_SENDINFO *p_skb)
3086 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_skb->dev->priv;
3088 + p_cpmac_priv->net_dev_stats.tx_packets++;
3089 + p_cpmac_priv->net_dev_stats.tx_bytes += p_skb->len;
3091 + dev_kfree_skb_any(p_skb);
3097 +int cpmac_reset(CPMAC_PRIVATE_INFO_T *p_cpmac_priv)
3099 + // code here to reset the device/hal. Not now.
3101 + netif_wake_queue(p_cpmac_priv->owner);
3107 +#define isprint(a) ((a >=' ')&&(a<= '~'))
3108 +void xdump( u_char* cp, int length, char* prefix )
3111 + u_char prntBuf[120];
3112 + u_char* pBuf = prntBuf;
3114 + while(count < length){
3115 + pBuf += sprintf( pBuf, "%s", prefix );
3116 + for(col = 0;count + col < length && col < 16; col++){
3117 + if (col != 0 && (col % 4) == 0)
3118 + pBuf += sprintf( pBuf, " " );
3119 + pBuf += sprintf( pBuf, "%02X ", cp[count + col] );
3121 + while(col++ < 16){ /* pad end of buffer with blanks */
3122 + if ((col % 4) == 0)
3123 + sprintf( pBuf, " " );
3124 + pBuf += sprintf( pBuf, " " );
3126 + pBuf += sprintf( pBuf, " " );
3127 + for(col = 0;count + col < length && col < 16; col++){
3128 + if (isprint((int)cp[count + col]))
3129 + pBuf += sprintf( pBuf, "%c", cp[count + col] );
3131 + pBuf += sprintf( pBuf, "." );
3133 + sprintf( pBuf, "\n" );
3134 + // SPrint(prntBuf);
3140 +} /* close xdump(... */
3144 +static int __init cpmac_dev_probe(void)
3148 + int instance_count = CONFIG_MIPS_CPMAC_PORTS;
3150 + //cpmac_cpu_freq = avalanche_clkc_get_freq(CLKC_MIPS);
3151 + cpmac_cpu_freq = CONFIG_AR7_CPU_FREQUENCY * 1000 * 1000;
3153 + build_psp_config();
3155 + for(unit = 0; unit < instance_count; unit++)
3157 + struct net_device *p_dev;
3158 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv;
3162 + dev_size = sizeof(struct net_device)
3163 + + sizeof(CPMAC_PRIVATE_INFO_T);
3166 + if((p_dev = (struct net_device *) kmalloc(dev_size, GFP_KERNEL)) == NULL)
3168 + dbgPrint( "Could not allocate memory for device.\n" );
3173 + memset(p_dev, 0, dev_size );
3175 + p_dev->priv = p_cpmac_priv
3176 + = (CPMAC_PRIVATE_INFO_T*)(((char *) p_dev) + sizeof(struct net_device));
3177 + p_cpmac_priv->owner = p_dev;
3179 + ether_setup(p_dev);
3181 + p_cpmac_priv->instance_num = unit;
3182 + p_dev->init = cpmac_dev_init;
3184 + g_dev_array[p_cpmac_priv->instance_num] = p_dev;
3186 +#if defined CONFIG_MIPS_CPMAC_INIT_BUF_MALLOC
3187 + g_init_enable_flag = 1;
3188 + printk("Cpmac driver is allocating buffer memory at init time.\n");
3191 + /* This section gives a default value by the number of PHY in order to
3192 + * replace the default MACRO. */
3194 + char *mac_port = prom_getenv("MAC_PORT"); /* Internal: 0, External: 1 */
3195 + if(!mac_port || (0 != strcmp(mac_port, "0"))) {
3196 + printk("Using the MAC with external PHY\n");
3197 + cfg_start_link_speed = _CPMDIO_NOPHY;
3198 + cpmac_max_frame_size = CPMAC_MAX_FRAME_SIZE + 4;
3201 + printk("Using the MAC with internal PHY\n");
3202 + cfg_start_link_speed = CFG_START_LINK_SPEED;
3203 + cpmac_max_frame_size = CPMAC_MAX_FRAME_SIZE;
3205 + g_cfg_start_link_params = cfg_start_link_speed;
3208 + cpmac_p_detect_manual_cfg(cfg_link_speed, cfg_link_mode, cpmac_debug_mode);
3210 + failed = register_netdev(p_dev);
3213 + dbgPrint("Could not register device for inst %d because of reason \
3214 + code %d.\n", unit, failed);
3222 + char proc_name[100];
3223 + int proc_category_name_len = 0;
3225 + p_cpmac_priv->next_device = last_cpmac_device;
3226 + last_cpmac_device = p_dev;
3228 + dbgPrint(" %s irq=%2d io=%04x\n",p_dev->name, (int) p_dev->irq,
3229 + (int) p_dev->base_addr);
3231 + strcpy(proc_name, "avalanche/");
3232 + strcat(proc_name, p_dev->name);
3233 + proc_category_name_len = strlen(proc_name);
3235 + strcpy(proc_name + proc_category_name_len, "_rfc2665_stats");
3236 + create_proc_read_entry(proc_name,0,NULL,cpmac_p_read_rfc2665_stats, p_dev);
3243 + /* To maintain backward compatibility with NSP. */
3244 + gp_stats_file = create_proc_entry("avalanche/cpmac_stats", 0644, NULL);
3247 + gp_stats_file->read_proc = cpmac_p_read_stats;
3248 + gp_stats_file->write_proc = cpmac_p_write_stats;
3250 + create_proc_read_entry("avalanche/cpmac_link", 0, NULL, cpmac_p_read_link, NULL);
3251 + create_proc_read_entry("avalanche/cpmac_ver", 0, NULL, cpmac_p_get_version, NULL);
3255 + cpmac_devices_installed = unit;
3256 + dbgPrint("Installed %d cpmac instances.\n", unit);
3257 + return ( (unit >= 0 ) ? 0 : -ENODEV );
3259 +} /* init_module */
3262 +/***************************************************************
3270 + * Goes through the CpmacDevices list and frees the device
3271 + * structs and memory associated with each device (lists
3272 + * and buffers). It also ureserves the IO port regions
3273 + * associated with this device.
3275 + **************************************************************/
3277 +void cpmac_exit(void)
3279 + struct net_device *p_dev;
3280 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv;
3282 + while (cpmac_devices_installed)
3284 + char proc_name[100];
3285 + int proc_category_name_len = 0;
3287 + p_dev = last_cpmac_device;
3288 + p_cpmac_priv = (CPMAC_PRIVATE_INFO_T *) p_dev->priv;
3290 + dbgPrint("Unloading %s irq=%2d io=%04x\n",p_dev->name, (int) p_dev->irq, (int) p_dev->base_addr);
3292 + if(g_init_enable_flag)
3293 + cpmac_p_dev_disable(p_dev);
3295 + cpmac_drv_cleanup(p_cpmac_priv->drv_hal);
3297 +//#if defined (CONFIG_MIPS_AVALANCHE_LED)
3298 +// avalanche_led_unregister(p_cpmac_priv->led_handle);
3300 + strcpy(proc_name, "avalanche/");
3301 + strcat(proc_name, p_dev->name);
3302 + proc_category_name_len = strlen(proc_name);
3304 + strcpy(proc_name + proc_category_name_len, "_rfc2665_stats");
3305 + remove_proc_entry(proc_name, NULL);
3307 + release_mem_region(p_dev->base_addr, p_cpmac_priv->dev_size);
3308 + unregister_netdev(p_dev);
3309 + last_cpmac_device = p_cpmac_priv->next_device;
3311 + kfree(p_cpmac_priv->drv_hal);
3314 + cpmac_devices_installed--;
3318 + remove_proc_entry("avalanche/cpmac_stats", NULL);
3320 + remove_proc_entry("avalanche/cpmac_link", NULL);
3321 + remove_proc_entry("avalanche/cpmac_ver", NULL);
3323 + psp_config_cleanup();
3327 +module_init(cpmac_dev_probe);
3328 +module_exit(cpmac_exit);
3329 diff -urN linux.old/drivers/net/avalanche_cpmac/cpmac.h linux.dev/drivers/net/avalanche_cpmac/cpmac.h
3330 --- linux.old/drivers/net/avalanche_cpmac/cpmac.h 1970-01-01 01:00:00.000000000 +0100
3331 +++ linux.dev/drivers/net/avalanche_cpmac/cpmac.h 2005-07-12 02:48:42.043594000 +0200
3333 +/******************************************************************************
3334 + * FILE PURPOSE: CPMAC Linux Network Device Driver Header
3335 + ******************************************************************************
3336 + * FILE NAME: cpmac.h
3338 + * DESCRIPTION: CPMAC Network Device Driver Header
3340 + * REVISION HISTORY:
3341 + * Date Name Details
3342 + *-----------------------------------------------------------------------------
3343 + * 27 Nov 2002 Suraj S Iyer Initial Create.
3344 + * 09 Jun 2003 Suraj S Iyer Preparing for GA.
3346 + * (C) Copyright 2003, Texas Instruments, Inc
3347 + *******************************************************************************/
3352 +#include <linux/timer.h>
3353 +#include <linux/netdevice.h>
3354 +#include <asm/semaphore.h>
3355 +#include <linux/ctype.h>
3356 +#include <linux/interrupt.h>
3358 +#include "cpmacHalLx.h"
3359 +/*-----------------------------------------------------------------------------
3360 + * Config macros. Use these to config the driver.
3361 + *---------------------------------------------------------------------------*/
3362 +#define CPMAC_MAX_FRAME_SIZE 1518
3364 +#if defined(CONFIG_AR7WRD) || defined(CONFIG_AR7WI) || defined(CONFIG_AR7VWI)|| defined(CONFIG_AR7VW)
3365 +#define CFG_RX_NUM_BUF_DESC 64
3366 +#define CFG_RX_NUM_BUF_SERVICE 32
3368 +#define CFG_RX_NUM_BUF_DESC 16
3369 +#define CFG_RX_NUM_BUF_SERVICE 8
3372 +#define CFG_RX_BUF_OFFSET 0
3374 +#define CFG_TX_NUM_BUF_DESC 128
3375 +#define CFG_TX_NUM_BUF_SERVICE 20
3376 +#define CFG_TX_BUF_OFFSET 0 /* Lets not change this. */
3377 +#define CFG_TX_TIMEOUT 2000 /* ticks*/
3378 +#define CFG_TX_INT_DISABLE 1 /* Disable the Tx Complete interrupt */
3380 +#define CFG_JUMBO_FRAMES 1
3381 +#define CFG_SHORT_FRAMES 1
3382 +#define CFG_PROMISCOUS 1
3383 +#define CFG_BROADCAST 1
3384 +#define CFG_MULTICAST 1
3385 +#define CFG_ALL_MULTI (1*(CFG_MULTICAST))
3386 +#define CFG_AUTO_NEGOTIATION 1
3388 +#if defined (CONFIG_MIPS_AVALANCHE_MARVELL)
3389 +#define EGRESS_TRAILOR_LEN 4
3390 +#define CFG_START_LINK_SPEED (_CPMDIO_NOPHY)
3391 +#undef CPMAC_MAX_FRAME_SIZE
3392 +#define CPMAC_MAX_FRAME_SIZE (1518 + EGRESS_TRAILOR_LEN)
3394 +#define CFG_START_LINK_SPEED (_CPMDIO_10 | _CPMDIO_100 | _CPMDIO_HD | _CPMDIO_FD) /* auto nego */
3397 +#define CFG_LOOP_BACK 1
3398 +#define CFG_TX_FLOW_CNTL 0
3399 +#define CFG_RX_FLOW_CNTL 0
3400 +#define CFG_TX_PACING 0
3401 +#define CFG_RX_PASS_CRC 0
3402 +#define CFG_QOS_802_1Q 0
3403 +#define CFG_TX_NUM_CHAN 1
3406 +/*-----------------------------------------------------------------------------
3408 + *---------------------------------------------------------------------------*/
3409 +#define MAX_TIMER 2
3411 +#define TICK_TIMER 0
3412 +#define MAX_TX_CHAN 8
3414 +#define CPMAC_LINK_OFF 0
3415 +#define CPMAC_LINK_ON 1
3416 +/*#define CPMAC_SPEED_100 2
3417 +#define CPMAC_SPEED_10 3
3418 +#define CPMAC_FULL_DPLX 4
3419 +#define CPMAC_HALF_DPLX 5*/
3420 +#define CPMAC_RX_ACTIVITY 2
3421 +#define CPMAC_TX_ACTIVITY 3
3423 +struct cpmac_timer_info;
3425 +typedef int (*CPMAC_HAL_ISR_FUNC_T)(HAL_DEVICE*, int*);
3426 +typedef int (*CPMAC_TIMEOUT_CB_T)(struct cpmac_timer_info*);
3428 +typedef struct cpmac_ability_info
3437 + int auto_negotiation;
3438 + int tx_flow_control;
3439 + int rx_flow_control;
3446 +CPMAC_ABILITY_INFO_T;
3449 +typedef struct cpmac_timer_info
3452 + UINT32 delay_ticks;
3454 + UINT32 is_running;
3455 + UINT32 timer_set_at;
3456 + CPMAC_TIMEOUT_CB_T timeout_CB;
3457 +} CPMAC_TIMER_INFO_T;
3462 + unsigned int num_cl_desc;
3463 + CL_DESC *cl_desc_tbl;
3464 + M_CL_CONFIG *m_cl_blk_config;
3465 + NET_POOL *net_pool;
3466 + CL_POOL_ID clPoolId;
3468 +} CPMAC_NET_MEM_INFO_T;
3475 + CPMAC_HAL_ISR_FUNC_T hal_isr;
3476 + struct tasklet_struct tasklet;
3479 +} CPMAC_ISR_INFO_T;
3481 +typedef struct cpmac_chan
3485 + int buffer_offset;
3489 + int tot_reserve_bytes;
3493 +#define CHAN_CLOSE 0
3494 +#define CHAN_OPENED 1
3501 + CPMAC_CHAN_T chan[1];
3502 + int enable_802_1q;
3504 +} CPMAC_RX_CHAN_INFO_T;
3511 + int tx_int_disable;
3512 + CPMAC_CHAN_T chan[MAX_TX_CHAN];
3514 +} CPMAC_TX_CHAN_INFO_T;
3521 + HAL_FUNCTIONS *hal_funcs;
3522 + HAL_DEVICE *hal_dev;
3523 + OS_FUNCTIONS *os_funcs;
3524 +// SEM_ID chan_teardown_sem;
3525 + int non_data_irq_expected;
3526 +} CPMAC_DRV_HAL_INFO_T;
3531 + unsigned long tx_discards;
3532 + unsigned long rx_discards;
3533 + unsigned long start_tick;
3535 +} CPMAC_DRV_STATS_T;
3539 + unsigned long ifInGoodFrames;
3540 + unsigned long ifInBroadcasts;
3541 + unsigned long ifInMulticasts;
3542 + unsigned long ifInPauseFrames;
3543 + unsigned long ifInCRCErrors;
3544 + unsigned long ifInAlignCodeErrors;
3545 + unsigned long ifInOversizedFrames;
3546 + unsigned long ifInJabberFrames;
3547 + unsigned long ifInUndersizedFrames;
3548 + unsigned long ifInFragments;
3549 + unsigned long ifInFilteredFrames;
3550 + unsigned long ifInQosFilteredFrames;
3551 + unsigned long ifInOctets;
3552 + unsigned long ifOutGoodFrames;
3553 + unsigned long ifOutBroadcasts;
3554 + unsigned long ifOutMulticasts;
3555 + unsigned long ifOutPauseFrames;
3556 + unsigned long ifDeferredTransmissions;
3557 + unsigned long ifCollisionFrames;
3558 + unsigned long ifSingleCollisionFrames;
3559 + unsigned long ifMultipleCollisionFrames;
3560 + unsigned long ifExcessiveCollisionFrames;
3561 + unsigned long ifLateCollisions;
3562 + unsigned long ifOutUnderrun;
3563 + unsigned long ifCarrierSenseErrors;
3564 + unsigned long ifOutOctets;
3565 + unsigned long if64OctetFrames;
3566 + unsigned long if65To127OctetFrames;
3567 + unsigned long if128To255OctetFrames;
3568 + unsigned long if256To511OctetFrames;
3569 + unsigned long if512To1023OctetFrames;
3570 + unsigned long if1024ToUPOctetFrames;
3571 + unsigned long ifNetOctets;
3572 + unsigned long ifRxSofOverruns;
3573 + unsigned long ifRxMofOverruns;
3574 + unsigned long ifRxDMAOverruns;
3576 +} CPMAC_DEVICE_MIB_T;
3583 + int timer_created;
3584 + struct timer_list timer[1];
3585 + CPMAC_DRV_HAL_INFO_T *drv_hal;
3586 + unsigned int num_of_intr;
3587 + CPMAC_ISR_INFO_T cpmac_isr;
3588 + unsigned int link_speed;
3589 + unsigned int link_mode;
3590 + unsigned int enable_802_1q;
3591 + unsigned int timer_access_hal;
3592 + unsigned int loop_back;
3593 + CPMAC_RX_CHAN_INFO_T *rx_chan_info;
3594 + CPMAC_TX_CHAN_INFO_T *tx_chan_info;
3595 + CPMAC_ABILITY_INFO_T *ability_info;
3596 + CPMAC_DEVICE_MIB_T *device_mib;
3597 + CPMAC_DRV_STATS_T *stats;
3598 + unsigned int flags;
3599 + unsigned int delay_ticks;
3601 + struct net_device_stats net_dev_stats;
3602 +// rwlock_t rw_lock;
3604 + struct net_device *next_device;
3605 + unsigned int instance_num;
3606 + unsigned int non_data_irq_expected;
3607 + unsigned long dev_size;
3609 +} CPMAC_PRIVATE_INFO_T;
3612 +/* Private flags */
3614 +/* bit 0 to 31, bit 32 is used to indicate set or reset */
3616 +#define IFF_PRIV_SHORT_FRAMES 0x00010000
3617 +#define IFF_PRIV_JUMBO_FRAMES 0x00020000
3618 +#define IFF_PRIV_AUTOSPEED 0x00080000
3619 +#define IFF_PRIV_LINK10_HD 0x00100000
3620 +#define IFF_PRIV_LINK10_FD 0x00200000
3621 +#define IFF_PRIV_LINK100_HD 0x00400000
3622 +#define IFF_PRIV_LINK100_FD 0x00800000
3623 +#define IFF_PRIV_8021Q_EN 0x01000000
3624 +#define IFF_PRIV_NUM_TX_CHAN 0x02000000
3625 +#define IFF_PRIV_TX_FLOW_CNTL 0x04000000
3626 +#define IFF_PRIV_RX_FLOW_CNTL 0x08000000
3627 +#define IFF_PRIV_TX_PACING 0x10000000
3628 +#define IFF_PRIV_RX_PASS_CRC 0x20000000
3630 +#define PRIVCSFLAGS 0x200
3631 +#define PRIVCGFLAGS 0x201
3635 +#define CHAN_TEARDOWN 2
3636 +#define CHAN_SETUP 4
3638 +#define FREE_BUFFER 16
3641 +static const char pszStats0[] = "Stats0";
3642 +static const char pszStats1[] = "Stats1";
3643 +static const char pszStats2[] = "Stats2";
3644 +static const char pszStats3[] = "Stats3";
3645 +static const char pszStats4[] = "Stats4";
3646 +static const char pszStatsDump[] = "StatsDump";
3647 +static const char pszStatsClear[] = "StatsClear";
3648 +static const char pszRX_PASS_CRC[] = "RX_PASS_CRC";
3649 +static const char pszRX_QOS_EN[] = "RX_QOS_EN";
3650 +static const char pszRX_NO_CHAIN[] = "RX_NO_CHAIN";
3651 +static const char pszRX_CMF_EN[] = "RX_CMF_EN";
3652 +static const char pszRX_CSF_EN[] = "RX_CSF_EN";
3653 +static const char pszRX_CEF_EN[] = "RX_CEF_EN";
3654 +static const char pszRX_CAF_EN[] = "RX_CAF_EN";
3655 +static const char pszRX_PROM_CH[] = "RX_PROM_CH";
3656 +static const char pszRX_BROAD_EN[] = "RX_BROAD_EN";
3657 +static const char pszRX_BROAD_CH[] = "RX_BROAD_CH";
3658 +static const char pszRX_MULT_EN[] = "RX_MULT_EN";
3659 +static const char pszRX_MULT_CH[] = "RX_MULT_CH";
3660 +static const char pszTX_PTYPE[] = "TX_PTYPE";
3661 +static const char pszTX_PACE[] = "TX_PACE";
3662 +static const char pszMII_EN[] = "MII_EN";
3663 +static const char pszTX_FLOW_EN[] = "TX_FLOW_EN";
3664 +static const char pszRX_FLOW_EN[] = "RX_FLOW_EN";
3665 +static const char pszRX_MAXLEN[] = "RX_MAXLEN";
3666 +static const char pszRX_FILTERLOWTHRESH[] = "RX_FILTERLOWTHRESH";
3667 +static const char pszRX0_FLOWTHRESH[] = "RX0_FLOWTHRESH";
3668 +static const char pszRX_UNICAST_SET[] = "RX_UNICAST_SET";
3669 +static const char pszRX_UNICAST_CLEAR[] = "RX_UNICAST_CLEAR";
3670 +static const char pszMdioConnect[] = "MdioConnect";
3671 +static const char pszMacAddr[] = "MacAddr";
3672 +static const char pszTick[] = "Tick";
3673 +static const char pszRX_MULTICAST[] = "RX_MULTICAST";
3674 +static const char pszRX_MULTI_ALL[] = "RX_MULTI_ALL";
3675 +static const char pszRX_MULTI_SINGLE[] = "RX_MULTI_SINGLE";
3677 +static const char pszSet[] = "Set";
3678 +static const char pszGet[] = "Get";
3679 +static const char pszClear[] = "Clear";
3682 +void *cpmac_hal_malloc_buffer(unsigned int size, void *MemBase, unsigned int MemRange,
3683 + HAL_DEVICE *HalDev, HAL_RECEIVEINFO *HalReceiveInfo,
3684 + OS_RECEIVEINFO **OsReceiveInfo, OS_DEVICE *OsDev);
3686 +void cpmac_hal_tear_down_complete(OS_DEVICE*, int, int);
3687 +int cpmac_hal_control(OS_DEVICE *p_END_obj, const char *key,
3688 + const char *action, void *value);
3689 +int cpmac_hal_receive(OS_DEVICE *p_END_obj, FRAGLIST *fragList,
3690 + unsigned int FragCount, unsigned int pkt_len,
3691 + HAL_RECEIVEINFO *halReceiveInfo,
3692 + unsigned int mode);
3693 +int cpmac_hal_send_complete(OS_SENDINFO*);
3695 +void cpmac_hal_isr(int irq, void *p_param, struct pt_regs *p_cb_param);
3696 +void cpmac_handle_tasklet(unsigned long data);
3698 +inline static int cpmac_ci_strcmp(const char *s1, const char *s2)
3702 + if(tolower(*s1) != tolower(*s2))
3708 + return(tolower(*s1) - tolower(*s2));
3712 diff -urN linux.old/drivers/net/avalanche_cpmac/cpmacHalLx.c linux.dev/drivers/net/avalanche_cpmac/cpmacHalLx.c
3713 --- linux.old/drivers/net/avalanche_cpmac/cpmacHalLx.c 1970-01-01 01:00:00.000000000 +0100
3714 +++ linux.dev/drivers/net/avalanche_cpmac/cpmacHalLx.c 2005-07-12 02:48:42.044593000 +0200
3716 +/******************************************************************************
3717 + * FILE PURPOSE: CPMAC Net Driver HAL support Source
3718 + ******************************************************************************
3719 + * FILE NAME: cpmacHalLx.c
3721 + * DESCRIPTION: CPMAC Network Device Driver Source
3723 + * REVISION HISTORY:
3725 + * Date Description Author
3726 + *-----------------------------------------------------------------------------
3727 + * 27 Nov 2002 Initial Creation Suraj S Iyer
3728 + * 09 Jun 2003 Updates for GA Suraj S Iyer
3729 + * 18 Dec 2003 Updated for 5.7 Suraj S Iyer
3731 + * (C) Copyright 2003, Texas Instruments, Inc
3732 + *******************************************************************************/
3733 +#include <linux/kernel.h>
3734 +#include <linux/module.h>
3735 +#include <linux/init.h>
3736 +#include <linux/netdevice.h>
3737 +#include <linux/etherdevice.h>
3738 +#include <linux/delay.h>
3739 +#include <linux/spinlock.h>
3740 +#include <linux/proc_fs.h>
3741 +#include <asm/io.h>
3742 +#include <linux/string.h>
3744 +#include "cpmacHalLx.h"
3747 +/* PSP config headers */
3748 +#include "psp_config_parse.h"
3749 +#include "psp_config_mgr.h"
3751 +/* Probe Debug Section*/
3754 +extern int cpmac_debug_mode;
3755 +#define dbgPrint if (cpmac_debug_mode) printk
3756 +#define errPrint printk
3758 +char CpmacSignature[] = "Cpmac driver";
3759 +static unsigned long irq_flags = 0;
3760 +OS_SETUP *p_os_setup = NULL;
3762 +extern int avalanche_request_intr_pacing(int, unsigned int, unsigned int);
3763 +extern int avalanche_free_intr_pacing(unsigned int blk_num);
3765 +/*----------------------------------------------------------------------------
3766 + * Parameter extracting functionalities.
3767 + *--------------------------------------------------------------------------*/
3768 +static int os_find_parm_u_int(void *info_ptr, const char *param, unsigned int *val)
3772 + if((ret_val = psp_config_get_param_uint(info_ptr, param, val)) == -1)
3774 + dbgPrint("Error: could not locate the requested \"%s\" param.\n",param);
3781 +static int os_find_parm_val(void *info_ptr, const char *param, void *val)
3785 + if(psp_config_get_param_string(info_ptr, param, val) == -1)
3787 + dbgPrint("Error: could not locate the requested \"%s\" param.\n",param);
3794 +static int os_find_device(int unit, const char *find_name, void *device_info)
3798 + if(psp_config_get((char *)find_name, unit, device_info) == -1)
3800 + dbgPrint("Error: could not locate the requested \"%s\" param.\n", find_name);
3807 +/*---------------------------------------------------------------------------
3808 + * Memory related OS abstraction.
3809 + *--------------------------------------------------------------------------*/
3810 +void os_free(void *mem_ptr)
3815 +void os_free_buffer(OS_RECEIVEINFO *osReceiveInfo, void *mem_ptr)
3817 + dev_kfree_skb_any(osReceiveInfo);
3820 +void os_free_dev(void *mem_ptr)
3825 +void os_free_dma_xfer(void *mem_ptr)
3830 +static void *os_malloc(unsigned int size)
3832 + return(kmalloc(size, GFP_KERNEL));
3835 +static void *os_malloc_dma_xfer(unsigned int size,
3837 + unsigned int mem_range)
3839 + return(kmalloc(size, GFP_KERNEL));
3842 +static void *os_malloc_dev(unsigned int size)
3844 + return(kmalloc(size, GFP_KERNEL));
3848 +/*----------------------------------------------------------------------------
3849 + * CRITICAL SECTION ENABLING/DISABLING.
3850 + *--------------------------------------------------------------------------*/
3851 +static void os_critical_on(void)
3853 + save_and_cli(irq_flags);
3856 +static void os_critical_off(void)
3858 + restore_flags(irq_flags);
3861 +/*----------------------------------------------------------------------------
3862 + * Cache related abstraction
3863 + *--------------------------------------------------------------------------*/
3864 +static void os_cache_invalidate(void *mem_ptr, int size)
3866 + dma_cache_inv((unsigned long)mem_ptr, size);
3869 +static void os_cache_writeback(void *mem_ptr, int size)
3871 + dma_cache_wback_inv((unsigned long)mem_ptr, size);
3874 +/*-----------------------------------------------------------------------------
3875 + * Support functions.
3876 + *---------------------------------------------------------------------------*/
3878 +static void hal_drv_unregister_isr(OS_DEVICE *p_dev, int intr)
3880 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_dev->priv;
3881 + CPMAC_ISR_INFO_T *p_isr_cb_param = &p_cpmac_priv->cpmac_isr;
3882 + intr = LNXINTNUM(intr);
3884 + free_irq(p_isr_cb_param->intr, p_isr_cb_param);
3886 + dbgPrint("cpmac_hal_unregister called for the intr %d for unit %x and isr_cb_param %x.\n",
3887 + intr, p_cpmac_priv->instance_num, (unsigned int )&p_cpmac_priv->cpmac_isr);
3891 +static void hal_drv_register_isr(OS_DEVICE *p_dev,
3892 + CPMAC_HAL_ISR_FUNC_T hal_isr, int intr)
3894 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_dev->priv;
3895 + CPMAC_DRV_HAL_INFO_T *p_drv_hal = p_cpmac_priv->drv_hal;
3896 + CPMAC_ISR_INFO_T *p_isr_cb_param = &p_cpmac_priv->cpmac_isr;
3897 + intr = LNXINTNUM(intr);
3899 + dbgPrint("osRegister called for the intr %d for device %x and p_isr_cb_param %x.\n",
3900 + intr, (bit32u)p_dev, (bit32u)p_isr_cb_param);
3902 + p_isr_cb_param->owner = p_drv_hal;
3903 + p_isr_cb_param->hal_isr = hal_isr;
3904 + p_isr_cb_param->intr = intr;
3906 + tasklet_init(&p_isr_cb_param->tasklet, cpmac_handle_tasklet, (unsigned long)p_isr_cb_param);
3907 + dbgPrint("Success in registering irq %d for Cpmac unit# %d.\n", intr, p_cpmac_priv->instance_num);
3910 +/*---------------------------------------------------------------------------
3911 + * FUNCTIONS called by the CPMAC Net Device.
3912 + *-------------------------------------------------------------------------*/
3913 +static int load_os_funcs(OS_FUNCTIONS *os_func)
3915 + dbgPrint("os_init_module: Start\n");
3916 + if( os_func == 0 )
3918 + return(sizeof(OS_FUNCTIONS));
3921 + os_func->Control = cpmac_hal_control;
3922 + os_func->CriticalOn = os_critical_on;
3923 + os_func->CriticalOff = os_critical_off;
3924 + os_func->DataCacheHitInvalidate = os_cache_invalidate;
3925 + os_func->DataCacheHitWriteback = os_cache_writeback;
3926 + os_func->DeviceFindInfo = os_find_device;
3927 + os_func->DeviceFindParmUint = os_find_parm_u_int;
3928 + os_func->DeviceFindParmValue= os_find_parm_val;
3929 + os_func->Free = os_free;
3930 + os_func->FreeRxBuffer = os_free_buffer;
3931 + os_func->FreeDev = os_free_dev;
3932 + os_func->FreeDmaXfer = os_free_dma_xfer;
3933 + os_func->IsrRegister = hal_drv_register_isr;
3934 + os_func->IsrUnRegister = hal_drv_unregister_isr;
3935 + os_func->Malloc = os_malloc;
3936 + os_func->MallocDev = os_malloc_dev;
3937 + os_func->MallocDmaXfer = os_malloc_dma_xfer;
3938 + os_func->MallocRxBuffer = cpmac_hal_malloc_buffer;
3939 + os_func->Memset = memset;
3940 + os_func->Printf = printk;
3941 + os_func->Receive = cpmac_hal_receive;
3942 + os_func->SendComplete = cpmac_hal_send_complete;
3943 + os_func->Strcmpi = cpmac_ci_strcmp;
3944 + os_func->TeardownComplete = cpmac_hal_tear_down_complete;
3945 + os_func->Strstr = strstr;
3946 + os_func->Strtoul = simple_strtol;
3947 + os_func->Sprintf = sprintf;
3948 + os_func->Strlen = strlen;
3950 + dbgPrint("os_init_module: Leave\n");
3956 +int cpmac_drv_init(CPMAC_DRV_HAL_INFO_T *p_drv_hal)
3958 + HAL_DEVICE *p_hal_dev = p_drv_hal->hal_dev;
3959 + HAL_FUNCTIONS *p_hal_funcs = p_drv_hal->hal_funcs;
3961 + return(p_hal_funcs->Init(p_hal_dev));
3964 +int cpmac_drv_cleanup(CPMAC_DRV_HAL_INFO_T *p_drv_hal)
3966 + HAL_DEVICE *p_hal_dev = p_drv_hal->hal_dev;
3967 + HAL_FUNCTIONS *p_hal_funcs = p_drv_hal->hal_funcs;
3969 + int ret_val = p_hal_funcs->Shutdown(p_hal_dev);
3973 + kfree(p_hal_funcs);
3978 + kfree(p_drv_hal->os_funcs);
3983 +int cpmac_drv_tx_setup(HAL_FUNCTIONS *p_hal_funcs,
3984 + HAL_DEVICE *p_hal_dev,
3985 + CPMAC_TX_CHAN_INFO_T *p_tx_chan_info)
3989 + CHANNEL_INFO chan_info;
3991 + /* Let's setup the TX Channels. */
3992 + for(count=0; count < p_tx_chan_info->cfg_chan; count++)
3994 + chan_info.Channel = count;
3995 + chan_info.Direction = DIRECTION_TX;
3996 + chan_info.TxNumBuffers = p_tx_chan_info->chan[count].num_BD;
3997 + chan_info.TxServiceMax = p_tx_chan_info->chan[count].service_max;
3998 + chan_info.TxNumQueues = 0;
4000 + if((ret_val = p_hal_funcs->ChannelSetup(p_hal_dev, &chan_info,
4003 + errPrint("Error in opening channel %d for TX.\n", count);
4008 + p_tx_chan_info->opened_chan++;
4014 +int cpmac_drv_rx_setup(HAL_FUNCTIONS *p_hal_funcs,
4015 + HAL_DEVICE *p_hal_dev,
4016 + CPMAC_RX_CHAN_INFO_T *p_rx_chan_info)
4019 + CHANNEL_INFO chan_info;
4021 + chan_info.Channel = 0;
4022 + chan_info.Direction = DIRECTION_RX;
4023 + chan_info.RxBufSize = p_rx_chan_info->chan[0].buffer_size;
4024 + chan_info.RxBufferOffset= p_rx_chan_info->chan[0].buffer_offset;
4025 + chan_info.RxNumBuffers = p_rx_chan_info->chan[0].num_BD;
4026 + chan_info.RxServiceMax = p_rx_chan_info->chan[0].service_max;
4028 + if(p_hal_funcs->ChannelSetup(p_hal_dev, &chan_info, p_rx_chan_info) != 0)
4030 + errPrint("Error in opening channel %d for RX.\n", 0);
4037 +int cpmac_drv_start(CPMAC_DRV_HAL_INFO_T *p_drv_hal,
4038 + CPMAC_TX_CHAN_INFO_T *p_tx_chan_info,
4039 + CPMAC_RX_CHAN_INFO_T *p_rx_chan_info,
4040 + unsigned int flags)
4043 + HAL_FUNCTIONS *p_hal_funcs = p_drv_hal->hal_funcs;
4044 + HAL_DEVICE *p_hal_dev = p_drv_hal->hal_dev;
4046 + dbgPrint("It is in cpmac_drv_start for %x.\n", (unsigned int)p_drv_hal);
4048 + if(flags & CHAN_SETUP)
4050 + if(cpmac_drv_tx_setup(p_hal_funcs, p_hal_dev,
4051 + p_tx_chan_info)!=0)
4053 + errPrint("Failed to set up tx channel(s).\n");
4056 + else if(cpmac_drv_rx_setup(p_hal_funcs, p_hal_dev,
4057 + p_rx_chan_info)!=0)
4059 + errPrint("Failed to set up rx channel.\n");
4068 + /* Error in setting up the Channels, quit. */
4069 + if((ret_val == 0) && (ret_val = p_hal_funcs->Open(p_hal_dev)) != 0)
4071 + errPrint("failed to open the HAL!!!.\n");
4076 +} /* cpmac_drv_start */
4080 +int cpmac_drv_tx_teardown(HAL_FUNCTIONS *p_hal_funcs,
4081 + HAL_DEVICE *p_hal_dev,
4082 + CPMAC_TX_CHAN_INFO_T *p_tx_chan_info,
4083 + unsigned int flags)
4088 + /* Let's setup the TX Channels. */
4089 + for(; p_tx_chan_info->opened_chan > 0;
4090 + p_tx_chan_info->opened_chan--, count++)
4092 + if(p_hal_funcs->ChannelTeardown(p_hal_dev, count, flags) != 0)
4094 + errPrint("Error in tearing down channel %d for TX.\n", count);
4104 +int cpmac_drv_rx_teardown(HAL_FUNCTIONS *p_hal_funcs,
4105 + HAL_DEVICE *p_hal_dev,
4106 + unsigned int flags)
4110 + if(p_hal_funcs->ChannelTeardown(p_hal_dev, 0, flags) != 0)
4112 + errPrint("Error in tearing down channel %d for RX.\n", 0);
4119 +int cpmac_drv_stop(CPMAC_DRV_HAL_INFO_T *p_drv_hal,
4120 + CPMAC_TX_CHAN_INFO_T *p_tx_chan_info,
4121 + CPMAC_RX_CHAN_INFO_T *p_rx_chan_info,
4122 + unsigned int flags)
4124 + HAL_DEVICE *p_hal_dev = p_drv_hal->hal_dev;
4125 + HAL_FUNCTIONS *p_hal_funcs = p_drv_hal->hal_funcs;
4128 + if(flags & CHAN_TEARDOWN)
4130 + unsigned int chan_flags = 0;
4132 + if(flags & FREE_BUFFER) chan_flags |= 0x4; /* full tear down */
4133 + if(flags & BLOCKING) chan_flags |= 0x8; /* blocking call */
4135 + dbgPrint("The teardown flags are %d.\n", flags);
4136 + dbgPrint("The teardown chan flags are %d.\n", chan_flags);
4138 + if(cpmac_drv_tx_teardown(p_hal_funcs, p_hal_dev,
4139 + p_tx_chan_info, chan_flags | 0x1) != 0)
4142 + errPrint("The tx channel teardown failed.\n");
4144 + else if(cpmac_drv_rx_teardown(p_hal_funcs, p_hal_dev, chan_flags | 0x2) != 0)
4147 + errPrint("The rx channel teardown failed.\n");
4157 + int close_flags = 1;
4159 + if(flags & FREE_BUFFER) close_flags = 2;
4160 +// if(flags & COMPLETE) close_flags = 3;
4162 + if(p_hal_funcs->Close(p_hal_dev, close_flags) != 0)
4171 +int cpmac_drv_init_module(CPMAC_DRV_HAL_INFO_T *p_drv_hal, OS_DEVICE *p_os_dev, int inst)
4174 + int hal_func_size;
4176 + dbgPrint("Entering the CpmacInitModule for the inst %d \n", inst);
4178 + if((p_drv_hal->os_funcs = kmalloc(sizeof(OS_FUNCTIONS), GFP_KERNEL)) == NULL)
4180 + errPrint("Failed to allocate memory for OS_FUNCTIONS.\n");
4182 + else if(load_os_funcs(p_drv_hal->os_funcs) != 0)
4184 + errPrint("Failed to load OS funcs.\n");
4185 + os_free(p_drv_hal->os_funcs);
4187 + else if(halCpmacInitModule(&p_drv_hal->hal_dev, p_os_dev,
4188 + &p_drv_hal->hal_funcs, p_drv_hal->os_funcs,
4189 + sizeof(*p_drv_hal->os_funcs),
4190 + &hal_func_size, inst) != 0)
4192 + errPrint("halCpmacInitModule failed for inst %d \n", inst);
4193 + os_free(p_drv_hal->os_funcs);
4195 + else if(p_drv_hal->hal_funcs->Probe(p_drv_hal->hal_dev) != 0)
4197 + errPrint("halCpmacProbe failed for inst %d \n", inst);
4198 + os_free(p_drv_hal->os_funcs);
4202 + /* every thing went well. */
4208 diff -urN linux.old/drivers/net/avalanche_cpmac/cpmacHalLx.h linux.dev/drivers/net/avalanche_cpmac/cpmacHalLx.h
4209 --- linux.old/drivers/net/avalanche_cpmac/cpmacHalLx.h 1970-01-01 01:00:00.000000000 +0100
4210 +++ linux.dev/drivers/net/avalanche_cpmac/cpmacHalLx.h 2005-07-12 02:48:42.044593000 +0200
4212 +/******************************************************************************
4213 + * FILE PURPOSE: CPMAC Linux Device Driver HAL support Header
4214 + ******************************************************************************
4215 + * FILE NAME: cpmacHalVx.h
4217 + * DESCRIPTION: CPMAC Linux Device Driver Header
4219 + * REVISION HISTORY:
4221 + * Date Description Author
4222 + *-----------------------------------------------------------------------------
4223 + * 27 Nov 2002 Initial Creation Suraj S Iyer
4224 + * 09 Jun 2003 Updates for GA Suraj S Iyer
4226 + * (C) Copyright 2002, Texas Instruments, Inc
4227 + *******************************************************************************/
4229 +#ifndef __CPMAC_HAL_LX_H
4230 +#define __CPMAC_HAL_LX_H
4233 +typedef struct net_device OS_DEVICE;
4234 +typedef struct sk_buff OS_RECEIVEINFO;
4235 +typedef struct sk_buff OS_SENDINFO;
4238 +typedef void HAL_RECEIVEINFO;
4239 +typedef void HAL_DEVICE;
4240 +typedef void OS_SETUP;
4243 +#define OS_SETUP void
4244 +#define HAL_DEVICE void
4245 +#define HAL_RECEIVEINFO void
4247 +#define _CPHAL_CPMAC
4249 +#include "cpswhal_cpmac.h"
4252 +int cpmac_drv_start(CPMAC_DRV_HAL_INFO_T *, CPMAC_TX_CHAN_INFO_T*,
4253 + CPMAC_RX_CHAN_INFO_T *, unsigned int);
4254 +int cpmac_drv_cleanup(CPMAC_DRV_HAL_INFO_T *);
4255 +int cpmac_drv_init(CPMAC_DRV_HAL_INFO_T*);
4256 +int cpmac_drv_close(CPMAC_DRV_HAL_INFO_T*);
4257 +int cpmac_drv_open(CPMAC_DRV_HAL_INFO_T*);
4258 +int cpmac_drv_init_module(CPMAC_DRV_HAL_INFO_T*, OS_DEVICE*, int);
4259 +int cpmac_drv_stop(CPMAC_DRV_HAL_INFO_T *p_drv_hal,CPMAC_TX_CHAN_INFO_T *p_tx_chan_info,
4260 + CPMAC_RX_CHAN_INFO_T *p_rx_chan_info,unsigned int flags);
4263 diff -urN linux.old/drivers/net/avalanche_cpmac/cpmac_reg.h linux.dev/drivers/net/avalanche_cpmac/cpmac_reg.h
4264 --- linux.old/drivers/net/avalanche_cpmac/cpmac_reg.h 1970-01-01 01:00:00.000000000 +0100
4265 +++ linux.dev/drivers/net/avalanche_cpmac/cpmac_reg.h 2005-07-12 02:48:42.045593000 +0200
4267 +/****************************************************************************
4268 + TNETD73xx Software Support
4269 + Copyright(c) 2000, Texas Instruments Incorporated. All Rights Reserved.
4271 + FILE: cpmac_reg.h Register definitions for the CPMAC module
4274 + This include file contains register definitions for the
4278 + 15Nov00 BEGR Original version written
4279 + 30May02 MICK Added bits for Int Vector
4280 + 19Sep02 MICK Added INT_ACK per Channel
4281 + 08Nov02 GDUN Updated to use base
4282 + 12Nov02 MICK Incorporated into CPHAL
4283 +*****************************************************************************/
4284 +#ifndef _INC_CPMAC_REG
4285 +#define _INC_CPMAC_REG
4288 +#define MEM_PTR volatile bit32u *
4291 +/***************************************************************************
4293 + * C P M A C M E M O R Y M A P
4295 + **************************************************************************/
4297 +#define pCPMAC_TX_IDVER(base) ((MEM_PTR)(base+0x000))
4298 +#define CPMAC_TX_IDVER(base) (*pCPMAC_TX_IDVER(base))
4299 +#define pCPMAC_TX_CONTROL(base) ((MEM_PTR)(base+0x004))
4300 +#define CPMAC_TX_CONTROL(base) (*pCPMAC_TX_CONTROL(base))
4301 +#define pCPMAC_TX_TEARDOWN(base) ((MEM_PTR)(base+0x008))
4302 +#define CPMAC_TX_TEARDOWN(base) (*pCPMAC_TX_TEARDOWN(base))
4303 +#define pCPMAC_RX_IDVER(base) ((MEM_PTR)(base+0x010))
4304 +#define CPMAC_RX_IDVER(base) (*pCPMAC_RX_IDVER(base))
4305 +#define pCPMAC_RX_CONTROL(base) ((MEM_PTR)(base+0x014))
4306 +#define CPMAC_RX_CONTROL(base) (*pCPMAC_RX_CONTROL(base))
4307 +#define pCPMAC_RX_TEARDOWN(base) ((MEM_PTR)(base+0x018))
4308 +#define CPMAC_RX_TEARDOWN(base) (*pCPMAC_RX_TEARDOWN(base))
4309 +#define pCPMAC_RX_MBP_ENABLE(base) ((MEM_PTR)(base+0x100))
4310 +#define CPMAC_RX_MBP_ENABLE(base) (*pCPMAC_RX_MBP_ENABLE(base))
4311 +#define pCPMAC_RX_UNICAST_SET(base) ((MEM_PTR)(base+0x104))
4312 +#define CPMAC_RX_UNICAST_SET(base) (*pCPMAC_RX_UNICAST_SET(base))
4313 +#define pCPMAC_RX_UNICAST_CLEAR(base) ((MEM_PTR)(base+0x108))
4314 +#define CPMAC_RX_UNICAST_CLEAR(base) (*pCPMAC_RX_UNICAST_CLEAR(base))
4315 +#define pCPMAC_RX_MAXLEN(base) ((MEM_PTR)(base+0x10C))
4316 +#define CPMAC_RX_MAXLEN(base) (*pCPMAC_RX_MAXLEN(base))
4317 +#define pCPMAC_RX_BUFFER_OFFSET(base) ((MEM_PTR)(base+0x110))
4318 +#define CPMAC_RX_BUFFER_OFFSET(base) (*pCPMAC_RX_BUFFER_OFFSET(base))
4319 +#define pCPMAC_RX_FILTERLOWTHRESH(base) ((MEM_PTR)(base+0x114))
4320 +#define CPMAC_RX_FILTERLOWTHRESH(base) (*pCPMAC_RX_FILTERLOWTHRESH(base))
4321 +#define pCPMAC_RX0_FLOWTHRESH(base) ((MEM_PTR)(base+0x120))
4322 +#define CPMAC_RX0_FLOWTHRESH(base) (*pCPMAC_RX0_FLOWTHRESH(base))
4323 +#define pCPMAC_RX1_FLOWTHRESH(base) ((MEM_PTR)(base+0x124))
4324 +#define CPMAC_RX1_FLOWTHRESH(base) (*pCPMAC_RX1_FLOWTHRESH(base))
4325 +#define pCPMAC_RX2_FLOWTHRESH(base) ((MEM_PTR)(base+0x128))
4326 +#define CPMAC_RX2_FLOWTHRESH(base) (*pCPMAC_RX2_FLOWTHRESH(base))
4327 +#define pCPMAC_RX3_FLOWTHRESH(base) ((MEM_PTR)(base+0x12C))
4328 +#define CPMAC_RX3_FLOWTHRESH(base) (*pCPMAC_RX3_FLOWTHRESH(base))
4329 +#define pCPMAC_RX4_FLOWTHRESH(base) ((MEM_PTR)(base+0x130))
4330 +#define CPMAC_RX4_FLOWTHRESH(base) (*pCPMAC_RX4_FLOWTHRESH(base))
4331 +#define pCPMAC_RX5_FLOWTHRESH(base) ((MEM_PTR)(base+0x134))
4332 +#define CPMAC_RX5_FLOWTHRESH(base) (*pCPMAC_RX5_FLOWTHRESH(base))
4333 +#define pCPMAC_RX6_FLOWTHRESH(base) ((MEM_PTR)(base+0x138))
4334 +#define CPMAC_RX6_FLOWTHRESH(base) (*pCPMAC_RX6_FLOWTHRESH(base))
4335 +#define pCPMAC_RX7_FLOWTHRESH(base) ((MEM_PTR)(base+0x13C))
4336 +#define CPMAC_RX7_FLOWTHRESH(base) (*pCPMAC_RX7_FLOWTHRESH(base))
4337 +#define pCPMAC_RX0_FREEBUFFER(base) ((MEM_PTR)(base+0x140))
4338 +#define CPMAC_RX0_FREEBUFFER(base) (*pCPMAC_RX0_FREEBUFFER(base))
4339 +#define pCPMAC_RX1_FREEBUFFER(base) ((MEM_PTR)(base+0x144))
4340 +#define CPMAC_RX1_FREEBUFFER(base) (*pCPMAC_RX1_FREEBUFFER(base))
4341 +#define pCPMAC_RX2_FREEBUFFER(base) ((MEM_PTR)(base+0x148))
4342 +#define CPMAC_RX2_FREEBUFFER(base) (*pCPMAC_RX2_FREEBUFFER(base))
4343 +#define pCPMAC_RX3_FREEBUFFER(base) ((MEM_PTR)(base+0x14C))
4344 +#define CPMAC_RX3_FREEBUFFER(base) (*pCPMAC_RX3_FREEBUFFER(base))
4345 +#define pCPMAC_RX4_FREEBUFFER(base) ((MEM_PTR)(base+0x150))
4346 +#define CPMAC_RX4_FREEBUFFER(base) (*pCPMAC_RX4_FREEBUFFER(base))
4347 +#define pCPMAC_RX5_FREEBUFFER(base) ((MEM_PTR)(base+0x154))
4348 +#define CPMAC_RX5_FREEBUFFER(base) (*pCPMAC_RX5_FREEBUFFER(base))
4349 +#define pCPMAC_RX6_FREEBUFFER(base) ((MEM_PTR)(base+0x158))
4350 +#define CPMAC_RX6_FREEBUFFER(base) (*pCPMAC_RX6_FREEBUFFER(base))
4351 +#define pCPMAC_RX7_FREEBUFFER(base) ((MEM_PTR)(base+0x15C))
4352 +#define CPMAC_RX7_FREEBUFFER(base) (*pCPMAC_RX7_FREEBUFFER(base))
4353 +#define pCPMAC_MACCONTROL(base) ((MEM_PTR)(base+0x160))
4354 +#define CPMAC_MACCONTROL(base) (*pCPMAC_MACCONTROL(base))
4355 +#define pCPMAC_MACSTATUS(base) ((MEM_PTR)(base+0x164))
4356 +#define CPMAC_MACSTATUS(base) (*pCPMAC_MACSTATUS(base))
4357 +#define pCPMAC_EMCONTROL(base) ((MEM_PTR)(base+0x168))
4358 +#define CPMAC_EMCONTROL(base) (*pCPMAC_EMCONTROL(base))
4359 +#define pCPMAC_TX_INTSTAT_RAW(base) ((MEM_PTR)(base+0x170))
4360 +#define CPMAC_TX_INTSTAT_RAW(base) (*pCPMAC_TX_INTSTAT_RAW(base))
4361 +#define pCPMAC_TX_INTSTAT_MASKED(base) ((MEM_PTR)(base+0x174))
4362 +#define CPMAC_TX_INTSTAT_MASKED(base) (*pCPMAC_TX_INTSTAT_MASKED(base))
4363 +#define pCPMAC_TX_INTMASK_SET(base) ((MEM_PTR)(base+0x178))
4364 +#define CPMAC_TX_INTMASK_SET(base) (*pCPMAC_TX_INTMASK_SET(base))
4365 +#define pCPMAC_TX_INTMASK_CLEAR(base) ((MEM_PTR)(base+0x17C))
4366 +#define CPMAC_TX_INTMASK_CLEAR(base) (*pCPMAC_TX_INTMASK_CLEAR(base))
4367 +#define pCPMAC_MAC_IN_VECTOR(base) ((MEM_PTR)(base+0x180))
4368 +#define CPMAC_MAC_IN_VECTOR(base) (*pCPMAC_MAC_IN_VECTOR(base))
4369 +#define pCPMAC_MAC_EOI_VECTOR(base) ((MEM_PTR)(base+0x184))
4370 +#define CPMAC_MAC_EOI_VECTOR(base) (*pCPMAC_MAC_EOI_VECTOR(base))
4371 +#define pCPMAC_RX_INTSTAT_RAW(base) ((MEM_PTR)(base+0x190))
4372 +#define CPMAC_RX_INTSTAT_RAW(base) (*pCPMAC_RX_INTSTAT_RAW(base))
4373 +#define pCPMAC_RX_INTSTAT_MASKED(base) ((MEM_PTR)(base+0x194))
4374 +#define CPMAC_RX_INTSTAT_MASKED(base) (*pCPMAC_RX_INTSTAT_MASKED(base))
4375 +#define pCPMAC_RX_INTMASK_SET(base) ((MEM_PTR)(base+0x198))
4376 +#define CPMAC_RX_INTMASK_SET(base) (*pCPMAC_RX_INTMASK_SET(base))
4377 +#define pCPMAC_RX_INTMASK_CLEAR(base) ((MEM_PTR)(base+0x19C))
4378 +#define CPMAC_RX_INTMASK_CLEAR(base) (*pCPMAC_RX_INTMASK_CLEAR(base))
4379 +#define pCPMAC_MAC_INTSTAT_RAW(base) ((MEM_PTR)(base+0x1A0))
4380 +#define CPMAC_MAC_INTSTAT_RAW(base) (*pCPMAC_MAC_INTSTAT_RAW(base))
4381 +#define pCPMAC_MAC_INTSTAT_MASKED(base) ((MEM_PTR)(base+0x1A4))
4382 +#define CPMAC_MAC_INTSTAT_MASKED(base) (*pCPMAC_MAC_INTSTAT_MASKED(base))
4383 +#define pCPMAC_MAC_INTMASK_SET(base) ((MEM_PTR)(base+0x1A8))
4384 +#define CPMAC_MAC_INTMASK_SET(base) (*pCPMAC_MAC_INTMASK_SET(base))
4385 +#define pCPMAC_MAC_INTMASK_CLEAR(base) ((MEM_PTR)(base+0x1AC))
4386 +#define CPMAC_MAC_INTMASK_CLEAR(base) (*pCPMAC_MAC_INTMASK_CLEAR(base))
4387 +#define pCPMAC_MACADDRLO_0(base) ((MEM_PTR)(base+0x1B0))
4388 +#define CPMAC_MACADDRLO_0(base) (*pCPMAC_MACADDRLO_0(base))
4389 +#define pCPMAC_MACADDRLO_1(base) ((MEM_PTR)(base+0x1B4))
4390 +#define CPMAC_MACADDRLO_1(base) (*pCPMAC_MACADDRLO_1(base))
4391 +#define pCPMAC_MACADDRLO_2(base) ((MEM_PTR)(base+0x1B8))
4392 +#define CPMAC_MACADDRLO_2(base) (*pCPMAC_MACADDRLO_2(base))
4393 +#define pCPMAC_MACADDRLO_3(base) ((MEM_PTR)(base+0x1BC))
4394 +#define CPMAC_MACADDRLO_3(base) (*pCPMAC_MACADDRLO_3(base))
4395 +#define pCPMAC_MACADDRLO_4(base) ((MEM_PTR)(base+0x1C0))
4396 +#define CPMAC_MACADDRLO_4(base) (*pCPMAC_MACADDRLO_4(base))
4397 +#define pCPMAC_MACADDRLO_5(base) ((MEM_PTR)(base+0x1C4))
4398 +#define CPMAC_MACADDRLO_5(base) (*pCPMAC_MACADDRLO_5(base))
4399 +#define pCPMAC_MACADDRLO_6(base) ((MEM_PTR)(base+0x1C8))
4400 +#define CPMAC_MACADDRLO_6(base) (*pCPMAC_MACADDRLO_6(base))
4401 +#define pCPMAC_MACADDRLO_7(base) ((MEM_PTR)(base+0x1CC))
4402 +#define CPMAC_MACADDRLO_7(base) (*pCPMAC_MACADDRLO_7(base))
4403 +#define pCPMAC_MACADDRMID(base) ((MEM_PTR)(base+0x1D0))
4404 +#define CPMAC_MACADDRMID(base) (*pCPMAC_MACADDRMID(base))
4405 +#define pCPMAC_MACADDRHI(base) ((MEM_PTR)(base+0x1D4))
4406 +#define CPMAC_MACADDRHI(base) (*pCPMAC_MACADDRHI(base))
4407 +#define pCPMAC_MACHASH1(base) ((MEM_PTR)(base+0x1D8))
4408 +#define CPMAC_MACHASH1(base) (*pCPMAC_MACHASH1(base))
4409 +#define pCPMAC_MACHASH2(base) ((MEM_PTR)(base+0x1DC))
4410 +#define CPMAC_MACHASH2(base) (*pCPMAC_MACHASH2(base))
4411 +#define pCPMAC_BOFFTEST(base) ((MEM_PTR)(base+0x1E0))
4412 +#define CPMAC_BOFFTEST(base) (*pCPMAC_BOFFTEST(base))
4413 +#define pCPMAC_PACTEST(base) ((MEM_PTR)(base+0x1E4))
4414 +#define CPMAC_PACTEST(base) (*pCPMAC_PACTEST(base))
4415 +#define pCPMAC_RXPAUSE(base) ((MEM_PTR)(base+0x1E8))
4416 +#define CPMAC_RXPAUSE(base) (*pCPMAC_RXPAUSE(base))
4417 +#define pCPMAC_TXPAUSE(base) ((MEM_PTR)(base+0x1EC))
4418 +#define CPMAC_TXPAUSE(base) (*pCPMAC_TXPAUSE(base))
4420 +#define pCPMAC_RXGOODFRAMES(base) ((MEM_PTR)(base+0x200))
4421 +#define CPMAC_RXGOODFRAMES(base) (*pCPMAC_RXGOODFRAMES(base))
4422 +#define pCPMAC_RXBROADCASTFRAMES(base) ((MEM_PTR)(base+0x204))
4423 +#define CPMAC_RXBROADCASTFRAMES(base) (*pCPMAC_RXBROADCASTFRAMES(base))
4424 +#define pCPMAC_RXMULTICASTFRAMES(base) ((MEM_PTR)(base+0x208))
4425 +#define CPMAC_RXMULTICASTFRAMES(base) (*pCPMAC_RXMULTICASTFRAMES(base))
4426 +#define pCPMAC_RXPAUSEFRAMES(base) ((MEM_PTR)(base+0x20C))
4427 +#define CPMAC_RXPAUSEFRAMES(base) (*pCPMAC_RXPAUSEFRAMES(base))
4428 +#define pCPMAC_RXCRCERRORS(base) ((MEM_PTR)(base+0x210))
4429 +#define CPMAC_RXCRCERRORS(base) (*pCPMAC_RXCRCERRORS(base))
4430 +#define pCPMAC_RXALIGNCODEERRORS(base) ((MEM_PTR)(base+0x214))
4431 +#define CPMAC_RXALIGNCODEERRORS(base) (*pCPMAC_RXALIGNCODEERRORS(base))
4432 +#define pCPMAC_RXOVERSIZEDFRAMES(base) ((MEM_PTR)(base+0x218))
4433 +#define CPMAC_RXOVERSIZEDFRAMES(base) (*pCPMAC_RXOVERSIZEDFRAMES(base))
4434 +#define pCPMAC_RXJABBERFRAMES(base) ((MEM_PTR)(base+0x21C))
4435 +#define CPMAC_RXJABBERFRAMES(base) (*pCPMAC_RXJABBERFRAMES(base))
4436 +#define pCPMAC_RXUNDERSIZEDFRAMES(base) ((MEM_PTR)(base+0x220))
4437 +#define CPMAC_RXUNDERSIZEDFRAMES(base) (*pCPMAC_RXUNDERSIZEDFRAMES(base))
4438 +#define pCPMAC_RXFRAGMENTS(base) ((MEM_PTR)(base+0x224))
4439 +#define CPMAC_RXFRAGMENTS(base) (*pCPMAC_RXFRAGMENTS(base))
4440 +#define pCPMAC_RXFILTEREDFRAMES(base) ((MEM_PTR)(base+0x228))
4441 +#define CPMAC_RXFILTEREDFRAMES(base) (*pCPMAC_RXFILTEREDFRAMES(base))
4442 +#define pCPMAC_RXQOSFILTEREDFRAMES(base) ((MEM_PTR)(base+0x22C))
4443 +#define CPMAC_RXQOSFILTEREDFRAMES(base) (*pCPMAC_RXQOSFILTEREDFRAMES(base))
4444 +#define pCPMAC_RXOCTETS(base) ((MEM_PTR)(base+0x230))
4445 +#define CPMAC_RXOCTETS(base) (*pCPMAC_RXOCTETS(base))
4446 +#define pCPMAC_TXGOODFRAMES(base) ((MEM_PTR)(base+0x234))
4447 +#define CPMAC_TXGOODFRAMES(base) (*pCPMAC_TXGOODFRAMES(base))
4448 +#define pCPMAC_TXBROADCASTFRAMES(base) ((MEM_PTR)(base+0x238))
4449 +#define CPMAC_TXBROADCASTFRAMES(base) (*pCPMAC_TXBROADCASTFRAMES(base))
4450 +#define pCPMAC_TXMULTICASTFRAMES(base) ((MEM_PTR)(base+0x23C))
4451 +#define CPMAC_TXMULTICASTFRAMES(base) (*pCPMAC_TXMULTICASTFRAMES(base))
4452 +#define pCPMAC_TXPAUSEFRAMES(base) ((MEM_PTR)(base+0x240))
4453 +#define CPMAC_TXPAUSEFRAMES(base) (*pCPMAC_TXPAUSEFRAMES(base))
4454 +#define pCPMAC_TXDEFERREDFRAMES(base) ((MEM_PTR)(base+0x244))
4455 +#define CPMAC_TXDEFERREDFRAMES(base) (*pCPMAC_TXDEFERREDFRAMES(base))
4456 +#define pCPMAC_TXCOLLISIONFRAMES(base) ((MEM_PTR)(base+0x248))
4457 +#define CPMAC_TXCOLLISIONFRAMES(base) (*pCPMAC_TXCOLLISIONFRAMES(base))
4458 +#define pCPMAC_TXSINGLECOLLFRAMES(base) ((MEM_PTR)(base+0x24C))
4459 +#define CPMAC_TXSINGLECOLLFRAMES(base) (*pCPMAC_TXSINGLECOLLFRAMES(base))
4460 +#define pCPMAC_TXMULTCOLLFRAMES(base) ((MEM_PTR)(base+0x250))
4461 +#define CPMAC_TXMULTCOLLFRAMES(base) (*pCPMAC_TXMULTCOLLFRAMES(base))
4462 +#define pCPMAC_TXEXCESSIVECOLLISIONS(base) ((MEM_PTR)(base+0x254))
4463 +#define CPMAC_TXEXCESSIVECOLLISIONS(base) (*pCPMAC_TXEXCESSIVECOLLISIONS(base))
4464 +#define pCPMAC_TXLATECOLLISIONS(base) ((MEM_PTR)(base+0x258))
4465 +#define CPMAC_TXLATECOLLISIONS(base) (*pCPMAC_TXLATECOLLISIONS(base))
4466 +#define pCPMAC_TXUNDERRUN(base) ((MEM_PTR)(base+0x25C))
4467 +#define CPMAC_TXUNDERRUN(base) (*pCPMAC_TXUNDERRUN(base))
4468 +#define pCPMAC_TXCARRIERSENSEERRORS(base) ((MEM_PTR)(base+0x260))
4469 +#define CPMAC_TXCARRIERSENSEERRORS(base) (*pCPMAC_TXCARRIERSENSEERRORS(base))
4470 +#define pCPMAC_TXOCTETS(base) ((MEM_PTR)(base+0x264))
4471 +#define CPMAC_TXOCTETS(base) (*pCPMAC_TXOCTETS(base))
4472 +#define pCPMAC_64OCTETFRAMES(base) ((MEM_PTR)(base+0x268))
4473 +#define CPMAC_64OCTETFRAMES(base) (*pCPMAC_64OCTETFRAMES(base))
4474 +#define pCPMAC_65T127OCTETFRAMES(base) ((MEM_PTR)(base+0x26C))
4475 +#define CPMAC_65T127OCTETFRAMES(base) (*pCPMAC_65T127OCTETFRAMES(base))
4476 +#define pCPMAC_128T255OCTETFRAMES(base) ((MEM_PTR)(base+0x270))
4477 +#define CPMAC_128T255OCTETFRAMES(base) (*pCPMAC_128T255OCTETFRAMES(base))
4478 +#define pCPMAC_256T511OCTETFRAMES(base) ((MEM_PTR)(base+0x274))
4479 +#define CPMAC_256T511OCTETFRAMES(base) (*pCPMAC_256T511OCTETFRAMES(base))
4480 +#define pCPMAC_512T1023OCTETFRAMES(base) ((MEM_PTR)(base+0x278))
4481 +#define CPMAC_512T1023OCTETFRAMES(base) (*pCPMAC_512T1023OCTETFRAMES(base))
4482 +#define pCPMAC_1024TUPOCTETFRAMES(base) ((MEM_PTR)(base+0x27C))
4483 +#define CPMAC_1024TUPOCTETFRAMES(base) (*pCPMAC_1024TUPOCTETFRAMES(base))
4484 +#define pCPMAC_NETOCTETS(base) ((MEM_PTR)(base+0x280))
4485 +#define CPMAC_NETOCTETS(base) (*pCPMAC_NETOCTETS(base))
4486 +#define pCPMAC_RXSOFOVERRUNS(base) ((MEM_PTR)(base+0x284))
4487 +#define CPMAC_RXSOFOVERRUNS(base) (*pCPMAC_RXSOFOVERRUNS(base))
4488 +#define pCPMAC_RXMOFOVERRUNS(base) ((MEM_PTR)(base+0x288))
4489 +#define CPMAC_RXMOFOVERRUNS(base) (*pCPMAC_RXMOFOVERRUNS(base))
4490 +#define pCPMAC_RXDMAOVERRUNS(base) ((MEM_PTR)(base+0x28C))
4491 +#define CPMAC_RXDMAOVERRUNS(base) (*pCPMAC_RXDMAOVERRUNS(base))
4493 +#define CPMAC_TX_HDP(base,ch) (*(MEM_PTR)(base+0x600+(4*ch)))
4494 +#define pCPMAC_TX0_HDP(base) ((MEM_PTR)(base+0x600))
4495 +#define CPMAC_TX0_HDP(base) (*pCPMAC_TX0_HDP(base))
4496 +#define pCPMAC_TX1_HDP(base) ((MEM_PTR)(base+0x604))
4497 +#define CPMAC_TX1_HDP(base) (*pCPMAC_TX1_HDP(base))
4498 +#define pCPMAC_TX2_HDP(base) ((MEM_PTR)(base+0x608))
4499 +#define CPMAC_TX2_HDP(base) (*pCPMAC_TX2_HDP(base))
4500 +#define pCPMAC_TX3_HDP(base) ((MEM_PTR)(base+0x60C))
4501 +#define CPMAC_TX3_HDP(base) (*pCPMAC_TX3_HDP(base))
4502 +#define pCPMAC_TX4_HDP(base) ((MEM_PTR)(base+0x610))
4503 +#define CPMAC_TX4_HDP(base) (*pCPMAC_TX4_HDP(base))
4504 +#define pCPMAC_TX5_HDP(base) ((MEM_PTR)(base+0x614))
4505 +#define CPMAC_TX5_HDP(base) (*pCPMAC_TX5_HDP(base))
4506 +#define pCPMAC_TX6_HDP(base) ((MEM_PTR)(base+0x618))
4507 +#define CPMAC_TX6_HDP(base) (*pCPMAC_TX6_HDP(base))
4508 +#define pCPMAC_TX7_HDP(base) ((MEM_PTR)(base+0x61C))
4509 +#define CPMAC_TX7_HDP(base) (*pCPMAC_TX7_HDP(base))
4510 +#define CPMAC_RX_HDP(base,ch) (*(MEM_PTR)(base+0x620+(4*ch)))
4511 +#define pCPMAC_RX0_HDP(base) ((MEM_PTR)(base+0x620))
4512 +#define CPMAC_RX0_HDP(base) (*pCPMAC_RX0_HDP(base))
4513 +#define pCPMAC_RX1_HDP(base) ((MEM_PTR)(base+0x624))
4514 +#define CPMAC_RX1_HDP(base) (*pCPMAC_RX1_HDP(base))
4515 +#define pCPMAC_RX2_HDP(base) ((MEM_PTR)(base+0x628))
4516 +#define CPMAC_RX2_HDP(base) (*pCPMAC_RX2_HDP(base))
4517 +#define pCPMAC_RX3_HDP(base) ((MEM_PTR)(base+0x62C))
4518 +#define CPMAC_RX3_HDP(base) (*pCPMAC_RX3_HDP(base))
4519 +#define pCPMAC_RX4_HDP(base) ((MEM_PTR)(base+0x630))
4520 +#define CPMAC_RX4_HDP(base) (*pCPMAC_RX4_HDP(base))
4521 +#define pCPMAC_RX5_HDP(base) ((MEM_PTR)(base+0x634))
4522 +#define CPMAC_RX5_HDP(base) (*pCPMAC_RX5_HDP(base))
4523 +#define pCPMAC_RX6_HDP(base) ((MEM_PTR)(base+0x638))
4524 +#define CPMAC_RX6_HDP(base) (*pCPMAC_RX6_HDP(base))
4525 +#define pCPMAC_RX7_HDP(base) ((MEM_PTR)(base+0x63C))
4526 +#define CPMAC_RX7_HDP(base) (*pCPMAC_RX7_HDP(base))
4529 +#define CPMAC_TX_INT_ACK(base,ch) (*(MEM_PTR)(base+0x640+(4*ch)))
4531 +#define pCPMAC_TX0_INT_ACK(base) ((MEM_PTR)(base+0x640))
4532 +#define CPMAC_TX0_INT_ACK(base) (*pCPMAC_TX0_INT_ACK(base))
4533 +#define pCPMAC_TX1_INT_ACK(base) ((MEM_PTR)(base+0x644))
4534 +#define CPMAC_TX1_INT_ACK(base) (*pCPMAC_TX1_INT_ACK(base))
4535 +#define pCPMAC_TX2_INT_ACK(base) ((MEM_PTR)(base+0x648))
4536 +#define CPMAC_TX2_INT_ACK(base) (*pCPMAC_TX2_INT_ACK(base))
4537 +#define pCPMAC_TX3_INT_ACK(base) ((MEM_PTR)(base+0x64C))
4538 +#define CPMAC_TX3_INT_ACK(base) (*pCPMAC_TX3_INT_ACK(base))
4539 +#define pCPMAC_TX4_INT_ACK(base) ((MEM_PTR)(base+0x650))
4540 +#define CPMAC_TX4_INT_ACK(base) (*pCPMAC_TX4_INT_ACK(base))
4541 +#define pCPMAC_TX5_INT_ACK(base) ((MEM_PTR)(base+0x654))
4542 +#define CPMAC_TX5_INT_ACK(base) (*pCPMAC_TX5_INT_ACK(base))
4543 +#define pCPMAC_TX6_INT_ACK(base) ((MEM_PTR)(base+0x658))
4544 +#define CPMAC_TX6_INT_ACK(base) (*pCPMAC_TX6_INT_ACK(base))
4545 +#define pCPMAC_TX7_INT_ACK(base) ((MEM_PTR)(base+0x65C))
4546 +#define CPMAC_TX7_INT_ACK(base) (*pCPMAC_TX7_INT_ACK(base))
4547 +#define CPMAC_RX_INT_ACK(base,ch) (*(MEM_PTR)(base+0x660+(4*ch)))
4549 +#define pCPMAC_RX0_INT_ACK(base) ((MEM_PTR)(base+0x660))
4550 +#define CPMAC_RX0_INT_ACK(base) (*pCPMAC_RX0_INT_ACK(base))
4551 +#define pCPMAC_RX1_INT_ACK(base) ((MEM_PTR)(base+0x664))
4552 +#define CPMAC_RX1_INT_ACK(base) (*pCPMAC_RX1_INT_ACK(base))
4553 +#define pCPMAC_RX2_INT_ACK(base) ((MEM_PTR)(base+0x668))
4554 +#define CPMAC_RX2_INT_ACK(base) (*pCPMAC_RX2_INT_ACK(base))
4555 +#define pCPMAC_RX3_INT_ACK(base) ((MEM_PTR)(base+0x66C))
4556 +#define CPMAC_RX3_INT_ACK(base) (*pCPMAC_RX3_INT_ACK(base))
4557 +#define pCPMAC_RX4_INT_ACK(base) ((MEM_PTR)(base+0x670))
4558 +#define CPMAC_RX4_INT_ACK(base) (*pCPMAC_RX4_INT_ACK(base))
4559 +#define pCPMAC_RX5_INT_ACK(base) ((MEM_PTR)(base+0x674))
4560 +#define CPMAC_RX5_INT_ACK(base) (*pCPMAC_RX5_INT_ACK(base))
4561 +#define pCPMAC_RX6_INT_ACK(base) ((MEM_PTR)(base+0x678))
4562 +#define CPMAC_RX6_INT_ACK(base) (*pCPMAC_RX6_INT_ACK(base))
4563 +#define pCPMAC_RX7_INT_ACK(base) ((MEM_PTR)(base+0x67C))
4564 +#define CPMAC_RX7_INT_ACK(base) (*pCPMAC_RX7_INT_ACK(base))
4566 +/****************************************************************************/
4568 +/* R E G I S T E R B I T D E F I N I T I O N S */
4570 +/****************************************************************************/
4574 +#define TX_EN (1 << 0)
4578 +#define RX_EN (1 << 0)
4580 +/* RX_MBP_ENABLE */
4582 +#define RX_PASS_CRC (1 << 30)
4583 +#define RX_QOS_EN (1 << 29)
4584 +#define RX_NO_CHAIN (1 << 28)
4586 +#define RX_CMF_EN (1 << 24)
4587 +#define RX_CSF_EN (1 << 23)
4588 +#define RX_CEF_EN (1 << 22)
4589 +#define RX_CAF_EN (1 << 21)
4591 +#define RX_PROM_CH(n) (n << 16)
4592 +#define RX_PROM_CH_MASK RX_PROM_CH(7)
4593 +#define RX_PROM_CH_7 RX_PROM_CH(7)
4594 +#define RX_PROM_CH_6 RX_PROM_CH(6)
4595 +#define RX_PROM_CH_5 RX_PROM_CH(5)
4596 +#define RX_PROM_CH_4 RX_PROM_CH(4)
4597 +#define RX_PROM_CH_3 RX_PROM_CH(3)
4598 +#define RX_PROM_CH_2 RX_PROM_CH(2)
4599 +#define RX_PROM_CH_1 RX_PROM_CH(1)
4600 +#define RX_PROM_CH_0 RX_PROM_CH(0)
4602 +#define RX_BROAD_EN (1 << 13)
4604 +#define RX_BROAD_CH(n) (n << 8)
4605 +#define RX_BROAD_CH_MASK RX_BROAD_CH(7)
4606 +#define RX_BROAD_CH_7 RX_BROAD_CH(7)
4607 +#define RX_BROAD_CH_6 RX_BROAD_CH(6)
4608 +#define RX_BROAD_CH_5 RX_BROAD_CH(5)
4609 +#define RX_BROAD_CH_4 RX_BROAD_CH(4)
4610 +#define RX_BROAD_CH_3 RX_BROAD_CH(3)
4611 +#define RX_BROAD_CH_2 RX_BROAD_CH(2)
4612 +#define RX_BROAD_CH_1 RX_BROAD_CH(1)
4613 +#define RX_BROAD_CH_0 RX_BROAD_CH(0)
4615 +#define RX_MULT_EN (1 << 5)
4617 +#define RX_MULT_CH(n) (n << 0)
4618 +#define RX_MULT_CH_MASK RX_MULT_CH(7)
4619 +#define RX_MULT_CH_7 RX_MULT_CH(7)
4620 +#define RX_MULT_CH_6 RX_MULT_CH(6)
4621 +#define RX_MULT_CH_5 RX_MULT_CH(5)
4622 +#define RX_MULT_CH_4 RX_MULT_CH(4)
4623 +#define RX_MULT_CH_3 RX_MULT_CH(3)
4624 +#define RX_MULT_CH_2 RX_MULT_CH(2)
4625 +#define RX_MULT_CH_1 RX_MULT_CH(1)
4626 +#define RX_MULT_CH_0 RX_MULT_CH(0)
4630 +/* RX_UNICAST_SET */
4632 +#define RX_CH7_EN (1 << 7)
4633 +#define RX_CH6_EN (1 << 6)
4634 +#define RX_CH5_EN (1 << 5)
4635 +#define RX_CH4_EN (1 << 4)
4636 +#define RX_CH3_EN (1 << 3)
4637 +#define RX_CH2_EN (1 << 2)
4638 +#define RX_CH1_EN (1 << 1)
4639 +#define RX_CH0_EN (1 << 0)
4644 +#define TX_PTYPE (1 << 9)
4645 +#define TX_PACE (1 << 6)
4646 +#define MII_EN (1 << 5)
4647 +#define TX_FLOW_EN (1 << 4)
4648 +#define RX_FLOW_EN (1 << 3)
4649 +#define MTEST (1 << 2)
4650 +#define CTRL_LOOPBACK (1 << 1)
4651 +#define FULLDUPLEX (1 << 0)
4654 +/* IntVec definitions */
4655 +#define MAC_IN_VECTOR_STATUS_INT (1 << 19)
4656 +#define MAC_IN_VECTOR_HOST_INT (1 << 18)
4657 +#define MAC_IN_VECTOR_RX_INT_OR (1 << 17)
4658 +#define MAC_IN_VECTOR_TX_INT_OR (1 << 16)
4659 +#define MAC_IN_VECTOR_RX_INT_VEC (7 << 8)
4660 +#define MAC_IN_VECTOR_TX_INT_VEC (7)
4665 +#define TX_HOST_ERR_CODE (0xF << 20)
4666 +#define TX_ERR_CH (0x7 << 16)
4667 +#define RX_HOST_ERR_CODE (0xF << 12)
4668 +#define RX_ERR_CH (0x7 << 8)
4669 +#define RX_QOS_ACT (1 << 2)
4670 +#define RX_FLOW_ACT (1 << 1)
4671 +#define TX_FLOW_ACT (1 << 0)
4672 +#endif _INC_CPMAC_REG
4673 diff -urN linux.old/drivers/net/avalanche_cpmac/cpmdio.c linux.dev/drivers/net/avalanche_cpmac/cpmdio.c
4674 --- linux.old/drivers/net/avalanche_cpmac/cpmdio.c 1970-01-01 01:00:00.000000000 +0100
4675 +++ linux.dev/drivers/net/avalanche_cpmac/cpmdio.c 2005-07-12 02:48:42.046593000 +0200
4677 +/***************************************************************************
4678 +** TNETD53xx Software Support
4679 +** Copyright(c) 2002, Texas Instruments Incorporated. All Rights Reserved.
4684 +** MDIO Polling State Machine API. Functions will enable mii-Phy
4688 +** 01Jan01 Denis, Bill Original
4689 +** 27Mar02 Michael Hanrahan (modified from emacmdio.c)
4690 +** 07May02 Michael Hanrahan replaced clockwait for code delay
4691 +** 10Jul02 Michael Hanrahan more debug, if fallback link is selected
4692 +*****************************************************************************/
4693 +#define __CPHAL_CPMDIO
4695 +#include "mdio_reg.h"
4697 +#ifdef _CPHAL_CPMAC
4698 +#define mdioPrintf PhyDev->HalDev->OsFunc->Printf
4700 +#define mdioPrintf printf
4703 +typedef struct _phy_device
4712 +#ifdef _CPHAL_CPMAC
4713 + HAL_DEVICE *HalDev;
4717 +static void _mdioDelayEmulate(PHY_DEVICE *PhyDev, int ClockWait);
4718 +static void _mdioWaitForAccessComplete(PHY_DEVICE *PhyDev);
4719 +static void _mdioUserAccess(PHY_DEVICE *PhyDev, bit32u method, bit32u regadr, bit32u phyadr, bit32u data);
4720 +static bit32u _mdioUserAccessRead(PHY_DEVICE *PhyDev, bit32u regadr, bit32u phyadr);
4721 +static void _mdioUserAccessWrite(PHY_DEVICE *PhyDev, bit32u regadr, bit32u phyadr, bit32u data);
4723 +static void _mdioDisablePhy(PHY_DEVICE *PhyDev,bit32u PhyNum);
4724 +static void _mdioPhyTimeOut(PHY_DEVICE *PhyDev);
4725 +static void _mdioResetPhy(PHY_DEVICE *PhyDev,bit32u PhyNum);
4727 +static void _mdioDumpPhy(PHY_DEVICE *PhyDev, bit32u p);
4728 +static void _mdioDumpState(PHY_DEVICE *PhyDev);
4731 +static void _mdioMdixDelay(PHY_DEVICE *PhyDev);
4732 +static int _mdioMdixSupported(PHY_DEVICE *PhyDev);
4734 +static void _MdioDefaultState (PHY_DEVICE *PhyDev);
4735 +static void _MdioFindingState (PHY_DEVICE *PhyDev);
4736 +static void _MdioFoundState (PHY_DEVICE *PhyDev);
4737 +static void _MdioInitState (PHY_DEVICE *PhyDev);
4738 +static void _MdioLinkedState (PHY_DEVICE *PhyDev);
4739 +static void _MdioLinkWaitState (PHY_DEVICE *PhyDev);
4740 +static void _MdioLoopbackState (PHY_DEVICE *PhyDev);
4741 +static void _MdioNwayStartState(PHY_DEVICE *PhyDev);
4742 +static void _MdioNwayWaitState (PHY_DEVICE *PhyDev);
4747 +#define TRUE (1==1)
4751 +#define FALSE (1==2)
4754 +#define PHY_NOT_FOUND 0xFFFF /* Used in Phy Detection */
4756 +/*PhyState breakout */
4758 +#define PHY_DEV_OFFSET (0)
4759 +#define PHY_DEV_SIZE (5) /* 5 Bits used */
4760 +#define PHY_DEV_MASK (0x1f<<PHY_DEV_OFFSET)
4762 +#define PHY_STATE_OFFSET (PHY_DEV_SIZE+PHY_DEV_OFFSET)
4763 +#define PHY_STATE_SIZE (5) /* 10 Bits used */
4764 +#define PHY_STATE_MASK (0x1f<<PHY_STATE_OFFSET)
4765 + #define INIT (1<<PHY_STATE_OFFSET)
4766 + #define FINDING (2<<PHY_STATE_OFFSET)
4767 + #define FOUND (3<<PHY_STATE_OFFSET)
4768 + #define NWAY_START (4<<PHY_STATE_OFFSET)
4769 + #define NWAY_WAIT (5<<PHY_STATE_OFFSET)
4770 + #define LINK_WAIT (6<<PHY_STATE_OFFSET)
4771 + #define LINKED (7<<PHY_STATE_OFFSET)
4772 + #define LOOPBACK (8<<PHY_STATE_OFFSET)
4774 +#define PHY_SPEED_OFFSET (PHY_STATE_OFFSET+PHY_STATE_SIZE)
4775 +#define PHY_SPEED_SIZE (1) /* 11 Bits used */
4776 +#define PHY_SPEED_MASK (1<<PHY_SPEED_OFFSET)
4778 +#define PHY_DUPLEX_OFFSET (PHY_SPEED_OFFSET+PHY_SPEED_SIZE)
4779 +#define PHY_DUPLEX_SIZE (1) /* 12 Bits used */
4780 +#define PHY_DUPLEX_MASK (1<<PHY_DUPLEX_OFFSET)
4782 +#define PHY_TIM_OFFSET (PHY_DUPLEX_OFFSET+PHY_DUPLEX_SIZE)
4783 +#define PHY_TIM_SIZE (10) /* 22 Bits used */
4784 +#define PHY_TIM_MASK (0x3ff<<PHY_TIM_OFFSET)
4785 + #define PHY_FIND_TO ( 2<<PHY_TIM_OFFSET)
4786 + #define PHY_RECK_TO (200<<PHY_TIM_OFFSET)
4787 + #define PHY_LINK_TO (500<<PHY_TIM_OFFSET)
4788 + #define PHY_NWST_TO (500<<PHY_TIM_OFFSET)
4789 + #define PHY_NWDN_TO (800<<PHY_TIM_OFFSET)
4790 + #define PHY_MDIX_TO (274<<PHY_TIM_OFFSET) /* 2.74 Seconds <--Spec and empirical */
4792 +#define PHY_SMODE_OFFSET (PHY_TIM_OFFSET+PHY_TIM_SIZE)
4793 +#define PHY_SMODE_SIZE (5) /* 27 Bits used */
4794 +#define PHY_SMODE_MASK (0x1f<<PHY_SMODE_OFFSET)
4795 + #define SMODE_AUTO (0x10<<PHY_SMODE_OFFSET)
4796 + #define SMODE_FD100 (0x08<<PHY_SMODE_OFFSET)
4797 + #define SMODE_HD100 (0x04<<PHY_SMODE_OFFSET)
4798 + #define SMODE_FD10 (0x02<<PHY_SMODE_OFFSET)
4799 + #define SMODE_HD10 (0x01<<PHY_SMODE_OFFSET)
4800 + #define SMODE_ALL (0x1f<<PHY_SMODE_OFFSET)
4802 +#define PHY_CHNG_OFFSET (PHY_SMODE_OFFSET+PHY_SMODE_SIZE)
4803 +#define PHY_CHNG_SIZE (1) /* 28 Bits used */
4804 +#define PHY_CHNG_MASK (1<<PHY_CHNG_OFFSET)
4805 + #define PHY_CHANGE (1<<PHY_CHNG_OFFSET)
4807 +#define PHY_TIMEDOUT_OFFSET (PHY_CHNG_OFFSET+PHY_CHNG_SIZE)
4808 +#define PHY_TIMEDOUT_SIZE (1) /* 29 Bits used */
4809 +#define PHY_TIMEDOUT_MASK (1<<PHY_TIMEDOUT_OFFSET)
4810 + #define PHY_MDIX_SWITCH (1<<PHY_TIMEDOUT_OFFSET)
4812 +#define PHY_MDIX_OFFSET (PHY_TIMEDOUT_OFFSET+PHY_TIMEDOUT_SIZE)
4813 +#define PHY_MDIX_SIZE (1) /* 30 Bits used */
4814 +#define PHY_MDIX_MASK (1<<PHY_MDIX_OFFSET)
4815 + #define PHY_MDIX (1<<PHY_MDIX_OFFSET)
4817 +static char *lstate[]={"NULL","INIT","FINDING","FOUND","NWAY_START","NWAY_WAIT","LINK_WAIT","LINKED", "LOOPBACK"};
4818 +static int cpMacDebug;
4820 +/* Local MDIO Register Macros */
4822 +#define myMDIO_ALIVE MDIO_ALIVE (PhyDev->miibase)
4823 +#define myMDIO_CONTROL MDIO_CONTROL (PhyDev->miibase)
4824 +#define myMDIO_LINK MDIO_LINK (PhyDev->miibase)
4825 +#define myMDIO_LINKINT MDIO_LINKINT (PhyDev->miibase)
4826 +#define myMDIO_USERACCESS MDIO_USERACCESS(PhyDev->miibase, PhyDev->inst)
4827 +#define myMDIO_USERPHYSEL MDIO_USERPHYSEL(PhyDev->miibase, PhyDev->inst)
4828 +#define myMDIO_VER MDIO_VER (PhyDev->miibase)
4831 +#define VOLATILE32(addr) (*((volatile bit32u *)(addr)))
4834 +/************************************
4836 +*** Delays at least ClockWait cylces
4837 +*** before returning
4839 +**************************************/
4840 +void _mdioDelayEmulate(PHY_DEVICE *PhyDev, int ClockWait)
4842 +#ifdef _CPHAL_CPMAC /*+RC3.02*/
4843 + HAL_DEVICE *HalDev = PhyDev->HalDev; /*+RC3.02*/
4844 + osfuncSleep((int*)&ClockWait); /*+RC3.02*/
4846 + volatile bit32u i=0;
4847 + while(ClockWait--)
4849 + i |= myMDIO_LINK; /* MDIO register access to burn cycles */
4854 +void _mdioWaitForAccessComplete(PHY_DEVICE *PhyDev)
4856 + while((myMDIO_USERACCESS & MDIO_USERACCESS_GO)!=0)
4861 +void _mdioUserAccess(PHY_DEVICE *PhyDev, bit32u method, bit32u regadr, bit32u phyadr, bit32u data)
4865 + control = MDIO_USERACCESS_GO |
4867 + (((regadr) << 21) & MDIO_USERACCESS_REGADR) |
4868 + (((phyadr) << 16) & MDIO_USERACCESS_PHYADR) |
4869 + ((data) & MDIO_USERACCESS_DATA);
4871 + myMDIO_USERACCESS = control;
4876 +/************************************
4878 +*** Waits for MDIO_USERACCESS to be ready and reads data
4879 +*** If 'WaitForData' set, waits for read to complete and returns Data,
4880 +*** otherwise returns 0
4881 +*** Note: 'data' is 16 bits but we use 32 bits
4882 +*** to be consistent with rest of the code.
4884 +**************************************/
4885 +bit32u _mdioUserAccessRead(PHY_DEVICE *PhyDev, bit32u regadr, bit32u phyadr)
4888 + _mdioWaitForAccessComplete(PhyDev); /* Wait until UserAccess ready */
4889 + _mdioUserAccess(PhyDev, MDIO_USERACCESS_READ, regadr, phyadr, 0);
4890 + _mdioWaitForAccessComplete(PhyDev); /* Wait for Read to complete */
4892 + return(myMDIO_USERACCESS & MDIO_USERACCESS_DATA);
4896 +/************************************
4898 +*** Waits for MDIO_USERACCESS to be ready and writes data
4900 +**************************************/
4901 +void _mdioUserAccessWrite(PHY_DEVICE *PhyDev, bit32u regadr, bit32u phyadr, bit32u data)
4903 + _mdioWaitForAccessComplete(PhyDev); /* Wait until UserAccess ready */
4904 + _mdioUserAccess(PhyDev, MDIO_USERACCESS_WRITE, regadr, phyadr, data);
4907 +void _mdioDumpPhyDetailed(PHY_DEVICE *PhyDev)
4909 + bit32u *PhyState = &PhyDev->PhyState;
4913 + PhyNum=(*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET;
4915 + RegData = _mdioUserAccessRead(PhyDev, 0, PhyNum);
4916 + mdioPrintf("PhyControl: %04X, Lookback=%s, Speed=%s, Duplex=%s\n",
4918 + RegData&PHY_LOOP?"On":"Off",
4919 + RegData&PHY_100?"100":"10",
4920 + RegData&PHY_FD?"Full":"Half");
4921 + RegData = _mdioUserAccessRead(PhyDev, 1, PhyNum);
4922 + mdioPrintf("PhyStatus: %04X, AutoNeg=%s, Link=%s\n",
4924 + RegData&NWAY_COMPLETE?"Complete":"NotComplete",
4925 + RegData&PHY_LINKED?"Up":"Down");
4926 + RegData = _mdioUserAccessRead(PhyDev, 4, PhyNum);
4927 + mdioPrintf("PhyMyCapability: %04X, 100FD=%s, 100HD=%s, 10FD=%s, 10HD=%s\n",
4929 + RegData&NWAY_FD100?"Yes":"No",
4930 + RegData&NWAY_HD100?"Yes":"No",
4931 + RegData&NWAY_FD10?"Yes":"No",
4932 + RegData&NWAY_HD10?"Yes":"No");
4934 + RegData = _mdioUserAccessRead(PhyDev, 5, PhyNum);
4935 + mdioPrintf("PhyPartnerCapability: %04X, 100FD=%s, 100HD=%s, 10FD=%s, 10HD=%s\n",
4937 + RegData&NWAY_FD100?"Yes":"No",
4938 + RegData&NWAY_HD100?"Yes":"No",
4939 + RegData&NWAY_FD10?"Yes":"No",
4940 + RegData&NWAY_HD10?"Yes":"No");
4942 +void _mdioDumpPhy(PHY_DEVICE *PhyDev, bit32u p)
4944 + bit32u j,n,PhyAcks;
4945 + bit32u PhyRegAddr;
4947 + bit32u PhyMask = PhyDev->PhyMask;
4949 + PhyAcks=myMDIO_ALIVE;
4950 + PhyAcks&=PhyMask; /* Only interested in 'our' Phys */
4952 + for(phy_num=0,j=1;phy_num<32;phy_num++,j<<=1)
4956 + mdioPrintf("%2d%s:",phy_num,(phy_num==p)?">":" ");
4957 + for(PhyRegAddr=0;PhyRegAddr<6;PhyRegAddr++)
4959 + n = _mdioUserAccessRead(PhyDev, PhyRegAddr, phy_num);
4960 + mdioPrintf(" %04x",n&0x0ffff);
4965 + _mdioDumpPhyDetailed(PhyDev);
4968 +void _mdioDumpState(PHY_DEVICE *PhyDev)
4970 + bit32u state = PhyDev->PhyState;
4972 + if (!cpMacDebug) return;
4974 + mdioPrintf("Phy: %d, ",(state&PHY_DEV_MASK)>>PHY_DEV_OFFSET);
4975 + mdioPrintf("State: %d/%s, ",(state&PHY_STATE_MASK)>>PHY_STATE_OFFSET,lstate[(state&PHY_STATE_MASK)>>PHY_STATE_OFFSET]);
4976 + mdioPrintf("Speed: %d, ",(state&PHY_SPEED_MASK)>>PHY_SPEED_OFFSET);
4977 + mdioPrintf("Dup: %d, ",(state&PHY_DUPLEX_MASK)>>PHY_DUPLEX_OFFSET);
4978 + mdioPrintf("Tim: %d, ",(state&PHY_TIM_MASK)>>PHY_TIM_OFFSET);
4979 + mdioPrintf("SMode: %d, ",(state&PHY_SMODE_MASK)>>PHY_SMODE_OFFSET);
4980 + mdioPrintf("Chng: %d",(state&PHY_CHNG_MASK)>>PHY_CHNG_OFFSET);
4983 + if (((state&PHY_STATE_MASK)!=FINDING)&&((state&PHY_STATE_MASK)!=INIT))
4984 + _mdioDumpPhy(PhyDev, (state&PHY_DEV_MASK)>>PHY_DEV_OFFSET);
4988 +void _mdioResetPhy(PHY_DEVICE *PhyDev,bit32u PhyNum)
4990 + bit16u PhyControlReg;
4992 + _mdioUserAccessWrite(PhyDev, PHY_CONTROL_REG, PhyNum, PHY_RESET);
4994 + mdioPrintf("cpMacMdioPhYReset(%d)\n",PhyNum);
4996 + /* Read control register until Phy Reset is complete */
4999 + PhyControlReg = _mdioUserAccessRead(PhyDev, PHY_CONTROL_REG, PhyNum);
5001 + while (PhyControlReg & PHY_RESET); /* Wait for Reset to clear */
5004 +void _mdioDisablePhy(PHY_DEVICE *PhyDev,bit32u PhyNum)
5006 + _mdioUserAccessWrite(PhyDev, PHY_CONTROL_REG, PhyNum, PHY_ISOLATE|PHY_PDOWN);
5009 + mdioPrintf("cpMacMdioDisablePhy(%d)\n",PhyNum);
5013 +void _MdioInitState(PHY_DEVICE *PhyDev)
5015 + bit32u *PhyState = &PhyDev->PhyState;
5016 + bit32u CurrentState;
5018 + CurrentState=*PhyState;
5019 + CurrentState=(CurrentState&~PHY_TIM_MASK)|(PHY_FIND_TO);
5020 + CurrentState=(CurrentState&~PHY_STATE_MASK)|(FINDING);
5021 + CurrentState=(CurrentState&~PHY_SPEED_MASK);
5022 + CurrentState=(CurrentState&~PHY_DUPLEX_MASK);
5023 + CurrentState|=PHY_CHANGE;
5025 + *PhyState=CurrentState;
5029 +void _MdioFindingState(PHY_DEVICE *PhyDev)
5031 + bit32u *PhyState = &PhyDev->PhyState;
5032 + bit32u PhyMask = PhyDev->PhyMask;
5033 + bit32u PhyNum,i,j,PhyAcks;
5036 + PhyNum=PHY_NOT_FOUND;
5038 + if (*PhyState&PHY_TIM_MASK)
5040 + *PhyState=(*PhyState&~PHY_TIM_MASK)|((*PhyState&PHY_TIM_MASK)-(1<<PHY_TIM_OFFSET));
5044 + PhyAcks=myMDIO_ALIVE;
5045 + PhyAcks&=PhyMask; /* Only interested in 'our' Phys */
5047 + for(i=0,j=1;(i<32)&&((j&PhyAcks)==0);i++,j<<=1);
5049 + if ((PhyAcks)&&(i<32)) PhyNum=i;
5050 + if (PhyNum!=PHY_NOT_FOUND)
5053 + *PhyState=(*PhyState&~PHY_DEV_MASK)|((PhyNum&PHY_DEV_MASK)<<PHY_DEV_OFFSET);
5054 + *PhyState=(*PhyState&~PHY_STATE_MASK)|(FOUND);
5055 + *PhyState|=PHY_CHANGE;
5057 + mdioPrintf("cpMacMdioFindingState: PhyNum: %d\n",PhyNum);
5062 + mdioPrintf("cpMacMdioFindingState: Timed Out looking for a Phy!\n");
5063 + *PhyState|=PHY_RECK_TO; /* This state currently has no support?*/
5068 +void _MdioFoundState(PHY_DEVICE *PhyDev)
5070 + bit32u *PhyState = &PhyDev->PhyState;
5071 + bit32u PhyMask = PhyDev->PhyMask;
5072 + bit32u MLinkMask = PhyDev->MLinkMask;
5073 + bit32u PhyNum,PhyStatus,NWAYadvertise,m,phynum,i,j,PhyAcks;
5076 + if ((*PhyState&PHY_SMODE_MASK)==0) return;
5078 + PhyNum=(*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET;
5080 + PhyAcks=myMDIO_ALIVE;
5081 + PhyAcks&=PhyMask; /* Only interested in 'our' Phys */
5083 + /* Will now isolate all our Phys, except the one we have decided to use */
5084 + for(phynum=0,j=1;phynum<32;phynum++,j<<=1)
5088 + if (phynum!=PhyNum) /* Do not disabled Found Phy */
5089 + _mdioDisablePhy(PhyDev,phynum);
5093 + /* Reset the Phy and proceed with auto-negotiation */
5094 + _mdioResetPhy(PhyDev,PhyNum);
5096 + /* Now setup the MDIOUserPhySel register */
5098 + PhySel=PhyNum; /* Set the phy address */
5100 + /* Set the way Link will be Monitored */
5101 + /* Check the Link Selection Method */
5102 + if ((1 << PhyNum) & MLinkMask)
5103 + PhySel |= MDIO_USERPHYSEL_LINKSEL;
5105 + myMDIO_USERPHYSEL = PhySel; /* update PHYSEL */
5107 + /* Get the Phy Status */
5108 + PhyStatus = _mdioUserAccessRead(PhyDev, PHY_STATUS_REG, PhyNum);
5111 +#ifdef _CPHAL_CPMAC
5112 + /* For Phy Internal loopback test, need to wait until Phy
5113 + found, then set Loopback */
5114 + if (PhyDev->HalDev->MdioConnect & _CPMDIO_LOOPBK)
5116 + /* Set Phy in Loopback */
5117 + _mdioUserAccessWrite(PhyDev, PHY_CONTROL_REG, PhyNum, PHY_LOOP|PHY_FD);
5118 + /* Do a read to ensure PHY_LOOP has completed */
5119 + _mdioUserAccessRead(PhyDev, PHY_STATUS_REG, PhyNum);
5120 + *PhyState=(*PhyState&~PHY_STATE_MASK)|(LOOPBACK);
5121 + *PhyState|=PHY_CHANGE;
5128 + mdioPrintf("Enable Phy to negotiate external connection\n");
5130 + NWAYadvertise=NWAY_SEL;
5131 + if (*PhyState&SMODE_FD100) NWAYadvertise|=NWAY_FD100;
5132 + if (*PhyState&SMODE_HD100) NWAYadvertise|=NWAY_HD100;
5133 + if (*PhyState&SMODE_FD10) NWAYadvertise|=NWAY_FD10;
5134 + if (*PhyState&SMODE_HD10) NWAYadvertise|=NWAY_HD10;
5136 + *PhyState&=~(PHY_TIM_MASK|PHY_STATE_MASK);
5137 + if ((PhyStatus&NWAY_CAPABLE)&&(*PhyState&SMODE_AUTO)) /*NWAY Phy Detected*/
5139 + /*For NWAY compliant Phys */
5141 + _mdioUserAccessWrite(PhyDev, NWAY_ADVERTIZE_REG, PhyNum, NWAYadvertise);
5145 + mdioPrintf("NWAY Advertising: ");
5146 + if (NWAYadvertise&NWAY_FD100) mdioPrintf("FullDuplex-100 ");
5147 + if (NWAYadvertise&NWAY_HD100) mdioPrintf("HalfDuplex-100 ");
5148 + if (NWAYadvertise&NWAY_FD10) mdioPrintf("FullDuplex-10 ");
5149 + if (NWAYadvertise&NWAY_HD10) mdioPrintf("HalfDuplex-10 ");
5153 + _mdioUserAccessWrite(PhyDev, PHY_CONTROL_REG, PhyNum, AUTO_NEGOTIATE_EN);
5155 + _mdioUserAccessWrite(PhyDev, PHY_CONTROL_REG, PhyNum, AUTO_NEGOTIATE_EN|RENEGOTIATE);
5157 + *PhyState|=PHY_CHANGE|PHY_NWST_TO|NWAY_START;
5161 + *PhyState&=~SMODE_AUTO; /*The Phy is not capable of auto negotiation! */
5163 + for(j=0x8000,i=0;(i<16)&&((j&m)==0);i++,j>>=1);
5166 + if (m&(NWAY_FD100|NWAY_HD100))
5169 + m&=(NWAY_FD100|NWAY_HD100);
5171 + if (m&(NWAY_FD100|NWAY_FD10))
5174 + mdioPrintf("Requested PHY mode %s Duplex %s Mbps\n",(j&PHY_FD)?"Full":"Half",(j&PHY_100)?"100":"10");
5175 + _mdioUserAccessWrite(PhyDev, PHY_CONTROL_REG, PhyNum, j);
5176 + *PhyState&=~PHY_SPEED_MASK;
5178 + *PhyState|=(1<<PHY_SPEED_OFFSET);
5179 + *PhyState&=~PHY_DUPLEX_MASK;
5181 + *PhyState|=(1<<PHY_DUPLEX_OFFSET);
5182 + *PhyState|=PHY_CHANGE|PHY_LINK_TO|LINK_WAIT;
5184 + _mdioMdixDelay(PhyDev); /* If AutoMdix add delay */
5187 +void _MdioNwayStartState(PHY_DEVICE *PhyDev)
5189 + bit32u *PhyState = &PhyDev->PhyState;
5190 + bit32u PhyNum,PhyMode;
5192 + PhyNum=(*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET;
5194 + /*Wait for Negotiation to start */
5196 + PhyMode=_mdioUserAccessRead(PhyDev, PHY_CONTROL_REG, PhyNum);
5198 + if((PhyMode&RENEGOTIATE)==0)
5200 + _mdioUserAccessRead(PhyDev, PHY_STATUS_REG, PhyNum); /*Flush pending latch bits*/
5201 + *PhyState&=~(PHY_STATE_MASK|PHY_TIM_MASK);
5202 + *PhyState|=PHY_CHANGE|NWAY_WAIT|PHY_NWDN_TO;
5203 + _mdioMdixDelay(PhyDev); /* If AutoMdix add delay */
5207 + if (*PhyState&PHY_TIM_MASK)
5208 + *PhyState=(*PhyState&~PHY_TIM_MASK)|((*PhyState&PHY_TIM_MASK)-(1<<PHY_TIM_OFFSET));
5210 + _mdioPhyTimeOut(PhyDev);
5214 +void _MdioNwayWaitState(PHY_DEVICE *PhyDev)
5216 + bit32u *PhyState = &PhyDev->PhyState;
5217 + bit32u PhyNum,PhyStatus,NWAYadvertise,NWAYREadvertise,NegMode,i,j;
5219 + PhyNum=(*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET;
5221 + PhyStatus=_mdioUserAccessRead(PhyDev, PHY_STATUS_REG, PhyNum);
5223 + if (PhyStatus&NWAY_COMPLETE)
5225 + *PhyState|=PHY_CHANGE;
5226 + *PhyState&=~PHY_SPEED_MASK;
5227 + *PhyState&=~PHY_DUPLEX_MASK;
5229 + NWAYadvertise =_mdioUserAccessRead(PhyDev, NWAY_ADVERTIZE_REG, PhyNum);
5230 + NWAYREadvertise =_mdioUserAccessRead(PhyDev, NWAY_REMADVERTISE_REG, PhyNum);
5232 + /* Negotiated mode is we and the remote have in common */
5233 + NegMode = NWAYadvertise & NWAYREadvertise;
5237 + mdioPrintf("Phy: %d, ",(*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET);
5238 + mdioPrintf("NegMode %04X, NWAYadvertise %04X, NWAYREadvertise %04X\n",
5239 + NegMode, NWAYadvertise, NWAYREadvertise);
5242 + /* Limit negotiation to fields below */
5243 + NegMode &= (NWAY_FD100|NWAY_HD100|NWAY_FD10|NWAY_HD10);
5247 + NegMode=(NWAY_HD100|NWAY_HD10)&NWAYadvertise; /*or 10 ?? who knows, Phy is not MII compliant*/
5250 + mdioPrintf("Mdio:WARNING: Negotiation complete but NO agreement, default is HD\n");
5251 + _mdioDumpPhyDetailed(PhyDev);
5254 + for(j=0x8000,i=0;(i<16)&&((j&NegMode)==0);i++,j>>=1);
5260 + mdioPrintf("Negotiated connection: ");
5261 + if (NegMode&NWAY_FD100) mdioPrintf("FullDuplex 100 Mbs\n");
5262 + if (NegMode&NWAY_HD100) mdioPrintf("HalfDuplex 100 Mbs\n");
5263 + if (NegMode&NWAY_FD10) mdioPrintf("FullDuplex 10 Mbs\n");
5264 + if (NegMode&NWAY_HD10) mdioPrintf("HalfDuplex 10 Mbs\n");
5268 + if (PhyStatus&PHY_LINKED)
5269 + *PhyState=(*PhyState&~PHY_STATE_MASK)|LINKED;
5271 + *PhyState=(*PhyState&~PHY_STATE_MASK)|LINK_WAIT;
5272 + if (NegMode&(NWAY_FD100|NWAY_HD100))
5273 + *PhyState=(*PhyState&~PHY_SPEED_MASK)|(1<<PHY_SPEED_OFFSET);
5274 + if (NegMode&(NWAY_FD100|NWAY_FD10))
5275 + *PhyState=(*PhyState&~PHY_DUPLEX_MASK)|(1<<PHY_DUPLEX_OFFSET);
5280 + if (*PhyState&PHY_TIM_MASK)
5281 + *PhyState=(*PhyState&~PHY_TIM_MASK)|((*PhyState&PHY_TIM_MASK)-(1<<PHY_TIM_OFFSET));
5283 + _mdioPhyTimeOut(PhyDev);
5287 +void _MdioLinkWaitState(PHY_DEVICE *PhyDev)
5289 + bit32u *PhyState = &PhyDev->PhyState;
5293 + PhyNum=(*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET;
5295 + PhyStatus=_mdioUserAccessRead(PhyDev, PHY_STATUS_REG, PhyNum);
5297 + if (PhyStatus&PHY_LINKED)
5299 + *PhyState=(*PhyState&~PHY_STATE_MASK)|LINKED;
5300 + *PhyState|=PHY_CHANGE;
5304 + if (*PhyState&PHY_TIM_MASK)
5305 + *PhyState=(*PhyState&~PHY_TIM_MASK)|((*PhyState&PHY_TIM_MASK)-(1<<PHY_TIM_OFFSET));
5307 + _mdioPhyTimeOut(PhyDev);
5311 +void _mdioPhyTimeOut(PHY_DEVICE *PhyDev)
5315 + if(_mdioMdixSupported(PhyDev) == 0)
5316 + return; /* AutoMdix not supported */
5318 + PhyState = &PhyDev->PhyState;
5320 + /* Indicate MDI/MDIX mode switch is needed */
5321 + *PhyState|=PHY_MDIX_SWITCH;
5323 + /* Toggle the MDIX mode indicatir */
5324 + if(*PhyState & PHY_MDIX)
5325 + *PhyState &= ~PHY_MDIX_MASK; /* Current State is MDIX, set to MDI */
5327 + *PhyState |= PHY_MDIX_MASK; /* Current State is MDI, set to MDIX */
5329 + /* Reset state machine to FOUND */
5330 + *PhyState=(*PhyState&~PHY_STATE_MASK)|(FOUND);
5333 +void _MdioLoopbackState(PHY_DEVICE *PhyDev)
5338 +void _MdioLinkedState(PHY_DEVICE *PhyDev)
5340 + bit32u *PhyState = &PhyDev->PhyState;
5341 + bit32u PhyNum = (*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET;
5343 + if (myMDIO_LINK&(1<<PhyNum)) return; /* if still Linked, exit*/
5346 + *PhyState&=~(PHY_STATE_MASK|PHY_TIM_MASK);
5347 + if (*PhyState&SMODE_AUTO)
5348 + *PhyState|=PHY_CHANGE|NWAY_WAIT|PHY_NWDN_TO;
5350 + *PhyState|=PHY_CHANGE|PHY_LINK_TO|LINK_WAIT;
5352 + _mdioMdixDelay(PhyDev); /* If AutoMdix add delay */
5355 +void _MdioDefaultState(PHY_DEVICE *PhyDev)
5357 + bit32u *PhyState = &PhyDev->PhyState;
5358 + /*Awaiting a cpMacMdioInit call */
5359 + *PhyState|=PHY_CHANGE;
5363 +/*User Calls********************************************************* */
5365 +void cpMacMdioClose(PHY_DEVICE *PhyDev, int Full)
5370 +int cpMacMdioInit(PHY_DEVICE *PhyDev, bit32u miibase, bit32u inst, bit32u PhyMask, bit32u MLinkMask, bit32u MdixMask, bit32u ResetReg, bit32u ResetBit, bit32u MdioBusFreq, bit32u MdioClockFreq, int verbose, void *Info)
5372 + bit32u HighestChannel;
5373 + bit32u ControlState;
5374 + bit32u *PhyState = &PhyDev->PhyState;
5375 + bit32u clkdiv; /*MJH+030328*/
5377 + cpMacDebug=verbose;
5379 + PhyDev->miibase = miibase;
5380 + PhyDev->inst = inst;
5381 + PhyDev->PhyMask = PhyMask;
5382 + PhyDev->MLinkMask = MLinkMask;
5383 + PhyDev->MdixMask = MdixMask;
5384 +#ifdef _CPHAL_CPMAC
5385 + PhyDev->HalDev = (HAL_DEVICE*) Info;
5388 + *PhyState &= ~PHY_MDIX_MASK; /* Set initial State to MDI */
5390 + /* Check that the channel supplied is within range */
5391 + HighestChannel = (myMDIO_CONTROL & MDIO_CONTROL_HIGHEST_USER_CHANNEL) > 8;
5392 + if(inst > HighestChannel)
5393 + return(HighestChannel);
5395 + /*Setup MII MDIO access regs */
5397 + /* Calculate the correct value for the mclkdiv */
5398 + /* See PITS #14 */
5399 + if (MdioClockFreq) /*MJH+030402*/
5400 + clkdiv = (MdioBusFreq / MdioClockFreq) - 1; /*MJH+030402*/
5401 + else /*MJH+030402*/
5402 + clkdiv = 0xFF; /*MJH+030402*/
5404 + ControlState = MDIO_CONTROL_ENABLE;
5405 + ControlState |= (clkdiv & MDIO_CONTROL_CLKDIV); /*MJH+030328*/
5408 + If mii is not out of reset or if the Control Register is not set correctly
5411 + if( !(VOLATILE32(ResetReg) & (1 << ResetBit)) ||
5412 + ((myMDIO_CONTROL & (MDIO_CONTROL_CLKDIV | MDIO_CONTROL_ENABLE)) != ControlState) )/*GSG~030404*/
5414 + /* MII not setup, Setup initial condition */
5415 + VOLATILE32(ResetReg) &= ~(1 << ResetBit);
5416 + _mdioDelayEmulate(PhyDev, 64);
5417 + VOLATILE32(ResetReg) |= (1 << ResetBit); /* take mii out of reset */
5418 + _mdioDelayEmulate(PhyDev, 64);
5419 + myMDIO_CONTROL = ControlState; /* Enable MDIO */
5425 + mdioPrintf("cpMacMdioInit\n");
5426 + _mdioDumpState(PhyDev);
5430 +void cpMacMdioSetPhyMode(PHY_DEVICE *PhyDev,bit32u PhyMode)
5432 + bit32u *PhyState = &PhyDev->PhyState;
5433 + bit32u CurrentState;
5435 + PhyDev->PhyMode = PhyMode; /* used for AUTOMIDX, planned to replace PhyState fields */
5437 + *PhyState&=~PHY_SMODE_MASK;
5439 + if (PhyMode&NWAY_AUTO) *PhyState|=SMODE_AUTO;
5440 + if (PhyMode&NWAY_FD100) *PhyState|=SMODE_FD100;
5441 + if (PhyMode&NWAY_HD100) *PhyState|=SMODE_HD100;
5442 + if (PhyMode&NWAY_FD10) *PhyState|=SMODE_FD10;
5443 + if (PhyMode&NWAY_HD10) *PhyState|=SMODE_HD10;
5445 + CurrentState=*PhyState&PHY_STATE_MASK;
5446 + if ((CurrentState==NWAY_START)||
5447 + (CurrentState==NWAY_WAIT) ||
5448 + (CurrentState==LINK_WAIT) ||
5449 + (CurrentState==LINKED) )
5450 + *PhyState=(*PhyState&~PHY_STATE_MASK)|FOUND|PHY_CHANGE;
5452 + mdioPrintf("cpMacMdioSetPhyMode:%08X Auto:%d, FD10:%d, HD10:%d, FD100:%d, HD100:%d\n", PhyMode,
5453 + PhyMode&NWAY_AUTO, PhyMode&NWAY_FD10, PhyMode&NWAY_HD10, PhyMode&NWAY_FD100,
5454 + PhyMode&NWAY_HD100);
5455 + _mdioDumpState(PhyDev);
5458 +/* cpMacMdioTic is called every 10 mili seconds to process Phy states */
5460 +int cpMacMdioTic(PHY_DEVICE *PhyDev)
5462 + bit32u *PhyState = &PhyDev->PhyState;
5463 + bit32u CurrentState;
5465 + /*Act on current state of the Phy */
5467 + CurrentState=*PhyState;
5468 + switch(CurrentState&PHY_STATE_MASK)
5470 + case INIT: _MdioInitState(PhyDev); break;
5471 + case FINDING: _MdioFindingState(PhyDev); break;
5472 + case FOUND: _MdioFoundState(PhyDev); break;
5473 + case NWAY_START: _MdioNwayStartState(PhyDev); break;
5474 + case NWAY_WAIT: _MdioNwayWaitState(PhyDev); break;
5475 + case LINK_WAIT: _MdioLinkWaitState(PhyDev); break;
5476 + case LINKED: _MdioLinkedState(PhyDev); break;
5477 + case LOOPBACK: _MdioLoopbackState(PhyDev); break;
5478 + default: _MdioDefaultState(PhyDev); break;
5481 + /*Dump state info if a change has been detected */
5483 + if ((CurrentState&~PHY_TIM_MASK)!=(*PhyState&~PHY_TIM_MASK))
5484 + _mdioDumpState(PhyDev);
5486 + /* Check is MDI/MDIX mode switch is needed */
5487 + if(*PhyState & PHY_MDIX_SWITCH)
5491 + *PhyState &= ~PHY_MDIX_SWITCH; /* Clear Mdix Flip indicator */
5493 + if(*PhyState & PHY_MDIX)
5497 + return(_MIIMDIO_MDIXFLIP|Mdix);
5500 + /*Return state change to user */
5502 + if (*PhyState&PHY_CHNG_MASK)
5504 + *PhyState&=~PHY_CHNG_MASK;
5511 +/* cpMacMdioGetDuplex is called to retrieve the Duplex info */
5513 +int cpMacMdioGetDuplex(PHY_DEVICE *PhyDev)
5515 + bit32u *PhyState = &PhyDev->PhyState;
5516 + return((*PhyState&PHY_DUPLEX_MASK)?1:0); /* return 0 or a 1 */
5519 +/* cpMacMdioGetSpeed is called to retreive the Speed info */
5521 +int cpMacMdioGetSpeed(PHY_DEVICE *PhyDev)
5523 + bit32u *PhyState = &PhyDev->PhyState;
5524 + return(*PhyState&PHY_SPEED_MASK);
5527 +/* cpMacMdioGetPhyNum is called to retreive the Phy Device Adr info */
5529 +int cpMacMdioGetPhyNum(PHY_DEVICE *PhyDev)
5531 + bit32u *PhyState = &PhyDev->PhyState;
5532 + return((*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET);
5535 +/* cpMacMdioGetLoopback is called to Determine if the LOOPBACK state has been reached*/
5537 +int cpMacMdioGetLoopback(PHY_DEVICE *PhyDev)
5539 + bit32u *PhyState = &PhyDev->PhyState;
5540 + return((*PhyState&PHY_STATE_MASK)==LOOPBACK);
5542 +/* cpMacMdioGetLinked is called to Determine if the LINKED state has been reached*/
5544 +int cpMacMdioGetLinked(PHY_DEVICE *PhyDev)
5546 + bit32u *PhyState = &PhyDev->PhyState;
5547 + return((*PhyState&PHY_STATE_MASK)==LINKED);
5550 +void cpMacMdioLinkChange(PHY_DEVICE *PhyDev)
5552 + bit32u *PhyState = &PhyDev->PhyState;
5553 + bit32u PhyNum,PhyStatus;
5555 + PhyNum=(*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET;
5557 + if (cpMacMdioGetLinked(PhyDev))
5559 + PhyStatus=_mdioUserAccessRead(PhyDev, PHY_STATUS_REG, PhyNum);
5561 + if ((PhyStatus&PHY_LINKED)==0)
5563 + *PhyState&=~(PHY_TIM_MASK|PHY_STATE_MASK);
5564 + if (*PhyState&SMODE_AUTO)
5566 + _mdioUserAccessWrite(PhyDev, PHY_CONTROL_REG, PhyNum, AUTO_NEGOTIATE_EN|RENEGOTIATE);
5567 + *PhyState|=PHY_CHANGE|PHY_NWST_TO|NWAY_START;
5571 + *PhyState|=PHY_CHANGE|PHY_LINK_TO|LINK_WAIT;
5577 +void cpMacMdioGetVer(bit32u miibase, bit32u *ModID, bit32u *RevMaj, bit32u *RevMin)
5581 + Ver = MDIO_VER(miibase);
5583 + *ModID = (Ver & MDIO_VER_MODID) >> 16;
5584 + *RevMaj = (Ver & MDIO_VER_REVMAJ) >> 8;
5585 + *RevMin = (Ver & MDIO_VER_REVMIN);
5588 +int cpMacMdioGetPhyDevSize(void)
5590 + return(sizeof(PHY_DEVICE));
5593 + /* returns 0 if current Phy has AutoMdix support, otherwise 0 */
5594 +int _mdioMdixSupported(PHY_DEVICE *PhyDev)
5596 + bit32u *PhyState = &PhyDev->PhyState;
5599 + if((PhyDev->PhyMode & NWAY_AUTOMDIX) == 0)
5600 + return(0); /* AutoMdix not turned on */
5602 + PhyNum=(*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET;
5603 + if( ((1<<PhyNum) & PhyDev->MdixMask) == 0)
5604 + return(0); /* Phy does not support AutoMdix*/
5609 +/* If current Phy has AutoMdix support add Mdix Delay to the Timer State Value */
5610 +void _mdioMdixDelay(PHY_DEVICE *PhyDev)
5613 + bit32u *PhyState = &PhyDev->PhyState;
5614 +#ifdef _CPHAL_CPMAC
5615 + HAL_DEVICE *HalDev = PhyDev->HalDev;
5618 + if(_mdioMdixSupported(PhyDev) == 0)
5619 + return; /* AutoMdix not supported */
5620 +/* Currently only supported when used with the CPMAC */
5621 +#ifdef _CPHAL_CPMAC
5622 + /* Get the Delay value in milli-seconds and convert to ten-milli second value */
5623 + Delay = cpmacRandomRange(HalDev, _AUTOMDIX_DELAY_MIN, _AUTOMDIX_DELAY_MAX);
5626 + /* Add AutoMidx Random Switch Delay to AutoMdix Link Delay */
5628 + Delay += (PHY_MDIX_TO>>PHY_TIM_OFFSET);
5630 + /* Change Timeout value to AutoMdix standard */
5631 + *PhyState &= ~(PHY_TIM_MASK); /* Clear current Time out value */
5632 + *PhyState |= (Delay<<PHY_TIM_OFFSET); /* Set new value */
5637 diff -urN linux.old/drivers/net/avalanche_cpmac/cpmdio.h linux.dev/drivers/net/avalanche_cpmac/cpmdio.h
5638 --- linux.old/drivers/net/avalanche_cpmac/cpmdio.h 1970-01-01 01:00:00.000000000 +0100
5639 +++ linux.dev/drivers/net/avalanche_cpmac/cpmdio.h 2005-07-12 02:48:42.047593000 +0200
5641 +/*****************************************************************************
5642 +** TNETD53xx Software Support
5643 +** Copyright(c) 2002, Texas Instruments Incorporated. All Rights Reserved.
5645 +** FILE: cpmdio.h User Include for MDIO API Access
5648 +** This include file contains definitions for the the MDIO API
5651 +** 27Mar02 Michael Hanrahan Original (modified from emacmdio.h)
5652 +** 04Apr02 Michael Hanrahan Added Interrupt Support
5653 +*****************************************************************************/
5654 +#ifndef _INC_CPMDIO
5655 +#define _INC_CPMDIO
5658 +#ifndef __CPHAL_CPMDIO
5659 +typedef void PHY_DEVICE;
5663 +/*Version Information */
5665 +void cpMacMdioGetVer(bit32u miiBase, bit32u *ModID, bit32u *RevMaj, bit32u *RevMin);
5667 +/*Called once at the begining of time */
5669 +int cpMacMdioInit(PHY_DEVICE *PhyDev, bit32u miibase, bit32u inst, bit32u PhyMask, bit32u MLinkMask, bit32u MdixMask, bit32u ResetBase, bit32u ResetBit, bit32u MdioBusFreq, bit32u MdioClockFreq, int verbose, void *Info);
5670 +int cpMacMdioGetPhyDevSize(void);
5673 +/*Called every 10 mili Seconds, returns TRUE if there has been a mode change */
5675 +int cpMacMdioTic(PHY_DEVICE *PhyDev);
5677 +/*Called to set Phy mode */
5679 +void cpMacMdioSetPhyMode(PHY_DEVICE *PhyDev,bit32u PhyMode);
5681 +/*Calls to retreive info after a mode change! */
5683 +int cpMacMdioGetDuplex(PHY_DEVICE *PhyDev);
5684 +int cpMacMdioGetSpeed(PHY_DEVICE *PhyDev);
5685 +int cpMacMdioGetPhyNum(PHY_DEVICE *PhyDev);
5686 +int cpMacMdioGetLinked(PHY_DEVICE *PhyDev);
5687 +void cpMacMdioLinkChange(PHY_DEVICE *PhyDev);
5691 +void cpMacMdioClose(PHY_DEVICE *PhyDev, int Full);
5694 +/* Phy Mode Values */
5695 +#define NWAY_AUTOMDIX (1<<16)
5696 +#define NWAY_FD100 (1<<8)
5697 +#define NWAY_HD100 (1<<7)
5698 +#define NWAY_FD10 (1<<6)
5699 +#define NWAY_HD10 (1<<5)
5700 +#define NWAY_AUTO (1<<0)
5704 + * Tic() return values
5708 +#define _MIIMDIO_MDIXFLIP (1<<28)
5710 +#define _AUTOMDIX_DELAY_MIN 80 /* milli-seconds*/
5711 +#define _AUTOMDIX_DELAY_MAX 200 /* milli-seconds*/
5713 +#endif /* _INC_CPMDIO */
5714 diff -urN linux.old/drivers/net/avalanche_cpmac/cppi_cpmac.c linux.dev/drivers/net/avalanche_cpmac/cppi_cpmac.c
5715 --- linux.old/drivers/net/avalanche_cpmac/cppi_cpmac.c 1970-01-01 01:00:00.000000000 +0100
5716 +++ linux.dev/drivers/net/avalanche_cpmac/cppi_cpmac.c 2005-07-12 02:48:42.048593000 +0200
5718 +/*************************************************************************
5719 + * TNETDxxxx Software Support
5720 + * Copyright (c) 2002,2003 Texas Instruments Incorporated. All Rights Reserved.
5725 + * This file contains shared code for all CPPI modules.
5728 + * 7Aug02 Greg RC1.00 Original Version created.
5729 + * 27Sep02 Mick RC1.01 Merged for use by CPMAC/CPSAR
5730 + * 16Oct02 Mick RC1.02 Performance Tweaks (see cppihist.txt)
5731 + * 12Nov02 Mick RC1.02 Updated to use cpmac_reg.h
5732 + * 09Jan03 Mick RC3.01 Removed modification to RxBuffer ptr
5733 + * 28Mar03 Mick 1.03 RxReturn now returns error if Malloc Fails
5734 + * 10Apr03 Mick 1.03.02 Added Needs Buffer Support
5735 + * 11Jun03 Mick 1.06.02 halSend() errors corrected
5736 + * 23Aug04 Mick 1.07.08 cpmac only - Send: bypass threshold check if TxInts re-enabled
5738 + * @author Greg Guyotte
5740 + * @date 7-Aug-2002
5741 + *****************************************************************************/
5742 +/* each CPPI module must modify this file, the rest of the
5743 + code in cppi.c should be totally shared *//* Each CPPI module MUST properly define all constants shown below */
5745 +/* CPPI registers */
5747 +/* the following defines are not CPPI specific */
5749 +static int TxInt(HAL_DEVICE *HalDev, int Ch, int Queue, int *MoreWork);
5751 +static void FreeRx(HAL_DEVICE *HalDev, int Ch)
5753 + HAL_RCB *rcb_ptr; /*+GSG 030303*/
5754 + int rcbSize = (sizeof(HAL_RCB)+0xf)&~0xf; /*+GSG 030303*/
5755 + int Num = HalDev->ChData[Ch].RxNumBuffers, i; /*+GSG 030303*/
5757 + /* Free Rx data buffers attached to descriptors, if necessary */
5758 + if (HalDev->RcbStart[Ch] != 0) /*+GSG 030303*/
5760 + for(i=0;i<Num;i++) /*+GSG 030303*/
5762 + rcb_ptr = (HAL_RCB *)(HalDev->RcbStart[Ch] + (i*rcbSize)); /*+GSG 030303*/
5764 + /* free the data buffer */
5765 + if (rcb_ptr->DatPtr != 0)
5768 + HalDev->OsFunc->FreeRxBuffer((void *)rcb_ptr->OsInfo, (void *)rcb_ptr->DatPtr);
5769 + rcb_ptr->OsInfo=0; /*MJH+030522*/
5770 + rcb_ptr->DatPtr=0; /*MJH+030522*/
5775 + /* free up all desciptors at once */
5776 + HalDev->OsFunc->FreeDmaXfer(HalDev->RcbStart[Ch]);
5778 + /* mark buffers as freed */
5779 + HalDev->RcbStart[Ch] = 0;
5782 +static void FreeTx(HAL_DEVICE *HalDev, int Ch, int Queue)
5787 + /* free all descriptors at once */
5788 + HalDev->OsFunc->FreeDmaXfer(HalDev->TcbStart[Ch][Queue]);
5790 + HalDev->TcbStart[Ch][Queue] = 0;
5793 +/* return of 0 means that this code executed, -1 means the interrupt was not
5794 + a teardown interrupt */
5795 +static int RxTeardownInt(HAL_DEVICE *HalDev, int Ch)
5797 + bit32u base = HalDev->dev_base;
5799 + /* check to see if the interrupt is a teardown interrupt */
5800 + if (((CPMAC_RX_INT_ACK( base , Ch )) & TEARDOWN_VAL) == TEARDOWN_VAL)
5802 + /* finish channel teardown */
5804 + /* Free channel resources on a FULL teardown */
5805 + if (HalDev->RxTeardownPending[Ch] & FULL_TEARDOWN)
5807 + FreeRx(HalDev, Ch);
5810 + /* bug fix - clear Rx channel pointers on teardown */
5811 + HalDev->RcbPool[Ch] = 0;
5812 + HalDev->RxActQueueHead[Ch] = 0;
5813 + HalDev->RxActQueueCount[Ch] = 0;
5814 + HalDev->RxActive[Ch] = FALSE;
5816 + /* write completion pointer */
5817 + (CPMAC_RX_INT_ACK( base , Ch )) = TEARDOWN_VAL;
5819 + /* use direction bit as a teardown pending bit! May be able to
5820 + use only one teardown pending integer in HalDev */
5822 + HalDev->RxTeardownPending[Ch] &= ~RX_TEARDOWN;
5824 + HalDev->ChIsOpen[Ch][DIRECTION_RX] = 0;
5826 + HalDev->ChIsOpen[Ch][DIRECTION_RX] = 0;
5827 + CPMAC_RX_INTMASK_CLEAR(HalDev->dev_base) = (1<<Ch);
5828 + if ((HalDev->RxTeardownPending[Ch] & BLOCKING_TEARDOWN) == 0)
5831 + HalDev->OsFunc->TeardownComplete(HalDev->OsDev, Ch, DIRECTION_RX);
5833 + HalDev->RxTeardownPending[Ch] = 0;
5835 + return (EC_NO_ERRORS);
5840 +/* return of 0 means that this code executed, -1 means the interrupt was not
5841 + a teardown interrupt. Note: this code is always called with Queue == 0 (hi priority). */
5842 +static int TxTeardownInt(HAL_DEVICE *HalDev, int Ch, int Queue)
5844 + bit32u base = HalDev->dev_base;
5845 + HAL_TCB *Last, *Curr, *First; /*+GSG 030303*/
5848 + if (((CPMAC_TX_INT_ACK( base , Ch )) & TEARDOWN_VAL) == TEARDOWN_VAL)
5850 + /* perform all actions for both queues (+GSG 040212) */
5851 + for (i=0; i<HalDev->ChData[Ch].TxNumQueues; i++)
5853 + /* return outstanding buffers to OS +RC3.02*/
5854 + Curr = HalDev->TxActQueueHead[Ch][i]; /*+GSG 030303*/
5855 + First = Curr; /*+GSG 030303*/
5856 + while (Curr) /*+GSG 030303*/
5858 + /* Pop TCB(s) for packet from the stack */ /*+GSG 030303*/
5859 + Last = Curr->Eop; /*+GSG 030303*/
5860 + HalDev->TxActQueueHead[Ch][i] = Last->Next; /*+GSG 030303*/
5862 + /* return to OS */ /*+GSG 030303*/
5863 + HalDev->OsFunc->SendComplete(Curr->OsInfo); /*+GSG 030303*/
5865 + /* Push Tcb(s) back onto the stack */ /*+GSG 030303*/
5866 + Curr = Last->Next; /*+GSG 030303*/
5867 + Last->Next = HalDev->TcbPool[Ch][i]; /*+GSG 030303*/
5868 + HalDev->TcbPool[Ch][i] = First; /*+GSG 030303*/
5870 + /* set the first(SOP) pointer for the next packet */ /*+GSG 030303*/
5871 + First = Curr; /*+GSG 030303*/
5875 + /* finish channel teardown */
5877 + if (HalDev->TxTeardownPending[Ch] & FULL_TEARDOWN)
5879 + FreeTx(HalDev, Ch, 0);
5881 + if (HalDev->ChData[Ch].TxNumQueues == 2)
5882 + FreeTx(HalDev, Ch, 1);
5883 + } /* if FULL teardown */
5885 + /* perform all actions for both queues (+GSG 040212) */
5886 + for (i=0; i<HalDev->ChData[Ch].TxNumQueues; i++)
5888 + /* bug fix - clear Tx channel pointers on teardown */
5889 + HalDev->TcbPool[Ch][i] = 0;
5890 + HalDev->TxActQueueHead[Ch][i] = 0;
5891 + HalDev->TxActQueueCount[Ch][i] = 0;
5892 + HalDev->TxActive[Ch][i] = FALSE;
5895 + /* write completion pointer, only needed for the high priority queue */
5896 + (CPMAC_TX_INT_ACK( base , Ch )) = TEARDOWN_VAL;
5898 + /* no longer pending teardown */
5899 + HalDev->TxTeardownPending[Ch] &= ~TX_TEARDOWN;
5901 + HalDev->ChIsOpen[Ch][DIRECTION_TX] = 0;
5903 + HalDev->ChIsOpen[Ch][DIRECTION_TX] = 0;
5904 + CPMAC_TX_INTMASK_CLEAR(HalDev->dev_base) = (1<<Ch);
5905 + if ((HalDev->TxTeardownPending[Ch] & BLOCKING_TEARDOWN) == 0)
5908 + HalDev->OsFunc->TeardownComplete(HalDev->OsDev, Ch, DIRECTION_TX);
5910 + HalDev->TxTeardownPending[Ch] = 0;
5912 + return (EC_NO_ERRORS);
5918 +static void AddToRxQueue(HAL_DEVICE *HalDev, HAL_RCB *FirstRcb, HAL_RCB *LastRcb, int FragCount, int Ch)
5920 + if (HalDev->RxActQueueHead[Ch]==0)
5923 + HalDev->RxActQueueHead[Ch]=FirstRcb;
5924 + HalDev->RxActQueueTail[Ch]=LastRcb;
5925 + if (!HalDev->RxActive[Ch])
5927 + /* write Rx Queue Head Descriptor Pointer */
5928 + ((CPMAC_RX_HDP( HalDev->dev_base , Ch )) ) = VirtToPhys(FirstRcb) - HalDev->offset;
5929 + HalDev->RxActive[Ch]=TRUE;
5934 + register HAL_RCB *OldTailRcb;
5935 + register bit32u rmode;
5937 + HalDev->OsFunc->CriticalOn();
5938 + OldTailRcb=HalDev->RxActQueueTail[Ch];
5939 + OldTailRcb->Next=(void *)FirstRcb;
5940 + OldTailRcb=VirtToVirtNoCache(OldTailRcb);
5941 + OldTailRcb->HNext=VirtToPhys(FirstRcb) - HalDev->offset;
5942 + HalDev->RxActQueueTail[Ch]=LastRcb;
5943 + rmode=OldTailRcb->mode;
5944 + if (rmode&CB_EOQ_BIT)
5946 + rmode&=~CB_EOQ_BIT;
5947 + ((CPMAC_RX_HDP( HalDev->dev_base , Ch )) ) = VirtToPhys(FirstRcb) - HalDev->offset;
5948 + OldTailRcb->mode=rmode;
5950 + HalDev->OsFunc->CriticalOff();
5955 + * @ingroup CPHAL_Functions
5956 + * This function is called to indicate to the CPHAL that the upper layer
5957 + * software has finished processing the receive data (given to it by
5958 + * osReceive()). The CPHAL will then return the appropriate receive buffers
5959 + * and buffer descriptors to the available pool.
5961 + * @param HalReceiveInfo Start of receive buffer descriptor chain returned to
5963 + * @param StripFlag Flag indicating whether the upper layer software has
5964 + * retained ownership of the receive data buffers.
5966 + * 'FALSE' means that the CPHAL can reuse the receive data buffers.
5968 + * 'TRUE' : indicates the data buffers were retained by the OS
5970 + * NOTE: If StripFlag is TRUE, it is the responsibility of the upper layer software to free the buffers when they are no longer needed.
5972 + * @return EC_NO_ERRORS (ok). <BR>
5973 + * Possible Error Codes:<BR>
5974 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
5975 + * @ref EC_VAL_RCB_NEEDS_BUFFER "EC_VAL_RCB_NEEDS_BUFFER"<BR>
5976 + * @ref EC_VAL_RCB_DROPPED "EC_VAL_RCB_DROPPED"<BR>
5978 +static int halRxReturn(HAL_RECEIVEINFO *HalReceiveInfo,
5983 + HAL_DEVICE *HalDev;
5987 + Ch = HalReceiveInfo->mode&0x0ff;
5988 + HalDev = (HAL_DEVICE *)HalReceiveInfo->Off_BLen;
5989 + FragCount = HalReceiveInfo->mode>>8;
5991 + if (HalDev->State != enOpened)
5992 + return(EC_CPMAC |EC_FUNC_RXRETURN|EC_VAL_INVALID_STATE);
5994 + LastRcb=(HAL_RCB *)HalReceiveInfo->Eop;
5997 + RcbSize = HalDev->ChData[Ch].RxBufSize;
6001 + LastRcb->Off_BLen=RcbSize;
6002 + LastRcb->mode=CB_OWNERSHIP_BIT;
6005 + HalReceiveInfo->Off_BLen=RcbSize;
6006 + HalReceiveInfo->mode=CB_OWNERSHIP_BIT;
6008 + /* If OS has kept the buffers for this packet, attempt to alloc new buffers */
6011 + int rc=0; /*MJH+030417*/
6012 + int GoodCount=0; /*GSG+030421*/
6015 + HAL_RCB *CurrHeadRcb = HalReceiveInfo, *LastGoodRcb=0; /* +GSG 030421 */
6017 + TempRcb = HalReceiveInfo;
6018 + for (i=0; i<FragCount; i++)
6022 + dbgPrintf("Rx Return error while allocating new buffers\n");
6023 + dbgPrintf("Rcb = %08x, Rcb->Eop = %08x, FragCount = %d:%d\n",
6024 + (bit32u)HalReceiveInfo, (bit32u)HalReceiveInfo->Eop, FragCount,i);
6027 + return(EC_CPPI|EC_FUNC_RXRETURN|EC_VAL_CORRUPT_RCB_CHAIN);
6030 + pBuf= (char *) HalDev->OsFunc->MallocRxBuffer(RcbSize,0,
6031 + 0xF,HalDev->ChData[Ch].OsSetup,
6033 + (void *)&TempRcb->OsInfo,
6034 + (void *) HalDev->OsDev);
6037 + /* malloc failed, add this RCB to Needs Buffer List */
6038 + (HAL_RCB *)TempRcb->Eop = TempRcb; /* GSG +030430 */
6039 + TempRcb->mode=1<<8|Ch;
6040 + TempRcb->Off_BLen=(bit32u)HalDev;
6042 + if(HalDev->NeedsCount < MAX_NEEDS) /* +MJH 030410 */
6043 + { /* +MJH 030410 */
6044 + HalDev->Needs[HalDev->NeedsCount] = (HAL_RECEIVEINFO *) TempRcb; /* +MJH 030410 */
6045 + HalDev->NeedsCount++; /* +MJH 030410 */
6046 + rc = (EC_CPPI|EC_FUNC_RXRETURN|EC_VAL_RCB_NEEDS_BUFFER); /* ~MJH 030417 */
6047 + } /* +MJH 030410 */
6048 + else /* +MJH 030410 */
6049 + rc = (EC_CPPI|EC_FUNC_RXRETURN|EC_VAL_RCB_DROPPED); /* ~MJH 030417 */
6051 + /* requeue any previous RCB's that were ready to go before this one */
6052 + if (GoodCount > 0) /* +GSG 030421 */
6053 + { /* +GSG 030421 */
6054 + LastGoodRcb->HNext=0; /* +GSG 030430 */
6055 + LastGoodRcb->Next=0; /* +GSG 030430 */
6056 + osfuncDataCacheHitWritebackAndInvalidate((void *)LastGoodRcb, 16); /* +GSG 030430 */
6058 + AddToRxQueue(HalDev, CurrHeadRcb, LastGoodRcb, GoodCount, Ch); /* +GSG 030421 */
6059 + GoodCount = 0; /* +GSG 030421 */
6060 + } /* +GSG 030421 */
6062 + CurrHeadRcb = TempRcb->Next; /* +GSG 030421 */
6064 + else /* +GSG 030421 */
6065 + { /* +GSG 030421 */
6066 + /* malloc succeeded, requeue the RCB to the hardware */
6067 + TempRcb->BufPtr=VirtToPhys(pBuf) - HalDev->offset;
6068 + TempRcb->DatPtr=pBuf;
6069 + /* Emerald fix 10/29 */
6070 + osfuncDataCacheHitWritebackAndInvalidate((void *)TempRcb, 16);
6072 + /* i store the last good RCB in case the malloc fails for the
6073 + next fragment. This ensures that I can go ahead and return
6074 + a partial chain of RCB's to the hardware */
6075 + LastGoodRcb = TempRcb; /* +GSG 030421 */
6076 + GoodCount++; /* +GSG 030421 */
6077 + } /* +GSG 030421 */
6078 + TempRcb = TempRcb->Next;
6079 + } /* end of Frag loop */
6080 + /* if there any good RCB's to requeue, do so here */
6081 + if (GoodCount > 0) /* +GSG 030421 */
6083 + AddToRxQueue(HalDev, CurrHeadRcb, LastGoodRcb, GoodCount, Ch); /* +GSG 030421 */
6085 + return(rc); /* ~GSG 030421 */
6089 + /* Not Stripping */
6091 + /* Write Back SOP and last RCB */
6092 + osfuncDataCacheHitWritebackAndInvalidate((void *)HalReceiveInfo, 16);
6094 + if (FragCount > 1)
6096 + osfuncDataCacheHitWritebackAndInvalidate((void *)LastRcb, 16);
6098 + /* if not stripping buffers, always add to queue */
6099 + AddToRxQueue(HalDev, HalReceiveInfo, LastRcb, FragCount, Ch); /*MJH~030520*/
6102 + return(EC_NO_ERRORS);
6106 + Trys to liberate an RCB until liberation fails.
6107 + Note: If liberation fails then RxReturn will re-add the RCB to the
6110 +static void NeedsCheck(HAL_DEVICE *HalDev)
6112 + HAL_RECEIVEINFO* HalRcb;
6114 + HalDev->OsFunc->CriticalOn();
6115 + while(HalDev->NeedsCount)
6117 + HalDev->NeedsCount--;
6118 + HalRcb = HalDev->Needs[HalDev->NeedsCount];
6119 + rc = halRxReturn(HalRcb, 1);
6120 + /* short circuit if RxReturn starts to fail */
6124 + HalDev->OsFunc->CriticalOff();
6128 + * This function allocates transmit buffer descriptors (internal CPHAL function).
6129 + * It creates a high priority transmit queue by default for a single Tx
6130 + * channel. If QoS is enabled for the given CPHAL device, this function
6131 + * will also allocate a low priority transmit queue.
6133 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
6134 + * @param Ch Channel number.
6136 + * @return 0 OK, Non-Zero Not OK
6138 +static int InitTcb(HAL_DEVICE *HalDev, int Ch)
6140 + int i, Num = HalDev->ChData[Ch].TxNumBuffers;
6143 + int tcbSize, Queue;
6146 + tcbSize = (sizeof(HAL_TCB)+0xf)&~0xf;
6147 + SizeMalloc = (tcbSize*Num)+0xf;
6149 + for (Queue=0; Queue < HalDev->ChData[Ch].TxNumQueues; Queue++)
6151 + if (HalDev->TcbStart[Ch][Queue] == 0)
6154 + /* malloc all TCBs at once */
6155 + AllTcb = (char *)HalDev->OsFunc->MallocDmaXfer(SizeMalloc,0,0xffffffff);
6158 + return(EC_CPPI|EC_FUNC_HAL_INIT|EC_VAL_TCB_MALLOC_FAILED);
6161 + HalDev->OsFunc->Memset(AllTcb, 0, SizeMalloc);
6163 + /* keep this address for freeing later */
6164 + HalDev->TcbStart[Ch][Queue] = AllTcb;
6168 + /* if the memory has already been allocated, simply reuse it! */
6169 + AllTcb = HalDev->TcbStart[Ch][Queue];
6172 + /* align to cache line */
6173 + AllTcb = (char *)(((bit32u)AllTcb + 0xf) &~ 0xf); /*PITS #143 MJH~030522*/
6175 + /* default High priority transmit queue */
6176 + HalDev->TcbPool[Ch][Queue]=0;
6177 + for(i=0;i<Num;i++)
6179 + /*pTcb=(HAL_TCB *) OsFunc->MallocDmaXfer(sizeof(HAL_TCB),0,0xffffffff); */
6180 + pTcb= (HAL_TCB *)(AllTcb + (i*tcbSize));
6183 + pTcb->Next=HalDev->TcbPool[Ch][Queue];
6185 + HalDev->TcbPool[Ch][Queue]=pTcb;
6187 + /*HalDev->TcbEnd = pTcb;*/
6190 + return(EC_NO_ERRORS);
6194 + * This function allocates receive buffer descriptors (internal CPHAL function).
6195 + * After allocation, the function 'queues' (gives to the hardware) the newly
6196 + * created receive buffers to enable packet reception.
6198 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
6199 + * @param Ch Channel number.
6201 + * @return 0 OK, Non-Zero Not OK
6203 +static int InitRcb(HAL_DEVICE *HalDev, int Ch)
6205 + int i, Num = HalDev->ChData[Ch].RxNumBuffers;
6206 + int Size = HalDev->ChData[Ch].RxBufSize;
6215 + rcbSize = (sizeof(HAL_RCB)+0xf)&~0xf;
6216 + SizeMalloc = (rcbSize*Num)+0xf;
6218 + if (HalDev->RcbStart[Ch] == 0)
6222 + /* malloc all RCBs at once */
6223 + AllRcb= (char *)HalDev->OsFunc->MallocDmaXfer(SizeMalloc,0,0xffffffff);
6226 + return(EC_CPPI|EC_FUNC_HAL_INIT|EC_VAL_RCB_MALLOC_FAILED);
6229 + HalDev->OsFunc->Memset(AllRcb, 0, SizeMalloc);
6231 + /* keep this address for freeing later */
6232 + HalDev->RcbStart[Ch] = AllRcb;
6236 + /* if the memory has already been allocated, simply reuse it! */
6237 + AllRcb = HalDev->RcbStart[Ch];
6240 + /* align to cache line */
6241 + AllRcb = (char *)(((bit32u)AllRcb + 0xf)&~0xf); /*PITS #143 MJH~030522*/
6243 + HalDev->RcbPool[Ch]=0;
6244 + for(i=0;i<Num;i++)
6246 + pRcb = (HAL_RCB *)(AllRcb + (i*rcbSize));
6248 + if (DoMalloc == 1)
6251 + MallocSize = Size; /*~3.01 */
6252 + pBuf= (char *) HalDev->OsFunc->MallocRxBuffer(MallocSize,0,0xF,HalDev->ChData[Ch].OsSetup, (void *)pRcb, (void *)&pRcb->OsInfo, (void *) HalDev->OsDev);
6255 + return(EC_CPPI|EC_FUNC_HAL_INIT|EC_VAL_RX_BUFFER_MALLOC_FAILED);
6257 + /* -RC3.01 pBuf = (char *)(((bit32u)pBuf+0xF) & ~0xF); */
6258 + pRcb->BufPtr=VirtToPhys(pBuf) - HalDev->offset;
6259 + pRcb->DatPtr=pBuf;
6261 + pRcb->mode=(1<<8)|Ch; /* One Frag for Ch */
6262 + pRcb->Next=(void *)HalDev->RcbPool[Ch];
6263 + pRcb->Off_BLen=(bit32u)HalDev;
6264 + HalDev->RcbPool[Ch]=pRcb;
6267 + /* Give all of the Rx buffers to hardware */
6269 + while(HalDev->RcbPool[Ch])
6271 + pRcb=HalDev->RcbPool[Ch];
6272 + HalDev->RcbPool[Ch]=pRcb->Next;
6273 + pRcb->Eop=(void*)pRcb;
6274 + pRcb->mode=(1<<8)|Ch;
6275 + halRxReturn((HAL_RECEIVEINFO *)pRcb, 0);
6278 + return(EC_NO_ERRORS);
6282 + * @ingroup CPHAL_Functions
6283 + * This function transmits the data in FragList using available transmit
6284 + * buffer descriptors. More information on the use of the Mode parameter
6285 + * is available in the module-specific appendices. Note: The OS should
6286 + * not call Send() for a channel that has been requested to be torndown.
6288 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
6289 + * @param FragList Fragment List structure.
6290 + * @param FragCount Number of fragments in FragList.
6291 + * @param PacketSize Number of bytes to transmit.
6292 + * @param OsSendInfo OS Send Information structure. <BR>
6293 + * @param Mode 32-bit value with the following bit fields: <BR>
6294 + * 31-16: Mode (used for module specific data). <BR>
6295 + * 15-08: Queue (transmit queue to send on). <BR>
6296 + * 07-00: Channel (channel number to send on).
6298 + * @return EC_NO_ERRORS (ok). <BR>
6299 + * Possible Error Codes:<BR>
6300 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
6301 + * @ref EC_VAL_NOT_LINKED "EC_VAL_NOT_LINKED"<BR>
6302 + * @ref EC_VAL_INVALID_CH "EC_VAL_INVALID_CH"<BR>
6303 + * @ref EC_VAL_OUT_OF_TCBS "EC_VAL_OUT_OF_TCBS"<BR>
6304 + * @ref EC_VAL_NO_TCBS "EC_VAL_NO_TCBS"<BR>
6306 +static int halSend(HAL_DEVICE *HalDev,FRAGLIST *FragList,
6307 + int FragCount,int PacketSize, OS_SENDINFO *OsSendInfo,
6310 + HAL_TCB *tcb_ptr, *head;
6312 + int rc = EC_NO_ERRORS;
6313 + int Ch = Mode & 0xFF;
6314 + int Queue = (Mode>>8)&0xFF;
6315 + /*int DoThresholdCheck=1; */ /* Used when TxIntDisable is set and TxInts are re-enabled */
6317 + if (HalDev->State != enOpened)
6318 + return(EC_CPPI|EC_FUNC_SEND|EC_VAL_INVALID_STATE);
6320 + if (!HalDev->Linked)
6322 + rc = EC_CPPI|EC_FUNC_SEND|EC_VAL_NOT_LINKED;
6326 + if (HalDev->ChIsOpen[Ch][DIRECTION_TX] == 0) /*MJH~030611*/ /*PITS 148*/
6327 + return(EC_CPMAC |EC_FUNC_SEND|EC_VAL_INVALID_CH); /*+GSG 030303*/
6329 + HalDev->OsFunc->CriticalOn();
6331 + /* Setup Tx mode and size */
6332 + if (PacketSize<60)
6334 + FragList[FragCount-1].len += (60 - PacketSize); /*MJH~030506*//*PITS 132*/
6335 + PacketSize = 60; /*MJH~030506*/
6337 + Mode &= CB_PASSCRC_BIT;
6339 + tcb_ptr = head = HalDev->TcbPool[Ch][Queue];
6344 + Mode|=PacketSize|CB_SOF_BIT|CB_OWNERSHIP_BIT;
6346 + for (i=0; i<FragCount; i++)
6349 + /* Setup Tx mode and size */
6350 + tcb_ptr->Off_BLen = FragList[i].len;
6352 + tcb_ptr->mode = Mode;
6353 + tcb_ptr->BufPtr = VirtToPhys((bit32 *)FragList[i].data) - HalDev->offset;
6354 + tcb_ptr->OsInfo = OsSendInfo;
6356 + if (i == (FragCount - 1))
6358 + /* last fragment */
6359 + tcb_ptr->mode |= CB_EOF_BIT;
6361 + /* since this is the last fragment, set the TcbPool pointer before
6362 + nulling out the Next pointers */
6364 + HalDev->TcbPool[Ch][Queue] = tcb_ptr->Next;
6366 + tcb_ptr->Next = 0;
6367 + tcb_ptr->HNext = 0;
6369 + /* In the Tx Interrupt handler, we will need to know which TCB is EOP,
6370 + so we can save that information in the SOP */
6371 + head->Eop = tcb_ptr;
6373 + /* Emerald fix 10/29 */
6374 + osfuncDataCacheHitWritebackAndInvalidate((void *)tcb_ptr, 16);
6379 + Mode=CB_OWNERSHIP_BIT;
6380 + tcb_ptr->HNext = VirtToPhys((bit32 *)tcb_ptr->Next) - HalDev->offset;
6382 + /* Emerald fix 10/29 */
6383 + osfuncDataCacheHitWritebackAndInvalidate((void *)tcb_ptr, 16);
6385 + tcb_ptr = tcb_ptr->Next; /* what about the end of TCB list?? */
6389 + rc = EC_CPPI|EC_FUNC_SEND|EC_VAL_OUT_OF_TCBS;
6395 + /* put it on the high priority queue */
6396 + if (HalDev->TxActQueueHead[Ch][Queue] == 0)
6398 + HalDev->TxActQueueHead[Ch][Queue]=head;
6399 + HalDev->TxActQueueTail[Ch][Queue]=tcb_ptr;
6400 +/*+GSG 030303*//*+GSG 030303*/
6401 + if (!HalDev->TxActive[Ch][Queue])
6404 + bit32u base = HalDev->dev_base;
6406 + /* write CPPI TX HDP */
6407 + (CPMAC_TX_HDP( base , Ch )) = VirtToPhys(head) - HalDev->offset;
6408 + HalDev->TxActive[Ch][Queue]=TRUE;
6414 + register volatile HAL_TCB *pTailTcb;
6415 + register bit32u tmode;
6416 + register bit32u pCurrentTcb;
6418 + HalDev->TxActQueueTail[Ch][Queue]->Next=head;
6419 + /* Emerald fix 10/29 */
6421 + pTailTcb=(HAL_TCB *)VirtToVirtNoCache(&HalDev->TxActQueueTail[Ch][Queue]->HNext);
6422 + pCurrentTcb=VirtToPhys(head) - HalDev->offset;
6423 + pTailTcb->HNext=pCurrentTcb;
6424 + HalDev->TxActQueueTail[Ch][Queue]=tcb_ptr;
6426 + tmode=pTailTcb->mode;
6427 + if (tmode&CB_EOQ_BIT)
6429 + bit32u base = HalDev->dev_base;
6431 + tmode&=~CB_EOQ_BIT;
6432 + pTailTcb->mode=tmode;
6433 + ((CPMAC_TX_HDP( base , Ch )) ) = pCurrentTcb;
6438 + if(HalDev->TxIntDisable)
6440 + /* Enable Interrupts, to ensure packet goes out on wire */
6441 + CPMAC_TX_INTMASK_SET(HalDev->dev_base) = (1<<Ch);
6442 + halPacketProcessEnd(HalDev); /* Allow Interrupt to be seen at the OS */
6443 + /*DoThresholdCheck = 0; */ /* Disable Threshold Check */
6449 + rc = EC_NO_ERRORS;
6451 + } /* if (tcb_ptr) */
6454 + rc = EC_CPPI|EC_FUNC_SEND|EC_VAL_NO_TCBS;
6459 +/* 15 June 2004 - NSP Performance Update : If Tx Ints are disabled then process them here */
6460 +/* 29 June 2004 - NSP Performance Update : Moved to end at request of BCIL */
6461 +/* 23 Aug 2004 - NSP Performance Update : If Tx Ints are re-enabled do not do Threshold check */
6463 + if(HalDev->TxIntDisable /*&& DoThresholdCheck*/)
6465 + if(--HalDev->TxIntThreshold[Ch] <= 0)
6468 + TxInt(HalDev, Ch, 0, &MoreWork);
6469 + HalDev->TxIntThreshold[Ch] = HalDev->TxIntThresholdMaster[Ch];
6472 + HalDev->OsFunc->CriticalOff();
6478 + * This function processes receive interrupts. It traverses the receive
6479 + * buffer queue, extracting the data and passing it to the upper layer software via
6480 + * osReceive(). It handles all error conditions and fragments without valid data by
6481 + * immediately returning the RCB's to the RCB pool.
6483 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
6484 + * @param Ch Channel Number.
6485 + * @param MoreWork Flag that indicates that there is more work to do when set to 1.
6487 + * @return 0 if OK, non-zero otherwise.
6489 +static int RxInt(HAL_DEVICE *HalDev, int Ch, int *MoreWork)
6491 + HAL_RCB *CurrentRcb, *SopRcb, *EofRcb, *EopRcb;
6492 + bit32u RxBufStatus,PacketsServiced, RxPktLen = 0, RxSopStatus,
6493 + FrmFrags, TotalFrags, FrmLen;
6494 + int base = HalDev->dev_base, Ret;
6495 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
6496 + int RxServiceMax = HalDev->ChData[Ch].RxServiceMax;
6497 + int FragIndex; /* +GSG 030508 */
6499 + if(HalDev->NeedsCount) /* +MJH 030410 */
6500 + NeedsCheck(HalDev); /* +MJH 030410 */
6502 + /* Handle case of teardown interrupt */
6503 + if (HalDev->RxTeardownPending[Ch] != 0)
6505 + Ret = RxTeardownInt(HalDev, Ch);
6509 + return (EC_NO_ERRORS);
6513 + /* Examine first RCB on the software active queue */
6514 + CurrentRcb=HalDev->RxActQueueHead[Ch];
6515 + osfuncDataCacheHitInvalidate((void*)CurrentRcb, 16);
6516 + RxBufStatus=CurrentRcb->mode;
6517 + PacketsServiced=0;
6519 + /* Process received packets until we find hardware owned descriptors
6520 + or until we hit RxServiceMax */
6521 + while((CurrentRcb)&&((RxBufStatus&CB_OWNERSHIP_BIT)==0)&&
6522 + (PacketsServiced<RxServiceMax)) /* ~GSG 030307 */
6525 + PacketsServiced++; /* ~GSG 030307 */
6526 + SopRcb=CurrentRcb;
6527 + RxSopStatus=RxBufStatus;
6528 + RxPktLen = RxSopStatus&CB_SIZE_MASK;
6536 +/* +GSG 030508 *//* +GSG 030508 */
6538 + /* Loop through all fragments that comprise current packet. Build
6539 + fraglist and exit when the end of the packet is reached, or the
6540 + end of the descriptor list is reached. */
6546 + DmaLen=CurrentRcb->Off_BLen;
6552 + HalDev->fraglist[FragIndex].data=((char *)CurrentRcb->DatPtr); /* ~GSG 030508 */
6554 + HalDev->fraglist[FragIndex].len=DmaLen; /* ~GSG 030508 */
6557 + HalDev->fraglist[FragIndex].OsInfo = CurrentRcb->OsInfo; /* ~GSG 030508 */
6559 + /* Upper layer must do the data invalidate */
6562 + FragIndex++; /* ~GSG 030508 */
6563 + if (FrmLen>=RxPktLen)
6564 + EofRcb=CurrentRcb;
6566 + EopRcb=CurrentRcb;
6567 + CurrentRcb=EopRcb->Next;
6570 + osfuncDataCacheHitInvalidate((void*)CurrentRcb,16);
6572 + }while(((EopRcb->mode&CB_EOF_BIT)==0)&&(CurrentRcb));
6574 + /* Write the completion pointer for interrupt acknowledgement*/
6575 + (CPMAC_RX_INT_ACK( base , Ch )) = VirtToPhys(EopRcb) - HalDev->offset;
6579 + if (CurrentRcb == 0)
6581 + /* If we are out of RCB's we must not send this packet
6583 + int RcbSize = HalDev->ChData[Ch].RxBufSize;
6587 + EopRcb->Off_BLen=RcbSize;
6588 + EopRcb->mode=CB_OWNERSHIP_BIT;
6589 + osfuncDataCacheHitWritebackAndInvalidate((void *)EopRcb, 16);
6592 + SopRcb->Off_BLen=RcbSize;
6593 + SopRcb->mode=CB_OWNERSHIP_BIT;
6594 + osfuncDataCacheHitWritebackAndInvalidate((void *)SopRcb, 16);
6596 + ((CPMAC_RX_HDP( base , Ch )) ) = VirtToPhys(SopRcb);
6600 + /* Dequeue packet and send to OS */
6603 + /* setup SopRcb for the packet */
6604 + SopRcb->Eop=(void*)EopRcb;
6606 + /* dequeue packet */
6607 + HalDev->RxActQueueHead[Ch]=CurrentRcb;
6609 + if (EopRcb->mode&CB_EOQ_BIT)
6611 + /* Next pointer is non-null and EOQ bit is set, which
6612 + indicates misqueue packet in CPPI protocol. */
6614 + ((CPMAC_RX_HDP( base , Ch )) ) = EopRcb->HNext;
6617 + mode = (SopRcb->mode & 0xFFFF0000) | Ch;
6619 + SopRcb->mode=(FrmFrags<<8)|Ch;
6620 + SopRcb->Off_BLen=(bit32u)HalDev;
6622 + /* send packet up the higher layer driver */
6623 + OsFunc->Receive(HalDev->OsDev,HalDev->fraglist,FragIndex,RxPktLen, /* ~GSG 030508 */
6624 + (HAL_RECEIVEINFO *)SopRcb,mode);
6626 + RxBufStatus=CurrentRcb->mode;
6628 + } /* while loop */
6630 + if ((CurrentRcb)&&((RxBufStatus&CB_OWNERSHIP_BIT)==0)) /*~GSG 030307*/
6639 + return (EC_NO_ERRORS);
6643 + * This function processes transmit interrupts. It traverses the
6644 + * transmit buffer queue, detecting sent data buffers and notifying the upper
6645 + * layer software via osSendComplete(). (for SAR, i originally had this split
6646 + * into two functions, one for each queue, but joined them on 8/8/02)
6648 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
6649 + * @param Queue Queue number to service (always 0 for MAC, Choose 1 for SAR to service low priority queue)
6650 + * @param MoreWork Flag that indicates that there is more work to do when set to 1.
6652 + * @return 0 if OK, non-zero otherwise.
6654 +int TxInt(HAL_DEVICE *HalDev, int Ch, int Queue, int *MoreWork)
6656 + HAL_TCB *CurrentTcb,*LastTcbProcessed,*FirstTcbProcessed;
6657 + int PacketsServiced;
6658 + bit32u TxFrameStatus;
6660 + int TxServiceMax = HalDev->ChData[Ch].TxServiceMax;
6661 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
6663 +/*+GSG 030303*//*+GSG 030303*/
6665 + /* load the module base address */
6666 + base = HalDev->dev_base;
6668 + /* Handle case of teardown interrupt. This must be checked at
6669 + the top of the function rather than the bottom, because
6670 + the normal data processing can wipe out the completion
6671 + pointer which is used to determine teardown complete. */
6672 + if (HalDev->TxTeardownPending[Ch] != 0)
6676 + Ret = TxTeardownInt(HalDev, Ch, Queue);
6679 + *MoreWork = 0; /* bug fix 1/6 */ /*+GSG 030303*/
6680 + return (EC_NO_ERRORS);
6684 + OsFunc->CriticalOn(); /* 240904 */
6686 + CurrentTcb = HalDev->TxActQueueHead[Ch][Queue];
6687 + FirstTcbProcessed=CurrentTcb;
6689 + if (CurrentTcb==0)
6691 + /* I saw this error a couple of times when multi-channels were added */
6692 + dbgPrintf("[cppi TxInt()]TxH int with no TCB in queue!\n");
6693 + dbgPrintf(" Ch=%d, CurrentTcb = 0x%08x\n", Ch, (bit32u)CurrentTcb);
6694 + dbgPrintf(" HalDev = 0x%08x\n", (bit32u)HalDev);
6696 + OsFunc->CriticalOff();
6697 + return(EC_CPPI|EC_FUNC_TXINT|EC_VAL_NULL_TCB);
6700 + osfuncDataCacheHitInvalidate((void *)CurrentTcb, 16);
6701 + TxFrameStatus=CurrentTcb->mode;
6702 + PacketsServiced=0;
6704 + /* should the ownership bit check be inside of the loop?? could make it a
6705 + while-do loop and take this check away */
6706 + if ((TxFrameStatus&CB_OWNERSHIP_BIT)==0)
6710 + /* Pop TCB(s) for packet from the stack */
6711 + LastTcbProcessed=CurrentTcb->Eop;
6713 + /* new location for acknowledge */
6714 + /* Write the completion pointer */
6715 + (CPMAC_TX_INT_ACK( base , Ch )) = VirtToPhys(LastTcbProcessed) - HalDev->offset;
6717 + HalDev->TxActQueueHead[Ch][Queue] = LastTcbProcessed->Next;
6719 +/*+GSG 030303*//*+GSG 030303*/
6721 + osfuncDataCacheHitInvalidate((void *)LastTcbProcessed, 16);
6723 + if (LastTcbProcessed->mode&CB_EOQ_BIT)
6725 + if (LastTcbProcessed->Next)
6727 + /* Misqueued packet */
6729 + (CPMAC_TX_HDP( base , Ch )) = LastTcbProcessed->HNext;
6734 + /* Tx End of Queue */
6736 + HalDev->TxActive[Ch][Queue]=FALSE;
6740 + OsFunc->SendComplete(CurrentTcb->OsInfo);
6742 + /* Push Tcb(s) back onto the stack */
6743 + CurrentTcb = LastTcbProcessed->Next;
6745 + LastTcbProcessed->Next=HalDev->TcbPool[Ch][Queue];
6747 + HalDev->TcbPool[Ch][Queue]=FirstTcbProcessed;
6749 + PacketsServiced++;
6751 + TxFrameStatus=CB_OWNERSHIP_BIT;
6752 + /* set the first(SOP) pointer for the next packet */
6753 + FirstTcbProcessed = CurrentTcb;
6756 + osfuncDataCacheHitInvalidate((void *)CurrentTcb, 16);
6757 + TxFrameStatus=CurrentTcb->mode;
6760 + }while(((TxFrameStatus&CB_OWNERSHIP_BIT)==0)
6761 + &&(PacketsServiced<TxServiceMax));
6763 + if (((TxFrameStatus&CB_OWNERSHIP_BIT)==0)
6764 + &&(PacketsServiced==TxServiceMax))
6773 + OsFunc->CriticalOff();
6775 + return(EC_NO_ERRORS);
6779 + * @ingroup CPHAL_Functions
6780 + * This function performs a teardown for the given channel. The value of the
6781 + * Mode parameter controls the operation of the function, as documented below.
6783 + * Note: If bit 3 of Mode is set, this call is blocking, and will not return
6784 + * until the teardown interrupt has occurred and been processed. While waiting
6785 + * for a blocking teardown to complete, ChannelTeardown() will signal the OS
6786 + * (via Control(.."Sleep"..)) to allow the OS to perform other tasks if
6787 + * necessary. If and only if bit 3 of Mode is clear, the CPHAL will call the
6788 + * OS TeardownComplete() function to indicate that the teardown has completed.
6790 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
6791 + * @param Ch Channel number.
6792 + * @param Mode Bit 0 (LSB): Perform Tx teardown (if set).<BR>
6793 + * Bit 1: Perform Rx teardown (if set). <BR>
6794 + * Bit 2: If set, perform full teardown (free buffers/descriptors).
6795 + * If clear, perform partial teardown (keep buffers). <BR>
6796 + * Bit 3 (MSB): If set, call is blocking.
6797 + * If clear, call is non-blocking.
6799 + * @return EC_NO_ERRORS (ok). <BR>
6800 + * Possible Error Codes:<BR>
6801 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
6802 + * @ref EC_VAL_INVALID_CH "EC_VAL_INVALID_CH"<BR>
6803 + * @ref EC_VAL_TX_TEARDOWN_ALREADY_PEND "EC_VAL_TX_TEARDOWN_ALREADY_PEND"<BR>
6804 + * @ref EC_VAL_RX_TEARDOWN_ALREADY_PEND "EC_VAL_RX_TEARDOWN_ALREADY_PEND"<BR>
6805 + * @ref EC_VAL_TX_CH_ALREADY_TORNDOWN "EC_VAL_TX_CH_ALREADY_TORNDOWN"<BR>
6806 + * @ref EC_VAL_RX_CH_ALREADY_TORNDOWN "EC_VAL_RX_CH_ALREADY_TORNDOWN"<BR>
6807 + * @ref EC_VAL_TX_TEARDOWN_TIMEOUT "EC_VAL_TX_TEARDOWN_TIMEOUT"<BR>
6808 + * @ref EC_VAL_RX_TEARDOWN_TIMEOUT "EC_VAL_RX_TEARDOWN_TIMEOUT"<BR>
6809 + * @ref EC_VAL_LUT_NOT_READY "EC_VAL_LUT_NOT_READY"<BR>
6811 +static int halChannelTeardown(HAL_DEVICE *HalDev, int Ch, bit32 Mode)
6813 + int DoTx, DoRx, Sleep=2048, timeout=0; /*MJH~030306*/
6814 + bit32u base = HalDev->dev_base;
6816 +/* Set the module, used for error returns */
6818 + DoTx = (Mode & TX_TEARDOWN);
6819 + DoRx = (Mode & RX_TEARDOWN);
6821 + if (HalDev->State < enInitialized)
6822 + return(EC_CPMAC |EC_FUNC_CHTEARDOWN|EC_VAL_INVALID_STATE);
6824 + if ((Ch < 0) || (Ch > (MAX_CHAN-1) ))
6826 + return(EC_CPMAC |EC_FUNC_CHTEARDOWN|EC_VAL_INVALID_CH);
6829 + /* set teardown pending bits before performing the teardown, because they
6830 + will be used in the int handler (this is done for AAL5) */
6833 + if (HalDev->TxTeardownPending[Ch] != 0)
6834 + return(EC_CPMAC |EC_FUNC_CHTEARDOWN|EC_VAL_TX_TEARDOWN_ALREADY_PEND);
6836 + /* If a full teardown, this also means that the user must
6837 + setup all channels again to use them */
6838 + if (Mode & FULL_TEARDOWN)
6839 + HalDev->ChIsSetup[Ch][DIRECTION_TX] = 0;
6841 + if (HalDev->State < enOpened)
6843 + /* if the hardware has never been opened, the channel has never actually
6844 + been setup in the hardware, so I just need to reset the software flag
6846 + HalDev->ChIsSetup[Ch][DIRECTION_TX] = 0;
6847 + return (EC_NO_ERRORS);
6851 + if (HalDev->ChIsOpen[Ch][DIRECTION_TX] == 0)
6853 + return(EC_CPMAC |EC_FUNC_CHTEARDOWN|EC_VAL_TX_CH_ALREADY_TORNDOWN);
6856 + /* set teardown flag */
6857 + HalDev->TxTeardownPending[Ch] = Mode;
6863 + if (HalDev->RxTeardownPending[Ch] != 0)
6864 + return(EC_CPMAC |EC_FUNC_CHTEARDOWN|EC_VAL_RX_TEARDOWN_ALREADY_PEND);
6866 + if (Mode & FULL_TEARDOWN)
6867 + HalDev->ChIsSetup[Ch][DIRECTION_RX] = 0;
6869 + if (HalDev->State < enOpened)
6871 + HalDev->ChIsSetup[Ch][DIRECTION_RX] = 0;
6872 + return (EC_NO_ERRORS);
6876 + if (HalDev->ChIsOpen[Ch][DIRECTION_RX] == 0)
6877 + return(EC_CPMAC |EC_FUNC_CHTEARDOWN|EC_VAL_RX_CH_ALREADY_TORNDOWN);
6879 + HalDev->RxTeardownPending[Ch] = Mode;
6883 + /* Perform Tx Teardown Duties */
6884 + if ((DoTx) && (HalDev->State == enOpened))
6886 + /* Request TX channel teardown */
6887 + (CPMAC_TX_TEARDOWN( base )) = Ch;
6889 + /* wait until teardown has completed */
6890 + if (Mode & BLOCKING_TEARDOWN)
6893 + while (HalDev->ChIsOpen[Ch][DIRECTION_TX] == TRUE)
6895 + osfuncSleep(&Sleep);
6898 + if (timeout > 100000)
6900 + return(EC_CPMAC |EC_FUNC_CHTEARDOWN|EC_VAL_TX_TEARDOWN_TIMEOUT);
6906 + /* Perform Rx Teardown Duties */
6907 + if ((DoRx) && (HalDev->State == enOpened))
6910 + /* perform CPMAC specific RX channel teardown */
6911 + CPMAC_RX_TEARDOWN(base) = Ch;
6913 + if (Mode & BLOCKING_TEARDOWN)
6916 + while (HalDev->ChIsOpen[Ch][DIRECTION_RX] == TRUE)
6918 + osfuncSleep(&Sleep);
6921 + if (timeout > 100000)
6923 + return(EC_CPMAC |EC_FUNC_CHTEARDOWN|EC_VAL_RX_TEARDOWN_TIMEOUT);
6929 + return (EC_NO_ERRORS);
6933 + * @ingroup CPHAL_Functions
6934 + * This function closes the CPHAL module. The module will be reset.
6935 + * The Mode parameter should be used to determine the actions taken by
6938 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
6939 + * @param Mode Indicates actions to take on close. The following integer
6940 + * values are valid: <BR>
6941 + * 1: Does not free buffer resources, init parameters remain
6942 + * intact. User can then call Open() without calling Init()
6943 + * to attempt to reset the device and bring it back to the
6944 + * last known state.<BR>
6945 + * 2: Frees the buffer resources, but keeps init parameters. This
6946 + * option is a more aggressive means of attempting a device reset.
6947 + * 3: Frees the buffer resources, and clears all init parameters. <BR>
6948 + * At this point, the caller would have to call to completely
6949 + * reinitialize the device (Init()) before being able to call
6950 + * Open(). Use this mode if you are shutting down the module
6951 + * and do not plan to restart.
6953 + * @return EC_NO_ERRORS (ok).<BR>
6954 + * Possible Error Codes:<BR>
6955 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
6956 + * Any error code from halChannelTeardown().<BR>
6958 +static int halClose(HAL_DEVICE *HalDev, bit32 Mode)
6960 + int Ch, Inst, Ret;
6961 + OS_DEVICE *TmpOsDev;
6962 + OS_FUNCTIONS *TmpOsFunc;
6963 + HAL_FUNCTIONS *TmpHalFunc;
6964 + char *TmpDeviceInfo;
6966 + int Ticks; /*MJH~030306*/
6968 + /* Verify proper device state */
6969 + if (HalDev->State != enOpened)
6970 + return (EC_CPMAC | EC_FUNC_CLOSE|EC_VAL_INVALID_STATE);
6972 + /* Teardown all open channels */
6973 + for (Ch = 0; Ch <= (MAX_CHAN-1) ; Ch++)
6975 + if (HalDev->ChIsOpen[Ch][DIRECTION_TX] == TRUE)
6979 + Ret = halChannelTeardown(HalDev, Ch, TX_TEARDOWN | PARTIAL_TEARDOWN | BLOCKING_TEARDOWN);
6980 + if (Ret) return (Ret);
6984 + Ret = halChannelTeardown(HalDev, Ch, TX_TEARDOWN | FULL_TEARDOWN | BLOCKING_TEARDOWN);
6985 + if (Ret) return (Ret);
6989 + if (HalDev->ChIsOpen[Ch][DIRECTION_RX] == TRUE)
6993 + Ret = halChannelTeardown(HalDev, Ch, RX_TEARDOWN | PARTIAL_TEARDOWN | BLOCKING_TEARDOWN);
6994 + if (Ret) return (Ret);
6998 + Ret = halChannelTeardown(HalDev, Ch, RX_TEARDOWN | FULL_TEARDOWN | BLOCKING_TEARDOWN);
6999 + if (Ret) return (Ret);
7004 + /* free fraglist in HalDev */
7005 + HalDev->OsFunc->Free(HalDev->fraglist);
7006 + HalDev->fraglist = 0;
7008 + /* unregister the interrupt */
7009 + HalDev->OsFunc->IsrUnRegister(HalDev->OsDev, HalDev->interrupt);
7011 + Ticks = 0; /* Disable Tick Timer */ /*MJH+030306*/
7012 + HalDev->OsFunc->Control(HalDev->OsDev, hcTick, hcClear, &Ticks); /*MJH+030306*/
7014 + /* Free the Phy Information Structure */
7015 + if(HalDev->PhyDev)
7017 + HalDev->OsFunc->Free(HalDev->PhyDev); /*MJH+030513*/
7018 + HalDev->PhyDev = 0; /*MJH+030522*/
7021 + /* Perform CPMAC specific closing functions */
7022 + CPMAC_MACCONTROL(HalDev->dev_base) &= ~MII_EN;
7023 + CPMAC_TX_CONTROL(HalDev->dev_base) &= ~TX_EN;
7024 + CPMAC_RX_CONTROL(HalDev->dev_base) &= ~RX_EN;
7026 + /* put device back into reset */
7027 + (*(volatile bit32u *)(HalDev->ResetBase)) &=~ (1<<HalDev->ResetBit);
7028 + Ticks = 64; /*MJH~030306*/
7029 + osfuncSleep(&Ticks);
7031 + /* If mode is 3, than clear the HalDev and set next state to DevFound*/
7034 + /* I need to keep the HalDev parameters that were setup in InitModule */
7035 + TmpOsDev = HalDev->OsDev;
7036 + TmpOsFunc = HalDev->OsFunc;
7037 + TmpDeviceInfo = HalDev->DeviceInfo;
7039 + TmpHalFunc = HalDev->HalFuncPtr;
7040 + Inst = HalDev->Inst;
7042 + /* Clear HalDev */
7044 + HalDev->OsFunc->Memset(HalDev, 0, sizeof(HAL_DEVICE));
7046 + /* Restore key parameters */
7047 + HalDev->OsDev = TmpOsDev;
7048 + HalDev->OsFunc = TmpOsFunc;
7049 + HalDev->DeviceInfo = TmpDeviceInfo;
7051 + HalDev->HalFuncPtr = TmpHalFunc;
7052 + HalDev->Inst = Inst;
7054 + HalDev->State = enDevFound;
7058 + HalDev->State = enInitialized;
7061 + return(EC_NO_ERRORS);
7063 diff -urN linux.old/drivers/net/avalanche_cpmac/cpremap_cpmac.c linux.dev/drivers/net/avalanche_cpmac/cpremap_cpmac.c
7064 --- linux.old/drivers/net/avalanche_cpmac/cpremap_cpmac.c 1970-01-01 01:00:00.000000000 +0100
7065 +++ linux.dev/drivers/net/avalanche_cpmac/cpremap_cpmac.c 2005-07-12 02:48:42.049593000 +0200
7067 +#ifndef _INC_CPREMAP_C
7068 +#define _INC_CPREMAP_C
7071 +static inline void osfuncDataCacheHitInvalidate(void *ptr, int Size)
7073 + asm(" cache 17, (%0)" : : "r" (ptr));
7076 +static inline void osfuncDataCacheHitWriteback(void *ptr, int Size)
7078 + asm(" cache 25, (%0)" : : "r" (ptr));
7081 +static inline void osfuncDataCacheHitWritebackAndInvalidate(void *ptr, int Size)
7083 + asm(" cache 21, (%0)" : : "r" (ptr));
7088 +#define osfuncDataCacheHitInvalidate(MemPtr, Size) __asm__(" .set mips3; cache 17, (%0); .set mips0" : : "r" (MemPtr))
7089 +#define osfuncDataCacheHitWritebackAndInvalidate(MemPtr, Size) __asm__(" .set mips3; cache 21, (%0); .set mips0" : : "r" (MemPtr))
7090 +#define osfuncDataCacheHitWriteback(MemPtr, Size) __asm__(" .set mips3; cache 25, (%0); .set mips0" : : "r" (MemPtr))
7095 diff -urN linux.old/drivers/net/avalanche_cpmac/cpswhal_cpmac.h linux.dev/drivers/net/avalanche_cpmac/cpswhal_cpmac.h
7096 --- linux.old/drivers/net/avalanche_cpmac/cpswhal_cpmac.h 1970-01-01 01:00:00.000000000 +0100
7097 +++ linux.dev/drivers/net/avalanche_cpmac/cpswhal_cpmac.h 2005-07-12 02:48:42.050593000 +0200
7099 +/************************************************************************
7100 + * TNETDxxxx Software Support
7101 + * Copyright (c) 2002 Texas Instruments Incorporated. All Rights Reserved.
7106 + * User include file, contains data definitions shared between the CPHAL
7107 + * and the upper-layer software.
7110 + * Date Modifier Ver Notes
7111 + * 28Feb02 Greg 1.00 Original
7112 + * 06Mar02 Greg 1.01 Documentation enhanced
7113 + * 18Jul02 Greg 1.02 Many updates (OAM additions, general reorg)
7114 + * 22Nov02 Mick RC2 Additions from Denis' input on Control
7116 + * author Greg Guyotte
7118 + * date 18-Jul-2002
7119 + *****************************************************************************/
7120 +#ifndef _INC_CPHAL_H
7121 +#define _INC_CPHAL_H
7123 +#ifdef _CPHAL_CPMAC
7124 +#include "ec_errors_cpmac.h"
7128 +#include "ec_errors_cpaal5.h"
7131 +#ifdef _CPHAL_CPSAR
7132 +#include "ec_errors_cpsar.h"
7136 +#include "ec_errors_cpaal2.h"
7141 +typedef short bit16;
7144 +typedef unsigned char bit8u;
7145 +typedef unsigned short bit16u;
7146 +typedef unsigned int bit32u;
7150 +typedef short INT16;
7152 +typedef unsigned char UINT8;
7153 +typedef unsigned short UINT16;
7154 +typedef unsigned int UINT32;
7156 +/*typedef unsigned int size_t;*/
7162 +#define TRUE (1==1)
7166 +#define FALSE (1==2)
7175 +#define VirtToPhys(a) (((int)a)&~0xe0000000)
7176 +#define VirtToVirtNoCache(a) ((void*)((VirtToPhys(a))|0xa0000000))
7177 +#define VirtToVirtCache(a) ((void*)((VirtToPhys(a))|0x80000000))
7178 +#define PhysToVirtNoCache(a) ((void*)(((int)a)|0xa0000000))
7179 +#define PhysToVirtCache(a) ((void*)(((int)a)|0x80000000))
7181 +#define DataCacheHitInvalidate(a) {__asm__(" cache 17, (%0)" : : "r" (a));}
7182 +#define DataCacheHitWriteback(a) {__asm__(" cache 25, (%0)" : : "r" (a));}
7185 +#define PARTIAL 1 /**< Used in @c Close() and @c ChannelTeardown() */
7186 +#define FULL 2 /**< Used in @c Close() and @c ChannelTeardown() */
7188 +/* Channel Teardown Defines */
7189 +#define RX_TEARDOWN 2
7190 +#define TX_TEARDOWN 1
7191 +#define BLOCKING_TEARDOWN 8
7192 +#define FULL_TEARDOWN 4
7193 +#define PARTIAL_TEARDOWN 0
7196 +#define DIRECTION_TX 0
7197 +#define DIRECTION_RX 1
7200 +#define HAL_ERROR_DEVICE_NOT_FOUND 1
7201 +#define HAL_ERROR_FAILED_MALLOC 2
7202 +#define HAL_ERROR_OSFUNC_SIZE 3
7203 +#define HAL_DEFAULT 0xFFFFFFFF
7204 +#define VALID(val) (val!=HAL_DEFAULT)
7209 +HAL Module Codes. Each HAL module reporting an error code
7210 +should OR the error code with the respective Module error code
7211 +from the list below.
7213 +#define EC_AAL5 EC_HAL|EC_DEV_AAL5
7214 +#define EC_AAL2 EC_HAL|EC_DEV_AAL2
7215 +#define EC_CPSAR EC_HAL|EC_DEV_CPSAR
7216 +#define EC_CPMAC EC_HAL|EC_DEV_CPMAC
7217 +#define EC_VDMA EC_HAL|EC_DEV_VDMA
7218 +#define EC_VLYNQ EC_HAL|EC_DEV_VLYNQ
7219 +#define EC_CPPI EC_HAL|EC_DEV_CPPI
7222 +HAL Function Codes. Each HAL module reporting an error code
7223 +should OR the error code with one of the function codes from
7226 +#define EC_FUNC_HAL_INIT EC_FUNC(1)
7227 +#define EC_FUNC_CHSETUP EC_FUNC(2)
7228 +#define EC_FUNC_CHTEARDOWN EC_FUNC(3)
7229 +#define EC_FUNC_RXRETURN EC_FUNC(4)
7230 +#define EC_FUNC_SEND EC_FUNC(5)
7231 +#define EC_FUNC_RXINT EC_FUNC(6)
7232 +#define EC_FUNC_TXINT EC_FUNC(7)
7233 +#define EC_FUNC_AAL2_VDMA EC_FUNC(8)
7234 +#define EC_FUNC_OPTIONS EC_FUNC(9)
7235 +#define EC_FUNC_PROBE EC_FUNC(10)
7236 +#define EC_FUNC_OPEN EC_FUNC(11)
7237 +#define EC_FUNC_CONTROL EC_FUNC(12)
7238 +#define EC_FUNC_DEVICE_INT EC_FUNC(13)
7239 +#define EC_FUNC_STATUS EC_FUNC(14)
7240 +#define EC_FUNC_TICK EC_FUNC(15)
7241 +#define EC_FUNC_CLOSE EC_FUNC(16)
7242 +#define EC_FUNC_SHUTDOWN EC_FUNC(17)
7243 +#define EC_FUNC_DEVICE_INT_ALT EC_FUNC(18) /* +GSG 030306 */
7246 +HAL Error Codes. The list below defines every type of error
7247 +used in all HAL modules. DO NOT CHANGE THESE VALUES! Add new
7248 +values in integer order to the bottom of the list.
7250 +#define EC_VAL_PDSP_LOAD_FAIL EC_ERR(0x01)|EC_CRITICAL
7251 +#define EC_VAL_FIRMWARE_TOO_LARGE EC_ERR(0x02)|EC_CRITICAL
7252 +#define EC_VAL_DEVICE_NOT_FOUND EC_ERR(0x03)|EC_CRITICAL
7253 +#define EC_VAL_BASE_ADDR_NOT_FOUND EC_ERR(0x04)|EC_CRITICAL
7254 +#define EC_VAL_RESET_BIT_NOT_FOUND EC_ERR(0x05)|EC_CRITICAL
7255 +#define EC_VAL_CH_INFO_NOT_FOUND EC_ERR(0x06)
7256 +#define EC_VAL_RX_STATE_RAM_NOT_CLEARED EC_ERR(0x07)|EC_CRITICAL
7257 +#define EC_VAL_TX_STATE_RAM_NOT_CLEARED EC_ERR(0x08)|EC_CRITICAL
7258 +#define EC_VAL_MALLOC_DEV_FAILED EC_ERR(0x09)
7259 +#define EC_VAL_OS_VERSION_NOT_SUPPORTED EC_ERR(0x0A)|EC_CRITICAL
7260 +#define EC_VAL_CPSAR_VERSION_NOT_SUPPORTED EC_ERR(0x0B)|EC_CRITICAL
7261 +#define EC_VAL_NULL_CPSAR_DEV EC_ERR(0x0C)|EC_CRITICAL
7263 +#define EC_VAL_LUT_NOT_READY EC_ERR(0x0D)
7264 +#define EC_VAL_INVALID_CH EC_ERR(0x0E)
7265 +#define EC_VAL_NULL_CH_STRUCT EC_ERR(0x0F)
7266 +#define EC_VAL_RX_TEARDOWN_ALREADY_PEND EC_ERR(0x10)
7267 +#define EC_VAL_TX_TEARDOWN_ALREADY_PEND EC_ERR(0x11)
7268 +#define EC_VAL_RX_CH_ALREADY_TORNDOWN EC_ERR(0x12)
7269 +#define EC_VAL_TX_CH_ALREADY_TORNDOWN EC_ERR(0x13)
7270 +#define EC_VAL_TX_TEARDOWN_TIMEOUT EC_ERR(0x14)
7271 +#define EC_VAL_RX_TEARDOWN_TIMEOUT EC_ERR(0x15)
7272 +#define EC_VAL_CH_ALREADY_TORNDOWN EC_ERR(0x16)
7273 +#define EC_VAL_VC_SETUP_NOT_READY EC_ERR(0x17)
7274 +#define EC_VAL_VC_TEARDOWN_NOT_READY EC_ERR(0x18)
7275 +#define EC_VAL_INVALID_VC EC_ERR(0x19)
7276 +#define EC_VAL_INVALID_LC EC_ERR(0x20)
7277 +#define EC_VAL_INVALID_VDMA_CH EC_ERR(0x21)
7278 +#define EC_VAL_INVALID_CID EC_ERR(0x22)
7279 +#define EC_VAL_INVALID_UUI EC_ERR(0x23)
7280 +#define EC_VAL_INVALID_UUI_DISCARD EC_ERR(0x24)
7281 +#define EC_VAL_CH_ALREADY_OPEN EC_ERR(0x25)
7283 +#define EC_VAL_RCB_MALLOC_FAILED EC_ERR(0x26)
7284 +#define EC_VAL_RX_BUFFER_MALLOC_FAILED EC_ERR(0x27)
7285 +#define EC_VAL_OUT_OF_TCBS EC_ERR(0x28)
7286 +#define EC_VAL_NO_TCBS EC_ERR(0x29)
7287 +#define EC_VAL_NULL_RCB EC_ERR(0x30)|EC_CRITICAL
7288 +#define EC_VAL_SOP_ERROR EC_ERR(0x31)|EC_CRITICAL
7289 +#define EC_VAL_EOP_ERROR EC_ERR(0x32)|EC_CRITICAL
7290 +#define EC_VAL_NULL_TCB EC_ERR(0x33)|EC_CRITICAL
7291 +#define EC_VAL_CORRUPT_RCB_CHAIN EC_ERR(0x34)|EC_CRITICAL
7292 +#define EC_VAL_TCB_MALLOC_FAILED EC_ERR(0x35)
7294 +#define EC_VAL_DISABLE_POLLING_FAILED EC_ERR(0x36)
7295 +#define EC_VAL_KEY_NOT_FOUND EC_ERR(0x37)
7296 +#define EC_VAL_MALLOC_FAILED EC_ERR(0x38)
7297 +#define EC_VAL_RESET_BASE_NOT_FOUND EC_ERR(0x39)|EC_CRITICAL
7298 +#define EC_VAL_INVALID_STATE EC_ERR(0x40)
7299 +#define EC_VAL_NO_TXH_WORK_TO_DO EC_ERR(0x41)
7300 +#define EC_VAL_NO_TXL_WORK_TO_DO EC_ERR(0x42)
7301 +#define EC_VAL_NO_RX_WORK_TO_DO EC_ERR(0x43)
7302 +#define EC_VAL_NOT_LINKED EC_ERR(0x44)
7303 +#define EC_VAL_INTERRUPT_NOT_FOUND EC_ERR(0x45)
7304 +#define EC_VAL_OFFSET_NOT_FOUND EC_ERR(0x46)
7305 +#define EC_VAL_MODULE_ALREADY_CLOSED EC_ERR(0x47)
7306 +#define EC_VAL_MODULE_ALREADY_SHUTDOWN EC_ERR(0x48)
7307 +#define EC_VAL_ACTION_NOT_FOUND EC_ERR(0x49)
7308 +#define EC_VAL_RX_CH_ALREADY_SETUP EC_ERR(0x50)
7309 +#define EC_VAL_TX_CH_ALREADY_SETUP EC_ERR(0x51)
7310 +#define EC_VAL_RX_CH_ALREADY_OPEN EC_ERR(0x52)
7311 +#define EC_VAL_TX_CH_ALREADY_OPEN EC_ERR(0x53)
7312 +#define EC_VAL_CH_ALREADY_SETUP EC_ERR(0x54)
7313 +#define EC_VAL_RCB_NEEDS_BUFFER EC_ERR(0x55) /* +GSG 030410 */
7314 +#define EC_VAL_RCB_DROPPED EC_ERR(0x56) /* +GSG 030410 */
7315 +#define EC_VAL_INVALID_VALUE EC_ERR(0x57)
7318 +@defgroup shared_data Shared Data Structures
7320 +The data structures documented here are shared by all modules.
7324 + * @ingroup shared_data
7325 + * This is the fragment list structure. Each fragment list entry contains a
7326 + * length and a data buffer.
7330 + bit32u len; /**< Length of the fragment in bytes (lower 16 bits are valid). For SOP, upper 16 bits is the buffer offset. */
7331 + void *data; /**< Pointer to fragment data. */
7332 + void *OsInfo; /**< Pointer to OS defined data. */
7335 +#if defined (_CPHAL_CPMAC)
7336 +#define CB_PASSCRC_BIT (1<<26)
7338 +/* CPMAC CPHAL STATUS */
7339 +#define CPMAC_STATUS_LINK (1 << 0)
7340 +#define CPMAC_STATUS_LINK_DUPLEX (1 << 1) /* 0 - HD, 1 - FD */
7341 +#define CPMAC_STATUS_LINK_SPEED (1 << 2) /* 0 - 10, 1 - 100 */
7343 +/* ADAPTER CHECK Codes */
7345 +#define CPMAC_STATUS_ADAPTER_CHECK (1 << 7)
7346 +#define CPMAC_STATUS_HOST_ERR_DIRECTION (1 << 8)
7347 +#define CPMAC_STATUS_HOST_ERR_CODE (0xF << 9)
7348 +#define CPMAC_STATUS_HOST_ERR_CH (0x7 << 13)
7350 +#define _CPMDIO_DISABLE (1 << 0)
7351 +#define _CPMDIO_HD (1 << 1)
7352 +#define _CPMDIO_FD (1 << 2)
7353 +#define _CPMDIO_10 (1 << 3)
7354 +#define _CPMDIO_100 (1 << 4)
7355 +#define _CPMDIO_NEG_OFF (1 << 5)
7356 +#define _CPMDIO_LOOPBK (1 << 16)
7357 +#define _CPMDIO_AUTOMDIX (1 << 17) /* Bit 16 and above not used by MII register */
7358 +#define _CPMDIO_NOPHY (1 << 20)
7362 + * @ingroup shared_data
7363 + * Channel specific configuration information. This structure should be
7364 + * populated by upper-layer software prior to calling @c ChannelSetup(). Any
7365 + * configuration item that can be changed on a per channel basis should
7366 + * be represented here. Each module may define this structure with additional
7367 + * module-specific members.
7371 + int Channel; /**< Channel number. */
7372 + int Direction; /**< DIRECTION_RX(1) or DIRECTION_TX(0). */
7373 + OS_SETUP *OsSetup; /**< OS defined information associated with this channel. */
7375 +#if defined(_CPHAL_AAL5) || defined (_CPHAL_CPSAR) || defined (_CPHAL_CPMAC)
7376 + int RxBufSize; /**< Size (in bytes) for each Rx buffer.*/
7377 + int RxBufferOffset; /**< Number of bytes to offset rx data from start of buffer (must be less than buffer size). */
7378 + int RxNumBuffers; /**< The number of Rx buffer descriptors to allocate for Ch. */
7379 + int RxServiceMax; /**< Maximum number of packets to service at one time. */
7381 + int TxNumBuffers; /**< The number of Tx buffer descriptors to allocate for Ch. */
7382 + int TxNumQueues; /**< Number of Tx queues for this channel (1-2). Choosing 2 enables a low priority SAR queue. */
7383 + int TxServiceMax; /**< Maximum number of packets to service at one time. */
7386 +#if defined(_CPHAL_AAL5) || defined(_CPHAL_CPSAR)
7387 + int CpcsUU; /**< The 2-byte CPCS UU and CPI information. */
7388 + int Gfc; /**< Generic Flow Control. */
7389 + int Clp; /**< Cell Loss Priority. */
7390 + int Pti; /**< Payload Type Indication. */
7393 +#if defined(_CPHAL_AAL2) || defined(_CPHAL_AAL5) || defined(_CPHAL_CPSAR)
7394 + int DaMask; /**< Specifies whether credit issuance is paused when Tx data not available. */
7395 + int Priority; /**< Priority bin this channel will be scheduled within. */
7396 + int PktType; /**< 0=AAL5,1=Null AAL,2=OAM,3=Transparent,4=AAL2. */
7397 + int Vci; /**< Virtual Channel Identifier. */
7398 + int Vpi; /**< Virtual Path Identifier. */
7399 + int FwdUnkVc; /**< Enables forwarding of unknown VCI/VPI cells to host. 1=enable, 0=disable. */
7402 + int TxVc_CellRate; /**< Tx rate, set as clock ticks between transmissions (SCR for VBR, CBR for CBR). */
7403 + int TxVc_QosType; /**< 0=CBR,1=VBR,2=UBR,3=UBRmcr. */
7404 + int TxVc_Mbs; /**< Min Burst Size in cells.*/
7405 + int TxVc_Pcr; /**< Peak Cell Rate for VBR in clock ticks between transmissions. */
7407 + bit32 TxVc_AtmHeader; /**< ATM Header placed on firmware gen'd OAM cells for this Tx Ch (must be big endian with 0 PTI). */
7408 + int TxVc_OamTc; /**< TC Path to transmit OAM cells for TX connection (0,1). */
7409 + int TxVc_VpOffset; /**< Offset to the OAM VP state table. */
7411 + int RxVc_OamCh; /**< Ch to terminate rx'd OAM cells to be forwarded to the host. */
7412 + int RxVc_OamToHost; /**< 0=do not pass, 1=pass. */
7413 + bit32 RxVc_AtmHeader; /**< ATM Header placed on firmware gen'd OAM cells for this Rx conn (must be big endian with 0 PTI). */
7414 + int RxVc_OamTc; /**< TC Path to transmit OAM cells for RX connection (0,1). */
7415 + int RxVc_VpOffset; /**< Offset to the OAM VP state table. */
7417 + int TxVp_OamTc; /**< TC Path to transmit OAM cells for TX VP connection (0,1). */
7418 + bit32 TxVp_AtmHeader; /**< ATM Header placed on firmware gen'd VP OAM cells for this Tx VP conn (must be big endian with 0 VCI). */
7420 + int RxVp_OamCh; /**< Ch to terminate rx'd OAM cells to be forwarded to the host. */
7421 + int RxVp_OamToHost; /**< 0=do not pass, 1=pass. */
7422 + bit32 RxVp_AtmHeader; /**< ATM Header placed on firmware gen'd OAM cells for this Rx VP conn (must be big endian with 0 VCI). */
7423 + int RxVp_OamTc; /**< TC Path to transmit OAM cells for RX VP connection (0,1). */
7424 + int RxVp_OamVcList; /**< Indicates all VC channels associated with this VP channel (one-hot encoded). */
7428 +#ifdef _CPHAL_VDMAVT
7429 + bit32u RemFifoAddr; /* Mirror mode only. */
7439 + * This structure contains each statistic value gathered by the CPHAL.
7440 + * Applications may access statistics data by using the @c StatsGet() routine.
7443 +#if defined(_CPHAL_AAL2) || defined(_CPHAL_AAL5) || defined(_CPHAL_CPSAR)
7446 + bit32u CrcErrors[16];
7447 + bit32u LenErrors[16];
7448 + bit32u DmaLenErrors[16];
7449 + bit32u AbortErrors[16];
7450 + bit32u StarvErrors[16];
7451 + bit32u TxMisQCnt[16][2];
7452 + bit32u RxMisQCnt[16];
7453 + bit32u RxEOQCnt[16];
7454 + bit32u TxEOQCnt[16][2];
7455 + bit32u RxPacketsServiced[16];
7456 + bit32u TxPacketsServiced[16][2];
7457 + bit32u RxMaxServiced;
7458 + bit32u TxMaxServiced[16][2];
7465 + * VDMA Channel specific configuration information
7470 + int Ch; /**< Channel Number */
7471 + int RemoteEndian; /**< Endianness of remote VDMA-VT device */
7472 + int CpsSwap; /**< When 0, octet 0 in CPS pkt located in LS byte of 16-bit word sent to rem VDMA device. When 1, in MS byte. */
7477 + typedef void HAL_DEVICE;
7478 + typedef void HAL_PRIVATE;
7479 + typedef void HAL_RCB;
7480 + typedef void HAL_RECEIVEINFO;
7484 + * @ingroup shared_data
7485 + * The HAL_FUNCTIONS struct defines the function pointers used by upper layer
7486 + * software. The upper layer software receives these pointers through the
7487 + * call to xxxInitModule().
7491 + int (*ChannelSetup) (HAL_DEVICE *HalDev, CHANNEL_INFO *Channel, OS_SETUP *OsSetup);
7492 + int (*ChannelTeardown) (HAL_DEVICE *HalDev, int Channel, int Mode);
7493 + int (*Close) (HAL_DEVICE *HalDev, int Mode);
7494 + int (*Control) (HAL_DEVICE *HalDev, const char *Key, const char *Action, void *Value);
7495 + int (*Init) (HAL_DEVICE *HalDev);
7496 + int (*Open) (HAL_DEVICE *HalDev);
7497 + int (*PacketProcessEnd) (HAL_DEVICE *HalDev);
7498 + int (*Probe) (HAL_DEVICE *HalDev);
7499 + int (*RxReturn) (HAL_RECEIVEINFO *HalReceiveInfo, int StripFlag);
7500 + int (*Send) (HAL_DEVICE *HalDev, FRAGLIST *FragList, int FragCount, int PacketSize, OS_SENDINFO *OsSendInfo, bit32u Mode);
7501 + int (*Shutdown) (HAL_DEVICE *HalDev);
7502 + int (*Tick) (HAL_DEVICE *HalDev);
7505 + int (*Kick) (HAL_DEVICE *HalDev, int Queue);
7506 + void (*OamFuncConfig) (HAL_DEVICE *HalDev, unsigned int OamConfig);
7507 + void (*OamLoopbackConfig) (HAL_DEVICE *HalDev, unsigned int OamConfig, unsigned int *LLID, unsigned int CorrelationTag);
7508 + volatile bit32u* (*RegAccess)(HAL_DEVICE *HalDev, bit32u RegOffset);
7509 + STAT_INFO* (*StatsGetOld)(HAL_DEVICE *HalDev);
7514 + * @ingroup shared_data
7515 + * The OS_FUNCTIONS struct defines the function pointers for all upper layer
7516 + * functions accessible to the CPHAL. The upper layer software is responsible
7517 + * for providing the correct OS-specific implementations for the following
7518 + * functions. It is populated by calling InitModule() (done by the CPHAL in
7519 + * xxxInitModule().
7523 + int (*Control)(OS_DEVICE *OsDev, const char *Key, const char *Action, void *Value);
7524 + void (*CriticalOn)(void);
7525 + void (*CriticalOff)(void);
7526 + void (*DataCacheHitInvalidate)(void *MemPtr, int Size);
7527 + void (*DataCacheHitWriteback)(void *MemPtr, int Size);
7528 + int (*DeviceFindInfo)(int Inst, const char *DeviceName, void *DeviceInfo);
7529 + int (*DeviceFindParmUint)(void *DeviceInfo, const char *Parm, bit32u *Value);
7530 + int (*DeviceFindParmValue)(void *DeviceInfo, const char *Parm, void *Value);
7531 + void (*Free)(void *MemPtr);
7532 + void (*FreeRxBuffer)(OS_RECEIVEINFO *OsReceiveInfo, void *MemPtr);
7533 + void (*FreeDev)(void *MemPtr);
7534 + void (*FreeDmaXfer)(void *MemPtr);
7535 + void (*IsrRegister)(OS_DEVICE *OsDev, int (*halISR)(HAL_DEVICE*, int*), int InterruptBit);
7536 + void (*IsrUnRegister)(OS_DEVICE *OsDev, int InterruptBit);
7537 + void* (*Malloc)(bit32u size);
7538 + void* (*MallocDev)(bit32u Size);
7539 + void* (*MallocDmaXfer)(bit32u size, void *MemBase, bit32u MemRange);
7540 + void* (*MallocRxBuffer)(bit32u size, void *MemBase, bit32u MemRange,
7541 + OS_SETUP *OsSetup, HAL_RECEIVEINFO *HalReceiveInfo,
7542 + OS_RECEIVEINFO **OsReceiveInfo, OS_DEVICE *OsDev);
7543 + void* (*Memset)(void *Dest, int C, bit32u N);
7544 + int (*Printf)(const char *Format, ...);
7545 + int (*Receive)(OS_DEVICE *OsDev,FRAGLIST *FragList,bit32u FragCount,
7546 + bit32u PacketSize,HAL_RECEIVEINFO *HalReceiveInfo, bit32u Mode);
7547 + int (*SendComplete)(OS_SENDINFO *OsSendInfo);
7548 + int (*Sprintf)(char *S, const char *Format, ...);
7549 + int (*Strcmpi)(const char *Str1, const char *Str2);
7550 + unsigned int (*Strlen)(const char *S);
7551 + char* (*Strstr)(const char *S1, const char *S2);
7552 + unsigned long (*Strtoul)(const char *Str, char **Endptr, int Base);
7553 + void (*TeardownComplete)(OS_DEVICE *OsDev, int Ch, int Direction);
7556 +/************** MODULE SPECIFIC STUFF BELOW **************/
7558 +#ifdef _CPHAL_CPMAC
7561 +int halCpmacInitModule(HAL_DEVICE **HalDev, OS_DEVICE *OsDev, HAL_FUNCTIONS *HalFunc, int (*osBridgeInitModule)(OS_FUNCTIONS *), void* (*osMallocDev) (bit32u), int *Size, int inst);
7564 +int halCpmacInitModule(HAL_DEVICE **HalDev,
7566 + HAL_FUNCTIONS **HalFunc,
7567 + OS_FUNCTIONS *OsFunc,
7575 + * @ingroup shared_data
7576 + * The AAL5_FUNCTIONS struct defines the AAL5 function pointers used by upper layer
7577 + * software. The upper layer software receives these pointers through the
7578 + * call to cphalInitModule().
7583 + int (*ChannelSetup)(HAL_DEVICE *HalDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup);
7584 + int (*ChannelTeardown)(HAL_DEVICE *HalDev, int Ch, int Mode);
7585 + int (*Close)(HAL_DEVICE *HalDev, int Mode);
7586 + int (*Init)(HAL_DEVICE *HalDev);
7587 + int (*ModeChange)(HAL_DEVICE *HalDev, char *DeviceParms);
7588 + int (*Open)(HAL_DEVICE *HalDev);
7589 + int (*InfoGet)(HAL_DEVICE *HalDev, int Key, void *Value);
7590 + int (*Probe)(HAL_DEVICE *HalDev);
7591 + int (*RxReturn)(HAL_RECEIVEINFO *HalReceiveInfo, int StripFlag);
7592 + int (*Send)(HAL_DEVICE *HalDev,FRAGLIST *FragList,int FragCount,
7593 + int PacketSize,OS_SENDINFO *OsSendInfo,int Ch, int Queue,
7595 + int (*StatsClear)(HAL_DEVICE *HalDev);
7596 + STAT_INFO* (*StatsGet)(HAL_DEVICE *HalDev);
7597 + int (*Status)(HAL_DEVICE *HalDev);
7598 + void (*Tick)(HAL_DEVICE *HalDev);
7599 + int (*Kick)(HAL_DEVICE *HalDev, int Queue);
7600 + volatile bit32u* (*RegAccess)(HAL_DEVICE *HalDev, bit32u RegOffset);
7604 +int cpaal5InitModule(HAL_DEVICE **HalDev,
7606 + HAL_FUNCTIONS **HalFunc,
7607 + OS_FUNCTIONS *OsFunc,
7615 + * @ingroup shared_data
7616 + * The AAL2_FUNCTIONS struct defines the AAL2 function pointers used by upper layer
7617 + * software. The upper layer software receives these pointers through the
7618 + * call to cphalInitModule().
7622 + int (*ChannelSetup)(HAL_DEVICE *HalDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup);
7623 + int (*ChannelTeardown)(HAL_DEVICE *HalDev, int Ch, int Mode);
7624 + int (*Close)(HAL_DEVICE *HalDev, int Mode);
7625 + int (*Init)(HAL_DEVICE *HalDev);
7626 + int (*ModeChange)(HAL_DEVICE *HalDev, char *DeviceParms);
7627 + int (*Open)(HAL_DEVICE *HalDev);
7628 + int (*OptionsGet)(HAL_DEVICE *HalDev, char *Key, bit32u *Value);
7629 + int (*Probe)(HAL_DEVICE *HalDev);
7631 + int (*StatsClear)(HAL_DEVICE *HalDev);
7632 + STAT_INFO* (*StatsGet)(HAL_DEVICE *HalDev);
7633 + int (*Status)(HAL_DEVICE *HalDev);
7634 + void (*Tick)(HAL_DEVICE *HalDev);
7635 + int (*Aal2UuiMappingSetup)(HAL_DEVICE *HalDev, int VC, int UUI,
7636 + int VdmaCh, int UUIDiscard);
7637 + int (*Aal2RxMappingSetup)(HAL_DEVICE *HalDev, int VC, int CID,
7639 + int (*Aal2TxMappingSetup)(HAL_DEVICE *HalDev, int VC, int LC, int VdmaCh);
7640 + int (*Aal2VdmaChSetup)(HAL_DEVICE *HalDev, bit32u RemVdmaVtAddr,
7641 + VdmaChInfo *VdmaCh);
7642 + volatile bit32u* (*RegAccess)(HAL_DEVICE *HalDev, bit32u RegOffset);
7643 + int (*Aal2ModeChange)(HAL_DEVICE *HalDev, int Vc, int RxCrossMode,
7644 + int RxMultiMode, int TxMultiMode, int SchedMode,
7646 + void (*Aal2VdmaEnable)(HAL_DEVICE *HalDev, int Ch);
7647 + int (*Aal2VdmaDisable)(HAL_DEVICE *HalDev, int Ch);
7650 +int cpaal2InitModule(HAL_DEVICE **HalDev,
7652 + AAL2_FUNCTIONS **HalFunc,
7653 + OS_FUNCTIONS *OsFunc,
7659 +#ifdef _CPHAL_VDMAVT
7661 + * @ingroup shared_data
7662 + * The VDMA_FUNCTIONS struct defines the HAL function pointers used by upper layer
7663 + * software. The upper layer software receives these pointers through the
7664 + * call to InitModule().
7666 + * Note that this list is still under definition.
7670 + bit32 (*Init)( HAL_DEVICE *VdmaVtDev);
7671 + /* bit32 (*SetupTxFifo)(HAL_DEVICE *VdmaVtDev, bit32u LclRem,
7672 + bit32u Addr, bit32u Size, bit32u PollInt);
7673 + bit32 (*SetupRxFifo)(HAL_DEVICE *VdmaVtDev, bit32u LclRem,
7674 + bit32u Addr, bit32u Size, bit32u PollInt); */
7675 + bit32 (*Tx)(HAL_DEVICE *VdmaVtDev);
7676 + bit32 (*Rx)(HAL_DEVICE *VdmaVtDev);
7677 + bit32 (*SetRemoteChannel)(HAL_DEVICE *VdmaVtDev, bit32u RemAddr,
7679 + bit32 (*ClearRxInt)(HAL_DEVICE *VdmaVtDev);
7680 + bit32 (*ClearTxInt)(HAL_DEVICE *VdmaVtDev);
7681 + bit32 (*Open)(HAL_DEVICE *VdmaVtDev);
7682 + bit32 (*Close)(HAL_DEVICE *VdmaVtDev);
7683 + int (*Control) (HAL_DEVICE *HalDev, const char *Key, const char *Action, void *Value);
7684 + int (*ChannelSetup)(HAL_DEVICE *VdmaVtDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup);
7685 + int (*ChannelTeardown)(HAL_DEVICE *VdmaVtDev, int Ch, int Mode);
7686 + int (*Send)(HAL_DEVICE *VdmaVtDev,FRAGLIST *FragList,int FragCount,
7687 + int PacketSize,OS_SENDINFO *OsSendInfo,bit32u Mode);
7690 +int VdmaInitModule(HAL_DEVICE **VdmaVt,
7692 + VDMA_FUNCTIONS **VdmaVtFunc,
7693 + OS_FUNCTIONS *OsFunc,
7700 +extern int cphalInitModule(MODULE_TYPE ModuleType, HAL_DEVICE **HalDev, OS_DEVICE *OsDev, HAL_FUNCTIONS *HalFunc,
7701 + int (*osInitModule)(OS_FUNCTIONS *), void* (*osMallocDev)(bit32u),
7702 + int *Size, int Inst);
7707 +extern const char hcSarFrequency[];
7710 +#ifdef _CPHAL_CPMAC
7711 +/* following will be common, once 'utl' added */
7712 +extern const char hcClear[];
7713 +extern const char hcGet[];
7714 +extern const char hcSet[];
7715 +extern const char hcTick[];
7717 +extern const char hcCpuFrequency[];
7718 +extern const char hcCpmacFrequency[];
7719 +extern const char hcMdioBusFrequency[];
7720 +extern const char hcMdioClockFrequency[];
7721 +extern const char hcCpmacBase[];
7722 +extern const char hcPhyNum[];
7723 +extern const char hcSize[];
7724 +extern const char hcCpmacSize[];
7725 +extern const char hcPhyAccess[];
7726 +extern const char hcMdixMask[];
7727 +extern const char hcMdioMdixSwitch[];
7730 +#endif /* end of _INC_ */
7731 diff -urN linux.old/drivers/net/avalanche_cpmac/dox_cpmac.h linux.dev/drivers/net/avalanche_cpmac/dox_cpmac.h
7732 --- linux.old/drivers/net/avalanche_cpmac/dox_cpmac.h 1970-01-01 01:00:00.000000000 +0100
7733 +++ linux.dev/drivers/net/avalanche_cpmac/dox_cpmac.h 2005-07-12 02:48:42.050593000 +0200
7735 +/*****************************************************************************
7736 + * TNETDxxxx Software Support
7737 + * Copyright (c) 2002,2003 Texas Instruments Incorporated. All Rights Reserved.
7742 + * This file contains documentation for the CPMAC
7745 + * @author Michael Hanrahan/Greg Guyotte
7747 + * @date 03-Dec-2002
7748 + *****************************************************************************/
7749 +#ifndef _DOX_CPMAC_H
7750 +#define _DOX_CPMAC_H
7752 +@page CPMAC_Implementation_Details Version
7754 +@copydoc CPMAC_Version
7758 +@page cpmac_intro Introduction
7760 +The CPMAC implementation will support 8 channels for transmit and 8 channel for
7761 +receive. Each of the 8 transmit channels has 1 queue associated with it. It is
7762 +recommended that only 1 channel is used for @c Receive() per processor.
7766 +@page cpmac_details API Implementation Details
7769 +- The Upper 16 bits of Mode match Word 3 of the Rx Buffer Descriptor
7773 +- Bits 0-7 contain the Channel Number
7774 +- Bits 8-25 are reserved
7775 +- Bit 26 - if 0, the CRC will be calculated, if 1 the CRC will be Passed
7776 +- Bits 27-31 : reserved
7777 +@section cpmac_keys Control Keys
7780 +CPHAL calls the OS when a state change is detected.
7781 +OS should check the CPMAC Status. See the Control Key 'Status' for more details.
7784 +OS calls the CPHAL to obtain Status information. The Returned status is as follows
7787 +The OS may "Set" or "Get" this value. This defines the maximum
7788 +number of fragments that can be received by the CPMAC Rx port. The default
7789 +value for CPMAC is 2. This provides enough space to receive a maximum
7790 +length packet (1,518 bytes) with the default buffer size of 1518 and any
7791 +amount of RxBufferOffset. If the buffer size is configured to be smaller,
7792 +the OS *MUST* modify this parameter according to the following formula:
7793 +((System Max packet length)/(RxBufSize)) + 1. (The extra 1 fragment is to
7794 +allow for RxBufferOffset)
7797 +// Following defined in "cpswhal_cpmac.h"
7798 +// CPMAC CPHAL STATUS
7799 +#define CPMAC_STATUS_LINK (1 << 0)
7800 +#define CPMAC_STATUS_LINK_DUPLEX (1 << 1) // 0 - HD, 1 - FD
7801 +#define CPMAC_STATUS_LINK_SPEED (1 << 2) // 0 - 10, 1 - 100
7803 +// ADAPTER CHECK Codes
7804 +#define CPMAC_STATUS_ADAPTER_CHECK (1 << 7)
7805 +#define CPMAC_STATUS_HOST_ERR_DIRECTION (1 << 8) // 0 - Tx, 1 - Rx
7806 +#define CPMAC_STATUS_HOST_ERR_CODE (0xF << 9) See CPMAC Guide
7807 +#define CPMAC_STATUS_HOST_ERR_CH (0x7 << 13) See CPMAC Guide
7811 +void osStateChange(OS_DEVICE *OsDev)
7814 + OsDev->HalFunc->Control(OsDev->HalDev, "Status", hcGet, &status);
7815 + if(status & CPMAC_STATUS_ADAPTER_CHECK)
7817 + printf("[osStateChange[%d]] HAL notified OS of AdapterCheck (Link Status 0x%08X)\n", OsDev->port, status);
7818 + adaptercheck(OsDev->port);
7822 + printf("[osStateChange[%d]] HAL notified OS of State Change (Link Status %s)\n", OsDev->port, (status & CPMAC_STATUS_LINK) ? "Up" : "Down");
7823 + if(status & CPMAC_STATUS_LINK)
7825 + printf("Speed %s, Duplex %s\n",
7826 + status & CPMAC_STATUS_LINK_SPEED ? "100" : "10",
7827 + status & CPMAC_STATUS_LINK_DUPLEX ? "FD" : "HD");
7833 + The CPHAL calls the OS to set the interval for calling halTick()<BR>
7834 + Note: Predefined value hcTick now recommended for use.
7836 +*** Example Code ***
7840 +HalDev->OsFunc->Control(HalDev->OsDev, hcTick, hcSet, &Ticks);
7844 + if(osStrcmpi(pszKey, hcTick) == 0)
7846 + if(osStrcmpi(pszAction, hcSet) == 0)
7848 + // Enable the Tick Interval
7849 + if(*(unsigned int *) ParmValue)
7850 + printf("osTickSet: Interval = %d ticks\n", Interval);
7853 + if(osStrcmpi(pszAction, hcClear) == 0)
7855 + // Request disabling of the Tick Timer, ParmValue is ignored
7860 +@par The following information can be obtained by the OS via 'Get'
7862 +- StatsDump : OS supplies pointer to an 36 element unsigned int array
7863 +CPHAL will populate the array with the current Statistics values.<BR>
7864 +Note: all hcXXXX values are predefined and should be used by the OS.
7866 +- hcPhyNum : Returns the PHY number.
7867 +- hcCpmacBase : Returns the base-address of the CPMAC device
7868 +- hcCpmacSize : Returns size of the CPMAC memory map
7871 +@par Phy Register Communication
7873 +halControl() is used to read and write the Phy Registers via the key hcPhyAccess
7875 +Both reading and writing the Phy registers involve setting the Value parameter of halControl()
7877 +Value is a 32-bit value with bits partioned as follows
7880 + 0 - 4 Phy Number <BR>
7881 + 5 - 9 Phy Register <BR>
7882 + 10 - 15 reserved <BR>
7883 + 16 - 31 Data (write only)
7887 +<B>Reading the Phy register</B>
7893 + bit32u PhyRegisterData;
7895 + // Read Phy 31, register 20
7900 + Value = (RegAddr << 5);
7901 + Value |= (PhyNum & 0x1F);
7903 + rc = HalFunc->Control(HalDev, hcPhyAccess, hcGet, (bit32u *) &Value)
7906 + // Value is overwriten with the value in Register 20 of Phy number 31.
7907 + PhyRegisterData = Value;
7911 +<B>Writing the Phy register</B>
7916 + bit32u PhyRegisterData;
7922 + PhyRegisterData = 0x8000; // Reset bit set
7924 + Value = (RegAddr << 5);
7925 + Value |= (PhyNum & 0x1F);
7926 + Value |= (PhyRegisterData << 16);
7928 + rc = HalFunc->Control(HalDev, hcPhyAccess, hcSet, (bit32u *) &Value)
7930 + // Check is reset if done
7935 + Value = (RegAddr << 5);
7936 + Value |= (PhyNum & 0x1F);
7938 + rc = HalFunc->Control(HalDev, hcPhyAccess, hcGet, (bit32u *) &Value)
7942 + // Value is overwriten with the value in Register 0 of Phy number 23.
7943 + PhyRegisterData = Value;
7944 + if((PhyRegisterData & 0x8000) == 0)
7950 +*** Example Showing turning values off/on ***
7958 + # Turn On loopback
7959 + OsDev->HalFunc->Control(OsDev->HalDev, "CTRL_LOOPBACK", hcSet, (int*) &On);
7961 + # Turn off RX Flow
7962 + OsDev->HalFunc->Control(OsDev->HalDev, "RX_FLOW_EN", hcSet, (int*) &Off);
7965 +@par CPMAC Configurable Parameters
7967 +- RX_PASS_CRC : See MBP_Enable description
7968 +- RX_QOS_EN : See MBP_Enable description
7969 +- RX_NO_CHAIN : See MBP_Enable description
7970 +- RX_CMF_EN : See MBP_Enable description
7971 +- RX_CSF_EN : See MBP_Enable description
7972 +- RX_CEF_EN : See MBP_Enable description
7973 +- RX_CAF_EN : See MBP_Enable description
7974 +- RX_PROM_CH : See MBP_Enable description
7975 +- RX_BROAD_EN : See MBP_Enable description
7976 +- RX_BROAD_CH : See MBP_Enable description
7977 +- RX_MULT_EN : See MBP_Enable description
7978 +- RX_MULT_CH : See MBP_Enable description
7980 +- TX_PTYPE : See MacControl description
7981 +- TX_PACE : See MacControl description
7982 +- TX_FLOW_EN : See MacControl description
7983 +- RX_FLOW_EN : See MacControl description
7984 +- CTRL_LOOPBACK : See MacControl description
7986 +- RX_MAXLEN : See CPMAC Guide
7987 +- RX_FILTERLOWTHRESH : See CPMAC Guide
7988 +- RX0_FLOWTHRESH : See CPMAC Guide
7989 +- RX_UNICAST_SET : See CPMAC Guide
7990 +- RX_UNICAST_CLEAR : See CPMAC Guide
7992 +@par Multicast Support
7993 +- RX_MULTI_ALL : When used with hcSet, sets all the Hash Bits. When used
7994 +with hcClear clears all the Hash Bits.
7995 +- RX_MULTI_SINGLE : When used with hcSet, adds the Hashed Mac Address. When used
7996 +with hcClear deletes the Hashed Mac Address.
7997 +Note: Support will be added to keep track of Single additions and deletions.
8000 +*** Example Code ***
8003 + bit8u MacAddress[6];
8004 + MacAddress[0] = 0x80;
8005 + MacAddress[1] = 0x12;
8006 + MacAddress[2] = 0x34;
8007 + MacAddress[3] = 0x56;
8008 + MacAddress[4] = 0x78;
8009 + MacAddress[5] = 0x78;
8010 + OsDev->HalFunc->Control(OsDev->HalDev, "RX_MULTI_SINGLE", hcSet, (bit8u*) &MacAddress);
8011 + OsDev->HalFunc->Control(OsDev->HalDev, "RX_MULTI_SINGLE", hcClear, (bit8u*) &MacAddress);
8012 + OsDev->HalFunc->Control(OsDev->HalDev, "RX_MULTI_ALL", hcSet, NULL);
8013 + OsDev->HalFunc->Control(OsDev->HalDev, "RX_MULTI_ALL", hcClear, NULL);
8015 +@par MdioConnect Fields
8017 +- "MdioConnect" : The OS can set the Phy connection using this key. The default connection is Auto-Negotiation ON, All modes possible.
8020 +- _CPMDIO_HD <----- Allow Half Duplex, default is 1 (On)
8021 +- _CPMDIO_FD <----- Allow Full Duplex, default is 1 (On)
8022 +- _CPMDIO_10 <----- Allow 10 Mbs, default is 1 (On)
8023 +- _CPMDIO_100 <----- Allow 100 Mbs, default is 1 (On)
8024 +- _CPMDIO_NEG_OFF <----- Turn off Auto Negotiation, default is 0 (Auto Neg is on)
8025 +- _CPMDIO_NOPHY <----- Set for use with Marvel-type switch, default is 0 (Phy present)
8026 +- _CPMDIO_AUTOMDIX <---- Enables Auto Mdix (in conjunction with MdixMask), default is 1 (On)
8028 +Note: When _CPMDIO_NOPHY is set, CPMAC will report being linked at 100/FD. Reported PhyNum will be 0xFFFFFFFF
8030 +@par Setting CPMAC for use with a Marvel-type Switch
8032 + bit32u MdioConnect;
8034 + MdioConnect = _CPMDIO_NOPHY;
8035 + OsDev->HalFunc->Control(OsDev->HalDev, "MdioConnect", hcSet, (bit32u*) &MdioConnect);
8038 +@par OS Support for MDIO
8039 +@p The OS will need to supply the following values which the CPHAL will request via halControl()
8041 +- MdioBusFrequency : The frequency of the BUS that MDIO is on (requested via hcMdioBusFrequency)
8043 +- MdioClockFrequency : The desired Clock Frequency that MDIO qill operate at (requested via hcMdioClockFrequency)
8047 +@page cpmac_conf DeviceFindxxx() Parameters
8049 +These are some of the parameters that the CPMAC will request via the DeviceFindxxx() functions -
8051 +- "Mlink" : bit mask indicating what link status method Phy is using. Default is MDIO state machine (0x0)
8052 +- "PhyMask" : bit mask indicating PhyNums used by this CPMAC (e.g 0x8000000, PhyNum is 31)
8053 +- "MdixMask" : bit mask indicating which Phys support AutoMdix. Default is 0x0 (None)
8055 +@par Example cpmac definition from the options.conf for the Sangam VDB
8057 +- cpmac( id=eth0, base=0xA8610000, size=0x800, reset_bit=17, int_line=19, PhyMask=0x80000000, MLink=0, MdixMask=0 )
8061 +@page auto_mdix Auto Mdix Support
8063 +Auto Mdix selection is controlled by two elements in the CPMAC. First the OS can turn Auto Midx On or Off by the use of the
8064 +MdioConnect field, _CPMDIO_AUTOMDIX. This is defaulted ON. For actual Auto Mdix operation the Phy must also be Auto Mdix capable.
8065 +This is specified by the DeviceFindxxx() field, "MdixMask" (supplied as the variable hcMdixMask).
8066 +If both these fields are set then the CPMDIO state machine will be enabled for Auto Mdix checking.
8067 +If a switch to MDI or MDIX mode is needed, the CPMAC will signal this to the OS via Control() using
8068 +the hcMdioMdixSwitch key.
8070 +@par OS example for responding to a Mdix Switch Request
8073 +if(osStrcmpi(pszKey, hcMdioMdixSwitch) == 0) // See if key is Mdix Switch Request
8075 + if(osStrcmpi(pszAction, hcSet) == 0) // Only respond to Set requests
8080 + Mdix = *(bit32u *) ParmValue; // Extract requested Mode
8084 + osSetPhyIntoMdixMode(); // Device specific logic
8086 + osSetPhyIntoMdiMode(); // Device specific logic
8087 + rc = 0; // Set return code as Successfull
8093 +@page cpmac_stats CPMAC Specific Statistics
8095 +Statistics level '0' contains all CPMAC specific statistics.
8101 +@page Example_Driver_Code
8103 +@section example_intro Introduction
8104 +This section provides an in-depth code example for driver implementations. The code
8105 +below illustrates the use of the CPMAC HAL, but is equally applicable to any CPHAL
8106 +implementation. Note: the CPHAl constants hcGet, hcSet etc., are currently available for use with teh CPMAC module.
8107 +Other modules should continue to use pszGET, etc. until these are made generally available.
8109 +@par Pull Model Example
8113 +#define _CPHAL_CPMAC
8115 +typedef struct _os_device_s OS_DEVICE;
8116 +typedef struct _os_receive_s OS_RECEIVEINFO;
8117 +typedef struct _os_send_s OS_SENDINFO;
8118 +typedef struct _os_setup_s OS_SETUP;
8120 +#include "cpswhal_cpmac.h"
8122 +#define dbgPrintf printf
8124 +typedef struct _os_device_s
8126 + HAL_DEVICE *HalDev;
8127 + HAL_FUNCTIONS *HalFunc;
8128 + OS_FUNCTIONS *OsFunc;
8129 + OS_SETUP *OsSetup;
8131 + int (*halIsr)(HAL_DEVICE *HalDev, int*);
8134 + int LinkStatus; // 0-> down, otherwise up
8137 +typedef struct _os_receive_s
8139 + HAL_RECEIVEINFO *HalReceiveInfo;
8140 + char *ReceiveBuffer;
8144 +typedef struct _os_send_s
8149 +typedef struct _os_setup_s
8156 +void FlowForCphal(OS_DEVICE *OsDev)
8158 + CHANNEL_INFO ChannelInfo;
8159 + int nChannels = 200;
8163 + // Populate OsFunc structure
8164 + rc = osInitModule(OsDev);
8168 + sprintf(bufTmp, "%s: return code from osInitModule:'0x%08X'", __FUNCTION__, rc);
8173 + // OS-Cphal handshake
8174 + rc = halCpmacInitModule(&OsDev->HalDev, OsDev, &OsDev->HalFunc, OsDev->OsFunc,
8175 + sizeof(OS_FUNCTIONS), &halFuncSize, OsDev->ModulePort);
8179 + sprintf(bufTmp, "%s: return code from halCpmacInitModule:'0x%08X'", __FUNCTION__, rc);
8183 + // See if hardware module exists
8184 + rc = OsDev->HalFunc->Probe(OsDev->HalDev);
8188 + sprintf(bufTmp, "%s: return code from Probe:'0x%08X'", __FUNCTION__, rc);
8192 + // Initialize hardware module
8193 + rc = OsDev->HalFunc->Init(OsDev->HalDev);
8197 + sprintf(bufTmp, "%s: return code from Init:'0x%08X'", __FUNCTION__, rc);
8201 + // Setup Channel Information (Tranmsit, channel 0)
8202 + ChannelInfo.Channel = 0;
8203 + ChannelInfo.Direction = DIRECTION_TX;
8204 + ChannelInfo.TxNumBuffers = nChannels;
8205 + ChannelInfo.TxNumQueues = 1;
8206 + ChannelInfo.TxServiceMax = nChannels/3;
8208 + rc = OsDev->HalFunc->ChannelSetup(OsDev->HalDev, &ChannelInfo, OsDev->OsSetup);
8210 + // Setup Channel Information (Receive, channel 0)
8211 + ChannelInfo.Channel = 0;
8212 + ChannelInfo.Direction = DIRECTION_RX;
8213 + ChannelInfo.RxBufSize = 1518;
8214 + ChannelInfo.RxBufferOffset = 0;
8215 + ChannelInfo.RxNumBuffers = 2*nChannels;
8216 + ChannelInfo.RxServiceMax = nChannels/3;
8218 + rc = OsDev->HalFunc->ChannelSetup(OsDev->HalDev, &ChannelInfo, OsDev->OsSetup);
8220 + // Open the hardware module
8221 + rc = OsDev->HalFunc->Open(OsDev->HalDev);
8223 + // Module now ready to Send/Receive data
8227 +int osInitModule(OS_FUNCTIONS **pOsFunc)
8229 + OS_FUNCTIONS *OsFunc;
8231 + OsFunc = (OS_FUNCTIONS *) malloc(sizeof(OS_FUNCTIONS));
8235 + *pOsFunc = OsFunc;
8237 + OsFunc->CriticalOff = osCriticalOff;
8238 + OsFunc->CriticalOn = osCriticalOn;
8239 + OsFunc->DataCacheHitInvalidate = osDataCacheHitInvalidate;
8240 + OsFunc->DataCacheHitWriteback = osDataCacheHitWriteback;
8241 + OsFunc->DeviceFindInfo = osDeviceFindInfo;
8242 + OsFunc->DeviceFindParmUint = osDeviceFindParmUint;
8243 + OsFunc->DeviceFindParmValue = osDeviceFindParmValue;
8244 + OsFunc->Free = osFree;
8245 + OsFunc->FreeDev = osFreeDev;
8246 + OsFunc->FreeDmaXfer = osFreeDmaXfer;
8247 + OsFunc->FreeRxBuffer = osFreeRxBuffer;
8248 + OsFunc->IsrRegister = osIsrRegister;
8249 + OsFunc->IsrUnRegister = osIsrUnRegister;
8250 + OsFunc->Malloc = osMalloc;
8251 + OsFunc->MallocDev = osMallocDev;
8252 + OsFunc->MallocDmaXfer = osMallocDmaXfer;
8253 + OsFunc->MallocRxBuffer = osMallocRxBuffer;
8256 + OsFunc->Memset = memset;
8257 + OsFunc->Printf = printf;
8258 + OsFunc->Sprintf = sprintf;
8259 + OsFunc->Strcmpi = osStrcmpi;
8260 + OsFunc->Strlen = strlen;
8261 + OsFunc->Strstr = strstr;
8262 + OsFunc->Strtoul = strtoul;
8264 + OsFunc->Control = osControl;
8265 + OsFunc->Receive = osReceive;
8266 + OsFunc->SendComplete = osSendComplete;
8267 + OsFunc->TeardownComplete = osTearDownComplete;
8273 +int osReceive(OS_DEVICE *OsDev,FRAGLIST *Fraglist,bit32u FragCount,bit32u PacketSize,HAL_RECEIVEINFO *halInfo, bit32u mode)
8275 + OS_RECEIVEINFO *skb = (OS_RECEIVEINFO *)Fraglist[0].OsInfo;
8276 + dcache_i((char *)Fraglist->data, Fraglist->len);
8277 + OsDev->HalFunc->RxReturn(halInfo,0);
8281 +int osSendComplete(OS_SENDINFO *skb)
8287 +static void *osMallocRxBuffer(bit32u Size,void *MemBase, bit32u MemRange,
8288 + OS_SETUP *OsSetup, HAL_RECEIVEINFO *HalReceiveInfo,
8289 + OS_RECEIVEINFO **OsReceiveInfo, OS_DEVICE *OsDev )
8292 + OS_RECEIVEINFO *OsPriv;
8294 + HalBuffer=malloc(Size);
8300 + // Malloc the OS block
8301 + *OsReceiveInfo = malloc(sizeof(OS_RECEIVEINFO));
8302 + if (!*OsReceiveInfo)
8308 + // Initialize the new buffer descriptor
8309 + OsPriv = *OsReceiveInfo;
8310 + OsPriv->OsDev = OsDev;
8311 + OsPriv->ReceiveBuffer = HalBuffer;
8312 + OsPriv->HalReceiveInfo = HalReceiveInfo;
8314 + return(HalBuffer);
8318 +void SendBuffer(OS_DEVICE *OsDev, char *Buffer, int Size)
8320 + FRAGLIST Fraglist;
8324 + Fraglist.len = Size;
8325 + Fraglist.data = (unsigned *) Buffer;
8327 + mode = 0; // Channel 0
8329 + dcache_wb(Fraglist.data, Fraglist.len);
8330 + OsDev->HalFunc->Send(OsDev->HalDev, &Fraglist, FragCount, Size, (OS_SENDINFO *) Buffer, mode);
8334 +void osStateChange(OS_DEVICE *OsDev)
8338 + OsDev->HalFunc->Control(OsDev->HalDev, "Status", hcGet, &status);
8339 + if(status & CPMAC_STATUS_ADAPTER_CHECK)
8341 + // Adapter Check, take appropiate action
8345 + LinkStatus = status & CPMAC_STATUS_LINK;
8346 + if(LinkStatus != OsDev->LinkStatus)
8348 + dbgPrintf("\n%s:Link %s for inst %d Speed %s, Duplex %s\n",
8350 + LinkStatus ? "up" : "down",
8351 + OsDev->ModulePort,
8352 + status & CPMAC_STATUS_LINK_SPEED ? "100" : "10",
8353 + status & CPMAC_STATUS_LINK_DUPLEX ? "FD" : "HD");
8354 + OsDev->LinkStatus = LinkStatus;
8360 +int osControl(OS_DEVICE *OsDev, const char *pszKey, const char* pszAction, void *ParmValue)
8364 + if (osStrcmpi(pszKey, hcCpuFrequency) == 0)
8366 + if(osStrcmpi(pszAction, hcGet) == 0)
8368 + *(bit32u*) ParmValue = cpufreq;
8372 + if (osStrcmpi(pszKey, hcMdioBusFrequency) == 0)
8374 + if(osStrcmpi(pszAction, hcGet) == 0)
8376 + *(bit32u *)ParmValue = MdioBusFrequency;
8380 +if (osStrcmpi(pszKey, hcMdioClockFrequency) == 0)
8382 + if(osStrcmpi(pszAction, hcGet) == 0)
8384 + *(bit32u *)ParmValue = MdioClockFrequency;
8389 + if (osStrcmpi(pszKey, hcTick) == 0)
8391 + if(osStrcmpi(pszAction, hcSet) == 0)
8393 + osTickSetInterval(OsDev, *(unsigned int *) ParmValue);
8397 + if(osStrcmpi(pszAction, hcClear) == 0)
8399 + osTickDisable(OsDev);
8404 + if (osStrcmpi(pszKey, "SioFlush") == 0)
8410 + if (osStrcmpi(pszKey, "StateChange") == 0)
8412 + osStateChange(OsDev);
8416 + if (osStrcmpi(pszKey, "Sleep") == 0)
8418 + osSleep(*(int *)ParmValue);
8427 +@par Push Model Example (Currently Eswitch ONLY)
8431 +typedef struct _os_device_s OS_DEVICE;
8432 +typedef struct _os_receive_s OS_RECEIVEINFO;
8433 +typedef struct _os_send_s OS_SENDINFO;
8434 +typedef struct _os_setup_s OS_SETUP;
8436 +#include "cpswhal.h" //Get glogal HAL stuff
8437 +#include "cpswhaleswitch.h" //Get device specific hal stuff
8440 +typedef struct _os_device_s
8442 + HAL_DEVICE *HalDev;
8443 + HAL_FUNCTIONS *HalFunc;
8444 + OS_FUNCTIONS *OsFunc;
8445 + OS_SETUP *OsSetup;
8447 + int (*halIsr)(HAL_DEVICE *HalDev, int*);
8450 + int LinkStatus; // 0-> down, otherwise up
8453 +typedef struct _os_receive_s
8455 + HAL_RECEIVEINFO *HalReceiveInfo;
8456 + char *ReceiveBuffer;
8460 +typedef struct _os_send_s
8465 +typedef struct _os_setup_s
8472 +void FlowForCphal(OS_DEVICE *OsDev)
8474 +CHANNEL_INFO ChannelInfo;
8475 + int nChannels = 200;
8479 + // Populate OsFunc structure
8480 + rc = osInitModule(OsDev);
8484 + sprintf(bufTmp, "%s: return code from osInitModule:'0x%08X'", __FUNCTION__, rc);
8489 + // OS-Cphal handshake
8490 + rc = cpswHalEswitchInitModule(&OsDev->HalDev, OsDev, &OsDev->HalFunc, OsDev->OsFunc,
8491 + sizeof(OS_FUNCTIONS), &halFuncSize, OsDev->ModulePort);
8495 + sprintf(bufTmp, "%s: return code from cpswHalEswitchInitModule:'0x%08X'", __FUNCTION__, rc);
8500 + ChannelInfo.Channel = 7;
8501 + ChannelInfo.Direction = DIRECTION_RX;
8502 + ChanInfo.Receive = osReceiveSS; // Specify function to receive data for this channel
8504 + rc = OsDev->HalFunc->ChannelSetup(OsDev->HalDev, &ChannelInfo, OsDev->OsSetup);
8507 + MyConfig.CpuFrequency = CpuFreq;
8508 + MyConfig.EswitchFrequency = EswitchFreq;
8509 + MyConfig.ResetBase = 0xa8611600;
8510 + MyConfig.MacAddress = MacAddr;
8512 + MyConfig.EswitchResetBit= 27;
8513 + MyConfig.Cpmac0ResetBit = 17;
8514 + MyConfig.Cpmac1ResetBit = 21;
8515 + MyConfig.MdioResetBit = 22;
8516 + MyConfig.Phy0ResetBit = 26;
8517 + MyConfig.Phy1ResetBit = 28;
8518 + MyConfig.HdmaResetBit = 13;
8519 + MyConfig.Cpmac0IntBit = 19;
8520 + MyConfig.Cpmac1IntBit = 33;
8521 + MyConfig.EswitchIntBit = 27;
8522 + MyConfig.EswitchBase = 0xa8640000;
8523 + MyConfig.EswitchBufferSize = 64;
8524 + MyConfig.EswitchHostBufCount = 0;
8525 + MyConfig.EswitchDefaultCamSize = 64;
8526 + MyConfig.EswitchOverFlowCount = 200;
8527 + MyConfig.EswitchOverFlowSize = 256;
8532 + rc=EswitchConfig(HalDev,HalFunc,&MyConfig);
8535 + // Open the hardware module
8536 + rc = OsDev->HalFunc->Open(OsDev->HalDev);
8538 + // Module now ready to Send/Receive data
8542 +int EswitchConfig(HAL_DEVICE *HalDev, HAL_FUNCTIONS *HalFunc, ESWITCH_CONFIG *Config)
8547 + sts |= cpswhalPushBin(hcdebug, Config->debug);
8548 + sts |= cpswhalPushBin(hcCpuFrequency , Config->CpuFrequency );
8549 + sts |= cpswhalPushBin(hcEswitchFrequency , Config->EswitchFrequency );
8550 + sts |= cpswhalPushBin(hcResetBase , Config->ResetBase );
8551 + sts |= cpswhalPushBin(hcMacAddress , Config->MacAddress );
8552 + sts |= cpswhalPushBin(hcEswitchResetBit, Config->EswitchResetBit);
8553 + sts |= cpswhalPushBin(hcCpmac0ResetBit , Config->Cpmac0ResetBit );
8554 + sts |= cpswhalPushBin(hcCpmac1ResetBit , Config->Cpmac1ResetBit );
8555 + sts |= cpswhalPushBin(hcMdioResetBit , Config->MdioResetBit );
8556 + sts |= cpswhalPushBin(hcPhy0ResetBit , Config->Phy0ResetBit );
8557 + sts |= cpswhalPushBin(hcPhy1ResetBit , Config->Phy1ResetBit );
8558 + sts |= cpswhalPushBin(hcHdmaResetBit , Config->HdmaResetBit );
8559 + sts |= cpswhalPushBin(hcCpmac0IntBit , Config->Cpmac0IntBit );
8560 + sts |= cpswhalPushBin(hcCpmac1IntBit , Config->Cpmac1IntBit );
8561 + sts |= cpswhalPushBin(hcEswitchIntBit , Config->EswitchIntBit );
8562 + sts |= cpswhalPushBin(hcEswitchBase , Config->EswitchBase );
8563 + sts |= cpswhalPushBin(hcEswitchBufferSize , Config->EswitchBufferSize );
8564 + sts |= cpswhalPushBin(hcEswitchHostBufCount , Config->EswitchHostBufCount );
8565 + sts |= cpswhalPushBin(hcEswitchDefaultCamSize , Config->EswitchDefaultCamSize );
8566 + sts |= cpswhalPushBin(hcEswitchOverFlowCount , Config->EswitchOverFlowCount );
8567 + sts |= cpswhalPushBin(hcEswitchOverFlowSize , Config->EswitchOverFlowSize );
8577 diff -urN linux.old/drivers/net/avalanche_cpmac/ec_errors_cpmac.h linux.dev/drivers/net/avalanche_cpmac/ec_errors_cpmac.h
8578 --- linux.old/drivers/net/avalanche_cpmac/ec_errors_cpmac.h 1970-01-01 01:00:00.000000000 +0100
8579 +++ linux.dev/drivers/net/avalanche_cpmac/ec_errors_cpmac.h 2005-07-12 02:48:42.051592000 +0200
8581 +/***************************************************************************
8582 + Copyright(c) 2001, Texas Instruments Incorporated. All Rights Reserved.
8587 + This file contains definitions and function declarations for
8588 + error code support.
8591 + 14Dec00 MJH Added masking to EC_CLASS etc macros
8592 + 17Sep02 GSG Added HAL support (new class&devices)
8593 + 03Oct02 GSG Removed C++ style comments
8594 +***************************************************************************/
8595 +#ifndef _INC_EC_ERRORS
8596 +#define _INC_EC_ERRORS
8600 + 30-28 - CLASS (ie. DIAG, KERNEL, FLASH, etc)
8601 + 27-24 - INSTANCE (ie. 1, 2, 3, etc )
8602 + 23-16 - DEVICE (ie. EMAC, IIC, etc)
8603 + 15-08 - FUNCTION (ie. RX, TX, INIT, etc)
8604 + 07-00 - ERROR CODE (ie. NO_BASE, FILE_NOT_FOUND, etc )
8607 +/*---------------------------------------------------------------------------
8608 + Useful defines for accessing fields within error code
8609 +---------------------------------------------------------------------------*/
8610 +#define CRITICAL_SHIFT 31
8611 +#define CLASS_SHIFT 28
8612 +#define INST_SHIFT 24
8613 +#define DEVICE_SHIFT 16
8614 +#define FUNCTION_SHIFT 8
8615 +#define ERROR_CODE_SHIFT 0
8617 +#define CRITICAL_MASK 1
8618 +#define CLASS_MASK 0x07
8619 +#define DEVICE_MASK 0xFF
8620 +#define INST_MASK 0x0F
8621 +#define FUNCTION_MASK 0xFF
8622 +#define ERROR_CODE_MASK 0xFF
8624 +#define EC_CLASS(val) ((val&CLASS_MASK) << CLASS_SHIFT)
8625 +#define EC_DEVICE(val) ((val&DEVICE_MASK) << DEVICE_SHIFT)
8626 +#define EC_INST(val) ((val&INST_MASK) << INST_SHIFT)
8627 +#define EC_FUNC(val) ((val&FUNCTION_MASK) << FUNCTION_SHIFT)
8628 +#define EC_ERR(val) ((val&ERROR_CODE_MASK) << ERROR_CODE_SHIFT)
8630 +/*---------------------------------------------------------------------------
8632 +---------------------------------------------------------------------------*/
8633 +#define EC_HAL EC_CLASS(0)
8634 +#define EC_DIAG EC_CLASS(8)
8636 +/*---------------------------------------------------------------------------
8638 +---------------------------------------------------------------------------*/
8639 +#define EC_DEV_EMAC EC_DEVICE(1)
8640 +#define EC_DEV_IIC EC_DEVICE(2)
8641 +#define EC_DEV_RESET EC_DEVICE(3)
8642 +#define EC_DEV_ATMSAR EC_DEVICE(4)
8643 +#define EC_DEV_MEM EC_DEVICE(5)
8644 +#define EC_DEV_DES EC_DEVICE(6)
8645 +#define EC_DEV_DMA EC_DEVICE(7)
8646 +#define EC_DEV_DSP EC_DEVICE(8)
8647 +#define EC_DEV_TMR EC_DEVICE(9)
8648 +#define EC_DEV_WDT EC_DEVICE(10)
8649 +#define EC_DEV_DCL EC_DEVICE(11)
8650 +#define EC_DEV_BBIF EC_DEVICE(12)
8651 +#define EC_DEV_PCI EC_DEVICE(13)
8652 +#define EC_DEV_XBUS EC_DEVICE(14)
8653 +#define EC_DEV_DSLIF EC_DEVICE(15)
8654 +#define EC_DEV_USB EC_DEVICE(16)
8655 +#define EC_DEV_CLKC EC_DEVICE(17)
8656 +#define EC_DEV_RAPTOR EC_DEVICE(18)
8657 +#define EC_DEV_DSPC EC_DEVICE(19)
8658 +#define EC_DEV_INTC EC_DEVICE(20)
8659 +#define EC_DEV_GPIO EC_DEVICE(21)
8660 +#define EC_DEV_BIST EC_DEVICE(22)
8661 +#define EC_DEV_HDLC EC_DEVICE(23)
8662 +#define EC_DEV_UART EC_DEVICE(24)
8663 +#define EC_DEV_VOIC EC_DEVICE(25)
8664 +/* 9.17.02 (new HAL modules) */
8665 +#define EC_DEV_CPSAR EC_DEVICE(0x1A)
8666 +#define EC_DEV_AAL5 EC_DEVICE(0x1B)
8667 +#define EC_DEV_AAL2 EC_DEVICE(0x1C)
8668 +#define EC_DEV_CPMAC EC_DEVICE(0x1D)
8669 +#define EC_DEV_VDMA EC_DEVICE(0x1E)
8670 +#define EC_DEV_VLYNQ EC_DEVICE(0x1F)
8671 +#define EC_DEV_CPPI EC_DEVICE(0x20)
8672 +#define EC_DEV_CPMDIO EC_DEVICE(0x21)
8674 +/*---------------------------------------------------------------------------
8676 +---------------------------------------------------------------------------*/
8677 +#define EC_FUNC_READ_CONF EC_FUNC(1)
8678 +#define EC_FUNC_INIT EC_FUNC(2)
8680 +/*---------------------------------------------------------------------------
8682 +---------------------------------------------------------------------------*/
8683 +#define EC_CRITICAL (1<<CRITICAL_SHIFT)
8684 +#define EC_NO_ERRORS 0
8685 +#define EC_VAL_NO_BASE EC_ERR(1)
8686 +#define EC_VAL_NO_RESET_BIT EC_ERR(2)
8687 +#define EC_VAL_NO_RESET EC_ERR(3)
8688 +#define EC_VAL_BAD_BASE EC_ERR(4)
8689 +#define EC_VAL_MALLOCFAILED EC_ERR(5)
8690 +#define EC_VAL_NO_RESETBASE EC_ERR(6)
8691 +#define EC_DEVICE_NOT_FOUND EC_ERR(7)
8693 +/*---------------------------------------------------------------------------
8694 + Function declarations
8695 +---------------------------------------------------------------------------*/
8696 +extern void ec_log_error( unsigned int );
8698 +#endif /* _INC_EC_ERRORS */
8699 diff -urN linux.old/drivers/net/avalanche_cpmac/hcpmac.c linux.dev/drivers/net/avalanche_cpmac/hcpmac.c
8700 --- linux.old/drivers/net/avalanche_cpmac/hcpmac.c 1970-01-01 01:00:00.000000000 +0100
8701 +++ linux.dev/drivers/net/avalanche_cpmac/hcpmac.c 2005-07-12 02:48:42.174574000 +0200
8703 +/******************************************************************************
8704 + * TNETDxxxx Software Support
8705 + * Copyright (c) 2002-2004 Texas Instruments Incorporated. All Rights Reserved.
8710 + * This file contains the code for the HAL EMAC Bridge Test
8713 + * xxXxx01 Denis RC1.00 Original Version created.
8714 + * 22Jan02 Denis/Mick RC1.01 Modified for HAL EMAC API
8715 + * 24Jan02 Denis/Mick RC1.02 Speed Improvements
8716 + * 28Jan02 Denis/Mick RC1.16 Made function calls pointers
8717 + * 28Jan02 Mick RC1.18 Split into separate modules
8718 + * 29Jan02 Mick RC1.19 Hal include file cleaned up
8719 + * 15Jul02 Michael Hanrahan RC1.20 Synch'd with Linux Version
8720 + * 23Sep02 Michael Hanrahan RC1.21 Added CPPI.C
8721 + * 16Oct02 Michael Hanrahan RC1.22 Added CAF etc to Options.Conf
8722 + * 09Jan03 Michael Hanrahan RC3.01 Fixed incorrect MDIO check
8723 + * 01Feb03 Michael Hanrahan RC3.02 Updated for GPIO/PBUSFREQ
8724 + * 29Mar03 Michael Hanrahan 1.03 Corrected ChannelConfigGet
8725 + * 29Mar03 Michael Hanrahan 1.03 Removed user setting of TxNumQueues
8726 + * 23Aug04 Michael Hanrahan 1.7.8 Support for Setting Mac Address
8727 + * @author Michael Hanrahan
8729 + * @date 24-Jan-2002
8730 + *****************************************************************************/
8732 +#define _CPHAL_CPMAC
8734 +#define __CPHAL_CPMDIO
8736 +#include "dox_cpmac.h" /* Documentation information */
8738 +/* OS Data Structure definitions */
8740 +typedef void OS_PRIVATE;
8741 +typedef void OS_DEVICE;
8742 +typedef void OS_SENDINFO;
8743 +typedef void OS_RECEIVEINFO;
8744 +typedef void OS_SETUP;
8746 +/* HAL Data Structure definitions */
8748 +typedef struct _phy_device PHY_DEVICE;
8749 +typedef struct hal_device HAL_DEVICE;
8750 +typedef struct hal_private HAL_PRIVATE;
8751 +typedef struct hal_private HAL_RECEIVEINFO;
8753 +#include "cpcommon_cpmac.h"
8754 +#include "cpswhal_cpmac.h"
8755 +#include "cpmdio.h"
8756 +#include "hcpmac.h"
8757 +#include "cpmac_reg.h"
8762 +/* MDIO Clock Frequency Default Value */
8764 +/* Rcb/Tcb Constants */
8766 +#define CB_SOF_BIT (1<<31)
8767 +#define CB_EOF_BIT (1<<30)
8768 +#define CB_SOF_AND_EOF_BIT (CB_SOF_BIT|CB_EOF_BIT)
8769 +#define CB_OWNERSHIP_BIT (1<<29)
8770 +#define CB_EOQ_BIT (1<<28)
8771 +#define CB_SIZE_MASK 0x0000ffff
8772 +#define RCB_ERRORS_MASK 0x03fe0000
8774 +static char *channel_names[] = CHANNEL_NAMES; /* GSG 11/22 (may change this implementation) */
8776 +#define scFound(Module) if (HalDev->State != enDevFound) return (Module|EC_FUNC_CHSETUP|EC_VAL_INVALID_STATE)
8777 +#define scInit(Module) if (HalDev->State < enInitialized) return (Module|EC_FUNC_CHSETUP|EC_VAL_INVALID_STATE)
8778 +#define scOpen(Module) if (HalDev->State < enOpened) return (Module|EC_FUNC_CHSETUP|EC_VAL_INVALID_STATE)
8782 +/********************************************************************
8784 +** L O C A L F U N C T I O N S
8786 +********************************************************************/
8787 +static int halIsr(HAL_DEVICE *HalDev, int *MorePackets);
8788 +static int cpmacRandom(HAL_DEVICE *HalDev);
8789 +static int cpmacRandomRange(HAL_DEVICE *HalDev, int min, int max);
8790 +static int halPacketProcessEnd(HAL_DEVICE *HalDev);
8792 +#include "cpcommon_cpmac.c" /*~RC3.02*/
8793 +#include "cppi_cpmac.c"
8794 +#include "cpmdio.c" /*~RC3.02*/
8796 +static int MacAddressSave(HAL_DEVICE *HalDev, unsigned char *MacAddr)
8799 + int inst = HalDev->inst;
8801 + HalDev->MacAddr = MacAddr;
8805 + dbgPrintf("MacAddrSave[%d]: ", inst);
8807 + dbgPrintf("%X", HalDev->MacAddr[i]);
8811 + return(EC_NO_ERRORS);
8813 +static int MacAddressSet(HAL_DEVICE *HalDev)
8815 + unsigned char *macadr = &HalDev->MacAddr[0];
8816 + int base = HalDev->dev_base;
8819 + CPMAC_MACADDRLO_0(base) = macadr[5];
8820 + CPMAC_MACADDRMID(base) = macadr[4];
8821 + CPMAC_MACADDRHI(base) = (macadr[0])|(macadr[1]<<8)|(macadr[2]<<16)|(macadr[3]<<24);
8824 + dbgPrintf("MacAddrSet: MacAddr(%d) %X %X %X\n", HalDev->inst, CPMAC_MACADDRLO_0(base),
8825 + CPMAC_MACADDRMID(base),
8826 + CPMAC_MACADDRHI(base));
8828 + dbgPrintf("Start MAC: %d\n",HalDev->dev_base);
8831 + return(EC_NO_ERRORS);
8836 + Updates the MacHash registers
8838 +static void MacHashSet(HAL_DEVICE *HalDev)
8840 + if(HalDev->State < enOpened)
8843 + CPMAC_MACHASH1(HalDev->dev_base) = HalDev->MacHash1;
8844 + CPMAC_MACHASH2(HalDev->dev_base) = HalDev->MacHash2;
8846 + dbgPrintf("CPMAC[%X]: MacHash1 0x%08X, MacHash2 0x%08X\n", HalDev->dev_base, CPMAC_MACHASH1(HalDev->dev_base), CPMAC_MACHASH2(HalDev->dev_base));
8850 + Reads the MacControl register and updates
8851 + the changable bits. (See MACCONTROL_MASK)
8853 +static void RxMBP_EnableSet(HAL_DEVICE *HalDev)
8855 + bit32u RxMbpEnable;
8856 + if(HalDev->State < enOpened)
8858 + RxMbpEnable = CPMAC_RX_MBP_ENABLE(HalDev->dev_base);
8859 + RxMbpEnable &= ~RX_MBP_ENABLE_MASK; /* Clear out updatable bits */
8860 + RxMbpEnable |= HalDev->RxMbpEnable;
8861 + CPMAC_RX_MBP_ENABLE(HalDev->dev_base) = RxMbpEnable;
8864 + Reads the MacControl register and updates
8865 + the changable bits. (See MACCONTROL_MASK)
8867 +static void MacControlSet(HAL_DEVICE *HalDev)
8869 + bit32u MacControl;
8870 + if(HalDev->State < enOpened)
8872 + MacControl = CPMAC_MACCONTROL(HalDev->dev_base);
8873 + MacControl &= ~MACCONTROL_MASK; /* Clear out updatable bits */
8874 + MacControl |= HalDev->MacControl;
8875 + if(!(MacControl & MII_EN)) /* If Enable is not set just update register */
8876 + CPMAC_MACCONTROL(HalDev->dev_base) = MacControl;
8879 + if(MacControl & CTRL_LOOPBACK) /* Loopback Set */
8881 + /* mii_en is set and loopback is needed,
8882 + clear mii_en, set loopback, then set mii_en
8884 + MacControl &= ~MII_EN; /* Clear MII_EN */
8885 + CPMAC_MACCONTROL(HalDev->dev_base) = MacControl;
8886 + CPMAC_MACCONTROL(HalDev->dev_base) |= MII_EN; /* Set MII_EN */
8887 + HalDev->Linked = 1; /* if in loopback the logically linked */
8889 + else /* If Loopback not set just update */
8891 + CPMAC_MACCONTROL(HalDev->dev_base) = MacControl;
8895 + dbgPrintf("[halMacControlSet]MacControl:%08X\n", CPMAC_MACCONTROL(HalDev->dev_base));
8897 +static int UnicastSet(HAL_DEVICE *HalDev)
8899 + CPMAC_RX_UNICAST_SET(HalDev->dev_base) = HalDev->RxUnicastSet;
8900 + CPMAC_RX_UNICAST_CLEAR(HalDev->dev_base) = HalDev->RxUnicastClear;
8901 + return(EC_NO_ERRORS);
8905 +static bit32u HashGet(bit8u *Address)
8912 + for( i=0; i<2; i++ )
8914 + tmpval = *Address++;
8915 + hash ^= (tmpval>>2)^(tmpval<<4);
8916 + tmpval = *Address++;
8917 + hash ^= (tmpval>>4)^(tmpval<<2);
8918 + tmpval = *Address++;
8919 + hash ^= (tmpval>>6)^(tmpval);
8922 + return( hash & 0x3F );
8925 +static void HashAdd(HAL_DEVICE *HalDev, bit8u *MacAddress)
8930 + HashValue = HashGet(MacAddress);
8932 + if(HashValue < 32)
8934 + HashBit = (1 << HashValue);
8935 + HalDev->MacHash1 |= HashBit;
8939 + HashBit = (1 << (HashValue-32));
8940 + HalDev->MacHash2 |= HashBit;
8944 +static void HashDel(HAL_DEVICE *HalDev, bit8u *MacAddress)
8949 + HashValue = HashGet(MacAddress);
8951 + if(HashValue < 32)
8953 + HashBit = (1 << HashValue);
8954 + HalDev->MacHash1 &= ~HashBit;
8958 + HashBit = (1 << (HashValue-32));
8959 + HalDev->MacHash2 &= ~HashBit;
8963 +/* Replace with an array based on key, with a ptr to the code to do */
8964 +/* e.g. [enRX_PASS_CRC] = {Set, MBP_UPDATE() } */
8965 +static void DuplexUpdate(HAL_DEVICE *HalDev)
8967 + int base = HalDev->dev_base;
8968 + PHY_DEVICE *PhyDev = HalDev->PhyDev;
8970 + if(HalDev->State < enOpened)
8973 + /* No Phy Condition */
8974 + if(HalDev->MdioConnect & _CPMDIO_NOPHY) /*MJH+030805*/
8976 + /* No Phy condition, always linked */
8977 + HalDev->Linked = 1;
8978 + HalDev->EmacSpeed = 1;
8979 + HalDev->EmacDuplex = 1;
8980 + HalDev->PhyNum = 0xFFFFFFFF; /* No Phy Num */
8981 + CPMAC_MACCONTROL(base) |= FULLDUPLEX; /*MJH+030909*/
8982 + osfuncStateChange();
8986 + if(HalDev->MacControl & CTRL_LOOPBACK) /* Loopback Set */
8988 + HalDev->Linked = 1;
8992 + if (HalDev->MdioConnect & _CPMDIO_LOOPBK)
8994 + HalDev->Linked = cpMacMdioGetLoopback(HalDev->PhyDev);
8998 + HalDev->Linked = cpMacMdioGetLinked(HalDev->PhyDev);
9000 + if (HalDev->Linked)
9002 + /* Retreive Duplex and Speed and the Phy Number */
9003 + if(HalDev->MdioConnect & _CPMDIO_LOOPBK)
9004 + HalDev->EmacDuplex = 1;
9006 + HalDev->EmacDuplex = cpMacMdioGetDuplex(PhyDev);
9007 + HalDev->EmacSpeed = cpMacMdioGetSpeed(PhyDev);
9008 + HalDev->PhyNum = cpMacMdioGetPhyNum(PhyDev);
9010 + if(HalDev->EmacDuplex)
9011 + CPMAC_MACCONTROL(base) |= FULLDUPLEX;
9013 + CPMAC_MACCONTROL(base) &= ~FULLDUPLEX;
9015 + dbgPrintf("%d: Phy= %d, Speed=%s, Duplex=%s\n",HalDev->inst,HalDev->PhyNum,(HalDev->EmacSpeed)?"100":"10",(HalDev->EmacDuplex)?"Full":"Half");
9018 + dbgPrintf("DuplexUpdate[%d]: MACCONTROL 0x%08X, %s\n", HalDev->inst, CPMAC_MACCONTROL(base),(HalDev->Linked)?"Linked":"Not Linked");
9020 +static void MdioSetPhyMode(HAL_DEVICE *HalDev)
9022 + unsigned int PhyMode;
9023 + /* Verify proper device state */
9024 + if (HalDev->State < enOpened)
9027 + PhyMode = NWAY_AUTO|NWAY_FD100|NWAY_HD100|NWAY_FD10|NWAY_HD10;
9030 + dbgPrintf("halSetPhyMode1: MdioConnect:%08X ,", HalDev->MdioConnect);
9031 + dbgPrintf("PhyMode:%08X Auto:%d, FD10:%d, HD10:%d, FD100:%d, HD100:%d\n", PhyMode,
9032 + PhyMode&NWAY_AUTO, PhyMode&NWAY_FD10, PhyMode&NWAY_HD10, PhyMode&NWAY_FD100,
9033 + PhyMode&NWAY_HD100);
9037 + if ( HalDev->MdioConnect & _CPMDIO_NEG_OFF) /* ~RC3.01 */
9038 + PhyMode &= ~(NWAY_AUTO); /* Disable Auto Neg */
9039 + if (!(HalDev->MdioConnect & _CPMDIO_HD))
9040 + PhyMode &= ~(NWAY_HD100|NWAY_HD10); /* Cannot support HD */
9041 + if (!(HalDev->MdioConnect & _CPMDIO_FD))
9042 + PhyMode &= ~(NWAY_FD100|NWAY_FD10); /* Cannot support FD */
9043 + if (!(HalDev->MdioConnect & _CPMDIO_10))
9044 + PhyMode &= ~(NWAY_HD10|NWAY_FD10); /* Cannot support 10 Mbs */
9045 + if (!(HalDev->MdioConnect & _CPMDIO_100))
9046 + PhyMode &= ~(NWAY_HD100|NWAY_FD100); /* Cannot support 100 Mbs */
9048 + if(HalDev->MdioConnect & _CPMDIO_AUTOMDIX) PhyMode |= NWAY_AUTOMDIX; /* Set AutoMdix */
9050 + if (HalDev->CpmacFrequency <= 50000000)
9051 + PhyMode &= ~(NWAY_FD100|NWAY_HD100); /* Cannot support 100 MBS */
9053 + dbgPrintf("halNeg: PhyMode[0x%08X] %d\n", HalDev->dev_base, PhyMode);
9057 + dbgPrintf("halSetPhyMode2: MdioConnect:%08X ,", HalDev->MdioConnect);
9058 + dbgPrintf("PhyMode:%08X Auto:%d, FD10:%d, HD10:%d, FD100:%d, HD100:%d\n", PhyMode,
9059 + PhyMode&NWAY_AUTO, PhyMode&NWAY_FD10, PhyMode&NWAY_HD10, PhyMode&NWAY_FD100,
9060 + PhyMode&NWAY_HD100);
9064 + cpMacMdioSetPhyMode(HalDev->PhyDev,PhyMode);
9065 + DuplexUpdate(HalDev);
9067 +static int StatsClear(HAL_DEVICE *HalDev)
9074 + pStats = pCPMAC_RXGOODFRAMES(HalDev->dev_base);
9075 + for (i=0;i<STATS_MAX;i++)
9077 + *(MEM_PTR)(pStats) = 0xFFFFFFFF;
9081 + return(EC_NO_ERRORS);
9083 +static void StatsDump(HAL_DEVICE *HalDev, void *Value)
9088 + ptrStats = pCPMAC_RXGOODFRAMES(HalDev->dev_base);
9089 + ptrValue = (bit32u*) Value;
9090 + for (i=0; i<STATS_MAX; i++)
9092 + *ptrValue = *ptrStats;
9095 + dbgPrintf("halStatsDump: Stat[%d:0x%08X] %d 0x%08X %d\n", i, ptrStats, *ptrStats, ptrValue, *ptrValue);
9102 +static void ConfigApply(HAL_DEVICE *HalDev)
9104 + CPMAC_RX_MAXLEN(HalDev->dev_base) = HalDev->RxMaxLen;
9105 + CPMAC_RX_FILTERLOWTHRESH(HalDev->dev_base) = HalDev->RxFilterLowThresh;
9106 + CPMAC_RX0_FLOWTHRESH(HalDev->dev_base) = HalDev->Rx0FlowThresh;
9107 + UnicastSet(HalDev);
9108 + MacAddressSet(HalDev);
9109 + RxMBP_EnableSet(HalDev);
9110 + MacHashSet(HalDev);
9111 + MacControlSet(HalDev);
9113 + dbgPrintf("ValuesUpdate[%d]: MBP_ENABLE 0x%08X\n", HalDev->inst, CPMAC_RX_MBP_ENABLE(HalDev->dev_base));
9115 +static int halStatus(HAL_DEVICE *HalDev)
9119 + if(HalDev->State < enOpened)
9120 + return (EC_CPMAC|EC_FUNC_STATUS|EC_VAL_INVALID_STATE); /*MJH+030805*/
9122 + /* No Phy Condition */
9123 + if(HalDev->MdioConnect & _CPMDIO_NOPHY) /*MJH+030805*/
9125 + /* No Phy condition, always linked */
9126 + status = HalDev->Linked;
9127 + status |= CPMAC_STATUS_LINK_DUPLEX;
9128 + status |= CPMAC_STATUS_LINK_SPEED;
9133 + if (HalDev->HostErr) /* Adapter Check */
9136 + status = CPMAC_STATUS_ADAPTER_CHECK;
9137 + if(HalDev->MacStatus & RX_HOST_ERR_CODE)
9139 + status |= CPMAC_STATUS_HOST_ERR_DIRECTION;
9140 + tmp = (HalDev->MacStatus & RX_HOST_ERR_CODE) >> 12; /* Code */
9141 + status |= (tmp << 9); /* Code */
9142 + tmp = (HalDev->MacStatus & RX_ERR_CH) >> 8; /* Channel */
9143 + status |= (tmp << 13);
9146 + if(HalDev->MacStatus & TX_HOST_ERR_CODE)
9148 + status |= CPMAC_STATUS_HOST_ERR_DIRECTION;
9149 + tmp = (HalDev->MacStatus & TX_HOST_ERR_CODE) >> 20; /* Code */
9150 + status |= (tmp << 9); /* Code */
9151 + tmp = (HalDev->MacStatus & TX_ERR_CH) >> 16; /* Channel */
9152 + status |= (tmp << 13);
9157 + status = HalDev->Linked;
9160 + status = CPMAC_STATUS_LINK;
9161 + if(cpMacMdioGetDuplex(HalDev->PhyDev))
9162 + status |= CPMAC_STATUS_LINK_DUPLEX;
9163 + if(cpMacMdioGetSpeed(HalDev->PhyDev))
9164 + status |= CPMAC_STATUS_LINK_SPEED;
9168 + dbgPrintf("[halStatus] Link Status is %d for 0x%X\n", status, HalDev->dev_base);
9171 +static int InfoAccess(HAL_DEVICE *HalDev, int Key, int Action, void *ParmValue)
9178 + /********************************************************************/
9182 + /********************************************************************/
9187 + *(const char **)ParmValue = pszVersion_CPMAC;
9193 + HalDev->debug = *(unsigned int *)ParmValue;
9201 + status = halStatus(HalDev);
9202 + *(int *)ParmValue = status;
9205 + /********************************************************************/
9207 + /* RX_MBP_ENABLE */
9209 + /********************************************************************/
9211 + case enRX_PASS_CRC :
9214 + UPDATE_RX_PASS_CRC(*(unsigned int *)ParmValue);
9218 + case enRX_QOS_EN :
9221 + UPDATE_RX_QOS_EN(*(unsigned int *)ParmValue);
9225 + case enRX_NO_CHAIN :
9228 + UPDATE_RX_NO_CHAIN(*(unsigned int *)ParmValue);
9232 + case enRX_CMF_EN :
9235 + UPDATE_RX_CMF_EN(*(unsigned int *)ParmValue);
9239 + case enRX_CSF_EN :
9242 + UPDATE_RX_CSF_EN(*(unsigned int *)ParmValue);
9246 + case enRX_CEF_EN :
9249 + UPDATE_RX_CEF_EN(*(unsigned int *)ParmValue);
9253 + case enRX_CAF_EN :
9256 + UPDATE_RX_CAF_EN(*(unsigned int *)ParmValue);
9260 + case enRX_PROM_CH :
9263 + UPDATE_RX_PROM_CH(*(unsigned int *)ParmValue);
9267 + case enRX_BROAD_EN :
9270 + UPDATE_RX_BROAD_EN(*(unsigned int *)ParmValue);
9274 + case enRX_BROAD_CH :
9277 + UPDATE_RX_BROAD_CH(*(unsigned int *)ParmValue);
9281 + case enRX_MULT_EN :
9284 + UPDATE_RX_MULT_EN(*(unsigned int *)ParmValue);
9288 + case enRX_MULT_CH :
9291 + UPDATE_RX_MULT_CH(*(unsigned int *)ParmValue);
9296 + /********************************************************************/
9300 + /********************************************************************/
9305 + UPDATE_TX_PTYPE(*(unsigned int *)ParmValue);
9312 + UPDATE_TX_PACE(*(unsigned int *)ParmValue);
9316 + case enTX_FLOW_EN :
9319 + UPDATE_TX_FLOW_EN(*(unsigned int *)ParmValue);
9323 + case enRX_FLOW_EN :
9326 + UPDATE_RX_FLOW_EN(*(unsigned int *)ParmValue);
9331 + case enCTRL_LOOPBACK :
9334 + UPDATE_CTRL_LOOPBACK(*(unsigned int *)ParmValue);
9338 + /********************************************************************/
9340 + /* RX_UNICAST_SET */
9342 + /********************************************************************/
9344 + case enRX_UNICAST_SET :
9347 + HalDev->RxUnicastSet |= (1 << *(unsigned int *)ParmValue);
9348 + HalDev->RxUnicastClear &= ~(1 << *(unsigned int *)ParmValue);
9352 + case enRX_UNICAST_CLEAR :
9355 + HalDev->RxUnicastClear |= (1 << *(unsigned int *)ParmValue);
9356 + HalDev->RxUnicastSet &= ~(1 << *(unsigned int *)ParmValue);
9361 + case enRX_MAXLEN :
9364 + HalDev->RxMaxLen = *(unsigned int *)ParmValue;
9369 + case enRX_FILTERLOWTHRESH :
9372 + HalDev->RxFilterLowThresh = *(unsigned int *)ParmValue;
9376 + case enRX0_FLOWTHRESH :
9379 + HalDev->Rx0FlowThresh = *(unsigned int *)ParmValue;
9383 + /********************************************************************/
9385 + /* RX_MULTICAST */
9387 + /********************************************************************/
9389 + case enRX_MULTICAST :
9391 + case enRX_MULTI_SINGLE :
9395 + bit8u *MacAddress;
9396 + MacAddress = (bit8u *) ParmValue;
9397 + dbgPrintf("CPMAC[%X]: MacAddress '", HalDev->dev_base);
9398 + for (tmpi=0; tmpi<6; tmpi++)
9399 + dbgPrintf("%02X:", MacAddress[tmpi]);
9402 + if(Action==enCLEAR)
9404 + HashDel(HalDev, ParmValue);
9410 + HashAdd(HalDev, ParmValue);
9414 + case enRX_MULTI_ALL :
9415 + if(Action==enCLEAR)
9417 + HalDev->MacHash1 = 0;
9418 + HalDev->MacHash2 = 0;
9424 + HalDev->MacHash1 = 0xFFFFFFFF;
9425 + HalDev->MacHash2 = 0xFFFFFFFF;
9430 + /********************************************************************/
9434 + /********************************************************************/
9436 + case enMdioConnect :
9439 + HalDev->MdioConnect = *(unsigned int *)ParmValue;
9440 + MdioSetPhyMode(HalDev);
9444 + *(unsigned int *)ParmValue = HalDev->MdioConnect;
9449 + /********************************************************************/
9453 + /********************************************************************/
9454 + case enStatsClear :
9455 + StatsClear(HalDev);
9457 + case enStatsDump :
9460 + StatsDump(HalDev, ParmValue);
9468 + StatsGet(HalDev, ParmValue, 1);
9475 + StatsGet(HalDev, ParmValue, 2);
9481 + StatsGet(HalDev, ParmValue, 3);
9487 + StatsGet(HalDev, ParmValue, 4);
9494 + rc = EC_CPMAC|EC_FUNC_OPTIONS|EC_VAL_KEY_NOT_FOUND;
9498 + /* Verify proper device state */
9499 + if (HalDev->State == enOpened)
9503 + ConfigApply(HalDev);
9511 +static const char pszStats[] = "Stats;";
9513 +static int halControl(HAL_DEVICE *HalDev, const char *pszKey, const char *pszAction, void *Value)
9521 +#ifdef __CPHAL_DEBUG
9524 + dbgPrintf("\nhalControl-HalDev:%08X,Action:%s,Key:%s\n", (bit32u)HalDev, pszAction, pszKey);
9528 + /* 23Aug04 - BCIL needs to set Mac Address */
9529 + if(HalDev->OsFunc->Strcmpi(pszKey, pszMacAddr) == 0)
9532 + if(HalDev->OsFunc->Strcmpi(pszAction, hcSet) == 0)
9534 + unsigned char *MacAddr;
9535 + MacAddr = (unsigned char *) Value;
9536 + MacAddressSave(HalDev, MacAddr);
9537 + MacAddressSet(HalDev);
9546 + if(HalDev->OsFunc->Strcmpi(pszKey, hcLinked) == 0)
9549 + if(HalDev->OsFunc->Strcmpi(pszAction, hcSet) == 0)
9551 + HalDev->Linked = *(int *)Value;
9560 + if(HalDev->OsFunc->Strcmpi(pszKey, "TxIntDisable") == 0)
9563 + if(HalDev->OsFunc->Strcmpi(pszAction, hcSet) == 0)
9565 + HalDev->TxIntDisable = *(int *)Value;
9566 + if(HalDev->TxIntDisable && (HalDev->State == enOpened))
9568 + /* if Opened and need TxIntDisabled, clear Ints for Channel 0 */
9569 + CPMAC_TX_INTMASK_CLEAR(HalDev->dev_base) = 1;
9579 + if(HalDev->OsFunc->Strcmpi(pszKey, hcPhyAccess) == 0)
9586 + ValueIn = *(bit32u*) Value;
9589 + /* Cannot access MII if not opended */
9591 + if(HalDev->State < enOpened)
9594 + if(HalDev->OsFunc->Strcmpi(pszAction, hcGet) == 0)
9597 + PhyNum = (ValueIn & 0x1F); /* Phynum 0-32 */
9598 + RegAddr = (ValueIn >> 5) & 0xFF; /* RegAddr in upper 11 bits */
9600 + *(bit32u*)Value = _mdioUserAccessRead(HalDev->PhyDev, RegAddr, PhyNum);
9603 + } /* end of hcGet */
9606 + if(HalDev->OsFunc->Strcmpi(pszAction, hcSet) == 0)
9608 + PhyNum = (ValueIn & 0x1F); /* Phynum 0-32 */
9609 + RegAddr = (ValueIn >> 5) & 0xFF; /* RegAddr in upper 11 bits of lower 16 */
9611 + Data = ValueIn >> 16; /* Data store in upper 16 bits */
9613 + _mdioUserAccessWrite(HalDev->PhyDev, RegAddr, PhyNum, Data);
9616 + } /* End of hcPhyAccess */
9618 + if(HalDev->OsFunc->Strcmpi(pszKey, hcPhyNum) == 0)
9621 + if(!HalDev->Linked)
9622 + return(-1); /* if not linked the no Phy Connected */
9623 + if(HalDev->OsFunc->Strcmpi(pszAction, hcGet) == 0)
9625 + *(int *)Value = HalDev->PhyNum;
9630 + if(HalDev->OsFunc->Strcmpi(pszKey, hcCpmacSize) == 0)
9633 + if(HalDev->OsFunc->Strcmpi(pszAction, hcGet) == 0)
9635 + *(bit32u *)Value = HalDev->CpmacSize;
9640 + if(HalDev->OsFunc->Strcmpi(pszKey, hcCpmacBase) == 0)
9643 + if(HalDev->OsFunc->Strcmpi(pszAction, hcGet) == 0)
9645 + *(int *)Value = HalDev->dev_base;
9650 + if(HalDev->OsFunc->Strcmpi(pszKey, hcFullDuplex) == 0)
9653 + if(HalDev->OsFunc->Strcmpi(pszAction, hcSet) == 0)
9655 + UPDATE_FULLDUPLEX(*(unsigned int *)Value);
9656 + if(HalDev->State == enOpened)
9657 + ConfigApply(HalDev);
9664 + if(HalDev->OsFunc->Strcmpi(pszKey, pszDebug) == 0)
9667 + if(HalDev->OsFunc->Strcmpi(pszAction, hcSet) == 0)
9670 + HalDev->debug = *(int *)Value;
9674 + if(HalDev->OsFunc->Strcmpi(pszKey, hcMaxFrags) == 0)
9677 + if(HalDev->OsFunc->Strcmpi(pszAction, hcSet) == 0)
9681 + if ((*(int *)Value) > 0)
9682 + HalDev->MaxFrags = *(int *)Value;
9684 + rc = (EC_AAL5|EC_FUNC_CONTROL|EC_VAL_INVALID_VALUE);
9687 + if (HalDev->OsFunc->Strcmpi(pszAction, hcGet) == 0)
9691 + *(int *)Value = HalDev->MaxFrags;
9695 + if(HalDev->OsFunc->Strstr(pszKey, pszStats) != 0)
9698 + if(HalDev->OsFunc->Strcmpi(pszAction, hcGet) == 0)
9702 + char *TmpKey = (char *)pszKey;
9704 + TmpKey += HalDev->OsFunc->Strlen(pszStats);
9705 + Level = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
9707 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
9710 +#ifdef __CPHAL_DEBUG
9713 + dbgPrintf("\nhalControl-HalDev:%08X, Level:%d, Ch:%d\n", (bit32u)HalDev, Level, Ch);
9716 + StatsGet(HalDev, (void **)Value, Level, Ch, 0);
9722 + if(HalDev->OsFunc->Strcmpi(pszAction, hcSet) == 0)
9725 + if(HalDev->OsFunc->Strcmpi(pszAction, hcClear) == 0)
9728 + if(HalDev->OsFunc->Strcmpi(pszAction, hcGet) == 0)
9735 + for(i=enCommonStart+1;i<enCommonEnd;i++)
9737 + if(HalDev->OsFunc->Strcmpi(KeyCommon[i].strKey, pszKey)==0)
9739 + rc = InfoAccess(HalDev, KeyCommon[i].enKey, Action, Value);
9742 + for(i=enCpmacStart+1;i<enCpmacEnd;i++)
9744 + if(HalDev->OsFunc->Strcmpi(KeyCpmac[i].strKey, pszKey)==0)
9746 + rc = InfoAccess(HalDev, KeyCpmac[i].enKey, Action, Value);
9750 + if (KeyFound == 0)
9751 + rc = (EC_MODULE|EC_FUNC_CONTROL|EC_VAL_KEY_NOT_FOUND);
9753 + if (ActionFound == 0)
9754 + rc = (EC_MODULE|EC_FUNC_CONTROL|EC_VAL_ACTION_NOT_FOUND);
9759 +static bit32u ConfigGet(HAL_DEVICE *HalDev)
9761 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
9762 + char *DeviceInfo = HalDev->DeviceInfo;
9763 + int i = HalDev->inst;
9767 + /* get the configuration parameters common to all modules */
9768 + Error = ConfigGetCommon(HalDev);
9769 + if (Error) return (EC_CPMAC|Error);
9771 + if (HalDev->debug)
9773 + dbgPrintf("ConfigGet: haldev:0x%08X inst:%d base:0x%08X reset:%d\n", (bit32u) &HalDev, HalDev->inst, HalDev->dev_base, HalDev->ResetBit);
9777 + Error = OsFunc->DeviceFindParmUint(DeviceInfo, pszMdioConnect,&Value); /*MJH+030805*/
9778 + if(!Error) HalDev->MdioConnect = Value;
9780 + Error = OsFunc->DeviceFindParmUint(DeviceInfo, "PhyMask",&Value);
9781 + if(!Error) HalDev->PhyMask = Value;
9783 + Error = OsFunc->DeviceFindParmUint(DeviceInfo, "MLink",&Value);
9784 + if(!Error) HalDev->MLinkMask = Value;
9786 + Error = OsFunc->DeviceFindParmUint(DeviceInfo, hcMdixMask, &Value);
9788 + HalDev->MdixMask = Value;
9790 + HalDev->MdixMask = 0;
9792 + Error = OsFunc->DeviceFindParmUint(DeviceInfo, hcSize, &Value); /*MJH+030425*/
9793 + if(!Error) HalDev->CpmacSize = Value;
9795 + for(i=enCommonStart+1;i<enCommonEnd;i++)
9797 + Error = OsFunc->DeviceFindParmUint(DeviceInfo, KeyCommon[i].strKey, (bit32u*)&Value);
9800 + InfoAccess(HalDev, KeyCommon[i].enKey, enSET, (bit32u*)&Value);
9803 + for(i=enCpmacStart+1;i<enCpmacEnd;i++)
9805 + Error = OsFunc->DeviceFindParmUint(DeviceInfo, KeyCpmac[i].strKey, (bit32u*)&Value);
9808 + InfoAccess(HalDev, KeyCpmac[i].enKey, enSET, (bit32u*)&Value);
9811 + return (EC_NO_ERRORS);
9815 +static void ConfigInit(HAL_DEVICE *HalDev)
9817 + if(HalDev->inst == 0)
9819 + HalDev->dev_base = 0xA8610000;
9820 + HalDev->ResetBit = 17;
9821 + HalDev->interrupt = 19;
9822 + HalDev->MLinkMask = 0;
9823 + HalDev->PhyMask = 0xAAAAAAAA;
9827 + HalDev->dev_base = 0xA8612800;
9828 + HalDev->ResetBit = 21;
9829 + HalDev->interrupt = 33; /*~RC3.02*/
9830 + HalDev->MLinkMask = 0;
9831 + HalDev->PhyMask = 0x55555555;
9833 + HalDev->RxMaxLen = 1518;
9834 + HalDev->MaxFrags = 2;
9835 + HalDev->MdioConnect = _CPMDIO_HD|_CPMDIO_FD|_CPMDIO_10|_CPMDIO_100|_CPMDIO_AUTOMDIX;
9836 + HalDev->debug=0xFFFFFFFF;
9839 +/* Shuts down the EMAC device
9841 + *@param HalDev EMAC instance. This was returned by halOpen()
9842 + *@param mode Indicates actions to tak on close.
9844 + *PARTIAL - Disable EMAC
9846 + *FULL - Disable EMAC and call OS to free all allocated memory
9854 +static int halInit( HAL_DEVICE *HalDev)
9858 + /* Verify proper device state */
9859 + if (HalDev->State != enDevFound)
9860 + return(EC_CPMAC|EC_FUNC_HAL_INIT|EC_VAL_INVALID_STATE);
9862 + /* Configure HAL defaults */
9863 + ConfigInit(HalDev);
9865 + /* Retrieve HAL configuration parameters from data store */
9866 + rc = ConfigGet(HalDev);
9867 + if (rc) return (rc);
9869 + /* Updated 030403*/
9870 + rc = HalDev->OsFunc->Control(HalDev->OsDev, hcCpuFrequency, hcGet, &HalDev->CpuFrequency); /*MJH+030403*/
9872 + HalDev->CpuFrequency = 20000000; /*20 Mhz default */ /*MJH+030403*/
9874 + rc = HalDev->OsFunc->Control(HalDev->OsDev, hcCpmacFrequency, hcGet, &HalDev->CpmacFrequency); /*MJH+030331*/
9876 + HalDev->CpmacFrequency = HalDev->CpuFrequency/2; /*MJH~030404*/
9878 + rc = HalDev->OsFunc->Control(HalDev->OsDev, hcMdioBusFrequency, hcGet, &HalDev->MdioBusFrequency); /*MJH+030402*/
9880 + HalDev->MdioBusFrequency = HalDev->CpmacFrequency;
9882 + rc = HalDev->OsFunc->Control(HalDev->OsDev, hcMdioClockFrequency, hcGet, &HalDev->MdioClockFrequency); /*MJH+030402*/
9884 + HalDev->MdioClockFrequency = 2200000; /* 2.2 Mhz PITS #14 */
9887 + /* update device state */
9888 + HalDev->State = enInitialized;
9890 + /* initialize statistics */
9891 + StatsInit(HalDev); /* +RC3.02 */
9894 + StatsTable3[0].StatPtr = &HalDev->ChData[0].RxBufSize;
9895 + StatsTable3[1].StatPtr = &HalDev->ChData[0].RxBufferOffset;
9896 + StatsTable3[2].StatPtr = &HalDev->ChData[0].RxNumBuffers;
9897 + StatsTable3[3].StatPtr = &HalDev->ChData[0].RxServiceMax;
9898 + StatsTable3[4].StatPtr = &HalDev->ChData[0].TxNumBuffers;
9899 + StatsTable3[5].StatPtr = &HalDev->ChData[0].TxNumQueues;
9900 + StatsTable3[6].StatPtr = &HalDev->ChData[0].TxServiceMax;
9903 + return(EC_NO_ERRORS);
9905 +static int halProbe(HAL_DEVICE *HalDev)
9907 + int inst = HalDev->inst;
9908 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
9911 + if (HalDev->State != enConnected)
9912 + return (EC_CPMAC|EC_FUNC_PROBE|EC_VAL_INVALID_STATE);
9914 + if(HalDev->debug) dbgPrintf("halProbe: %d ",inst);
9916 + error_code = OsFunc->DeviceFindInfo(inst,"cpmac",&HalDev->DeviceInfo);
9919 + return (EC_CPMAC|EC_FUNC_PROBE|EC_VAL_DEVICE_NOT_FOUND );
9921 + /* Set device state to DevFound */
9922 + HalDev->State = enDevFound;
9923 + return(EC_NO_ERRORS);
9925 +static void ChannelConfigInit(HAL_DEVICE *HalDev, CHANNEL_INFO *HalChn)
9927 + int Ch = HalChn->Channel;
9928 + int Direction = HalChn->Direction;
9929 + int nTxBuffers = 256;
9931 + if (Direction == DIRECTION_TX)
9933 + HalDev->ChData[Ch].TxNumBuffers = nTxBuffers;
9934 + HalDev->ChData[Ch].TxNumQueues = 1;
9935 + HalDev->ChData[Ch].TxServiceMax = nTxBuffers/3;
9936 + HalDev->TxIntThreshold[Ch] = HalDev->ChData[Ch].TxServiceMax;
9937 + HalDev->TxIntThresholdMaster[Ch] = HalDev->TxIntThreshold[Ch];
9940 + if (Direction == DIRECTION_RX)
9942 + HalDev->ChData[Ch].RxNumBuffers = nTxBuffers*2;
9943 + HalDev->ChData[Ch].RxBufferOffset = 0;
9944 + HalDev->ChData[Ch].RxBufSize = 1518;
9945 + HalDev->ChData[Ch].RxServiceMax = nTxBuffers/3; /*Not a typo*/
9948 +static int ChannelConfigApply(HAL_DEVICE *HalDev, CHANNEL_INFO *HalChn)
9950 + int Ch = HalChn->Channel;
9951 + int Direction = HalChn->Direction;
9955 + dbgPrintf("halChannelConfigApply[%d:%d] haldev:0x%08X inst:%d base:0x%08X reset:%d\n", Ch, Direction, (bit32u) &HalDev, HalDev->inst, HalDev->dev_base, HalDev->ResetBit);
9959 + if (Direction == DIRECTION_TX)
9961 + if (HalDev->ChIsOpen[Ch][Direction] == TRUE)
9963 + return(EC_CPMAC|EC_FUNC_CHSETUP|EC_VAL_TX_CH_ALREADY_OPEN);
9966 + /* Initialize Queue Data */
9967 + HalDev->TxActQueueHead[Ch][0] = 0;
9968 + HalDev->TxActQueueCount[Ch][0] = 0;
9969 + HalDev->TxActive[Ch][0] = FALSE;
9971 + /* Need to use a macro that takes channel as input */
9972 + CPMAC_TX0_HDP(HalDev->dev_base)=0;
9974 + /* Initialize buffer memory for the channel */
9975 + InitTcb(HalDev, Ch);
9977 + if(!HalDev->TxIntDisable)
9978 + CPMAC_TX_INTMASK_SET(HalDev->dev_base) = (1<<Ch); /* GSG 11/22 */
9982 + if (HalDev->ChIsOpen[Ch][Direction] == TRUE)
9984 + return(EC_CPMAC|EC_FUNC_CHSETUP|EC_VAL_RX_CH_ALREADY_OPEN);
9987 + /* Initialize Queue Data */
9988 + HalDev->RxActQueueHead[Ch] = 0;
9989 + HalDev->RxActQueueCount[Ch] = 0;
9991 + HalDev->RxActive[Ch] = FALSE;
9993 + /* Need to use a macro that takes channel as input */
9994 + CPMAC_RX0_HDP(HalDev->dev_base)=0;
9996 + /* Initialize buffer memory for the channel */
9997 + InitRcb(HalDev, Ch);
9999 + CPMAC_RX_INTMASK_SET(HalDev->dev_base) = (1<<Ch); /* GSG 11/22 */
10002 + HalDev->ChIsOpen[Ch][Direction] = TRUE; /* channel is open */
10004 + return (EC_NO_ERRORS);
10008 + * Retrieves channel parameters from configuration file. Any parameters
10009 + * which are not found are ignored, and the HAL default value will apply,
10010 + * unless a new value is given through the channel structure in the call
10011 + * to ChannelSetup.
10013 +static int ChannelConfigGet(HAL_DEVICE *HalDev, CHANNEL_INFO *HalChn)
10015 + int Ch = HalChn->Channel;
10016 + int Direction = HalChn->Direction;
10017 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
10018 + unsigned int rc, Value;
10021 + rc=OsFunc->DeviceFindParmValue(HalDev->DeviceInfo, channel_names[Ch], &ChInfo);
10022 + /* Do not fail if Channel Info not available for RC2 */
10023 + if (rc) return(0);
10024 +/* if (rc) return(EC_CPMAC|EC_FUNC_CHSETUP|EC_VAL_CH_INFO_NOT_FOUND);*/
10026 + /* i don't care if a value is not found because they are optional */
10027 + if(Direction == DIRECTION_TX)
10029 + rc=OsFunc->DeviceFindParmUint(ChInfo, "TxNumBuffers", &Value);
10030 + if (!rc) HalDev->ChData[Ch].TxNumBuffers = Value;
10032 + /*rc=OsFunc->DeviceFindParmUint(ChInfo, "TxNumQueues", &Value);*/ /*MJH-030329*/
10033 + /*if (!rc) HalDev->ChData[Ch].TxNumQueues = Value;*/ /*MJH-030329*/
10035 + rc=OsFunc->DeviceFindParmUint(ChInfo, "TxServiceMax", &Value);
10038 + HalDev->ChData[Ch].TxServiceMax = Value;
10039 + HalDev->TxIntThreshold[Ch] = HalDev->ChData[Ch].TxServiceMax;
10040 + HalDev->TxIntThresholdMaster[Ch] = HalDev->TxIntThreshold[Ch];
10043 + if(Direction == DIRECTION_RX)
10045 + rc=OsFunc->DeviceFindParmUint(ChInfo, "RxNumBuffers", &Value);
10046 + if (!rc) HalDev->ChData[Ch].RxNumBuffers = Value;
10048 + rc=OsFunc->DeviceFindParmUint(ChInfo, "RxBufferOffset", &Value);
10049 + if (!rc) HalDev->ChData[Ch].RxBufferOffset = Value;
10051 + rc=OsFunc->DeviceFindParmUint(ChInfo, "RxBufSize", &Value);
10052 + if (!rc) HalDev->ChData[Ch].RxBufSize = Value;
10054 + rc=OsFunc->DeviceFindParmUint(ChInfo, "RxServiceMax", &Value);
10055 + if (!rc) HalDev->ChData[Ch].RxServiceMax = Value;
10057 + return (EC_NO_ERRORS);
10059 +#define ChannelUpdate(Field) if(HalChn->Field != 0xFFFFFFFF) HalDev->ChData[Ch].Field = HalChn->Field
10061 +static void ChannelConfigUpdate(HAL_DEVICE *HalDev, CHANNEL_INFO *HalChn)
10063 + int Ch = HalChn->Channel;
10064 + int Direction = HalChn->Direction;
10065 +#ifdef __CPHAL_DEBUG
10068 + dbgPrintf("\nChnUpd-HalDev:%08X,Chn:%d:%d\n", (bit32u)HalDev, Ch, Direction); osfuncSioFlush();
10071 + if (Direction == DIRECTION_TX)
10073 + ChannelUpdate(TxNumBuffers);
10074 + /*ChannelUpdate(TxNumQueues);*/ /*MJH~030329*/
10075 + ChannelUpdate(TxServiceMax);
10076 + HalDev->TxIntThreshold[Ch] = HalDev->ChData[Ch].TxServiceMax;
10077 + HalDev->TxIntThresholdMaster[Ch] = HalDev->TxIntThreshold[Ch];
10080 + if (Direction == DIRECTION_RX)
10082 + ChannelUpdate(RxBufferOffset);
10083 + ChannelUpdate(RxBufSize);
10084 + ChannelUpdate(RxNumBuffers);
10085 + ChannelUpdate(RxServiceMax);
10086 +#ifdef __CPHAL_DEBUG
10089 + dbgPrintf("\nRxNumBuffers %d\n",HalChn->RxNumBuffers); osfuncSioFlush();
10094 +static int halChannelSetup(HAL_DEVICE *HalDev, CHANNEL_INFO *HalChn, OS_SETUP *OsSetup)
10100 + /* Verify proper device state */
10101 + if (HalDev->State < enInitialized)
10102 + return (EC_CPMAC|EC_FUNC_CHSETUP|EC_VAL_INVALID_STATE);
10104 + /* We require the channel structure to be passed, even if it only contains
10105 + the channel number */
10106 + if (HalChn == NULL)
10108 + return(EC_CPMAC|EC_FUNC_CHSETUP|EC_VAL_NULL_CH_STRUCT);
10111 + Ch = HalChn->Channel;
10112 + Direction = HalChn->Direction;
10114 + /* This should check on Maximum Channels for RX or TX,
10115 + they might be different Mick 021124 */
10116 + if ((Ch < 0) || (Ch > (MAX_CHAN-1)))
10118 + return(EC_CPMAC|EC_FUNC_CHSETUP|EC_VAL_INVALID_CH);
10121 + /* if channel is already open, this call is invalid */
10122 + if (HalDev->ChIsOpen[Ch][Direction] == TRUE)
10124 + return(EC_CPMAC|EC_FUNC_CHSETUP|EC_VAL_CH_ALREADY_OPEN);
10127 + /* channel is closed, but might be setup. If so, reopen the hardware channel. */
10128 + if (HalDev->ChIsSetup[Ch][Direction] == FALSE)
10130 + /* Setup channel configuration */
10131 + HalDev->ChData[Ch].Channel = Ch;
10133 + /* Store OS_SETUP */
10134 + HalDev->ChData[Ch].OsSetup = OsSetup;
10137 + Set Default Values
10138 + Update with options.conf
10139 + Apply driver updates
10141 + ChannelConfigInit(HalDev, HalChn);
10142 + ChannelConfigGet(HalDev, HalChn);
10143 + ChannelConfigUpdate(HalDev, HalChn);
10145 + /* cppi.c needs to use Rx/TxServiceMax */
10146 + HalDev->BuffersServicedMax = 169; /* TEMP */
10148 + HalDev->ChIsSetup[Ch][Direction] = TRUE;
10151 + rc = EC_NO_ERRORS;
10153 + /* If the hardware has been opened (is out of reset), then configure the channel
10154 + in the hardware. NOTE: ChannelConfigApply calls the CPSAR ChannelSetup()! */
10155 + if (HalDev->State == enOpened)
10157 + rc = ChannelConfigApply(HalDev, HalChn);
10164 +static int miiInfoGet(HAL_DEVICE *HalDev, bit32u *miiBaseAddress, bit32u *miiResetBit)
10167 + void *DeviceInfo;
10168 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
10170 + /* Only one instance of cpmdio */
10171 + rc = OsFunc->DeviceFindInfo(0,"cpmdio",&DeviceInfo); /*~RC3.02*/
10174 + return (EC_DEV_CPMDIO|EC_FUNC_OPEN|EC_VAL_DEVICE_NOT_FOUND );
10176 + rc = OsFunc->DeviceFindParmUint(DeviceInfo, "base",miiBaseAddress);
10178 + rc=EC_DEV_CPMDIO|EC_FUNC_OPEN|EC_VAL_NO_BASE;
10180 + rc = OsFunc->DeviceFindParmUint(DeviceInfo, "reset_bit",miiResetBit);
10182 + rc=EC_DEV_CPMDIO|EC_FUNC_OPEN|EC_VAL_NO_BASE;
10185 + /* See if need to make mdio functional in GPIO */
10186 + gpioCheck(HalDev, DeviceInfo);
10189 + dbgPrintf("miiBase: 0x%08X %u\n", *miiBaseAddress, *miiResetBit);
10192 +static void ephyCheck(HAL_DEVICE *HalDev)
10195 + void *DeviceInfo;
10198 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
10200 + rc = OsFunc->DeviceFindInfo(0,"ephy",&DeviceInfo);
10203 + rc = OsFunc->DeviceFindParmUint(DeviceInfo, "mii_phy",&mii_phy);
10206 + rc = OsFunc->DeviceFindParmUint(DeviceInfo, "reset_bit",&reset_bit);
10209 + if (HalDev->PhyMask & (1 << mii_phy))
10211 + *(volatile bit32u *)(HalDev->ResetBase) |= (1 << reset_bit); /*+RC3.02*/
10212 + resetWait(HalDev);
10215 +static void AutoNegotiate(HAL_DEVICE *HalDev)
10218 + bit32u ModID, RevMaj, RevMin;
10219 + PHY_DEVICE *PhyDev;
10220 + bit32u miiBaseAddress;
10221 + bit32u miiResetBit;
10223 + /* Verify proper device state */
10224 + if (HalDev->State < enOpened)
10227 + miiInfoGet(HalDev, &miiBaseAddress, &miiResetBit);
10229 + cpMacMdioGetVer(miiBaseAddress, &ModID, &RevMaj, &RevMin);
10230 + if(HalDev->debug)
10231 + dbgPrintf("Mdio Module Id %d, Version %d.%d\n", ModID, RevMaj, RevMin);
10233 + size = cpMacMdioGetPhyDevSize();
10234 + PhyDev = (PHY_DEVICE *) HalDev->OsFunc->Malloc( size );
10236 + HalDev->PhyDev = PhyDev;
10238 + ephyCheck(HalDev);
10240 + cpMacMdioInit( PhyDev, miiBaseAddress, HalDev->inst, HalDev->PhyMask, HalDev->MLinkMask, HalDev->MdixMask, HalDev->ResetBase, miiResetBit, HalDev->MdioBusFrequency, HalDev->MdioClockFrequency, HalDev->debug, HalDev); /*MJH~030402*/
10241 + MdioSetPhyMode(HalDev);
10245 +static int halOpen(HAL_DEVICE *HalDev)
10247 + unsigned char *MacAddr;
10252 + if (HalDev->debug)
10254 + dbgPrintf("halOpen: haldev:0x%08X inst:%d base:0x%08X reset:%d\n", (bit32u) &HalDev, HalDev->inst, HalDev->dev_base, HalDev->ResetBit);
10255 + osfuncSioFlush();
10258 + /* Verify proper device state */
10259 + if (HalDev->State < enInitialized)
10260 + return (EC_CPMAC|EC_FUNC_OPEN|EC_VAL_INVALID_STATE);
10263 + /* take CPMAC out of reset - GSG 11/20*/
10264 + if ((VOLATILE32(HalDev->ResetBase) & (1 << HalDev->ResetBit)) != 0)
10266 + /* perform normal close duties */
10267 + CPMAC_MACCONTROL(HalDev->dev_base) &= ~MII_EN;
10268 + CPMAC_TX_CONTROL(HalDev->dev_base) &= ~TX_EN;
10269 + CPMAC_RX_CONTROL(HalDev->dev_base) &= ~RX_EN;
10271 + /* disable interrupt masks */
10272 + CPMAC_TX_INTMASK_CLEAR(HalDev->dev_base) = 0xFF;
10273 + CPMAC_RX_INTMASK_CLEAR(HalDev->dev_base) = 0xFF;
10276 + /* take CPMAC out of reset */
10277 + *(volatile bit32u *)(HalDev->ResetBase) &= ~(1 << HalDev->ResetBit);
10278 + resetWait(HalDev);
10279 + *(volatile bit32u *)(HalDev->ResetBase) |= (1 << HalDev->ResetBit);
10280 + resetWait(HalDev);
10282 + /* After Reset clear the Transmit and Receive DMA Head Descriptor Pointers */
10284 + CPMAC_TX0_HDP(HalDev->dev_base)=0;
10285 + CPMAC_TX1_HDP(HalDev->dev_base)=0;
10286 + CPMAC_TX2_HDP(HalDev->dev_base)=0;
10287 + CPMAC_TX3_HDP(HalDev->dev_base)=0;
10288 + CPMAC_TX4_HDP(HalDev->dev_base)=0;
10289 + CPMAC_TX5_HDP(HalDev->dev_base)=0;
10290 + CPMAC_TX6_HDP(HalDev->dev_base)=0;
10291 + CPMAC_TX7_HDP(HalDev->dev_base)=0;
10295 + CPMAC_RX0_HDP(HalDev->dev_base) = 0;
10296 + CPMAC_RX1_HDP(HalDev->dev_base) = 0;
10297 + CPMAC_RX2_HDP(HalDev->dev_base) = 0;
10298 + CPMAC_RX3_HDP(HalDev->dev_base) = 0;
10299 + CPMAC_RX4_HDP(HalDev->dev_base) = 0;
10300 + CPMAC_RX5_HDP(HalDev->dev_base) = 0;
10301 + CPMAC_RX6_HDP(HalDev->dev_base) = 0;
10302 + CPMAC_RX7_HDP(HalDev->dev_base) = 0;
10304 + CPMAC_RX_BUFFER_OFFSET(HalDev->dev_base) = 0;
10306 + /* Init Tx and Rx DMA */
10308 + CPMAC_TX_CONTROL(HalDev->dev_base) |= TX_EN;
10309 + CPMAC_RX_CONTROL(HalDev->dev_base) |= RX_EN;
10311 + CPMAC_MAC_INTMASK_SET(HalDev->dev_base) |=2; /* Enable Adaptercheck Ints */
10312 + HalDev->OsFunc->Control(HalDev->OsDev, pszMacAddr, hcGet, &MacAddr); /* GSG 11/22 */
10313 + MacAddressSave(HalDev, MacAddr);
10315 + HalDev->HostErr = 0; /* Clear Adapter Check indicator */
10316 + HalDev->State = enOpened; /* Change device state */
10318 + /* Start MDIO Negotiation */
10319 + AutoNegotiate(HalDev);
10321 + /* Enable the Os Timer */
10322 + Ticks = HalDev->CpuFrequency / 100; /* 10 milli-secs */ /*MJH~030402*/
10323 + HalDev->OsFunc->Control(HalDev->OsDev, pszTick, hcSet, &Ticks); /* GSG 11/22 */
10324 + HalDev->OsFunc->IsrRegister(HalDev->OsDev, halIsr, HalDev->interrupt);
10326 + /* GSG +030523 Malloc space for the Rx fraglist */
10327 + HalDev->fraglist = HalDev->OsFunc->Malloc(HalDev->MaxFrags * sizeof(FRAGLIST));
10329 + /* Any pre-open configuration */
10331 + /* For any channels that have been pre-initialized, set them up now */
10332 + /* Note : This loop should not use MAX_CHN, it should only
10333 + loop through Channels Setup, memory should not be reserved
10334 + until Channel is Setup
10336 + for(i=0; i<MAX_CHAN; i++) /* i loops through Channels */
10337 + for(j=0; j<2; j++) /* j loops through DIRECTION values, 0 and 1 */
10339 + if(HalDev->ChIsSetup[i][j]==TRUE) /* If the Channel and Direction have been Setup */
10340 + if(HalDev->ChIsOpen[i][j]==FALSE) /* but not opened, then Apply Values now */
10342 + CHANNEL_INFO HalChn;
10343 + HalChn.Channel = i;
10344 + HalChn.Direction = j;
10345 + rc = ChannelConfigApply(HalDev, &HalChn);
10346 + if(rc != EC_NO_ERRORS)
10349 + } /* End of looping through Channel/Direction */
10351 + ConfigApply(HalDev); /* Apply Configuration Values to Device */
10352 + CPMAC_MACCONTROL(HalDev->dev_base) |= MII_EN; /* MAC_EN */
10354 + dbgPrintf("[halOpen]MacControl:%08X\n", CPMAC_MACCONTROL(HalDev->dev_base));
10355 + return(EC_NO_ERRORS);
10358 +#define INT_PENDING (MAC_IN_VECTOR_TX_INT_OR | MAC_IN_VECTOR_RX_INT_OR | MAC_IN_VECTOR_HOST_INT)
10359 +static int halShutdown(HAL_DEVICE *HalDev)
10361 + int Ch, Queue; /*GSG+030514*/
10363 + /* Verify proper device state */
10364 + if (HalDev->State == enOpened)
10365 + halClose(HalDev, 3); /* GSG ~030429 */
10367 + /* Buffer/descriptor resources may still need to be freed if a Close
10368 + Mode 1 was performed prior to Shutdown - clean up here */ /*GSG+030514*/
10369 + for (Ch=0; Ch<MAX_CHAN; Ch++)
10371 + if (HalDev->RcbStart[Ch] != 0)
10372 + FreeRx(HalDev,Ch);
10374 + for(Queue=0; Queue<MAX_QUEUE; Queue++)
10376 + if (HalDev->TcbStart[Ch][Queue] != 0)
10377 + FreeTx(HalDev,Ch,Queue);
10381 + /* free the HalFunc */
10382 + HalDev->OsFunc->Free(HalDev->HalFuncPtr);
10384 + /* free the HAL device */
10385 + HalDev->OsFunc->Free(HalDev);
10387 + return(EC_NO_ERRORS);
10389 +int halIsr(HAL_DEVICE *HalDev, int *MorePackets)
10393 + int PacketsServiced=0;
10395 + int TxMorePackets=0;
10396 + int RxMorePackets=0;
10398 + /* Verify proper device state - important because a call prior to Open would
10399 + result in a lockup */
10400 + if (HalDev->State != enOpened)
10401 + return(EC_CPMAC|EC_FUNC_DEVICE_INT|EC_VAL_INVALID_STATE);
10403 + IntVec = CPMAC_MAC_IN_VECTOR(HalDev->dev_base);
10405 +#ifdef __CPHAL_DEBUG
10408 + dbgPrintf("\nhalIsr: inst %d, IntVec 0x%X\n", HalDev->inst, IntVec); osfuncSioFlush();/* GSG 11/22 */
10412 + HalDev->IntVec = IntVec;
10413 + if (IntVec & MAC_IN_VECTOR_TX_INT_OR)
10415 + int TxServiceMax=0; /* Compiler complains if not initialized */
10417 + Channel = (IntVec & 0x7);
10419 + if(HalDev->TxIntDisable)
10421 + CPMAC_TX_INTMASK_CLEAR(HalDev->dev_base) = (1<<Channel); /* Disable Interrupt for Channel */
10422 + TxServiceMax = HalDev->ChData[Channel].TxServiceMax;
10423 + HalDev->ChData[Channel].TxServiceMax = 10000; /* Need to service all packets in the Queue */
10426 + PacketsServiced |= TxInt(HalDev, Channel, 0, &TxMorePackets);
10428 + if(HalDev->TxIntDisable)
10429 + HalDev->ChData[Channel].TxServiceMax = TxServiceMax;
10432 + if (IntVec & MAC_IN_VECTOR_RX_INT_OR)
10434 + Channel = (IntVec >> 8) & 0x7;
10435 + Serviced = RxInt(HalDev, Channel, &RxMorePackets);
10436 + PacketsServiced |= (Serviced<<16);
10439 + if (IntVec & MAC_IN_VECTOR_HOST_INT)
10441 + /* Adaptercheck */
10442 + HalDev->HostErr = 1;
10443 + HalDev->MacStatus = CPMAC_MACSTATUS(HalDev->dev_base);
10444 + osfuncStateChange(); /*MJH+030328*/
10447 + dbgPrintf("Adaptercheck: %08x for base:%X\n",HalDev->MacStatus, (bit32u)HalDev->dev_base);
10448 + osfuncSioFlush();
10451 + *MorePackets = (TxMorePackets | RxMorePackets);
10452 + return (PacketsServiced);
10455 +int halPacketProcessEnd(HAL_DEVICE *HalDev)
10457 + int base = HalDev->dev_base;
10458 + CPMAC_MAC_EOI_VECTOR(base) = 0;
10464 +static int PhyCheck(HAL_DEVICE *HalDev)
10466 + return(cpMacMdioTic(HalDev->PhyDev));
10468 +static int halTick(HAL_DEVICE *HalDev)
10472 + if(HalDev->State < enOpened)
10473 + return (EC_CPMAC|EC_FUNC_TICK|EC_VAL_INVALID_STATE);
10475 + /* if NO Phy no need to check Link */
10476 + if(HalDev->MdioConnect & _CPMDIO_NOPHY)
10477 + return(EC_NO_ERRORS); /* No change in Phy State detected */
10479 + TickChange = PhyCheck(HalDev);
10480 + /* Phy State Change Detected */
10481 + if(TickChange == 1)
10483 + /* MDIO indicated a change */
10484 + DuplexUpdate(HalDev);
10485 + osfuncStateChange();
10486 + return(EC_NO_ERRORS);
10489 + /* if in AutoMdix mode, and Flip request received, inform OS */
10490 + if( (HalDev->MdioConnect & _CPMDIO_AUTOMDIX) &&
10491 + (TickChange & _MIIMDIO_MDIXFLIP))
10494 + Mdix = TickChange & 0x1; /* Mdix mode stored in bit 0 */
10495 + HalDev->OsFunc->Control(HalDev->OsDev, hcMdioMdixSwitch, hcSet, &Mdix);
10496 + return(EC_NO_ERRORS);
10499 + return(EC_NO_ERRORS);
10502 +int halCpmacInitModule(HAL_DEVICE **pHalDev, OS_DEVICE *OsDev, HAL_FUNCTIONS **pHalFunc,
10503 + OS_FUNCTIONS *OsFunc, int OsFuncSize, int *HalFuncSize, int Inst)
10505 + HAL_DEVICE *HalDev;
10506 + HAL_FUNCTIONS *HalFunc;
10508 + if (OsFuncSize < sizeof(OS_FUNCTIONS))
10509 + return (EC_CPMAC|EC_FUNC_HAL_INIT|EC_VAL_OS_VERSION_NOT_SUPPORTED);
10511 + HalDev = (HAL_DEVICE *) OsFunc->MallocDev(sizeof(HAL_DEVICE));
10513 + return (EC_CPMAC|EC_FUNC_HAL_INIT|EC_VAL_MALLOC_DEV_FAILED);
10515 + /* clear the HalDev area */
10516 + OsFunc->Memset(HalDev, 0, sizeof(HAL_DEVICE));
10518 + /* Initialize the size of hal functions */
10519 + *HalFuncSize = sizeof (HAL_FUNCTIONS);
10521 + HalFunc = (HAL_FUNCTIONS *) OsFunc->Malloc(sizeof(HAL_FUNCTIONS));
10523 + return (EC_CPMAC|EC_FUNC_HAL_INIT|EC_VAL_MALLOC_FAILED);
10525 + /* clear the function pointers */
10526 + OsFunc->Memset(HalFunc, 0, sizeof(HAL_FUNCTIONS));
10528 + HalDev->OsDev = OsDev;
10529 + HalDev->OsOpen = OsDev;
10530 + HalDev->inst = Inst;
10531 + HalDev->OsFunc = OsFunc;
10532 + HalDev->HalFunc = HalFunc;
10533 + /* Remove the following from cppi, replace with HalFunc */
10534 + HalDev->HalFuncPtr = HalFunc; /* GSG 11/20 changed name to match cppi */
10536 + /****************************************************************/
10537 + /* POPULATE HALFUNC */
10538 + /****************************************************************/
10539 + HalFunc->ChannelSetup = halChannelSetup;
10540 + HalFunc->ChannelTeardown = halChannelTeardown; /* GSG 11/20 */
10541 + HalFunc->Close = halClose; /* GSG 11/20 */
10542 + HalFunc->Control = halControl; /* GSG 11/22 */
10543 + HalFunc->Init = halInit;
10544 + HalFunc->Open = halOpen;
10545 + HalFunc->PacketProcessEnd = halPacketProcessEnd;
10546 + HalFunc->Probe = halProbe;
10547 + HalFunc->RxReturn = halRxReturn;
10548 + HalFunc->Send = halSend;
10549 + HalFunc->Shutdown = halShutdown;
10550 + HalFunc->Tick = halTick;
10552 + /* HalFunc->Status = halStatus;*/ /* GSG 11/22 */
10553 + /* pass the HalDev and HalFunc back to the caller */
10555 + *pHalDev = HalDev;
10556 + *pHalFunc = HalFunc;
10558 + HalDev->State = enConnected; /* Initialize the hardware state */
10560 + if (HalDev->debug) HalDev->OsFunc->Printf("halCpmacInitModule: Leave\n");
10564 +int cpmacRandomRange(HAL_DEVICE *HalDev, int min, int max)
10567 + iTmp = cpmacRandom(HalDev);
10568 + iTmp %= ((max-min)+1);
10573 +int cpmacRandom(HAL_DEVICE *HalDev)
10576 + iTmp = CPMAC_BOFFTEST(HalDev->dev_base);
10577 + iTmp >>= 16; /* get rndnum field */
10578 + iTmp &= (0x3FF); /* field is 10 bits wide */
10581 diff -urN linux.old/drivers/net/avalanche_cpmac/hcpmac.h linux.dev/drivers/net/avalanche_cpmac/hcpmac.h
10582 --- linux.old/drivers/net/avalanche_cpmac/hcpmac.h 1970-01-01 01:00:00.000000000 +0100
10583 +++ linux.dev/drivers/net/avalanche_cpmac/hcpmac.h 2005-07-12 02:48:42.175574000 +0200
10585 +/** @file***********************************************************************
10586 + * TNETDxxxx Software Support
10587 + * Copyright (c) 2002 Texas Instruments Incorporated. All Rights Reserved.
10592 + * This file contains definitions for the HAL EMAC API
10595 + * xxXxx01 Denis 1.00 Original Version created.
10596 + * 22Jan02 Denis/Mick 1.01 Modified for HAL EMAC API
10597 + * 24Jan02 Denis/Mick 1.02 Speed Improvements
10598 + * 28Jan02 Denis/Mick 1.16 Made function calls pointers
10599 + * 28Jan02 Mick 1.18 Split into separate modules
10600 + * @author Michael Hanrahan
10602 + * @date 24-Jan-2002
10603 + *****************************************************************************/
10604 +#ifndef _INC_HCPMAC
10605 +#define _INC_HCPMAC
10607 +/** \namespace CPMAC_Version
10608 +This documents version 01.07.04 of the CPMAC CPHAL.
10610 +const char *pszVersion_CPMAC="CPMAC 01.07.08 "__DATE__" "__TIME__;
10612 +/* CHECK THESE LOCATIONS */
10613 +#define TEARDOWN_VAL 0xfffffffc
10614 +#define CB_OFFSET_MASK 0xFFFF0000
10617 +#define MAX_CHAN 8
10618 +#define MAX_QUEUE 1
10622 + bit32 HNext; /*< Hardware's pointer to next buffer descriptor */
10623 + bit32 BufPtr; /*< Pointer to the data buffer */
10624 + bit32 Off_BLen; /*< Contains buffer offset and buffer length */
10625 + bit32 mode; /*< SOP, EOP, Ownership, EOQ, Teardown, Q Starv, Length */
10629 +#ifdef __CPHAL_DEBUG
10632 + bit32 DbgFraglist;
10636 +typedef volatile struct hal_private
10638 + bit32 HNext; /*< Hardware's pointer to next buffer descriptor */
10639 + bit32 BufPtr; /*< Pointer to the data buffer */
10640 + bit32 Off_BLen; /*< Contains buffer offset and buffer length */
10641 + bit32 mode; /*< SOP, EOP, Ownership, EOQ, Teardown Complete bits */
10648 +#define MAX_NEEDS 512 /*MJH+030409*/
10651 +typedef struct hal_device
10653 + OS_DEVICE *OsDev;
10654 + OS_FUNCTIONS *OsFunc;
10655 + /*OS_SETUP *OsSetup;*/ /* -GSG 030508 */
10663 + bit32u ResetBase; /* GSG 10/20 */
10667 + PHY_DEVICE *PhyDev;
10668 + bit32u EmacDuplex;
10669 + bit32u EmacSpeed;
10671 + bit32u MLinkMask;
10676 + DEVICE_STATE State;
10677 + unsigned char *MacAddr;
10678 + HAL_FUNCTIONS *HalFuncPtr; /* GSG 11/20 changed name to match cppi */
10679 + HAL_FUNCTIONS *HalFunc;
10680 +/* unsigned int CpuFreq;*/ /*MJH-030402*/
10681 + unsigned int MdioConnect;
10682 + unsigned int HostErr;
10684 +/************************************************************************/
10686 +/* R E G I S T E R S */
10688 +/************************************************************************/
10690 + bit32u RxMbpEnable;
10691 + bit32u RxUnicastSet;
10692 + bit32u RxUnicastClear;
10694 + bit32u RxFilterLowThresh;
10695 + bit32u Rx0FlowThresh;
10696 + bit32u MacControl;
10697 + bit32u MacStatus;
10701 +/************************************************************************/
10703 +/* O P T I O N S */
10705 +/************************************************************************/
10707 + char *DeviceInfo;
10708 + bit32u interrupt;
10711 + bit32u RxPassCrc;
10715 + bit32u RxBcastCh;
10716 + HAL_RCB *RcbPool[MAX_CHAN];
10717 + bit32 RxActQueueCount[MAX_CHAN];
10718 + HAL_RCB *RxActQueueHead[MAX_CHAN];
10719 + HAL_RCB *RxActQueueTail[MAX_CHAN];
10720 + bit32 RxActive[MAX_CHAN];
10721 + HAL_TCB *TcbPool[MAX_CHAN][MAX_QUEUE];
10722 + bit32 TxActQueueCount[MAX_CHAN][MAX_QUEUE];
10723 + HAL_TCB *TxActQueueHead[MAX_CHAN][MAX_QUEUE];
10724 + HAL_TCB *TxActQueueTail[MAX_CHAN][MAX_QUEUE];
10725 + bit32 TxActive[MAX_CHAN][MAX_QUEUE];
10726 + bit32 TxTeardownPending[MAX_CHAN];
10727 + bit32 RxTeardownPending[MAX_CHAN];
10728 + bit32 ChIsOpen[MAX_CHAN][2];
10729 + bit32 ChIsSetup[MAX_CHAN][2];
10730 + FRAGLIST *fraglist;
10731 + char *TcbStart[MAX_CHAN][MAX_QUEUE];
10732 + char *RcbStart[MAX_CHAN];
10733 + bit32 RcbSize[MAX_CHAN];
10734 +/* STAT_INFO Stats; */
10736 + bit32u BuffersServicedMax;
10737 + CHANNEL_INFO ChData[MAX_CHAN];
10738 + bit32u MdioClockFrequency; /*MJH+030402*/
10739 + bit32u MdioBusFrequency; /*MJH+030402*/
10740 + bit32u CpuFrequency; /*MJH+030402*/
10741 + bit32u CpmacFrequency; /*MJH+030403*/
10742 + bit32u CpmacSize; /*MJH+030425*/
10744 + bit32u NeedsCount; /*MJH+030409*/
10745 + HAL_RECEIVEINFO *Needs[MAX_NEEDS]; /*MJH+030409*/
10747 + int TxIntThreshold[MAX_CHAN]; /* MJH 040621 NSP Performance Update */
10748 + int TxIntThresholdMaster[MAX_CHAN]; /* MJH 040827 NSP Performance Update */
10749 + int TxIntDisable; /* MJH 040621 NSP Performance Update */
10752 +#define STATS_MAX 36
10754 +#define MACCONTROL_MASK (TX_PTYPE|TX_PACE|TX_FLOW_EN|RX_FLOW_EN|CTRL_LOOPBACK)
10755 +#define RX_MBP_ENABLE_MASK \
10756 + (RX_PASS_CRC|RX_QOS_EN|RX_NO_CHAIN| \
10757 + RX_CMF_EN|RX_CSF_EN|RX_CEF_EN|RX_CAF_EN|RX_PROM_CH_MASK| \
10758 + RX_BROAD_EN|RX_BROAD_CH_MASK|RX_MULT_EN|RX_MULT_CH_MASK)
10761 +#define MBP_UPDATE(Mask, On) \
10762 + if(On) HalDev->RxMbpEnable |= Mask; \
10763 + else HalDev->RxMbpEnable &= ~Mask
10765 +#define CONTROL_UPDATE(Mask, On) \
10766 + if(On) HalDev->MacControl |= Mask; \
10767 + else HalDev->MacControl &= ~Mask
10770 +#define UPDATE_TX_PTYPE(Value) CONTROL_UPDATE(TX_PTYPE,Value)
10771 +#define UPDATE_TX_PACE(Value) CONTROL_UPDATE(TX_PACE,Value)
10772 +#define UPDATE_MII_EN(Value) CONTROL_UPDATE(MII_EN,Value)
10773 +#define UPDATE_TX_FLOW_EN(Value) CONTROL_UPDATE(TX_FLOW_EN,Value)
10774 +#define UPDATE_RX_FLOW_EN(Value) CONTROL_UPDATE(RX_FLOW_EN,Value)
10775 +#define UPDATE_CTRL_LOOPBACK(Value) CONTROL_UPDATE(CTRL_LOOPBACK,Value)
10776 +#define UPDATE_FULLDUPLEX(Value) CONTROL_UPDATE(FULLDUPLEX,(Value))
10778 +#define UPDATE_RX_PASS_CRC(Value) MBP_UPDATE(RX_PASS_CRC, Value)
10779 +#define UPDATE_RX_QOS_EN(Value) MBP_UPDATE(RX_QOS_EN, Value)
10780 +#define UPDATE_RX_NO_CHAIN(Value) MBP_UPDATE(RX_NO_CHAIN, Value)
10781 +#define UPDATE_RX_CMF_EN(Value) MBP_UPDATE(RX_CMF_EN, Value)
10782 +#define UPDATE_RX_CSF_EN(Value) MBP_UPDATE(RX_CSF_EN, Value)
10783 +#define UPDATE_RX_CEF_EN(Value) MBP_UPDATE(RX_CEF_EN, Value)
10784 +#define UPDATE_RX_CAF_EN(Value) MBP_UPDATE(RX_CAF_EN, Value)
10785 +#define UPDATE_RX_BROAD_EN(Value) MBP_UPDATE(RX_BROAD_EN, Value)
10786 +#define UPDATE_RX_MULT_EN(Value) MBP_UPDATE(RX_MULT_EN, Value)
10788 +#define UPDATE_RX_PROM_CH(Value) \
10789 + HalDev->RxMbpEnable &= ~RX_PROM_CH_MASK; \
10790 + HalDev->RxMbpEnable |= RX_PROM_CH(Value)
10792 +#define UPDATE_RX_BROAD_CH(Value) \
10793 + HalDev->RxMbpEnable &= ~RX_BROAD_CH_MASK; \
10794 + HalDev->RxMbpEnable |= RX_BROAD_CH(Value)
10796 +#define UPDATE_RX_MULT_CH(Value) \
10797 + HalDev->RxMbpEnable &= ~RX_MULT_CH_MASK; \
10798 + HalDev->RxMbpEnable |= RX_MULT_CH(Value)
10834 + enRX_FILTERLOWTHRESH,
10835 + enRX0_FLOWTHRESH,
10836 + enRX_UNICAST_SET,
10837 + enRX_UNICAST_CLEAR,
10843 + enRX_MULTI_SINGLE,
10845 + enCpmacEnd /* Last entry */
10848 +static const char pszVersion[] = "Version";
10849 +static const char pszStats0[] = "Stats0";
10850 +static const char pszStats1[] = "Stats1";
10851 +static const char pszStats2[] = "Stats2";
10852 +static const char pszStats3[] = "Stats3";
10853 +static const char pszStats4[] = "Stats4";
10854 +static const char pszStatsDump[] = "StatsDump";
10855 +static const char pszStatsClear[] = "StatsClear";
10857 +/********************************************************************
10861 +********************************************************************/
10862 +static const char pszRX_PASS_CRC[] = "RX_PASS_CRC";
10863 +static const char pszRX_QOS_EN[] = "RX_QOS_EN";
10864 +static const char pszRX_NO_CHAIN[] = "RX_NO_CHAIN";
10865 +static const char pszRX_CMF_EN[] = "RX_CMF_EN";
10866 +static const char pszRX_CSF_EN[] = "RX_CSF_EN";
10867 +static const char pszRX_CEF_EN[] = "RX_CEF_EN";
10868 +static const char pszRX_CAF_EN[] = "RX_CAF_EN";
10869 +static const char pszRX_PROM_CH[] = "RX_PROM_CH";
10870 +static const char pszRX_BROAD_EN[] = "RX_BROAD_EN";
10871 +static const char pszRX_BROAD_CH[] = "RX_BROAD_CH";
10872 +static const char pszRX_MULT_EN[] = "RX_MULT_EN";
10873 +static const char pszRX_MULT_CH[] = "RX_MULT_CH";
10876 +/********************************************************************
10880 +********************************************************************/
10881 +static const char pszTX_PTYPE[] = "TX_PTYPE";
10882 +static const char pszTX_PACE[] = "TX_PACE";
10883 +static const char pszMII_EN[] = "MII_EN";
10884 +static const char pszTX_FLOW_EN[] = "TX_FLOW_EN";
10885 +static const char pszRX_FLOW_EN[] = "RX_FLOW_EN";
10886 +static const char pszCTRL_LOOPBACK[] = "CTRL_LOOPBACK";
10888 +static const char pszRX_MAXLEN[] = "RX_MAXLEN";
10889 +static const char pszRX_FILTERLOWTHRESH[] = "RX_FILTERLOWTHRESH";
10890 +static const char pszRX0_FLOWTHRESH[] = "RX0_FLOWTHRESH";
10891 +static const char pszRX_UNICAST_SET[] = "RX_UNICAST_SET";
10892 +static const char pszRX_UNICAST_CLEAR[] = "RX_UNICAST_CLEAR";
10893 +static const char pszMdioConnect[] = "MdioConnect";
10894 +static const char pszMacAddr[] = "MacAddr";
10895 +static const char pszTick[] = "Tick";
10897 +/********************************************************************
10901 +********************************************************************/
10903 +static const char pszRX_MULTICAST[] = "RX_MULTICAST";
10904 +static const char pszRX_MULTI_ALL[] = "RX_MULTI_ALL";
10905 +static const char pszRX_MULTI_SINGLE[] = "RX_MULTI_SINGLE";
10908 +static const char* pszGFHN = "GFHN";
10911 +static const CONTROL_KEY KeyCpmac[] =
10913 + {"" , enCpmacStart},
10914 + {pszStats0 , enStats0},
10915 + {pszStats1 , enStats1},
10916 + {pszStats2 , enStats2},
10917 + {pszStats3 , enStats3},
10918 + {pszStats4 , enStats4},
10919 + {pszStatsClear , enStatsClear},
10920 + {pszStatsDump , enStatsDump},
10921 + {pszRX_PASS_CRC , enRX_PASS_CRC},
10922 + {pszRX_QOS_EN , enRX_QOS_EN},
10923 + {pszRX_NO_CHAIN , enRX_NO_CHAIN},
10924 + {pszRX_CMF_EN , enRX_CMF_EN},
10925 + {pszRX_CSF_EN , enRX_CSF_EN},
10926 + {pszRX_CEF_EN , enRX_CEF_EN},
10927 + {pszRX_CAF_EN , enRX_CAF_EN},
10928 + {pszRX_PROM_CH , enRX_PROM_CH},
10929 + {pszRX_BROAD_EN , enRX_BROAD_EN},
10930 + {pszRX_BROAD_CH , enRX_BROAD_CH},
10931 + {pszRX_MULT_EN , enRX_MULT_EN},
10932 + {pszRX_MULT_CH , enRX_MULT_CH},
10934 + {pszTX_PTYPE , enTX_PTYPE},
10935 + {pszTX_PACE , enTX_PACE},
10936 + {pszMII_EN , enMII_EN},
10937 + {pszTX_FLOW_EN , enTX_FLOW_EN},
10938 + {pszRX_FLOW_EN , enRX_FLOW_EN},
10939 + {pszCTRL_LOOPBACK , enCTRL_LOOPBACK},
10940 + {pszRX_MAXLEN , enRX_MAXLEN},
10941 + {pszRX_FILTERLOWTHRESH , enRX_FILTERLOWTHRESH},
10942 + {pszRX0_FLOWTHRESH , enRX0_FLOWTHRESH},
10943 + {pszRX_UNICAST_SET , enRX_UNICAST_SET},
10944 + {pszRX_UNICAST_CLEAR , enRX_UNICAST_CLEAR},
10945 + {pszMdioConnect , enMdioConnect},
10946 + {pszRX_MULTICAST , enRX_MULTICAST},
10947 + {pszRX_MULTI_ALL , enRX_MULTI_ALL},
10948 + {pszRX_MULTI_SINGLE , enRX_MULTI_SINGLE},
10949 + {pszTick , enTick},
10950 + {pszVersion , enVersion},
10951 + {"" , enCpmacEnd}
10954 +const char hcCpuFrequency[] = "CpuFreq";
10955 +const char hcCpmacFrequency[] = "CpmacFrequency";
10956 +const char hcMdioBusFrequency[] = "MdioBusFrequency";
10957 +const char hcMdioClockFrequency[] = "MdioClockFrequency";
10958 +const char hcCpmacBase[] = "CpmacBase";
10959 +const char hcPhyNum[] = "PhyNum";
10960 +const char hcSize[] = "size";
10961 +const char hcCpmacSize[] = "CpmacSize";
10962 +const char hcPhyAccess[] = "PhyAccess";
10963 +const char hcLinked[] = "Linked";
10964 +const char hcFullDuplex[] = "FullDuplex";
10965 +const char hcMdixMask[] = "MdixMask";
10966 +const char hcMdioMdixSwitch[] = "MdixSet";
10968 diff -urN linux.old/drivers/net/avalanche_cpmac/Makefile linux.dev/drivers/net/avalanche_cpmac/Makefile
10969 --- linux.old/drivers/net/avalanche_cpmac/Makefile 1970-01-01 01:00:00.000000000 +0100
10970 +++ linux.dev/drivers/net/avalanche_cpmac/Makefile 2005-07-12 02:48:42.175574000 +0200
10972 +# File: drivers/net/avalanche_cpmac/Makefile
10974 +# Makefile for the Linux network (CPMAC) device drivers.
10977 +O_TARGET := avalanche_cpmac.o
10980 +list-multi := avalanche_cpmac.o
10981 +obj-$(CONFIG_MIPS_AVALANCHE_CPMAC) := avalanche_cpmac.o
10983 +avalanche_cpmac-objs += cpmac.o cpmacHalLx.o hcpmac.o \
10984 + psp_config_build.o psp_config_mgr.o \
10985 + psp_config_parse.o psp_config_util.o
10988 +include $(TOPDIR)/Rules.make
10991 +avalanche_cpmac.o: $(avalanche_cpmac-objs)
10992 + $(LD) -r -o $@ $(avalanche_cpmac-objs)
10997 + rm -f core *.o *.a *.s
10998 diff -urN linux.old/drivers/net/avalanche_cpmac/mdio_reg.h linux.dev/drivers/net/avalanche_cpmac/mdio_reg.h
10999 --- linux.old/drivers/net/avalanche_cpmac/mdio_reg.h 1970-01-01 01:00:00.000000000 +0100
11000 +++ linux.dev/drivers/net/avalanche_cpmac/mdio_reg.h 2005-07-12 02:48:42.176573000 +0200
11002 +/****************************************************************************
11003 +** TNETD53xx Software Support
11004 +** Copyright(c) 2002, Texas Instruments Incorporated. All Rights Reserved.
11006 +** FILE: mdio_reg.h Register definitions for the VBUS MII module
11009 +** This include file contains register definitions for the
11010 +** VBUS MII module.
11013 +** 27Mar02 Michael Hanrahan Original (modified from emacmdio.h)
11014 +** 01Apr02 Michael Hanrahan Modified to include all regs. in spec
11015 +** 03Apr02 Michael Hanrahan Updated to Version 0.6 of spec
11016 +** 05Apr02 Michael Hanrahan Moved Phy Mode values into here
11017 +** 30Apr02 Michael Hanrahan Updated to Version 0.8 of spec
11018 +** 30Apr02 Michael Hanrahan Updated to recommended format
11019 +** 10May02 Michael Hanrahan Updated to Version 0.9 of spec
11020 +*****************************************************************************/
11021 +#ifndef _INC_MDIO_REG
11022 +#define _INC_MDIO_REG
11024 +/***************************************************************************
11026 +** M D I O M E M O R Y M A P
11028 +***************************************************************************/
11031 +#define pMDIO_VER(base) ((volatile bit32u *)(base+0x00))
11032 +#define pMDIO_CONTROL(base) ((volatile bit32u *)(base+0x04))
11033 +#define pMDIO_ALIVE(base) ((volatile bit32u *)(base+0x08))
11034 +#define pMDIO_LINK(base) ((volatile bit32u *)(base+0x0C))
11035 +#define pMDIO_LINKINTRAW(base) ((volatile bit32u *)(base+0x10))
11036 +#define pMDIO_LINKINTMASKED(base) ((volatile bit32u *)(base+0x14))
11037 +#define pMDIO_USERINTRAW(base) ((volatile bit32u *)(base+0x20))
11038 +#define pMDIO_USERINTMASKED(base) ((volatile bit32u *)(base+0x24))
11039 +#define pMDIO_USERINTMASKED_SET(base) ((volatile bit32u *)(base+0x28))
11040 +#define pMDIO_USERINTMASKED_CLR(base) ((volatile bit32u *)(base+0x2C))
11041 +#define pMDIO_USERACCESS(base, channel) ((volatile bit32u *)(base+(0x80+(channel*8))))
11042 +#define pMDIO_USERPHYSEL(base, channel) ((volatile bit32u *)(base+(0x84+(channel*8))))
11045 +/***************************************************************************
11047 +** M D I O R E G I S T E R A C C E S S M A C R O S
11049 +***************************************************************************/
11052 +#define MDIO_ALIVE(base) (*(pMDIO_ALIVE(base)))
11053 +#define MDIO_CONTROL(base) (*(pMDIO_CONTROL(base)))
11054 +#define MDIO_CONTROL_IDLE (1 << 31)
11055 +#define MDIO_CONTROL_ENABLE (1 << 30)
11056 +#define MDIO_CONTROL_PREAMBLE (1 << 20)
11057 +#define MDIO_CONTROL_FAULT (1 << 19)
11058 +#define MDIO_CONTROL_FAULT_DETECT_ENABLE (1 << 18)
11059 +#define MDIO_CONTROL_INT_TEST_ENABLE (1 << 17)
11060 +#define MDIO_CONTROL_HIGHEST_USER_CHANNEL (0x1F << 8)
11061 +#define MDIO_CONTROL_CLKDIV (0xFF)
11062 +#define MDIO_LINK(base) (*(pMDIO_LINK(base)))
11063 +#define MDIO_LINKINTRAW(base) (*(pMDIO_LINKINTRAW(base)))
11064 +#define MDIO_LINKINTMASKED(base) (*(pMDIO_LINKINTMASKED(base)))
11065 +#define MDIO_USERINTRAW(base) (*(pMDIO_USERINTRAW(base)))
11066 +#define MDIO_USERINTMASKED(base) (*(pMDIO_USERINTMASKED(base)))
11067 +#define MDIO_USERINTMASKED_CLR(base) (*(pMDIO_USERINTMASKED_CLR(base)))
11068 +#define MDIO_USERINTMASKED_SET(base) (*(pMDIO_USERINTMASKED_SET(base)))
11069 +#define MDIO_USERINTRAW(base) (*(pMDIO_USERINTRAW(base)))
11070 +#define MDIO_USERACCESS(base, channel) (*(pMDIO_USERACCESS(base, channel)))
11071 +#define MDIO_USERACCESS_GO (1 << 31)
11072 +#define MDIO_USERACCESS_WRITE (1 << 30)
11073 +#define MDIO_USERACCESS_READ (0 << 30)
11074 +#define MDIO_USERACCESS_ACK (1 << 29)
11075 +#define MDIO_USERACCESS_REGADR (0x1F << 21)
11076 +#define MDIO_USERACCESS_PHYADR (0x1F << 16)
11077 +#define MDIO_USERACCESS_DATA (0xFFFF)
11078 +#define MDIO_USERPHYSEL(base, channel) (*(pMDIO_USERPHYSEL(base, channel)))
11079 +#define MDIO_USERPHYSEL_LINKSEL (1 << 7)
11080 +#define MDIO_USERPHYSEL_LINKINT_ENABLE (1 << 6)
11081 +#define MDIO_USERPHYSEL_PHYADR_MON (0x1F)
11082 +#define MDIO_VER(base) (*(pMDIO_VER(base)))
11083 +#define MDIO_VER_MODID (0xFFFF << 16)
11084 +#define MDIO_VER_REVMAJ (0xFF << 8)
11085 +#define MDIO_VER_REVMIN (0xFF)
11090 +/****************************************************************************/
11092 +/* P H Y R E G I S T E R D E F I N I T I O N S */
11094 +/****************************************************************************/
11097 +#define PHY_CONTROL_REG 0
11098 + #define PHY_RESET (1<<15)
11099 + #define PHY_LOOP (1<<14)
11100 + #define PHY_100 (1<<13)
11101 + #define AUTO_NEGOTIATE_EN (1<<12)
11102 + #define PHY_PDOWN (1<<11)
11103 + #define PHY_ISOLATE (1<<10)
11104 + #define RENEGOTIATE (1<<9)
11105 + #define PHY_FD (1<<8)
11107 +#define PHY_STATUS_REG 1
11108 + #define NWAY_COMPLETE (1<<5)
11109 + #define NWAY_CAPABLE (1<<3)
11110 + #define PHY_LINKED (1<<2)
11112 +#define NWAY_ADVERTIZE_REG 4
11113 +#define NWAY_REMADVERTISE_REG 5
11114 + #define NWAY_FD100 (1<<8)
11115 + #define NWAY_HD100 (1<<7)
11116 + #define NWAY_FD10 (1<<6)
11117 + #define NWAY_HD10 (1<<5)
11118 + #define NWAY_SEL (1<<0)
11119 + #define NWAY_AUTO (1<<0)
11122 +#endif _INC_MDIO_REG
11123 diff -urN linux.old/drivers/net/avalanche_cpmac/psp_config_build.c linux.dev/drivers/net/avalanche_cpmac/psp_config_build.c
11124 --- linux.old/drivers/net/avalanche_cpmac/psp_config_build.c 1970-01-01 01:00:00.000000000 +0100
11125 +++ linux.dev/drivers/net/avalanche_cpmac/psp_config_build.c 2005-07-12 02:48:42.176573000 +0200
11127 +/******************************************************************************
11128 + * FILE PURPOSE: PSP Config Manager - Configuration Build Source
11129 + ******************************************************************************
11130 + * FILE NAME: psp_config_build.c
11132 + * DESCRIPTION: Configuration Build API Implementation
11134 + * REVISION HISTORY:
11135 + * 27 Nov 02 - PSP TII
11137 + * (C) Copyright 2002, Texas Instruments, Inc
11138 + *******************************************************************************/
11140 +#ifdef INCLUDE_FFS
11142 +#endif /* INCLUDE_FFS */
11144 +#include "psp_config_mgr.h"
11145 +#include "psp_config_build.h"
11146 +#include "psp_config_util.h"
11148 +#define MAX_DEVICE_NAME_LEN 16
11149 +#define MAX_DEVICE_STR_LEN 512
11152 +#define NULL (char *)0
11155 +#include <asm/ar7/sangam.h>
11156 +#include <linux/slab.h>
11157 +#include <linux/config.h>
11160 +#define os_malloc(size) kmalloc(size, GFP_KERNEL)
11162 +int psp_run_enumerator(void)
11167 +#if defined (CONFIG_AVALANCHE_CPMAC_AUTO)
11169 +static int auto_detect_cpmac_phy(void)
11172 +#define SELECT_INT_PHY_MAC 0
11173 +#define SELECT_EXT_PHY_MAC 1
11175 + volatile unsigned long *reset_cntl = AVALANCHE_RESET_CONTROL_BASE, *mdio_cntl = ((int)AVALANCHE_MDIO_BASE + 0x4);
11176 + unsigned int j= 0, detected_phy_map = 0, auto_select = SELECT_INT_PHY_MAC;
11178 + *reset_cntl |= (1 << AVALANCHE_MDIO_RESET_BIT) | (1 << AVALANCHE_LOW_CPMAC_RESET_BIT) | (1 << AVALANCHE_HIGH_CPMAC_RESET_BIT) | (1 << AVALANCHE_LOW_EPHY_RESET_BIT);
11179 + *mdio_cntl = (1 << 30) | ((CONFIG_AR7_SYS_FREQUENCY * 1000)/2200);
11181 + for(j=0;j < 300000; j++)
11183 + if(j%100000) continue;
11185 + detected_phy_map = *(mdio_cntl + 1);
11186 + if(detected_phy_map)
11188 + detected_phy_map &= ~AVALANCHE_LOW_CPMAC_PHY_MASK;
11190 + if(detected_phy_map && !(detected_phy_map & (detected_phy_map - 1)))
11192 + auto_select = SELECT_EXT_PHY_MAC;
11198 + return(auto_select);
11205 +#ifndef AVALANCHE_LOW_CPMAC_MDIX_MASK
11206 +#define AVALANCHE_LOW_CPMAC_MDIX_MASK 0
11209 +void psp_load_default_static_cfg(void)
11211 + char s2[100], s3[100];
11212 + char s4[2000], s6[2000];
11213 + int threshold = 20;
11214 + char *tx_threshold_ptr = prom_getenv("threshold");
11216 + if(tx_threshold_ptr)
11217 + threshold = simple_strtol(tx_threshold_ptr, (char **)NULL, 10);
11219 + /* Static configuration if options.conf not present */
11220 + sprintf(s3,"cpmdio(id=mii, base=%u, reset_bit=%d)", AVALANCHE_MDIO_BASE, 22);
11221 + sprintf(s2, "reset( id=[ResetRegister], base=%u)", AVALANCHE_RESET_CONTROL_BASE);
11223 + sprintf(s4, "cpmac(id=[cpmac], unit=0, base=%u, size=0x800, reset_bit=%d, PhyMask=%u, MdixMask=%u, MLink=0, int_line=%d, memory_offset=0, RX_CAF=1, RX_PASSCRC=0, RX_CEF=1, RX_BCAST=0, RX_BCASTCH=0, Ch0=[TxNumBuffers=256, TxNumQueues=1, TxServiceMax=%d, RxNumBuffers=256, RxBufferOffset=0, RxBufSize=1000, RxServiceMax=128], Ch1=[TxNumBuffers=256, TxNumQueues=1, TxServiceMax=%d, RxNumBuffers=256, RxBufferOffset=0, RxBufSize=1000, RxServiceMax=128], Ch2=[TxNumBuffers=256, TxNumQueues=1, TxServiceMax=%d, RxNumBuffers=256, RxBufferOffset=0, RxBufSize=1000, RxServiceMax=128])", AVALANCHE_LOW_CPMAC_BASE, AVALANCHE_LOW_CPMAC_RESET_BIT, AVALANCHE_LOW_CPMAC_PHY_MASK, AVALANCHE_LOW_CPMAC_MDIX_MASK, AVALANCHE_LOW_CPMAC_INT,threshold,threshold,threshold);
11225 + sprintf(s6, "cpmac(id=[cpmac], unit=1, base=%u, size=0x800, reset_bit=%d, PhyMask=%u, MLink=0, int_line=%d, memory_offset=0, RX_CAF=1, RX_PASSCRC=0, RX_CEF=1, RX_BCAST=0, RX_BCASTCH=0, Ch0=[TxNumBuffers=256, TxNumQueues=1, TxServiceMax=%d, RxNumBuffers=256, RxBufferOffset=0, RxBufSize=1000, RxServiceMax=128], Ch1=[TxNumBuffers=256, TxNumQueues=1, TxServiceMax=%d, RxNumBuffers=256, RxBufferOffset=0, RxBufSize=1000, RxServiceMax=128], Ch2=[TxNumBuffers=256, TxNumQueues=1, TxServiceMax=%d, RxNumBuffers=256, RxBufferOffset=0, RxBufSize=1000, RxServiceMax=128])", AVALANCHE_HIGH_CPMAC_BASE, AVALANCHE_HIGH_CPMAC_RESET_BIT, AVALANCHE_HIGH_CPMAC_PHY_MASK, AVALANCHE_HIGH_CPMAC_INT,threshold,threshold,threshold);
11227 + psp_config_add("reset", s2, psp_config_strlen(s2), en_compile);
11230 +#if defined (CONFIG_AVALANCHE_LOW_CPMAC)
11232 + psp_config_add("cpmdio", s3, psp_config_strlen(s3), en_compile);
11233 + psp_config_add("cpmac", s4, psp_config_strlen(s4), en_compile);
11238 +#if defined (CONFIG_AVALANCHE_HIGH_CPMAC)
11240 + psp_config_add("cpmdio", s3, psp_config_strlen(s3), en_compile);
11241 + psp_config_add("cpmac", s6, psp_config_strlen(s6), en_compile);
11245 +#if defined (CONFIG_AVALANCHE_CPMAC_AUTO)
11247 + char *phy_sel_ptr = prom_getenv("mac_phy_sel");
11248 + int phy_sel = SELECT_EXT_PHY_MAC;
11249 + char *mac_port = prom_getenv("MAC_PORT"); /* Internal: 0, External: 1 */
11251 + if(phy_sel_ptr && (0 == strcmp(phy_sel_ptr, "int")))
11253 + phy_sel = SELECT_INT_PHY_MAC;
11256 + //if(phy_sel == auto_detect_cpmac_phy())
11257 + if(!mac_port || (0 != strcmp(mac_port, "0")))
11259 + printk("Using the MAC with external PHY\n");
11260 + psp_config_add("cpmdio", s3, psp_config_strlen(s3), en_compile);
11261 + psp_config_add("cpmac", s6, psp_config_strlen(s6), en_compile);
11265 + printk("Using the MAC with internal PHY\n");
11266 + psp_config_add("cpmdio", s3, psp_config_strlen(s3), en_compile);
11267 + psp_config_add("cpmac", s4, psp_config_strlen(s4), en_compile);
11275 +char* psp_conf_read_file(char *p_file_name)
11277 +#ifdef INCLUDE_FFS
11279 + char *p_file_data = NULL;
11280 + unsigned int file_size;
11281 + FFS_FILE *p_file = NULL;
11283 + if(p_file_name == NULL)
11288 + if(!(p_file = ffs_fopen(p_file_name, "r")))
11293 + file_size = p_file->_AvailableBytes;
11295 + p_file_data = os_malloc(file_size + 1);
11297 + if(ffs_fread(p_file_data, file_size, 1, p_file) == 0)
11299 + kfree(p_file_data);
11303 + ffs_fclose(p_file);
11305 + p_file_data[file_size] = '\0';
11307 + return(p_file_data);
11309 +#else /* NO FFS */
11311 +#endif /* INCLUDE_FFS */
11314 +int psp_conf_get_line(char *p_in_data, char **next_line)
11316 + char *p = p_in_data;
11318 + while(*p && *p++ != '\n')
11325 + return(p - 1 - p_in_data);
11329 +int psp_conf_is_data_line(char *line)
11333 + if(*line == '\0' || *line == '\n' || *line == '#')
11339 +int psp_conf_get_key_size(char *data)
11343 + while(*p && *p != '\n' && *p != '(' && *p != ' ')
11346 + return(p - data);
11349 +char* psp_conf_eat_white_spaces(char *p)
11351 + while(*p && *p != '\n' && *p == ' ')
11357 +int psp_build_from_opt_conf(void)
11359 + char *data = NULL;
11360 + char *data_hold = NULL;
11361 + char *next_line = NULL;
11362 + int line_size = 0;
11364 + if((data = psp_conf_read_file("/etc/options.conf")) == NULL)
11367 + data_hold = data;
11369 + while((line_size=psp_conf_get_line(data, &next_line)) != -1)
11372 + char *name = NULL;
11375 + data = psp_conf_eat_white_spaces(data);
11377 + if(psp_conf_is_data_line(data))
11379 + data[line_size] = '\0';
11381 + name_size = psp_conf_get_key_size(data);
11383 + if(name_size > 0)
11385 + name = (char *) os_malloc(name_size + 1);
11386 + if(name == NULL) break;
11388 + psp_config_memcpy(name, data, name_size);
11389 + name[name_size] = '\0';
11391 + psp_config_add(name, data, line_size, en_opt_conf);
11396 + data[line_size] = '\n';
11399 + data = next_line;
11402 + kfree(data_hold);
11407 +int psp_write_conf_file(char *p_write_file, char * dev_cfg_string)
11409 +#ifdef INCLUDE_FFS
11410 + int bytes_written=0;
11411 + FFS_FILE *file_ptr=NULL;
11414 + * NOTE: In current implementation of FFS in ADAM2 if the file exists beforehand, it
11415 + * can't be opened for write.
11417 + if(!(file_ptr=ffs_fopen(p_write_file, "w"))) {
11421 + /* Write into the file "output.con" the character string */
11422 + /* write a \n before a writing a line */
11423 + if(!(bytes_written = ffs_fwrite("\n", 1, sizeof(char), file_ptr))) {
11427 + if(!(bytes_written = ffs_fwrite(dev_cfg_string, psp_config_strlen(dev_cfg_string), sizeof(char), file_ptr))) {
11430 + ffs_fclose(file_ptr);
11431 + return (bytes_written+1);
11432 +#else /* NO FFS */
11434 +#endif /* INCLUDE_FFS */
11437 +void build_psp_config(void)
11440 + /* initialize the repository. */
11441 + psp_config_init();
11443 +#ifdef INCLUDE_FFS
11445 +#endif /* INCLUDE_FFS */
11447 + /* read the configuration from the options.conf to override default ones */
11448 + psp_build_from_opt_conf();
11450 + /* read the configuration which were not over ridden in options.conf */
11451 + psp_load_default_static_cfg();
11453 + /* let the vlynq be enumerated. Enumerator will add cfg info
11454 + of the discovered device instances to the repository.*/
11455 + psp_run_enumerator();
11457 + /* dump the repository*/
11458 + dump_device_cfg_pool();
11462 diff -urN linux.old/drivers/net/avalanche_cpmac/psp_config_build.h linux.dev/drivers/net/avalanche_cpmac/psp_config_build.h
11463 --- linux.old/drivers/net/avalanche_cpmac/psp_config_build.h 1970-01-01 01:00:00.000000000 +0100
11464 +++ linux.dev/drivers/net/avalanche_cpmac/psp_config_build.h 2005-07-12 02:48:42.176573000 +0200
11466 +/******************************************************************************
11467 + * FILE PURPOSE: PSP Config Manager - Configuration Build Header
11468 + ******************************************************************************
11469 + * FILE NAME: psp_config_build.h
11471 + * DESCRIPTION: Configuration Build API's.
11473 + * REVISION HISTORY:
11474 + * 27 Nov 02 - PSP TII
11476 + * (C) Copyright 2002, Texas Instruments, Inc
11477 + *******************************************************************************/
11479 +#ifndef __PSP_CONF_BUILD_H__
11480 +#define __PSP_CONF_BUILD_H__
11482 +/*------------------------------------------------------------------------------
11483 + * Name: psp_conf_read_file
11486 + * in: p_file_name - the name of the file to read from.
11489 + * Reads the entire file in one shot. This function opens the
11490 + * file, determines the size of the data to be read, allocates
11491 + * the required memory, NULL terminates the data and closes the
11494 + * It is responsibily of the callee to free the memory after it is
11495 + * done with that data.
11499 + * A NULL pointer, if failed to read the data otherwise, a valid
11500 + * pointer referring to the data read from the file.
11504 + * psp_conf_read_file("/etc/options.conf");
11505 + *---------------------------------------------------------------------------*/
11506 + char *psp_conf_read_file(char *p_file_name);
11508 + /*----------------------------------------------------------------------------
11509 + * Function : psp_conf_write_file
11512 + * in: p_file_name - the file to which data is to be written.
11513 + * in: data - the NULL terminated data string.
11516 + * Write the indicated data into the file. This function opens the file,
11517 + * appends the data to end of the file, closes the file.
11521 + * The number of bytes on success.
11526 + * psp_conf_write_file("/etc/outcon.conf", data);
11527 + *--------------------------------------------------------------------------*/
11528 + int psp_conf_write_file(char *p_file_name, char *data);
11530 + /*----------------------------------------------------------------------------
11531 + * Function: psp_conf_get_line
11534 + * in: data - the data from which the line is to identified.
11535 + * out: next_line - the pointer to start of the next line.
11538 + * Expects the data to be '\n' separated segments and data is NULL
11539 + * terminated. Parses the given data for '\n' or '\0'. Provides a pointer
11540 + * to the start of next line in the next_line.
11544 + * 0 or more to indicate the number of bytes in the line starting at
11546 + *--------------------------------------------------------------------------*/
11547 + int psp_get_conf_line(char *p_in_data, char **next_line);
11549 + /*----------------------------------------------------------------------------
11550 + * Function: psp_conf_is_data_line
11553 + * in: line - the array of bytes.
11556 + * Tests the first byte in the array for '\0' or '\n' or '#'. Lines
11557 + * starting with these characters are not considered data.
11560 + * 1 if the line has data.
11563 + *--------------------------------------------------------------------------*/
11564 + int psp_conf_is_data_line(char *line);
11566 + /*----------------------------------------------------------------------------
11567 + * Function: psp_conf_eat_white_spaces
11570 + * in: line - the array of bytes.
11573 + * Eats white spaces at the begining of the line while looking out for
11574 + * '\0' or '\n' or ' '.
11577 + * Pointer to the begining of the non white space character.
11578 + * NULL if '\0' or '\n' is found.
11580 + *--------------------------------------------------------------------------*/
11581 + char *psp_conf_eat_white_spaces(char *line);
11583 + /*---------------------------------------------------------------------------
11584 + * Function: psp_conf_get_key_size
11587 + * in: line - the array of bytes.
11590 + * Identifies the size of the 'key' in array formatted as
11591 + * key(id=[key1]....). This function also checks out for '\0' and '\n'.
11594 + * On success, The number of bytes that forms the key.
11597 + *-------------------------------------------------------------------------*/
11598 + int psp_conf_get_key_size(char *line);
11602 +#endif /* __PSP_CONF_BUILD_H__ */
11604 diff -urN linux.old/drivers/net/avalanche_cpmac/psp_config_mgr.c linux.dev/drivers/net/avalanche_cpmac/psp_config_mgr.c
11605 --- linux.old/drivers/net/avalanche_cpmac/psp_config_mgr.c 1970-01-01 01:00:00.000000000 +0100
11606 +++ linux.dev/drivers/net/avalanche_cpmac/psp_config_mgr.c 2005-07-12 02:48:42.177573000 +0200
11608 +/******************************************************************************
11609 + * FILE PURPOSE: PSP Config Manager Source
11610 + ******************************************************************************
11611 + * FILE NAME: psp_config_mgr.c
11615 + * Manages configuration information. The repository is managed on the basis of
11616 + * <key, info> pair. It is possible to have multiple occurrence of the same key.
11617 + * Multiple occurences of the same keys are referred to as 'instances'.
11618 + * 'instances' are assigned in the order of configuration arrival. The first
11619 + * config for a 'key' added to the repository would be treated as instance 0 and
11620 + * next config to arrive for the same key would be treated as instance '1' and
11623 + * Info is retrieved from the repository based on the 'key' and 'instance' value.
11625 + * No assumption is made about the format of the information that is put in the
11626 + * repository. The only requirement is that 'key' should be NULL terminated
11629 + * REVISION HISTORY:
11630 + * 27 Nov 02 - PSP TII
11632 + * (C) Copyright 2002, Texas Instruments, Inc
11633 + *******************************************************************************/
11635 +//#include <stdio.h>
11636 +//#include <stdlib.h>
11637 +#include "psp_config_mgr.h"
11638 +#include "psp_config_util.h"
11640 +#include <linux/slab.h>
11642 +/*-----------------------------------------------------------
11643 + Implemented elsewhere
11644 + -----------------------------------------------------------*/
11645 +extern int sys_read_options_conf(void);
11646 +extern int sys_write_options_conf(char *cfg_info);
11647 +extern int sys_load_default_static_cfg(void);
11648 +extern int sys_run_enumerator(void);
11650 +#define os_malloc(size) kmalloc(size, GFP_KERNEL)
11652 +/*---------------------------------------------------------
11653 + * Data structures.
11654 + *--------------------------------------------------------*/
11655 +struct device_cfg_data;
11657 +typedef struct device_instance_cfg_data
11659 + struct device_instance_cfg_data *next;
11660 + char locale[100];
11661 + unsigned int data_size;
11664 +} DEV_INSTANCE_CFG_DATA_T;
11666 +struct device_cfg_collection;
11668 +typedef struct device_cfg_collection
11670 + struct device_cfg_collection *next;
11671 + char *device_name;
11672 + CFG_TYPE_T cfg_type;
11674 + DEV_INSTANCE_CFG_DATA_T *dev_inst_list_begin;
11675 + DEV_INSTANCE_CFG_DATA_T *dev_inst_list_end;
11679 +typedef struct device_cfg_list
11681 + DEVICE_CFG_T *device_cfg_begin;
11683 +} DEVICE_CFG_LIST_T;
11685 +/*-----------------------------------------------------------------------------
11686 + * Functions used locally with in the file.
11687 + *---------------------------------------------------------------------------*/
11688 +static void p_init_device_cfg_list(void);
11689 +static int p_add_instance_cfg_data(DEVICE_CFG_T *p_dev_cfg,
11690 + DEV_INSTANCE_CFG_DATA_T *p_dev_inst_data);
11691 +static DEVICE_CFG_T* p_create_dev_cfg(char *device_name);
11692 +static DEVICE_CFG_T* p_get_dev_cfg(char *device_name);
11693 +static int p_set_device_cfg_type(DEVICE_CFG_T *p_dev_cfg,
11694 + CFG_TYPE_T cfg_type);
11696 +/* PSP Config manager debug */
11697 +#define PSP_CFG_MGR_DEBUG 0
11699 +#define dbgPrint if (PSP_CFG_MGR_DEBUG) printk
11701 +/*-----------------------------------------------------------------------------
11702 + * The repository.
11703 + *---------------------------------------------------------------------------*/
11704 +static DEVICE_CFG_LIST_T g_device_cfg_list;
11706 +/*---------------------------------------------
11707 + * Initialize the device collection pool.
11708 + *--------------------------------------------*/
11709 +void p_init_device_cfg_list(void)
11711 + g_device_cfg_list.count = 0;
11712 + g_device_cfg_list.device_cfg_begin = NULL;
11715 +/*----------------------------------------------------------------------
11716 + * Add the device cfg into the device linked list.
11717 + *---------------------------------------------------------------------*/
11718 +int p_add_dev_cfg_to_list(DEVICE_CFG_LIST_T *p_dev_list,
11719 + DEVICE_CFG_T *p_dev_cfg)
11721 + if(p_dev_list->count != 0)
11722 + p_dev_cfg->next = p_dev_list->device_cfg_begin;
11724 + p_dev_list->device_cfg_begin = p_dev_cfg;
11726 + p_dev_list->count++;
11731 +/*------------------------------------------------------------------
11732 + * Add the cfg data into the cfg data linked list of the collection.
11733 + *------------------------------------------------------------------*/
11734 +int p_add_instance_cfg_data(DEVICE_CFG_T *p_dev_cfg,
11735 + DEV_INSTANCE_CFG_DATA_T *p_dev_inst_data)
11737 + if(p_dev_cfg->count == 0)
11738 + p_dev_cfg->dev_inst_list_begin = p_dev_inst_data;
11740 + p_dev_cfg->dev_inst_list_end->next = p_dev_inst_data;
11742 + p_dev_cfg->dev_inst_list_end = p_dev_inst_data;
11744 + p_dev_cfg->count++;
11749 +/*-----------------------------------------------------------------------------
11750 + * Create the device cfg.
11751 + *---------------------------------------------------------------------------*/
11752 +DEVICE_CFG_T *p_create_dev_cfg(char *device_name)
11754 + DEVICE_CFG_T *p_dev_cfg = NULL;
11756 + if((p_dev_cfg = os_malloc(sizeof(DEVICE_CFG_T))) == NULL)
11758 + dbgPrint("Failed to allocate memory for DEVICE_CFG_T.\n");
11760 + else if((p_dev_cfg->device_name = os_malloc(psp_config_strlen(device_name) + 1))==NULL)
11762 + dbgPrint("Failed to allocate memory for device name.\n");
11766 + psp_config_strcpy(p_dev_cfg->device_name, device_name);
11767 + p_dev_cfg->cfg_type = en_raw;
11768 + p_dev_cfg->count = 0;
11769 + p_dev_cfg->dev_inst_list_begin = NULL;
11770 + p_dev_cfg->dev_inst_list_end = NULL;
11771 + p_dev_cfg->next = NULL;
11774 + return(p_dev_cfg);
11777 +/*------------------------------------------------------------------------------
11778 + * Get the device cfg collection.
11779 + *-----------------------------------------------------------------------------*/
11780 +DEVICE_CFG_T *p_get_dev_cfg(char *device_name)
11783 + DEVICE_CFG_T *p_dev_cfg = g_device_cfg_list.device_cfg_begin;
11785 + for(count=0; count < g_device_cfg_list.count; count++)
11787 + if(psp_config_strcmp(device_name, p_dev_cfg->device_name) == 0)
11792 + p_dev_cfg = p_dev_cfg->next;
11795 + return(p_dev_cfg);
11798 +/*-------------------------------------------------------------------------
11799 + * Gets the name for the static cfg type. Utility function. Debug purposes.
11800 + *-------------------------------------------------------------------------*/
11801 +char *p_get_cfg_type_name_for_en(CFG_TYPE_T cfg_type)
11803 + static char raw_str [] = "still raw";
11804 + static char compile_str [] = "configured at compile time";
11805 + static char optconf_str [] = "configured by options.conf";
11806 + static char vlynq_str [] = "configured by VLYNQ";
11807 + static char no_static_str[] = "no static configuration";
11809 + if(cfg_type == en_raw)
11810 + return (raw_str);
11811 + else if(cfg_type == en_compile)
11812 + return (compile_str);
11813 + else if(cfg_type == en_opt_conf)
11814 + return (optconf_str);
11815 + else if(cfg_type == en_vlynq)
11816 + return (vlynq_str);
11818 + return (no_static_str);
11822 +/*-----------------------------------------------------------------------------
11823 + * Sets the static cfg status of the device collection.
11825 + * If the collection is en_virgin then, the collection is assigned to cfg_type.
11826 + * If the cfg_type is en_vlynq then, the old cfg_type is retained.
11827 + * en_compile and en_opt_conf are mutually exclusive. One of these can be
11830 + *---------------------------------------------------------------------------*/
11831 +int p_set_device_cfg_type(DEVICE_CFG_T *p_dev_cfg,
11832 + CFG_TYPE_T cfg_type)
11836 + if(p_dev_cfg->cfg_type == en_raw)
11837 + p_dev_cfg->cfg_type = cfg_type;
11838 + else if((cfg_type == en_vlynq) || (p_dev_cfg->cfg_type == cfg_type))
11842 + dbgPrint("Device %s has been %s which overrides %s.\n",
11843 + p_dev_cfg->device_name,
11844 + p_get_cfg_type_name_for_en(p_dev_cfg->cfg_type),
11845 + p_get_cfg_type_name_for_en(cfg_type));
11852 +/*------------------------------------------------------------------------
11853 + * Add the config str into the repository. The cfg type indicates
11854 + * whether the device has been configured statically, from options.conf or
11855 + * by vlynq enumeration.
11856 + *------------------------------------------------------------------------*/
11857 +int psp_config_add(char *key, void *p_cfg_str, unsigned int cfg_len,
11858 + CFG_TYPE_T cfg_type)
11860 + int ret_val = -1;
11861 + DEVICE_CFG_T *p_dev_cfg = NULL;
11862 + DEV_INSTANCE_CFG_DATA_T *p_dev_inst_data = NULL;
11864 + if(p_cfg_str == NULL || key == NULL)
11866 + dbgPrint("Null input pointer(s).\n");
11868 + /* check if there exist a dev_cfg for the given key, if not,
11869 + then create one and add it to the device list. */
11870 + else if(((p_dev_cfg = p_get_dev_cfg(key)) == NULL) &&
11871 + (((p_dev_cfg = p_create_dev_cfg(key)) == NULL) ||
11872 + p_add_dev_cfg_to_list(&g_device_cfg_list, p_dev_cfg) != 0))
11874 + dbgPrint("Failed to allocate mem or add dev cfg for %s.\n", key);
11876 + /* make sure that we can add this cfg type to the repository */
11877 + else if(p_set_device_cfg_type(p_dev_cfg, cfg_type) == -1)
11879 + dbgPrint("Ignoring \"%s\" for device \"%s\".\n",
11880 + p_get_cfg_type_name_for_en(cfg_type),
11881 + p_dev_cfg->device_name);
11883 + else if((p_dev_inst_data = os_malloc(sizeof(DEV_INSTANCE_CFG_DATA_T)))== NULL)
11885 + dbgPrint("Failed to allocate memory for DEV_INSTANCE_CFG_DATA_T.\n");
11887 + else if((p_dev_inst_data->data = os_malloc(cfg_len) + 1) == NULL)
11889 + dbgPrint("Failed to allocate memory for the config data.\n");
11893 + p_dev_inst_data->next = NULL;
11895 + if(cfg_type == en_opt_conf || cfg_type == en_compile)
11896 + psp_config_strcpy(p_dev_inst_data->locale, "dev on chip ");
11897 + else if(cfg_type == en_vlynq)
11898 + psp_config_strcpy(p_dev_inst_data->locale, "dev on vlynq");
11900 + psp_config_strcpy(p_dev_inst_data->locale, "dev locale ?");
11902 + psp_config_memcpy(p_dev_inst_data->data, p_cfg_str, cfg_len);
11903 + p_dev_inst_data->data_size = cfg_len;
11904 + *(p_dev_inst_data->data + cfg_len) = '\0';
11906 + ret_val = p_add_instance_cfg_data(p_dev_cfg, p_dev_inst_data);
11912 +/*-------------------------------------------------------------
11913 + * Get the total number of device instances in the repository
11914 + *------------------------------------------------------------*/
11915 +int psp_config_get_num_keys(void)
11917 + return(g_device_cfg_list.count);
11921 +/*--------------------------------------------------------------------
11922 + * Get the device configuration info from the repository.
11923 + *-------------------------------------------------------------------*/
11924 +int psp_config_get(char *key, int instance, char **cfg_data_out)
11926 + int ret_val = -1;
11927 + DEVICE_CFG_T *p_dev_cfg = NULL;
11928 + *cfg_data_out = NULL;
11930 + if(key == NULL && cfg_data_out == NULL)
11932 + dbgPrint("Key has a NULL value.\n");
11934 + else if((p_dev_cfg = p_get_dev_cfg(key)) == NULL)
11936 + dbgPrint("cfg information for %s could not be found.\n", key);
11938 + else if(p_dev_cfg->count)
11940 + DEV_INSTANCE_CFG_DATA_T *p_dev_inst_data =
11941 + p_dev_cfg->dev_inst_list_begin;
11944 + index != instance && index < p_dev_cfg->count;
11947 + p_dev_inst_data = p_dev_inst_data->next;
11950 + if(p_dev_inst_data != NULL && p_dev_inst_data->data != NULL)
11952 + *cfg_data_out = p_dev_inst_data->data;
11953 + ret_val = p_dev_inst_data->data_size;
11957 + return (ret_val);
11960 +/*----------------------------------------------------------------
11961 + * Returns the number of instances found in the repository for the
11963 + *---------------------------------------------------------------*/
11964 +int psp_config_get_num_instances(char *key)
11967 + DEVICE_CFG_T *p_dev_cfg = NULL;
11971 + dbgPrint("Key has a NULL value.\n");
11973 + else if((p_dev_cfg = p_get_dev_cfg(key)) == NULL)
11975 + dbgPrint("cfg information for %s could not be found.\n", key);
11979 + ret_val = p_dev_cfg->count;
11982 + return (ret_val);
11985 +/*------------------------------------------------------------------
11986 + * Dump the configuration repository.
11987 + * Caution: DO NOT USE THIS FOR ANY NON NBU specified config format.
11988 + *-----------------------------------------------------------------*/
11989 +void psp_config_print(char *key)
11991 + DEVICE_CFG_T *p_dev_cfg = NULL;
11995 + dbgPrint("Key has a NULL value.\n");
11997 + else if((p_dev_cfg = p_get_dev_cfg(key)) == NULL)
11999 + dbgPrint("cfg information for %s could not be found.\n", key);
12001 + else if(p_dev_cfg && p_dev_cfg->count)
12003 + DEV_INSTANCE_CFG_DATA_T *p_dev_inst_data;
12005 + p_dev_inst_data = p_dev_cfg->dev_inst_list_begin;
12009 + dbgPrint("%s : %s\n", p_dev_inst_data->locale,
12010 + p_dev_inst_data->data);
12011 + p_dev_inst_data = p_dev_inst_data->next;
12013 + } while(p_dev_inst_data);
12017 + dbgPrint("Nothing was found for %s.\n", key);
12021 +void dump_device_cfg_pool(void)
12023 + DEVICE_CFG_T *p_dev_cfg = g_device_cfg_list.device_cfg_begin;
12025 + if(p_dev_cfg != NULL && g_device_cfg_list.count)
12029 + for(index=0; index < g_device_cfg_list.count; index++)
12031 + psp_config_print(p_dev_cfg->device_name);
12032 + p_dev_cfg = p_dev_cfg->next;
12037 + dbgPrint("repository is empty.\n");
12041 +void psp_config_init(void)
12043 + p_init_device_cfg_list();
12046 +void psp_config_cleanup()
12048 + int dev_count = 0;
12049 + int inst_count = 0;
12050 + DEVICE_CFG_T *p = g_device_cfg_list.device_cfg_begin;
12051 + DEV_INSTANCE_CFG_DATA_T *q = NULL;
12053 + for(dev_count = 0; dev_count < g_device_cfg_list.count; dev_count++)
12055 + DEVICE_CFG_T *p_temp = NULL;
12056 + if(p) q = p->dev_inst_list_begin;
12058 + for(inst_count = 0; inst_count < p->count && q != NULL; inst_count++)
12060 + DEV_INSTANCE_CFG_DATA_T *q_temp = q;
12061 + q_temp = q->next;
12067 + p_temp = p->next;
12072 diff -urN linux.old/drivers/net/avalanche_cpmac/psp_config_mgr.h linux.dev/drivers/net/avalanche_cpmac/psp_config_mgr.h
12073 --- linux.old/drivers/net/avalanche_cpmac/psp_config_mgr.h 1970-01-01 01:00:00.000000000 +0100
12074 +++ linux.dev/drivers/net/avalanche_cpmac/psp_config_mgr.h 2005-07-12 02:48:42.177573000 +0200
12076 +/******************************************************************************
12077 + * FILE PURPOSE: PSP Config Manager Header
12078 + ******************************************************************************
12079 + * FILE NAME: psp_config_mgr.h
12081 + * DESCRIPTION: Storing and retrieving the configuration based on key
12082 + * A set of APIs to be used by one and sundry (including drivers and enumerator) to build
12083 + * and read cfg information of the devices for an avalanche SOC.
12085 + * This set of APIs isolates the configuration management from the world and provides simple
12086 + * access convinience.
12088 + * Device in this set refers to the peripherals that can be found on the SOC or on VLYNQ.
12089 + * The configuration is stored in the form of string and drivers can use these APIs to get
12090 + * a particular parameter value.
12092 + * The memory allocation for the pass back parameters is done by the caller.
12094 + * 0 is returned for SUCCESS or TRUE.
12095 + * -1 is returned for FAILURE or FALSE.
12097 + * REVISION HISTORY:
12098 + * 27 Nov 02 - PSP TII
12100 + * (C) Copyright 2002, Texas Instruments, Inc
12101 + *******************************************************************************/
12103 +#ifndef __PSP_CONFIG_MGR_H__
12104 +#define __PSP_CONFIG_MGR_H__
12106 +typedef enum cfg_type
12114 +/* Build psp configuration */
12115 +void build_psp_config(void);
12117 +/********************************************************
12118 + * Access Operations.
12119 + ********************************************************/
12121 +/*-------------------------------------------------------------------------
12122 + initializes the configuration repository.
12123 + -------------------------------------------------------------------------*/
12124 +void psp_config_init(void);
12126 +/*--------------------------------------------------------------------------
12127 + Adds the configuration information into the repository. 'key' is required
12128 + to be NULL terminated string. 'cfg_ptr' points to the configuration data.
12129 + 'cfg_len' is the length of the data pointed to by 'cfg_ptr' in bytes.
12130 + 'cfg_type' indicates the type of config information.
12132 + psp_config_mgr copies the 'cfg_len' bytes of data pointed to by 'cfg_ptr'
12133 + into its internal repository.
12135 + Returns: 0 on success, -1 on failure.
12136 + -------------------------------------------------------------------------*/
12137 +int psp_config_add(char *key, void *cfg_ptr,
12138 + unsigned int cfg_len, CFG_TYPE_T cfg_type);
12141 +/* --------------------------------------------------------------------------
12142 + Passes back, in "*cfg_out_val" a pointer to the config data in the repository
12143 + for the specified 'key' and 'instance'. It returns the size of the config
12146 + psp_config_mgr passes back a pointer in '*cfg_out_val' which refers to
12147 + some location in its internal repository. It is strongly recommended that
12148 + if the user intends to modify the contents of the config info for reasons
12149 + whatsoever, then, user should allocate memory of size returned by this
12150 + routine and copy the contents from '*cfg_out_val'.
12152 + Any, modification carried out on the repository would lead to un-expected
12155 + Returns: 0 or more for the size of config info, -1 on error.
12156 + --------------------------------------------------------------------------*/
12157 +int psp_config_get(char *key, int instance, char **cfg_out_val);
12160 +/*--------------------------------------------------------------------------
12161 + Get the number of keys that have been added in the repository so far.
12163 + Returns: 0 or more for the num of keys, -1 on error.
12164 + -------------------------------------------------------------------------*/
12165 +int psp_config_get_num_keys(void);
12168 +/*--------------------------------------------------------------------------
12169 + Get the number of instances that are present in the repository for the
12172 + Returns: 0 or more for the num of instances, -1 on error.
12173 + -------------------------------------------------------------------------*/
12174 +int psp_config_get_num_instances(char *key);
12177 +/*--------------------------------------------------------------------------
12178 + Prints the config data for all instances associated with the specified
12180 + -------------------------------------------------------------------------*/
12181 +void psp_config_print(char *key);
12183 +void dump_device_cfg_pool(void);
12185 +#endif /* __PSP_CONFIG_MGR_H__ */
12186 diff -urN linux.old/drivers/net/avalanche_cpmac/psp_config_parse.c linux.dev/drivers/net/avalanche_cpmac/psp_config_parse.c
12187 --- linux.old/drivers/net/avalanche_cpmac/psp_config_parse.c 1970-01-01 01:00:00.000000000 +0100
12188 +++ linux.dev/drivers/net/avalanche_cpmac/psp_config_parse.c 2005-07-12 02:48:42.178573000 +0200
12190 +/******************************************************************************
12191 + * FILE PURPOSE: PSP Config Manager - Parse API Source
12192 + ******************************************************************************
12193 + * FILE NAME: psp_config_parse.c
12195 + * DESCRIPTION: These APIs should be used only for scanvenging parameters which
12196 + * are stored in the following format.
12198 + * str[] = "module(id=[module], k1=v1, k2=[k3=v3, k4=v4], k5=v5)"
12200 + * REVISION HISTORY:
12201 + * 27 Nov 02 - PSP TII
12203 + * (C) Copyright 2002, Texas Instruments, Inc
12204 + *******************************************************************************/
12206 +//#include <stdio.h>
12207 +#include <linux/stddef.h>
12209 +/*--------------------------------------------------
12211 + *-------------------------------------------------*/
12212 +#define my_isdigit(c) (c >= '0' && c <= '9')
12213 +#define my_isoct(c) (c >= '0' && c <= '7')
12214 +#define my_xtod(c) ((c) <= '9' ? (c) - '0' : (c) - 'a' + 10)
12215 +#define my_ifupper(c) (c >= 'A' && c <= 'F')
12216 +#define XTOD(c) ((c) - 'A' + 10)
12217 +#define my_ishex(c) ((c >= 'a' && c <='f') || (c >= 'A' && c<='F') || my_isdigit(c) )
12219 +/*---------------------------------------------------
12220 + * Local Functions.
12221 + *--------------------------------------------------*/
12222 +static int p_get_substr_from_str(char *p_in_str, char begin_delimiter,
12223 + char end_delimiter, int pair_flag,
12224 + char **p_out_str);
12225 +static int p_get_u_int_from_str(char *p_in_str, char begin_delimiter,
12226 + char end_delimiter, unsigned long *out_val);
12228 +/*---------------------------------------------------
12229 + * Return pointer to first instance of the char.
12230 + *--------------------------------------------------*/
12231 +static char* psp_config_strchr(char *str, char chr)
12240 + return((*str) ? str : NULL);
12243 +/*------------------------------------------------------------------------
12244 + * Convert the string upto delimiter to unsigned long.
12245 + *-----------------------------------------------------------------------*/
12246 +unsigned long my_atoul(char *p, char end_delimiter, unsigned long *out_val)
12251 + /* check the for null input */
12257 + /* pass through the leading spaces */
12258 + if (!my_isdigit(c))
12260 + while ( c == ' ')
12267 + if(*(p + 1) == 'x' || *(p+1) == 'X' )
12269 + /* string is in hex format */
12276 + if(my_ifupper(c))
12282 + return -1; /* invalid hex string format */
12284 + while ((c = *++p) && my_ishex(c))
12287 + if(my_ifupper(c))
12295 + /* string is in octal format */
12297 + if( my_isoct(c) )
12300 + return -1; /* invalid octal string format */
12302 + while ((c = *++p) && my_isoct(c))
12312 + /* string is in decimal format */
12314 + if( my_isdigit(c) )
12317 + return -1; /* invalid decimal string format */
12319 + while ((c = *++p) && my_isdigit(c))
12326 + /* move through the trailing spaces */
12330 + if(*p == end_delimiter)
12337 + return -1; /* invalid string format */
12340 +/*---------------------------------------------------------------------------------
12341 + * Gets the substring de-limited by the 'begin_delimiter' and 'end_delimiter'.
12342 + * and returns the size of the substring.
12344 + * Parses the NULL terminated p_in_str for a character array delimited by
12345 + * begin_delimiter and end_delimiter, passes back the pointer to the character
12346 + * array in ' *p_out_str '. The passed pointer ' *p_out_str ' should point to
12347 + * the location next (byte) to the begin_delimiter. The function routine returns
12348 + * the number of characters excluding the begin_delimiter and end_delimiter,
12349 + * found in the array delimited by the said delimiters.
12351 + * If the pair_flag is set to 1, then, number of begin_delimiter and end_delimiter
12352 + * found in the parsing should match (equal) and this routine passes back the
12353 + * pointer to the character array, starting at a location next (byte) to the
12354 + * first begin_delimiter, inclusive of all intermediate matching delimiter
12355 + * characters found between outer delimiters. If the pair flag is set and if
12356 + * begin_delimiter and end_delimiter happens to be same, then error (-1) is
12359 + * Return: 0 or more to indicate the size of the substring, -1 on error.
12360 + *-------------------------------------------------------------------------------*/
12361 +int p_get_substr_from_str(char *p_in_str, char begin_delimiter,
12362 + char end_delimiter, int pair_flag,
12363 + char **p_out_str)
12367 + if(pair_flag && begin_delimiter == end_delimiter)
12370 + if((p_in_str = psp_config_strchr(p_in_str, begin_delimiter)) == 0)
12371 + return -1; /* no start delimiter found */
12374 + *p_out_str = p_in_str;
12376 + for(pos = 0,cnt =1; cnt && p_in_str[pos] ; pos++)
12378 + if(p_in_str[pos] == end_delimiter)
12380 + if(pair_flag == 0)
12385 + else if(p_in_str[pos] == begin_delimiter)
12388 + ; /* We do nothing */
12395 + return -1; /* no corresponding end delimiter found */
12398 +/*--------------------------------------------------------------------------
12399 + * Parses the NULL terminated p_in_str for unsigned long value delimited by
12400 + * begin_delimiter and end_delimiter, passes back the found in ' *out_val '.
12401 + * The function routine returns 0 on success and returns -1 on failure.
12402 + * The first instance of the de-limiter should be accounted for the parsing.
12404 + * The base for unsigned value would 10, octal and hex. The value passed back
12405 + * would be of the base 10. Spaces at the begining of the byte array are valid
12406 + * and should be ingnored in the calculation of the value. Space character in
12407 + * the middle of the byte array or any character other than the valid ones
12408 + * (based on base type) should return error. The octal value begins with '0',
12409 + * the hex value begins with "0x" or "0X", the base value can begin with
12412 + * Returns: 0 on success, -1 on failure.
12413 + *-------------------------------------------------------------------------*/
12414 +int p_get_u_int_from_str(char *p_in_str, char begin_delimiter,
12415 + char end_delimiter, unsigned long *out_val)
12418 + unsigned long num;
12420 + num = p_get_substr_from_str(p_in_str, begin_delimiter, end_delimiter,
12423 + if(num == (unsigned long)-1)
12426 + return my_atoul(start,end_delimiter,out_val);
12429 +/*--------------------------------------------------------------------------
12430 + * Finds the first occurrence of the substring p_find_str in the string
12432 + *-------------------------------------------------------------------------*/
12433 +char *my_strstr(char *p_in_str, const char *p_find_str)
12435 + char *p = (char *)p_find_str;
12436 + char *ret = NULL;
12442 + else if(*p_in_str == *p)
12444 + if(!ret) ret = p_in_str;
12450 + p = (char *)p_find_str;
12451 + p_in_str = ret + 1;
12458 + if(*p_in_str != *p) ret = NULL;
12464 +/*------------------------------------------------------------------------------
12465 + * Gets the value of the config param in the unsigned int format. The value is
12466 + * stored in the following format in the string.
12467 + * str[] = "module(id=[module], k1=v1, k2=[k3=v3, k4=v4], k5=v5)"
12468 + *-----------------------------------------------------------------------------*/
12469 +int psp_config_get_param_uint(char *p_in_str, const char *param, unsigned int *out_val)
12471 + int ret_val = -1;
12474 + if(!p_in_str || !param || !out_val)
12478 + else if((p_strstr = my_strstr(p_in_str, param)) == NULL)
12482 + else if(p_get_u_int_from_str(p_strstr, '=', ',', (unsigned long *)out_val) == 0)
12486 + else if(p_get_u_int_from_str(p_strstr, '=', ']', (unsigned long*)out_val) == 0)
12490 + else if(p_get_u_int_from_str(p_strstr, '=', ')', (unsigned long*)out_val) == 0)
12499 + return (ret_val);
12502 +/*------------------------------------------------------------------------------
12503 + * Gets the value of the config param in the Non NULL terminated format. The value
12504 + * is stored in the following format in the string.
12505 + * str[] = "module(id=[module], k1=v1, k2=[k3=v3, k4=v4], k5=v5)"
12506 + *-----------------------------------------------------------------------------*/
12507 +int psp_config_get_param_string(char *p_in_str, const char *param, char **out_val)
12509 + int ret_val = -1;
12512 + if(!p_in_str || !param || !(out_val))
12514 + else if((p_strstr = my_strstr(p_in_str, param)) == NULL)
12518 + else if((ret_val = p_get_substr_from_str(p_strstr, '[', ']', 1, out_val)) == -1)
12524 + ; /* we got the value */
12527 + return (ret_val);
12530 +#ifdef PSP_CONFIG_MGR_DEBUG_TEST
12533 + unsigned long num =999;
12535 + char *val1 = NULL;
12537 + char str1[] = "cpmac(id=[cpmac], k0=[a1=[a2=[test], a3=2], k1=100, k2=[k3=300, k4=200], k7=722)";
12539 + psp_config_get_param_uint(str1, "k7", &num);
12540 + printf("%u.\n", num);
12541 + ret = psp_config_get_param_string(str1, "a1", &val1);
12542 + if(ret >= 0) { printf("%d.\n", ret); strncpy(val, val1, ret); val[ret] = '\0';}
12544 + printf("val = \"%s\", and size = %d \n", val, ret);
12546 + if(val[ret]) ; else printf("jeee.\n");
12548 +#endif /* PSP_CONFIG_MGR_DEBUG_TEST */
12552 diff -urN linux.old/drivers/net/avalanche_cpmac/psp_config_parse.h linux.dev/drivers/net/avalanche_cpmac/psp_config_parse.h
12553 --- linux.old/drivers/net/avalanche_cpmac/psp_config_parse.h 1970-01-01 01:00:00.000000000 +0100
12554 +++ linux.dev/drivers/net/avalanche_cpmac/psp_config_parse.h 2005-07-12 02:48:42.178573000 +0200
12556 +/******************************************************************************
12557 + * FILE PURPOSE: PSP Config Manager - Parse API Header
12558 + ******************************************************************************
12559 + * FILE NAME: psp_config_parse.h
12561 + * DESCRIPTION: Parsing for params from string available in the NBU format.
12562 + * These APIs should be used only for scanvenging parameters which
12563 + * are stored in the following format.
12565 + * str[] = "module(id=[module], k1=v1, k2=[k3=v3, k4=v4], k5=v5)"
12567 + * REVISION HISTORY:
12568 + * 27 Nov 02 - PSP TII
12570 + * (C) Copyright 2002, Texas Instruments, Inc
12571 + *******************************************************************************/
12573 +#ifndef __PSP_CONFIG_PARSER_H__
12574 +#define __PSP_CONFIG_PARSER_H__
12576 +/*------------------------------------------------------------------
12577 + * These APIs should be used only for scanvenging parameters which
12578 + * are stored in the following format.
12580 + * str[] = "module(id=[module], k1=v1, k2=[k3=v3, k4=v4], k5=v5)"
12581 + *-----------------------------------------------------------------*/
12582 +int psp_config_get_param_uint(char *p_in_str, const char *param,
12583 + unsigned int *out_val);
12584 +int psp_config_get_param_string(char *p_in_str, const char *param,
12587 +#endif /* __PSP_CONFIG_PARSER_H__ */
12588 diff -urN linux.old/drivers/net/avalanche_cpmac/psp_config_util.c linux.dev/drivers/net/avalanche_cpmac/psp_config_util.c
12589 --- linux.old/drivers/net/avalanche_cpmac/psp_config_util.c 1970-01-01 01:00:00.000000000 +0100
12590 +++ linux.dev/drivers/net/avalanche_cpmac/psp_config_util.c 2005-07-12 02:48:42.178573000 +0200
12592 +/******************************************************************************
12593 + * FILE PURPOSE: PSP Config Manager - Utilities API Source
12594 + ******************************************************************************
12595 + * FILE NAME: psp_config_util.c
12597 + * DESCRIPTION: These APIs provide the standard "C" string interfaces.
12598 + * Provided here to reduce dependencies on the standard libraries
12599 + * and for cases where psp_config would required to run before
12600 + * the whole system is loaded or outside the scope of the OS.
12602 + * REVISION HISTORY:
12603 + * 27 Nov 02 - PSP TII
12605 + * (C) Copyright 2002, Texas Instruments, Inc
12606 + *******************************************************************************/
12608 +//#include <stdio.h>
12609 +#include "psp_config_util.h"
12610 +#include <linux/stddef.h>
12612 +/*---------------------------------------------
12614 + *-------------------------------------------*/
12615 +int psp_config_strlen(char *p)
12617 + char *p_orig = p;
12620 + return(p - p_orig);
12623 +/*--------------------------------------------
12625 + *-------------------------------------------*/
12626 +int psp_config_strcmp(char *s1, char *s2)
12628 + while(*s1 && *s2)
12636 + return(*s1 - *s2);
12639 +/*--------------------------------------------
12641 + *------------------------------------------*/
12642 +char* psp_config_strcpy(char *dest, char *src)
12644 + char *dest_orig = dest;
12648 + *dest++ = *src++;
12653 + return(dest_orig);
12656 +/*----------------------------------------------
12657 + * psp_config_memcpy.
12658 + *--------------------------------------------*/
12659 +void* psp_config_memcpy(void* dest, void* src, unsigned int n)
12661 + void *dest_orig = dest;
12665 + *(char *)dest++ = *(char *)src++;
12669 + return (dest_orig);
12672 +/*---------------------------------------------------
12673 + * Return pointer to first instance of the char.
12674 + *--------------------------------------------------*/
12675 +char* psp_config_strchr(char *str, char chr)
12684 + return((*str) ? str : NULL);
12687 +#ifdef PSP_CONFIG_MGR_DEBUG_TEST
12691 + char s[] = "hello ";
12692 + printf("%d.\n", psp_config_strlen("hello\n"));
12693 + printf("%d.\n", psp_config_strcmp("hells", "hellq"));
12694 + printf("%s %s.\n", psp_config_strcpy(s + 6, "test1"), s);
12697 +#endif /* PSP_CONFIG_MGR_DEBUG_TEST */
12698 diff -urN linux.old/drivers/net/avalanche_cpmac/psp_config_util.h linux.dev/drivers/net/avalanche_cpmac/psp_config_util.h
12699 --- linux.old/drivers/net/avalanche_cpmac/psp_config_util.h 1970-01-01 01:00:00.000000000 +0100
12700 +++ linux.dev/drivers/net/avalanche_cpmac/psp_config_util.h 2005-07-12 02:48:42.179573000 +0200
12702 +/******************************************************************************
12703 + * FILE PURPOSE: PSP Config Manager - Utilities API Header
12704 + ******************************************************************************
12705 + * FILE NAME: psp_config_util.h
12707 + * DESCRIPTION: These APIs provide the standard "C" string interfaces.
12708 + * Provided here to reduce dependencies on the standard libraries
12709 + * and for cases where psp_config would required to run before
12710 + * the whole system is loaded or outside the scope of the OS.
12712 + * REVISION HISTORY:
12713 + * 27 Nov 02 - PSP TII
12715 + * (C) Copyright 2002, Texas Instruments, Inc
12716 + *******************************************************************************/
12718 +#ifndef __PSP_CONFIG_UTIL_H__
12719 +#define __PSP_CONFIG_UTIL_H__
12721 +extern int psp_config_strlen(char*);
12722 +extern int psp_config_strcmp(char*, char*);
12723 +extern char* psp_config_strcpy(char*, char*);
12724 +extern void* psp_config_memcpy(void*, void*, unsigned int n);
12725 +extern char* psp_config_strchr(char*, char);
12727 +#endif /* __PSP_CONFIG_UTIL_H__ */
12728 diff -urN linux.old/drivers/net/avalanche_cpmac/readme.txt linux.dev/drivers/net/avalanche_cpmac/readme.txt
12729 --- linux.old/drivers/net/avalanche_cpmac/readme.txt 1970-01-01 01:00:00.000000000 +0100
12730 +++ linux.dev/drivers/net/avalanche_cpmac/readme.txt 2005-07-12 02:48:42.179573000 +0200
12732 +23 August 2004 CPMAC 1.7.8 (NSP Performance Team Release)
12734 +CC Labels: REL_20040823_HALdallas_cpmac_01.07.08
12736 +New features: Key "MacAddr" can now be used to set the Mac Address after Open.
12738 + unsigned char MacAddr[6];
12740 + // Set Mac Address to "00.B0.D0.10.80.C1"
12741 + MacAddr[0] = 0x00;
12742 + MacAddr[1] = 0xB0;
12743 + MacAddr[2] = 0xD0;
12744 + MacAddr[3] = 0x10;
12745 + MacAddr[4] = 0x80;
12746 + MacAddr[5] = 0xC1;
12748 + HalFunc->Control(HalDev, "MacAddr", hcSet, &MacAddr);
12750 +Bug fixes: in Send(), Threshold is not checked if Tx Ints are re-enabled.
12752 +Modules affected: hcpmac.c, hcpmac.h, cppi_cpmac.c
12754 +22 June 2004 CPMAC 1.7.6 (NSP Performance Team Release)
12756 +CC Labels: REL_20040622_HALdallas_cpmac_01.07.06
12758 +New features: Key "TxIntDisable" used to disable Tx Interrupts. If it is set, then Tx Interrupts will be processed on Send() controlled by Tx ServiceMax Setting.
12761 + HalFunc->Control(HalDev, "TxIntDisable", "Set", &On);
12765 +10 June 2004 CPMAC 1.7.5 (external release)
12767 +CC Labels: REL_20040610_HALdallas_cpmac_01.07.05
12771 +Bug fixes: Fixed an issue with calculation for the multicast hash.
12773 +27 May 2004 CPSAR 1.7.4, CPMAC 1.7.4 (external release)
12775 +CC Labels: REL_20040527_HALdallas_cpsar_01.07.04
12776 + REL_20040527_HALdallas_cpmac_01.07.04
12780 +Bug fixes: A flaw was fixed in the critical sectioning of the CPPI file, affecting both
12781 + the MAC and the SAR releases. This flaw was detected on Titan PSP 4.7 BFT2.
12783 +05 May 2004 CPSAR 1.7.3, CPMAC 1.7.3 (external release)
12785 +CC Labels: REL_20040505_HALdallas_cpsar_01.07.03
12786 + REL_20040505_HALdallas_cpmac_01.07.03
12790 +Bug fixes: 1) Firmware has been updated to fix a problem with Host OAM mode operation.
12791 + 2) Cache macros have been fixed.
12793 +Notes: This release contains all performance enhancements currently available for CPHAL 1.x.
12795 +19 April 2004 CPSAR 1.7.2, CPMAC 1.7.2 (external release)
12797 +CC Labels: REL_20040419_HALdallas_cpsar_01.07.02
12798 + REL_20040419_HALdallas_cpmac_01.07.02
12802 +Bug fixes: Fixes merge problem in 1.7.1.
12804 +Notes: This is a branch release which contains only a subset of the performance improvements.
12805 + The remaining performance improvements are stiill being qualified at this time.
12807 +1 April 2004 CPSAR 1.7.1, CPMAC 1.7.1 (external release)
12809 +NOTICE: DO NOT USE 1.7.1. It has a known problem (see 1.7.2 notes)
12811 +CC Labels: REL_20040401_HALdallas_cpsar_01.07.01
12812 + REL_20040401_HALdallas_cpmac_01.07.01
12814 +New features: Performance improvement in CPPI layer, affecting both CPSAR and CPMAC.
12818 +17 Februrary 2004 CPSAR 1.7.0 (external release)
12820 +CC Labels: REL_20040217_HALdallas_cpsar_01.07.00
12822 +New features: Added support for "TxFlush" feature. This allows the upper
12823 + layer to flush all or part of a given Tx queue for a given
12824 + channel. This is to be used during call setup for a voice
12827 +30 January 2004 CPMAC 1.7.0 (external release)
12829 +CC Labels: REL_20040130_HALdallas_cpmac_01.07.00
12831 +Bug fixes: CPMDIO - When in manual negotiate mode and linked, dropping link would move into NWAY state rather than manual state.
12832 + CPMDIO - Extraneous debug message corrected
12833 +New features: CPMDIO - Support for AutoMdix usage added.
12835 +25 September 2003 CPSAR 1.6.6 (external release)
12837 +CC Labels: REL_20030925_HALdallas_cpsar_01.06.06
12839 +Bug fixes: PDSP firmware has been updated to fix the OAM padding problem. It previously
12840 + wrote pad bytes into a reserved field of the OAM cell. There is a small
12841 + change to the CPSAR configuration code which corresponds to the PDSP spec
12846 +09 September 2003 CPMAC 1.6.6 (external release)
12848 +CC Labels: REL_20030909_HALdallas_cpmac_01.06.06
12850 +Bug fixes: CPMAC : When _CPMDIO_NOPHY is set, Cpmac COntrol is set to Full Duplex
12851 + Bridge loopback test does not show a problem using 1.6.5 if packet rate is
12852 + below 50,000 pbs. Now testing with a 100% send from Ixia.
12856 +05 August 2003 CPHAL 1.6.5 (external release)
12858 +CC Labels: REL_20030805_HALdallas_cpmac_01.06.05
12862 +New features: CPMAC : Added support for CPMAC modules that do not have a Phy connected.
12863 + The CPMAC is informed of this by the MdioConnect option
12864 + _CPMDIO_NOPHY. This is the only driver change needed to
12865 + receive and transmit packets through the Marvel switch.
12866 + Note In this mode Link status will reported linked at 100/FD to
12867 + PhyNum 0xFFFFFFFF.
12869 + ALL: Cleaned up some Vlynq support logic.
12871 +16 July 2003 CPSAR 1.6.3 (external release), no CPMAC release
12873 +CC Labels: REL_20030716_HALdallas_cpsar_01.06.03
12875 +Bug fixes: 1) Changed default value of CPCS_UU from 0x5aa5 to 0. The old default value caused
12876 + problems with Cisco routers.
12880 +Known issues not addressed in this release: NTR.
12882 +01 July 2003 CPHAL 1.6.2 (external release)
12884 +CC Labels: REL_20030701_HALdallas_cpmac_01.06.02
12885 + REL_20030701_HALdallas_cpsar_01.06.02
12887 +Bug fixes: 1) A previous firmware upgrade caused firmware OAM loopback cells to only work on every other
12888 + command. This has been fixed in the new firmware version (0.47).
12889 + 2) Problem with PTI values changing on transparent mode packets has been resolved.
12890 + 3) Previously, successful firmware OAM loopback cells waited 5 seconds before notifying the
12891 + OS of success, rather that notifying immediately. This has been resolved in firmware.
12892 + 4) PITS #148 (MAC and SAR), #149 (MAC) have been fixed.
12894 +New features: 1) AAL5 HAL now capable of receiving unknown VCI/VPI cells on a single transparent channel.
12895 + See updated HAL document (AAL5 appendix) for implementation details.
12896 + 2) AAL5 HAL now allows OS to modify the OAM loopback timeout window. Previously, failed
12897 + OAM loopback attempts timed out after a nominal 5 seconds (based on the SAR frequency
12898 + provided by the OS). Now, the default is 5 seconds, but the OS may change the
12899 + value via halControl() to any integer number of milliseconds. See updated HAL document
12900 + (AAL5 appendix) for implementation details.
12901 + 3) MAC (cpmdio): added loopback to Istate. Used for debug.
12903 +Known issues not addressed in this release: NTR.
12905 +09 June 2003 CPSAR 1.6.1 (external release), CPMAC 1.6.1 (internal release - no functional change)
12907 +Note: This is the same set of fixes being applied to 1.6.0 that were applied to 1.5.3. The only difference
12908 + between 1.6.1 and 1.5.4 is that 1.6.1 has the TurboDSL fix.
12910 +CC Labels: REL_20030609_HALdallas_cpmac_01.06.01
12911 + REL_20030609_HALdallas_cpsar_01.06.01
12913 +Bug fixes: 1) Bug in OamLoopbackConfig fixed.
12914 + 2) New firmware version (.43) to fix Westell issue of dropped downstream packets in
12915 + presence of OAM traffic when operating at or near line rate.
12917 +New features: NTR.
12919 +09 June 2003 CPSAR 1.5.4 (external release), CPMAC 1.5.4 (internal release - no functional change)
12921 +Note: This is a branch release from 1.5.3. This does not contain anything from 1.6.0. The CPMAC is
12922 +only being labeled to keep the release flow consistent.
12924 +CC Labels: REL_20030609_HALdallas_cpmac_01.05.04
12925 + REL_20030609_HALdallas_cpsar_01.05.04
12927 +Bug fixes: 1) Bug in OamLoopbackConfig fixed.
12928 + 2) New firmware version (.43) to fix Westell issue of dropped downstream packets in
12929 + presence of OAM traffic when operating at or near line rate.
12931 +New features: NTR.
12933 +30 May 2003 CPSAR 1.6.0 (external release), CPMAC 1.6.0 (internal release - no functional change)
12935 +CC Labels: REL_20030530_HALdallas_cpmac_01.06.00
12936 + REL_20030530_HALdallas_cpsar_01.06.00
12938 +Bug fixes: 1) TurboDSL issue has been fixed with a software workaround in TxInt. This workaround
12939 + has been verified under Adam2 ONLY at this point. Testing remains to be done on
12940 + Linux and VxWorks.
12942 +New features: NTR.
12944 +Known issues not addressed in this release: NTR.
12946 +30 May 2003 CPSAR 1.5.3 (external release), CPMAC 1.5.3 (internal release - no functional change)
12948 +CC Labels: REL_20030530_HALdallas_cpmac_01.05.03
12949 + REL_20030530_HALdallas_cpsar_01.05.03
12953 +New features: 1) AAL5 Send() has been modified to accept an ATM Header either in the first
12954 + fragment by itself, or in the first fragment directly in front of payload data.
12955 + The API() does not change.
12956 + 2) Documentation updates throughout, reflected in latest version of CPHAL user's
12958 + 3) AAL5 MaxFrags default value is now 46. This is based upon the default AAL5
12959 + RxBufSize of 1518 (MaxFrags = (65568/1518) + 2). IF THE OS CHOOSES A SMALLER
12960 + RxBufSize, IT MUST INCREASE THE VALUE OF MaxFrags ACCORDINGLY. This is done
12961 + via halControl(), prior to Open().
12963 +Known issues not addressed in this release:
12964 + 1) The Linux SAR driver is seeing an issue in which it cannot
12965 + reliably send traffic simultaneously on both the high and
12966 + low priority queues of a single AAL5 channel. (TurboDSL)
12968 +23 May 2003 CPHAL 1.5.2 (external release)
12970 +CC Labels: REL_20030523_HALdallas_cpmac_01.05.02
12971 + REL_20030523_HALdallas_cpsar_01.05.02
12973 +Bug fixes: 1) PITS #138: CPMAC flooding issue resolved.
12974 + 2) PITS #142: OS may now set "MaxFrags" via Control(). This controls the
12975 + maximum number of fragments expected by the CPHAL. The default value is 2 for
12976 + CPMAC and 1028 for AAL5. If the OS chooses a RxBufSize that will cause more
12977 + fragments than the defaults, the OS must set "MaxFrags" to a correct value
12978 + ((maximum packet length / RxBufSize) + 2).
12979 + 3) PITS #143: Fixed.
12980 + 4) Firmware OAM bug fixed. (new firmware release in this version)
12982 +New features: NTR.
12984 +Known issues not addressed in this release:
12985 + 1) The Linux SAR driver is seeing an issue in which it cannot
12986 + reliably send traffic simultaneously on both the high and
12987 + low priority queues of a single AAL5 channel. (TurboDSL)
12989 +14 May 2003 CPHAL 1.5.1 (external release)
12991 +CC Labels: REL_20030514_HALdallas_cpmac_01.05.01
12992 + REL_20030514_HALdallas_cpsar_01.05.01
12994 +Bug fixes: 1) PITS 132 - (CPMAC) Frames < 60 bytes and split into
12996 + 2) BCIL MR PSP00000353 - (CPMAC) PhyDev not free'd on halClose()
12997 + 3) PITS 113 - OsSetup bug in ChannelSetup fixed.
12998 + 4) Fixed AAL5 to check return values of InitTcb/InitRcb.
12999 + 5) Fixed Shutdown to properly free resources in the case of a Close
13000 + mode 1 followed by Shutdown. Previously, buffer and descriptor
13001 + resources were left unfreed in this case.
13003 +New features: 1) AAL5 Send() modified to be capable of accepting ATM header as first four
13004 + bytes of first fragment. This allows the OS to "override" the
13005 + default ATM header which is constructed from preconfigured channel
13007 + 2) AAL5 Receive() modified to be capable of passing the received ATM header (4 bytes, no HEC)
13008 + in the first fragment (by itself). It also passes up the OS an indication
13009 + of what the received packet type was. For Host OAM and transparent mode
13010 + packets, the ATM header is passed in this manner, and for other types of packets
13011 + (AAL5, NULL AAL) no ATM header is passed currently.
13013 +Known issues not addressed in this release:
13014 + 1) The Linux SAR driver is seeing an issue in which it cannot
13015 + reliably send traffic simultaneously on both the high and
13016 + low priority queues of a single AAL5 channel.
13018 +30 April 2003 CPHAL 1.5.0 (external release)
13020 +CC Labels: REL_20030430_HALdallas_cpmac_01.05.00
13021 + REL_20030430_HALdallas_cpsar_01.05.00
13023 +Bug fixes: 1) Fixed AAL5 bug that rendered the low priority queue
13025 + 2) Fixed a bug in AAL5's Oam Rate calculations.
13026 + 3) Fixed use of "DeviceCPID" key in AAL5's halControl().
13027 + 4) Fixed RxReturn logic in HAL. The HAL now can handle
13028 + failing MallocRxBuffer calls when multiple fragments
13031 +New features: 1) AAL5 Stats now available on a per queue basis.
13032 + 2) AAL5 adds two new keys to halControl() for "Set" actions:
13033 + RxVc_OamCh and RxVp_OamCh.
13034 + 3) Shutdown() has been modified for both AAL5 and CPMAC to
13035 + call Close() if the module is still in the Open state.
13036 + 4) CPMAC adds the following access keys to halControl():
13037 + hcPhyAccess,hcPhyNum,hcCpmacBase,hcSize,and hcCpmacSize.
13038 + 5) CPHAL no longer requests an extra 15 bytes on data buffer
13041 +Known issues not addressed in this release:
13042 + 1) The Linux SAR driver is seeing an issue in which it cannot
13043 + reliably send traffic simultaneously on both the high and
13044 + low priority queues of a single AAL5 channel.
13046 +21 April 2003 CPHAL 1.4.1 (external release)
13048 +CC Labels: REL_20030421_HALdallas_cpmac_01.04.01
13049 + REL_20030421_HALdallas_cpsar_01.04.01
13051 +Bug fixes: 1) Fixed OAM logic in SAR portion of CPHAL.
13053 +New features: 1) OAM loopback counters exposed through halControl.
13054 + 2) Host OAM Send() can now use a single channel to send
13055 + OAM cells on unlimited number of VP's/VC's.
13056 + 3) CPHAL now requests "SarFreq" through osControl.
13057 + 4) CPHAL now calculates all OAM function rates based on
13058 + "SarFreq"; function OamRateConfig removed for API.
13059 + 5) New OAM function OamLoopbackConfig, used for configuring
13060 + loopback functions in firmware OAM mode.
13062 +Known issues not addressed in this release: Bug fix 1) in release 1.4
13063 + (see below) does not work properly for multiple fragments.
13065 +10 April 2003 CPHAL 1.4 (external release)
13067 +CC Labels: REL_20030410_HALdallas_cpmac_01.04.00
13068 + REL_20030410_HALdallas_cpsar_01.04.00
13070 +This release is for SAR and MAC.
13072 + Bug fixes: 1) Implemented logic in HAL to re-request buffer mallocs
13073 + in the case of MallocRxBuffer failing. The HAL now maintains
13074 + a NeedsBuffer queue of all RCB's that are without buffers.
13075 + On interrupts, or on Send(), the HAL checks to see if any
13076 + RCB's are on the queue, and if so, calls MallocRxBuffer
13077 + to attempt to get a new buffer and return the RCB to
13079 + 2) SAR now properly returns all error codes from halOpen and
13082 + New features: NTR
13084 + Known issues not addressed in this release: NTR
13086 +08 April 2003 CPHAL 1.3.1 (internal release - SAR only)
13088 + CC Labels: REL_20030408_HALdallas_cpsar_01.03.01
13090 + This is a SAR only release. The current CPMAC release is still 1.3.
13092 + Bug fixes: 1) PDSP State RAM / Scratchpad RAM is now completely cleared after reset.
13093 + This resolves a stability issue.
13095 + New features: 1) OamMode is now a parameter in halControl(). Both "Set" and "Get"
13096 + actions are available. The value may be "0" (Host OAM), or "1"
13099 + Known issues not addressed in this release:
13100 + 1) Appropriate action for HAL in the case of MallocRxBuffer failing. We
13101 + are investigating whether the HAL should implement a needs buffer
13104 +04 April 2003 CPHAL 1.3 (external release)
13106 + CC Labels: REL_20030404_HALdallas_cpmac_01.03.00
13107 + REL_20030404_HALdallas_cpsar_01.03.00
13108 + REL_20030404_HALdallas_cpaal5_01.03.00
13109 + REL_20030404_HALdallas_cpaal2_01.03.00
13111 + This release requires no changes for the ethernet end driver. The changes necessary
13112 + for the sar driver (firmware file name changes) have already been implemented.
13114 + Bug fixes: 1) RxReturn now returns an error if MallocRxBuffer fails. On RxReturn error, the driver should
13115 + call RxReturn again at a later time (when the malloc may succeed) in order for the CPHAL
13116 + to maintain a full complement of Rx buffers. We recommend holding off making this driver
13117 + change until we verify that this condition occurs.
13119 + New features: 1) Removed benign compiler warnings.
13120 + 2) PITS 122: http://www.nbu.sc.ti.com/cgi-bin/pits/redisplay_archive?product=cphal_dev&report=122
13121 + 3) Cpsar label (above) now is applied to everything
13123 + 4) PITS 14: http://www.nbu.sc.ti.com/cgi-bin/pits/redisplay_archive?product=cphal_dev&report=14
13124 + Transferred to MR PSP 00000089.
13125 + 5) PITS 120: http://www.nbu.sc.ti.com/cgi-bin/pits/redisplay_archive?product=cphal_dev&report=120
13127 + Known issues not addressed in this release:
13128 + 1) PITS 102 (as relating to OamMode configuration):
13129 + http://www.nbu.sc.ti.com/cgi-bin/pits/redisplay_archive?product=cphal_dev&report=102
13130 + Future release will make OamMode configurable
13131 + through halControl(), not on per channel basis.
13133 +20 March 2003 CPHAL 1.2.1 (internal release)
13135 + CC Labels: REL_20030320_HALdallas_cpmac_01.02.01
13136 + REL_20030320_HALdallas_cpsar_01.02.01
13137 + REL_20030320_HALdallas_cpaal5_01.02.01
13138 + REL_20030320_HALdallas_cpaal2_01.02.01
13140 + Bug fixes: 1. Fixed modification of buffer pointer following
13141 + MallocRxBuffer in cppi.c.
13142 + 2. Removed extra firmware files from /cpsar.
13144 + New features: NTR.
13146 + Known issues not addressed in this release: NTR.
13148 +07 March 2003 CPHAL 1.2 (external release)
13150 + CPMAC/CPSAR feature complete release. SAR added
13151 + several features including full OAM support and various
13152 + other features and bug fixes to address PITS 99-106, and
13153 + 114. CPMAC cleaned up details raised by India PSP
13156 +29 January 2003 CPHAL RC 3.01a (external release)
13158 + Corrects non-static functions to be static in cppi.c.
13160 +09 Janurary 2003 CPHAL RC 3.01 (external release)
13162 + PITS 88: Fixed MDIO re-connection problem (hcpmac.c)
13163 + PITS 90: Corrected Rx Buffer Pointer modification (cppi.c)
13165 + Corrected error in cpremap.c
13167 +20 December 2002 CPHAL RC 3 (external release)
13169 + Statistics support via halControl(). See Appendix A of guide.
13170 + Fixed errors in ChannelTeardown/ChannelSetup CPHAL logic.
13171 + Added multicast support as requested.
13172 + Several new OS string functions added to OS_FUNCTIONS.
13173 + "DebugLevel" configuration parameter changed to "Debug".
13174 + "Stats0" changed to "StatsDump" for CPMAC.
13176 +13 December 2002 CPHAL RC 2.03 (internal release)
13178 + Performance improvements.
13179 + More debug statements implemented (esp AAL5).
13180 + Updated makefile with "make debug" option.
13181 + Hbridge performance: [debug library] 15774 tps (53% line rate)
13182 + [non-debug library] 13700 tps (46%)
13184 +10 December 2002 CPHAL Release Candidate 2.02 (internal release)
13186 + Much of the configuration code internal to CPMAC and AAL5 has been made common.
13187 + [os]Receive API had been modified to remove OsReceiveInfo. This information is now
13188 + available as third member of the FRAGLIST structure, on a per buffer basis.
13189 + Successfully tested multi-fragment support on CPMAC, using 32 byte buffers.
13190 + Code is now Emerald compliant - all buffer descriptors now aligned to cache-line
13193 +2 December 2002 CPHAL Release Candidate 2.01
13195 + Updates to comments in hcpmac.c, cpmdio.c, hcpmac.h
13196 + Nested comment in hcpmac.c in RC2 can cause compile errors.
13198 +25 November 2002 CPHAL Release Candidate 2
13200 +Project Items not completed for RC2
13201 +#6 Ship as Library - Once under CC. Moved to RC3
13202 +#8 Under Clearcase - Moved to RC3
13203 +#25 Emerald compliant - Moved to RC3
13204 +#26 Statistics support - Moved to RC3 (some support in RC2)
13205 +#36 Debug scheme implemented - Moved to RC3 (some support in RC2)
13207 +8 November 2002 CPHAL Release Candidate 1
13211 +Project Items not completed for RC1
13213 +#8 Under Clearcase - Clearcase server failure this week. Moved to RC2
13214 +#6 Ship as Library - Once under CC. Moved to RC2
13215 +#13 Verify Datatypes. Moved to RC2
13216 +#14 Review APIs. Moved to RC2
13218 +APIs under review for RC2
13227 +CPMAC Build Instructions
13229 +Compile the file 'hcpmac.c'.
13232 +AAL5 Build Instructions
13234 +The AAL5 build is composed of the source files aal5sar.c and cpsar.c.
13235 +Refer to the provided makefile for an example of compiling these files
13238 +Example CPHAL Code
13242 +Example CPMAC code is provided in the file hbridge.c.
13243 +This program is provided simply as an example of using the CPHAL API.
13244 +It is not intended to be compiled and executed in your environment.
13248 +Example AAL5 code is provided in the file loopback.c. This program
13249 +is provided simply as an example of using the CPHAL API. It is not
13250 +intended to be compiled and executed in your environment.
13253 +Performance Baseline
13258 +RC1: hbridge.bin, running with IXIA cpahl_1.cfg.
13259 + This sends 64-byte packets from each Ixia port, with mac destination the other Ixia port.
13262 +RC2: hbridge.bin, running with IXIA cpahl_1.cfg.
13263 + This sends 64-byte packets from each Ixia port, with mac destination the other Ixia port.
13265 + CPHAL now includes Emerald support, but this has been disabled by using 'cache -wt' to emulate 4Kc.
13267 +RC3: hbridge.bin, running with IXIA cpahl_1.cfg.
13268 + This sends 64-byte packets from each Ixia port, with mac destination the other Ixia port.
13270 + Running as Emerald processor.
13272 +Release Total Receive Rate Throughput Setting
13277 diff -urN linux.old/drivers/net/Config.in linux.dev/drivers/net/Config.in
13278 --- linux.old/drivers/net/Config.in 2005-07-12 03:20:45.726149872 +0200
13279 +++ linux.dev/drivers/net/Config.in 2005-07-12 02:48:42.180573000 +0200
13281 comment 'Ethernet (10 or 100Mbit)'
13282 bool 'Ethernet (10 or 100Mbit)' CONFIG_NET_ETHERNET
13283 if [ "$CONFIG_NET_ETHERNET" = "y" ]; then
13284 + if [ "$CONFIG_MIPS_TITAN" = "y" -o "$CONFIG_AR7" = "y" ]; then
13285 + tristate ' Texas Instruments Avalanche CPMAC support' CONFIG_MIPS_AVALANCHE_CPMAC
13287 + if [ "$CONFIG_MIPS_AVALANCHE_CPMAC" != "n" ]; then
13288 + if [ "$CONFIG_AR7WRD" = "y" -o "$CONFIG_AR7VWI" = "y" -o "$CONFIG_AR7VW" = "y" ]; then
13289 + define_bool CONFIG_MIPS_CPMAC_INIT_BUF_MALLOC y
13290 + define_int CONFIG_MIPS_CPMAC_PORTS 1
13291 + if [ "$CONFIG_MIPS_AVALANCHE_MARVELL" = "y" ]; then
13292 + define_bool CONFIG_AVALANCHE_LOW_CPMAC n
13293 + define_bool CONFIG_AVALANCHE_HIGH_CPMAC y
13295 + define_bool CONFIG_AVALANCHE_CPMAC_AUTO y
13296 + define_bool CONFIG_AVALANCHE_LOW_CPMAC n
13297 + define_bool CONFIG_AVALANCHE_HIGH_CPMAC n
13302 if [ "$CONFIG_ARM" = "y" ]; then
13303 dep_bool ' ARM EBSA110 AM79C961A support' CONFIG_ARM_AM79C961A $CONFIG_ARCH_EBSA110
13304 tristate ' Cirrus Logic CS8900A support' CONFIG_ARM_CIRRUS
13305 diff -urN linux.old/drivers/net/Makefile linux.dev/drivers/net/Makefile
13306 --- linux.old/drivers/net/Makefile 2005-07-12 03:20:45.726149872 +0200
13307 +++ linux.dev/drivers/net/Makefile 2005-07-12 02:48:42.181573000 +0200
13309 subdir-$(CONFIG_BONDING) += bonding
13312 +# Texas Instruments AVALANCHE CPMAC driver
13315 +subdir-$(CONFIG_MIPS_AVALANCHE_CPMAC) += avalanche_cpmac
13316 +#obj-$(CONFIG_MIPS_AVALANCHE_CPMAC) += avalanche_cpmac/avalanche_cpmac.o
13317 +ifeq ($(CONFIG_MIPS_AVALANCHE_CPMAC),y)
13318 + obj-y += avalanche_cpmac/avalanche_cpmac.o
13322 # link order important here
13324 obj-$(CONFIG_PLIP) += plip.o