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-22 01:03:12.609318544 +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 * 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 * 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 + p_skb->protocol = eth_type_trans(p_skb, p_dev);
3042 +//#if defined (CONFIG_MIPS_AVALANCHE_LED)
3043 +// avalanche_led_action(p_cpmac_priv->led_handle, CPMAC_RX_ACTIVITY);
3046 + p_cpmac_priv->net_dev_stats.rx_packets++;
3047 + p_cpmac_priv->net_dev_stats.rx_bytes += packet_size;
3049 + p_drv_hal->hal_funcs->RxReturn(hal_receive_info,1);
3053 +cpmac_hal_recv_alloc_failed:
3055 +#ifdef CPMAC_8021Q_SUPPORT
3056 +cpmac_hal_recv_frame_mismatch:
3063 + dev_kfree_skb_any(fragList[fragCount].OsInfo);
3065 + while(fragCount--);
3067 + p_cpmac_priv->net_dev_stats.rx_dropped++;
3070 +} /*cpmac_receive*/
3073 +void cpmac_hal_tear_down_complete(OS_DEVICE*a, int b, int ch)
3075 + dbgPrint("what to do with this.\n");
3079 +int cpmac_hal_send_complete(OS_SENDINFO *p_skb)
3081 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_skb->dev->priv;
3083 + p_cpmac_priv->net_dev_stats.tx_packets++;
3084 + p_cpmac_priv->net_dev_stats.tx_bytes += p_skb->len;
3086 + dev_kfree_skb_any(p_skb);
3092 +int cpmac_reset(CPMAC_PRIVATE_INFO_T *p_cpmac_priv)
3094 + // code here to reset the device/hal. Not now.
3096 + netif_wake_queue(p_cpmac_priv->owner);
3102 +#define isprint(a) ((a >=' ')&&(a<= '~'))
3103 +void xdump( u_char* cp, int length, char* prefix )
3106 + u_char prntBuf[120];
3107 + u_char* pBuf = prntBuf;
3109 + while(count < length){
3110 + pBuf += sprintf( pBuf, "%s", prefix );
3111 + for(col = 0;count + col < length && col < 16; col++){
3112 + if (col != 0 && (col % 4) == 0)
3113 + pBuf += sprintf( pBuf, " " );
3114 + pBuf += sprintf( pBuf, "%02X ", cp[count + col] );
3116 + while(col++ < 16){ /* pad end of buffer with blanks */
3117 + if ((col % 4) == 0)
3118 + sprintf( pBuf, " " );
3119 + pBuf += sprintf( pBuf, " " );
3121 + pBuf += sprintf( pBuf, " " );
3122 + for(col = 0;count + col < length && col < 16; col++){
3123 + if (isprint((int)cp[count + col]))
3124 + pBuf += sprintf( pBuf, "%c", cp[count + col] );
3126 + pBuf += sprintf( pBuf, "." );
3128 + sprintf( pBuf, "\n" );
3129 + // SPrint(prntBuf);
3135 +} /* close xdump(... */
3139 +static int __init cpmac_dev_probe(void)
3143 + int instance_count = CONFIG_MIPS_CPMAC_PORTS;
3145 + //cpmac_cpu_freq = avalanche_clkc_get_freq(CLKC_MIPS);
3146 + cpmac_cpu_freq = CONFIG_AR7_CPU * 1000 * 1000;
3148 + build_psp_config();
3150 + for(unit = 0; unit < instance_count; unit++)
3152 + struct net_device *p_dev;
3153 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv;
3157 + dev_size = sizeof(struct net_device)
3158 + + sizeof(CPMAC_PRIVATE_INFO_T);
3161 + if((p_dev = (struct net_device *) kmalloc(dev_size, GFP_KERNEL)) == NULL)
3163 + dbgPrint( "Could not allocate memory for device.\n" );
3168 + memset(p_dev, 0, dev_size );
3170 + p_dev->priv = p_cpmac_priv
3171 + = (CPMAC_PRIVATE_INFO_T*)(((char *) p_dev) + sizeof(struct net_device));
3172 + p_cpmac_priv->owner = p_dev;
3174 + ether_setup(p_dev);
3176 + p_cpmac_priv->instance_num = unit;
3177 + p_dev->init = cpmac_dev_init;
3179 + g_dev_array[p_cpmac_priv->instance_num] = p_dev;
3181 +#if defined CONFIG_MIPS_CPMAC_INIT_BUF_MALLOC
3182 + g_init_enable_flag = 1;
3183 + printk("Cpmac driver is allocating buffer memory at init time.\n");
3186 + /* This section gives a default value by the number of PHY in order to
3187 + * replace the default MACRO. */
3189 + char *mac_port = prom_getenv("MAC_PORT"); /* Internal: 0, External: 1 */
3190 + if(!mac_port || (0 != strcmp(mac_port, "0"))) {
3191 + printk("Using the MAC with external PHY\n");
3192 + cfg_start_link_speed = _CPMDIO_NOPHY;
3193 + cpmac_max_frame_size = CPMAC_MAX_FRAME_SIZE + 4;
3196 + printk("Using the MAC with internal PHY\n");
3197 + cfg_start_link_speed = CFG_START_LINK_SPEED;
3198 + cpmac_max_frame_size = CPMAC_MAX_FRAME_SIZE;
3200 + g_cfg_start_link_params = cfg_start_link_speed;
3203 + cpmac_p_detect_manual_cfg(cfg_link_speed, cfg_link_mode, cpmac_debug_mode);
3205 + failed = register_netdev(p_dev);
3208 + dbgPrint("Could not register device for inst %d because of reason \
3209 + code %d.\n", unit, failed);
3217 + char proc_name[100];
3218 + int proc_category_name_len = 0;
3220 + p_cpmac_priv->next_device = last_cpmac_device;
3221 + last_cpmac_device = p_dev;
3223 + dbgPrint(" %s irq=%2d io=%04x\n",p_dev->name, (int) p_dev->irq,
3224 + (int) p_dev->base_addr);
3226 + strcpy(proc_name, "avalanche/");
3227 + strcat(proc_name, p_dev->name);
3228 + proc_category_name_len = strlen(proc_name);
3230 + strcpy(proc_name + proc_category_name_len, "_rfc2665_stats");
3231 + create_proc_read_entry(proc_name,0,NULL,cpmac_p_read_rfc2665_stats, p_dev);
3238 + /* To maintain backward compatibility with NSP. */
3239 + gp_stats_file = create_proc_entry("avalanche/cpmac_stats", 0644, NULL);
3242 + gp_stats_file->read_proc = cpmac_p_read_stats;
3243 + gp_stats_file->write_proc = cpmac_p_write_stats;
3245 + create_proc_read_entry("avalanche/cpmac_link", 0, NULL, cpmac_p_read_link, NULL);
3246 + create_proc_read_entry("avalanche/cpmac_ver", 0, NULL, cpmac_p_get_version, NULL);
3250 + cpmac_devices_installed = unit;
3251 + dbgPrint("Installed %d cpmac instances.\n", unit);
3252 + return ( (unit >= 0 ) ? 0 : -ENODEV );
3254 +} /* init_module */
3257 +/***************************************************************
3265 + * Goes through the CpmacDevices list and frees the device
3266 + * structs and memory associated with each device (lists
3267 + * and buffers). It also ureserves the IO port regions
3268 + * associated with this device.
3270 + **************************************************************/
3272 +void cpmac_exit(void)
3274 + struct net_device *p_dev;
3275 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv;
3277 + while (cpmac_devices_installed)
3279 + char proc_name[100];
3280 + int proc_category_name_len = 0;
3282 + p_dev = last_cpmac_device;
3283 + p_cpmac_priv = (CPMAC_PRIVATE_INFO_T *) p_dev->priv;
3285 + dbgPrint("Unloading %s irq=%2d io=%04x\n",p_dev->name, (int) p_dev->irq, (int) p_dev->base_addr);
3287 + if(g_init_enable_flag)
3288 + cpmac_p_dev_disable(p_dev);
3290 + cpmac_drv_cleanup(p_cpmac_priv->drv_hal);
3292 +//#if defined (CONFIG_MIPS_AVALANCHE_LED)
3293 +// avalanche_led_unregister(p_cpmac_priv->led_handle);
3295 + strcpy(proc_name, "avalanche/");
3296 + strcat(proc_name, p_dev->name);
3297 + proc_category_name_len = strlen(proc_name);
3299 + strcpy(proc_name + proc_category_name_len, "_rfc2665_stats");
3300 + remove_proc_entry(proc_name, NULL);
3302 + release_mem_region(p_dev->base_addr, p_cpmac_priv->dev_size);
3303 + unregister_netdev(p_dev);
3304 + last_cpmac_device = p_cpmac_priv->next_device;
3306 + kfree(p_cpmac_priv->drv_hal);
3309 + cpmac_devices_installed--;
3313 + remove_proc_entry("avalanche/cpmac_stats", NULL);
3315 + remove_proc_entry("avalanche/cpmac_link", NULL);
3316 + remove_proc_entry("avalanche/cpmac_ver", NULL);
3318 + psp_config_cleanup();
3322 +module_init(cpmac_dev_probe);
3323 +module_exit(cpmac_exit);
3324 diff -urN linux.old/drivers/net/avalanche_cpmac/cpmac.h linux.dev/drivers/net/avalanche_cpmac/cpmac.h
3325 --- linux.old/drivers/net/avalanche_cpmac/cpmac.h 1970-01-01 01:00:00.000000000 +0100
3326 +++ linux.dev/drivers/net/avalanche_cpmac/cpmac.h 2005-07-12 02:48:42.043594000 +0200
3328 +/******************************************************************************
3329 + * FILE PURPOSE: CPMAC Linux Network Device Driver Header
3330 + ******************************************************************************
3331 + * FILE NAME: cpmac.h
3333 + * DESCRIPTION: CPMAC Network Device Driver Header
3335 + * REVISION HISTORY:
3336 + * Date Name Details
3337 + *-----------------------------------------------------------------------------
3338 + * 27 Nov 2002 Suraj S Iyer Initial Create.
3339 + * 09 Jun 2003 Suraj S Iyer Preparing for GA.
3341 + * (C) Copyright 2003, Texas Instruments, Inc
3342 + *******************************************************************************/
3347 +#include <linux/timer.h>
3348 +#include <linux/netdevice.h>
3349 +#include <asm/semaphore.h>
3350 +#include <linux/ctype.h>
3351 +#include <linux/interrupt.h>
3353 +#include "cpmacHalLx.h"
3354 +/*-----------------------------------------------------------------------------
3355 + * Config macros. Use these to config the driver.
3356 + *---------------------------------------------------------------------------*/
3357 +#define CPMAC_MAX_FRAME_SIZE 1518
3359 +#if defined(CONFIG_AR7WRD) || defined(CONFIG_AR7WI) || defined(CONFIG_AR7VWI)|| defined(CONFIG_AR7VW)
3360 +#define CFG_RX_NUM_BUF_DESC 64
3361 +#define CFG_RX_NUM_BUF_SERVICE 32
3363 +#define CFG_RX_NUM_BUF_DESC 16
3364 +#define CFG_RX_NUM_BUF_SERVICE 8
3367 +#define CFG_RX_BUF_OFFSET 0
3369 +#define CFG_TX_NUM_BUF_DESC 128
3370 +#define CFG_TX_NUM_BUF_SERVICE 20
3371 +#define CFG_TX_BUF_OFFSET 0 /* Lets not change this. */
3372 +#define CFG_TX_TIMEOUT 2000 /* ticks*/
3373 +#define CFG_TX_INT_DISABLE 1 /* Disable the Tx Complete interrupt */
3375 +#define CFG_JUMBO_FRAMES 1
3376 +#define CFG_SHORT_FRAMES 1
3377 +#define CFG_PROMISCOUS 1
3378 +#define CFG_BROADCAST 1
3379 +#define CFG_MULTICAST 1
3380 +#define CFG_ALL_MULTI (1*(CFG_MULTICAST))
3381 +#define CFG_AUTO_NEGOTIATION 1
3383 +#if defined (CONFIG_MIPS_AVALANCHE_MARVELL)
3384 +#define EGRESS_TRAILOR_LEN 4
3385 +#define CFG_START_LINK_SPEED (_CPMDIO_NOPHY)
3386 +#undef CPMAC_MAX_FRAME_SIZE
3387 +#define CPMAC_MAX_FRAME_SIZE (1518 + EGRESS_TRAILOR_LEN)
3389 +#define CFG_START_LINK_SPEED (_CPMDIO_10 | _CPMDIO_100 | _CPMDIO_HD | _CPMDIO_FD) /* auto nego */
3392 +#define CFG_LOOP_BACK 1
3393 +#define CFG_TX_FLOW_CNTL 0
3394 +#define CFG_RX_FLOW_CNTL 0
3395 +#define CFG_TX_PACING 0
3396 +#define CFG_RX_PASS_CRC 0
3397 +#define CFG_QOS_802_1Q 0
3398 +#define CFG_TX_NUM_CHAN 1
3401 +/*-----------------------------------------------------------------------------
3403 + *---------------------------------------------------------------------------*/
3404 +#define MAX_TIMER 2
3406 +#define TICK_TIMER 0
3407 +#define MAX_TX_CHAN 8
3409 +#define CPMAC_LINK_OFF 0
3410 +#define CPMAC_LINK_ON 1
3411 +/*#define CPMAC_SPEED_100 2
3412 +#define CPMAC_SPEED_10 3
3413 +#define CPMAC_FULL_DPLX 4
3414 +#define CPMAC_HALF_DPLX 5*/
3415 +#define CPMAC_RX_ACTIVITY 2
3416 +#define CPMAC_TX_ACTIVITY 3
3418 +struct cpmac_timer_info;
3420 +typedef int (*CPMAC_HAL_ISR_FUNC_T)(HAL_DEVICE*, int*);
3421 +typedef int (*CPMAC_TIMEOUT_CB_T)(struct cpmac_timer_info*);
3423 +typedef struct cpmac_ability_info
3432 + int auto_negotiation;
3433 + int tx_flow_control;
3434 + int rx_flow_control;
3441 +CPMAC_ABILITY_INFO_T;
3444 +typedef struct cpmac_timer_info
3447 + UINT32 delay_ticks;
3449 + UINT32 is_running;
3450 + UINT32 timer_set_at;
3451 + CPMAC_TIMEOUT_CB_T timeout_CB;
3452 +} CPMAC_TIMER_INFO_T;
3457 + unsigned int num_cl_desc;
3458 + CL_DESC *cl_desc_tbl;
3459 + M_CL_CONFIG *m_cl_blk_config;
3460 + NET_POOL *net_pool;
3461 + CL_POOL_ID clPoolId;
3463 +} CPMAC_NET_MEM_INFO_T;
3470 + CPMAC_HAL_ISR_FUNC_T hal_isr;
3471 + struct tasklet_struct tasklet;
3474 +} CPMAC_ISR_INFO_T;
3476 +typedef struct cpmac_chan
3480 + int buffer_offset;
3484 + int tot_reserve_bytes;
3488 +#define CHAN_CLOSE 0
3489 +#define CHAN_OPENED 1
3496 + CPMAC_CHAN_T chan[1];
3497 + int enable_802_1q;
3499 +} CPMAC_RX_CHAN_INFO_T;
3506 + int tx_int_disable;
3507 + CPMAC_CHAN_T chan[MAX_TX_CHAN];
3509 +} CPMAC_TX_CHAN_INFO_T;
3516 + HAL_FUNCTIONS *hal_funcs;
3517 + HAL_DEVICE *hal_dev;
3518 + OS_FUNCTIONS *os_funcs;
3519 +// SEM_ID chan_teardown_sem;
3520 + int non_data_irq_expected;
3521 +} CPMAC_DRV_HAL_INFO_T;
3526 + unsigned long tx_discards;
3527 + unsigned long rx_discards;
3528 + unsigned long start_tick;
3530 +} CPMAC_DRV_STATS_T;
3534 + unsigned long ifInGoodFrames;
3535 + unsigned long ifInBroadcasts;
3536 + unsigned long ifInMulticasts;
3537 + unsigned long ifInPauseFrames;
3538 + unsigned long ifInCRCErrors;
3539 + unsigned long ifInAlignCodeErrors;
3540 + unsigned long ifInOversizedFrames;
3541 + unsigned long ifInJabberFrames;
3542 + unsigned long ifInUndersizedFrames;
3543 + unsigned long ifInFragments;
3544 + unsigned long ifInFilteredFrames;
3545 + unsigned long ifInQosFilteredFrames;
3546 + unsigned long ifInOctets;
3547 + unsigned long ifOutGoodFrames;
3548 + unsigned long ifOutBroadcasts;
3549 + unsigned long ifOutMulticasts;
3550 + unsigned long ifOutPauseFrames;
3551 + unsigned long ifDeferredTransmissions;
3552 + unsigned long ifCollisionFrames;
3553 + unsigned long ifSingleCollisionFrames;
3554 + unsigned long ifMultipleCollisionFrames;
3555 + unsigned long ifExcessiveCollisionFrames;
3556 + unsigned long ifLateCollisions;
3557 + unsigned long ifOutUnderrun;
3558 + unsigned long ifCarrierSenseErrors;
3559 + unsigned long ifOutOctets;
3560 + unsigned long if64OctetFrames;
3561 + unsigned long if65To127OctetFrames;
3562 + unsigned long if128To255OctetFrames;
3563 + unsigned long if256To511OctetFrames;
3564 + unsigned long if512To1023OctetFrames;
3565 + unsigned long if1024ToUPOctetFrames;
3566 + unsigned long ifNetOctets;
3567 + unsigned long ifRxSofOverruns;
3568 + unsigned long ifRxMofOverruns;
3569 + unsigned long ifRxDMAOverruns;
3571 +} CPMAC_DEVICE_MIB_T;
3578 + int timer_created;
3579 + struct timer_list timer[1];
3580 + CPMAC_DRV_HAL_INFO_T *drv_hal;
3581 + unsigned int num_of_intr;
3582 + CPMAC_ISR_INFO_T cpmac_isr;
3583 + unsigned int link_speed;
3584 + unsigned int link_mode;
3585 + unsigned int enable_802_1q;
3586 + unsigned int timer_access_hal;
3587 + unsigned int loop_back;
3588 + CPMAC_RX_CHAN_INFO_T *rx_chan_info;
3589 + CPMAC_TX_CHAN_INFO_T *tx_chan_info;
3590 + CPMAC_ABILITY_INFO_T *ability_info;
3591 + CPMAC_DEVICE_MIB_T *device_mib;
3592 + CPMAC_DRV_STATS_T *stats;
3593 + unsigned int flags;
3594 + unsigned int delay_ticks;
3596 + struct net_device_stats net_dev_stats;
3597 +// rwlock_t rw_lock;
3599 + struct net_device *next_device;
3600 + unsigned int instance_num;
3601 + unsigned int non_data_irq_expected;
3602 + unsigned long dev_size;
3604 +} CPMAC_PRIVATE_INFO_T;
3607 +/* Private flags */
3609 +/* bit 0 to 31, bit 32 is used to indicate set or reset */
3611 +#define IFF_PRIV_SHORT_FRAMES 0x00010000
3612 +#define IFF_PRIV_JUMBO_FRAMES 0x00020000
3613 +#define IFF_PRIV_AUTOSPEED 0x00080000
3614 +#define IFF_PRIV_LINK10_HD 0x00100000
3615 +#define IFF_PRIV_LINK10_FD 0x00200000
3616 +#define IFF_PRIV_LINK100_HD 0x00400000
3617 +#define IFF_PRIV_LINK100_FD 0x00800000
3618 +#define IFF_PRIV_8021Q_EN 0x01000000
3619 +#define IFF_PRIV_NUM_TX_CHAN 0x02000000
3620 +#define IFF_PRIV_TX_FLOW_CNTL 0x04000000
3621 +#define IFF_PRIV_RX_FLOW_CNTL 0x08000000
3622 +#define IFF_PRIV_TX_PACING 0x10000000
3623 +#define IFF_PRIV_RX_PASS_CRC 0x20000000
3625 +#define PRIVCSFLAGS 0x200
3626 +#define PRIVCGFLAGS 0x201
3630 +#define CHAN_TEARDOWN 2
3631 +#define CHAN_SETUP 4
3633 +#define FREE_BUFFER 16
3636 +static const char pszStats0[] = "Stats0";
3637 +static const char pszStats1[] = "Stats1";
3638 +static const char pszStats2[] = "Stats2";
3639 +static const char pszStats3[] = "Stats3";
3640 +static const char pszStats4[] = "Stats4";
3641 +static const char pszStatsDump[] = "StatsDump";
3642 +static const char pszStatsClear[] = "StatsClear";
3643 +static const char pszRX_PASS_CRC[] = "RX_PASS_CRC";
3644 +static const char pszRX_QOS_EN[] = "RX_QOS_EN";
3645 +static const char pszRX_NO_CHAIN[] = "RX_NO_CHAIN";
3646 +static const char pszRX_CMF_EN[] = "RX_CMF_EN";
3647 +static const char pszRX_CSF_EN[] = "RX_CSF_EN";
3648 +static const char pszRX_CEF_EN[] = "RX_CEF_EN";
3649 +static const char pszRX_CAF_EN[] = "RX_CAF_EN";
3650 +static const char pszRX_PROM_CH[] = "RX_PROM_CH";
3651 +static const char pszRX_BROAD_EN[] = "RX_BROAD_EN";
3652 +static const char pszRX_BROAD_CH[] = "RX_BROAD_CH";
3653 +static const char pszRX_MULT_EN[] = "RX_MULT_EN";
3654 +static const char pszRX_MULT_CH[] = "RX_MULT_CH";
3655 +static const char pszTX_PTYPE[] = "TX_PTYPE";
3656 +static const char pszTX_PACE[] = "TX_PACE";
3657 +static const char pszMII_EN[] = "MII_EN";
3658 +static const char pszTX_FLOW_EN[] = "TX_FLOW_EN";
3659 +static const char pszRX_FLOW_EN[] = "RX_FLOW_EN";
3660 +static const char pszRX_MAXLEN[] = "RX_MAXLEN";
3661 +static const char pszRX_FILTERLOWTHRESH[] = "RX_FILTERLOWTHRESH";
3662 +static const char pszRX0_FLOWTHRESH[] = "RX0_FLOWTHRESH";
3663 +static const char pszRX_UNICAST_SET[] = "RX_UNICAST_SET";
3664 +static const char pszRX_UNICAST_CLEAR[] = "RX_UNICAST_CLEAR";
3665 +static const char pszMdioConnect[] = "MdioConnect";
3666 +static const char pszMacAddr[] = "MacAddr";
3667 +static const char pszTick[] = "Tick";
3668 +static const char pszRX_MULTICAST[] = "RX_MULTICAST";
3669 +static const char pszRX_MULTI_ALL[] = "RX_MULTI_ALL";
3670 +static const char pszRX_MULTI_SINGLE[] = "RX_MULTI_SINGLE";
3672 +static const char pszSet[] = "Set";
3673 +static const char pszGet[] = "Get";
3674 +static const char pszClear[] = "Clear";
3677 +void *cpmac_hal_malloc_buffer(unsigned int size, void *MemBase, unsigned int MemRange,
3678 + HAL_DEVICE *HalDev, HAL_RECEIVEINFO *HalReceiveInfo,
3679 + OS_RECEIVEINFO **OsReceiveInfo, OS_DEVICE *OsDev);
3681 +void cpmac_hal_tear_down_complete(OS_DEVICE*, int, int);
3682 +int cpmac_hal_control(OS_DEVICE *p_END_obj, const char *key,
3683 + const char *action, void *value);
3684 +int cpmac_hal_receive(OS_DEVICE *p_END_obj, FRAGLIST *fragList,
3685 + unsigned int FragCount, unsigned int pkt_len,
3686 + HAL_RECEIVEINFO *halReceiveInfo,
3687 + unsigned int mode);
3688 +int cpmac_hal_send_complete(OS_SENDINFO*);
3690 +void cpmac_hal_isr(int irq, void *p_param, struct pt_regs *p_cb_param);
3691 +void cpmac_handle_tasklet(unsigned long data);
3693 +inline static int cpmac_ci_strcmp(const char *s1, const char *s2)
3697 + if(tolower(*s1) != tolower(*s2))
3703 + return(tolower(*s1) - tolower(*s2));
3707 diff -urN linux.old/drivers/net/avalanche_cpmac/cpmacHalLx.c linux.dev/drivers/net/avalanche_cpmac/cpmacHalLx.c
3708 --- linux.old/drivers/net/avalanche_cpmac/cpmacHalLx.c 1970-01-01 01:00:00.000000000 +0100
3709 +++ linux.dev/drivers/net/avalanche_cpmac/cpmacHalLx.c 2005-07-12 02:48:42.044593000 +0200
3711 +/******************************************************************************
3712 + * FILE PURPOSE: CPMAC Net Driver HAL support Source
3713 + ******************************************************************************
3714 + * FILE NAME: cpmacHalLx.c
3716 + * DESCRIPTION: CPMAC Network Device Driver Source
3718 + * REVISION HISTORY:
3720 + * Date Description Author
3721 + *-----------------------------------------------------------------------------
3722 + * 27 Nov 2002 Initial Creation Suraj S Iyer
3723 + * 09 Jun 2003 Updates for GA Suraj S Iyer
3724 + * 18 Dec 2003 Updated for 5.7 Suraj S Iyer
3726 + * (C) Copyright 2003, Texas Instruments, Inc
3727 + *******************************************************************************/
3728 +#include <linux/kernel.h>
3729 +#include <linux/module.h>
3730 +#include <linux/init.h>
3731 +#include <linux/netdevice.h>
3732 +#include <linux/etherdevice.h>
3733 +#include <linux/delay.h>
3734 +#include <linux/spinlock.h>
3735 +#include <linux/proc_fs.h>
3736 +#include <asm/io.h>
3737 +#include <linux/string.h>
3739 +#include "cpmacHalLx.h"
3742 +/* PSP config headers */
3743 +#include "psp_config_parse.h"
3744 +#include "psp_config_mgr.h"
3746 +/* Probe Debug Section*/
3749 +extern int cpmac_debug_mode;
3750 +#define dbgPrint if (cpmac_debug_mode) printk
3751 +#define errPrint printk
3753 +char CpmacSignature[] = "Cpmac driver";
3754 +static unsigned long irq_flags = 0;
3755 +OS_SETUP *p_os_setup = NULL;
3757 +extern int avalanche_request_intr_pacing(int, unsigned int, unsigned int);
3758 +extern int avalanche_free_intr_pacing(unsigned int blk_num);
3760 +/*----------------------------------------------------------------------------
3761 + * Parameter extracting functionalities.
3762 + *--------------------------------------------------------------------------*/
3763 +static int os_find_parm_u_int(void *info_ptr, const char *param, unsigned int *val)
3767 + if((ret_val = psp_config_get_param_uint(info_ptr, param, val)) == -1)
3769 + dbgPrint("Error: could not locate the requested \"%s\" param.\n",param);
3776 +static int os_find_parm_val(void *info_ptr, const char *param, void *val)
3780 + if(psp_config_get_param_string(info_ptr, param, val) == -1)
3782 + dbgPrint("Error: could not locate the requested \"%s\" param.\n",param);
3789 +static int os_find_device(int unit, const char *find_name, void *device_info)
3793 + if(psp_config_get((char *)find_name, unit, device_info) == -1)
3795 + dbgPrint("Error: could not locate the requested \"%s\" param.\n", find_name);
3802 +/*---------------------------------------------------------------------------
3803 + * Memory related OS abstraction.
3804 + *--------------------------------------------------------------------------*/
3805 +void os_free(void *mem_ptr)
3810 +void os_free_buffer(OS_RECEIVEINFO *osReceiveInfo, void *mem_ptr)
3812 + dev_kfree_skb_any(osReceiveInfo);
3815 +void os_free_dev(void *mem_ptr)
3820 +void os_free_dma_xfer(void *mem_ptr)
3825 +static void *os_malloc(unsigned int size)
3827 + return(kmalloc(size, GFP_KERNEL));
3830 +static void *os_malloc_dma_xfer(unsigned int size,
3832 + unsigned int mem_range)
3834 + return(kmalloc(size, GFP_KERNEL));
3837 +static void *os_malloc_dev(unsigned int size)
3839 + return(kmalloc(size, GFP_KERNEL));
3843 +/*----------------------------------------------------------------------------
3844 + * CRITICAL SECTION ENABLING/DISABLING.
3845 + *--------------------------------------------------------------------------*/
3846 +static void os_critical_on(void)
3848 + save_and_cli(irq_flags);
3851 +static void os_critical_off(void)
3853 + restore_flags(irq_flags);
3856 +/*----------------------------------------------------------------------------
3857 + * Cache related abstraction
3858 + *--------------------------------------------------------------------------*/
3859 +static void os_cache_invalidate(void *mem_ptr, int size)
3861 + dma_cache_inv((unsigned long)mem_ptr, size);
3864 +static void os_cache_writeback(void *mem_ptr, int size)
3866 + dma_cache_wback_inv((unsigned long)mem_ptr, size);
3869 +/*-----------------------------------------------------------------------------
3870 + * Support functions.
3871 + *---------------------------------------------------------------------------*/
3873 +static void hal_drv_unregister_isr(OS_DEVICE *p_dev, int intr)
3875 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_dev->priv;
3876 + CPMAC_ISR_INFO_T *p_isr_cb_param = &p_cpmac_priv->cpmac_isr;
3877 + intr = LNXINTNUM(intr);
3879 + free_irq(p_isr_cb_param->intr, p_isr_cb_param);
3881 + dbgPrint("cpmac_hal_unregister called for the intr %d for unit %x and isr_cb_param %x.\n",
3882 + intr, p_cpmac_priv->instance_num, (unsigned int )&p_cpmac_priv->cpmac_isr);
3886 +static void hal_drv_register_isr(OS_DEVICE *p_dev,
3887 + CPMAC_HAL_ISR_FUNC_T hal_isr, int intr)
3889 + CPMAC_PRIVATE_INFO_T *p_cpmac_priv = p_dev->priv;
3890 + CPMAC_DRV_HAL_INFO_T *p_drv_hal = p_cpmac_priv->drv_hal;
3891 + CPMAC_ISR_INFO_T *p_isr_cb_param = &p_cpmac_priv->cpmac_isr;
3892 + intr = LNXINTNUM(intr);
3894 + dbgPrint("osRegister called for the intr %d for device %x and p_isr_cb_param %x.\n",
3895 + intr, (bit32u)p_dev, (bit32u)p_isr_cb_param);
3897 + p_isr_cb_param->owner = p_drv_hal;
3898 + p_isr_cb_param->hal_isr = hal_isr;
3899 + p_isr_cb_param->intr = intr;
3901 + tasklet_init(&p_isr_cb_param->tasklet, cpmac_handle_tasklet, (unsigned long)p_isr_cb_param);
3902 + dbgPrint("Success in registering irq %d for Cpmac unit# %d.\n", intr, p_cpmac_priv->instance_num);
3905 +/*---------------------------------------------------------------------------
3906 + * FUNCTIONS called by the CPMAC Net Device.
3907 + *-------------------------------------------------------------------------*/
3908 +static int load_os_funcs(OS_FUNCTIONS *os_func)
3910 + dbgPrint("os_init_module: Start\n");
3911 + if( os_func == 0 )
3913 + return(sizeof(OS_FUNCTIONS));
3916 + os_func->Control = cpmac_hal_control;
3917 + os_func->CriticalOn = os_critical_on;
3918 + os_func->CriticalOff = os_critical_off;
3919 + os_func->DataCacheHitInvalidate = os_cache_invalidate;
3920 + os_func->DataCacheHitWriteback = os_cache_writeback;
3921 + os_func->DeviceFindInfo = os_find_device;
3922 + os_func->DeviceFindParmUint = os_find_parm_u_int;
3923 + os_func->DeviceFindParmValue= os_find_parm_val;
3924 + os_func->Free = os_free;
3925 + os_func->FreeRxBuffer = os_free_buffer;
3926 + os_func->FreeDev = os_free_dev;
3927 + os_func->FreeDmaXfer = os_free_dma_xfer;
3928 + os_func->IsrRegister = hal_drv_register_isr;
3929 + os_func->IsrUnRegister = hal_drv_unregister_isr;
3930 + os_func->Malloc = os_malloc;
3931 + os_func->MallocDev = os_malloc_dev;
3932 + os_func->MallocDmaXfer = os_malloc_dma_xfer;
3933 + os_func->MallocRxBuffer = cpmac_hal_malloc_buffer;
3934 + os_func->Memset = memset;
3935 + os_func->Printf = printk;
3936 + os_func->Receive = cpmac_hal_receive;
3937 + os_func->SendComplete = cpmac_hal_send_complete;
3938 + os_func->Strcmpi = cpmac_ci_strcmp;
3939 + os_func->TeardownComplete = cpmac_hal_tear_down_complete;
3940 + os_func->Strstr = strstr;
3941 + os_func->Strtoul = simple_strtol;
3942 + os_func->Sprintf = sprintf;
3943 + os_func->Strlen = strlen;
3945 + dbgPrint("os_init_module: Leave\n");
3951 +int cpmac_drv_init(CPMAC_DRV_HAL_INFO_T *p_drv_hal)
3953 + HAL_DEVICE *p_hal_dev = p_drv_hal->hal_dev;
3954 + HAL_FUNCTIONS *p_hal_funcs = p_drv_hal->hal_funcs;
3956 + return(p_hal_funcs->Init(p_hal_dev));
3959 +int cpmac_drv_cleanup(CPMAC_DRV_HAL_INFO_T *p_drv_hal)
3961 + HAL_DEVICE *p_hal_dev = p_drv_hal->hal_dev;
3962 + HAL_FUNCTIONS *p_hal_funcs = p_drv_hal->hal_funcs;
3964 + int ret_val = p_hal_funcs->Shutdown(p_hal_dev);
3968 + kfree(p_hal_funcs);
3973 + kfree(p_drv_hal->os_funcs);
3978 +int cpmac_drv_tx_setup(HAL_FUNCTIONS *p_hal_funcs,
3979 + HAL_DEVICE *p_hal_dev,
3980 + CPMAC_TX_CHAN_INFO_T *p_tx_chan_info)
3984 + CHANNEL_INFO chan_info;
3986 + /* Let's setup the TX Channels. */
3987 + for(count=0; count < p_tx_chan_info->cfg_chan; count++)
3989 + chan_info.Channel = count;
3990 + chan_info.Direction = DIRECTION_TX;
3991 + chan_info.TxNumBuffers = p_tx_chan_info->chan[count].num_BD;
3992 + chan_info.TxServiceMax = p_tx_chan_info->chan[count].service_max;
3993 + chan_info.TxNumQueues = 0;
3995 + if((ret_val = p_hal_funcs->ChannelSetup(p_hal_dev, &chan_info,
3998 + errPrint("Error in opening channel %d for TX.\n", count);
4003 + p_tx_chan_info->opened_chan++;
4009 +int cpmac_drv_rx_setup(HAL_FUNCTIONS *p_hal_funcs,
4010 + HAL_DEVICE *p_hal_dev,
4011 + CPMAC_RX_CHAN_INFO_T *p_rx_chan_info)
4014 + CHANNEL_INFO chan_info;
4016 + chan_info.Channel = 0;
4017 + chan_info.Direction = DIRECTION_RX;
4018 + chan_info.RxBufSize = p_rx_chan_info->chan[0].buffer_size;
4019 + chan_info.RxBufferOffset= p_rx_chan_info->chan[0].buffer_offset;
4020 + chan_info.RxNumBuffers = p_rx_chan_info->chan[0].num_BD;
4021 + chan_info.RxServiceMax = p_rx_chan_info->chan[0].service_max;
4023 + if(p_hal_funcs->ChannelSetup(p_hal_dev, &chan_info, p_rx_chan_info) != 0)
4025 + errPrint("Error in opening channel %d for RX.\n", 0);
4032 +int cpmac_drv_start(CPMAC_DRV_HAL_INFO_T *p_drv_hal,
4033 + CPMAC_TX_CHAN_INFO_T *p_tx_chan_info,
4034 + CPMAC_RX_CHAN_INFO_T *p_rx_chan_info,
4035 + unsigned int flags)
4038 + HAL_FUNCTIONS *p_hal_funcs = p_drv_hal->hal_funcs;
4039 + HAL_DEVICE *p_hal_dev = p_drv_hal->hal_dev;
4041 + dbgPrint("It is in cpmac_drv_start for %x.\n", (unsigned int)p_drv_hal);
4043 + if(flags & CHAN_SETUP)
4045 + if(cpmac_drv_tx_setup(p_hal_funcs, p_hal_dev,
4046 + p_tx_chan_info)!=0)
4048 + errPrint("Failed to set up tx channel(s).\n");
4051 + else if(cpmac_drv_rx_setup(p_hal_funcs, p_hal_dev,
4052 + p_rx_chan_info)!=0)
4054 + errPrint("Failed to set up rx channel.\n");
4063 + /* Error in setting up the Channels, quit. */
4064 + if((ret_val == 0) && (ret_val = p_hal_funcs->Open(p_hal_dev)) != 0)
4066 + errPrint("failed to open the HAL!!!.\n");
4071 +} /* cpmac_drv_start */
4075 +int cpmac_drv_tx_teardown(HAL_FUNCTIONS *p_hal_funcs,
4076 + HAL_DEVICE *p_hal_dev,
4077 + CPMAC_TX_CHAN_INFO_T *p_tx_chan_info,
4078 + unsigned int flags)
4083 + /* Let's setup the TX Channels. */
4084 + for(; p_tx_chan_info->opened_chan > 0;
4085 + p_tx_chan_info->opened_chan--, count++)
4087 + if(p_hal_funcs->ChannelTeardown(p_hal_dev, count, flags) != 0)
4089 + errPrint("Error in tearing down channel %d for TX.\n", count);
4099 +int cpmac_drv_rx_teardown(HAL_FUNCTIONS *p_hal_funcs,
4100 + HAL_DEVICE *p_hal_dev,
4101 + unsigned int flags)
4105 + if(p_hal_funcs->ChannelTeardown(p_hal_dev, 0, flags) != 0)
4107 + errPrint("Error in tearing down channel %d for RX.\n", 0);
4114 +int cpmac_drv_stop(CPMAC_DRV_HAL_INFO_T *p_drv_hal,
4115 + CPMAC_TX_CHAN_INFO_T *p_tx_chan_info,
4116 + CPMAC_RX_CHAN_INFO_T *p_rx_chan_info,
4117 + unsigned int flags)
4119 + HAL_DEVICE *p_hal_dev = p_drv_hal->hal_dev;
4120 + HAL_FUNCTIONS *p_hal_funcs = p_drv_hal->hal_funcs;
4123 + if(flags & CHAN_TEARDOWN)
4125 + unsigned int chan_flags = 0;
4127 + if(flags & FREE_BUFFER) chan_flags |= 0x4; /* full tear down */
4128 + if(flags & BLOCKING) chan_flags |= 0x8; /* blocking call */
4130 + dbgPrint("The teardown flags are %d.\n", flags);
4131 + dbgPrint("The teardown chan flags are %d.\n", chan_flags);
4133 + if(cpmac_drv_tx_teardown(p_hal_funcs, p_hal_dev,
4134 + p_tx_chan_info, chan_flags | 0x1) != 0)
4137 + errPrint("The tx channel teardown failed.\n");
4139 + else if(cpmac_drv_rx_teardown(p_hal_funcs, p_hal_dev, chan_flags | 0x2) != 0)
4142 + errPrint("The rx channel teardown failed.\n");
4152 + int close_flags = 1;
4154 + if(flags & FREE_BUFFER) close_flags = 2;
4155 +// if(flags & COMPLETE) close_flags = 3;
4157 + if(p_hal_funcs->Close(p_hal_dev, close_flags) != 0)
4166 +int cpmac_drv_init_module(CPMAC_DRV_HAL_INFO_T *p_drv_hal, OS_DEVICE *p_os_dev, int inst)
4169 + int hal_func_size;
4171 + dbgPrint("Entering the CpmacInitModule for the inst %d \n", inst);
4173 + if((p_drv_hal->os_funcs = kmalloc(sizeof(OS_FUNCTIONS), GFP_KERNEL)) == NULL)
4175 + errPrint("Failed to allocate memory for OS_FUNCTIONS.\n");
4177 + else if(load_os_funcs(p_drv_hal->os_funcs) != 0)
4179 + errPrint("Failed to load OS funcs.\n");
4180 + os_free(p_drv_hal->os_funcs);
4182 + else if(halCpmacInitModule(&p_drv_hal->hal_dev, p_os_dev,
4183 + &p_drv_hal->hal_funcs, p_drv_hal->os_funcs,
4184 + sizeof(*p_drv_hal->os_funcs),
4185 + &hal_func_size, inst) != 0)
4187 + errPrint("halCpmacInitModule failed for inst %d \n", inst);
4188 + os_free(p_drv_hal->os_funcs);
4190 + else if(p_drv_hal->hal_funcs->Probe(p_drv_hal->hal_dev) != 0)
4192 + errPrint("halCpmacProbe failed for inst %d \n", inst);
4193 + os_free(p_drv_hal->os_funcs);
4197 + /* every thing went well. */
4203 diff -urN linux.old/drivers/net/avalanche_cpmac/cpmacHalLx.h linux.dev/drivers/net/avalanche_cpmac/cpmacHalLx.h
4204 --- linux.old/drivers/net/avalanche_cpmac/cpmacHalLx.h 1970-01-01 01:00:00.000000000 +0100
4205 +++ linux.dev/drivers/net/avalanche_cpmac/cpmacHalLx.h 2005-07-12 02:48:42.044593000 +0200
4207 +/******************************************************************************
4208 + * FILE PURPOSE: CPMAC Linux Device Driver HAL support Header
4209 + ******************************************************************************
4210 + * FILE NAME: cpmacHalVx.h
4212 + * DESCRIPTION: CPMAC Linux Device Driver Header
4214 + * REVISION HISTORY:
4216 + * Date Description Author
4217 + *-----------------------------------------------------------------------------
4218 + * 27 Nov 2002 Initial Creation Suraj S Iyer
4219 + * 09 Jun 2003 Updates for GA Suraj S Iyer
4221 + * (C) Copyright 2002, Texas Instruments, Inc
4222 + *******************************************************************************/
4224 +#ifndef __CPMAC_HAL_LX_H
4225 +#define __CPMAC_HAL_LX_H
4228 +typedef struct net_device OS_DEVICE;
4229 +typedef struct sk_buff OS_RECEIVEINFO;
4230 +typedef struct sk_buff OS_SENDINFO;
4233 +typedef void HAL_RECEIVEINFO;
4234 +typedef void HAL_DEVICE;
4235 +typedef void OS_SETUP;
4238 +#define OS_SETUP void
4239 +#define HAL_DEVICE void
4240 +#define HAL_RECEIVEINFO void
4242 +#define _CPHAL_CPMAC
4244 +#include "cpswhal_cpmac.h"
4247 +int cpmac_drv_start(CPMAC_DRV_HAL_INFO_T *, CPMAC_TX_CHAN_INFO_T*,
4248 + CPMAC_RX_CHAN_INFO_T *, unsigned int);
4249 +int cpmac_drv_cleanup(CPMAC_DRV_HAL_INFO_T *);
4250 +int cpmac_drv_init(CPMAC_DRV_HAL_INFO_T*);
4251 +int cpmac_drv_close(CPMAC_DRV_HAL_INFO_T*);
4252 +int cpmac_drv_open(CPMAC_DRV_HAL_INFO_T*);
4253 +int cpmac_drv_init_module(CPMAC_DRV_HAL_INFO_T*, OS_DEVICE*, int);
4254 +int cpmac_drv_stop(CPMAC_DRV_HAL_INFO_T *p_drv_hal,CPMAC_TX_CHAN_INFO_T *p_tx_chan_info,
4255 + CPMAC_RX_CHAN_INFO_T *p_rx_chan_info,unsigned int flags);
4258 diff -urN linux.old/drivers/net/avalanche_cpmac/cpmac_reg.h linux.dev/drivers/net/avalanche_cpmac/cpmac_reg.h
4259 --- linux.old/drivers/net/avalanche_cpmac/cpmac_reg.h 1970-01-01 01:00:00.000000000 +0100
4260 +++ linux.dev/drivers/net/avalanche_cpmac/cpmac_reg.h 2005-07-12 02:48:42.045593000 +0200
4262 +/****************************************************************************
4263 + TNETD73xx Software Support
4264 + Copyright(c) 2000, Texas Instruments Incorporated. All Rights Reserved.
4266 + FILE: cpmac_reg.h Register definitions for the CPMAC module
4269 + This include file contains register definitions for the
4273 + 15Nov00 BEGR Original version written
4274 + 30May02 MICK Added bits for Int Vector
4275 + 19Sep02 MICK Added INT_ACK per Channel
4276 + 08Nov02 GDUN Updated to use base
4277 + 12Nov02 MICK Incorporated into CPHAL
4278 +*****************************************************************************/
4279 +#ifndef _INC_CPMAC_REG
4280 +#define _INC_CPMAC_REG
4283 +#define MEM_PTR volatile bit32u *
4286 +/***************************************************************************
4288 + * C P M A C M E M O R Y M A P
4290 + **************************************************************************/
4292 +#define pCPMAC_TX_IDVER(base) ((MEM_PTR)(base+0x000))
4293 +#define CPMAC_TX_IDVER(base) (*pCPMAC_TX_IDVER(base))
4294 +#define pCPMAC_TX_CONTROL(base) ((MEM_PTR)(base+0x004))
4295 +#define CPMAC_TX_CONTROL(base) (*pCPMAC_TX_CONTROL(base))
4296 +#define pCPMAC_TX_TEARDOWN(base) ((MEM_PTR)(base+0x008))
4297 +#define CPMAC_TX_TEARDOWN(base) (*pCPMAC_TX_TEARDOWN(base))
4298 +#define pCPMAC_RX_IDVER(base) ((MEM_PTR)(base+0x010))
4299 +#define CPMAC_RX_IDVER(base) (*pCPMAC_RX_IDVER(base))
4300 +#define pCPMAC_RX_CONTROL(base) ((MEM_PTR)(base+0x014))
4301 +#define CPMAC_RX_CONTROL(base) (*pCPMAC_RX_CONTROL(base))
4302 +#define pCPMAC_RX_TEARDOWN(base) ((MEM_PTR)(base+0x018))
4303 +#define CPMAC_RX_TEARDOWN(base) (*pCPMAC_RX_TEARDOWN(base))
4304 +#define pCPMAC_RX_MBP_ENABLE(base) ((MEM_PTR)(base+0x100))
4305 +#define CPMAC_RX_MBP_ENABLE(base) (*pCPMAC_RX_MBP_ENABLE(base))
4306 +#define pCPMAC_RX_UNICAST_SET(base) ((MEM_PTR)(base+0x104))
4307 +#define CPMAC_RX_UNICAST_SET(base) (*pCPMAC_RX_UNICAST_SET(base))
4308 +#define pCPMAC_RX_UNICAST_CLEAR(base) ((MEM_PTR)(base+0x108))
4309 +#define CPMAC_RX_UNICAST_CLEAR(base) (*pCPMAC_RX_UNICAST_CLEAR(base))
4310 +#define pCPMAC_RX_MAXLEN(base) ((MEM_PTR)(base+0x10C))
4311 +#define CPMAC_RX_MAXLEN(base) (*pCPMAC_RX_MAXLEN(base))
4312 +#define pCPMAC_RX_BUFFER_OFFSET(base) ((MEM_PTR)(base+0x110))
4313 +#define CPMAC_RX_BUFFER_OFFSET(base) (*pCPMAC_RX_BUFFER_OFFSET(base))
4314 +#define pCPMAC_RX_FILTERLOWTHRESH(base) ((MEM_PTR)(base+0x114))
4315 +#define CPMAC_RX_FILTERLOWTHRESH(base) (*pCPMAC_RX_FILTERLOWTHRESH(base))
4316 +#define pCPMAC_RX0_FLOWTHRESH(base) ((MEM_PTR)(base+0x120))
4317 +#define CPMAC_RX0_FLOWTHRESH(base) (*pCPMAC_RX0_FLOWTHRESH(base))
4318 +#define pCPMAC_RX1_FLOWTHRESH(base) ((MEM_PTR)(base+0x124))
4319 +#define CPMAC_RX1_FLOWTHRESH(base) (*pCPMAC_RX1_FLOWTHRESH(base))
4320 +#define pCPMAC_RX2_FLOWTHRESH(base) ((MEM_PTR)(base+0x128))
4321 +#define CPMAC_RX2_FLOWTHRESH(base) (*pCPMAC_RX2_FLOWTHRESH(base))
4322 +#define pCPMAC_RX3_FLOWTHRESH(base) ((MEM_PTR)(base+0x12C))
4323 +#define CPMAC_RX3_FLOWTHRESH(base) (*pCPMAC_RX3_FLOWTHRESH(base))
4324 +#define pCPMAC_RX4_FLOWTHRESH(base) ((MEM_PTR)(base+0x130))
4325 +#define CPMAC_RX4_FLOWTHRESH(base) (*pCPMAC_RX4_FLOWTHRESH(base))
4326 +#define pCPMAC_RX5_FLOWTHRESH(base) ((MEM_PTR)(base+0x134))
4327 +#define CPMAC_RX5_FLOWTHRESH(base) (*pCPMAC_RX5_FLOWTHRESH(base))
4328 +#define pCPMAC_RX6_FLOWTHRESH(base) ((MEM_PTR)(base+0x138))
4329 +#define CPMAC_RX6_FLOWTHRESH(base) (*pCPMAC_RX6_FLOWTHRESH(base))
4330 +#define pCPMAC_RX7_FLOWTHRESH(base) ((MEM_PTR)(base+0x13C))
4331 +#define CPMAC_RX7_FLOWTHRESH(base) (*pCPMAC_RX7_FLOWTHRESH(base))
4332 +#define pCPMAC_RX0_FREEBUFFER(base) ((MEM_PTR)(base+0x140))
4333 +#define CPMAC_RX0_FREEBUFFER(base) (*pCPMAC_RX0_FREEBUFFER(base))
4334 +#define pCPMAC_RX1_FREEBUFFER(base) ((MEM_PTR)(base+0x144))
4335 +#define CPMAC_RX1_FREEBUFFER(base) (*pCPMAC_RX1_FREEBUFFER(base))
4336 +#define pCPMAC_RX2_FREEBUFFER(base) ((MEM_PTR)(base+0x148))
4337 +#define CPMAC_RX2_FREEBUFFER(base) (*pCPMAC_RX2_FREEBUFFER(base))
4338 +#define pCPMAC_RX3_FREEBUFFER(base) ((MEM_PTR)(base+0x14C))
4339 +#define CPMAC_RX3_FREEBUFFER(base) (*pCPMAC_RX3_FREEBUFFER(base))
4340 +#define pCPMAC_RX4_FREEBUFFER(base) ((MEM_PTR)(base+0x150))
4341 +#define CPMAC_RX4_FREEBUFFER(base) (*pCPMAC_RX4_FREEBUFFER(base))
4342 +#define pCPMAC_RX5_FREEBUFFER(base) ((MEM_PTR)(base+0x154))
4343 +#define CPMAC_RX5_FREEBUFFER(base) (*pCPMAC_RX5_FREEBUFFER(base))
4344 +#define pCPMAC_RX6_FREEBUFFER(base) ((MEM_PTR)(base+0x158))
4345 +#define CPMAC_RX6_FREEBUFFER(base) (*pCPMAC_RX6_FREEBUFFER(base))
4346 +#define pCPMAC_RX7_FREEBUFFER(base) ((MEM_PTR)(base+0x15C))
4347 +#define CPMAC_RX7_FREEBUFFER(base) (*pCPMAC_RX7_FREEBUFFER(base))
4348 +#define pCPMAC_MACCONTROL(base) ((MEM_PTR)(base+0x160))
4349 +#define CPMAC_MACCONTROL(base) (*pCPMAC_MACCONTROL(base))
4350 +#define pCPMAC_MACSTATUS(base) ((MEM_PTR)(base+0x164))
4351 +#define CPMAC_MACSTATUS(base) (*pCPMAC_MACSTATUS(base))
4352 +#define pCPMAC_EMCONTROL(base) ((MEM_PTR)(base+0x168))
4353 +#define CPMAC_EMCONTROL(base) (*pCPMAC_EMCONTROL(base))
4354 +#define pCPMAC_TX_INTSTAT_RAW(base) ((MEM_PTR)(base+0x170))
4355 +#define CPMAC_TX_INTSTAT_RAW(base) (*pCPMAC_TX_INTSTAT_RAW(base))
4356 +#define pCPMAC_TX_INTSTAT_MASKED(base) ((MEM_PTR)(base+0x174))
4357 +#define CPMAC_TX_INTSTAT_MASKED(base) (*pCPMAC_TX_INTSTAT_MASKED(base))
4358 +#define pCPMAC_TX_INTMASK_SET(base) ((MEM_PTR)(base+0x178))
4359 +#define CPMAC_TX_INTMASK_SET(base) (*pCPMAC_TX_INTMASK_SET(base))
4360 +#define pCPMAC_TX_INTMASK_CLEAR(base) ((MEM_PTR)(base+0x17C))
4361 +#define CPMAC_TX_INTMASK_CLEAR(base) (*pCPMAC_TX_INTMASK_CLEAR(base))
4362 +#define pCPMAC_MAC_IN_VECTOR(base) ((MEM_PTR)(base+0x180))
4363 +#define CPMAC_MAC_IN_VECTOR(base) (*pCPMAC_MAC_IN_VECTOR(base))
4364 +#define pCPMAC_MAC_EOI_VECTOR(base) ((MEM_PTR)(base+0x184))
4365 +#define CPMAC_MAC_EOI_VECTOR(base) (*pCPMAC_MAC_EOI_VECTOR(base))
4366 +#define pCPMAC_RX_INTSTAT_RAW(base) ((MEM_PTR)(base+0x190))
4367 +#define CPMAC_RX_INTSTAT_RAW(base) (*pCPMAC_RX_INTSTAT_RAW(base))
4368 +#define pCPMAC_RX_INTSTAT_MASKED(base) ((MEM_PTR)(base+0x194))
4369 +#define CPMAC_RX_INTSTAT_MASKED(base) (*pCPMAC_RX_INTSTAT_MASKED(base))
4370 +#define pCPMAC_RX_INTMASK_SET(base) ((MEM_PTR)(base+0x198))
4371 +#define CPMAC_RX_INTMASK_SET(base) (*pCPMAC_RX_INTMASK_SET(base))
4372 +#define pCPMAC_RX_INTMASK_CLEAR(base) ((MEM_PTR)(base+0x19C))
4373 +#define CPMAC_RX_INTMASK_CLEAR(base) (*pCPMAC_RX_INTMASK_CLEAR(base))
4374 +#define pCPMAC_MAC_INTSTAT_RAW(base) ((MEM_PTR)(base+0x1A0))
4375 +#define CPMAC_MAC_INTSTAT_RAW(base) (*pCPMAC_MAC_INTSTAT_RAW(base))
4376 +#define pCPMAC_MAC_INTSTAT_MASKED(base) ((MEM_PTR)(base+0x1A4))
4377 +#define CPMAC_MAC_INTSTAT_MASKED(base) (*pCPMAC_MAC_INTSTAT_MASKED(base))
4378 +#define pCPMAC_MAC_INTMASK_SET(base) ((MEM_PTR)(base+0x1A8))
4379 +#define CPMAC_MAC_INTMASK_SET(base) (*pCPMAC_MAC_INTMASK_SET(base))
4380 +#define pCPMAC_MAC_INTMASK_CLEAR(base) ((MEM_PTR)(base+0x1AC))
4381 +#define CPMAC_MAC_INTMASK_CLEAR(base) (*pCPMAC_MAC_INTMASK_CLEAR(base))
4382 +#define pCPMAC_MACADDRLO_0(base) ((MEM_PTR)(base+0x1B0))
4383 +#define CPMAC_MACADDRLO_0(base) (*pCPMAC_MACADDRLO_0(base))
4384 +#define pCPMAC_MACADDRLO_1(base) ((MEM_PTR)(base+0x1B4))
4385 +#define CPMAC_MACADDRLO_1(base) (*pCPMAC_MACADDRLO_1(base))
4386 +#define pCPMAC_MACADDRLO_2(base) ((MEM_PTR)(base+0x1B8))
4387 +#define CPMAC_MACADDRLO_2(base) (*pCPMAC_MACADDRLO_2(base))
4388 +#define pCPMAC_MACADDRLO_3(base) ((MEM_PTR)(base+0x1BC))
4389 +#define CPMAC_MACADDRLO_3(base) (*pCPMAC_MACADDRLO_3(base))
4390 +#define pCPMAC_MACADDRLO_4(base) ((MEM_PTR)(base+0x1C0))
4391 +#define CPMAC_MACADDRLO_4(base) (*pCPMAC_MACADDRLO_4(base))
4392 +#define pCPMAC_MACADDRLO_5(base) ((MEM_PTR)(base+0x1C4))
4393 +#define CPMAC_MACADDRLO_5(base) (*pCPMAC_MACADDRLO_5(base))
4394 +#define pCPMAC_MACADDRLO_6(base) ((MEM_PTR)(base+0x1C8))
4395 +#define CPMAC_MACADDRLO_6(base) (*pCPMAC_MACADDRLO_6(base))
4396 +#define pCPMAC_MACADDRLO_7(base) ((MEM_PTR)(base+0x1CC))
4397 +#define CPMAC_MACADDRLO_7(base) (*pCPMAC_MACADDRLO_7(base))
4398 +#define pCPMAC_MACADDRMID(base) ((MEM_PTR)(base+0x1D0))
4399 +#define CPMAC_MACADDRMID(base) (*pCPMAC_MACADDRMID(base))
4400 +#define pCPMAC_MACADDRHI(base) ((MEM_PTR)(base+0x1D4))
4401 +#define CPMAC_MACADDRHI(base) (*pCPMAC_MACADDRHI(base))
4402 +#define pCPMAC_MACHASH1(base) ((MEM_PTR)(base+0x1D8))
4403 +#define CPMAC_MACHASH1(base) (*pCPMAC_MACHASH1(base))
4404 +#define pCPMAC_MACHASH2(base) ((MEM_PTR)(base+0x1DC))
4405 +#define CPMAC_MACHASH2(base) (*pCPMAC_MACHASH2(base))
4406 +#define pCPMAC_BOFFTEST(base) ((MEM_PTR)(base+0x1E0))
4407 +#define CPMAC_BOFFTEST(base) (*pCPMAC_BOFFTEST(base))
4408 +#define pCPMAC_PACTEST(base) ((MEM_PTR)(base+0x1E4))
4409 +#define CPMAC_PACTEST(base) (*pCPMAC_PACTEST(base))
4410 +#define pCPMAC_RXPAUSE(base) ((MEM_PTR)(base+0x1E8))
4411 +#define CPMAC_RXPAUSE(base) (*pCPMAC_RXPAUSE(base))
4412 +#define pCPMAC_TXPAUSE(base) ((MEM_PTR)(base+0x1EC))
4413 +#define CPMAC_TXPAUSE(base) (*pCPMAC_TXPAUSE(base))
4415 +#define pCPMAC_RXGOODFRAMES(base) ((MEM_PTR)(base+0x200))
4416 +#define CPMAC_RXGOODFRAMES(base) (*pCPMAC_RXGOODFRAMES(base))
4417 +#define pCPMAC_RXBROADCASTFRAMES(base) ((MEM_PTR)(base+0x204))
4418 +#define CPMAC_RXBROADCASTFRAMES(base) (*pCPMAC_RXBROADCASTFRAMES(base))
4419 +#define pCPMAC_RXMULTICASTFRAMES(base) ((MEM_PTR)(base+0x208))
4420 +#define CPMAC_RXMULTICASTFRAMES(base) (*pCPMAC_RXMULTICASTFRAMES(base))
4421 +#define pCPMAC_RXPAUSEFRAMES(base) ((MEM_PTR)(base+0x20C))
4422 +#define CPMAC_RXPAUSEFRAMES(base) (*pCPMAC_RXPAUSEFRAMES(base))
4423 +#define pCPMAC_RXCRCERRORS(base) ((MEM_PTR)(base+0x210))
4424 +#define CPMAC_RXCRCERRORS(base) (*pCPMAC_RXCRCERRORS(base))
4425 +#define pCPMAC_RXALIGNCODEERRORS(base) ((MEM_PTR)(base+0x214))
4426 +#define CPMAC_RXALIGNCODEERRORS(base) (*pCPMAC_RXALIGNCODEERRORS(base))
4427 +#define pCPMAC_RXOVERSIZEDFRAMES(base) ((MEM_PTR)(base+0x218))
4428 +#define CPMAC_RXOVERSIZEDFRAMES(base) (*pCPMAC_RXOVERSIZEDFRAMES(base))
4429 +#define pCPMAC_RXJABBERFRAMES(base) ((MEM_PTR)(base+0x21C))
4430 +#define CPMAC_RXJABBERFRAMES(base) (*pCPMAC_RXJABBERFRAMES(base))
4431 +#define pCPMAC_RXUNDERSIZEDFRAMES(base) ((MEM_PTR)(base+0x220))
4432 +#define CPMAC_RXUNDERSIZEDFRAMES(base) (*pCPMAC_RXUNDERSIZEDFRAMES(base))
4433 +#define pCPMAC_RXFRAGMENTS(base) ((MEM_PTR)(base+0x224))
4434 +#define CPMAC_RXFRAGMENTS(base) (*pCPMAC_RXFRAGMENTS(base))
4435 +#define pCPMAC_RXFILTEREDFRAMES(base) ((MEM_PTR)(base+0x228))
4436 +#define CPMAC_RXFILTEREDFRAMES(base) (*pCPMAC_RXFILTEREDFRAMES(base))
4437 +#define pCPMAC_RXQOSFILTEREDFRAMES(base) ((MEM_PTR)(base+0x22C))
4438 +#define CPMAC_RXQOSFILTEREDFRAMES(base) (*pCPMAC_RXQOSFILTEREDFRAMES(base))
4439 +#define pCPMAC_RXOCTETS(base) ((MEM_PTR)(base+0x230))
4440 +#define CPMAC_RXOCTETS(base) (*pCPMAC_RXOCTETS(base))
4441 +#define pCPMAC_TXGOODFRAMES(base) ((MEM_PTR)(base+0x234))
4442 +#define CPMAC_TXGOODFRAMES(base) (*pCPMAC_TXGOODFRAMES(base))
4443 +#define pCPMAC_TXBROADCASTFRAMES(base) ((MEM_PTR)(base+0x238))
4444 +#define CPMAC_TXBROADCASTFRAMES(base) (*pCPMAC_TXBROADCASTFRAMES(base))
4445 +#define pCPMAC_TXMULTICASTFRAMES(base) ((MEM_PTR)(base+0x23C))
4446 +#define CPMAC_TXMULTICASTFRAMES(base) (*pCPMAC_TXMULTICASTFRAMES(base))
4447 +#define pCPMAC_TXPAUSEFRAMES(base) ((MEM_PTR)(base+0x240))
4448 +#define CPMAC_TXPAUSEFRAMES(base) (*pCPMAC_TXPAUSEFRAMES(base))
4449 +#define pCPMAC_TXDEFERREDFRAMES(base) ((MEM_PTR)(base+0x244))
4450 +#define CPMAC_TXDEFERREDFRAMES(base) (*pCPMAC_TXDEFERREDFRAMES(base))
4451 +#define pCPMAC_TXCOLLISIONFRAMES(base) ((MEM_PTR)(base+0x248))
4452 +#define CPMAC_TXCOLLISIONFRAMES(base) (*pCPMAC_TXCOLLISIONFRAMES(base))
4453 +#define pCPMAC_TXSINGLECOLLFRAMES(base) ((MEM_PTR)(base+0x24C))
4454 +#define CPMAC_TXSINGLECOLLFRAMES(base) (*pCPMAC_TXSINGLECOLLFRAMES(base))
4455 +#define pCPMAC_TXMULTCOLLFRAMES(base) ((MEM_PTR)(base+0x250))
4456 +#define CPMAC_TXMULTCOLLFRAMES(base) (*pCPMAC_TXMULTCOLLFRAMES(base))
4457 +#define pCPMAC_TXEXCESSIVECOLLISIONS(base) ((MEM_PTR)(base+0x254))
4458 +#define CPMAC_TXEXCESSIVECOLLISIONS(base) (*pCPMAC_TXEXCESSIVECOLLISIONS(base))
4459 +#define pCPMAC_TXLATECOLLISIONS(base) ((MEM_PTR)(base+0x258))
4460 +#define CPMAC_TXLATECOLLISIONS(base) (*pCPMAC_TXLATECOLLISIONS(base))
4461 +#define pCPMAC_TXUNDERRUN(base) ((MEM_PTR)(base+0x25C))
4462 +#define CPMAC_TXUNDERRUN(base) (*pCPMAC_TXUNDERRUN(base))
4463 +#define pCPMAC_TXCARRIERSENSEERRORS(base) ((MEM_PTR)(base+0x260))
4464 +#define CPMAC_TXCARRIERSENSEERRORS(base) (*pCPMAC_TXCARRIERSENSEERRORS(base))
4465 +#define pCPMAC_TXOCTETS(base) ((MEM_PTR)(base+0x264))
4466 +#define CPMAC_TXOCTETS(base) (*pCPMAC_TXOCTETS(base))
4467 +#define pCPMAC_64OCTETFRAMES(base) ((MEM_PTR)(base+0x268))
4468 +#define CPMAC_64OCTETFRAMES(base) (*pCPMAC_64OCTETFRAMES(base))
4469 +#define pCPMAC_65T127OCTETFRAMES(base) ((MEM_PTR)(base+0x26C))
4470 +#define CPMAC_65T127OCTETFRAMES(base) (*pCPMAC_65T127OCTETFRAMES(base))
4471 +#define pCPMAC_128T255OCTETFRAMES(base) ((MEM_PTR)(base+0x270))
4472 +#define CPMAC_128T255OCTETFRAMES(base) (*pCPMAC_128T255OCTETFRAMES(base))
4473 +#define pCPMAC_256T511OCTETFRAMES(base) ((MEM_PTR)(base+0x274))
4474 +#define CPMAC_256T511OCTETFRAMES(base) (*pCPMAC_256T511OCTETFRAMES(base))
4475 +#define pCPMAC_512T1023OCTETFRAMES(base) ((MEM_PTR)(base+0x278))
4476 +#define CPMAC_512T1023OCTETFRAMES(base) (*pCPMAC_512T1023OCTETFRAMES(base))
4477 +#define pCPMAC_1024TUPOCTETFRAMES(base) ((MEM_PTR)(base+0x27C))
4478 +#define CPMAC_1024TUPOCTETFRAMES(base) (*pCPMAC_1024TUPOCTETFRAMES(base))
4479 +#define pCPMAC_NETOCTETS(base) ((MEM_PTR)(base+0x280))
4480 +#define CPMAC_NETOCTETS(base) (*pCPMAC_NETOCTETS(base))
4481 +#define pCPMAC_RXSOFOVERRUNS(base) ((MEM_PTR)(base+0x284))
4482 +#define CPMAC_RXSOFOVERRUNS(base) (*pCPMAC_RXSOFOVERRUNS(base))
4483 +#define pCPMAC_RXMOFOVERRUNS(base) ((MEM_PTR)(base+0x288))
4484 +#define CPMAC_RXMOFOVERRUNS(base) (*pCPMAC_RXMOFOVERRUNS(base))
4485 +#define pCPMAC_RXDMAOVERRUNS(base) ((MEM_PTR)(base+0x28C))
4486 +#define CPMAC_RXDMAOVERRUNS(base) (*pCPMAC_RXDMAOVERRUNS(base))
4488 +#define CPMAC_TX_HDP(base,ch) (*(MEM_PTR)(base+0x600+(4*ch)))
4489 +#define pCPMAC_TX0_HDP(base) ((MEM_PTR)(base+0x600))
4490 +#define CPMAC_TX0_HDP(base) (*pCPMAC_TX0_HDP(base))
4491 +#define pCPMAC_TX1_HDP(base) ((MEM_PTR)(base+0x604))
4492 +#define CPMAC_TX1_HDP(base) (*pCPMAC_TX1_HDP(base))
4493 +#define pCPMAC_TX2_HDP(base) ((MEM_PTR)(base+0x608))
4494 +#define CPMAC_TX2_HDP(base) (*pCPMAC_TX2_HDP(base))
4495 +#define pCPMAC_TX3_HDP(base) ((MEM_PTR)(base+0x60C))
4496 +#define CPMAC_TX3_HDP(base) (*pCPMAC_TX3_HDP(base))
4497 +#define pCPMAC_TX4_HDP(base) ((MEM_PTR)(base+0x610))
4498 +#define CPMAC_TX4_HDP(base) (*pCPMAC_TX4_HDP(base))
4499 +#define pCPMAC_TX5_HDP(base) ((MEM_PTR)(base+0x614))
4500 +#define CPMAC_TX5_HDP(base) (*pCPMAC_TX5_HDP(base))
4501 +#define pCPMAC_TX6_HDP(base) ((MEM_PTR)(base+0x618))
4502 +#define CPMAC_TX6_HDP(base) (*pCPMAC_TX6_HDP(base))
4503 +#define pCPMAC_TX7_HDP(base) ((MEM_PTR)(base+0x61C))
4504 +#define CPMAC_TX7_HDP(base) (*pCPMAC_TX7_HDP(base))
4505 +#define CPMAC_RX_HDP(base,ch) (*(MEM_PTR)(base+0x620+(4*ch)))
4506 +#define pCPMAC_RX0_HDP(base) ((MEM_PTR)(base+0x620))
4507 +#define CPMAC_RX0_HDP(base) (*pCPMAC_RX0_HDP(base))
4508 +#define pCPMAC_RX1_HDP(base) ((MEM_PTR)(base+0x624))
4509 +#define CPMAC_RX1_HDP(base) (*pCPMAC_RX1_HDP(base))
4510 +#define pCPMAC_RX2_HDP(base) ((MEM_PTR)(base+0x628))
4511 +#define CPMAC_RX2_HDP(base) (*pCPMAC_RX2_HDP(base))
4512 +#define pCPMAC_RX3_HDP(base) ((MEM_PTR)(base+0x62C))
4513 +#define CPMAC_RX3_HDP(base) (*pCPMAC_RX3_HDP(base))
4514 +#define pCPMAC_RX4_HDP(base) ((MEM_PTR)(base+0x630))
4515 +#define CPMAC_RX4_HDP(base) (*pCPMAC_RX4_HDP(base))
4516 +#define pCPMAC_RX5_HDP(base) ((MEM_PTR)(base+0x634))
4517 +#define CPMAC_RX5_HDP(base) (*pCPMAC_RX5_HDP(base))
4518 +#define pCPMAC_RX6_HDP(base) ((MEM_PTR)(base+0x638))
4519 +#define CPMAC_RX6_HDP(base) (*pCPMAC_RX6_HDP(base))
4520 +#define pCPMAC_RX7_HDP(base) ((MEM_PTR)(base+0x63C))
4521 +#define CPMAC_RX7_HDP(base) (*pCPMAC_RX7_HDP(base))
4524 +#define CPMAC_TX_INT_ACK(base,ch) (*(MEM_PTR)(base+0x640+(4*ch)))
4526 +#define pCPMAC_TX0_INT_ACK(base) ((MEM_PTR)(base+0x640))
4527 +#define CPMAC_TX0_INT_ACK(base) (*pCPMAC_TX0_INT_ACK(base))
4528 +#define pCPMAC_TX1_INT_ACK(base) ((MEM_PTR)(base+0x644))
4529 +#define CPMAC_TX1_INT_ACK(base) (*pCPMAC_TX1_INT_ACK(base))
4530 +#define pCPMAC_TX2_INT_ACK(base) ((MEM_PTR)(base+0x648))
4531 +#define CPMAC_TX2_INT_ACK(base) (*pCPMAC_TX2_INT_ACK(base))
4532 +#define pCPMAC_TX3_INT_ACK(base) ((MEM_PTR)(base+0x64C))
4533 +#define CPMAC_TX3_INT_ACK(base) (*pCPMAC_TX3_INT_ACK(base))
4534 +#define pCPMAC_TX4_INT_ACK(base) ((MEM_PTR)(base+0x650))
4535 +#define CPMAC_TX4_INT_ACK(base) (*pCPMAC_TX4_INT_ACK(base))
4536 +#define pCPMAC_TX5_INT_ACK(base) ((MEM_PTR)(base+0x654))
4537 +#define CPMAC_TX5_INT_ACK(base) (*pCPMAC_TX5_INT_ACK(base))
4538 +#define pCPMAC_TX6_INT_ACK(base) ((MEM_PTR)(base+0x658))
4539 +#define CPMAC_TX6_INT_ACK(base) (*pCPMAC_TX6_INT_ACK(base))
4540 +#define pCPMAC_TX7_INT_ACK(base) ((MEM_PTR)(base+0x65C))
4541 +#define CPMAC_TX7_INT_ACK(base) (*pCPMAC_TX7_INT_ACK(base))
4542 +#define CPMAC_RX_INT_ACK(base,ch) (*(MEM_PTR)(base+0x660+(4*ch)))
4544 +#define pCPMAC_RX0_INT_ACK(base) ((MEM_PTR)(base+0x660))
4545 +#define CPMAC_RX0_INT_ACK(base) (*pCPMAC_RX0_INT_ACK(base))
4546 +#define pCPMAC_RX1_INT_ACK(base) ((MEM_PTR)(base+0x664))
4547 +#define CPMAC_RX1_INT_ACK(base) (*pCPMAC_RX1_INT_ACK(base))
4548 +#define pCPMAC_RX2_INT_ACK(base) ((MEM_PTR)(base+0x668))
4549 +#define CPMAC_RX2_INT_ACK(base) (*pCPMAC_RX2_INT_ACK(base))
4550 +#define pCPMAC_RX3_INT_ACK(base) ((MEM_PTR)(base+0x66C))
4551 +#define CPMAC_RX3_INT_ACK(base) (*pCPMAC_RX3_INT_ACK(base))
4552 +#define pCPMAC_RX4_INT_ACK(base) ((MEM_PTR)(base+0x670))
4553 +#define CPMAC_RX4_INT_ACK(base) (*pCPMAC_RX4_INT_ACK(base))
4554 +#define pCPMAC_RX5_INT_ACK(base) ((MEM_PTR)(base+0x674))
4555 +#define CPMAC_RX5_INT_ACK(base) (*pCPMAC_RX5_INT_ACK(base))
4556 +#define pCPMAC_RX6_INT_ACK(base) ((MEM_PTR)(base+0x678))
4557 +#define CPMAC_RX6_INT_ACK(base) (*pCPMAC_RX6_INT_ACK(base))
4558 +#define pCPMAC_RX7_INT_ACK(base) ((MEM_PTR)(base+0x67C))
4559 +#define CPMAC_RX7_INT_ACK(base) (*pCPMAC_RX7_INT_ACK(base))
4561 +/****************************************************************************/
4563 +/* R E G I S T E R B I T D E F I N I T I O N S */
4565 +/****************************************************************************/
4569 +#define TX_EN (1 << 0)
4573 +#define RX_EN (1 << 0)
4575 +/* RX_MBP_ENABLE */
4577 +#define RX_PASS_CRC (1 << 30)
4578 +#define RX_QOS_EN (1 << 29)
4579 +#define RX_NO_CHAIN (1 << 28)
4581 +#define RX_CMF_EN (1 << 24)
4582 +#define RX_CSF_EN (1 << 23)
4583 +#define RX_CEF_EN (1 << 22)
4584 +#define RX_CAF_EN (1 << 21)
4586 +#define RX_PROM_CH(n) (n << 16)
4587 +#define RX_PROM_CH_MASK RX_PROM_CH(7)
4588 +#define RX_PROM_CH_7 RX_PROM_CH(7)
4589 +#define RX_PROM_CH_6 RX_PROM_CH(6)
4590 +#define RX_PROM_CH_5 RX_PROM_CH(5)
4591 +#define RX_PROM_CH_4 RX_PROM_CH(4)
4592 +#define RX_PROM_CH_3 RX_PROM_CH(3)
4593 +#define RX_PROM_CH_2 RX_PROM_CH(2)
4594 +#define RX_PROM_CH_1 RX_PROM_CH(1)
4595 +#define RX_PROM_CH_0 RX_PROM_CH(0)
4597 +#define RX_BROAD_EN (1 << 13)
4599 +#define RX_BROAD_CH(n) (n << 8)
4600 +#define RX_BROAD_CH_MASK RX_BROAD_CH(7)
4601 +#define RX_BROAD_CH_7 RX_BROAD_CH(7)
4602 +#define RX_BROAD_CH_6 RX_BROAD_CH(6)
4603 +#define RX_BROAD_CH_5 RX_BROAD_CH(5)
4604 +#define RX_BROAD_CH_4 RX_BROAD_CH(4)
4605 +#define RX_BROAD_CH_3 RX_BROAD_CH(3)
4606 +#define RX_BROAD_CH_2 RX_BROAD_CH(2)
4607 +#define RX_BROAD_CH_1 RX_BROAD_CH(1)
4608 +#define RX_BROAD_CH_0 RX_BROAD_CH(0)
4610 +#define RX_MULT_EN (1 << 5)
4612 +#define RX_MULT_CH(n) (n << 0)
4613 +#define RX_MULT_CH_MASK RX_MULT_CH(7)
4614 +#define RX_MULT_CH_7 RX_MULT_CH(7)
4615 +#define RX_MULT_CH_6 RX_MULT_CH(6)
4616 +#define RX_MULT_CH_5 RX_MULT_CH(5)
4617 +#define RX_MULT_CH_4 RX_MULT_CH(4)
4618 +#define RX_MULT_CH_3 RX_MULT_CH(3)
4619 +#define RX_MULT_CH_2 RX_MULT_CH(2)
4620 +#define RX_MULT_CH_1 RX_MULT_CH(1)
4621 +#define RX_MULT_CH_0 RX_MULT_CH(0)
4625 +/* RX_UNICAST_SET */
4627 +#define RX_CH7_EN (1 << 7)
4628 +#define RX_CH6_EN (1 << 6)
4629 +#define RX_CH5_EN (1 << 5)
4630 +#define RX_CH4_EN (1 << 4)
4631 +#define RX_CH3_EN (1 << 3)
4632 +#define RX_CH2_EN (1 << 2)
4633 +#define RX_CH1_EN (1 << 1)
4634 +#define RX_CH0_EN (1 << 0)
4639 +#define TX_PTYPE (1 << 9)
4640 +#define TX_PACE (1 << 6)
4641 +#define MII_EN (1 << 5)
4642 +#define TX_FLOW_EN (1 << 4)
4643 +#define RX_FLOW_EN (1 << 3)
4644 +#define MTEST (1 << 2)
4645 +#define CTRL_LOOPBACK (1 << 1)
4646 +#define FULLDUPLEX (1 << 0)
4649 +/* IntVec definitions */
4650 +#define MAC_IN_VECTOR_STATUS_INT (1 << 19)
4651 +#define MAC_IN_VECTOR_HOST_INT (1 << 18)
4652 +#define MAC_IN_VECTOR_RX_INT_OR (1 << 17)
4653 +#define MAC_IN_VECTOR_TX_INT_OR (1 << 16)
4654 +#define MAC_IN_VECTOR_RX_INT_VEC (7 << 8)
4655 +#define MAC_IN_VECTOR_TX_INT_VEC (7)
4660 +#define TX_HOST_ERR_CODE (0xF << 20)
4661 +#define TX_ERR_CH (0x7 << 16)
4662 +#define RX_HOST_ERR_CODE (0xF << 12)
4663 +#define RX_ERR_CH (0x7 << 8)
4664 +#define RX_QOS_ACT (1 << 2)
4665 +#define RX_FLOW_ACT (1 << 1)
4666 +#define TX_FLOW_ACT (1 << 0)
4667 +#endif _INC_CPMAC_REG
4668 diff -urN linux.old/drivers/net/avalanche_cpmac/cpmdio.c linux.dev/drivers/net/avalanche_cpmac/cpmdio.c
4669 --- linux.old/drivers/net/avalanche_cpmac/cpmdio.c 1970-01-01 01:00:00.000000000 +0100
4670 +++ linux.dev/drivers/net/avalanche_cpmac/cpmdio.c 2005-07-12 02:48:42.046593000 +0200
4672 +/***************************************************************************
4673 +** TNETD53xx Software Support
4674 +** Copyright(c) 2002, Texas Instruments Incorporated. All Rights Reserved.
4679 +** MDIO Polling State Machine API. Functions will enable mii-Phy
4683 +** 01Jan01 Denis, Bill Original
4684 +** 27Mar02 Michael Hanrahan (modified from emacmdio.c)
4685 +** 07May02 Michael Hanrahan replaced clockwait for code delay
4686 +** 10Jul02 Michael Hanrahan more debug, if fallback link is selected
4687 +*****************************************************************************/
4688 +#define __CPHAL_CPMDIO
4690 +#include "mdio_reg.h"
4692 +#ifdef _CPHAL_CPMAC
4693 +#define mdioPrintf PhyDev->HalDev->OsFunc->Printf
4695 +#define mdioPrintf printf
4698 +typedef struct _phy_device
4707 +#ifdef _CPHAL_CPMAC
4708 + HAL_DEVICE *HalDev;
4712 +static void _mdioDelayEmulate(PHY_DEVICE *PhyDev, int ClockWait);
4713 +static void _mdioWaitForAccessComplete(PHY_DEVICE *PhyDev);
4714 +static void _mdioUserAccess(PHY_DEVICE *PhyDev, bit32u method, bit32u regadr, bit32u phyadr, bit32u data);
4715 +static bit32u _mdioUserAccessRead(PHY_DEVICE *PhyDev, bit32u regadr, bit32u phyadr);
4716 +static void _mdioUserAccessWrite(PHY_DEVICE *PhyDev, bit32u regadr, bit32u phyadr, bit32u data);
4718 +static void _mdioDisablePhy(PHY_DEVICE *PhyDev,bit32u PhyNum);
4719 +static void _mdioPhyTimeOut(PHY_DEVICE *PhyDev);
4720 +static void _mdioResetPhy(PHY_DEVICE *PhyDev,bit32u PhyNum);
4722 +static void _mdioDumpPhy(PHY_DEVICE *PhyDev, bit32u p);
4723 +static void _mdioDumpState(PHY_DEVICE *PhyDev);
4726 +static void _mdioMdixDelay(PHY_DEVICE *PhyDev);
4727 +static int _mdioMdixSupported(PHY_DEVICE *PhyDev);
4729 +static void _MdioDefaultState (PHY_DEVICE *PhyDev);
4730 +static void _MdioFindingState (PHY_DEVICE *PhyDev);
4731 +static void _MdioFoundState (PHY_DEVICE *PhyDev);
4732 +static void _MdioInitState (PHY_DEVICE *PhyDev);
4733 +static void _MdioLinkedState (PHY_DEVICE *PhyDev);
4734 +static void _MdioLinkWaitState (PHY_DEVICE *PhyDev);
4735 +static void _MdioLoopbackState (PHY_DEVICE *PhyDev);
4736 +static void _MdioNwayStartState(PHY_DEVICE *PhyDev);
4737 +static void _MdioNwayWaitState (PHY_DEVICE *PhyDev);
4742 +#define TRUE (1==1)
4746 +#define FALSE (1==2)
4749 +#define PHY_NOT_FOUND 0xFFFF /* Used in Phy Detection */
4751 +/*PhyState breakout */
4753 +#define PHY_DEV_OFFSET (0)
4754 +#define PHY_DEV_SIZE (5) /* 5 Bits used */
4755 +#define PHY_DEV_MASK (0x1f<<PHY_DEV_OFFSET)
4757 +#define PHY_STATE_OFFSET (PHY_DEV_SIZE+PHY_DEV_OFFSET)
4758 +#define PHY_STATE_SIZE (5) /* 10 Bits used */
4759 +#define PHY_STATE_MASK (0x1f<<PHY_STATE_OFFSET)
4760 + #define INIT (1<<PHY_STATE_OFFSET)
4761 + #define FINDING (2<<PHY_STATE_OFFSET)
4762 + #define FOUND (3<<PHY_STATE_OFFSET)
4763 + #define NWAY_START (4<<PHY_STATE_OFFSET)
4764 + #define NWAY_WAIT (5<<PHY_STATE_OFFSET)
4765 + #define LINK_WAIT (6<<PHY_STATE_OFFSET)
4766 + #define LINKED (7<<PHY_STATE_OFFSET)
4767 + #define LOOPBACK (8<<PHY_STATE_OFFSET)
4769 +#define PHY_SPEED_OFFSET (PHY_STATE_OFFSET+PHY_STATE_SIZE)
4770 +#define PHY_SPEED_SIZE (1) /* 11 Bits used */
4771 +#define PHY_SPEED_MASK (1<<PHY_SPEED_OFFSET)
4773 +#define PHY_DUPLEX_OFFSET (PHY_SPEED_OFFSET+PHY_SPEED_SIZE)
4774 +#define PHY_DUPLEX_SIZE (1) /* 12 Bits used */
4775 +#define PHY_DUPLEX_MASK (1<<PHY_DUPLEX_OFFSET)
4777 +#define PHY_TIM_OFFSET (PHY_DUPLEX_OFFSET+PHY_DUPLEX_SIZE)
4778 +#define PHY_TIM_SIZE (10) /* 22 Bits used */
4779 +#define PHY_TIM_MASK (0x3ff<<PHY_TIM_OFFSET)
4780 + #define PHY_FIND_TO ( 2<<PHY_TIM_OFFSET)
4781 + #define PHY_RECK_TO (200<<PHY_TIM_OFFSET)
4782 + #define PHY_LINK_TO (500<<PHY_TIM_OFFSET)
4783 + #define PHY_NWST_TO (500<<PHY_TIM_OFFSET)
4784 + #define PHY_NWDN_TO (800<<PHY_TIM_OFFSET)
4785 + #define PHY_MDIX_TO (274<<PHY_TIM_OFFSET) /* 2.74 Seconds <--Spec and empirical */
4787 +#define PHY_SMODE_OFFSET (PHY_TIM_OFFSET+PHY_TIM_SIZE)
4788 +#define PHY_SMODE_SIZE (5) /* 27 Bits used */
4789 +#define PHY_SMODE_MASK (0x1f<<PHY_SMODE_OFFSET)
4790 + #define SMODE_AUTO (0x10<<PHY_SMODE_OFFSET)
4791 + #define SMODE_FD100 (0x08<<PHY_SMODE_OFFSET)
4792 + #define SMODE_HD100 (0x04<<PHY_SMODE_OFFSET)
4793 + #define SMODE_FD10 (0x02<<PHY_SMODE_OFFSET)
4794 + #define SMODE_HD10 (0x01<<PHY_SMODE_OFFSET)
4795 + #define SMODE_ALL (0x1f<<PHY_SMODE_OFFSET)
4797 +#define PHY_CHNG_OFFSET (PHY_SMODE_OFFSET+PHY_SMODE_SIZE)
4798 +#define PHY_CHNG_SIZE (1) /* 28 Bits used */
4799 +#define PHY_CHNG_MASK (1<<PHY_CHNG_OFFSET)
4800 + #define PHY_CHANGE (1<<PHY_CHNG_OFFSET)
4802 +#define PHY_TIMEDOUT_OFFSET (PHY_CHNG_OFFSET+PHY_CHNG_SIZE)
4803 +#define PHY_TIMEDOUT_SIZE (1) /* 29 Bits used */
4804 +#define PHY_TIMEDOUT_MASK (1<<PHY_TIMEDOUT_OFFSET)
4805 + #define PHY_MDIX_SWITCH (1<<PHY_TIMEDOUT_OFFSET)
4807 +#define PHY_MDIX_OFFSET (PHY_TIMEDOUT_OFFSET+PHY_TIMEDOUT_SIZE)
4808 +#define PHY_MDIX_SIZE (1) /* 30 Bits used */
4809 +#define PHY_MDIX_MASK (1<<PHY_MDIX_OFFSET)
4810 + #define PHY_MDIX (1<<PHY_MDIX_OFFSET)
4812 +static char *lstate[]={"NULL","INIT","FINDING","FOUND","NWAY_START","NWAY_WAIT","LINK_WAIT","LINKED", "LOOPBACK"};
4813 +static int cpMacDebug;
4815 +/* Local MDIO Register Macros */
4817 +#define myMDIO_ALIVE MDIO_ALIVE (PhyDev->miibase)
4818 +#define myMDIO_CONTROL MDIO_CONTROL (PhyDev->miibase)
4819 +#define myMDIO_LINK MDIO_LINK (PhyDev->miibase)
4820 +#define myMDIO_LINKINT MDIO_LINKINT (PhyDev->miibase)
4821 +#define myMDIO_USERACCESS MDIO_USERACCESS(PhyDev->miibase, PhyDev->inst)
4822 +#define myMDIO_USERPHYSEL MDIO_USERPHYSEL(PhyDev->miibase, PhyDev->inst)
4823 +#define myMDIO_VER MDIO_VER (PhyDev->miibase)
4826 +#define VOLATILE32(addr) (*((volatile bit32u *)(addr)))
4829 +/************************************
4831 +*** Delays at least ClockWait cylces
4832 +*** before returning
4834 +**************************************/
4835 +void _mdioDelayEmulate(PHY_DEVICE *PhyDev, int ClockWait)
4837 +#ifdef _CPHAL_CPMAC /*+RC3.02*/
4838 + HAL_DEVICE *HalDev = PhyDev->HalDev; /*+RC3.02*/
4839 + osfuncSleep((int*)&ClockWait); /*+RC3.02*/
4841 + volatile bit32u i=0;
4842 + while(ClockWait--)
4844 + i |= myMDIO_LINK; /* MDIO register access to burn cycles */
4849 +void _mdioWaitForAccessComplete(PHY_DEVICE *PhyDev)
4851 + while((myMDIO_USERACCESS & MDIO_USERACCESS_GO)!=0)
4856 +void _mdioUserAccess(PHY_DEVICE *PhyDev, bit32u method, bit32u regadr, bit32u phyadr, bit32u data)
4860 + control = MDIO_USERACCESS_GO |
4862 + (((regadr) << 21) & MDIO_USERACCESS_REGADR) |
4863 + (((phyadr) << 16) & MDIO_USERACCESS_PHYADR) |
4864 + ((data) & MDIO_USERACCESS_DATA);
4866 + myMDIO_USERACCESS = control;
4871 +/************************************
4873 +*** Waits for MDIO_USERACCESS to be ready and reads data
4874 +*** If 'WaitForData' set, waits for read to complete and returns Data,
4875 +*** otherwise returns 0
4876 +*** Note: 'data' is 16 bits but we use 32 bits
4877 +*** to be consistent with rest of the code.
4879 +**************************************/
4880 +bit32u _mdioUserAccessRead(PHY_DEVICE *PhyDev, bit32u regadr, bit32u phyadr)
4883 + _mdioWaitForAccessComplete(PhyDev); /* Wait until UserAccess ready */
4884 + _mdioUserAccess(PhyDev, MDIO_USERACCESS_READ, regadr, phyadr, 0);
4885 + _mdioWaitForAccessComplete(PhyDev); /* Wait for Read to complete */
4887 + return(myMDIO_USERACCESS & MDIO_USERACCESS_DATA);
4891 +/************************************
4893 +*** Waits for MDIO_USERACCESS to be ready and writes data
4895 +**************************************/
4896 +void _mdioUserAccessWrite(PHY_DEVICE *PhyDev, bit32u regadr, bit32u phyadr, bit32u data)
4898 + _mdioWaitForAccessComplete(PhyDev); /* Wait until UserAccess ready */
4899 + _mdioUserAccess(PhyDev, MDIO_USERACCESS_WRITE, regadr, phyadr, data);
4902 +void _mdioDumpPhyDetailed(PHY_DEVICE *PhyDev)
4904 + bit32u *PhyState = &PhyDev->PhyState;
4908 + PhyNum=(*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET;
4910 + RegData = _mdioUserAccessRead(PhyDev, 0, PhyNum);
4911 + mdioPrintf("PhyControl: %04X, Lookback=%s, Speed=%s, Duplex=%s\n",
4913 + RegData&PHY_LOOP?"On":"Off",
4914 + RegData&PHY_100?"100":"10",
4915 + RegData&PHY_FD?"Full":"Half");
4916 + RegData = _mdioUserAccessRead(PhyDev, 1, PhyNum);
4917 + mdioPrintf("PhyStatus: %04X, AutoNeg=%s, Link=%s\n",
4919 + RegData&NWAY_COMPLETE?"Complete":"NotComplete",
4920 + RegData&PHY_LINKED?"Up":"Down");
4921 + RegData = _mdioUserAccessRead(PhyDev, 4, PhyNum);
4922 + mdioPrintf("PhyMyCapability: %04X, 100FD=%s, 100HD=%s, 10FD=%s, 10HD=%s\n",
4924 + RegData&NWAY_FD100?"Yes":"No",
4925 + RegData&NWAY_HD100?"Yes":"No",
4926 + RegData&NWAY_FD10?"Yes":"No",
4927 + RegData&NWAY_HD10?"Yes":"No");
4929 + RegData = _mdioUserAccessRead(PhyDev, 5, PhyNum);
4930 + mdioPrintf("PhyPartnerCapability: %04X, 100FD=%s, 100HD=%s, 10FD=%s, 10HD=%s\n",
4932 + RegData&NWAY_FD100?"Yes":"No",
4933 + RegData&NWAY_HD100?"Yes":"No",
4934 + RegData&NWAY_FD10?"Yes":"No",
4935 + RegData&NWAY_HD10?"Yes":"No");
4937 +void _mdioDumpPhy(PHY_DEVICE *PhyDev, bit32u p)
4939 + bit32u j,n,PhyAcks;
4940 + bit32u PhyRegAddr;
4942 + bit32u PhyMask = PhyDev->PhyMask;
4944 + PhyAcks=myMDIO_ALIVE;
4945 + PhyAcks&=PhyMask; /* Only interested in 'our' Phys */
4947 + for(phy_num=0,j=1;phy_num<32;phy_num++,j<<=1)
4951 + mdioPrintf("%2d%s:",phy_num,(phy_num==p)?">":" ");
4952 + for(PhyRegAddr=0;PhyRegAddr<6;PhyRegAddr++)
4954 + n = _mdioUserAccessRead(PhyDev, PhyRegAddr, phy_num);
4955 + mdioPrintf(" %04x",n&0x0ffff);
4960 + _mdioDumpPhyDetailed(PhyDev);
4963 +void _mdioDumpState(PHY_DEVICE *PhyDev)
4965 + bit32u state = PhyDev->PhyState;
4967 + if (!cpMacDebug) return;
4969 + mdioPrintf("Phy: %d, ",(state&PHY_DEV_MASK)>>PHY_DEV_OFFSET);
4970 + mdioPrintf("State: %d/%s, ",(state&PHY_STATE_MASK)>>PHY_STATE_OFFSET,lstate[(state&PHY_STATE_MASK)>>PHY_STATE_OFFSET]);
4971 + mdioPrintf("Speed: %d, ",(state&PHY_SPEED_MASK)>>PHY_SPEED_OFFSET);
4972 + mdioPrintf("Dup: %d, ",(state&PHY_DUPLEX_MASK)>>PHY_DUPLEX_OFFSET);
4973 + mdioPrintf("Tim: %d, ",(state&PHY_TIM_MASK)>>PHY_TIM_OFFSET);
4974 + mdioPrintf("SMode: %d, ",(state&PHY_SMODE_MASK)>>PHY_SMODE_OFFSET);
4975 + mdioPrintf("Chng: %d",(state&PHY_CHNG_MASK)>>PHY_CHNG_OFFSET);
4978 + if (((state&PHY_STATE_MASK)!=FINDING)&&((state&PHY_STATE_MASK)!=INIT))
4979 + _mdioDumpPhy(PhyDev, (state&PHY_DEV_MASK)>>PHY_DEV_OFFSET);
4983 +void _mdioResetPhy(PHY_DEVICE *PhyDev,bit32u PhyNum)
4985 + bit16u PhyControlReg;
4987 + _mdioUserAccessWrite(PhyDev, PHY_CONTROL_REG, PhyNum, PHY_RESET);
4989 + mdioPrintf("cpMacMdioPhYReset(%d)\n",PhyNum);
4991 + /* Read control register until Phy Reset is complete */
4994 + PhyControlReg = _mdioUserAccessRead(PhyDev, PHY_CONTROL_REG, PhyNum);
4996 + while (PhyControlReg & PHY_RESET); /* Wait for Reset to clear */
4999 +void _mdioDisablePhy(PHY_DEVICE *PhyDev,bit32u PhyNum)
5001 + _mdioUserAccessWrite(PhyDev, PHY_CONTROL_REG, PhyNum, PHY_ISOLATE|PHY_PDOWN);
5004 + mdioPrintf("cpMacMdioDisablePhy(%d)\n",PhyNum);
5008 +void _MdioInitState(PHY_DEVICE *PhyDev)
5010 + bit32u *PhyState = &PhyDev->PhyState;
5011 + bit32u CurrentState;
5013 + CurrentState=*PhyState;
5014 + CurrentState=(CurrentState&~PHY_TIM_MASK)|(PHY_FIND_TO);
5015 + CurrentState=(CurrentState&~PHY_STATE_MASK)|(FINDING);
5016 + CurrentState=(CurrentState&~PHY_SPEED_MASK);
5017 + CurrentState=(CurrentState&~PHY_DUPLEX_MASK);
5018 + CurrentState|=PHY_CHANGE;
5020 + *PhyState=CurrentState;
5024 +void _MdioFindingState(PHY_DEVICE *PhyDev)
5026 + bit32u *PhyState = &PhyDev->PhyState;
5027 + bit32u PhyMask = PhyDev->PhyMask;
5028 + bit32u PhyNum,i,j,PhyAcks;
5031 + PhyNum=PHY_NOT_FOUND;
5033 + if (*PhyState&PHY_TIM_MASK)
5035 + *PhyState=(*PhyState&~PHY_TIM_MASK)|((*PhyState&PHY_TIM_MASK)-(1<<PHY_TIM_OFFSET));
5039 + PhyAcks=myMDIO_ALIVE;
5040 + PhyAcks&=PhyMask; /* Only interested in 'our' Phys */
5042 + for(i=0,j=1;(i<32)&&((j&PhyAcks)==0);i++,j<<=1);
5044 + if ((PhyAcks)&&(i<32)) PhyNum=i;
5045 + if (PhyNum!=PHY_NOT_FOUND)
5048 + *PhyState=(*PhyState&~PHY_DEV_MASK)|((PhyNum&PHY_DEV_MASK)<<PHY_DEV_OFFSET);
5049 + *PhyState=(*PhyState&~PHY_STATE_MASK)|(FOUND);
5050 + *PhyState|=PHY_CHANGE;
5052 + mdioPrintf("cpMacMdioFindingState: PhyNum: %d\n",PhyNum);
5057 + mdioPrintf("cpMacMdioFindingState: Timed Out looking for a Phy!\n");
5058 + *PhyState|=PHY_RECK_TO; /* This state currently has no support?*/
5063 +void _MdioFoundState(PHY_DEVICE *PhyDev)
5065 + bit32u *PhyState = &PhyDev->PhyState;
5066 + bit32u PhyMask = PhyDev->PhyMask;
5067 + bit32u MLinkMask = PhyDev->MLinkMask;
5068 + bit32u PhyNum,PhyStatus,NWAYadvertise,m,phynum,i,j,PhyAcks;
5071 + if ((*PhyState&PHY_SMODE_MASK)==0) return;
5073 + PhyNum=(*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET;
5075 + PhyAcks=myMDIO_ALIVE;
5076 + PhyAcks&=PhyMask; /* Only interested in 'our' Phys */
5078 + /* Will now isolate all our Phys, except the one we have decided to use */
5079 + for(phynum=0,j=1;phynum<32;phynum++,j<<=1)
5083 + if (phynum!=PhyNum) /* Do not disabled Found Phy */
5084 + _mdioDisablePhy(PhyDev,phynum);
5088 + /* Reset the Phy and proceed with auto-negotiation */
5089 + _mdioResetPhy(PhyDev,PhyNum);
5091 + /* Now setup the MDIOUserPhySel register */
5093 + PhySel=PhyNum; /* Set the phy address */
5095 + /* Set the way Link will be Monitored */
5096 + /* Check the Link Selection Method */
5097 + if ((1 << PhyNum) & MLinkMask)
5098 + PhySel |= MDIO_USERPHYSEL_LINKSEL;
5100 + myMDIO_USERPHYSEL = PhySel; /* update PHYSEL */
5102 + /* Get the Phy Status */
5103 + PhyStatus = _mdioUserAccessRead(PhyDev, PHY_STATUS_REG, PhyNum);
5106 +#ifdef _CPHAL_CPMAC
5107 + /* For Phy Internal loopback test, need to wait until Phy
5108 + found, then set Loopback */
5109 + if (PhyDev->HalDev->MdioConnect & _CPMDIO_LOOPBK)
5111 + /* Set Phy in Loopback */
5112 + _mdioUserAccessWrite(PhyDev, PHY_CONTROL_REG, PhyNum, PHY_LOOP|PHY_FD);
5113 + /* Do a read to ensure PHY_LOOP has completed */
5114 + _mdioUserAccessRead(PhyDev, PHY_STATUS_REG, PhyNum);
5115 + *PhyState=(*PhyState&~PHY_STATE_MASK)|(LOOPBACK);
5116 + *PhyState|=PHY_CHANGE;
5123 + mdioPrintf("Enable Phy to negotiate external connection\n");
5125 + NWAYadvertise=NWAY_SEL;
5126 + if (*PhyState&SMODE_FD100) NWAYadvertise|=NWAY_FD100;
5127 + if (*PhyState&SMODE_HD100) NWAYadvertise|=NWAY_HD100;
5128 + if (*PhyState&SMODE_FD10) NWAYadvertise|=NWAY_FD10;
5129 + if (*PhyState&SMODE_HD10) NWAYadvertise|=NWAY_HD10;
5131 + *PhyState&=~(PHY_TIM_MASK|PHY_STATE_MASK);
5132 + if ((PhyStatus&NWAY_CAPABLE)&&(*PhyState&SMODE_AUTO)) /*NWAY Phy Detected*/
5134 + /*For NWAY compliant Phys */
5136 + _mdioUserAccessWrite(PhyDev, NWAY_ADVERTIZE_REG, PhyNum, NWAYadvertise);
5140 + mdioPrintf("NWAY Advertising: ");
5141 + if (NWAYadvertise&NWAY_FD100) mdioPrintf("FullDuplex-100 ");
5142 + if (NWAYadvertise&NWAY_HD100) mdioPrintf("HalfDuplex-100 ");
5143 + if (NWAYadvertise&NWAY_FD10) mdioPrintf("FullDuplex-10 ");
5144 + if (NWAYadvertise&NWAY_HD10) mdioPrintf("HalfDuplex-10 ");
5148 + _mdioUserAccessWrite(PhyDev, PHY_CONTROL_REG, PhyNum, AUTO_NEGOTIATE_EN);
5150 + _mdioUserAccessWrite(PhyDev, PHY_CONTROL_REG, PhyNum, AUTO_NEGOTIATE_EN|RENEGOTIATE);
5152 + *PhyState|=PHY_CHANGE|PHY_NWST_TO|NWAY_START;
5156 + *PhyState&=~SMODE_AUTO; /*The Phy is not capable of auto negotiation! */
5158 + for(j=0x8000,i=0;(i<16)&&((j&m)==0);i++,j>>=1);
5161 + if (m&(NWAY_FD100|NWAY_HD100))
5164 + m&=(NWAY_FD100|NWAY_HD100);
5166 + if (m&(NWAY_FD100|NWAY_FD10))
5169 + mdioPrintf("Requested PHY mode %s Duplex %s Mbps\n",(j&PHY_FD)?"Full":"Half",(j&PHY_100)?"100":"10");
5170 + _mdioUserAccessWrite(PhyDev, PHY_CONTROL_REG, PhyNum, j);
5171 + *PhyState&=~PHY_SPEED_MASK;
5173 + *PhyState|=(1<<PHY_SPEED_OFFSET);
5174 + *PhyState&=~PHY_DUPLEX_MASK;
5176 + *PhyState|=(1<<PHY_DUPLEX_OFFSET);
5177 + *PhyState|=PHY_CHANGE|PHY_LINK_TO|LINK_WAIT;
5179 + _mdioMdixDelay(PhyDev); /* If AutoMdix add delay */
5182 +void _MdioNwayStartState(PHY_DEVICE *PhyDev)
5184 + bit32u *PhyState = &PhyDev->PhyState;
5185 + bit32u PhyNum,PhyMode;
5187 + PhyNum=(*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET;
5189 + /*Wait for Negotiation to start */
5191 + PhyMode=_mdioUserAccessRead(PhyDev, PHY_CONTROL_REG, PhyNum);
5193 + if((PhyMode&RENEGOTIATE)==0)
5195 + _mdioUserAccessRead(PhyDev, PHY_STATUS_REG, PhyNum); /*Flush pending latch bits*/
5196 + *PhyState&=~(PHY_STATE_MASK|PHY_TIM_MASK);
5197 + *PhyState|=PHY_CHANGE|NWAY_WAIT|PHY_NWDN_TO;
5198 + _mdioMdixDelay(PhyDev); /* If AutoMdix add delay */
5202 + if (*PhyState&PHY_TIM_MASK)
5203 + *PhyState=(*PhyState&~PHY_TIM_MASK)|((*PhyState&PHY_TIM_MASK)-(1<<PHY_TIM_OFFSET));
5205 + _mdioPhyTimeOut(PhyDev);
5209 +void _MdioNwayWaitState(PHY_DEVICE *PhyDev)
5211 + bit32u *PhyState = &PhyDev->PhyState;
5212 + bit32u PhyNum,PhyStatus,NWAYadvertise,NWAYREadvertise,NegMode,i,j;
5214 + PhyNum=(*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET;
5216 + PhyStatus=_mdioUserAccessRead(PhyDev, PHY_STATUS_REG, PhyNum);
5218 + if (PhyStatus&NWAY_COMPLETE)
5220 + *PhyState|=PHY_CHANGE;
5221 + *PhyState&=~PHY_SPEED_MASK;
5222 + *PhyState&=~PHY_DUPLEX_MASK;
5224 + NWAYadvertise =_mdioUserAccessRead(PhyDev, NWAY_ADVERTIZE_REG, PhyNum);
5225 + NWAYREadvertise =_mdioUserAccessRead(PhyDev, NWAY_REMADVERTISE_REG, PhyNum);
5227 + /* Negotiated mode is we and the remote have in common */
5228 + NegMode = NWAYadvertise & NWAYREadvertise;
5232 + mdioPrintf("Phy: %d, ",(*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET);
5233 + mdioPrintf("NegMode %04X, NWAYadvertise %04X, NWAYREadvertise %04X\n",
5234 + NegMode, NWAYadvertise, NWAYREadvertise);
5237 + /* Limit negotiation to fields below */
5238 + NegMode &= (NWAY_FD100|NWAY_HD100|NWAY_FD10|NWAY_HD10);
5242 + NegMode=(NWAY_HD100|NWAY_HD10)&NWAYadvertise; /*or 10 ?? who knows, Phy is not MII compliant*/
5245 + mdioPrintf("Mdio:WARNING: Negotiation complete but NO agreement, default is HD\n");
5246 + _mdioDumpPhyDetailed(PhyDev);
5249 + for(j=0x8000,i=0;(i<16)&&((j&NegMode)==0);i++,j>>=1);
5255 + mdioPrintf("Negotiated connection: ");
5256 + if (NegMode&NWAY_FD100) mdioPrintf("FullDuplex 100 Mbs\n");
5257 + if (NegMode&NWAY_HD100) mdioPrintf("HalfDuplex 100 Mbs\n");
5258 + if (NegMode&NWAY_FD10) mdioPrintf("FullDuplex 10 Mbs\n");
5259 + if (NegMode&NWAY_HD10) mdioPrintf("HalfDuplex 10 Mbs\n");
5263 + if (PhyStatus&PHY_LINKED)
5264 + *PhyState=(*PhyState&~PHY_STATE_MASK)|LINKED;
5266 + *PhyState=(*PhyState&~PHY_STATE_MASK)|LINK_WAIT;
5267 + if (NegMode&(NWAY_FD100|NWAY_HD100))
5268 + *PhyState=(*PhyState&~PHY_SPEED_MASK)|(1<<PHY_SPEED_OFFSET);
5269 + if (NegMode&(NWAY_FD100|NWAY_FD10))
5270 + *PhyState=(*PhyState&~PHY_DUPLEX_MASK)|(1<<PHY_DUPLEX_OFFSET);
5275 + if (*PhyState&PHY_TIM_MASK)
5276 + *PhyState=(*PhyState&~PHY_TIM_MASK)|((*PhyState&PHY_TIM_MASK)-(1<<PHY_TIM_OFFSET));
5278 + _mdioPhyTimeOut(PhyDev);
5282 +void _MdioLinkWaitState(PHY_DEVICE *PhyDev)
5284 + bit32u *PhyState = &PhyDev->PhyState;
5288 + PhyNum=(*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET;
5290 + PhyStatus=_mdioUserAccessRead(PhyDev, PHY_STATUS_REG, PhyNum);
5292 + if (PhyStatus&PHY_LINKED)
5294 + *PhyState=(*PhyState&~PHY_STATE_MASK)|LINKED;
5295 + *PhyState|=PHY_CHANGE;
5299 + if (*PhyState&PHY_TIM_MASK)
5300 + *PhyState=(*PhyState&~PHY_TIM_MASK)|((*PhyState&PHY_TIM_MASK)-(1<<PHY_TIM_OFFSET));
5302 + _mdioPhyTimeOut(PhyDev);
5306 +void _mdioPhyTimeOut(PHY_DEVICE *PhyDev)
5310 + if(_mdioMdixSupported(PhyDev) == 0)
5311 + return; /* AutoMdix not supported */
5313 + PhyState = &PhyDev->PhyState;
5315 + /* Indicate MDI/MDIX mode switch is needed */
5316 + *PhyState|=PHY_MDIX_SWITCH;
5318 + /* Toggle the MDIX mode indicatir */
5319 + if(*PhyState & PHY_MDIX)
5320 + *PhyState &= ~PHY_MDIX_MASK; /* Current State is MDIX, set to MDI */
5322 + *PhyState |= PHY_MDIX_MASK; /* Current State is MDI, set to MDIX */
5324 + /* Reset state machine to FOUND */
5325 + *PhyState=(*PhyState&~PHY_STATE_MASK)|(FOUND);
5328 +void _MdioLoopbackState(PHY_DEVICE *PhyDev)
5333 +void _MdioLinkedState(PHY_DEVICE *PhyDev)
5335 + bit32u *PhyState = &PhyDev->PhyState;
5336 + bit32u PhyNum = (*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET;
5338 + if (myMDIO_LINK&(1<<PhyNum)) return; /* if still Linked, exit*/
5341 + *PhyState&=~(PHY_STATE_MASK|PHY_TIM_MASK);
5342 + if (*PhyState&SMODE_AUTO)
5343 + *PhyState|=PHY_CHANGE|NWAY_WAIT|PHY_NWDN_TO;
5345 + *PhyState|=PHY_CHANGE|PHY_LINK_TO|LINK_WAIT;
5347 + _mdioMdixDelay(PhyDev); /* If AutoMdix add delay */
5350 +void _MdioDefaultState(PHY_DEVICE *PhyDev)
5352 + bit32u *PhyState = &PhyDev->PhyState;
5353 + /*Awaiting a cpMacMdioInit call */
5354 + *PhyState|=PHY_CHANGE;
5358 +/*User Calls********************************************************* */
5360 +void cpMacMdioClose(PHY_DEVICE *PhyDev, int Full)
5365 +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)
5367 + bit32u HighestChannel;
5368 + bit32u ControlState;
5369 + bit32u *PhyState = &PhyDev->PhyState;
5370 + bit32u clkdiv; /*MJH+030328*/
5372 + cpMacDebug=verbose;
5374 + PhyDev->miibase = miibase;
5375 + PhyDev->inst = inst;
5376 + PhyDev->PhyMask = PhyMask;
5377 + PhyDev->MLinkMask = MLinkMask;
5378 + PhyDev->MdixMask = MdixMask;
5379 +#ifdef _CPHAL_CPMAC
5380 + PhyDev->HalDev = (HAL_DEVICE*) Info;
5383 + *PhyState &= ~PHY_MDIX_MASK; /* Set initial State to MDI */
5385 + /* Check that the channel supplied is within range */
5386 + HighestChannel = (myMDIO_CONTROL & MDIO_CONTROL_HIGHEST_USER_CHANNEL) > 8;
5387 + if(inst > HighestChannel)
5388 + return(HighestChannel);
5390 + /*Setup MII MDIO access regs */
5392 + /* Calculate the correct value for the mclkdiv */
5393 + /* See PITS #14 */
5394 + if (MdioClockFreq) /*MJH+030402*/
5395 + clkdiv = (MdioBusFreq / MdioClockFreq) - 1; /*MJH+030402*/
5396 + else /*MJH+030402*/
5397 + clkdiv = 0xFF; /*MJH+030402*/
5399 + ControlState = MDIO_CONTROL_ENABLE;
5400 + ControlState |= (clkdiv & MDIO_CONTROL_CLKDIV); /*MJH+030328*/
5403 + If mii is not out of reset or if the Control Register is not set correctly
5406 + if( !(VOLATILE32(ResetReg) & (1 << ResetBit)) ||
5407 + ((myMDIO_CONTROL & (MDIO_CONTROL_CLKDIV | MDIO_CONTROL_ENABLE)) != ControlState) )/*GSG~030404*/
5409 + /* MII not setup, Setup initial condition */
5410 + VOLATILE32(ResetReg) &= ~(1 << ResetBit);
5411 + _mdioDelayEmulate(PhyDev, 64);
5412 + VOLATILE32(ResetReg) |= (1 << ResetBit); /* take mii out of reset */
5413 + _mdioDelayEmulate(PhyDev, 64);
5414 + myMDIO_CONTROL = ControlState; /* Enable MDIO */
5420 + mdioPrintf("cpMacMdioInit\n");
5421 + _mdioDumpState(PhyDev);
5425 +void cpMacMdioSetPhyMode(PHY_DEVICE *PhyDev,bit32u PhyMode)
5427 + bit32u *PhyState = &PhyDev->PhyState;
5428 + bit32u CurrentState;
5430 + PhyDev->PhyMode = PhyMode; /* used for AUTOMIDX, planned to replace PhyState fields */
5432 + *PhyState&=~PHY_SMODE_MASK;
5434 + if (PhyMode&NWAY_AUTO) *PhyState|=SMODE_AUTO;
5435 + if (PhyMode&NWAY_FD100) *PhyState|=SMODE_FD100;
5436 + if (PhyMode&NWAY_HD100) *PhyState|=SMODE_HD100;
5437 + if (PhyMode&NWAY_FD10) *PhyState|=SMODE_FD10;
5438 + if (PhyMode&NWAY_HD10) *PhyState|=SMODE_HD10;
5440 + CurrentState=*PhyState&PHY_STATE_MASK;
5441 + if ((CurrentState==NWAY_START)||
5442 + (CurrentState==NWAY_WAIT) ||
5443 + (CurrentState==LINK_WAIT) ||
5444 + (CurrentState==LINKED) )
5445 + *PhyState=(*PhyState&~PHY_STATE_MASK)|FOUND|PHY_CHANGE;
5447 + mdioPrintf("cpMacMdioSetPhyMode:%08X Auto:%d, FD10:%d, HD10:%d, FD100:%d, HD100:%d\n", PhyMode,
5448 + PhyMode&NWAY_AUTO, PhyMode&NWAY_FD10, PhyMode&NWAY_HD10, PhyMode&NWAY_FD100,
5449 + PhyMode&NWAY_HD100);
5450 + _mdioDumpState(PhyDev);
5453 +/* cpMacMdioTic is called every 10 mili seconds to process Phy states */
5455 +int cpMacMdioTic(PHY_DEVICE *PhyDev)
5457 + bit32u *PhyState = &PhyDev->PhyState;
5458 + bit32u CurrentState;
5460 + /*Act on current state of the Phy */
5462 + CurrentState=*PhyState;
5463 + switch(CurrentState&PHY_STATE_MASK)
5465 + case INIT: _MdioInitState(PhyDev); break;
5466 + case FINDING: _MdioFindingState(PhyDev); break;
5467 + case FOUND: _MdioFoundState(PhyDev); break;
5468 + case NWAY_START: _MdioNwayStartState(PhyDev); break;
5469 + case NWAY_WAIT: _MdioNwayWaitState(PhyDev); break;
5470 + case LINK_WAIT: _MdioLinkWaitState(PhyDev); break;
5471 + case LINKED: _MdioLinkedState(PhyDev); break;
5472 + case LOOPBACK: _MdioLoopbackState(PhyDev); break;
5473 + default: _MdioDefaultState(PhyDev); break;
5476 + /*Dump state info if a change has been detected */
5478 + if ((CurrentState&~PHY_TIM_MASK)!=(*PhyState&~PHY_TIM_MASK))
5479 + _mdioDumpState(PhyDev);
5481 + /* Check is MDI/MDIX mode switch is needed */
5482 + if(*PhyState & PHY_MDIX_SWITCH)
5486 + *PhyState &= ~PHY_MDIX_SWITCH; /* Clear Mdix Flip indicator */
5488 + if(*PhyState & PHY_MDIX)
5492 + return(_MIIMDIO_MDIXFLIP|Mdix);
5495 + /*Return state change to user */
5497 + if (*PhyState&PHY_CHNG_MASK)
5499 + *PhyState&=~PHY_CHNG_MASK;
5506 +/* cpMacMdioGetDuplex is called to retrieve the Duplex info */
5508 +int cpMacMdioGetDuplex(PHY_DEVICE *PhyDev)
5510 + bit32u *PhyState = &PhyDev->PhyState;
5511 + return((*PhyState&PHY_DUPLEX_MASK)?1:0); /* return 0 or a 1 */
5514 +/* cpMacMdioGetSpeed is called to retreive the Speed info */
5516 +int cpMacMdioGetSpeed(PHY_DEVICE *PhyDev)
5518 + bit32u *PhyState = &PhyDev->PhyState;
5519 + return(*PhyState&PHY_SPEED_MASK);
5522 +/* cpMacMdioGetPhyNum is called to retreive the Phy Device Adr info */
5524 +int cpMacMdioGetPhyNum(PHY_DEVICE *PhyDev)
5526 + bit32u *PhyState = &PhyDev->PhyState;
5527 + return((*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET);
5530 +/* cpMacMdioGetLoopback is called to Determine if the LOOPBACK state has been reached*/
5532 +int cpMacMdioGetLoopback(PHY_DEVICE *PhyDev)
5534 + bit32u *PhyState = &PhyDev->PhyState;
5535 + return((*PhyState&PHY_STATE_MASK)==LOOPBACK);
5537 +/* cpMacMdioGetLinked is called to Determine if the LINKED state has been reached*/
5539 +int cpMacMdioGetLinked(PHY_DEVICE *PhyDev)
5541 + bit32u *PhyState = &PhyDev->PhyState;
5542 + return((*PhyState&PHY_STATE_MASK)==LINKED);
5545 +void cpMacMdioLinkChange(PHY_DEVICE *PhyDev)
5547 + bit32u *PhyState = &PhyDev->PhyState;
5548 + bit32u PhyNum,PhyStatus;
5550 + PhyNum=(*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET;
5552 + if (cpMacMdioGetLinked(PhyDev))
5554 + PhyStatus=_mdioUserAccessRead(PhyDev, PHY_STATUS_REG, PhyNum);
5556 + if ((PhyStatus&PHY_LINKED)==0)
5558 + *PhyState&=~(PHY_TIM_MASK|PHY_STATE_MASK);
5559 + if (*PhyState&SMODE_AUTO)
5561 + _mdioUserAccessWrite(PhyDev, PHY_CONTROL_REG, PhyNum, AUTO_NEGOTIATE_EN|RENEGOTIATE);
5562 + *PhyState|=PHY_CHANGE|PHY_NWST_TO|NWAY_START;
5566 + *PhyState|=PHY_CHANGE|PHY_LINK_TO|LINK_WAIT;
5572 +void cpMacMdioGetVer(bit32u miibase, bit32u *ModID, bit32u *RevMaj, bit32u *RevMin)
5576 + Ver = MDIO_VER(miibase);
5578 + *ModID = (Ver & MDIO_VER_MODID) >> 16;
5579 + *RevMaj = (Ver & MDIO_VER_REVMAJ) >> 8;
5580 + *RevMin = (Ver & MDIO_VER_REVMIN);
5583 +int cpMacMdioGetPhyDevSize(void)
5585 + return(sizeof(PHY_DEVICE));
5588 + /* returns 0 if current Phy has AutoMdix support, otherwise 0 */
5589 +int _mdioMdixSupported(PHY_DEVICE *PhyDev)
5591 + bit32u *PhyState = &PhyDev->PhyState;
5594 + if((PhyDev->PhyMode & NWAY_AUTOMDIX) == 0)
5595 + return(0); /* AutoMdix not turned on */
5597 + PhyNum=(*PhyState&PHY_DEV_MASK)>>PHY_DEV_OFFSET;
5598 + if( ((1<<PhyNum) & PhyDev->MdixMask) == 0)
5599 + return(0); /* Phy does not support AutoMdix*/
5604 +/* If current Phy has AutoMdix support add Mdix Delay to the Timer State Value */
5605 +void _mdioMdixDelay(PHY_DEVICE *PhyDev)
5608 + bit32u *PhyState = &PhyDev->PhyState;
5609 +#ifdef _CPHAL_CPMAC
5610 + HAL_DEVICE *HalDev = PhyDev->HalDev;
5613 + if(_mdioMdixSupported(PhyDev) == 0)
5614 + return; /* AutoMdix not supported */
5615 +/* Currently only supported when used with the CPMAC */
5616 +#ifdef _CPHAL_CPMAC
5617 + /* Get the Delay value in milli-seconds and convert to ten-milli second value */
5618 + Delay = cpmacRandomRange(HalDev, _AUTOMDIX_DELAY_MIN, _AUTOMDIX_DELAY_MAX);
5621 + /* Add AutoMidx Random Switch Delay to AutoMdix Link Delay */
5623 + Delay += (PHY_MDIX_TO>>PHY_TIM_OFFSET);
5625 + /* Change Timeout value to AutoMdix standard */
5626 + *PhyState &= ~(PHY_TIM_MASK); /* Clear current Time out value */
5627 + *PhyState |= (Delay<<PHY_TIM_OFFSET); /* Set new value */
5632 diff -urN linux.old/drivers/net/avalanche_cpmac/cpmdio.h linux.dev/drivers/net/avalanche_cpmac/cpmdio.h
5633 --- linux.old/drivers/net/avalanche_cpmac/cpmdio.h 1970-01-01 01:00:00.000000000 +0100
5634 +++ linux.dev/drivers/net/avalanche_cpmac/cpmdio.h 2005-07-12 02:48:42.047593000 +0200
5636 +/*****************************************************************************
5637 +** TNETD53xx Software Support
5638 +** Copyright(c) 2002, Texas Instruments Incorporated. All Rights Reserved.
5640 +** FILE: cpmdio.h User Include for MDIO API Access
5643 +** This include file contains definitions for the the MDIO API
5646 +** 27Mar02 Michael Hanrahan Original (modified from emacmdio.h)
5647 +** 04Apr02 Michael Hanrahan Added Interrupt Support
5648 +*****************************************************************************/
5649 +#ifndef _INC_CPMDIO
5650 +#define _INC_CPMDIO
5653 +#ifndef __CPHAL_CPMDIO
5654 +typedef void PHY_DEVICE;
5658 +/*Version Information */
5660 +void cpMacMdioGetVer(bit32u miiBase, bit32u *ModID, bit32u *RevMaj, bit32u *RevMin);
5662 +/*Called once at the begining of time */
5664 +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);
5665 +int cpMacMdioGetPhyDevSize(void);
5668 +/*Called every 10 mili Seconds, returns TRUE if there has been a mode change */
5670 +int cpMacMdioTic(PHY_DEVICE *PhyDev);
5672 +/*Called to set Phy mode */
5674 +void cpMacMdioSetPhyMode(PHY_DEVICE *PhyDev,bit32u PhyMode);
5676 +/*Calls to retreive info after a mode change! */
5678 +int cpMacMdioGetDuplex(PHY_DEVICE *PhyDev);
5679 +int cpMacMdioGetSpeed(PHY_DEVICE *PhyDev);
5680 +int cpMacMdioGetPhyNum(PHY_DEVICE *PhyDev);
5681 +int cpMacMdioGetLinked(PHY_DEVICE *PhyDev);
5682 +void cpMacMdioLinkChange(PHY_DEVICE *PhyDev);
5686 +void cpMacMdioClose(PHY_DEVICE *PhyDev, int Full);
5689 +/* Phy Mode Values */
5690 +#define NWAY_AUTOMDIX (1<<16)
5691 +#define NWAY_FD100 (1<<8)
5692 +#define NWAY_HD100 (1<<7)
5693 +#define NWAY_FD10 (1<<6)
5694 +#define NWAY_HD10 (1<<5)
5695 +#define NWAY_AUTO (1<<0)
5699 + * Tic() return values
5703 +#define _MIIMDIO_MDIXFLIP (1<<28)
5705 +#define _AUTOMDIX_DELAY_MIN 80 /* milli-seconds*/
5706 +#define _AUTOMDIX_DELAY_MAX 200 /* milli-seconds*/
5708 +#endif /* _INC_CPMDIO */
5709 diff -urN linux.old/drivers/net/avalanche_cpmac/cppi_cpmac.c linux.dev/drivers/net/avalanche_cpmac/cppi_cpmac.c
5710 --- linux.old/drivers/net/avalanche_cpmac/cppi_cpmac.c 1970-01-01 01:00:00.000000000 +0100
5711 +++ linux.dev/drivers/net/avalanche_cpmac/cppi_cpmac.c 2005-07-12 02:48:42.048593000 +0200
5713 +/*************************************************************************
5714 + * TNETDxxxx Software Support
5715 + * Copyright (c) 2002,2003 Texas Instruments Incorporated. All Rights Reserved.
5720 + * This file contains shared code for all CPPI modules.
5723 + * 7Aug02 Greg RC1.00 Original Version created.
5724 + * 27Sep02 Mick RC1.01 Merged for use by CPMAC/CPSAR
5725 + * 16Oct02 Mick RC1.02 Performance Tweaks (see cppihist.txt)
5726 + * 12Nov02 Mick RC1.02 Updated to use cpmac_reg.h
5727 + * 09Jan03 Mick RC3.01 Removed modification to RxBuffer ptr
5728 + * 28Mar03 Mick 1.03 RxReturn now returns error if Malloc Fails
5729 + * 10Apr03 Mick 1.03.02 Added Needs Buffer Support
5730 + * 11Jun03 Mick 1.06.02 halSend() errors corrected
5731 + * 23Aug04 Mick 1.07.08 cpmac only - Send: bypass threshold check if TxInts re-enabled
5733 + * @author Greg Guyotte
5735 + * @date 7-Aug-2002
5736 + *****************************************************************************/
5737 +/* each CPPI module must modify this file, the rest of the
5738 + code in cppi.c should be totally shared *//* Each CPPI module MUST properly define all constants shown below */
5740 +/* CPPI registers */
5742 +/* the following defines are not CPPI specific */
5744 +static int TxInt(HAL_DEVICE *HalDev, int Ch, int Queue, int *MoreWork);
5746 +static void FreeRx(HAL_DEVICE *HalDev, int Ch)
5748 + HAL_RCB *rcb_ptr; /*+GSG 030303*/
5749 + int rcbSize = (sizeof(HAL_RCB)+0xf)&~0xf; /*+GSG 030303*/
5750 + int Num = HalDev->ChData[Ch].RxNumBuffers, i; /*+GSG 030303*/
5752 + /* Free Rx data buffers attached to descriptors, if necessary */
5753 + if (HalDev->RcbStart[Ch] != 0) /*+GSG 030303*/
5755 + for(i=0;i<Num;i++) /*+GSG 030303*/
5757 + rcb_ptr = (HAL_RCB *)(HalDev->RcbStart[Ch] + (i*rcbSize)); /*+GSG 030303*/
5759 + /* free the data buffer */
5760 + if (rcb_ptr->DatPtr != 0)
5763 + HalDev->OsFunc->FreeRxBuffer((void *)rcb_ptr->OsInfo, (void *)rcb_ptr->DatPtr);
5764 + rcb_ptr->OsInfo=0; /*MJH+030522*/
5765 + rcb_ptr->DatPtr=0; /*MJH+030522*/
5770 + /* free up all desciptors at once */
5771 + HalDev->OsFunc->FreeDmaXfer(HalDev->RcbStart[Ch]);
5773 + /* mark buffers as freed */
5774 + HalDev->RcbStart[Ch] = 0;
5777 +static void FreeTx(HAL_DEVICE *HalDev, int Ch, int Queue)
5782 + /* free all descriptors at once */
5783 + HalDev->OsFunc->FreeDmaXfer(HalDev->TcbStart[Ch][Queue]);
5785 + HalDev->TcbStart[Ch][Queue] = 0;
5788 +/* return of 0 means that this code executed, -1 means the interrupt was not
5789 + a teardown interrupt */
5790 +static int RxTeardownInt(HAL_DEVICE *HalDev, int Ch)
5792 + bit32u base = HalDev->dev_base;
5794 + /* check to see if the interrupt is a teardown interrupt */
5795 + if (((CPMAC_RX_INT_ACK( base , Ch )) & TEARDOWN_VAL) == TEARDOWN_VAL)
5797 + /* finish channel teardown */
5799 + /* Free channel resources on a FULL teardown */
5800 + if (HalDev->RxTeardownPending[Ch] & FULL_TEARDOWN)
5802 + FreeRx(HalDev, Ch);
5805 + /* bug fix - clear Rx channel pointers on teardown */
5806 + HalDev->RcbPool[Ch] = 0;
5807 + HalDev->RxActQueueHead[Ch] = 0;
5808 + HalDev->RxActQueueCount[Ch] = 0;
5809 + HalDev->RxActive[Ch] = FALSE;
5811 + /* write completion pointer */
5812 + (CPMAC_RX_INT_ACK( base , Ch )) = TEARDOWN_VAL;
5814 + /* use direction bit as a teardown pending bit! May be able to
5815 + use only one teardown pending integer in HalDev */
5817 + HalDev->RxTeardownPending[Ch] &= ~RX_TEARDOWN;
5819 + HalDev->ChIsOpen[Ch][DIRECTION_RX] = 0;
5821 + HalDev->ChIsOpen[Ch][DIRECTION_RX] = 0;
5822 + CPMAC_RX_INTMASK_CLEAR(HalDev->dev_base) = (1<<Ch);
5823 + if ((HalDev->RxTeardownPending[Ch] & BLOCKING_TEARDOWN) == 0)
5826 + HalDev->OsFunc->TeardownComplete(HalDev->OsDev, Ch, DIRECTION_RX);
5828 + HalDev->RxTeardownPending[Ch] = 0;
5830 + return (EC_NO_ERRORS);
5835 +/* return of 0 means that this code executed, -1 means the interrupt was not
5836 + a teardown interrupt. Note: this code is always called with Queue == 0 (hi priority). */
5837 +static int TxTeardownInt(HAL_DEVICE *HalDev, int Ch, int Queue)
5839 + bit32u base = HalDev->dev_base;
5840 + HAL_TCB *Last, *Curr, *First; /*+GSG 030303*/
5843 + if (((CPMAC_TX_INT_ACK( base , Ch )) & TEARDOWN_VAL) == TEARDOWN_VAL)
5845 + /* perform all actions for both queues (+GSG 040212) */
5846 + for (i=0; i<HalDev->ChData[Ch].TxNumQueues; i++)
5848 + /* return outstanding buffers to OS +RC3.02*/
5849 + Curr = HalDev->TxActQueueHead[Ch][i]; /*+GSG 030303*/
5850 + First = Curr; /*+GSG 030303*/
5851 + while (Curr) /*+GSG 030303*/
5853 + /* Pop TCB(s) for packet from the stack */ /*+GSG 030303*/
5854 + Last = Curr->Eop; /*+GSG 030303*/
5855 + HalDev->TxActQueueHead[Ch][i] = Last->Next; /*+GSG 030303*/
5857 + /* return to OS */ /*+GSG 030303*/
5858 + HalDev->OsFunc->SendComplete(Curr->OsInfo); /*+GSG 030303*/
5860 + /* Push Tcb(s) back onto the stack */ /*+GSG 030303*/
5861 + Curr = Last->Next; /*+GSG 030303*/
5862 + Last->Next = HalDev->TcbPool[Ch][i]; /*+GSG 030303*/
5863 + HalDev->TcbPool[Ch][i] = First; /*+GSG 030303*/
5865 + /* set the first(SOP) pointer for the next packet */ /*+GSG 030303*/
5866 + First = Curr; /*+GSG 030303*/
5870 + /* finish channel teardown */
5872 + if (HalDev->TxTeardownPending[Ch] & FULL_TEARDOWN)
5874 + FreeTx(HalDev, Ch, 0);
5876 + if (HalDev->ChData[Ch].TxNumQueues == 2)
5877 + FreeTx(HalDev, Ch, 1);
5878 + } /* if FULL teardown */
5880 + /* perform all actions for both queues (+GSG 040212) */
5881 + for (i=0; i<HalDev->ChData[Ch].TxNumQueues; i++)
5883 + /* bug fix - clear Tx channel pointers on teardown */
5884 + HalDev->TcbPool[Ch][i] = 0;
5885 + HalDev->TxActQueueHead[Ch][i] = 0;
5886 + HalDev->TxActQueueCount[Ch][i] = 0;
5887 + HalDev->TxActive[Ch][i] = FALSE;
5890 + /* write completion pointer, only needed for the high priority queue */
5891 + (CPMAC_TX_INT_ACK( base , Ch )) = TEARDOWN_VAL;
5893 + /* no longer pending teardown */
5894 + HalDev->TxTeardownPending[Ch] &= ~TX_TEARDOWN;
5896 + HalDev->ChIsOpen[Ch][DIRECTION_TX] = 0;
5898 + HalDev->ChIsOpen[Ch][DIRECTION_TX] = 0;
5899 + CPMAC_TX_INTMASK_CLEAR(HalDev->dev_base) = (1<<Ch);
5900 + if ((HalDev->TxTeardownPending[Ch] & BLOCKING_TEARDOWN) == 0)
5903 + HalDev->OsFunc->TeardownComplete(HalDev->OsDev, Ch, DIRECTION_TX);
5905 + HalDev->TxTeardownPending[Ch] = 0;
5907 + return (EC_NO_ERRORS);
5913 +static void AddToRxQueue(HAL_DEVICE *HalDev, HAL_RCB *FirstRcb, HAL_RCB *LastRcb, int FragCount, int Ch)
5915 + if (HalDev->RxActQueueHead[Ch]==0)
5918 + HalDev->RxActQueueHead[Ch]=FirstRcb;
5919 + HalDev->RxActQueueTail[Ch]=LastRcb;
5920 + if (!HalDev->RxActive[Ch])
5922 + /* write Rx Queue Head Descriptor Pointer */
5923 + ((CPMAC_RX_HDP( HalDev->dev_base , Ch )) ) = VirtToPhys(FirstRcb) - HalDev->offset;
5924 + HalDev->RxActive[Ch]=TRUE;
5929 + register HAL_RCB *OldTailRcb;
5930 + register bit32u rmode;
5932 + HalDev->OsFunc->CriticalOn();
5933 + OldTailRcb=HalDev->RxActQueueTail[Ch];
5934 + OldTailRcb->Next=(void *)FirstRcb;
5935 + OldTailRcb=VirtToVirtNoCache(OldTailRcb);
5936 + OldTailRcb->HNext=VirtToPhys(FirstRcb) - HalDev->offset;
5937 + HalDev->RxActQueueTail[Ch]=LastRcb;
5938 + rmode=OldTailRcb->mode;
5939 + if (rmode&CB_EOQ_BIT)
5941 + rmode&=~CB_EOQ_BIT;
5942 + ((CPMAC_RX_HDP( HalDev->dev_base , Ch )) ) = VirtToPhys(FirstRcb) - HalDev->offset;
5943 + OldTailRcb->mode=rmode;
5945 + HalDev->OsFunc->CriticalOff();
5950 + * @ingroup CPHAL_Functions
5951 + * This function is called to indicate to the CPHAL that the upper layer
5952 + * software has finished processing the receive data (given to it by
5953 + * osReceive()). The CPHAL will then return the appropriate receive buffers
5954 + * and buffer descriptors to the available pool.
5956 + * @param HalReceiveInfo Start of receive buffer descriptor chain returned to
5958 + * @param StripFlag Flag indicating whether the upper layer software has
5959 + * retained ownership of the receive data buffers.
5961 + * 'FALSE' means that the CPHAL can reuse the receive data buffers.
5963 + * 'TRUE' : indicates the data buffers were retained by the OS
5965 + * NOTE: If StripFlag is TRUE, it is the responsibility of the upper layer software to free the buffers when they are no longer needed.
5967 + * @return EC_NO_ERRORS (ok). <BR>
5968 + * Possible Error Codes:<BR>
5969 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
5970 + * @ref EC_VAL_RCB_NEEDS_BUFFER "EC_VAL_RCB_NEEDS_BUFFER"<BR>
5971 + * @ref EC_VAL_RCB_DROPPED "EC_VAL_RCB_DROPPED"<BR>
5973 +static int halRxReturn(HAL_RECEIVEINFO *HalReceiveInfo,
5978 + HAL_DEVICE *HalDev;
5982 + Ch = HalReceiveInfo->mode&0x0ff;
5983 + HalDev = (HAL_DEVICE *)HalReceiveInfo->Off_BLen;
5984 + FragCount = HalReceiveInfo->mode>>8;
5986 + if (HalDev->State != enOpened)
5987 + return(EC_CPMAC |EC_FUNC_RXRETURN|EC_VAL_INVALID_STATE);
5989 + LastRcb=(HAL_RCB *)HalReceiveInfo->Eop;
5992 + RcbSize = HalDev->ChData[Ch].RxBufSize;
5996 + LastRcb->Off_BLen=RcbSize;
5997 + LastRcb->mode=CB_OWNERSHIP_BIT;
6000 + HalReceiveInfo->Off_BLen=RcbSize;
6001 + HalReceiveInfo->mode=CB_OWNERSHIP_BIT;
6003 + /* If OS has kept the buffers for this packet, attempt to alloc new buffers */
6006 + int rc=0; /*MJH+030417*/
6007 + int GoodCount=0; /*GSG+030421*/
6010 + HAL_RCB *CurrHeadRcb = HalReceiveInfo, *LastGoodRcb=0; /* +GSG 030421 */
6012 + TempRcb = HalReceiveInfo;
6013 + for (i=0; i<FragCount; i++)
6017 + dbgPrintf("Rx Return error while allocating new buffers\n");
6018 + dbgPrintf("Rcb = %08x, Rcb->Eop = %08x, FragCount = %d:%d\n",
6019 + (bit32u)HalReceiveInfo, (bit32u)HalReceiveInfo->Eop, FragCount,i);
6022 + return(EC_CPPI|EC_FUNC_RXRETURN|EC_VAL_CORRUPT_RCB_CHAIN);
6025 + pBuf= (char *) HalDev->OsFunc->MallocRxBuffer(RcbSize,0,
6026 + 0xF,HalDev->ChData[Ch].OsSetup,
6028 + (void *)&TempRcb->OsInfo,
6029 + (void *) HalDev->OsDev);
6032 + /* malloc failed, add this RCB to Needs Buffer List */
6033 + (HAL_RCB *)TempRcb->Eop = TempRcb; /* GSG +030430 */
6034 + TempRcb->mode=1<<8|Ch;
6035 + TempRcb->Off_BLen=(bit32u)HalDev;
6037 + if(HalDev->NeedsCount < MAX_NEEDS) /* +MJH 030410 */
6038 + { /* +MJH 030410 */
6039 + HalDev->Needs[HalDev->NeedsCount] = (HAL_RECEIVEINFO *) TempRcb; /* +MJH 030410 */
6040 + HalDev->NeedsCount++; /* +MJH 030410 */
6041 + rc = (EC_CPPI|EC_FUNC_RXRETURN|EC_VAL_RCB_NEEDS_BUFFER); /* ~MJH 030417 */
6042 + } /* +MJH 030410 */
6043 + else /* +MJH 030410 */
6044 + rc = (EC_CPPI|EC_FUNC_RXRETURN|EC_VAL_RCB_DROPPED); /* ~MJH 030417 */
6046 + /* requeue any previous RCB's that were ready to go before this one */
6047 + if (GoodCount > 0) /* +GSG 030421 */
6048 + { /* +GSG 030421 */
6049 + LastGoodRcb->HNext=0; /* +GSG 030430 */
6050 + LastGoodRcb->Next=0; /* +GSG 030430 */
6051 + osfuncDataCacheHitWritebackAndInvalidate((void *)LastGoodRcb, 16); /* +GSG 030430 */
6053 + AddToRxQueue(HalDev, CurrHeadRcb, LastGoodRcb, GoodCount, Ch); /* +GSG 030421 */
6054 + GoodCount = 0; /* +GSG 030421 */
6055 + } /* +GSG 030421 */
6057 + CurrHeadRcb = TempRcb->Next; /* +GSG 030421 */
6059 + else /* +GSG 030421 */
6060 + { /* +GSG 030421 */
6061 + /* malloc succeeded, requeue the RCB to the hardware */
6062 + TempRcb->BufPtr=VirtToPhys(pBuf) - HalDev->offset;
6063 + TempRcb->DatPtr=pBuf;
6064 + /* Emerald fix 10/29 */
6065 + osfuncDataCacheHitWritebackAndInvalidate((void *)TempRcb, 16);
6067 + /* i store the last good RCB in case the malloc fails for the
6068 + next fragment. This ensures that I can go ahead and return
6069 + a partial chain of RCB's to the hardware */
6070 + LastGoodRcb = TempRcb; /* +GSG 030421 */
6071 + GoodCount++; /* +GSG 030421 */
6072 + } /* +GSG 030421 */
6073 + TempRcb = TempRcb->Next;
6074 + } /* end of Frag loop */
6075 + /* if there any good RCB's to requeue, do so here */
6076 + if (GoodCount > 0) /* +GSG 030421 */
6078 + AddToRxQueue(HalDev, CurrHeadRcb, LastGoodRcb, GoodCount, Ch); /* +GSG 030421 */
6080 + return(rc); /* ~GSG 030421 */
6084 + /* Not Stripping */
6086 + /* Write Back SOP and last RCB */
6087 + osfuncDataCacheHitWritebackAndInvalidate((void *)HalReceiveInfo, 16);
6089 + if (FragCount > 1)
6091 + osfuncDataCacheHitWritebackAndInvalidate((void *)LastRcb, 16);
6093 + /* if not stripping buffers, always add to queue */
6094 + AddToRxQueue(HalDev, HalReceiveInfo, LastRcb, FragCount, Ch); /*MJH~030520*/
6097 + return(EC_NO_ERRORS);
6101 + Trys to liberate an RCB until liberation fails.
6102 + Note: If liberation fails then RxReturn will re-add the RCB to the
6105 +static void NeedsCheck(HAL_DEVICE *HalDev)
6107 + HAL_RECEIVEINFO* HalRcb;
6109 + HalDev->OsFunc->CriticalOn();
6110 + while(HalDev->NeedsCount)
6112 + HalDev->NeedsCount--;
6113 + HalRcb = HalDev->Needs[HalDev->NeedsCount];
6114 + rc = halRxReturn(HalRcb, 1);
6115 + /* short circuit if RxReturn starts to fail */
6119 + HalDev->OsFunc->CriticalOff();
6123 + * This function allocates transmit buffer descriptors (internal CPHAL function).
6124 + * It creates a high priority transmit queue by default for a single Tx
6125 + * channel. If QoS is enabled for the given CPHAL device, this function
6126 + * will also allocate a low priority transmit queue.
6128 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
6129 + * @param Ch Channel number.
6131 + * @return 0 OK, Non-Zero Not OK
6133 +static int InitTcb(HAL_DEVICE *HalDev, int Ch)
6135 + int i, Num = HalDev->ChData[Ch].TxNumBuffers;
6138 + int tcbSize, Queue;
6141 + tcbSize = (sizeof(HAL_TCB)+0xf)&~0xf;
6142 + SizeMalloc = (tcbSize*Num)+0xf;
6144 + for (Queue=0; Queue < HalDev->ChData[Ch].TxNumQueues; Queue++)
6146 + if (HalDev->TcbStart[Ch][Queue] == 0)
6149 + /* malloc all TCBs at once */
6150 + AllTcb = (char *)HalDev->OsFunc->MallocDmaXfer(SizeMalloc,0,0xffffffff);
6153 + return(EC_CPPI|EC_FUNC_HAL_INIT|EC_VAL_TCB_MALLOC_FAILED);
6156 + HalDev->OsFunc->Memset(AllTcb, 0, SizeMalloc);
6158 + /* keep this address for freeing later */
6159 + HalDev->TcbStart[Ch][Queue] = AllTcb;
6163 + /* if the memory has already been allocated, simply reuse it! */
6164 + AllTcb = HalDev->TcbStart[Ch][Queue];
6167 + /* align to cache line */
6168 + AllTcb = (char *)(((bit32u)AllTcb + 0xf) &~ 0xf); /*PITS #143 MJH~030522*/
6170 + /* default High priority transmit queue */
6171 + HalDev->TcbPool[Ch][Queue]=0;
6172 + for(i=0;i<Num;i++)
6174 + /*pTcb=(HAL_TCB *) OsFunc->MallocDmaXfer(sizeof(HAL_TCB),0,0xffffffff); */
6175 + pTcb= (HAL_TCB *)(AllTcb + (i*tcbSize));
6178 + pTcb->Next=HalDev->TcbPool[Ch][Queue];
6180 + HalDev->TcbPool[Ch][Queue]=pTcb;
6182 + /*HalDev->TcbEnd = pTcb;*/
6185 + return(EC_NO_ERRORS);
6189 + * This function allocates receive buffer descriptors (internal CPHAL function).
6190 + * After allocation, the function 'queues' (gives to the hardware) the newly
6191 + * created receive buffers to enable packet reception.
6193 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
6194 + * @param Ch Channel number.
6196 + * @return 0 OK, Non-Zero Not OK
6198 +static int InitRcb(HAL_DEVICE *HalDev, int Ch)
6200 + int i, Num = HalDev->ChData[Ch].RxNumBuffers;
6201 + int Size = HalDev->ChData[Ch].RxBufSize;
6210 + rcbSize = (sizeof(HAL_RCB)+0xf)&~0xf;
6211 + SizeMalloc = (rcbSize*Num)+0xf;
6213 + if (HalDev->RcbStart[Ch] == 0)
6217 + /* malloc all RCBs at once */
6218 + AllRcb= (char *)HalDev->OsFunc->MallocDmaXfer(SizeMalloc,0,0xffffffff);
6221 + return(EC_CPPI|EC_FUNC_HAL_INIT|EC_VAL_RCB_MALLOC_FAILED);
6224 + HalDev->OsFunc->Memset(AllRcb, 0, SizeMalloc);
6226 + /* keep this address for freeing later */
6227 + HalDev->RcbStart[Ch] = AllRcb;
6231 + /* if the memory has already been allocated, simply reuse it! */
6232 + AllRcb = HalDev->RcbStart[Ch];
6235 + /* align to cache line */
6236 + AllRcb = (char *)(((bit32u)AllRcb + 0xf)&~0xf); /*PITS #143 MJH~030522*/
6238 + HalDev->RcbPool[Ch]=0;
6239 + for(i=0;i<Num;i++)
6241 + pRcb = (HAL_RCB *)(AllRcb + (i*rcbSize));
6243 + if (DoMalloc == 1)
6246 + MallocSize = Size; /*~3.01 */
6247 + pBuf= (char *) HalDev->OsFunc->MallocRxBuffer(MallocSize,0,0xF,HalDev->ChData[Ch].OsSetup, (void *)pRcb, (void *)&pRcb->OsInfo, (void *) HalDev->OsDev);
6250 + return(EC_CPPI|EC_FUNC_HAL_INIT|EC_VAL_RX_BUFFER_MALLOC_FAILED);
6252 + /* -RC3.01 pBuf = (char *)(((bit32u)pBuf+0xF) & ~0xF); */
6253 + pRcb->BufPtr=VirtToPhys(pBuf) - HalDev->offset;
6254 + pRcb->DatPtr=pBuf;
6256 + pRcb->mode=(1<<8)|Ch; /* One Frag for Ch */
6257 + pRcb->Next=(void *)HalDev->RcbPool[Ch];
6258 + pRcb->Off_BLen=(bit32u)HalDev;
6259 + HalDev->RcbPool[Ch]=pRcb;
6262 + /* Give all of the Rx buffers to hardware */
6264 + while(HalDev->RcbPool[Ch])
6266 + pRcb=HalDev->RcbPool[Ch];
6267 + HalDev->RcbPool[Ch]=pRcb->Next;
6268 + pRcb->Eop=(void*)pRcb;
6269 + pRcb->mode=(1<<8)|Ch;
6270 + halRxReturn((HAL_RECEIVEINFO *)pRcb, 0);
6273 + return(EC_NO_ERRORS);
6277 + * @ingroup CPHAL_Functions
6278 + * This function transmits the data in FragList using available transmit
6279 + * buffer descriptors. More information on the use of the Mode parameter
6280 + * is available in the module-specific appendices. Note: The OS should
6281 + * not call Send() for a channel that has been requested to be torndown.
6283 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
6284 + * @param FragList Fragment List structure.
6285 + * @param FragCount Number of fragments in FragList.
6286 + * @param PacketSize Number of bytes to transmit.
6287 + * @param OsSendInfo OS Send Information structure. <BR>
6288 + * @param Mode 32-bit value with the following bit fields: <BR>
6289 + * 31-16: Mode (used for module specific data). <BR>
6290 + * 15-08: Queue (transmit queue to send on). <BR>
6291 + * 07-00: Channel (channel number to send on).
6293 + * @return EC_NO_ERRORS (ok). <BR>
6294 + * Possible Error Codes:<BR>
6295 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
6296 + * @ref EC_VAL_NOT_LINKED "EC_VAL_NOT_LINKED"<BR>
6297 + * @ref EC_VAL_INVALID_CH "EC_VAL_INVALID_CH"<BR>
6298 + * @ref EC_VAL_OUT_OF_TCBS "EC_VAL_OUT_OF_TCBS"<BR>
6299 + * @ref EC_VAL_NO_TCBS "EC_VAL_NO_TCBS"<BR>
6301 +static int halSend(HAL_DEVICE *HalDev,FRAGLIST *FragList,
6302 + int FragCount,int PacketSize, OS_SENDINFO *OsSendInfo,
6305 + HAL_TCB *tcb_ptr, *head;
6307 + int rc = EC_NO_ERRORS;
6308 + int Ch = Mode & 0xFF;
6309 + int Queue = (Mode>>8)&0xFF;
6310 + /*int DoThresholdCheck=1; */ /* Used when TxIntDisable is set and TxInts are re-enabled */
6312 + if (HalDev->State != enOpened)
6313 + return(EC_CPPI|EC_FUNC_SEND|EC_VAL_INVALID_STATE);
6315 + if (!HalDev->Linked)
6317 + rc = EC_CPPI|EC_FUNC_SEND|EC_VAL_NOT_LINKED;
6321 + if (HalDev->ChIsOpen[Ch][DIRECTION_TX] == 0) /*MJH~030611*/ /*PITS 148*/
6322 + return(EC_CPMAC |EC_FUNC_SEND|EC_VAL_INVALID_CH); /*+GSG 030303*/
6324 + HalDev->OsFunc->CriticalOn();
6326 + /* Setup Tx mode and size */
6327 + if (PacketSize<60)
6329 + FragList[FragCount-1].len += (60 - PacketSize); /*MJH~030506*//*PITS 132*/
6330 + PacketSize = 60; /*MJH~030506*/
6332 + Mode &= CB_PASSCRC_BIT;
6334 + tcb_ptr = head = HalDev->TcbPool[Ch][Queue];
6339 + Mode|=PacketSize|CB_SOF_BIT|CB_OWNERSHIP_BIT;
6341 + for (i=0; i<FragCount; i++)
6344 + /* Setup Tx mode and size */
6345 + tcb_ptr->Off_BLen = FragList[i].len;
6347 + tcb_ptr->mode = Mode;
6348 + tcb_ptr->BufPtr = VirtToPhys((bit32 *)FragList[i].data) - HalDev->offset;
6349 + tcb_ptr->OsInfo = OsSendInfo;
6351 + if (i == (FragCount - 1))
6353 + /* last fragment */
6354 + tcb_ptr->mode |= CB_EOF_BIT;
6356 + /* since this is the last fragment, set the TcbPool pointer before
6357 + nulling out the Next pointers */
6359 + HalDev->TcbPool[Ch][Queue] = tcb_ptr->Next;
6361 + tcb_ptr->Next = 0;
6362 + tcb_ptr->HNext = 0;
6364 + /* In the Tx Interrupt handler, we will need to know which TCB is EOP,
6365 + so we can save that information in the SOP */
6366 + head->Eop = tcb_ptr;
6368 + /* Emerald fix 10/29 */
6369 + osfuncDataCacheHitWritebackAndInvalidate((void *)tcb_ptr, 16);
6374 + Mode=CB_OWNERSHIP_BIT;
6375 + tcb_ptr->HNext = VirtToPhys((bit32 *)tcb_ptr->Next) - HalDev->offset;
6377 + /* Emerald fix 10/29 */
6378 + osfuncDataCacheHitWritebackAndInvalidate((void *)tcb_ptr, 16);
6380 + tcb_ptr = tcb_ptr->Next; /* what about the end of TCB list?? */
6384 + rc = EC_CPPI|EC_FUNC_SEND|EC_VAL_OUT_OF_TCBS;
6390 + /* put it on the high priority queue */
6391 + if (HalDev->TxActQueueHead[Ch][Queue] == 0)
6393 + HalDev->TxActQueueHead[Ch][Queue]=head;
6394 + HalDev->TxActQueueTail[Ch][Queue]=tcb_ptr;
6395 +/*+GSG 030303*//*+GSG 030303*/
6396 + if (!HalDev->TxActive[Ch][Queue])
6399 + bit32u base = HalDev->dev_base;
6401 + /* write CPPI TX HDP */
6402 + (CPMAC_TX_HDP( base , Ch )) = VirtToPhys(head) - HalDev->offset;
6403 + HalDev->TxActive[Ch][Queue]=TRUE;
6409 + register volatile HAL_TCB *pTailTcb;
6410 + register bit32u tmode;
6411 + register bit32u pCurrentTcb;
6413 + HalDev->TxActQueueTail[Ch][Queue]->Next=head;
6414 + /* Emerald fix 10/29 */
6416 + pTailTcb=(HAL_TCB *)VirtToVirtNoCache(&HalDev->TxActQueueTail[Ch][Queue]->HNext);
6417 + pCurrentTcb=VirtToPhys(head) - HalDev->offset;
6418 + pTailTcb->HNext=pCurrentTcb;
6419 + HalDev->TxActQueueTail[Ch][Queue]=tcb_ptr;
6421 + tmode=pTailTcb->mode;
6422 + if (tmode&CB_EOQ_BIT)
6424 + bit32u base = HalDev->dev_base;
6426 + tmode&=~CB_EOQ_BIT;
6427 + pTailTcb->mode=tmode;
6428 + ((CPMAC_TX_HDP( base , Ch )) ) = pCurrentTcb;
6433 + if(HalDev->TxIntDisable)
6435 + /* Enable Interrupts, to ensure packet goes out on wire */
6436 + CPMAC_TX_INTMASK_SET(HalDev->dev_base) = (1<<Ch);
6437 + halPacketProcessEnd(HalDev); /* Allow Interrupt to be seen at the OS */
6438 + /*DoThresholdCheck = 0; */ /* Disable Threshold Check */
6444 + rc = EC_NO_ERRORS;
6446 + } /* if (tcb_ptr) */
6449 + rc = EC_CPPI|EC_FUNC_SEND|EC_VAL_NO_TCBS;
6454 +/* 15 June 2004 - NSP Performance Update : If Tx Ints are disabled then process them here */
6455 +/* 29 June 2004 - NSP Performance Update : Moved to end at request of BCIL */
6456 +/* 23 Aug 2004 - NSP Performance Update : If Tx Ints are re-enabled do not do Threshold check */
6458 + if(HalDev->TxIntDisable /*&& DoThresholdCheck*/)
6460 + if(--HalDev->TxIntThreshold[Ch] <= 0)
6463 + TxInt(HalDev, Ch, 0, &MoreWork);
6464 + HalDev->TxIntThreshold[Ch] = HalDev->TxIntThresholdMaster[Ch];
6467 + HalDev->OsFunc->CriticalOff();
6473 + * This function processes receive interrupts. It traverses the receive
6474 + * buffer queue, extracting the data and passing it to the upper layer software via
6475 + * osReceive(). It handles all error conditions and fragments without valid data by
6476 + * immediately returning the RCB's to the RCB pool.
6478 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
6479 + * @param Ch Channel Number.
6480 + * @param MoreWork Flag that indicates that there is more work to do when set to 1.
6482 + * @return 0 if OK, non-zero otherwise.
6484 +static int RxInt(HAL_DEVICE *HalDev, int Ch, int *MoreWork)
6486 + HAL_RCB *CurrentRcb, *SopRcb, *EofRcb, *EopRcb;
6487 + bit32u RxBufStatus,PacketsServiced, RxPktLen = 0, RxSopStatus,
6488 + FrmFrags, TotalFrags, FrmLen;
6489 + int base = HalDev->dev_base, Ret;
6490 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
6491 + int RxServiceMax = HalDev->ChData[Ch].RxServiceMax;
6492 + int FragIndex; /* +GSG 030508 */
6494 + if(HalDev->NeedsCount) /* +MJH 030410 */
6495 + NeedsCheck(HalDev); /* +MJH 030410 */
6497 + /* Handle case of teardown interrupt */
6498 + if (HalDev->RxTeardownPending[Ch] != 0)
6500 + Ret = RxTeardownInt(HalDev, Ch);
6504 + return (EC_NO_ERRORS);
6508 + /* Examine first RCB on the software active queue */
6509 + CurrentRcb=HalDev->RxActQueueHead[Ch];
6510 + osfuncDataCacheHitInvalidate((void*)CurrentRcb, 16);
6511 + RxBufStatus=CurrentRcb->mode;
6512 + PacketsServiced=0;
6514 + /* Process received packets until we find hardware owned descriptors
6515 + or until we hit RxServiceMax */
6516 + while((CurrentRcb)&&((RxBufStatus&CB_OWNERSHIP_BIT)==0)&&
6517 + (PacketsServiced<RxServiceMax)) /* ~GSG 030307 */
6520 + PacketsServiced++; /* ~GSG 030307 */
6521 + SopRcb=CurrentRcb;
6522 + RxSopStatus=RxBufStatus;
6523 + RxPktLen = RxSopStatus&CB_SIZE_MASK;
6531 +/* +GSG 030508 *//* +GSG 030508 */
6533 + /* Loop through all fragments that comprise current packet. Build
6534 + fraglist and exit when the end of the packet is reached, or the
6535 + end of the descriptor list is reached. */
6541 + DmaLen=CurrentRcb->Off_BLen;
6547 + HalDev->fraglist[FragIndex].data=((char *)CurrentRcb->DatPtr); /* ~GSG 030508 */
6549 + HalDev->fraglist[FragIndex].len=DmaLen; /* ~GSG 030508 */
6552 + HalDev->fraglist[FragIndex].OsInfo = CurrentRcb->OsInfo; /* ~GSG 030508 */
6554 + /* Upper layer must do the data invalidate */
6557 + FragIndex++; /* ~GSG 030508 */
6558 + if (FrmLen>=RxPktLen)
6559 + EofRcb=CurrentRcb;
6561 + EopRcb=CurrentRcb;
6562 + CurrentRcb=EopRcb->Next;
6565 + osfuncDataCacheHitInvalidate((void*)CurrentRcb,16);
6567 + }while(((EopRcb->mode&CB_EOF_BIT)==0)&&(CurrentRcb));
6569 + /* Write the completion pointer for interrupt acknowledgement*/
6570 + (CPMAC_RX_INT_ACK( base , Ch )) = VirtToPhys(EopRcb) - HalDev->offset;
6574 + if (CurrentRcb == 0)
6576 + /* If we are out of RCB's we must not send this packet
6578 + int RcbSize = HalDev->ChData[Ch].RxBufSize;
6582 + EopRcb->Off_BLen=RcbSize;
6583 + EopRcb->mode=CB_OWNERSHIP_BIT;
6584 + osfuncDataCacheHitWritebackAndInvalidate((void *)EopRcb, 16);
6587 + SopRcb->Off_BLen=RcbSize;
6588 + SopRcb->mode=CB_OWNERSHIP_BIT;
6589 + osfuncDataCacheHitWritebackAndInvalidate((void *)SopRcb, 16);
6591 + ((CPMAC_RX_HDP( base , Ch )) ) = VirtToPhys(SopRcb);
6595 + /* Dequeue packet and send to OS */
6598 + /* setup SopRcb for the packet */
6599 + SopRcb->Eop=(void*)EopRcb;
6601 + /* dequeue packet */
6602 + HalDev->RxActQueueHead[Ch]=CurrentRcb;
6604 + if (EopRcb->mode&CB_EOQ_BIT)
6606 + /* Next pointer is non-null and EOQ bit is set, which
6607 + indicates misqueue packet in CPPI protocol. */
6609 + ((CPMAC_RX_HDP( base , Ch )) ) = EopRcb->HNext;
6612 + mode = (SopRcb->mode & 0xFFFF0000) | Ch;
6614 + SopRcb->mode=(FrmFrags<<8)|Ch;
6615 + SopRcb->Off_BLen=(bit32u)HalDev;
6617 + /* send packet up the higher layer driver */
6618 + OsFunc->Receive(HalDev->OsDev,HalDev->fraglist,FragIndex,RxPktLen, /* ~GSG 030508 */
6619 + (HAL_RECEIVEINFO *)SopRcb,mode);
6621 + RxBufStatus=CurrentRcb->mode;
6623 + } /* while loop */
6625 + if ((CurrentRcb)&&((RxBufStatus&CB_OWNERSHIP_BIT)==0)) /*~GSG 030307*/
6634 + return (EC_NO_ERRORS);
6638 + * This function processes transmit interrupts. It traverses the
6639 + * transmit buffer queue, detecting sent data buffers and notifying the upper
6640 + * layer software via osSendComplete(). (for SAR, i originally had this split
6641 + * into two functions, one for each queue, but joined them on 8/8/02)
6643 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
6644 + * @param Queue Queue number to service (always 0 for MAC, Choose 1 for SAR to service low priority queue)
6645 + * @param MoreWork Flag that indicates that there is more work to do when set to 1.
6647 + * @return 0 if OK, non-zero otherwise.
6649 +int TxInt(HAL_DEVICE *HalDev, int Ch, int Queue, int *MoreWork)
6651 + HAL_TCB *CurrentTcb,*LastTcbProcessed,*FirstTcbProcessed;
6652 + int PacketsServiced;
6653 + bit32u TxFrameStatus;
6655 + int TxServiceMax = HalDev->ChData[Ch].TxServiceMax;
6656 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
6658 +/*+GSG 030303*//*+GSG 030303*/
6660 + /* load the module base address */
6661 + base = HalDev->dev_base;
6663 + /* Handle case of teardown interrupt. This must be checked at
6664 + the top of the function rather than the bottom, because
6665 + the normal data processing can wipe out the completion
6666 + pointer which is used to determine teardown complete. */
6667 + if (HalDev->TxTeardownPending[Ch] != 0)
6671 + Ret = TxTeardownInt(HalDev, Ch, Queue);
6674 + *MoreWork = 0; /* bug fix 1/6 */ /*+GSG 030303*/
6675 + return (EC_NO_ERRORS);
6679 + OsFunc->CriticalOn(); /* 240904 */
6681 + CurrentTcb = HalDev->TxActQueueHead[Ch][Queue];
6682 + FirstTcbProcessed=CurrentTcb;
6684 + if (CurrentTcb==0)
6686 + /* I saw this error a couple of times when multi-channels were added */
6687 + dbgPrintf("[cppi TxInt()]TxH int with no TCB in queue!\n");
6688 + dbgPrintf(" Ch=%d, CurrentTcb = 0x%08x\n", Ch, (bit32u)CurrentTcb);
6689 + dbgPrintf(" HalDev = 0x%08x\n", (bit32u)HalDev);
6691 + OsFunc->CriticalOff();
6692 + return(EC_CPPI|EC_FUNC_TXINT|EC_VAL_NULL_TCB);
6695 + osfuncDataCacheHitInvalidate((void *)CurrentTcb, 16);
6696 + TxFrameStatus=CurrentTcb->mode;
6697 + PacketsServiced=0;
6699 + /* should the ownership bit check be inside of the loop?? could make it a
6700 + while-do loop and take this check away */
6701 + if ((TxFrameStatus&CB_OWNERSHIP_BIT)==0)
6705 + /* Pop TCB(s) for packet from the stack */
6706 + LastTcbProcessed=CurrentTcb->Eop;
6708 + /* new location for acknowledge */
6709 + /* Write the completion pointer */
6710 + (CPMAC_TX_INT_ACK( base , Ch )) = VirtToPhys(LastTcbProcessed) - HalDev->offset;
6712 + HalDev->TxActQueueHead[Ch][Queue] = LastTcbProcessed->Next;
6714 +/*+GSG 030303*//*+GSG 030303*/
6716 + osfuncDataCacheHitInvalidate((void *)LastTcbProcessed, 16);
6718 + if (LastTcbProcessed->mode&CB_EOQ_BIT)
6720 + if (LastTcbProcessed->Next)
6722 + /* Misqueued packet */
6724 + (CPMAC_TX_HDP( base , Ch )) = LastTcbProcessed->HNext;
6729 + /* Tx End of Queue */
6731 + HalDev->TxActive[Ch][Queue]=FALSE;
6735 + OsFunc->SendComplete(CurrentTcb->OsInfo);
6737 + /* Push Tcb(s) back onto the stack */
6738 + CurrentTcb = LastTcbProcessed->Next;
6740 + LastTcbProcessed->Next=HalDev->TcbPool[Ch][Queue];
6742 + HalDev->TcbPool[Ch][Queue]=FirstTcbProcessed;
6744 + PacketsServiced++;
6746 + TxFrameStatus=CB_OWNERSHIP_BIT;
6747 + /* set the first(SOP) pointer for the next packet */
6748 + FirstTcbProcessed = CurrentTcb;
6751 + osfuncDataCacheHitInvalidate((void *)CurrentTcb, 16);
6752 + TxFrameStatus=CurrentTcb->mode;
6755 + }while(((TxFrameStatus&CB_OWNERSHIP_BIT)==0)
6756 + &&(PacketsServiced<TxServiceMax));
6758 + if (((TxFrameStatus&CB_OWNERSHIP_BIT)==0)
6759 + &&(PacketsServiced==TxServiceMax))
6768 + OsFunc->CriticalOff();
6770 + return(EC_NO_ERRORS);
6774 + * @ingroup CPHAL_Functions
6775 + * This function performs a teardown for the given channel. The value of the
6776 + * Mode parameter controls the operation of the function, as documented below.
6778 + * Note: If bit 3 of Mode is set, this call is blocking, and will not return
6779 + * until the teardown interrupt has occurred and been processed. While waiting
6780 + * for a blocking teardown to complete, ChannelTeardown() will signal the OS
6781 + * (via Control(.."Sleep"..)) to allow the OS to perform other tasks if
6782 + * necessary. If and only if bit 3 of Mode is clear, the CPHAL will call the
6783 + * OS TeardownComplete() function to indicate that the teardown has completed.
6785 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
6786 + * @param Ch Channel number.
6787 + * @param Mode Bit 0 (LSB): Perform Tx teardown (if set).<BR>
6788 + * Bit 1: Perform Rx teardown (if set). <BR>
6789 + * Bit 2: If set, perform full teardown (free buffers/descriptors).
6790 + * If clear, perform partial teardown (keep buffers). <BR>
6791 + * Bit 3 (MSB): If set, call is blocking.
6792 + * If clear, call is non-blocking.
6794 + * @return EC_NO_ERRORS (ok). <BR>
6795 + * Possible Error Codes:<BR>
6796 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
6797 + * @ref EC_VAL_INVALID_CH "EC_VAL_INVALID_CH"<BR>
6798 + * @ref EC_VAL_TX_TEARDOWN_ALREADY_PEND "EC_VAL_TX_TEARDOWN_ALREADY_PEND"<BR>
6799 + * @ref EC_VAL_RX_TEARDOWN_ALREADY_PEND "EC_VAL_RX_TEARDOWN_ALREADY_PEND"<BR>
6800 + * @ref EC_VAL_TX_CH_ALREADY_TORNDOWN "EC_VAL_TX_CH_ALREADY_TORNDOWN"<BR>
6801 + * @ref EC_VAL_RX_CH_ALREADY_TORNDOWN "EC_VAL_RX_CH_ALREADY_TORNDOWN"<BR>
6802 + * @ref EC_VAL_TX_TEARDOWN_TIMEOUT "EC_VAL_TX_TEARDOWN_TIMEOUT"<BR>
6803 + * @ref EC_VAL_RX_TEARDOWN_TIMEOUT "EC_VAL_RX_TEARDOWN_TIMEOUT"<BR>
6804 + * @ref EC_VAL_LUT_NOT_READY "EC_VAL_LUT_NOT_READY"<BR>
6806 +static int halChannelTeardown(HAL_DEVICE *HalDev, int Ch, bit32 Mode)
6808 + int DoTx, DoRx, Sleep=2048, timeout=0; /*MJH~030306*/
6809 + bit32u base = HalDev->dev_base;
6811 +/* Set the module, used for error returns */
6813 + DoTx = (Mode & TX_TEARDOWN);
6814 + DoRx = (Mode & RX_TEARDOWN);
6816 + if (HalDev->State < enInitialized)
6817 + return(EC_CPMAC |EC_FUNC_CHTEARDOWN|EC_VAL_INVALID_STATE);
6819 + if ((Ch < 0) || (Ch > (MAX_CHAN-1) ))
6821 + return(EC_CPMAC |EC_FUNC_CHTEARDOWN|EC_VAL_INVALID_CH);
6824 + /* set teardown pending bits before performing the teardown, because they
6825 + will be used in the int handler (this is done for AAL5) */
6828 + if (HalDev->TxTeardownPending[Ch] != 0)
6829 + return(EC_CPMAC |EC_FUNC_CHTEARDOWN|EC_VAL_TX_TEARDOWN_ALREADY_PEND);
6831 + /* If a full teardown, this also means that the user must
6832 + setup all channels again to use them */
6833 + if (Mode & FULL_TEARDOWN)
6834 + HalDev->ChIsSetup[Ch][DIRECTION_TX] = 0;
6836 + if (HalDev->State < enOpened)
6838 + /* if the hardware has never been opened, the channel has never actually
6839 + been setup in the hardware, so I just need to reset the software flag
6841 + HalDev->ChIsSetup[Ch][DIRECTION_TX] = 0;
6842 + return (EC_NO_ERRORS);
6846 + if (HalDev->ChIsOpen[Ch][DIRECTION_TX] == 0)
6848 + return(EC_CPMAC |EC_FUNC_CHTEARDOWN|EC_VAL_TX_CH_ALREADY_TORNDOWN);
6851 + /* set teardown flag */
6852 + HalDev->TxTeardownPending[Ch] = Mode;
6858 + if (HalDev->RxTeardownPending[Ch] != 0)
6859 + return(EC_CPMAC |EC_FUNC_CHTEARDOWN|EC_VAL_RX_TEARDOWN_ALREADY_PEND);
6861 + if (Mode & FULL_TEARDOWN)
6862 + HalDev->ChIsSetup[Ch][DIRECTION_RX] = 0;
6864 + if (HalDev->State < enOpened)
6866 + HalDev->ChIsSetup[Ch][DIRECTION_RX] = 0;
6867 + return (EC_NO_ERRORS);
6871 + if (HalDev->ChIsOpen[Ch][DIRECTION_RX] == 0)
6872 + return(EC_CPMAC |EC_FUNC_CHTEARDOWN|EC_VAL_RX_CH_ALREADY_TORNDOWN);
6874 + HalDev->RxTeardownPending[Ch] = Mode;
6878 + /* Perform Tx Teardown Duties */
6879 + if ((DoTx) && (HalDev->State == enOpened))
6881 + /* Request TX channel teardown */
6882 + (CPMAC_TX_TEARDOWN( base )) = Ch;
6884 + /* wait until teardown has completed */
6885 + if (Mode & BLOCKING_TEARDOWN)
6888 + while (HalDev->ChIsOpen[Ch][DIRECTION_TX] == TRUE)
6890 + osfuncSleep(&Sleep);
6893 + if (timeout > 100000)
6895 + return(EC_CPMAC |EC_FUNC_CHTEARDOWN|EC_VAL_TX_TEARDOWN_TIMEOUT);
6901 + /* Perform Rx Teardown Duties */
6902 + if ((DoRx) && (HalDev->State == enOpened))
6905 + /* perform CPMAC specific RX channel teardown */
6906 + CPMAC_RX_TEARDOWN(base) = Ch;
6908 + if (Mode & BLOCKING_TEARDOWN)
6911 + while (HalDev->ChIsOpen[Ch][DIRECTION_RX] == TRUE)
6913 + osfuncSleep(&Sleep);
6916 + if (timeout > 100000)
6918 + return(EC_CPMAC |EC_FUNC_CHTEARDOWN|EC_VAL_RX_TEARDOWN_TIMEOUT);
6924 + return (EC_NO_ERRORS);
6928 + * @ingroup CPHAL_Functions
6929 + * This function closes the CPHAL module. The module will be reset.
6930 + * The Mode parameter should be used to determine the actions taken by
6933 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
6934 + * @param Mode Indicates actions to take on close. The following integer
6935 + * values are valid: <BR>
6936 + * 1: Does not free buffer resources, init parameters remain
6937 + * intact. User can then call Open() without calling Init()
6938 + * to attempt to reset the device and bring it back to the
6939 + * last known state.<BR>
6940 + * 2: Frees the buffer resources, but keeps init parameters. This
6941 + * option is a more aggressive means of attempting a device reset.
6942 + * 3: Frees the buffer resources, and clears all init parameters. <BR>
6943 + * At this point, the caller would have to call to completely
6944 + * reinitialize the device (Init()) before being able to call
6945 + * Open(). Use this mode if you are shutting down the module
6946 + * and do not plan to restart.
6948 + * @return EC_NO_ERRORS (ok).<BR>
6949 + * Possible Error Codes:<BR>
6950 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
6951 + * Any error code from halChannelTeardown().<BR>
6953 +static int halClose(HAL_DEVICE *HalDev, bit32 Mode)
6955 + int Ch, Inst, Ret;
6956 + OS_DEVICE *TmpOsDev;
6957 + OS_FUNCTIONS *TmpOsFunc;
6958 + HAL_FUNCTIONS *TmpHalFunc;
6959 + char *TmpDeviceInfo;
6961 + int Ticks; /*MJH~030306*/
6963 + /* Verify proper device state */
6964 + if (HalDev->State != enOpened)
6965 + return (EC_CPMAC | EC_FUNC_CLOSE|EC_VAL_INVALID_STATE);
6967 + /* Teardown all open channels */
6968 + for (Ch = 0; Ch <= (MAX_CHAN-1) ; Ch++)
6970 + if (HalDev->ChIsOpen[Ch][DIRECTION_TX] == TRUE)
6974 + Ret = halChannelTeardown(HalDev, Ch, TX_TEARDOWN | PARTIAL_TEARDOWN | BLOCKING_TEARDOWN);
6975 + if (Ret) return (Ret);
6979 + Ret = halChannelTeardown(HalDev, Ch, TX_TEARDOWN | FULL_TEARDOWN | BLOCKING_TEARDOWN);
6980 + if (Ret) return (Ret);
6984 + if (HalDev->ChIsOpen[Ch][DIRECTION_RX] == TRUE)
6988 + Ret = halChannelTeardown(HalDev, Ch, RX_TEARDOWN | PARTIAL_TEARDOWN | BLOCKING_TEARDOWN);
6989 + if (Ret) return (Ret);
6993 + Ret = halChannelTeardown(HalDev, Ch, RX_TEARDOWN | FULL_TEARDOWN | BLOCKING_TEARDOWN);
6994 + if (Ret) return (Ret);
6999 + /* free fraglist in HalDev */
7000 + HalDev->OsFunc->Free(HalDev->fraglist);
7001 + HalDev->fraglist = 0;
7003 + /* unregister the interrupt */
7004 + HalDev->OsFunc->IsrUnRegister(HalDev->OsDev, HalDev->interrupt);
7006 + Ticks = 0; /* Disable Tick Timer */ /*MJH+030306*/
7007 + HalDev->OsFunc->Control(HalDev->OsDev, hcTick, hcClear, &Ticks); /*MJH+030306*/
7009 + /* Free the Phy Information Structure */
7010 + if(HalDev->PhyDev)
7012 + HalDev->OsFunc->Free(HalDev->PhyDev); /*MJH+030513*/
7013 + HalDev->PhyDev = 0; /*MJH+030522*/
7016 + /* Perform CPMAC specific closing functions */
7017 + CPMAC_MACCONTROL(HalDev->dev_base) &= ~MII_EN;
7018 + CPMAC_TX_CONTROL(HalDev->dev_base) &= ~TX_EN;
7019 + CPMAC_RX_CONTROL(HalDev->dev_base) &= ~RX_EN;
7021 + /* put device back into reset */
7022 + (*(volatile bit32u *)(HalDev->ResetBase)) &=~ (1<<HalDev->ResetBit);
7023 + Ticks = 64; /*MJH~030306*/
7024 + osfuncSleep(&Ticks);
7026 + /* If mode is 3, than clear the HalDev and set next state to DevFound*/
7029 + /* I need to keep the HalDev parameters that were setup in InitModule */
7030 + TmpOsDev = HalDev->OsDev;
7031 + TmpOsFunc = HalDev->OsFunc;
7032 + TmpDeviceInfo = HalDev->DeviceInfo;
7034 + TmpHalFunc = HalDev->HalFuncPtr;
7035 + Inst = HalDev->Inst;
7037 + /* Clear HalDev */
7039 + HalDev->OsFunc->Memset(HalDev, 0, sizeof(HAL_DEVICE));
7041 + /* Restore key parameters */
7042 + HalDev->OsDev = TmpOsDev;
7043 + HalDev->OsFunc = TmpOsFunc;
7044 + HalDev->DeviceInfo = TmpDeviceInfo;
7046 + HalDev->HalFuncPtr = TmpHalFunc;
7047 + HalDev->Inst = Inst;
7049 + HalDev->State = enDevFound;
7053 + HalDev->State = enInitialized;
7056 + return(EC_NO_ERRORS);
7058 diff -urN linux.old/drivers/net/avalanche_cpmac/cpremap_cpmac.c linux.dev/drivers/net/avalanche_cpmac/cpremap_cpmac.c
7059 --- linux.old/drivers/net/avalanche_cpmac/cpremap_cpmac.c 1970-01-01 01:00:00.000000000 +0100
7060 +++ linux.dev/drivers/net/avalanche_cpmac/cpremap_cpmac.c 2005-07-12 02:48:42.049593000 +0200
7062 +#ifndef _INC_CPREMAP_C
7063 +#define _INC_CPREMAP_C
7066 +static inline void osfuncDataCacheHitInvalidate(void *ptr, int Size)
7068 + asm(" cache 17, (%0)" : : "r" (ptr));
7071 +static inline void osfuncDataCacheHitWriteback(void *ptr, int Size)
7073 + asm(" cache 25, (%0)" : : "r" (ptr));
7076 +static inline void osfuncDataCacheHitWritebackAndInvalidate(void *ptr, int Size)
7078 + asm(" cache 21, (%0)" : : "r" (ptr));
7083 +#define osfuncDataCacheHitInvalidate(MemPtr, Size) __asm__(" .set mips3; cache 17, (%0); .set mips0" : : "r" (MemPtr))
7084 +#define osfuncDataCacheHitWritebackAndInvalidate(MemPtr, Size) __asm__(" .set mips3; cache 21, (%0); .set mips0" : : "r" (MemPtr))
7085 +#define osfuncDataCacheHitWriteback(MemPtr, Size) __asm__(" .set mips3; cache 25, (%0); .set mips0" : : "r" (MemPtr))
7090 diff -urN linux.old/drivers/net/avalanche_cpmac/cpswhal_cpmac.h linux.dev/drivers/net/avalanche_cpmac/cpswhal_cpmac.h
7091 --- linux.old/drivers/net/avalanche_cpmac/cpswhal_cpmac.h 1970-01-01 01:00:00.000000000 +0100
7092 +++ linux.dev/drivers/net/avalanche_cpmac/cpswhal_cpmac.h 2005-07-12 02:48:42.050593000 +0200
7094 +/************************************************************************
7095 + * TNETDxxxx Software Support
7096 + * Copyright (c) 2002 Texas Instruments Incorporated. All Rights Reserved.
7101 + * User include file, contains data definitions shared between the CPHAL
7102 + * and the upper-layer software.
7105 + * Date Modifier Ver Notes
7106 + * 28Feb02 Greg 1.00 Original
7107 + * 06Mar02 Greg 1.01 Documentation enhanced
7108 + * 18Jul02 Greg 1.02 Many updates (OAM additions, general reorg)
7109 + * 22Nov02 Mick RC2 Additions from Denis' input on Control
7111 + * author Greg Guyotte
7113 + * date 18-Jul-2002
7114 + *****************************************************************************/
7115 +#ifndef _INC_CPHAL_H
7116 +#define _INC_CPHAL_H
7118 +#ifdef _CPHAL_CPMAC
7119 +#include "ec_errors_cpmac.h"
7123 +#include "ec_errors_cpaal5.h"
7126 +#ifdef _CPHAL_CPSAR
7127 +#include "ec_errors_cpsar.h"
7131 +#include "ec_errors_cpaal2.h"
7136 +typedef short bit16;
7139 +typedef unsigned char bit8u;
7140 +typedef unsigned short bit16u;
7141 +typedef unsigned int bit32u;
7145 +typedef short INT16;
7147 +typedef unsigned char UINT8;
7148 +typedef unsigned short UINT16;
7149 +typedef unsigned int UINT32;
7151 +/*typedef unsigned int size_t;*/
7157 +#define TRUE (1==1)
7161 +#define FALSE (1==2)
7170 +#define VirtToPhys(a) (((int)a)&~0xe0000000)
7171 +#define VirtToVirtNoCache(a) ((void*)((VirtToPhys(a))|0xa0000000))
7172 +#define VirtToVirtCache(a) ((void*)((VirtToPhys(a))|0x80000000))
7173 +#define PhysToVirtNoCache(a) ((void*)(((int)a)|0xa0000000))
7174 +#define PhysToVirtCache(a) ((void*)(((int)a)|0x80000000))
7176 +#define DataCacheHitInvalidate(a) {__asm__(" cache 17, (%0)" : : "r" (a));}
7177 +#define DataCacheHitWriteback(a) {__asm__(" cache 25, (%0)" : : "r" (a));}
7180 +#define PARTIAL 1 /**< Used in @c Close() and @c ChannelTeardown() */
7181 +#define FULL 2 /**< Used in @c Close() and @c ChannelTeardown() */
7183 +/* Channel Teardown Defines */
7184 +#define RX_TEARDOWN 2
7185 +#define TX_TEARDOWN 1
7186 +#define BLOCKING_TEARDOWN 8
7187 +#define FULL_TEARDOWN 4
7188 +#define PARTIAL_TEARDOWN 0
7191 +#define DIRECTION_TX 0
7192 +#define DIRECTION_RX 1
7195 +#define HAL_ERROR_DEVICE_NOT_FOUND 1
7196 +#define HAL_ERROR_FAILED_MALLOC 2
7197 +#define HAL_ERROR_OSFUNC_SIZE 3
7198 +#define HAL_DEFAULT 0xFFFFFFFF
7199 +#define VALID(val) (val!=HAL_DEFAULT)
7204 +HAL Module Codes. Each HAL module reporting an error code
7205 +should OR the error code with the respective Module error code
7206 +from the list below.
7208 +#define EC_AAL5 EC_HAL|EC_DEV_AAL5
7209 +#define EC_AAL2 EC_HAL|EC_DEV_AAL2
7210 +#define EC_CPSAR EC_HAL|EC_DEV_CPSAR
7211 +#define EC_CPMAC EC_HAL|EC_DEV_CPMAC
7212 +#define EC_VDMA EC_HAL|EC_DEV_VDMA
7213 +#define EC_VLYNQ EC_HAL|EC_DEV_VLYNQ
7214 +#define EC_CPPI EC_HAL|EC_DEV_CPPI
7217 +HAL Function Codes. Each HAL module reporting an error code
7218 +should OR the error code with one of the function codes from
7221 +#define EC_FUNC_HAL_INIT EC_FUNC(1)
7222 +#define EC_FUNC_CHSETUP EC_FUNC(2)
7223 +#define EC_FUNC_CHTEARDOWN EC_FUNC(3)
7224 +#define EC_FUNC_RXRETURN EC_FUNC(4)
7225 +#define EC_FUNC_SEND EC_FUNC(5)
7226 +#define EC_FUNC_RXINT EC_FUNC(6)
7227 +#define EC_FUNC_TXINT EC_FUNC(7)
7228 +#define EC_FUNC_AAL2_VDMA EC_FUNC(8)
7229 +#define EC_FUNC_OPTIONS EC_FUNC(9)
7230 +#define EC_FUNC_PROBE EC_FUNC(10)
7231 +#define EC_FUNC_OPEN EC_FUNC(11)
7232 +#define EC_FUNC_CONTROL EC_FUNC(12)
7233 +#define EC_FUNC_DEVICE_INT EC_FUNC(13)
7234 +#define EC_FUNC_STATUS EC_FUNC(14)
7235 +#define EC_FUNC_TICK EC_FUNC(15)
7236 +#define EC_FUNC_CLOSE EC_FUNC(16)
7237 +#define EC_FUNC_SHUTDOWN EC_FUNC(17)
7238 +#define EC_FUNC_DEVICE_INT_ALT EC_FUNC(18) /* +GSG 030306 */
7241 +HAL Error Codes. The list below defines every type of error
7242 +used in all HAL modules. DO NOT CHANGE THESE VALUES! Add new
7243 +values in integer order to the bottom of the list.
7245 +#define EC_VAL_PDSP_LOAD_FAIL EC_ERR(0x01)|EC_CRITICAL
7246 +#define EC_VAL_FIRMWARE_TOO_LARGE EC_ERR(0x02)|EC_CRITICAL
7247 +#define EC_VAL_DEVICE_NOT_FOUND EC_ERR(0x03)|EC_CRITICAL
7248 +#define EC_VAL_BASE_ADDR_NOT_FOUND EC_ERR(0x04)|EC_CRITICAL
7249 +#define EC_VAL_RESET_BIT_NOT_FOUND EC_ERR(0x05)|EC_CRITICAL
7250 +#define EC_VAL_CH_INFO_NOT_FOUND EC_ERR(0x06)
7251 +#define EC_VAL_RX_STATE_RAM_NOT_CLEARED EC_ERR(0x07)|EC_CRITICAL
7252 +#define EC_VAL_TX_STATE_RAM_NOT_CLEARED EC_ERR(0x08)|EC_CRITICAL
7253 +#define EC_VAL_MALLOC_DEV_FAILED EC_ERR(0x09)
7254 +#define EC_VAL_OS_VERSION_NOT_SUPPORTED EC_ERR(0x0A)|EC_CRITICAL
7255 +#define EC_VAL_CPSAR_VERSION_NOT_SUPPORTED EC_ERR(0x0B)|EC_CRITICAL
7256 +#define EC_VAL_NULL_CPSAR_DEV EC_ERR(0x0C)|EC_CRITICAL
7258 +#define EC_VAL_LUT_NOT_READY EC_ERR(0x0D)
7259 +#define EC_VAL_INVALID_CH EC_ERR(0x0E)
7260 +#define EC_VAL_NULL_CH_STRUCT EC_ERR(0x0F)
7261 +#define EC_VAL_RX_TEARDOWN_ALREADY_PEND EC_ERR(0x10)
7262 +#define EC_VAL_TX_TEARDOWN_ALREADY_PEND EC_ERR(0x11)
7263 +#define EC_VAL_RX_CH_ALREADY_TORNDOWN EC_ERR(0x12)
7264 +#define EC_VAL_TX_CH_ALREADY_TORNDOWN EC_ERR(0x13)
7265 +#define EC_VAL_TX_TEARDOWN_TIMEOUT EC_ERR(0x14)
7266 +#define EC_VAL_RX_TEARDOWN_TIMEOUT EC_ERR(0x15)
7267 +#define EC_VAL_CH_ALREADY_TORNDOWN EC_ERR(0x16)
7268 +#define EC_VAL_VC_SETUP_NOT_READY EC_ERR(0x17)
7269 +#define EC_VAL_VC_TEARDOWN_NOT_READY EC_ERR(0x18)
7270 +#define EC_VAL_INVALID_VC EC_ERR(0x19)
7271 +#define EC_VAL_INVALID_LC EC_ERR(0x20)
7272 +#define EC_VAL_INVALID_VDMA_CH EC_ERR(0x21)
7273 +#define EC_VAL_INVALID_CID EC_ERR(0x22)
7274 +#define EC_VAL_INVALID_UUI EC_ERR(0x23)
7275 +#define EC_VAL_INVALID_UUI_DISCARD EC_ERR(0x24)
7276 +#define EC_VAL_CH_ALREADY_OPEN EC_ERR(0x25)
7278 +#define EC_VAL_RCB_MALLOC_FAILED EC_ERR(0x26)
7279 +#define EC_VAL_RX_BUFFER_MALLOC_FAILED EC_ERR(0x27)
7280 +#define EC_VAL_OUT_OF_TCBS EC_ERR(0x28)
7281 +#define EC_VAL_NO_TCBS EC_ERR(0x29)
7282 +#define EC_VAL_NULL_RCB EC_ERR(0x30)|EC_CRITICAL
7283 +#define EC_VAL_SOP_ERROR EC_ERR(0x31)|EC_CRITICAL
7284 +#define EC_VAL_EOP_ERROR EC_ERR(0x32)|EC_CRITICAL
7285 +#define EC_VAL_NULL_TCB EC_ERR(0x33)|EC_CRITICAL
7286 +#define EC_VAL_CORRUPT_RCB_CHAIN EC_ERR(0x34)|EC_CRITICAL
7287 +#define EC_VAL_TCB_MALLOC_FAILED EC_ERR(0x35)
7289 +#define EC_VAL_DISABLE_POLLING_FAILED EC_ERR(0x36)
7290 +#define EC_VAL_KEY_NOT_FOUND EC_ERR(0x37)
7291 +#define EC_VAL_MALLOC_FAILED EC_ERR(0x38)
7292 +#define EC_VAL_RESET_BASE_NOT_FOUND EC_ERR(0x39)|EC_CRITICAL
7293 +#define EC_VAL_INVALID_STATE EC_ERR(0x40)
7294 +#define EC_VAL_NO_TXH_WORK_TO_DO EC_ERR(0x41)
7295 +#define EC_VAL_NO_TXL_WORK_TO_DO EC_ERR(0x42)
7296 +#define EC_VAL_NO_RX_WORK_TO_DO EC_ERR(0x43)
7297 +#define EC_VAL_NOT_LINKED EC_ERR(0x44)
7298 +#define EC_VAL_INTERRUPT_NOT_FOUND EC_ERR(0x45)
7299 +#define EC_VAL_OFFSET_NOT_FOUND EC_ERR(0x46)
7300 +#define EC_VAL_MODULE_ALREADY_CLOSED EC_ERR(0x47)
7301 +#define EC_VAL_MODULE_ALREADY_SHUTDOWN EC_ERR(0x48)
7302 +#define EC_VAL_ACTION_NOT_FOUND EC_ERR(0x49)
7303 +#define EC_VAL_RX_CH_ALREADY_SETUP EC_ERR(0x50)
7304 +#define EC_VAL_TX_CH_ALREADY_SETUP EC_ERR(0x51)
7305 +#define EC_VAL_RX_CH_ALREADY_OPEN EC_ERR(0x52)
7306 +#define EC_VAL_TX_CH_ALREADY_OPEN EC_ERR(0x53)
7307 +#define EC_VAL_CH_ALREADY_SETUP EC_ERR(0x54)
7308 +#define EC_VAL_RCB_NEEDS_BUFFER EC_ERR(0x55) /* +GSG 030410 */
7309 +#define EC_VAL_RCB_DROPPED EC_ERR(0x56) /* +GSG 030410 */
7310 +#define EC_VAL_INVALID_VALUE EC_ERR(0x57)
7313 +@defgroup shared_data Shared Data Structures
7315 +The data structures documented here are shared by all modules.
7319 + * @ingroup shared_data
7320 + * This is the fragment list structure. Each fragment list entry contains a
7321 + * length and a data buffer.
7325 + bit32u len; /**< Length of the fragment in bytes (lower 16 bits are valid). For SOP, upper 16 bits is the buffer offset. */
7326 + void *data; /**< Pointer to fragment data. */
7327 + void *OsInfo; /**< Pointer to OS defined data. */
7330 +#if defined (_CPHAL_CPMAC)
7331 +#define CB_PASSCRC_BIT (1<<26)
7333 +/* CPMAC CPHAL STATUS */
7334 +#define CPMAC_STATUS_LINK (1 << 0)
7335 +#define CPMAC_STATUS_LINK_DUPLEX (1 << 1) /* 0 - HD, 1 - FD */
7336 +#define CPMAC_STATUS_LINK_SPEED (1 << 2) /* 0 - 10, 1 - 100 */
7338 +/* ADAPTER CHECK Codes */
7340 +#define CPMAC_STATUS_ADAPTER_CHECK (1 << 7)
7341 +#define CPMAC_STATUS_HOST_ERR_DIRECTION (1 << 8)
7342 +#define CPMAC_STATUS_HOST_ERR_CODE (0xF << 9)
7343 +#define CPMAC_STATUS_HOST_ERR_CH (0x7 << 13)
7345 +#define _CPMDIO_DISABLE (1 << 0)
7346 +#define _CPMDIO_HD (1 << 1)
7347 +#define _CPMDIO_FD (1 << 2)
7348 +#define _CPMDIO_10 (1 << 3)
7349 +#define _CPMDIO_100 (1 << 4)
7350 +#define _CPMDIO_NEG_OFF (1 << 5)
7351 +#define _CPMDIO_LOOPBK (1 << 16)
7352 +#define _CPMDIO_AUTOMDIX (1 << 17) /* Bit 16 and above not used by MII register */
7353 +#define _CPMDIO_NOPHY (1 << 20)
7357 + * @ingroup shared_data
7358 + * Channel specific configuration information. This structure should be
7359 + * populated by upper-layer software prior to calling @c ChannelSetup(). Any
7360 + * configuration item that can be changed on a per channel basis should
7361 + * be represented here. Each module may define this structure with additional
7362 + * module-specific members.
7366 + int Channel; /**< Channel number. */
7367 + int Direction; /**< DIRECTION_RX(1) or DIRECTION_TX(0). */
7368 + OS_SETUP *OsSetup; /**< OS defined information associated with this channel. */
7370 +#if defined(_CPHAL_AAL5) || defined (_CPHAL_CPSAR) || defined (_CPHAL_CPMAC)
7371 + int RxBufSize; /**< Size (in bytes) for each Rx buffer.*/
7372 + int RxBufferOffset; /**< Number of bytes to offset rx data from start of buffer (must be less than buffer size). */
7373 + int RxNumBuffers; /**< The number of Rx buffer descriptors to allocate for Ch. */
7374 + int RxServiceMax; /**< Maximum number of packets to service at one time. */
7376 + int TxNumBuffers; /**< The number of Tx buffer descriptors to allocate for Ch. */
7377 + int TxNumQueues; /**< Number of Tx queues for this channel (1-2). Choosing 2 enables a low priority SAR queue. */
7378 + int TxServiceMax; /**< Maximum number of packets to service at one time. */
7381 +#if defined(_CPHAL_AAL5) || defined(_CPHAL_CPSAR)
7382 + int CpcsUU; /**< The 2-byte CPCS UU and CPI information. */
7383 + int Gfc; /**< Generic Flow Control. */
7384 + int Clp; /**< Cell Loss Priority. */
7385 + int Pti; /**< Payload Type Indication. */
7388 +#if defined(_CPHAL_AAL2) || defined(_CPHAL_AAL5) || defined(_CPHAL_CPSAR)
7389 + int DaMask; /**< Specifies whether credit issuance is paused when Tx data not available. */
7390 + int Priority; /**< Priority bin this channel will be scheduled within. */
7391 + int PktType; /**< 0=AAL5,1=Null AAL,2=OAM,3=Transparent,4=AAL2. */
7392 + int Vci; /**< Virtual Channel Identifier. */
7393 + int Vpi; /**< Virtual Path Identifier. */
7394 + int FwdUnkVc; /**< Enables forwarding of unknown VCI/VPI cells to host. 1=enable, 0=disable. */
7397 + int TxVc_CellRate; /**< Tx rate, set as clock ticks between transmissions (SCR for VBR, CBR for CBR). */
7398 + int TxVc_QosType; /**< 0=CBR,1=VBR,2=UBR,3=UBRmcr. */
7399 + int TxVc_Mbs; /**< Min Burst Size in cells.*/
7400 + int TxVc_Pcr; /**< Peak Cell Rate for VBR in clock ticks between transmissions. */
7402 + bit32 TxVc_AtmHeader; /**< ATM Header placed on firmware gen'd OAM cells for this Tx Ch (must be big endian with 0 PTI). */
7403 + int TxVc_OamTc; /**< TC Path to transmit OAM cells for TX connection (0,1). */
7404 + int TxVc_VpOffset; /**< Offset to the OAM VP state table. */
7406 + int RxVc_OamCh; /**< Ch to terminate rx'd OAM cells to be forwarded to the host. */
7407 + int RxVc_OamToHost; /**< 0=do not pass, 1=pass. */
7408 + bit32 RxVc_AtmHeader; /**< ATM Header placed on firmware gen'd OAM cells for this Rx conn (must be big endian with 0 PTI). */
7409 + int RxVc_OamTc; /**< TC Path to transmit OAM cells for RX connection (0,1). */
7410 + int RxVc_VpOffset; /**< Offset to the OAM VP state table. */
7412 + int TxVp_OamTc; /**< TC Path to transmit OAM cells for TX VP connection (0,1). */
7413 + 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). */
7415 + int RxVp_OamCh; /**< Ch to terminate rx'd OAM cells to be forwarded to the host. */
7416 + int RxVp_OamToHost; /**< 0=do not pass, 1=pass. */
7417 + bit32 RxVp_AtmHeader; /**< ATM Header placed on firmware gen'd OAM cells for this Rx VP conn (must be big endian with 0 VCI). */
7418 + int RxVp_OamTc; /**< TC Path to transmit OAM cells for RX VP connection (0,1). */
7419 + int RxVp_OamVcList; /**< Indicates all VC channels associated with this VP channel (one-hot encoded). */
7423 +#ifdef _CPHAL_VDMAVT
7424 + bit32u RemFifoAddr; /* Mirror mode only. */
7434 + * This structure contains each statistic value gathered by the CPHAL.
7435 + * Applications may access statistics data by using the @c StatsGet() routine.
7438 +#if defined(_CPHAL_AAL2) || defined(_CPHAL_AAL5) || defined(_CPHAL_CPSAR)
7441 + bit32u CrcErrors[16];
7442 + bit32u LenErrors[16];
7443 + bit32u DmaLenErrors[16];
7444 + bit32u AbortErrors[16];
7445 + bit32u StarvErrors[16];
7446 + bit32u TxMisQCnt[16][2];
7447 + bit32u RxMisQCnt[16];
7448 + bit32u RxEOQCnt[16];
7449 + bit32u TxEOQCnt[16][2];
7450 + bit32u RxPacketsServiced[16];
7451 + bit32u TxPacketsServiced[16][2];
7452 + bit32u RxMaxServiced;
7453 + bit32u TxMaxServiced[16][2];
7460 + * VDMA Channel specific configuration information
7465 + int Ch; /**< Channel Number */
7466 + int RemoteEndian; /**< Endianness of remote VDMA-VT device */
7467 + 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. */
7472 + typedef void HAL_DEVICE;
7473 + typedef void HAL_PRIVATE;
7474 + typedef void HAL_RCB;
7475 + typedef void HAL_RECEIVEINFO;
7479 + * @ingroup shared_data
7480 + * The HAL_FUNCTIONS struct defines the function pointers used by upper layer
7481 + * software. The upper layer software receives these pointers through the
7482 + * call to xxxInitModule().
7486 + int (*ChannelSetup) (HAL_DEVICE *HalDev, CHANNEL_INFO *Channel, OS_SETUP *OsSetup);
7487 + int (*ChannelTeardown) (HAL_DEVICE *HalDev, int Channel, int Mode);
7488 + int (*Close) (HAL_DEVICE *HalDev, int Mode);
7489 + int (*Control) (HAL_DEVICE *HalDev, const char *Key, const char *Action, void *Value);
7490 + int (*Init) (HAL_DEVICE *HalDev);
7491 + int (*Open) (HAL_DEVICE *HalDev);
7492 + int (*PacketProcessEnd) (HAL_DEVICE *HalDev);
7493 + int (*Probe) (HAL_DEVICE *HalDev);
7494 + int (*RxReturn) (HAL_RECEIVEINFO *HalReceiveInfo, int StripFlag);
7495 + int (*Send) (HAL_DEVICE *HalDev, FRAGLIST *FragList, int FragCount, int PacketSize, OS_SENDINFO *OsSendInfo, bit32u Mode);
7496 + int (*Shutdown) (HAL_DEVICE *HalDev);
7497 + int (*Tick) (HAL_DEVICE *HalDev);
7500 + int (*Kick) (HAL_DEVICE *HalDev, int Queue);
7501 + void (*OamFuncConfig) (HAL_DEVICE *HalDev, unsigned int OamConfig);
7502 + void (*OamLoopbackConfig) (HAL_DEVICE *HalDev, unsigned int OamConfig, unsigned int *LLID, unsigned int CorrelationTag);
7503 + volatile bit32u* (*RegAccess)(HAL_DEVICE *HalDev, bit32u RegOffset);
7504 + STAT_INFO* (*StatsGetOld)(HAL_DEVICE *HalDev);
7509 + * @ingroup shared_data
7510 + * The OS_FUNCTIONS struct defines the function pointers for all upper layer
7511 + * functions accessible to the CPHAL. The upper layer software is responsible
7512 + * for providing the correct OS-specific implementations for the following
7513 + * functions. It is populated by calling InitModule() (done by the CPHAL in
7514 + * xxxInitModule().
7518 + int (*Control)(OS_DEVICE *OsDev, const char *Key, const char *Action, void *Value);
7519 + void (*CriticalOn)(void);
7520 + void (*CriticalOff)(void);
7521 + void (*DataCacheHitInvalidate)(void *MemPtr, int Size);
7522 + void (*DataCacheHitWriteback)(void *MemPtr, int Size);
7523 + int (*DeviceFindInfo)(int Inst, const char *DeviceName, void *DeviceInfo);
7524 + int (*DeviceFindParmUint)(void *DeviceInfo, const char *Parm, bit32u *Value);
7525 + int (*DeviceFindParmValue)(void *DeviceInfo, const char *Parm, void *Value);
7526 + void (*Free)(void *MemPtr);
7527 + void (*FreeRxBuffer)(OS_RECEIVEINFO *OsReceiveInfo, void *MemPtr);
7528 + void (*FreeDev)(void *MemPtr);
7529 + void (*FreeDmaXfer)(void *MemPtr);
7530 + void (*IsrRegister)(OS_DEVICE *OsDev, int (*halISR)(HAL_DEVICE*, int*), int InterruptBit);
7531 + void (*IsrUnRegister)(OS_DEVICE *OsDev, int InterruptBit);
7532 + void* (*Malloc)(bit32u size);
7533 + void* (*MallocDev)(bit32u Size);
7534 + void* (*MallocDmaXfer)(bit32u size, void *MemBase, bit32u MemRange);
7535 + void* (*MallocRxBuffer)(bit32u size, void *MemBase, bit32u MemRange,
7536 + OS_SETUP *OsSetup, HAL_RECEIVEINFO *HalReceiveInfo,
7537 + OS_RECEIVEINFO **OsReceiveInfo, OS_DEVICE *OsDev);
7538 + void* (*Memset)(void *Dest, int C, bit32u N);
7539 + int (*Printf)(const char *Format, ...);
7540 + int (*Receive)(OS_DEVICE *OsDev,FRAGLIST *FragList,bit32u FragCount,
7541 + bit32u PacketSize,HAL_RECEIVEINFO *HalReceiveInfo, bit32u Mode);
7542 + int (*SendComplete)(OS_SENDINFO *OsSendInfo);
7543 + int (*Sprintf)(char *S, const char *Format, ...);
7544 + int (*Strcmpi)(const char *Str1, const char *Str2);
7545 + unsigned int (*Strlen)(const char *S);
7546 + char* (*Strstr)(const char *S1, const char *S2);
7547 + unsigned long (*Strtoul)(const char *Str, char **Endptr, int Base);
7548 + void (*TeardownComplete)(OS_DEVICE *OsDev, int Ch, int Direction);
7551 +/************** MODULE SPECIFIC STUFF BELOW **************/
7553 +#ifdef _CPHAL_CPMAC
7556 +int halCpmacInitModule(HAL_DEVICE **HalDev, OS_DEVICE *OsDev, HAL_FUNCTIONS *HalFunc, int (*osBridgeInitModule)(OS_FUNCTIONS *), void* (*osMallocDev) (bit32u), int *Size, int inst);
7559 +int halCpmacInitModule(HAL_DEVICE **HalDev,
7561 + HAL_FUNCTIONS **HalFunc,
7562 + OS_FUNCTIONS *OsFunc,
7570 + * @ingroup shared_data
7571 + * The AAL5_FUNCTIONS struct defines the AAL5 function pointers used by upper layer
7572 + * software. The upper layer software receives these pointers through the
7573 + * call to cphalInitModule().
7578 + int (*ChannelSetup)(HAL_DEVICE *HalDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup);
7579 + int (*ChannelTeardown)(HAL_DEVICE *HalDev, int Ch, int Mode);
7580 + int (*Close)(HAL_DEVICE *HalDev, int Mode);
7581 + int (*Init)(HAL_DEVICE *HalDev);
7582 + int (*ModeChange)(HAL_DEVICE *HalDev, char *DeviceParms);
7583 + int (*Open)(HAL_DEVICE *HalDev);
7584 + int (*InfoGet)(HAL_DEVICE *HalDev, int Key, void *Value);
7585 + int (*Probe)(HAL_DEVICE *HalDev);
7586 + int (*RxReturn)(HAL_RECEIVEINFO *HalReceiveInfo, int StripFlag);
7587 + int (*Send)(HAL_DEVICE *HalDev,FRAGLIST *FragList,int FragCount,
7588 + int PacketSize,OS_SENDINFO *OsSendInfo,int Ch, int Queue,
7590 + int (*StatsClear)(HAL_DEVICE *HalDev);
7591 + STAT_INFO* (*StatsGet)(HAL_DEVICE *HalDev);
7592 + int (*Status)(HAL_DEVICE *HalDev);
7593 + void (*Tick)(HAL_DEVICE *HalDev);
7594 + int (*Kick)(HAL_DEVICE *HalDev, int Queue);
7595 + volatile bit32u* (*RegAccess)(HAL_DEVICE *HalDev, bit32u RegOffset);
7599 +int cpaal5InitModule(HAL_DEVICE **HalDev,
7601 + HAL_FUNCTIONS **HalFunc,
7602 + OS_FUNCTIONS *OsFunc,
7610 + * @ingroup shared_data
7611 + * The AAL2_FUNCTIONS struct defines the AAL2 function pointers used by upper layer
7612 + * software. The upper layer software receives these pointers through the
7613 + * call to cphalInitModule().
7617 + int (*ChannelSetup)(HAL_DEVICE *HalDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup);
7618 + int (*ChannelTeardown)(HAL_DEVICE *HalDev, int Ch, int Mode);
7619 + int (*Close)(HAL_DEVICE *HalDev, int Mode);
7620 + int (*Init)(HAL_DEVICE *HalDev);
7621 + int (*ModeChange)(HAL_DEVICE *HalDev, char *DeviceParms);
7622 + int (*Open)(HAL_DEVICE *HalDev);
7623 + int (*OptionsGet)(HAL_DEVICE *HalDev, char *Key, bit32u *Value);
7624 + int (*Probe)(HAL_DEVICE *HalDev);
7626 + int (*StatsClear)(HAL_DEVICE *HalDev);
7627 + STAT_INFO* (*StatsGet)(HAL_DEVICE *HalDev);
7628 + int (*Status)(HAL_DEVICE *HalDev);
7629 + void (*Tick)(HAL_DEVICE *HalDev);
7630 + int (*Aal2UuiMappingSetup)(HAL_DEVICE *HalDev, int VC, int UUI,
7631 + int VdmaCh, int UUIDiscard);
7632 + int (*Aal2RxMappingSetup)(HAL_DEVICE *HalDev, int VC, int CID,
7634 + int (*Aal2TxMappingSetup)(HAL_DEVICE *HalDev, int VC, int LC, int VdmaCh);
7635 + int (*Aal2VdmaChSetup)(HAL_DEVICE *HalDev, bit32u RemVdmaVtAddr,
7636 + VdmaChInfo *VdmaCh);
7637 + volatile bit32u* (*RegAccess)(HAL_DEVICE *HalDev, bit32u RegOffset);
7638 + int (*Aal2ModeChange)(HAL_DEVICE *HalDev, int Vc, int RxCrossMode,
7639 + int RxMultiMode, int TxMultiMode, int SchedMode,
7641 + void (*Aal2VdmaEnable)(HAL_DEVICE *HalDev, int Ch);
7642 + int (*Aal2VdmaDisable)(HAL_DEVICE *HalDev, int Ch);
7645 +int cpaal2InitModule(HAL_DEVICE **HalDev,
7647 + AAL2_FUNCTIONS **HalFunc,
7648 + OS_FUNCTIONS *OsFunc,
7654 +#ifdef _CPHAL_VDMAVT
7656 + * @ingroup shared_data
7657 + * The VDMA_FUNCTIONS struct defines the HAL function pointers used by upper layer
7658 + * software. The upper layer software receives these pointers through the
7659 + * call to InitModule().
7661 + * Note that this list is still under definition.
7665 + bit32 (*Init)( HAL_DEVICE *VdmaVtDev);
7666 + /* bit32 (*SetupTxFifo)(HAL_DEVICE *VdmaVtDev, bit32u LclRem,
7667 + bit32u Addr, bit32u Size, bit32u PollInt);
7668 + bit32 (*SetupRxFifo)(HAL_DEVICE *VdmaVtDev, bit32u LclRem,
7669 + bit32u Addr, bit32u Size, bit32u PollInt); */
7670 + bit32 (*Tx)(HAL_DEVICE *VdmaVtDev);
7671 + bit32 (*Rx)(HAL_DEVICE *VdmaVtDev);
7672 + bit32 (*SetRemoteChannel)(HAL_DEVICE *VdmaVtDev, bit32u RemAddr,
7674 + bit32 (*ClearRxInt)(HAL_DEVICE *VdmaVtDev);
7675 + bit32 (*ClearTxInt)(HAL_DEVICE *VdmaVtDev);
7676 + bit32 (*Open)(HAL_DEVICE *VdmaVtDev);
7677 + bit32 (*Close)(HAL_DEVICE *VdmaVtDev);
7678 + int (*Control) (HAL_DEVICE *HalDev, const char *Key, const char *Action, void *Value);
7679 + int (*ChannelSetup)(HAL_DEVICE *VdmaVtDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup);
7680 + int (*ChannelTeardown)(HAL_DEVICE *VdmaVtDev, int Ch, int Mode);
7681 + int (*Send)(HAL_DEVICE *VdmaVtDev,FRAGLIST *FragList,int FragCount,
7682 + int PacketSize,OS_SENDINFO *OsSendInfo,bit32u Mode);
7685 +int VdmaInitModule(HAL_DEVICE **VdmaVt,
7687 + VDMA_FUNCTIONS **VdmaVtFunc,
7688 + OS_FUNCTIONS *OsFunc,
7695 +extern int cphalInitModule(MODULE_TYPE ModuleType, HAL_DEVICE **HalDev, OS_DEVICE *OsDev, HAL_FUNCTIONS *HalFunc,
7696 + int (*osInitModule)(OS_FUNCTIONS *), void* (*osMallocDev)(bit32u),
7697 + int *Size, int Inst);
7702 +extern const char hcSarFrequency[];
7705 +#ifdef _CPHAL_CPMAC
7706 +/* following will be common, once 'utl' added */
7707 +extern const char hcClear[];
7708 +extern const char hcGet[];
7709 +extern const char hcSet[];
7710 +extern const char hcTick[];
7712 +extern const char hcCpuFrequency[];
7713 +extern const char hcCpmacFrequency[];
7714 +extern const char hcMdioBusFrequency[];
7715 +extern const char hcMdioClockFrequency[];
7716 +extern const char hcCpmacBase[];
7717 +extern const char hcPhyNum[];
7718 +extern const char hcSize[];
7719 +extern const char hcCpmacSize[];
7720 +extern const char hcPhyAccess[];
7721 +extern const char hcMdixMask[];
7722 +extern const char hcMdioMdixSwitch[];
7725 +#endif /* end of _INC_ */
7726 diff -urN linux.old/drivers/net/avalanche_cpmac/dox_cpmac.h linux.dev/drivers/net/avalanche_cpmac/dox_cpmac.h
7727 --- linux.old/drivers/net/avalanche_cpmac/dox_cpmac.h 1970-01-01 01:00:00.000000000 +0100
7728 +++ linux.dev/drivers/net/avalanche_cpmac/dox_cpmac.h 2005-07-12 02:48:42.050593000 +0200
7730 +/*****************************************************************************
7731 + * TNETDxxxx Software Support
7732 + * Copyright (c) 2002,2003 Texas Instruments Incorporated. All Rights Reserved.
7737 + * This file contains documentation for the CPMAC
7740 + * @author Michael Hanrahan/Greg Guyotte
7742 + * @date 03-Dec-2002
7743 + *****************************************************************************/
7744 +#ifndef _DOX_CPMAC_H
7745 +#define _DOX_CPMAC_H
7747 +@page CPMAC_Implementation_Details Version
7749 +@copydoc CPMAC_Version
7753 +@page cpmac_intro Introduction
7755 +The CPMAC implementation will support 8 channels for transmit and 8 channel for
7756 +receive. Each of the 8 transmit channels has 1 queue associated with it. It is
7757 +recommended that only 1 channel is used for @c Receive() per processor.
7761 +@page cpmac_details API Implementation Details
7764 +- The Upper 16 bits of Mode match Word 3 of the Rx Buffer Descriptor
7768 +- Bits 0-7 contain the Channel Number
7769 +- Bits 8-25 are reserved
7770 +- Bit 26 - if 0, the CRC will be calculated, if 1 the CRC will be Passed
7771 +- Bits 27-31 : reserved
7772 +@section cpmac_keys Control Keys
7775 +CPHAL calls the OS when a state change is detected.
7776 +OS should check the CPMAC Status. See the Control Key 'Status' for more details.
7779 +OS calls the CPHAL to obtain Status information. The Returned status is as follows
7782 +The OS may "Set" or "Get" this value. This defines the maximum
7783 +number of fragments that can be received by the CPMAC Rx port. The default
7784 +value for CPMAC is 2. This provides enough space to receive a maximum
7785 +length packet (1,518 bytes) with the default buffer size of 1518 and any
7786 +amount of RxBufferOffset. If the buffer size is configured to be smaller,
7787 +the OS *MUST* modify this parameter according to the following formula:
7788 +((System Max packet length)/(RxBufSize)) + 1. (The extra 1 fragment is to
7789 +allow for RxBufferOffset)
7792 +// Following defined in "cpswhal_cpmac.h"
7793 +// CPMAC CPHAL STATUS
7794 +#define CPMAC_STATUS_LINK (1 << 0)
7795 +#define CPMAC_STATUS_LINK_DUPLEX (1 << 1) // 0 - HD, 1 - FD
7796 +#define CPMAC_STATUS_LINK_SPEED (1 << 2) // 0 - 10, 1 - 100
7798 +// ADAPTER CHECK Codes
7799 +#define CPMAC_STATUS_ADAPTER_CHECK (1 << 7)
7800 +#define CPMAC_STATUS_HOST_ERR_DIRECTION (1 << 8) // 0 - Tx, 1 - Rx
7801 +#define CPMAC_STATUS_HOST_ERR_CODE (0xF << 9) See CPMAC Guide
7802 +#define CPMAC_STATUS_HOST_ERR_CH (0x7 << 13) See CPMAC Guide
7806 +void osStateChange(OS_DEVICE *OsDev)
7809 + OsDev->HalFunc->Control(OsDev->HalDev, "Status", hcGet, &status);
7810 + if(status & CPMAC_STATUS_ADAPTER_CHECK)
7812 + printf("[osStateChange[%d]] HAL notified OS of AdapterCheck (Link Status 0x%08X)\n", OsDev->port, status);
7813 + adaptercheck(OsDev->port);
7817 + printf("[osStateChange[%d]] HAL notified OS of State Change (Link Status %s)\n", OsDev->port, (status & CPMAC_STATUS_LINK) ? "Up" : "Down");
7818 + if(status & CPMAC_STATUS_LINK)
7820 + printf("Speed %s, Duplex %s\n",
7821 + status & CPMAC_STATUS_LINK_SPEED ? "100" : "10",
7822 + status & CPMAC_STATUS_LINK_DUPLEX ? "FD" : "HD");
7828 + The CPHAL calls the OS to set the interval for calling halTick()<BR>
7829 + Note: Predefined value hcTick now recommended for use.
7831 +*** Example Code ***
7835 +HalDev->OsFunc->Control(HalDev->OsDev, hcTick, hcSet, &Ticks);
7839 + if(osStrcmpi(pszKey, hcTick) == 0)
7841 + if(osStrcmpi(pszAction, hcSet) == 0)
7843 + // Enable the Tick Interval
7844 + if(*(unsigned int *) ParmValue)
7845 + printf("osTickSet: Interval = %d ticks\n", Interval);
7848 + if(osStrcmpi(pszAction, hcClear) == 0)
7850 + // Request disabling of the Tick Timer, ParmValue is ignored
7855 +@par The following information can be obtained by the OS via 'Get'
7857 +- StatsDump : OS supplies pointer to an 36 element unsigned int array
7858 +CPHAL will populate the array with the current Statistics values.<BR>
7859 +Note: all hcXXXX values are predefined and should be used by the OS.
7861 +- hcPhyNum : Returns the PHY number.
7862 +- hcCpmacBase : Returns the base-address of the CPMAC device
7863 +- hcCpmacSize : Returns size of the CPMAC memory map
7866 +@par Phy Register Communication
7868 +halControl() is used to read and write the Phy Registers via the key hcPhyAccess
7870 +Both reading and writing the Phy registers involve setting the Value parameter of halControl()
7872 +Value is a 32-bit value with bits partioned as follows
7875 + 0 - 4 Phy Number <BR>
7876 + 5 - 9 Phy Register <BR>
7877 + 10 - 15 reserved <BR>
7878 + 16 - 31 Data (write only)
7882 +<B>Reading the Phy register</B>
7888 + bit32u PhyRegisterData;
7890 + // Read Phy 31, register 20
7895 + Value = (RegAddr << 5);
7896 + Value |= (PhyNum & 0x1F);
7898 + rc = HalFunc->Control(HalDev, hcPhyAccess, hcGet, (bit32u *) &Value)
7901 + // Value is overwriten with the value in Register 20 of Phy number 31.
7902 + PhyRegisterData = Value;
7906 +<B>Writing the Phy register</B>
7911 + bit32u PhyRegisterData;
7917 + PhyRegisterData = 0x8000; // Reset bit set
7919 + Value = (RegAddr << 5);
7920 + Value |= (PhyNum & 0x1F);
7921 + Value |= (PhyRegisterData << 16);
7923 + rc = HalFunc->Control(HalDev, hcPhyAccess, hcSet, (bit32u *) &Value)
7925 + // Check is reset if done
7930 + Value = (RegAddr << 5);
7931 + Value |= (PhyNum & 0x1F);
7933 + rc = HalFunc->Control(HalDev, hcPhyAccess, hcGet, (bit32u *) &Value)
7937 + // Value is overwriten with the value in Register 0 of Phy number 23.
7938 + PhyRegisterData = Value;
7939 + if((PhyRegisterData & 0x8000) == 0)
7945 +*** Example Showing turning values off/on ***
7953 + # Turn On loopback
7954 + OsDev->HalFunc->Control(OsDev->HalDev, "CTRL_LOOPBACK", hcSet, (int*) &On);
7956 + # Turn off RX Flow
7957 + OsDev->HalFunc->Control(OsDev->HalDev, "RX_FLOW_EN", hcSet, (int*) &Off);
7960 +@par CPMAC Configurable Parameters
7962 +- RX_PASS_CRC : See MBP_Enable description
7963 +- RX_QOS_EN : See MBP_Enable description
7964 +- RX_NO_CHAIN : See MBP_Enable description
7965 +- RX_CMF_EN : See MBP_Enable description
7966 +- RX_CSF_EN : See MBP_Enable description
7967 +- RX_CEF_EN : See MBP_Enable description
7968 +- RX_CAF_EN : See MBP_Enable description
7969 +- RX_PROM_CH : See MBP_Enable description
7970 +- RX_BROAD_EN : See MBP_Enable description
7971 +- RX_BROAD_CH : See MBP_Enable description
7972 +- RX_MULT_EN : See MBP_Enable description
7973 +- RX_MULT_CH : See MBP_Enable description
7975 +- TX_PTYPE : See MacControl description
7976 +- TX_PACE : See MacControl description
7977 +- TX_FLOW_EN : See MacControl description
7978 +- RX_FLOW_EN : See MacControl description
7979 +- CTRL_LOOPBACK : See MacControl description
7981 +- RX_MAXLEN : See CPMAC Guide
7982 +- RX_FILTERLOWTHRESH : See CPMAC Guide
7983 +- RX0_FLOWTHRESH : See CPMAC Guide
7984 +- RX_UNICAST_SET : See CPMAC Guide
7985 +- RX_UNICAST_CLEAR : See CPMAC Guide
7987 +@par Multicast Support
7988 +- RX_MULTI_ALL : When used with hcSet, sets all the Hash Bits. When used
7989 +with hcClear clears all the Hash Bits.
7990 +- RX_MULTI_SINGLE : When used with hcSet, adds the Hashed Mac Address. When used
7991 +with hcClear deletes the Hashed Mac Address.
7992 +Note: Support will be added to keep track of Single additions and deletions.
7995 +*** Example Code ***
7998 + bit8u MacAddress[6];
7999 + MacAddress[0] = 0x80;
8000 + MacAddress[1] = 0x12;
8001 + MacAddress[2] = 0x34;
8002 + MacAddress[3] = 0x56;
8003 + MacAddress[4] = 0x78;
8004 + MacAddress[5] = 0x78;
8005 + OsDev->HalFunc->Control(OsDev->HalDev, "RX_MULTI_SINGLE", hcSet, (bit8u*) &MacAddress);
8006 + OsDev->HalFunc->Control(OsDev->HalDev, "RX_MULTI_SINGLE", hcClear, (bit8u*) &MacAddress);
8007 + OsDev->HalFunc->Control(OsDev->HalDev, "RX_MULTI_ALL", hcSet, NULL);
8008 + OsDev->HalFunc->Control(OsDev->HalDev, "RX_MULTI_ALL", hcClear, NULL);
8010 +@par MdioConnect Fields
8012 +- "MdioConnect" : The OS can set the Phy connection using this key. The default connection is Auto-Negotiation ON, All modes possible.
8015 +- _CPMDIO_HD <----- Allow Half Duplex, default is 1 (On)
8016 +- _CPMDIO_FD <----- Allow Full Duplex, default is 1 (On)
8017 +- _CPMDIO_10 <----- Allow 10 Mbs, default is 1 (On)
8018 +- _CPMDIO_100 <----- Allow 100 Mbs, default is 1 (On)
8019 +- _CPMDIO_NEG_OFF <----- Turn off Auto Negotiation, default is 0 (Auto Neg is on)
8020 +- _CPMDIO_NOPHY <----- Set for use with Marvel-type switch, default is 0 (Phy present)
8021 +- _CPMDIO_AUTOMDIX <---- Enables Auto Mdix (in conjunction with MdixMask), default is 1 (On)
8023 +Note: When _CPMDIO_NOPHY is set, CPMAC will report being linked at 100/FD. Reported PhyNum will be 0xFFFFFFFF
8025 +@par Setting CPMAC for use with a Marvel-type Switch
8027 + bit32u MdioConnect;
8029 + MdioConnect = _CPMDIO_NOPHY;
8030 + OsDev->HalFunc->Control(OsDev->HalDev, "MdioConnect", hcSet, (bit32u*) &MdioConnect);
8033 +@par OS Support for MDIO
8034 +@p The OS will need to supply the following values which the CPHAL will request via halControl()
8036 +- MdioBusFrequency : The frequency of the BUS that MDIO is on (requested via hcMdioBusFrequency)
8038 +- MdioClockFrequency : The desired Clock Frequency that MDIO qill operate at (requested via hcMdioClockFrequency)
8042 +@page cpmac_conf DeviceFindxxx() Parameters
8044 +These are some of the parameters that the CPMAC will request via the DeviceFindxxx() functions -
8046 +- "Mlink" : bit mask indicating what link status method Phy is using. Default is MDIO state machine (0x0)
8047 +- "PhyMask" : bit mask indicating PhyNums used by this CPMAC (e.g 0x8000000, PhyNum is 31)
8048 +- "MdixMask" : bit mask indicating which Phys support AutoMdix. Default is 0x0 (None)
8050 +@par Example cpmac definition from the options.conf for the Sangam VDB
8052 +- cpmac( id=eth0, base=0xA8610000, size=0x800, reset_bit=17, int_line=19, PhyMask=0x80000000, MLink=0, MdixMask=0 )
8056 +@page auto_mdix Auto Mdix Support
8058 +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
8059 +MdioConnect field, _CPMDIO_AUTOMDIX. This is defaulted ON. For actual Auto Mdix operation the Phy must also be Auto Mdix capable.
8060 +This is specified by the DeviceFindxxx() field, "MdixMask" (supplied as the variable hcMdixMask).
8061 +If both these fields are set then the CPMDIO state machine will be enabled for Auto Mdix checking.
8062 +If a switch to MDI or MDIX mode is needed, the CPMAC will signal this to the OS via Control() using
8063 +the hcMdioMdixSwitch key.
8065 +@par OS example for responding to a Mdix Switch Request
8068 +if(osStrcmpi(pszKey, hcMdioMdixSwitch) == 0) // See if key is Mdix Switch Request
8070 + if(osStrcmpi(pszAction, hcSet) == 0) // Only respond to Set requests
8075 + Mdix = *(bit32u *) ParmValue; // Extract requested Mode
8079 + osSetPhyIntoMdixMode(); // Device specific logic
8081 + osSetPhyIntoMdiMode(); // Device specific logic
8082 + rc = 0; // Set return code as Successfull
8088 +@page cpmac_stats CPMAC Specific Statistics
8090 +Statistics level '0' contains all CPMAC specific statistics.
8096 +@page Example_Driver_Code
8098 +@section example_intro Introduction
8099 +This section provides an in-depth code example for driver implementations. The code
8100 +below illustrates the use of the CPMAC HAL, but is equally applicable to any CPHAL
8101 +implementation. Note: the CPHAl constants hcGet, hcSet etc., are currently available for use with teh CPMAC module.
8102 +Other modules should continue to use pszGET, etc. until these are made generally available.
8104 +@par Pull Model Example
8108 +#define _CPHAL_CPMAC
8110 +typedef struct _os_device_s OS_DEVICE;
8111 +typedef struct _os_receive_s OS_RECEIVEINFO;
8112 +typedef struct _os_send_s OS_SENDINFO;
8113 +typedef struct _os_setup_s OS_SETUP;
8115 +#include "cpswhal_cpmac.h"
8117 +#define dbgPrintf printf
8119 +typedef struct _os_device_s
8121 + HAL_DEVICE *HalDev;
8122 + HAL_FUNCTIONS *HalFunc;
8123 + OS_FUNCTIONS *OsFunc;
8124 + OS_SETUP *OsSetup;
8126 + int (*halIsr)(HAL_DEVICE *HalDev, int*);
8129 + int LinkStatus; // 0-> down, otherwise up
8132 +typedef struct _os_receive_s
8134 + HAL_RECEIVEINFO *HalReceiveInfo;
8135 + char *ReceiveBuffer;
8139 +typedef struct _os_send_s
8144 +typedef struct _os_setup_s
8151 +void FlowForCphal(OS_DEVICE *OsDev)
8153 + CHANNEL_INFO ChannelInfo;
8154 + int nChannels = 200;
8158 + // Populate OsFunc structure
8159 + rc = osInitModule(OsDev);
8163 + sprintf(bufTmp, "%s: return code from osInitModule:'0x%08X'", __FUNCTION__, rc);
8168 + // OS-Cphal handshake
8169 + rc = halCpmacInitModule(&OsDev->HalDev, OsDev, &OsDev->HalFunc, OsDev->OsFunc,
8170 + sizeof(OS_FUNCTIONS), &halFuncSize, OsDev->ModulePort);
8174 + sprintf(bufTmp, "%s: return code from halCpmacInitModule:'0x%08X'", __FUNCTION__, rc);
8178 + // See if hardware module exists
8179 + rc = OsDev->HalFunc->Probe(OsDev->HalDev);
8183 + sprintf(bufTmp, "%s: return code from Probe:'0x%08X'", __FUNCTION__, rc);
8187 + // Initialize hardware module
8188 + rc = OsDev->HalFunc->Init(OsDev->HalDev);
8192 + sprintf(bufTmp, "%s: return code from Init:'0x%08X'", __FUNCTION__, rc);
8196 + // Setup Channel Information (Tranmsit, channel 0)
8197 + ChannelInfo.Channel = 0;
8198 + ChannelInfo.Direction = DIRECTION_TX;
8199 + ChannelInfo.TxNumBuffers = nChannels;
8200 + ChannelInfo.TxNumQueues = 1;
8201 + ChannelInfo.TxServiceMax = nChannels/3;
8203 + rc = OsDev->HalFunc->ChannelSetup(OsDev->HalDev, &ChannelInfo, OsDev->OsSetup);
8205 + // Setup Channel Information (Receive, channel 0)
8206 + ChannelInfo.Channel = 0;
8207 + ChannelInfo.Direction = DIRECTION_RX;
8208 + ChannelInfo.RxBufSize = 1518;
8209 + ChannelInfo.RxBufferOffset = 0;
8210 + ChannelInfo.RxNumBuffers = 2*nChannels;
8211 + ChannelInfo.RxServiceMax = nChannels/3;
8213 + rc = OsDev->HalFunc->ChannelSetup(OsDev->HalDev, &ChannelInfo, OsDev->OsSetup);
8215 + // Open the hardware module
8216 + rc = OsDev->HalFunc->Open(OsDev->HalDev);
8218 + // Module now ready to Send/Receive data
8222 +int osInitModule(OS_FUNCTIONS **pOsFunc)
8224 + OS_FUNCTIONS *OsFunc;
8226 + OsFunc = (OS_FUNCTIONS *) malloc(sizeof(OS_FUNCTIONS));
8230 + *pOsFunc = OsFunc;
8232 + OsFunc->CriticalOff = osCriticalOff;
8233 + OsFunc->CriticalOn = osCriticalOn;
8234 + OsFunc->DataCacheHitInvalidate = osDataCacheHitInvalidate;
8235 + OsFunc->DataCacheHitWriteback = osDataCacheHitWriteback;
8236 + OsFunc->DeviceFindInfo = osDeviceFindInfo;
8237 + OsFunc->DeviceFindParmUint = osDeviceFindParmUint;
8238 + OsFunc->DeviceFindParmValue = osDeviceFindParmValue;
8239 + OsFunc->Free = osFree;
8240 + OsFunc->FreeDev = osFreeDev;
8241 + OsFunc->FreeDmaXfer = osFreeDmaXfer;
8242 + OsFunc->FreeRxBuffer = osFreeRxBuffer;
8243 + OsFunc->IsrRegister = osIsrRegister;
8244 + OsFunc->IsrUnRegister = osIsrUnRegister;
8245 + OsFunc->Malloc = osMalloc;
8246 + OsFunc->MallocDev = osMallocDev;
8247 + OsFunc->MallocDmaXfer = osMallocDmaXfer;
8248 + OsFunc->MallocRxBuffer = osMallocRxBuffer;
8251 + OsFunc->Memset = memset;
8252 + OsFunc->Printf = printf;
8253 + OsFunc->Sprintf = sprintf;
8254 + OsFunc->Strcmpi = osStrcmpi;
8255 + OsFunc->Strlen = strlen;
8256 + OsFunc->Strstr = strstr;
8257 + OsFunc->Strtoul = strtoul;
8259 + OsFunc->Control = osControl;
8260 + OsFunc->Receive = osReceive;
8261 + OsFunc->SendComplete = osSendComplete;
8262 + OsFunc->TeardownComplete = osTearDownComplete;
8268 +int osReceive(OS_DEVICE *OsDev,FRAGLIST *Fraglist,bit32u FragCount,bit32u PacketSize,HAL_RECEIVEINFO *halInfo, bit32u mode)
8270 + OS_RECEIVEINFO *skb = (OS_RECEIVEINFO *)Fraglist[0].OsInfo;
8271 + dcache_i((char *)Fraglist->data, Fraglist->len);
8272 + OsDev->HalFunc->RxReturn(halInfo,0);
8276 +int osSendComplete(OS_SENDINFO *skb)
8282 +static void *osMallocRxBuffer(bit32u Size,void *MemBase, bit32u MemRange,
8283 + OS_SETUP *OsSetup, HAL_RECEIVEINFO *HalReceiveInfo,
8284 + OS_RECEIVEINFO **OsReceiveInfo, OS_DEVICE *OsDev )
8287 + OS_RECEIVEINFO *OsPriv;
8289 + HalBuffer=malloc(Size);
8295 + // Malloc the OS block
8296 + *OsReceiveInfo = malloc(sizeof(OS_RECEIVEINFO));
8297 + if (!*OsReceiveInfo)
8303 + // Initialize the new buffer descriptor
8304 + OsPriv = *OsReceiveInfo;
8305 + OsPriv->OsDev = OsDev;
8306 + OsPriv->ReceiveBuffer = HalBuffer;
8307 + OsPriv->HalReceiveInfo = HalReceiveInfo;
8309 + return(HalBuffer);
8313 +void SendBuffer(OS_DEVICE *OsDev, char *Buffer, int Size)
8315 + FRAGLIST Fraglist;
8319 + Fraglist.len = Size;
8320 + Fraglist.data = (unsigned *) Buffer;
8322 + mode = 0; // Channel 0
8324 + dcache_wb(Fraglist.data, Fraglist.len);
8325 + OsDev->HalFunc->Send(OsDev->HalDev, &Fraglist, FragCount, Size, (OS_SENDINFO *) Buffer, mode);
8329 +void osStateChange(OS_DEVICE *OsDev)
8333 + OsDev->HalFunc->Control(OsDev->HalDev, "Status", hcGet, &status);
8334 + if(status & CPMAC_STATUS_ADAPTER_CHECK)
8336 + // Adapter Check, take appropiate action
8340 + LinkStatus = status & CPMAC_STATUS_LINK;
8341 + if(LinkStatus != OsDev->LinkStatus)
8343 + dbgPrintf("\n%s:Link %s for inst %d Speed %s, Duplex %s\n",
8345 + LinkStatus ? "up" : "down",
8346 + OsDev->ModulePort,
8347 + status & CPMAC_STATUS_LINK_SPEED ? "100" : "10",
8348 + status & CPMAC_STATUS_LINK_DUPLEX ? "FD" : "HD");
8349 + OsDev->LinkStatus = LinkStatus;
8355 +int osControl(OS_DEVICE *OsDev, const char *pszKey, const char* pszAction, void *ParmValue)
8359 + if (osStrcmpi(pszKey, hcCpuFrequency) == 0)
8361 + if(osStrcmpi(pszAction, hcGet) == 0)
8363 + *(bit32u*) ParmValue = cpufreq;
8367 + if (osStrcmpi(pszKey, hcMdioBusFrequency) == 0)
8369 + if(osStrcmpi(pszAction, hcGet) == 0)
8371 + *(bit32u *)ParmValue = MdioBusFrequency;
8375 +if (osStrcmpi(pszKey, hcMdioClockFrequency) == 0)
8377 + if(osStrcmpi(pszAction, hcGet) == 0)
8379 + *(bit32u *)ParmValue = MdioClockFrequency;
8384 + if (osStrcmpi(pszKey, hcTick) == 0)
8386 + if(osStrcmpi(pszAction, hcSet) == 0)
8388 + osTickSetInterval(OsDev, *(unsigned int *) ParmValue);
8392 + if(osStrcmpi(pszAction, hcClear) == 0)
8394 + osTickDisable(OsDev);
8399 + if (osStrcmpi(pszKey, "SioFlush") == 0)
8405 + if (osStrcmpi(pszKey, "StateChange") == 0)
8407 + osStateChange(OsDev);
8411 + if (osStrcmpi(pszKey, "Sleep") == 0)
8413 + osSleep(*(int *)ParmValue);
8422 +@par Push Model Example (Currently Eswitch ONLY)
8426 +typedef struct _os_device_s OS_DEVICE;
8427 +typedef struct _os_receive_s OS_RECEIVEINFO;
8428 +typedef struct _os_send_s OS_SENDINFO;
8429 +typedef struct _os_setup_s OS_SETUP;
8431 +#include "cpswhal.h" //Get glogal HAL stuff
8432 +#include "cpswhaleswitch.h" //Get device specific hal stuff
8435 +typedef struct _os_device_s
8437 + HAL_DEVICE *HalDev;
8438 + HAL_FUNCTIONS *HalFunc;
8439 + OS_FUNCTIONS *OsFunc;
8440 + OS_SETUP *OsSetup;
8442 + int (*halIsr)(HAL_DEVICE *HalDev, int*);
8445 + int LinkStatus; // 0-> down, otherwise up
8448 +typedef struct _os_receive_s
8450 + HAL_RECEIVEINFO *HalReceiveInfo;
8451 + char *ReceiveBuffer;
8455 +typedef struct _os_send_s
8460 +typedef struct _os_setup_s
8467 +void FlowForCphal(OS_DEVICE *OsDev)
8469 +CHANNEL_INFO ChannelInfo;
8470 + int nChannels = 200;
8474 + // Populate OsFunc structure
8475 + rc = osInitModule(OsDev);
8479 + sprintf(bufTmp, "%s: return code from osInitModule:'0x%08X'", __FUNCTION__, rc);
8484 + // OS-Cphal handshake
8485 + rc = cpswHalEswitchInitModule(&OsDev->HalDev, OsDev, &OsDev->HalFunc, OsDev->OsFunc,
8486 + sizeof(OS_FUNCTIONS), &halFuncSize, OsDev->ModulePort);
8490 + sprintf(bufTmp, "%s: return code from cpswHalEswitchInitModule:'0x%08X'", __FUNCTION__, rc);
8495 + ChannelInfo.Channel = 7;
8496 + ChannelInfo.Direction = DIRECTION_RX;
8497 + ChanInfo.Receive = osReceiveSS; // Specify function to receive data for this channel
8499 + rc = OsDev->HalFunc->ChannelSetup(OsDev->HalDev, &ChannelInfo, OsDev->OsSetup);
8502 + MyConfig.CpuFrequency = CpuFreq;
8503 + MyConfig.EswitchFrequency = EswitchFreq;
8504 + MyConfig.ResetBase = 0xa8611600;
8505 + MyConfig.MacAddress = MacAddr;
8507 + MyConfig.EswitchResetBit= 27;
8508 + MyConfig.Cpmac0ResetBit = 17;
8509 + MyConfig.Cpmac1ResetBit = 21;
8510 + MyConfig.MdioResetBit = 22;
8511 + MyConfig.Phy0ResetBit = 26;
8512 + MyConfig.Phy1ResetBit = 28;
8513 + MyConfig.HdmaResetBit = 13;
8514 + MyConfig.Cpmac0IntBit = 19;
8515 + MyConfig.Cpmac1IntBit = 33;
8516 + MyConfig.EswitchIntBit = 27;
8517 + MyConfig.EswitchBase = 0xa8640000;
8518 + MyConfig.EswitchBufferSize = 64;
8519 + MyConfig.EswitchHostBufCount = 0;
8520 + MyConfig.EswitchDefaultCamSize = 64;
8521 + MyConfig.EswitchOverFlowCount = 200;
8522 + MyConfig.EswitchOverFlowSize = 256;
8527 + rc=EswitchConfig(HalDev,HalFunc,&MyConfig);
8530 + // Open the hardware module
8531 + rc = OsDev->HalFunc->Open(OsDev->HalDev);
8533 + // Module now ready to Send/Receive data
8537 +int EswitchConfig(HAL_DEVICE *HalDev, HAL_FUNCTIONS *HalFunc, ESWITCH_CONFIG *Config)
8542 + sts |= cpswhalPushBin(hcdebug, Config->debug);
8543 + sts |= cpswhalPushBin(hcCpuFrequency , Config->CpuFrequency );
8544 + sts |= cpswhalPushBin(hcEswitchFrequency , Config->EswitchFrequency );
8545 + sts |= cpswhalPushBin(hcResetBase , Config->ResetBase );
8546 + sts |= cpswhalPushBin(hcMacAddress , Config->MacAddress );
8547 + sts |= cpswhalPushBin(hcEswitchResetBit, Config->EswitchResetBit);
8548 + sts |= cpswhalPushBin(hcCpmac0ResetBit , Config->Cpmac0ResetBit );
8549 + sts |= cpswhalPushBin(hcCpmac1ResetBit , Config->Cpmac1ResetBit );
8550 + sts |= cpswhalPushBin(hcMdioResetBit , Config->MdioResetBit );
8551 + sts |= cpswhalPushBin(hcPhy0ResetBit , Config->Phy0ResetBit );
8552 + sts |= cpswhalPushBin(hcPhy1ResetBit , Config->Phy1ResetBit );
8553 + sts |= cpswhalPushBin(hcHdmaResetBit , Config->HdmaResetBit );
8554 + sts |= cpswhalPushBin(hcCpmac0IntBit , Config->Cpmac0IntBit );
8555 + sts |= cpswhalPushBin(hcCpmac1IntBit , Config->Cpmac1IntBit );
8556 + sts |= cpswhalPushBin(hcEswitchIntBit , Config->EswitchIntBit );
8557 + sts |= cpswhalPushBin(hcEswitchBase , Config->EswitchBase );
8558 + sts |= cpswhalPushBin(hcEswitchBufferSize , Config->EswitchBufferSize );
8559 + sts |= cpswhalPushBin(hcEswitchHostBufCount , Config->EswitchHostBufCount );
8560 + sts |= cpswhalPushBin(hcEswitchDefaultCamSize , Config->EswitchDefaultCamSize );
8561 + sts |= cpswhalPushBin(hcEswitchOverFlowCount , Config->EswitchOverFlowCount );
8562 + sts |= cpswhalPushBin(hcEswitchOverFlowSize , Config->EswitchOverFlowSize );
8572 diff -urN linux.old/drivers/net/avalanche_cpmac/ec_errors_cpmac.h linux.dev/drivers/net/avalanche_cpmac/ec_errors_cpmac.h
8573 --- linux.old/drivers/net/avalanche_cpmac/ec_errors_cpmac.h 1970-01-01 01:00:00.000000000 +0100
8574 +++ linux.dev/drivers/net/avalanche_cpmac/ec_errors_cpmac.h 2005-07-12 02:48:42.051592000 +0200
8576 +/***************************************************************************
8577 + Copyright(c) 2001, Texas Instruments Incorporated. All Rights Reserved.
8582 + This file contains definitions and function declarations for
8583 + error code support.
8586 + 14Dec00 MJH Added masking to EC_CLASS etc macros
8587 + 17Sep02 GSG Added HAL support (new class&devices)
8588 + 03Oct02 GSG Removed C++ style comments
8589 +***************************************************************************/
8590 +#ifndef _INC_EC_ERRORS
8591 +#define _INC_EC_ERRORS
8595 + 30-28 - CLASS (ie. DIAG, KERNEL, FLASH, etc)
8596 + 27-24 - INSTANCE (ie. 1, 2, 3, etc )
8597 + 23-16 - DEVICE (ie. EMAC, IIC, etc)
8598 + 15-08 - FUNCTION (ie. RX, TX, INIT, etc)
8599 + 07-00 - ERROR CODE (ie. NO_BASE, FILE_NOT_FOUND, etc )
8602 +/*---------------------------------------------------------------------------
8603 + Useful defines for accessing fields within error code
8604 +---------------------------------------------------------------------------*/
8605 +#define CRITICAL_SHIFT 31
8606 +#define CLASS_SHIFT 28
8607 +#define INST_SHIFT 24
8608 +#define DEVICE_SHIFT 16
8609 +#define FUNCTION_SHIFT 8
8610 +#define ERROR_CODE_SHIFT 0
8612 +#define CRITICAL_MASK 1
8613 +#define CLASS_MASK 0x07
8614 +#define DEVICE_MASK 0xFF
8615 +#define INST_MASK 0x0F
8616 +#define FUNCTION_MASK 0xFF
8617 +#define ERROR_CODE_MASK 0xFF
8619 +#define EC_CLASS(val) ((val&CLASS_MASK) << CLASS_SHIFT)
8620 +#define EC_DEVICE(val) ((val&DEVICE_MASK) << DEVICE_SHIFT)
8621 +#define EC_INST(val) ((val&INST_MASK) << INST_SHIFT)
8622 +#define EC_FUNC(val) ((val&FUNCTION_MASK) << FUNCTION_SHIFT)
8623 +#define EC_ERR(val) ((val&ERROR_CODE_MASK) << ERROR_CODE_SHIFT)
8625 +/*---------------------------------------------------------------------------
8627 +---------------------------------------------------------------------------*/
8628 +#define EC_HAL EC_CLASS(0)
8629 +#define EC_DIAG EC_CLASS(8)
8631 +/*---------------------------------------------------------------------------
8633 +---------------------------------------------------------------------------*/
8634 +#define EC_DEV_EMAC EC_DEVICE(1)
8635 +#define EC_DEV_IIC EC_DEVICE(2)
8636 +#define EC_DEV_RESET EC_DEVICE(3)
8637 +#define EC_DEV_ATMSAR EC_DEVICE(4)
8638 +#define EC_DEV_MEM EC_DEVICE(5)
8639 +#define EC_DEV_DES EC_DEVICE(6)
8640 +#define EC_DEV_DMA EC_DEVICE(7)
8641 +#define EC_DEV_DSP EC_DEVICE(8)
8642 +#define EC_DEV_TMR EC_DEVICE(9)
8643 +#define EC_DEV_WDT EC_DEVICE(10)
8644 +#define EC_DEV_DCL EC_DEVICE(11)
8645 +#define EC_DEV_BBIF EC_DEVICE(12)
8646 +#define EC_DEV_PCI EC_DEVICE(13)
8647 +#define EC_DEV_XBUS EC_DEVICE(14)
8648 +#define EC_DEV_DSLIF EC_DEVICE(15)
8649 +#define EC_DEV_USB EC_DEVICE(16)
8650 +#define EC_DEV_CLKC EC_DEVICE(17)
8651 +#define EC_DEV_RAPTOR EC_DEVICE(18)
8652 +#define EC_DEV_DSPC EC_DEVICE(19)
8653 +#define EC_DEV_INTC EC_DEVICE(20)
8654 +#define EC_DEV_GPIO EC_DEVICE(21)
8655 +#define EC_DEV_BIST EC_DEVICE(22)
8656 +#define EC_DEV_HDLC EC_DEVICE(23)
8657 +#define EC_DEV_UART EC_DEVICE(24)
8658 +#define EC_DEV_VOIC EC_DEVICE(25)
8659 +/* 9.17.02 (new HAL modules) */
8660 +#define EC_DEV_CPSAR EC_DEVICE(0x1A)
8661 +#define EC_DEV_AAL5 EC_DEVICE(0x1B)
8662 +#define EC_DEV_AAL2 EC_DEVICE(0x1C)
8663 +#define EC_DEV_CPMAC EC_DEVICE(0x1D)
8664 +#define EC_DEV_VDMA EC_DEVICE(0x1E)
8665 +#define EC_DEV_VLYNQ EC_DEVICE(0x1F)
8666 +#define EC_DEV_CPPI EC_DEVICE(0x20)
8667 +#define EC_DEV_CPMDIO EC_DEVICE(0x21)
8669 +/*---------------------------------------------------------------------------
8671 +---------------------------------------------------------------------------*/
8672 +#define EC_FUNC_READ_CONF EC_FUNC(1)
8673 +#define EC_FUNC_INIT EC_FUNC(2)
8675 +/*---------------------------------------------------------------------------
8677 +---------------------------------------------------------------------------*/
8678 +#define EC_CRITICAL (1<<CRITICAL_SHIFT)
8679 +#define EC_NO_ERRORS 0
8680 +#define EC_VAL_NO_BASE EC_ERR(1)
8681 +#define EC_VAL_NO_RESET_BIT EC_ERR(2)
8682 +#define EC_VAL_NO_RESET EC_ERR(3)
8683 +#define EC_VAL_BAD_BASE EC_ERR(4)
8684 +#define EC_VAL_MALLOCFAILED EC_ERR(5)
8685 +#define EC_VAL_NO_RESETBASE EC_ERR(6)
8686 +#define EC_DEVICE_NOT_FOUND EC_ERR(7)
8688 +/*---------------------------------------------------------------------------
8689 + Function declarations
8690 +---------------------------------------------------------------------------*/
8691 +extern void ec_log_error( unsigned int );
8693 +#endif /* _INC_EC_ERRORS */
8694 diff -urN linux.old/drivers/net/avalanche_cpmac/hcpmac.c linux.dev/drivers/net/avalanche_cpmac/hcpmac.c
8695 --- linux.old/drivers/net/avalanche_cpmac/hcpmac.c 1970-01-01 01:00:00.000000000 +0100
8696 +++ linux.dev/drivers/net/avalanche_cpmac/hcpmac.c 2005-07-12 02:48:42.174574000 +0200
8698 +/******************************************************************************
8699 + * TNETDxxxx Software Support
8700 + * Copyright (c) 2002-2004 Texas Instruments Incorporated. All Rights Reserved.
8705 + * This file contains the code for the HAL EMAC Bridge Test
8708 + * xxXxx01 Denis RC1.00 Original Version created.
8709 + * 22Jan02 Denis/Mick RC1.01 Modified for HAL EMAC API
8710 + * 24Jan02 Denis/Mick RC1.02 Speed Improvements
8711 + * 28Jan02 Denis/Mick RC1.16 Made function calls pointers
8712 + * 28Jan02 Mick RC1.18 Split into separate modules
8713 + * 29Jan02 Mick RC1.19 Hal include file cleaned up
8714 + * 15Jul02 Michael Hanrahan RC1.20 Synch'd with Linux Version
8715 + * 23Sep02 Michael Hanrahan RC1.21 Added CPPI.C
8716 + * 16Oct02 Michael Hanrahan RC1.22 Added CAF etc to Options.Conf
8717 + * 09Jan03 Michael Hanrahan RC3.01 Fixed incorrect MDIO check
8718 + * 01Feb03 Michael Hanrahan RC3.02 Updated for GPIO/PBUSFREQ
8719 + * 29Mar03 Michael Hanrahan 1.03 Corrected ChannelConfigGet
8720 + * 29Mar03 Michael Hanrahan 1.03 Removed user setting of TxNumQueues
8721 + * 23Aug04 Michael Hanrahan 1.7.8 Support for Setting Mac Address
8722 + * @author Michael Hanrahan
8724 + * @date 24-Jan-2002
8725 + *****************************************************************************/
8727 +#define _CPHAL_CPMAC
8729 +#define __CPHAL_CPMDIO
8731 +#include "dox_cpmac.h" /* Documentation information */
8733 +/* OS Data Structure definitions */
8735 +typedef void OS_PRIVATE;
8736 +typedef void OS_DEVICE;
8737 +typedef void OS_SENDINFO;
8738 +typedef void OS_RECEIVEINFO;
8739 +typedef void OS_SETUP;
8741 +/* HAL Data Structure definitions */
8743 +typedef struct _phy_device PHY_DEVICE;
8744 +typedef struct hal_device HAL_DEVICE;
8745 +typedef struct hal_private HAL_PRIVATE;
8746 +typedef struct hal_private HAL_RECEIVEINFO;
8748 +#include "cpcommon_cpmac.h"
8749 +#include "cpswhal_cpmac.h"
8750 +#include "cpmdio.h"
8751 +#include "hcpmac.h"
8752 +#include "cpmac_reg.h"
8757 +/* MDIO Clock Frequency Default Value */
8759 +/* Rcb/Tcb Constants */
8761 +#define CB_SOF_BIT (1<<31)
8762 +#define CB_EOF_BIT (1<<30)
8763 +#define CB_SOF_AND_EOF_BIT (CB_SOF_BIT|CB_EOF_BIT)
8764 +#define CB_OWNERSHIP_BIT (1<<29)
8765 +#define CB_EOQ_BIT (1<<28)
8766 +#define CB_SIZE_MASK 0x0000ffff
8767 +#define RCB_ERRORS_MASK 0x03fe0000
8769 +static char *channel_names[] = CHANNEL_NAMES; /* GSG 11/22 (may change this implementation) */
8771 +#define scFound(Module) if (HalDev->State != enDevFound) return (Module|EC_FUNC_CHSETUP|EC_VAL_INVALID_STATE)
8772 +#define scInit(Module) if (HalDev->State < enInitialized) return (Module|EC_FUNC_CHSETUP|EC_VAL_INVALID_STATE)
8773 +#define scOpen(Module) if (HalDev->State < enOpened) return (Module|EC_FUNC_CHSETUP|EC_VAL_INVALID_STATE)
8777 +/********************************************************************
8779 +** L O C A L F U N C T I O N S
8781 +********************************************************************/
8782 +static int halIsr(HAL_DEVICE *HalDev, int *MorePackets);
8783 +static int cpmacRandom(HAL_DEVICE *HalDev);
8784 +static int cpmacRandomRange(HAL_DEVICE *HalDev, int min, int max);
8785 +static int halPacketProcessEnd(HAL_DEVICE *HalDev);
8787 +#include "cpcommon_cpmac.c" /*~RC3.02*/
8788 +#include "cppi_cpmac.c"
8789 +#include "cpmdio.c" /*~RC3.02*/
8791 +static int MacAddressSave(HAL_DEVICE *HalDev, unsigned char *MacAddr)
8794 + int inst = HalDev->inst;
8796 + HalDev->MacAddr = MacAddr;
8800 + dbgPrintf("MacAddrSave[%d]: ", inst);
8802 + dbgPrintf("%X", HalDev->MacAddr[i]);
8806 + return(EC_NO_ERRORS);
8808 +static int MacAddressSet(HAL_DEVICE *HalDev)
8810 + unsigned char *macadr = &HalDev->MacAddr[0];
8811 + int base = HalDev->dev_base;
8814 + CPMAC_MACADDRLO_0(base) = macadr[5];
8815 + CPMAC_MACADDRMID(base) = macadr[4];
8816 + CPMAC_MACADDRHI(base) = (macadr[0])|(macadr[1]<<8)|(macadr[2]<<16)|(macadr[3]<<24);
8819 + dbgPrintf("MacAddrSet: MacAddr(%d) %X %X %X\n", HalDev->inst, CPMAC_MACADDRLO_0(base),
8820 + CPMAC_MACADDRMID(base),
8821 + CPMAC_MACADDRHI(base));
8823 + dbgPrintf("Start MAC: %d\n",HalDev->dev_base);
8826 + return(EC_NO_ERRORS);
8831 + Updates the MacHash registers
8833 +static void MacHashSet(HAL_DEVICE *HalDev)
8835 + if(HalDev->State < enOpened)
8838 + CPMAC_MACHASH1(HalDev->dev_base) = HalDev->MacHash1;
8839 + CPMAC_MACHASH2(HalDev->dev_base) = HalDev->MacHash2;
8841 + dbgPrintf("CPMAC[%X]: MacHash1 0x%08X, MacHash2 0x%08X\n", HalDev->dev_base, CPMAC_MACHASH1(HalDev->dev_base), CPMAC_MACHASH2(HalDev->dev_base));
8845 + Reads the MacControl register and updates
8846 + the changable bits. (See MACCONTROL_MASK)
8848 +static void RxMBP_EnableSet(HAL_DEVICE *HalDev)
8850 + bit32u RxMbpEnable;
8851 + if(HalDev->State < enOpened)
8853 + RxMbpEnable = CPMAC_RX_MBP_ENABLE(HalDev->dev_base);
8854 + RxMbpEnable &= ~RX_MBP_ENABLE_MASK; /* Clear out updatable bits */
8855 + RxMbpEnable |= HalDev->RxMbpEnable;
8856 + CPMAC_RX_MBP_ENABLE(HalDev->dev_base) = RxMbpEnable;
8859 + Reads the MacControl register and updates
8860 + the changable bits. (See MACCONTROL_MASK)
8862 +static void MacControlSet(HAL_DEVICE *HalDev)
8864 + bit32u MacControl;
8865 + if(HalDev->State < enOpened)
8867 + MacControl = CPMAC_MACCONTROL(HalDev->dev_base);
8868 + MacControl &= ~MACCONTROL_MASK; /* Clear out updatable bits */
8869 + MacControl |= HalDev->MacControl;
8870 + if(!(MacControl & MII_EN)) /* If Enable is not set just update register */
8871 + CPMAC_MACCONTROL(HalDev->dev_base) = MacControl;
8874 + if(MacControl & CTRL_LOOPBACK) /* Loopback Set */
8876 + /* mii_en is set and loopback is needed,
8877 + clear mii_en, set loopback, then set mii_en
8879 + MacControl &= ~MII_EN; /* Clear MII_EN */
8880 + CPMAC_MACCONTROL(HalDev->dev_base) = MacControl;
8881 + CPMAC_MACCONTROL(HalDev->dev_base) |= MII_EN; /* Set MII_EN */
8882 + HalDev->Linked = 1; /* if in loopback the logically linked */
8884 + else /* If Loopback not set just update */
8886 + CPMAC_MACCONTROL(HalDev->dev_base) = MacControl;
8890 + dbgPrintf("[halMacControlSet]MacControl:%08X\n", CPMAC_MACCONTROL(HalDev->dev_base));
8892 +static int UnicastSet(HAL_DEVICE *HalDev)
8894 + CPMAC_RX_UNICAST_SET(HalDev->dev_base) = HalDev->RxUnicastSet;
8895 + CPMAC_RX_UNICAST_CLEAR(HalDev->dev_base) = HalDev->RxUnicastClear;
8896 + return(EC_NO_ERRORS);
8900 +static bit32u HashGet(bit8u *Address)
8907 + for( i=0; i<2; i++ )
8909 + tmpval = *Address++;
8910 + hash ^= (tmpval>>2)^(tmpval<<4);
8911 + tmpval = *Address++;
8912 + hash ^= (tmpval>>4)^(tmpval<<2);
8913 + tmpval = *Address++;
8914 + hash ^= (tmpval>>6)^(tmpval);
8917 + return( hash & 0x3F );
8920 +static void HashAdd(HAL_DEVICE *HalDev, bit8u *MacAddress)
8925 + HashValue = HashGet(MacAddress);
8927 + if(HashValue < 32)
8929 + HashBit = (1 << HashValue);
8930 + HalDev->MacHash1 |= HashBit;
8934 + HashBit = (1 << (HashValue-32));
8935 + HalDev->MacHash2 |= HashBit;
8939 +static void HashDel(HAL_DEVICE *HalDev, bit8u *MacAddress)
8944 + HashValue = HashGet(MacAddress);
8946 + if(HashValue < 32)
8948 + HashBit = (1 << HashValue);
8949 + HalDev->MacHash1 &= ~HashBit;
8953 + HashBit = (1 << (HashValue-32));
8954 + HalDev->MacHash2 &= ~HashBit;
8958 +/* Replace with an array based on key, with a ptr to the code to do */
8959 +/* e.g. [enRX_PASS_CRC] = {Set, MBP_UPDATE() } */
8960 +static void DuplexUpdate(HAL_DEVICE *HalDev)
8962 + int base = HalDev->dev_base;
8963 + PHY_DEVICE *PhyDev = HalDev->PhyDev;
8965 + if(HalDev->State < enOpened)
8968 + /* No Phy Condition */
8969 + if(HalDev->MdioConnect & _CPMDIO_NOPHY) /*MJH+030805*/
8971 + /* No Phy condition, always linked */
8972 + HalDev->Linked = 1;
8973 + HalDev->EmacSpeed = 1;
8974 + HalDev->EmacDuplex = 1;
8975 + HalDev->PhyNum = 0xFFFFFFFF; /* No Phy Num */
8976 + CPMAC_MACCONTROL(base) |= FULLDUPLEX; /*MJH+030909*/
8977 + osfuncStateChange();
8981 + if(HalDev->MacControl & CTRL_LOOPBACK) /* Loopback Set */
8983 + HalDev->Linked = 1;
8987 + if (HalDev->MdioConnect & _CPMDIO_LOOPBK)
8989 + HalDev->Linked = cpMacMdioGetLoopback(HalDev->PhyDev);
8993 + HalDev->Linked = cpMacMdioGetLinked(HalDev->PhyDev);
8995 + if (HalDev->Linked)
8997 + /* Retreive Duplex and Speed and the Phy Number */
8998 + if(HalDev->MdioConnect & _CPMDIO_LOOPBK)
8999 + HalDev->EmacDuplex = 1;
9001 + HalDev->EmacDuplex = cpMacMdioGetDuplex(PhyDev);
9002 + HalDev->EmacSpeed = cpMacMdioGetSpeed(PhyDev);
9003 + HalDev->PhyNum = cpMacMdioGetPhyNum(PhyDev);
9005 + if(HalDev->EmacDuplex)
9006 + CPMAC_MACCONTROL(base) |= FULLDUPLEX;
9008 + CPMAC_MACCONTROL(base) &= ~FULLDUPLEX;
9010 + dbgPrintf("%d: Phy= %d, Speed=%s, Duplex=%s\n",HalDev->inst,HalDev->PhyNum,(HalDev->EmacSpeed)?"100":"10",(HalDev->EmacDuplex)?"Full":"Half");
9013 + dbgPrintf("DuplexUpdate[%d]: MACCONTROL 0x%08X, %s\n", HalDev->inst, CPMAC_MACCONTROL(base),(HalDev->Linked)?"Linked":"Not Linked");
9015 +static void MdioSetPhyMode(HAL_DEVICE *HalDev)
9017 + unsigned int PhyMode;
9018 + /* Verify proper device state */
9019 + if (HalDev->State < enOpened)
9022 + PhyMode = NWAY_AUTO|NWAY_FD100|NWAY_HD100|NWAY_FD10|NWAY_HD10;
9025 + dbgPrintf("halSetPhyMode1: MdioConnect:%08X ,", HalDev->MdioConnect);
9026 + dbgPrintf("PhyMode:%08X Auto:%d, FD10:%d, HD10:%d, FD100:%d, HD100:%d\n", PhyMode,
9027 + PhyMode&NWAY_AUTO, PhyMode&NWAY_FD10, PhyMode&NWAY_HD10, PhyMode&NWAY_FD100,
9028 + PhyMode&NWAY_HD100);
9032 + if ( HalDev->MdioConnect & _CPMDIO_NEG_OFF) /* ~RC3.01 */
9033 + PhyMode &= ~(NWAY_AUTO); /* Disable Auto Neg */
9034 + if (!(HalDev->MdioConnect & _CPMDIO_HD))
9035 + PhyMode &= ~(NWAY_HD100|NWAY_HD10); /* Cannot support HD */
9036 + if (!(HalDev->MdioConnect & _CPMDIO_FD))
9037 + PhyMode &= ~(NWAY_FD100|NWAY_FD10); /* Cannot support FD */
9038 + if (!(HalDev->MdioConnect & _CPMDIO_10))
9039 + PhyMode &= ~(NWAY_HD10|NWAY_FD10); /* Cannot support 10 Mbs */
9040 + if (!(HalDev->MdioConnect & _CPMDIO_100))
9041 + PhyMode &= ~(NWAY_HD100|NWAY_FD100); /* Cannot support 100 Mbs */
9043 + if(HalDev->MdioConnect & _CPMDIO_AUTOMDIX) PhyMode |= NWAY_AUTOMDIX; /* Set AutoMdix */
9045 + if (HalDev->CpmacFrequency <= 50000000)
9046 + PhyMode &= ~(NWAY_FD100|NWAY_HD100); /* Cannot support 100 MBS */
9048 + dbgPrintf("halNeg: PhyMode[0x%08X] %d\n", HalDev->dev_base, PhyMode);
9052 + dbgPrintf("halSetPhyMode2: MdioConnect:%08X ,", HalDev->MdioConnect);
9053 + dbgPrintf("PhyMode:%08X Auto:%d, FD10:%d, HD10:%d, FD100:%d, HD100:%d\n", PhyMode,
9054 + PhyMode&NWAY_AUTO, PhyMode&NWAY_FD10, PhyMode&NWAY_HD10, PhyMode&NWAY_FD100,
9055 + PhyMode&NWAY_HD100);
9059 + cpMacMdioSetPhyMode(HalDev->PhyDev,PhyMode);
9060 + DuplexUpdate(HalDev);
9062 +static int StatsClear(HAL_DEVICE *HalDev)
9069 + pStats = pCPMAC_RXGOODFRAMES(HalDev->dev_base);
9070 + for (i=0;i<STATS_MAX;i++)
9072 + *(MEM_PTR)(pStats) = 0xFFFFFFFF;
9076 + return(EC_NO_ERRORS);
9078 +static void StatsDump(HAL_DEVICE *HalDev, void *Value)
9083 + ptrStats = pCPMAC_RXGOODFRAMES(HalDev->dev_base);
9084 + ptrValue = (bit32u*) Value;
9085 + for (i=0; i<STATS_MAX; i++)
9087 + *ptrValue = *ptrStats;
9090 + dbgPrintf("halStatsDump: Stat[%d:0x%08X] %d 0x%08X %d\n", i, ptrStats, *ptrStats, ptrValue, *ptrValue);
9097 +static void ConfigApply(HAL_DEVICE *HalDev)
9099 + CPMAC_RX_MAXLEN(HalDev->dev_base) = HalDev->RxMaxLen;
9100 + CPMAC_RX_FILTERLOWTHRESH(HalDev->dev_base) = HalDev->RxFilterLowThresh;
9101 + CPMAC_RX0_FLOWTHRESH(HalDev->dev_base) = HalDev->Rx0FlowThresh;
9102 + UnicastSet(HalDev);
9103 + MacAddressSet(HalDev);
9104 + RxMBP_EnableSet(HalDev);
9105 + MacHashSet(HalDev);
9106 + MacControlSet(HalDev);
9108 + dbgPrintf("ValuesUpdate[%d]: MBP_ENABLE 0x%08X\n", HalDev->inst, CPMAC_RX_MBP_ENABLE(HalDev->dev_base));
9110 +static int halStatus(HAL_DEVICE *HalDev)
9114 + if(HalDev->State < enOpened)
9115 + return (EC_CPMAC|EC_FUNC_STATUS|EC_VAL_INVALID_STATE); /*MJH+030805*/
9117 + /* No Phy Condition */
9118 + if(HalDev->MdioConnect & _CPMDIO_NOPHY) /*MJH+030805*/
9120 + /* No Phy condition, always linked */
9121 + status = HalDev->Linked;
9122 + status |= CPMAC_STATUS_LINK_DUPLEX;
9123 + status |= CPMAC_STATUS_LINK_SPEED;
9128 + if (HalDev->HostErr) /* Adapter Check */
9131 + status = CPMAC_STATUS_ADAPTER_CHECK;
9132 + if(HalDev->MacStatus & RX_HOST_ERR_CODE)
9134 + status |= CPMAC_STATUS_HOST_ERR_DIRECTION;
9135 + tmp = (HalDev->MacStatus & RX_HOST_ERR_CODE) >> 12; /* Code */
9136 + status |= (tmp << 9); /* Code */
9137 + tmp = (HalDev->MacStatus & RX_ERR_CH) >> 8; /* Channel */
9138 + status |= (tmp << 13);
9141 + if(HalDev->MacStatus & TX_HOST_ERR_CODE)
9143 + status |= CPMAC_STATUS_HOST_ERR_DIRECTION;
9144 + tmp = (HalDev->MacStatus & TX_HOST_ERR_CODE) >> 20; /* Code */
9145 + status |= (tmp << 9); /* Code */
9146 + tmp = (HalDev->MacStatus & TX_ERR_CH) >> 16; /* Channel */
9147 + status |= (tmp << 13);
9152 + status = HalDev->Linked;
9155 + status = CPMAC_STATUS_LINK;
9156 + if(cpMacMdioGetDuplex(HalDev->PhyDev))
9157 + status |= CPMAC_STATUS_LINK_DUPLEX;
9158 + if(cpMacMdioGetSpeed(HalDev->PhyDev))
9159 + status |= CPMAC_STATUS_LINK_SPEED;
9163 + dbgPrintf("[halStatus] Link Status is %d for 0x%X\n", status, HalDev->dev_base);
9166 +static int InfoAccess(HAL_DEVICE *HalDev, int Key, int Action, void *ParmValue)
9173 + /********************************************************************/
9177 + /********************************************************************/
9182 + *(const char **)ParmValue = pszVersion_CPMAC;
9188 + HalDev->debug = *(unsigned int *)ParmValue;
9196 + status = halStatus(HalDev);
9197 + *(int *)ParmValue = status;
9200 + /********************************************************************/
9202 + /* RX_MBP_ENABLE */
9204 + /********************************************************************/
9206 + case enRX_PASS_CRC :
9209 + UPDATE_RX_PASS_CRC(*(unsigned int *)ParmValue);
9213 + case enRX_QOS_EN :
9216 + UPDATE_RX_QOS_EN(*(unsigned int *)ParmValue);
9220 + case enRX_NO_CHAIN :
9223 + UPDATE_RX_NO_CHAIN(*(unsigned int *)ParmValue);
9227 + case enRX_CMF_EN :
9230 + UPDATE_RX_CMF_EN(*(unsigned int *)ParmValue);
9234 + case enRX_CSF_EN :
9237 + UPDATE_RX_CSF_EN(*(unsigned int *)ParmValue);
9241 + case enRX_CEF_EN :
9244 + UPDATE_RX_CEF_EN(*(unsigned int *)ParmValue);
9248 + case enRX_CAF_EN :
9251 + UPDATE_RX_CAF_EN(*(unsigned int *)ParmValue);
9255 + case enRX_PROM_CH :
9258 + UPDATE_RX_PROM_CH(*(unsigned int *)ParmValue);
9262 + case enRX_BROAD_EN :
9265 + UPDATE_RX_BROAD_EN(*(unsigned int *)ParmValue);
9269 + case enRX_BROAD_CH :
9272 + UPDATE_RX_BROAD_CH(*(unsigned int *)ParmValue);
9276 + case enRX_MULT_EN :
9279 + UPDATE_RX_MULT_EN(*(unsigned int *)ParmValue);
9283 + case enRX_MULT_CH :
9286 + UPDATE_RX_MULT_CH(*(unsigned int *)ParmValue);
9291 + /********************************************************************/
9295 + /********************************************************************/
9300 + UPDATE_TX_PTYPE(*(unsigned int *)ParmValue);
9307 + UPDATE_TX_PACE(*(unsigned int *)ParmValue);
9311 + case enTX_FLOW_EN :
9314 + UPDATE_TX_FLOW_EN(*(unsigned int *)ParmValue);
9318 + case enRX_FLOW_EN :
9321 + UPDATE_RX_FLOW_EN(*(unsigned int *)ParmValue);
9326 + case enCTRL_LOOPBACK :
9329 + UPDATE_CTRL_LOOPBACK(*(unsigned int *)ParmValue);
9333 + /********************************************************************/
9335 + /* RX_UNICAST_SET */
9337 + /********************************************************************/
9339 + case enRX_UNICAST_SET :
9342 + HalDev->RxUnicastSet |= (1 << *(unsigned int *)ParmValue);
9343 + HalDev->RxUnicastClear &= ~(1 << *(unsigned int *)ParmValue);
9347 + case enRX_UNICAST_CLEAR :
9350 + HalDev->RxUnicastClear |= (1 << *(unsigned int *)ParmValue);
9351 + HalDev->RxUnicastSet &= ~(1 << *(unsigned int *)ParmValue);
9356 + case enRX_MAXLEN :
9359 + HalDev->RxMaxLen = *(unsigned int *)ParmValue;
9364 + case enRX_FILTERLOWTHRESH :
9367 + HalDev->RxFilterLowThresh = *(unsigned int *)ParmValue;
9371 + case enRX0_FLOWTHRESH :
9374 + HalDev->Rx0FlowThresh = *(unsigned int *)ParmValue;
9378 + /********************************************************************/
9380 + /* RX_MULTICAST */
9382 + /********************************************************************/
9384 + case enRX_MULTICAST :
9386 + case enRX_MULTI_SINGLE :
9390 + bit8u *MacAddress;
9391 + MacAddress = (bit8u *) ParmValue;
9392 + dbgPrintf("CPMAC[%X]: MacAddress '", HalDev->dev_base);
9393 + for (tmpi=0; tmpi<6; tmpi++)
9394 + dbgPrintf("%02X:", MacAddress[tmpi]);
9397 + if(Action==enCLEAR)
9399 + HashDel(HalDev, ParmValue);
9405 + HashAdd(HalDev, ParmValue);
9409 + case enRX_MULTI_ALL :
9410 + if(Action==enCLEAR)
9412 + HalDev->MacHash1 = 0;
9413 + HalDev->MacHash2 = 0;
9419 + HalDev->MacHash1 = 0xFFFFFFFF;
9420 + HalDev->MacHash2 = 0xFFFFFFFF;
9425 + /********************************************************************/
9429 + /********************************************************************/
9431 + case enMdioConnect :
9434 + HalDev->MdioConnect = *(unsigned int *)ParmValue;
9435 + MdioSetPhyMode(HalDev);
9439 + *(unsigned int *)ParmValue = HalDev->MdioConnect;
9444 + /********************************************************************/
9448 + /********************************************************************/
9449 + case enStatsClear :
9450 + StatsClear(HalDev);
9452 + case enStatsDump :
9455 + StatsDump(HalDev, ParmValue);
9463 + StatsGet(HalDev, ParmValue, 1);
9470 + StatsGet(HalDev, ParmValue, 2);
9476 + StatsGet(HalDev, ParmValue, 3);
9482 + StatsGet(HalDev, ParmValue, 4);
9489 + rc = EC_CPMAC|EC_FUNC_OPTIONS|EC_VAL_KEY_NOT_FOUND;
9493 + /* Verify proper device state */
9494 + if (HalDev->State == enOpened)
9498 + ConfigApply(HalDev);
9506 +static const char pszStats[] = "Stats;";
9508 +static int halControl(HAL_DEVICE *HalDev, const char *pszKey, const char *pszAction, void *Value)
9516 +#ifdef __CPHAL_DEBUG
9519 + dbgPrintf("\nhalControl-HalDev:%08X,Action:%s,Key:%s\n", (bit32u)HalDev, pszAction, pszKey);
9523 + /* 23Aug04 - BCIL needs to set Mac Address */
9524 + if(HalDev->OsFunc->Strcmpi(pszKey, pszMacAddr) == 0)
9527 + if(HalDev->OsFunc->Strcmpi(pszAction, hcSet) == 0)
9529 + unsigned char *MacAddr;
9530 + MacAddr = (unsigned char *) Value;
9531 + MacAddressSave(HalDev, MacAddr);
9532 + MacAddressSet(HalDev);
9541 + if(HalDev->OsFunc->Strcmpi(pszKey, hcLinked) == 0)
9544 + if(HalDev->OsFunc->Strcmpi(pszAction, hcSet) == 0)
9546 + HalDev->Linked = *(int *)Value;
9555 + if(HalDev->OsFunc->Strcmpi(pszKey, "TxIntDisable") == 0)
9558 + if(HalDev->OsFunc->Strcmpi(pszAction, hcSet) == 0)
9560 + HalDev->TxIntDisable = *(int *)Value;
9561 + if(HalDev->TxIntDisable && (HalDev->State == enOpened))
9563 + /* if Opened and need TxIntDisabled, clear Ints for Channel 0 */
9564 + CPMAC_TX_INTMASK_CLEAR(HalDev->dev_base) = 1;
9574 + if(HalDev->OsFunc->Strcmpi(pszKey, hcPhyAccess) == 0)
9581 + ValueIn = *(bit32u*) Value;
9584 + /* Cannot access MII if not opended */
9586 + if(HalDev->State < enOpened)
9589 + if(HalDev->OsFunc->Strcmpi(pszAction, hcGet) == 0)
9592 + PhyNum = (ValueIn & 0x1F); /* Phynum 0-32 */
9593 + RegAddr = (ValueIn >> 5) & 0xFF; /* RegAddr in upper 11 bits */
9595 + *(bit32u*)Value = _mdioUserAccessRead(HalDev->PhyDev, RegAddr, PhyNum);
9598 + } /* end of hcGet */
9601 + if(HalDev->OsFunc->Strcmpi(pszAction, hcSet) == 0)
9603 + PhyNum = (ValueIn & 0x1F); /* Phynum 0-32 */
9604 + RegAddr = (ValueIn >> 5) & 0xFF; /* RegAddr in upper 11 bits of lower 16 */
9606 + Data = ValueIn >> 16; /* Data store in upper 16 bits */
9608 + _mdioUserAccessWrite(HalDev->PhyDev, RegAddr, PhyNum, Data);
9611 + } /* End of hcPhyAccess */
9613 + if(HalDev->OsFunc->Strcmpi(pszKey, hcPhyNum) == 0)
9616 + if(!HalDev->Linked)
9617 + return(-1); /* if not linked the no Phy Connected */
9618 + if(HalDev->OsFunc->Strcmpi(pszAction, hcGet) == 0)
9620 + *(int *)Value = HalDev->PhyNum;
9625 + if(HalDev->OsFunc->Strcmpi(pszKey, hcCpmacSize) == 0)
9628 + if(HalDev->OsFunc->Strcmpi(pszAction, hcGet) == 0)
9630 + *(bit32u *)Value = HalDev->CpmacSize;
9635 + if(HalDev->OsFunc->Strcmpi(pszKey, hcCpmacBase) == 0)
9638 + if(HalDev->OsFunc->Strcmpi(pszAction, hcGet) == 0)
9640 + *(int *)Value = HalDev->dev_base;
9645 + if(HalDev->OsFunc->Strcmpi(pszKey, hcFullDuplex) == 0)
9648 + if(HalDev->OsFunc->Strcmpi(pszAction, hcSet) == 0)
9650 + UPDATE_FULLDUPLEX(*(unsigned int *)Value);
9651 + if(HalDev->State == enOpened)
9652 + ConfigApply(HalDev);
9659 + if(HalDev->OsFunc->Strcmpi(pszKey, pszDebug) == 0)
9662 + if(HalDev->OsFunc->Strcmpi(pszAction, hcSet) == 0)
9665 + HalDev->debug = *(int *)Value;
9669 + if(HalDev->OsFunc->Strcmpi(pszKey, hcMaxFrags) == 0)
9672 + if(HalDev->OsFunc->Strcmpi(pszAction, hcSet) == 0)
9676 + if ((*(int *)Value) > 0)
9677 + HalDev->MaxFrags = *(int *)Value;
9679 + rc = (EC_AAL5|EC_FUNC_CONTROL|EC_VAL_INVALID_VALUE);
9682 + if (HalDev->OsFunc->Strcmpi(pszAction, hcGet) == 0)
9686 + *(int *)Value = HalDev->MaxFrags;
9690 + if(HalDev->OsFunc->Strstr(pszKey, pszStats) != 0)
9693 + if(HalDev->OsFunc->Strcmpi(pszAction, hcGet) == 0)
9697 + char *TmpKey = (char *)pszKey;
9699 + TmpKey += HalDev->OsFunc->Strlen(pszStats);
9700 + Level = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
9702 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
9705 +#ifdef __CPHAL_DEBUG
9708 + dbgPrintf("\nhalControl-HalDev:%08X, Level:%d, Ch:%d\n", (bit32u)HalDev, Level, Ch);
9711 + StatsGet(HalDev, (void **)Value, Level, Ch, 0);
9717 + if(HalDev->OsFunc->Strcmpi(pszAction, hcSet) == 0)
9720 + if(HalDev->OsFunc->Strcmpi(pszAction, hcClear) == 0)
9723 + if(HalDev->OsFunc->Strcmpi(pszAction, hcGet) == 0)
9730 + for(i=enCommonStart+1;i<enCommonEnd;i++)
9732 + if(HalDev->OsFunc->Strcmpi(KeyCommon[i].strKey, pszKey)==0)
9734 + rc = InfoAccess(HalDev, KeyCommon[i].enKey, Action, Value);
9737 + for(i=enCpmacStart+1;i<enCpmacEnd;i++)
9739 + if(HalDev->OsFunc->Strcmpi(KeyCpmac[i].strKey, pszKey)==0)
9741 + rc = InfoAccess(HalDev, KeyCpmac[i].enKey, Action, Value);
9745 + if (KeyFound == 0)
9746 + rc = (EC_MODULE|EC_FUNC_CONTROL|EC_VAL_KEY_NOT_FOUND);
9748 + if (ActionFound == 0)
9749 + rc = (EC_MODULE|EC_FUNC_CONTROL|EC_VAL_ACTION_NOT_FOUND);
9754 +static bit32u ConfigGet(HAL_DEVICE *HalDev)
9756 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
9757 + char *DeviceInfo = HalDev->DeviceInfo;
9758 + int i = HalDev->inst;
9762 + /* get the configuration parameters common to all modules */
9763 + Error = ConfigGetCommon(HalDev);
9764 + if (Error) return (EC_CPMAC|Error);
9766 + if (HalDev->debug)
9768 + dbgPrintf("ConfigGet: haldev:0x%08X inst:%d base:0x%08X reset:%d\n", (bit32u) &HalDev, HalDev->inst, HalDev->dev_base, HalDev->ResetBit);
9772 + Error = OsFunc->DeviceFindParmUint(DeviceInfo, pszMdioConnect,&Value); /*MJH+030805*/
9773 + if(!Error) HalDev->MdioConnect = Value;
9775 + Error = OsFunc->DeviceFindParmUint(DeviceInfo, "PhyMask",&Value);
9776 + if(!Error) HalDev->PhyMask = Value;
9778 + Error = OsFunc->DeviceFindParmUint(DeviceInfo, "MLink",&Value);
9779 + if(!Error) HalDev->MLinkMask = Value;
9781 + Error = OsFunc->DeviceFindParmUint(DeviceInfo, hcMdixMask, &Value);
9783 + HalDev->MdixMask = Value;
9785 + HalDev->MdixMask = 0;
9787 + Error = OsFunc->DeviceFindParmUint(DeviceInfo, hcSize, &Value); /*MJH+030425*/
9788 + if(!Error) HalDev->CpmacSize = Value;
9790 + for(i=enCommonStart+1;i<enCommonEnd;i++)
9792 + Error = OsFunc->DeviceFindParmUint(DeviceInfo, KeyCommon[i].strKey, (bit32u*)&Value);
9795 + InfoAccess(HalDev, KeyCommon[i].enKey, enSET, (bit32u*)&Value);
9798 + for(i=enCpmacStart+1;i<enCpmacEnd;i++)
9800 + Error = OsFunc->DeviceFindParmUint(DeviceInfo, KeyCpmac[i].strKey, (bit32u*)&Value);
9803 + InfoAccess(HalDev, KeyCpmac[i].enKey, enSET, (bit32u*)&Value);
9806 + return (EC_NO_ERRORS);
9810 +static void ConfigInit(HAL_DEVICE *HalDev)
9812 + if(HalDev->inst == 0)
9814 + HalDev->dev_base = 0xA8610000;
9815 + HalDev->ResetBit = 17;
9816 + HalDev->interrupt = 19;
9817 + HalDev->MLinkMask = 0;
9818 + HalDev->PhyMask = 0xAAAAAAAA;
9822 + HalDev->dev_base = 0xA8612800;
9823 + HalDev->ResetBit = 21;
9824 + HalDev->interrupt = 33; /*~RC3.02*/
9825 + HalDev->MLinkMask = 0;
9826 + HalDev->PhyMask = 0x55555555;
9828 + HalDev->RxMaxLen = 1518;
9829 + HalDev->MaxFrags = 2;
9830 + HalDev->MdioConnect = _CPMDIO_HD|_CPMDIO_FD|_CPMDIO_10|_CPMDIO_100|_CPMDIO_AUTOMDIX;
9831 + HalDev->debug=0xFFFFFFFF;
9834 +/* Shuts down the EMAC device
9836 + *@param HalDev EMAC instance. This was returned by halOpen()
9837 + *@param mode Indicates actions to tak on close.
9839 + *PARTIAL - Disable EMAC
9841 + *FULL - Disable EMAC and call OS to free all allocated memory
9849 +static int halInit( HAL_DEVICE *HalDev)
9853 + /* Verify proper device state */
9854 + if (HalDev->State != enDevFound)
9855 + return(EC_CPMAC|EC_FUNC_HAL_INIT|EC_VAL_INVALID_STATE);
9857 + /* Configure HAL defaults */
9858 + ConfigInit(HalDev);
9860 + /* Retrieve HAL configuration parameters from data store */
9861 + rc = ConfigGet(HalDev);
9862 + if (rc) return (rc);
9864 + /* Updated 030403*/
9865 + rc = HalDev->OsFunc->Control(HalDev->OsDev, hcCpuFrequency, hcGet, &HalDev->CpuFrequency); /*MJH+030403*/
9867 + HalDev->CpuFrequency = 20000000; /*20 Mhz default */ /*MJH+030403*/
9869 + rc = HalDev->OsFunc->Control(HalDev->OsDev, hcCpmacFrequency, hcGet, &HalDev->CpmacFrequency); /*MJH+030331*/
9871 + HalDev->CpmacFrequency = HalDev->CpuFrequency/2; /*MJH~030404*/
9873 + rc = HalDev->OsFunc->Control(HalDev->OsDev, hcMdioBusFrequency, hcGet, &HalDev->MdioBusFrequency); /*MJH+030402*/
9875 + HalDev->MdioBusFrequency = HalDev->CpmacFrequency;
9877 + rc = HalDev->OsFunc->Control(HalDev->OsDev, hcMdioClockFrequency, hcGet, &HalDev->MdioClockFrequency); /*MJH+030402*/
9879 + HalDev->MdioClockFrequency = 2200000; /* 2.2 Mhz PITS #14 */
9882 + /* update device state */
9883 + HalDev->State = enInitialized;
9885 + /* initialize statistics */
9886 + StatsInit(HalDev); /* +RC3.02 */
9889 + StatsTable3[0].StatPtr = &HalDev->ChData[0].RxBufSize;
9890 + StatsTable3[1].StatPtr = &HalDev->ChData[0].RxBufferOffset;
9891 + StatsTable3[2].StatPtr = &HalDev->ChData[0].RxNumBuffers;
9892 + StatsTable3[3].StatPtr = &HalDev->ChData[0].RxServiceMax;
9893 + StatsTable3[4].StatPtr = &HalDev->ChData[0].TxNumBuffers;
9894 + StatsTable3[5].StatPtr = &HalDev->ChData[0].TxNumQueues;
9895 + StatsTable3[6].StatPtr = &HalDev->ChData[0].TxServiceMax;
9898 + return(EC_NO_ERRORS);
9900 +static int halProbe(HAL_DEVICE *HalDev)
9902 + int inst = HalDev->inst;
9903 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
9906 + if (HalDev->State != enConnected)
9907 + return (EC_CPMAC|EC_FUNC_PROBE|EC_VAL_INVALID_STATE);
9909 + if(HalDev->debug) dbgPrintf("halProbe: %d ",inst);
9911 + error_code = OsFunc->DeviceFindInfo(inst,"cpmac",&HalDev->DeviceInfo);
9914 + return (EC_CPMAC|EC_FUNC_PROBE|EC_VAL_DEVICE_NOT_FOUND );
9916 + /* Set device state to DevFound */
9917 + HalDev->State = enDevFound;
9918 + return(EC_NO_ERRORS);
9920 +static void ChannelConfigInit(HAL_DEVICE *HalDev, CHANNEL_INFO *HalChn)
9922 + int Ch = HalChn->Channel;
9923 + int Direction = HalChn->Direction;
9924 + int nTxBuffers = 256;
9926 + if (Direction == DIRECTION_TX)
9928 + HalDev->ChData[Ch].TxNumBuffers = nTxBuffers;
9929 + HalDev->ChData[Ch].TxNumQueues = 1;
9930 + HalDev->ChData[Ch].TxServiceMax = nTxBuffers/3;
9931 + HalDev->TxIntThreshold[Ch] = HalDev->ChData[Ch].TxServiceMax;
9932 + HalDev->TxIntThresholdMaster[Ch] = HalDev->TxIntThreshold[Ch];
9935 + if (Direction == DIRECTION_RX)
9937 + HalDev->ChData[Ch].RxNumBuffers = nTxBuffers*2;
9938 + HalDev->ChData[Ch].RxBufferOffset = 0;
9939 + HalDev->ChData[Ch].RxBufSize = 1518;
9940 + HalDev->ChData[Ch].RxServiceMax = nTxBuffers/3; /*Not a typo*/
9943 +static int ChannelConfigApply(HAL_DEVICE *HalDev, CHANNEL_INFO *HalChn)
9945 + int Ch = HalChn->Channel;
9946 + int Direction = HalChn->Direction;
9950 + 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);
9954 + if (Direction == DIRECTION_TX)
9956 + if (HalDev->ChIsOpen[Ch][Direction] == TRUE)
9958 + return(EC_CPMAC|EC_FUNC_CHSETUP|EC_VAL_TX_CH_ALREADY_OPEN);
9961 + /* Initialize Queue Data */
9962 + HalDev->TxActQueueHead[Ch][0] = 0;
9963 + HalDev->TxActQueueCount[Ch][0] = 0;
9964 + HalDev->TxActive[Ch][0] = FALSE;
9966 + /* Need to use a macro that takes channel as input */
9967 + CPMAC_TX0_HDP(HalDev->dev_base)=0;
9969 + /* Initialize buffer memory for the channel */
9970 + InitTcb(HalDev, Ch);
9972 + if(!HalDev->TxIntDisable)
9973 + CPMAC_TX_INTMASK_SET(HalDev->dev_base) = (1<<Ch); /* GSG 11/22 */
9977 + if (HalDev->ChIsOpen[Ch][Direction] == TRUE)
9979 + return(EC_CPMAC|EC_FUNC_CHSETUP|EC_VAL_RX_CH_ALREADY_OPEN);
9982 + /* Initialize Queue Data */
9983 + HalDev->RxActQueueHead[Ch] = 0;
9984 + HalDev->RxActQueueCount[Ch] = 0;
9986 + HalDev->RxActive[Ch] = FALSE;
9988 + /* Need to use a macro that takes channel as input */
9989 + CPMAC_RX0_HDP(HalDev->dev_base)=0;
9991 + /* Initialize buffer memory for the channel */
9992 + InitRcb(HalDev, Ch);
9994 + CPMAC_RX_INTMASK_SET(HalDev->dev_base) = (1<<Ch); /* GSG 11/22 */
9997 + HalDev->ChIsOpen[Ch][Direction] = TRUE; /* channel is open */
9999 + return (EC_NO_ERRORS);
10003 + * Retrieves channel parameters from configuration file. Any parameters
10004 + * which are not found are ignored, and the HAL default value will apply,
10005 + * unless a new value is given through the channel structure in the call
10006 + * to ChannelSetup.
10008 +static int ChannelConfigGet(HAL_DEVICE *HalDev, CHANNEL_INFO *HalChn)
10010 + int Ch = HalChn->Channel;
10011 + int Direction = HalChn->Direction;
10012 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
10013 + unsigned int rc, Value;
10016 + rc=OsFunc->DeviceFindParmValue(HalDev->DeviceInfo, channel_names[Ch], &ChInfo);
10017 + /* Do not fail if Channel Info not available for RC2 */
10018 + if (rc) return(0);
10019 +/* if (rc) return(EC_CPMAC|EC_FUNC_CHSETUP|EC_VAL_CH_INFO_NOT_FOUND);*/
10021 + /* i don't care if a value is not found because they are optional */
10022 + if(Direction == DIRECTION_TX)
10024 + rc=OsFunc->DeviceFindParmUint(ChInfo, "TxNumBuffers", &Value);
10025 + if (!rc) HalDev->ChData[Ch].TxNumBuffers = Value;
10027 + /*rc=OsFunc->DeviceFindParmUint(ChInfo, "TxNumQueues", &Value);*/ /*MJH-030329*/
10028 + /*if (!rc) HalDev->ChData[Ch].TxNumQueues = Value;*/ /*MJH-030329*/
10030 + rc=OsFunc->DeviceFindParmUint(ChInfo, "TxServiceMax", &Value);
10033 + HalDev->ChData[Ch].TxServiceMax = Value;
10034 + HalDev->TxIntThreshold[Ch] = HalDev->ChData[Ch].TxServiceMax;
10035 + HalDev->TxIntThresholdMaster[Ch] = HalDev->TxIntThreshold[Ch];
10038 + if(Direction == DIRECTION_RX)
10040 + rc=OsFunc->DeviceFindParmUint(ChInfo, "RxNumBuffers", &Value);
10041 + if (!rc) HalDev->ChData[Ch].RxNumBuffers = Value;
10043 + rc=OsFunc->DeviceFindParmUint(ChInfo, "RxBufferOffset", &Value);
10044 + if (!rc) HalDev->ChData[Ch].RxBufferOffset = Value;
10046 + rc=OsFunc->DeviceFindParmUint(ChInfo, "RxBufSize", &Value);
10047 + if (!rc) HalDev->ChData[Ch].RxBufSize = Value;
10049 + rc=OsFunc->DeviceFindParmUint(ChInfo, "RxServiceMax", &Value);
10050 + if (!rc) HalDev->ChData[Ch].RxServiceMax = Value;
10052 + return (EC_NO_ERRORS);
10054 +#define ChannelUpdate(Field) if(HalChn->Field != 0xFFFFFFFF) HalDev->ChData[Ch].Field = HalChn->Field
10056 +static void ChannelConfigUpdate(HAL_DEVICE *HalDev, CHANNEL_INFO *HalChn)
10058 + int Ch = HalChn->Channel;
10059 + int Direction = HalChn->Direction;
10060 +#ifdef __CPHAL_DEBUG
10063 + dbgPrintf("\nChnUpd-HalDev:%08X,Chn:%d:%d\n", (bit32u)HalDev, Ch, Direction); osfuncSioFlush();
10066 + if (Direction == DIRECTION_TX)
10068 + ChannelUpdate(TxNumBuffers);
10069 + /*ChannelUpdate(TxNumQueues);*/ /*MJH~030329*/
10070 + ChannelUpdate(TxServiceMax);
10071 + HalDev->TxIntThreshold[Ch] = HalDev->ChData[Ch].TxServiceMax;
10072 + HalDev->TxIntThresholdMaster[Ch] = HalDev->TxIntThreshold[Ch];
10075 + if (Direction == DIRECTION_RX)
10077 + ChannelUpdate(RxBufferOffset);
10078 + ChannelUpdate(RxBufSize);
10079 + ChannelUpdate(RxNumBuffers);
10080 + ChannelUpdate(RxServiceMax);
10081 +#ifdef __CPHAL_DEBUG
10084 + dbgPrintf("\nRxNumBuffers %d\n",HalChn->RxNumBuffers); osfuncSioFlush();
10089 +static int halChannelSetup(HAL_DEVICE *HalDev, CHANNEL_INFO *HalChn, OS_SETUP *OsSetup)
10095 + /* Verify proper device state */
10096 + if (HalDev->State < enInitialized)
10097 + return (EC_CPMAC|EC_FUNC_CHSETUP|EC_VAL_INVALID_STATE);
10099 + /* We require the channel structure to be passed, even if it only contains
10100 + the channel number */
10101 + if (HalChn == NULL)
10103 + return(EC_CPMAC|EC_FUNC_CHSETUP|EC_VAL_NULL_CH_STRUCT);
10106 + Ch = HalChn->Channel;
10107 + Direction = HalChn->Direction;
10109 + /* This should check on Maximum Channels for RX or TX,
10110 + they might be different Mick 021124 */
10111 + if ((Ch < 0) || (Ch > (MAX_CHAN-1)))
10113 + return(EC_CPMAC|EC_FUNC_CHSETUP|EC_VAL_INVALID_CH);
10116 + /* if channel is already open, this call is invalid */
10117 + if (HalDev->ChIsOpen[Ch][Direction] == TRUE)
10119 + return(EC_CPMAC|EC_FUNC_CHSETUP|EC_VAL_CH_ALREADY_OPEN);
10122 + /* channel is closed, but might be setup. If so, reopen the hardware channel. */
10123 + if (HalDev->ChIsSetup[Ch][Direction] == FALSE)
10125 + /* Setup channel configuration */
10126 + HalDev->ChData[Ch].Channel = Ch;
10128 + /* Store OS_SETUP */
10129 + HalDev->ChData[Ch].OsSetup = OsSetup;
10132 + Set Default Values
10133 + Update with options.conf
10134 + Apply driver updates
10136 + ChannelConfigInit(HalDev, HalChn);
10137 + ChannelConfigGet(HalDev, HalChn);
10138 + ChannelConfigUpdate(HalDev, HalChn);
10140 + /* cppi.c needs to use Rx/TxServiceMax */
10141 + HalDev->BuffersServicedMax = 169; /* TEMP */
10143 + HalDev->ChIsSetup[Ch][Direction] = TRUE;
10146 + rc = EC_NO_ERRORS;
10148 + /* If the hardware has been opened (is out of reset), then configure the channel
10149 + in the hardware. NOTE: ChannelConfigApply calls the CPSAR ChannelSetup()! */
10150 + if (HalDev->State == enOpened)
10152 + rc = ChannelConfigApply(HalDev, HalChn);
10159 +static int miiInfoGet(HAL_DEVICE *HalDev, bit32u *miiBaseAddress, bit32u *miiResetBit)
10162 + void *DeviceInfo;
10163 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
10165 + /* Only one instance of cpmdio */
10166 + rc = OsFunc->DeviceFindInfo(0,"cpmdio",&DeviceInfo); /*~RC3.02*/
10169 + return (EC_DEV_CPMDIO|EC_FUNC_OPEN|EC_VAL_DEVICE_NOT_FOUND );
10171 + rc = OsFunc->DeviceFindParmUint(DeviceInfo, "base",miiBaseAddress);
10173 + rc=EC_DEV_CPMDIO|EC_FUNC_OPEN|EC_VAL_NO_BASE;
10175 + rc = OsFunc->DeviceFindParmUint(DeviceInfo, "reset_bit",miiResetBit);
10177 + rc=EC_DEV_CPMDIO|EC_FUNC_OPEN|EC_VAL_NO_BASE;
10180 + /* See if need to make mdio functional in GPIO */
10181 + gpioCheck(HalDev, DeviceInfo);
10184 + dbgPrintf("miiBase: 0x%08X %u\n", *miiBaseAddress, *miiResetBit);
10187 +static void ephyCheck(HAL_DEVICE *HalDev)
10190 + void *DeviceInfo;
10193 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
10195 + rc = OsFunc->DeviceFindInfo(0,"ephy",&DeviceInfo);
10198 + rc = OsFunc->DeviceFindParmUint(DeviceInfo, "mii_phy",&mii_phy);
10201 + rc = OsFunc->DeviceFindParmUint(DeviceInfo, "reset_bit",&reset_bit);
10204 + if (HalDev->PhyMask & (1 << mii_phy))
10206 + *(volatile bit32u *)(HalDev->ResetBase) |= (1 << reset_bit); /*+RC3.02*/
10207 + resetWait(HalDev);
10210 +static void AutoNegotiate(HAL_DEVICE *HalDev)
10213 + bit32u ModID, RevMaj, RevMin;
10214 + PHY_DEVICE *PhyDev;
10215 + bit32u miiBaseAddress;
10216 + bit32u miiResetBit;
10218 + /* Verify proper device state */
10219 + if (HalDev->State < enOpened)
10222 + miiInfoGet(HalDev, &miiBaseAddress, &miiResetBit);
10224 + cpMacMdioGetVer(miiBaseAddress, &ModID, &RevMaj, &RevMin);
10225 + if(HalDev->debug)
10226 + dbgPrintf("Mdio Module Id %d, Version %d.%d\n", ModID, RevMaj, RevMin);
10228 + size = cpMacMdioGetPhyDevSize();
10229 + PhyDev = (PHY_DEVICE *) HalDev->OsFunc->Malloc( size );
10231 + HalDev->PhyDev = PhyDev;
10233 + ephyCheck(HalDev);
10235 + cpMacMdioInit( PhyDev, miiBaseAddress, HalDev->inst, HalDev->PhyMask, HalDev->MLinkMask, HalDev->MdixMask, HalDev->ResetBase, miiResetBit, HalDev->MdioBusFrequency, HalDev->MdioClockFrequency, HalDev->debug, HalDev); /*MJH~030402*/
10236 + MdioSetPhyMode(HalDev);
10240 +static int halOpen(HAL_DEVICE *HalDev)
10242 + unsigned char *MacAddr;
10247 + if (HalDev->debug)
10249 + dbgPrintf("halOpen: haldev:0x%08X inst:%d base:0x%08X reset:%d\n", (bit32u) &HalDev, HalDev->inst, HalDev->dev_base, HalDev->ResetBit);
10250 + osfuncSioFlush();
10253 + /* Verify proper device state */
10254 + if (HalDev->State < enInitialized)
10255 + return (EC_CPMAC|EC_FUNC_OPEN|EC_VAL_INVALID_STATE);
10258 + /* take CPMAC out of reset - GSG 11/20*/
10259 + if ((VOLATILE32(HalDev->ResetBase) & (1 << HalDev->ResetBit)) != 0)
10261 + /* perform normal close duties */
10262 + CPMAC_MACCONTROL(HalDev->dev_base) &= ~MII_EN;
10263 + CPMAC_TX_CONTROL(HalDev->dev_base) &= ~TX_EN;
10264 + CPMAC_RX_CONTROL(HalDev->dev_base) &= ~RX_EN;
10266 + /* disable interrupt masks */
10267 + CPMAC_TX_INTMASK_CLEAR(HalDev->dev_base) = 0xFF;
10268 + CPMAC_RX_INTMASK_CLEAR(HalDev->dev_base) = 0xFF;
10271 + /* take CPMAC out of reset */
10272 + *(volatile bit32u *)(HalDev->ResetBase) &= ~(1 << HalDev->ResetBit);
10273 + resetWait(HalDev);
10274 + *(volatile bit32u *)(HalDev->ResetBase) |= (1 << HalDev->ResetBit);
10275 + resetWait(HalDev);
10277 + /* After Reset clear the Transmit and Receive DMA Head Descriptor Pointers */
10279 + CPMAC_TX0_HDP(HalDev->dev_base)=0;
10280 + CPMAC_TX1_HDP(HalDev->dev_base)=0;
10281 + CPMAC_TX2_HDP(HalDev->dev_base)=0;
10282 + CPMAC_TX3_HDP(HalDev->dev_base)=0;
10283 + CPMAC_TX4_HDP(HalDev->dev_base)=0;
10284 + CPMAC_TX5_HDP(HalDev->dev_base)=0;
10285 + CPMAC_TX6_HDP(HalDev->dev_base)=0;
10286 + CPMAC_TX7_HDP(HalDev->dev_base)=0;
10290 + CPMAC_RX0_HDP(HalDev->dev_base) = 0;
10291 + CPMAC_RX1_HDP(HalDev->dev_base) = 0;
10292 + CPMAC_RX2_HDP(HalDev->dev_base) = 0;
10293 + CPMAC_RX3_HDP(HalDev->dev_base) = 0;
10294 + CPMAC_RX4_HDP(HalDev->dev_base) = 0;
10295 + CPMAC_RX5_HDP(HalDev->dev_base) = 0;
10296 + CPMAC_RX6_HDP(HalDev->dev_base) = 0;
10297 + CPMAC_RX7_HDP(HalDev->dev_base) = 0;
10299 + CPMAC_RX_BUFFER_OFFSET(HalDev->dev_base) = 0;
10301 + /* Init Tx and Rx DMA */
10303 + CPMAC_TX_CONTROL(HalDev->dev_base) |= TX_EN;
10304 + CPMAC_RX_CONTROL(HalDev->dev_base) |= RX_EN;
10306 + CPMAC_MAC_INTMASK_SET(HalDev->dev_base) |=2; /* Enable Adaptercheck Ints */
10307 + HalDev->OsFunc->Control(HalDev->OsDev, pszMacAddr, hcGet, &MacAddr); /* GSG 11/22 */
10308 + MacAddressSave(HalDev, MacAddr);
10310 + HalDev->HostErr = 0; /* Clear Adapter Check indicator */
10311 + HalDev->State = enOpened; /* Change device state */
10313 + /* Start MDIO Negotiation */
10314 + AutoNegotiate(HalDev);
10316 + /* Enable the Os Timer */
10317 + Ticks = HalDev->CpuFrequency / 100; /* 10 milli-secs */ /*MJH~030402*/
10318 + HalDev->OsFunc->Control(HalDev->OsDev, pszTick, hcSet, &Ticks); /* GSG 11/22 */
10319 + HalDev->OsFunc->IsrRegister(HalDev->OsDev, halIsr, HalDev->interrupt);
10321 + /* GSG +030523 Malloc space for the Rx fraglist */
10322 + HalDev->fraglist = HalDev->OsFunc->Malloc(HalDev->MaxFrags * sizeof(FRAGLIST));
10324 + /* Any pre-open configuration */
10326 + /* For any channels that have been pre-initialized, set them up now */
10327 + /* Note : This loop should not use MAX_CHN, it should only
10328 + loop through Channels Setup, memory should not be reserved
10329 + until Channel is Setup
10331 + for(i=0; i<MAX_CHAN; i++) /* i loops through Channels */
10332 + for(j=0; j<2; j++) /* j loops through DIRECTION values, 0 and 1 */
10334 + if(HalDev->ChIsSetup[i][j]==TRUE) /* If the Channel and Direction have been Setup */
10335 + if(HalDev->ChIsOpen[i][j]==FALSE) /* but not opened, then Apply Values now */
10337 + CHANNEL_INFO HalChn;
10338 + HalChn.Channel = i;
10339 + HalChn.Direction = j;
10340 + rc = ChannelConfigApply(HalDev, &HalChn);
10341 + if(rc != EC_NO_ERRORS)
10344 + } /* End of looping through Channel/Direction */
10346 + ConfigApply(HalDev); /* Apply Configuration Values to Device */
10347 + CPMAC_MACCONTROL(HalDev->dev_base) |= MII_EN; /* MAC_EN */
10349 + dbgPrintf("[halOpen]MacControl:%08X\n", CPMAC_MACCONTROL(HalDev->dev_base));
10350 + return(EC_NO_ERRORS);
10353 +#define INT_PENDING (MAC_IN_VECTOR_TX_INT_OR | MAC_IN_VECTOR_RX_INT_OR | MAC_IN_VECTOR_HOST_INT)
10354 +static int halShutdown(HAL_DEVICE *HalDev)
10356 + int Ch, Queue; /*GSG+030514*/
10358 + /* Verify proper device state */
10359 + if (HalDev->State == enOpened)
10360 + halClose(HalDev, 3); /* GSG ~030429 */
10362 + /* Buffer/descriptor resources may still need to be freed if a Close
10363 + Mode 1 was performed prior to Shutdown - clean up here */ /*GSG+030514*/
10364 + for (Ch=0; Ch<MAX_CHAN; Ch++)
10366 + if (HalDev->RcbStart[Ch] != 0)
10367 + FreeRx(HalDev,Ch);
10369 + for(Queue=0; Queue<MAX_QUEUE; Queue++)
10371 + if (HalDev->TcbStart[Ch][Queue] != 0)
10372 + FreeTx(HalDev,Ch,Queue);
10376 + /* free the HalFunc */
10377 + HalDev->OsFunc->Free(HalDev->HalFuncPtr);
10379 + /* free the HAL device */
10380 + HalDev->OsFunc->Free(HalDev);
10382 + return(EC_NO_ERRORS);
10384 +int halIsr(HAL_DEVICE *HalDev, int *MorePackets)
10388 + int PacketsServiced=0;
10390 + int TxMorePackets=0;
10391 + int RxMorePackets=0;
10393 + /* Verify proper device state - important because a call prior to Open would
10394 + result in a lockup */
10395 + if (HalDev->State != enOpened)
10396 + return(EC_CPMAC|EC_FUNC_DEVICE_INT|EC_VAL_INVALID_STATE);
10398 + IntVec = CPMAC_MAC_IN_VECTOR(HalDev->dev_base);
10400 +#ifdef __CPHAL_DEBUG
10403 + dbgPrintf("\nhalIsr: inst %d, IntVec 0x%X\n", HalDev->inst, IntVec); osfuncSioFlush();/* GSG 11/22 */
10407 + HalDev->IntVec = IntVec;
10408 + if (IntVec & MAC_IN_VECTOR_TX_INT_OR)
10410 + int TxServiceMax=0; /* Compiler complains if not initialized */
10412 + Channel = (IntVec & 0x7);
10414 + if(HalDev->TxIntDisable)
10416 + CPMAC_TX_INTMASK_CLEAR(HalDev->dev_base) = (1<<Channel); /* Disable Interrupt for Channel */
10417 + TxServiceMax = HalDev->ChData[Channel].TxServiceMax;
10418 + HalDev->ChData[Channel].TxServiceMax = 10000; /* Need to service all packets in the Queue */
10421 + PacketsServiced |= TxInt(HalDev, Channel, 0, &TxMorePackets);
10423 + if(HalDev->TxIntDisable)
10424 + HalDev->ChData[Channel].TxServiceMax = TxServiceMax;
10427 + if (IntVec & MAC_IN_VECTOR_RX_INT_OR)
10429 + Channel = (IntVec >> 8) & 0x7;
10430 + Serviced = RxInt(HalDev, Channel, &RxMorePackets);
10431 + PacketsServiced |= (Serviced<<16);
10434 + if (IntVec & MAC_IN_VECTOR_HOST_INT)
10436 + /* Adaptercheck */
10437 + HalDev->HostErr = 1;
10438 + HalDev->MacStatus = CPMAC_MACSTATUS(HalDev->dev_base);
10439 + osfuncStateChange(); /*MJH+030328*/
10442 + dbgPrintf("Adaptercheck: %08x for base:%X\n",HalDev->MacStatus, (bit32u)HalDev->dev_base);
10443 + osfuncSioFlush();
10446 + *MorePackets = (TxMorePackets | RxMorePackets);
10447 + return (PacketsServiced);
10450 +int halPacketProcessEnd(HAL_DEVICE *HalDev)
10452 + int base = HalDev->dev_base;
10453 + CPMAC_MAC_EOI_VECTOR(base) = 0;
10459 +static int PhyCheck(HAL_DEVICE *HalDev)
10461 + return(cpMacMdioTic(HalDev->PhyDev));
10463 +static int halTick(HAL_DEVICE *HalDev)
10467 + if(HalDev->State < enOpened)
10468 + return (EC_CPMAC|EC_FUNC_TICK|EC_VAL_INVALID_STATE);
10470 + /* if NO Phy no need to check Link */
10471 + if(HalDev->MdioConnect & _CPMDIO_NOPHY)
10472 + return(EC_NO_ERRORS); /* No change in Phy State detected */
10474 + TickChange = PhyCheck(HalDev);
10475 + /* Phy State Change Detected */
10476 + if(TickChange == 1)
10478 + /* MDIO indicated a change */
10479 + DuplexUpdate(HalDev);
10480 + osfuncStateChange();
10481 + return(EC_NO_ERRORS);
10484 + /* if in AutoMdix mode, and Flip request received, inform OS */
10485 + if( (HalDev->MdioConnect & _CPMDIO_AUTOMDIX) &&
10486 + (TickChange & _MIIMDIO_MDIXFLIP))
10489 + Mdix = TickChange & 0x1; /* Mdix mode stored in bit 0 */
10490 + HalDev->OsFunc->Control(HalDev->OsDev, hcMdioMdixSwitch, hcSet, &Mdix);
10491 + return(EC_NO_ERRORS);
10494 + return(EC_NO_ERRORS);
10497 +int halCpmacInitModule(HAL_DEVICE **pHalDev, OS_DEVICE *OsDev, HAL_FUNCTIONS **pHalFunc,
10498 + OS_FUNCTIONS *OsFunc, int OsFuncSize, int *HalFuncSize, int Inst)
10500 + HAL_DEVICE *HalDev;
10501 + HAL_FUNCTIONS *HalFunc;
10503 + if (OsFuncSize < sizeof(OS_FUNCTIONS))
10504 + return (EC_CPMAC|EC_FUNC_HAL_INIT|EC_VAL_OS_VERSION_NOT_SUPPORTED);
10506 + HalDev = (HAL_DEVICE *) OsFunc->MallocDev(sizeof(HAL_DEVICE));
10508 + return (EC_CPMAC|EC_FUNC_HAL_INIT|EC_VAL_MALLOC_DEV_FAILED);
10510 + /* clear the HalDev area */
10511 + OsFunc->Memset(HalDev, 0, sizeof(HAL_DEVICE));
10513 + /* Initialize the size of hal functions */
10514 + *HalFuncSize = sizeof (HAL_FUNCTIONS);
10516 + HalFunc = (HAL_FUNCTIONS *) OsFunc->Malloc(sizeof(HAL_FUNCTIONS));
10518 + return (EC_CPMAC|EC_FUNC_HAL_INIT|EC_VAL_MALLOC_FAILED);
10520 + /* clear the function pointers */
10521 + OsFunc->Memset(HalFunc, 0, sizeof(HAL_FUNCTIONS));
10523 + HalDev->OsDev = OsDev;
10524 + HalDev->OsOpen = OsDev;
10525 + HalDev->inst = Inst;
10526 + HalDev->OsFunc = OsFunc;
10527 + HalDev->HalFunc = HalFunc;
10528 + /* Remove the following from cppi, replace with HalFunc */
10529 + HalDev->HalFuncPtr = HalFunc; /* GSG 11/20 changed name to match cppi */
10531 + /****************************************************************/
10532 + /* POPULATE HALFUNC */
10533 + /****************************************************************/
10534 + HalFunc->ChannelSetup = halChannelSetup;
10535 + HalFunc->ChannelTeardown = halChannelTeardown; /* GSG 11/20 */
10536 + HalFunc->Close = halClose; /* GSG 11/20 */
10537 + HalFunc->Control = halControl; /* GSG 11/22 */
10538 + HalFunc->Init = halInit;
10539 + HalFunc->Open = halOpen;
10540 + HalFunc->PacketProcessEnd = halPacketProcessEnd;
10541 + HalFunc->Probe = halProbe;
10542 + HalFunc->RxReturn = halRxReturn;
10543 + HalFunc->Send = halSend;
10544 + HalFunc->Shutdown = halShutdown;
10545 + HalFunc->Tick = halTick;
10547 + /* HalFunc->Status = halStatus;*/ /* GSG 11/22 */
10548 + /* pass the HalDev and HalFunc back to the caller */
10550 + *pHalDev = HalDev;
10551 + *pHalFunc = HalFunc;
10553 + HalDev->State = enConnected; /* Initialize the hardware state */
10555 + if (HalDev->debug) HalDev->OsFunc->Printf("halCpmacInitModule: Leave\n");
10559 +int cpmacRandomRange(HAL_DEVICE *HalDev, int min, int max)
10562 + iTmp = cpmacRandom(HalDev);
10563 + iTmp %= ((max-min)+1);
10568 +int cpmacRandom(HAL_DEVICE *HalDev)
10571 + iTmp = CPMAC_BOFFTEST(HalDev->dev_base);
10572 + iTmp >>= 16; /* get rndnum field */
10573 + iTmp &= (0x3FF); /* field is 10 bits wide */
10576 diff -urN linux.old/drivers/net/avalanche_cpmac/hcpmac.h linux.dev/drivers/net/avalanche_cpmac/hcpmac.h
10577 --- linux.old/drivers/net/avalanche_cpmac/hcpmac.h 1970-01-01 01:00:00.000000000 +0100
10578 +++ linux.dev/drivers/net/avalanche_cpmac/hcpmac.h 2005-07-12 02:48:42.175574000 +0200
10580 +/** @file***********************************************************************
10581 + * TNETDxxxx Software Support
10582 + * Copyright (c) 2002 Texas Instruments Incorporated. All Rights Reserved.
10587 + * This file contains definitions for the HAL EMAC API
10590 + * xxXxx01 Denis 1.00 Original Version created.
10591 + * 22Jan02 Denis/Mick 1.01 Modified for HAL EMAC API
10592 + * 24Jan02 Denis/Mick 1.02 Speed Improvements
10593 + * 28Jan02 Denis/Mick 1.16 Made function calls pointers
10594 + * 28Jan02 Mick 1.18 Split into separate modules
10595 + * @author Michael Hanrahan
10597 + * @date 24-Jan-2002
10598 + *****************************************************************************/
10599 +#ifndef _INC_HCPMAC
10600 +#define _INC_HCPMAC
10602 +/** \namespace CPMAC_Version
10603 +This documents version 01.07.04 of the CPMAC CPHAL.
10605 +const char *pszVersion_CPMAC="CPMAC 01.07.08 "__DATE__" "__TIME__;
10607 +/* CHECK THESE LOCATIONS */
10608 +#define TEARDOWN_VAL 0xfffffffc
10609 +#define CB_OFFSET_MASK 0xFFFF0000
10612 +#define MAX_CHAN 8
10613 +#define MAX_QUEUE 1
10617 + bit32 HNext; /*< Hardware's pointer to next buffer descriptor */
10618 + bit32 BufPtr; /*< Pointer to the data buffer */
10619 + bit32 Off_BLen; /*< Contains buffer offset and buffer length */
10620 + bit32 mode; /*< SOP, EOP, Ownership, EOQ, Teardown, Q Starv, Length */
10624 +#ifdef __CPHAL_DEBUG
10627 + bit32 DbgFraglist;
10631 +typedef volatile struct hal_private
10633 + bit32 HNext; /*< Hardware's pointer to next buffer descriptor */
10634 + bit32 BufPtr; /*< Pointer to the data buffer */
10635 + bit32 Off_BLen; /*< Contains buffer offset and buffer length */
10636 + bit32 mode; /*< SOP, EOP, Ownership, EOQ, Teardown Complete bits */
10643 +#define MAX_NEEDS 512 /*MJH+030409*/
10646 +typedef struct hal_device
10648 + OS_DEVICE *OsDev;
10649 + OS_FUNCTIONS *OsFunc;
10650 + /*OS_SETUP *OsSetup;*/ /* -GSG 030508 */
10658 + bit32u ResetBase; /* GSG 10/20 */
10662 + PHY_DEVICE *PhyDev;
10663 + bit32u EmacDuplex;
10664 + bit32u EmacSpeed;
10666 + bit32u MLinkMask;
10671 + DEVICE_STATE State;
10672 + unsigned char *MacAddr;
10673 + HAL_FUNCTIONS *HalFuncPtr; /* GSG 11/20 changed name to match cppi */
10674 + HAL_FUNCTIONS *HalFunc;
10675 +/* unsigned int CpuFreq;*/ /*MJH-030402*/
10676 + unsigned int MdioConnect;
10677 + unsigned int HostErr;
10679 +/************************************************************************/
10681 +/* R E G I S T E R S */
10683 +/************************************************************************/
10685 + bit32u RxMbpEnable;
10686 + bit32u RxUnicastSet;
10687 + bit32u RxUnicastClear;
10689 + bit32u RxFilterLowThresh;
10690 + bit32u Rx0FlowThresh;
10691 + bit32u MacControl;
10692 + bit32u MacStatus;
10696 +/************************************************************************/
10698 +/* O P T I O N S */
10700 +/************************************************************************/
10702 + char *DeviceInfo;
10703 + bit32u interrupt;
10706 + bit32u RxPassCrc;
10710 + bit32u RxBcastCh;
10711 + HAL_RCB *RcbPool[MAX_CHAN];
10712 + bit32 RxActQueueCount[MAX_CHAN];
10713 + HAL_RCB *RxActQueueHead[MAX_CHAN];
10714 + HAL_RCB *RxActQueueTail[MAX_CHAN];
10715 + bit32 RxActive[MAX_CHAN];
10716 + HAL_TCB *TcbPool[MAX_CHAN][MAX_QUEUE];
10717 + bit32 TxActQueueCount[MAX_CHAN][MAX_QUEUE];
10718 + HAL_TCB *TxActQueueHead[MAX_CHAN][MAX_QUEUE];
10719 + HAL_TCB *TxActQueueTail[MAX_CHAN][MAX_QUEUE];
10720 + bit32 TxActive[MAX_CHAN][MAX_QUEUE];
10721 + bit32 TxTeardownPending[MAX_CHAN];
10722 + bit32 RxTeardownPending[MAX_CHAN];
10723 + bit32 ChIsOpen[MAX_CHAN][2];
10724 + bit32 ChIsSetup[MAX_CHAN][2];
10725 + FRAGLIST *fraglist;
10726 + char *TcbStart[MAX_CHAN][MAX_QUEUE];
10727 + char *RcbStart[MAX_CHAN];
10728 + bit32 RcbSize[MAX_CHAN];
10729 +/* STAT_INFO Stats; */
10731 + bit32u BuffersServicedMax;
10732 + CHANNEL_INFO ChData[MAX_CHAN];
10733 + bit32u MdioClockFrequency; /*MJH+030402*/
10734 + bit32u MdioBusFrequency; /*MJH+030402*/
10735 + bit32u CpuFrequency; /*MJH+030402*/
10736 + bit32u CpmacFrequency; /*MJH+030403*/
10737 + bit32u CpmacSize; /*MJH+030425*/
10739 + bit32u NeedsCount; /*MJH+030409*/
10740 + HAL_RECEIVEINFO *Needs[MAX_NEEDS]; /*MJH+030409*/
10742 + int TxIntThreshold[MAX_CHAN]; /* MJH 040621 NSP Performance Update */
10743 + int TxIntThresholdMaster[MAX_CHAN]; /* MJH 040827 NSP Performance Update */
10744 + int TxIntDisable; /* MJH 040621 NSP Performance Update */
10747 +#define STATS_MAX 36
10749 +#define MACCONTROL_MASK (TX_PTYPE|TX_PACE|TX_FLOW_EN|RX_FLOW_EN|CTRL_LOOPBACK)
10750 +#define RX_MBP_ENABLE_MASK \
10751 + (RX_PASS_CRC|RX_QOS_EN|RX_NO_CHAIN| \
10752 + RX_CMF_EN|RX_CSF_EN|RX_CEF_EN|RX_CAF_EN|RX_PROM_CH_MASK| \
10753 + RX_BROAD_EN|RX_BROAD_CH_MASK|RX_MULT_EN|RX_MULT_CH_MASK)
10756 +#define MBP_UPDATE(Mask, On) \
10757 + if(On) HalDev->RxMbpEnable |= Mask; \
10758 + else HalDev->RxMbpEnable &= ~Mask
10760 +#define CONTROL_UPDATE(Mask, On) \
10761 + if(On) HalDev->MacControl |= Mask; \
10762 + else HalDev->MacControl &= ~Mask
10765 +#define UPDATE_TX_PTYPE(Value) CONTROL_UPDATE(TX_PTYPE,Value)
10766 +#define UPDATE_TX_PACE(Value) CONTROL_UPDATE(TX_PACE,Value)
10767 +#define UPDATE_MII_EN(Value) CONTROL_UPDATE(MII_EN,Value)
10768 +#define UPDATE_TX_FLOW_EN(Value) CONTROL_UPDATE(TX_FLOW_EN,Value)
10769 +#define UPDATE_RX_FLOW_EN(Value) CONTROL_UPDATE(RX_FLOW_EN,Value)
10770 +#define UPDATE_CTRL_LOOPBACK(Value) CONTROL_UPDATE(CTRL_LOOPBACK,Value)
10771 +#define UPDATE_FULLDUPLEX(Value) CONTROL_UPDATE(FULLDUPLEX,(Value))
10773 +#define UPDATE_RX_PASS_CRC(Value) MBP_UPDATE(RX_PASS_CRC, Value)
10774 +#define UPDATE_RX_QOS_EN(Value) MBP_UPDATE(RX_QOS_EN, Value)
10775 +#define UPDATE_RX_NO_CHAIN(Value) MBP_UPDATE(RX_NO_CHAIN, Value)
10776 +#define UPDATE_RX_CMF_EN(Value) MBP_UPDATE(RX_CMF_EN, Value)
10777 +#define UPDATE_RX_CSF_EN(Value) MBP_UPDATE(RX_CSF_EN, Value)
10778 +#define UPDATE_RX_CEF_EN(Value) MBP_UPDATE(RX_CEF_EN, Value)
10779 +#define UPDATE_RX_CAF_EN(Value) MBP_UPDATE(RX_CAF_EN, Value)
10780 +#define UPDATE_RX_BROAD_EN(Value) MBP_UPDATE(RX_BROAD_EN, Value)
10781 +#define UPDATE_RX_MULT_EN(Value) MBP_UPDATE(RX_MULT_EN, Value)
10783 +#define UPDATE_RX_PROM_CH(Value) \
10784 + HalDev->RxMbpEnable &= ~RX_PROM_CH_MASK; \
10785 + HalDev->RxMbpEnable |= RX_PROM_CH(Value)
10787 +#define UPDATE_RX_BROAD_CH(Value) \
10788 + HalDev->RxMbpEnable &= ~RX_BROAD_CH_MASK; \
10789 + HalDev->RxMbpEnable |= RX_BROAD_CH(Value)
10791 +#define UPDATE_RX_MULT_CH(Value) \
10792 + HalDev->RxMbpEnable &= ~RX_MULT_CH_MASK; \
10793 + HalDev->RxMbpEnable |= RX_MULT_CH(Value)
10829 + enRX_FILTERLOWTHRESH,
10830 + enRX0_FLOWTHRESH,
10831 + enRX_UNICAST_SET,
10832 + enRX_UNICAST_CLEAR,
10838 + enRX_MULTI_SINGLE,
10840 + enCpmacEnd /* Last entry */
10843 +static const char pszVersion[] = "Version";
10844 +static const char pszStats0[] = "Stats0";
10845 +static const char pszStats1[] = "Stats1";
10846 +static const char pszStats2[] = "Stats2";
10847 +static const char pszStats3[] = "Stats3";
10848 +static const char pszStats4[] = "Stats4";
10849 +static const char pszStatsDump[] = "StatsDump";
10850 +static const char pszStatsClear[] = "StatsClear";
10852 +/********************************************************************
10856 +********************************************************************/
10857 +static const char pszRX_PASS_CRC[] = "RX_PASS_CRC";
10858 +static const char pszRX_QOS_EN[] = "RX_QOS_EN";
10859 +static const char pszRX_NO_CHAIN[] = "RX_NO_CHAIN";
10860 +static const char pszRX_CMF_EN[] = "RX_CMF_EN";
10861 +static const char pszRX_CSF_EN[] = "RX_CSF_EN";
10862 +static const char pszRX_CEF_EN[] = "RX_CEF_EN";
10863 +static const char pszRX_CAF_EN[] = "RX_CAF_EN";
10864 +static const char pszRX_PROM_CH[] = "RX_PROM_CH";
10865 +static const char pszRX_BROAD_EN[] = "RX_BROAD_EN";
10866 +static const char pszRX_BROAD_CH[] = "RX_BROAD_CH";
10867 +static const char pszRX_MULT_EN[] = "RX_MULT_EN";
10868 +static const char pszRX_MULT_CH[] = "RX_MULT_CH";
10871 +/********************************************************************
10875 +********************************************************************/
10876 +static const char pszTX_PTYPE[] = "TX_PTYPE";
10877 +static const char pszTX_PACE[] = "TX_PACE";
10878 +static const char pszMII_EN[] = "MII_EN";
10879 +static const char pszTX_FLOW_EN[] = "TX_FLOW_EN";
10880 +static const char pszRX_FLOW_EN[] = "RX_FLOW_EN";
10881 +static const char pszCTRL_LOOPBACK[] = "CTRL_LOOPBACK";
10883 +static const char pszRX_MAXLEN[] = "RX_MAXLEN";
10884 +static const char pszRX_FILTERLOWTHRESH[] = "RX_FILTERLOWTHRESH";
10885 +static const char pszRX0_FLOWTHRESH[] = "RX0_FLOWTHRESH";
10886 +static const char pszRX_UNICAST_SET[] = "RX_UNICAST_SET";
10887 +static const char pszRX_UNICAST_CLEAR[] = "RX_UNICAST_CLEAR";
10888 +static const char pszMdioConnect[] = "MdioConnect";
10889 +static const char pszMacAddr[] = "MacAddr";
10890 +static const char pszTick[] = "Tick";
10892 +/********************************************************************
10896 +********************************************************************/
10898 +static const char pszRX_MULTICAST[] = "RX_MULTICAST";
10899 +static const char pszRX_MULTI_ALL[] = "RX_MULTI_ALL";
10900 +static const char pszRX_MULTI_SINGLE[] = "RX_MULTI_SINGLE";
10903 +static const char* pszGFHN = "GFHN";
10906 +static const CONTROL_KEY KeyCpmac[] =
10908 + {"" , enCpmacStart},
10909 + {pszStats0 , enStats0},
10910 + {pszStats1 , enStats1},
10911 + {pszStats2 , enStats2},
10912 + {pszStats3 , enStats3},
10913 + {pszStats4 , enStats4},
10914 + {pszStatsClear , enStatsClear},
10915 + {pszStatsDump , enStatsDump},
10916 + {pszRX_PASS_CRC , enRX_PASS_CRC},
10917 + {pszRX_QOS_EN , enRX_QOS_EN},
10918 + {pszRX_NO_CHAIN , enRX_NO_CHAIN},
10919 + {pszRX_CMF_EN , enRX_CMF_EN},
10920 + {pszRX_CSF_EN , enRX_CSF_EN},
10921 + {pszRX_CEF_EN , enRX_CEF_EN},
10922 + {pszRX_CAF_EN , enRX_CAF_EN},
10923 + {pszRX_PROM_CH , enRX_PROM_CH},
10924 + {pszRX_BROAD_EN , enRX_BROAD_EN},
10925 + {pszRX_BROAD_CH , enRX_BROAD_CH},
10926 + {pszRX_MULT_EN , enRX_MULT_EN},
10927 + {pszRX_MULT_CH , enRX_MULT_CH},
10929 + {pszTX_PTYPE , enTX_PTYPE},
10930 + {pszTX_PACE , enTX_PACE},
10931 + {pszMII_EN , enMII_EN},
10932 + {pszTX_FLOW_EN , enTX_FLOW_EN},
10933 + {pszRX_FLOW_EN , enRX_FLOW_EN},
10934 + {pszCTRL_LOOPBACK , enCTRL_LOOPBACK},
10935 + {pszRX_MAXLEN , enRX_MAXLEN},
10936 + {pszRX_FILTERLOWTHRESH , enRX_FILTERLOWTHRESH},
10937 + {pszRX0_FLOWTHRESH , enRX0_FLOWTHRESH},
10938 + {pszRX_UNICAST_SET , enRX_UNICAST_SET},
10939 + {pszRX_UNICAST_CLEAR , enRX_UNICAST_CLEAR},
10940 + {pszMdioConnect , enMdioConnect},
10941 + {pszRX_MULTICAST , enRX_MULTICAST},
10942 + {pszRX_MULTI_ALL , enRX_MULTI_ALL},
10943 + {pszRX_MULTI_SINGLE , enRX_MULTI_SINGLE},
10944 + {pszTick , enTick},
10945 + {pszVersion , enVersion},
10946 + {"" , enCpmacEnd}
10949 +const char hcCpuFrequency[] = "CpuFreq";
10950 +const char hcCpmacFrequency[] = "CpmacFrequency";
10951 +const char hcMdioBusFrequency[] = "MdioBusFrequency";
10952 +const char hcMdioClockFrequency[] = "MdioClockFrequency";
10953 +const char hcCpmacBase[] = "CpmacBase";
10954 +const char hcPhyNum[] = "PhyNum";
10955 +const char hcSize[] = "size";
10956 +const char hcCpmacSize[] = "CpmacSize";
10957 +const char hcPhyAccess[] = "PhyAccess";
10958 +const char hcLinked[] = "Linked";
10959 +const char hcFullDuplex[] = "FullDuplex";
10960 +const char hcMdixMask[] = "MdixMask";
10961 +const char hcMdioMdixSwitch[] = "MdixSet";
10963 diff -urN linux.old/drivers/net/avalanche_cpmac/Makefile linux.dev/drivers/net/avalanche_cpmac/Makefile
10964 --- linux.old/drivers/net/avalanche_cpmac/Makefile 1970-01-01 01:00:00.000000000 +0100
10965 +++ linux.dev/drivers/net/avalanche_cpmac/Makefile 2005-07-12 02:48:42.175574000 +0200
10967 +# File: drivers/net/avalanche_cpmac/Makefile
10969 +# Makefile for the Linux network (CPMAC) device drivers.
10972 +O_TARGET := avalanche_cpmac.o
10975 +list-multi := avalanche_cpmac.o
10976 +obj-$(CONFIG_MIPS_AVALANCHE_CPMAC) := avalanche_cpmac.o
10978 +avalanche_cpmac-objs += cpmac.o cpmacHalLx.o hcpmac.o \
10979 + psp_config_build.o psp_config_mgr.o \
10980 + psp_config_parse.o psp_config_util.o
10983 +include $(TOPDIR)/Rules.make
10986 +avalanche_cpmac.o: $(avalanche_cpmac-objs)
10987 + $(LD) -r -o $@ $(avalanche_cpmac-objs)
10992 + rm -f core *.o *.a *.s
10993 diff -urN linux.old/drivers/net/avalanche_cpmac/mdio_reg.h linux.dev/drivers/net/avalanche_cpmac/mdio_reg.h
10994 --- linux.old/drivers/net/avalanche_cpmac/mdio_reg.h 1970-01-01 01:00:00.000000000 +0100
10995 +++ linux.dev/drivers/net/avalanche_cpmac/mdio_reg.h 2005-07-12 02:48:42.176573000 +0200
10997 +/****************************************************************************
10998 +** TNETD53xx Software Support
10999 +** Copyright(c) 2002, Texas Instruments Incorporated. All Rights Reserved.
11001 +** FILE: mdio_reg.h Register definitions for the VBUS MII module
11004 +** This include file contains register definitions for the
11005 +** VBUS MII module.
11008 +** 27Mar02 Michael Hanrahan Original (modified from emacmdio.h)
11009 +** 01Apr02 Michael Hanrahan Modified to include all regs. in spec
11010 +** 03Apr02 Michael Hanrahan Updated to Version 0.6 of spec
11011 +** 05Apr02 Michael Hanrahan Moved Phy Mode values into here
11012 +** 30Apr02 Michael Hanrahan Updated to Version 0.8 of spec
11013 +** 30Apr02 Michael Hanrahan Updated to recommended format
11014 +** 10May02 Michael Hanrahan Updated to Version 0.9 of spec
11015 +*****************************************************************************/
11016 +#ifndef _INC_MDIO_REG
11017 +#define _INC_MDIO_REG
11019 +/***************************************************************************
11021 +** M D I O M E M O R Y M A P
11023 +***************************************************************************/
11026 +#define pMDIO_VER(base) ((volatile bit32u *)(base+0x00))
11027 +#define pMDIO_CONTROL(base) ((volatile bit32u *)(base+0x04))
11028 +#define pMDIO_ALIVE(base) ((volatile bit32u *)(base+0x08))
11029 +#define pMDIO_LINK(base) ((volatile bit32u *)(base+0x0C))
11030 +#define pMDIO_LINKINTRAW(base) ((volatile bit32u *)(base+0x10))
11031 +#define pMDIO_LINKINTMASKED(base) ((volatile bit32u *)(base+0x14))
11032 +#define pMDIO_USERINTRAW(base) ((volatile bit32u *)(base+0x20))
11033 +#define pMDIO_USERINTMASKED(base) ((volatile bit32u *)(base+0x24))
11034 +#define pMDIO_USERINTMASKED_SET(base) ((volatile bit32u *)(base+0x28))
11035 +#define pMDIO_USERINTMASKED_CLR(base) ((volatile bit32u *)(base+0x2C))
11036 +#define pMDIO_USERACCESS(base, channel) ((volatile bit32u *)(base+(0x80+(channel*8))))
11037 +#define pMDIO_USERPHYSEL(base, channel) ((volatile bit32u *)(base+(0x84+(channel*8))))
11040 +/***************************************************************************
11042 +** M D I O R E G I S T E R A C C E S S M A C R O S
11044 +***************************************************************************/
11047 +#define MDIO_ALIVE(base) (*(pMDIO_ALIVE(base)))
11048 +#define MDIO_CONTROL(base) (*(pMDIO_CONTROL(base)))
11049 +#define MDIO_CONTROL_IDLE (1 << 31)
11050 +#define MDIO_CONTROL_ENABLE (1 << 30)
11051 +#define MDIO_CONTROL_PREAMBLE (1 << 20)
11052 +#define MDIO_CONTROL_FAULT (1 << 19)
11053 +#define MDIO_CONTROL_FAULT_DETECT_ENABLE (1 << 18)
11054 +#define MDIO_CONTROL_INT_TEST_ENABLE (1 << 17)
11055 +#define MDIO_CONTROL_HIGHEST_USER_CHANNEL (0x1F << 8)
11056 +#define MDIO_CONTROL_CLKDIV (0xFF)
11057 +#define MDIO_LINK(base) (*(pMDIO_LINK(base)))
11058 +#define MDIO_LINKINTRAW(base) (*(pMDIO_LINKINTRAW(base)))
11059 +#define MDIO_LINKINTMASKED(base) (*(pMDIO_LINKINTMASKED(base)))
11060 +#define MDIO_USERINTRAW(base) (*(pMDIO_USERINTRAW(base)))
11061 +#define MDIO_USERINTMASKED(base) (*(pMDIO_USERINTMASKED(base)))
11062 +#define MDIO_USERINTMASKED_CLR(base) (*(pMDIO_USERINTMASKED_CLR(base)))
11063 +#define MDIO_USERINTMASKED_SET(base) (*(pMDIO_USERINTMASKED_SET(base)))
11064 +#define MDIO_USERINTRAW(base) (*(pMDIO_USERINTRAW(base)))
11065 +#define MDIO_USERACCESS(base, channel) (*(pMDIO_USERACCESS(base, channel)))
11066 +#define MDIO_USERACCESS_GO (1 << 31)
11067 +#define MDIO_USERACCESS_WRITE (1 << 30)
11068 +#define MDIO_USERACCESS_READ (0 << 30)
11069 +#define MDIO_USERACCESS_ACK (1 << 29)
11070 +#define MDIO_USERACCESS_REGADR (0x1F << 21)
11071 +#define MDIO_USERACCESS_PHYADR (0x1F << 16)
11072 +#define MDIO_USERACCESS_DATA (0xFFFF)
11073 +#define MDIO_USERPHYSEL(base, channel) (*(pMDIO_USERPHYSEL(base, channel)))
11074 +#define MDIO_USERPHYSEL_LINKSEL (1 << 7)
11075 +#define MDIO_USERPHYSEL_LINKINT_ENABLE (1 << 6)
11076 +#define MDIO_USERPHYSEL_PHYADR_MON (0x1F)
11077 +#define MDIO_VER(base) (*(pMDIO_VER(base)))
11078 +#define MDIO_VER_MODID (0xFFFF << 16)
11079 +#define MDIO_VER_REVMAJ (0xFF << 8)
11080 +#define MDIO_VER_REVMIN (0xFF)
11085 +/****************************************************************************/
11087 +/* P H Y R E G I S T E R D E F I N I T I O N S */
11089 +/****************************************************************************/
11092 +#define PHY_CONTROL_REG 0
11093 + #define PHY_RESET (1<<15)
11094 + #define PHY_LOOP (1<<14)
11095 + #define PHY_100 (1<<13)
11096 + #define AUTO_NEGOTIATE_EN (1<<12)
11097 + #define PHY_PDOWN (1<<11)
11098 + #define PHY_ISOLATE (1<<10)
11099 + #define RENEGOTIATE (1<<9)
11100 + #define PHY_FD (1<<8)
11102 +#define PHY_STATUS_REG 1
11103 + #define NWAY_COMPLETE (1<<5)
11104 + #define NWAY_CAPABLE (1<<3)
11105 + #define PHY_LINKED (1<<2)
11107 +#define NWAY_ADVERTIZE_REG 4
11108 +#define NWAY_REMADVERTISE_REG 5
11109 + #define NWAY_FD100 (1<<8)
11110 + #define NWAY_HD100 (1<<7)
11111 + #define NWAY_FD10 (1<<6)
11112 + #define NWAY_HD10 (1<<5)
11113 + #define NWAY_SEL (1<<0)
11114 + #define NWAY_AUTO (1<<0)
11117 +#endif _INC_MDIO_REG
11118 diff -urN linux.old/drivers/net/avalanche_cpmac/psp_config_build.c linux.dev/drivers/net/avalanche_cpmac/psp_config_build.c
11119 --- linux.old/drivers/net/avalanche_cpmac/psp_config_build.c 1970-01-01 01:00:00.000000000 +0100
11120 +++ linux.dev/drivers/net/avalanche_cpmac/psp_config_build.c 2005-07-12 02:48:42.176573000 +0200
11122 +/******************************************************************************
11123 + * FILE PURPOSE: PSP Config Manager - Configuration Build Source
11124 + ******************************************************************************
11125 + * FILE NAME: psp_config_build.c
11127 + * DESCRIPTION: Configuration Build API Implementation
11129 + * REVISION HISTORY:
11130 + * 27 Nov 02 - PSP TII
11132 + * (C) Copyright 2002, Texas Instruments, Inc
11133 + *******************************************************************************/
11135 +#ifdef INCLUDE_FFS
11137 +#endif /* INCLUDE_FFS */
11139 +#include "psp_config_mgr.h"
11140 +#include "psp_config_build.h"
11141 +#include "psp_config_util.h"
11143 +#define MAX_DEVICE_NAME_LEN 16
11144 +#define MAX_DEVICE_STR_LEN 512
11147 +#define NULL (char *)0
11150 +#include <asm/ar7/sangam.h>
11151 +#include <linux/slab.h>
11152 +#include <linux/config.h>
11155 +#define os_malloc(size) kmalloc(size, GFP_KERNEL)
11157 +int psp_run_enumerator(void)
11162 +#if defined (CONFIG_AVALANCHE_CPMAC_AUTO)
11164 +static int auto_detect_cpmac_phy(void)
11167 +#define SELECT_INT_PHY_MAC 0
11168 +#define SELECT_EXT_PHY_MAC 1
11170 + volatile unsigned long *reset_cntl = AVALANCHE_RESET_CONTROL_BASE, *mdio_cntl = ((int)AVALANCHE_MDIO_BASE + 0x4);
11171 + unsigned int j= 0, detected_phy_map = 0, auto_select = SELECT_INT_PHY_MAC;
11173 + *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);
11174 + *mdio_cntl = (1 << 30) | ((CONFIG_AR7_SYS * 1000)/2200);
11176 + for(j=0;j < 300000; j++)
11178 + if(j%100000) continue;
11180 + detected_phy_map = *(mdio_cntl + 1);
11181 + if(detected_phy_map)
11183 + detected_phy_map &= ~AVALANCHE_LOW_CPMAC_PHY_MASK;
11185 + if(detected_phy_map && !(detected_phy_map & (detected_phy_map - 1)))
11187 + auto_select = SELECT_EXT_PHY_MAC;
11193 + return(auto_select);
11200 +#ifndef AVALANCHE_LOW_CPMAC_MDIX_MASK
11201 +#define AVALANCHE_LOW_CPMAC_MDIX_MASK 0
11204 +void psp_load_default_static_cfg(void)
11206 + char s2[100], s3[100];
11207 + char s4[2000], s6[2000];
11208 + int threshold = 20;
11209 + char *tx_threshold_ptr = prom_getenv("threshold");
11211 + if(tx_threshold_ptr)
11212 + threshold = simple_strtol(tx_threshold_ptr, (char **)NULL, 10);
11214 + /* Static configuration if options.conf not present */
11215 + sprintf(s3,"cpmdio(id=mii, base=%u, reset_bit=%d)", AVALANCHE_MDIO_BASE, 22);
11216 + sprintf(s2, "reset( id=[ResetRegister], base=%u)", AVALANCHE_RESET_CONTROL_BASE);
11218 + 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);
11220 + 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);
11222 + psp_config_add("reset", s2, psp_config_strlen(s2), en_compile);
11225 +#if defined (CONFIG_AVALANCHE_LOW_CPMAC)
11227 + psp_config_add("cpmdio", s3, psp_config_strlen(s3), en_compile);
11228 + psp_config_add("cpmac", s4, psp_config_strlen(s4), en_compile);
11233 +#if defined (CONFIG_AVALANCHE_HIGH_CPMAC)
11235 + psp_config_add("cpmdio", s3, psp_config_strlen(s3), en_compile);
11236 + psp_config_add("cpmac", s6, psp_config_strlen(s6), en_compile);
11240 +#if defined (CONFIG_AVALANCHE_CPMAC_AUTO)
11242 + char *phy_sel_ptr = prom_getenv("mac_phy_sel");
11243 + int phy_sel = SELECT_EXT_PHY_MAC;
11244 + char *mac_port = prom_getenv("MAC_PORT"); /* Internal: 0, External: 1 */
11246 + if(phy_sel_ptr && (0 == strcmp(phy_sel_ptr, "int")))
11248 + phy_sel = SELECT_INT_PHY_MAC;
11251 + //if(phy_sel == auto_detect_cpmac_phy())
11252 + if(!mac_port || (0 != strcmp(mac_port, "0")))
11254 + printk("Using the MAC with external PHY\n");
11255 + psp_config_add("cpmdio", s3, psp_config_strlen(s3), en_compile);
11256 + psp_config_add("cpmac", s6, psp_config_strlen(s6), en_compile);
11260 + printk("Using the MAC with internal PHY\n");
11261 + psp_config_add("cpmdio", s3, psp_config_strlen(s3), en_compile);
11262 + psp_config_add("cpmac", s4, psp_config_strlen(s4), en_compile);
11270 +char* psp_conf_read_file(char *p_file_name)
11272 +#ifdef INCLUDE_FFS
11274 + char *p_file_data = NULL;
11275 + unsigned int file_size;
11276 + FFS_FILE *p_file = NULL;
11278 + if(p_file_name == NULL)
11283 + if(!(p_file = ffs_fopen(p_file_name, "r")))
11288 + file_size = p_file->_AvailableBytes;
11290 + p_file_data = os_malloc(file_size + 1);
11292 + if(ffs_fread(p_file_data, file_size, 1, p_file) == 0)
11294 + kfree(p_file_data);
11298 + ffs_fclose(p_file);
11300 + p_file_data[file_size] = '\0';
11302 + return(p_file_data);
11304 +#else /* NO FFS */
11306 +#endif /* INCLUDE_FFS */
11309 +int psp_conf_get_line(char *p_in_data, char **next_line)
11311 + char *p = p_in_data;
11313 + while(*p && *p++ != '\n')
11320 + return(p - 1 - p_in_data);
11324 +int psp_conf_is_data_line(char *line)
11328 + if(*line == '\0' || *line == '\n' || *line == '#')
11334 +int psp_conf_get_key_size(char *data)
11338 + while(*p && *p != '\n' && *p != '(' && *p != ' ')
11341 + return(p - data);
11344 +char* psp_conf_eat_white_spaces(char *p)
11346 + while(*p && *p != '\n' && *p == ' ')
11352 +int psp_build_from_opt_conf(void)
11354 + char *data = NULL;
11355 + char *data_hold = NULL;
11356 + char *next_line = NULL;
11357 + int line_size = 0;
11359 + if((data = psp_conf_read_file("/etc/options.conf")) == NULL)
11362 + data_hold = data;
11364 + while((line_size=psp_conf_get_line(data, &next_line)) != -1)
11367 + char *name = NULL;
11370 + data = psp_conf_eat_white_spaces(data);
11372 + if(psp_conf_is_data_line(data))
11374 + data[line_size] = '\0';
11376 + name_size = psp_conf_get_key_size(data);
11378 + if(name_size > 0)
11380 + name = (char *) os_malloc(name_size + 1);
11381 + if(name == NULL) break;
11383 + psp_config_memcpy(name, data, name_size);
11384 + name[name_size] = '\0';
11386 + psp_config_add(name, data, line_size, en_opt_conf);
11391 + data[line_size] = '\n';
11394 + data = next_line;
11397 + kfree(data_hold);
11402 +int psp_write_conf_file(char *p_write_file, char * dev_cfg_string)
11404 +#ifdef INCLUDE_FFS
11405 + int bytes_written=0;
11406 + FFS_FILE *file_ptr=NULL;
11409 + * NOTE: In current implementation of FFS in ADAM2 if the file exists beforehand, it
11410 + * can't be opened for write.
11412 + if(!(file_ptr=ffs_fopen(p_write_file, "w"))) {
11416 + /* Write into the file "output.con" the character string */
11417 + /* write a \n before a writing a line */
11418 + if(!(bytes_written = ffs_fwrite("\n", 1, sizeof(char), file_ptr))) {
11422 + if(!(bytes_written = ffs_fwrite(dev_cfg_string, psp_config_strlen(dev_cfg_string), sizeof(char), file_ptr))) {
11425 + ffs_fclose(file_ptr);
11426 + return (bytes_written+1);
11427 +#else /* NO FFS */
11429 +#endif /* INCLUDE_FFS */
11432 +void build_psp_config(void)
11435 + /* initialize the repository. */
11436 + psp_config_init();
11438 +#ifdef INCLUDE_FFS
11440 +#endif /* INCLUDE_FFS */
11442 + /* read the configuration from the options.conf to override default ones */
11443 + psp_build_from_opt_conf();
11445 + /* read the configuration which were not over ridden in options.conf */
11446 + psp_load_default_static_cfg();
11448 + /* let the vlynq be enumerated. Enumerator will add cfg info
11449 + of the discovered device instances to the repository.*/
11450 + psp_run_enumerator();
11452 + /* dump the repository*/
11453 + dump_device_cfg_pool();
11457 diff -urN linux.old/drivers/net/avalanche_cpmac/psp_config_build.h linux.dev/drivers/net/avalanche_cpmac/psp_config_build.h
11458 --- linux.old/drivers/net/avalanche_cpmac/psp_config_build.h 1970-01-01 01:00:00.000000000 +0100
11459 +++ linux.dev/drivers/net/avalanche_cpmac/psp_config_build.h 2005-07-12 02:48:42.176573000 +0200
11461 +/******************************************************************************
11462 + * FILE PURPOSE: PSP Config Manager - Configuration Build Header
11463 + ******************************************************************************
11464 + * FILE NAME: psp_config_build.h
11466 + * DESCRIPTION: Configuration Build API's.
11468 + * REVISION HISTORY:
11469 + * 27 Nov 02 - PSP TII
11471 + * (C) Copyright 2002, Texas Instruments, Inc
11472 + *******************************************************************************/
11474 +#ifndef __PSP_CONF_BUILD_H__
11475 +#define __PSP_CONF_BUILD_H__
11477 +/*------------------------------------------------------------------------------
11478 + * Name: psp_conf_read_file
11481 + * in: p_file_name - the name of the file to read from.
11484 + * Reads the entire file in one shot. This function opens the
11485 + * file, determines the size of the data to be read, allocates
11486 + * the required memory, NULL terminates the data and closes the
11489 + * It is responsibily of the callee to free the memory after it is
11490 + * done with that data.
11494 + * A NULL pointer, if failed to read the data otherwise, a valid
11495 + * pointer referring to the data read from the file.
11499 + * psp_conf_read_file("/etc/options.conf");
11500 + *---------------------------------------------------------------------------*/
11501 + char *psp_conf_read_file(char *p_file_name);
11503 + /*----------------------------------------------------------------------------
11504 + * Function : psp_conf_write_file
11507 + * in: p_file_name - the file to which data is to be written.
11508 + * in: data - the NULL terminated data string.
11511 + * Write the indicated data into the file. This function opens the file,
11512 + * appends the data to end of the file, closes the file.
11516 + * The number of bytes on success.
11521 + * psp_conf_write_file("/etc/outcon.conf", data);
11522 + *--------------------------------------------------------------------------*/
11523 + int psp_conf_write_file(char *p_file_name, char *data);
11525 + /*----------------------------------------------------------------------------
11526 + * Function: psp_conf_get_line
11529 + * in: data - the data from which the line is to identified.
11530 + * out: next_line - the pointer to start of the next line.
11533 + * Expects the data to be '\n' separated segments and data is NULL
11534 + * terminated. Parses the given data for '\n' or '\0'. Provides a pointer
11535 + * to the start of next line in the next_line.
11539 + * 0 or more to indicate the number of bytes in the line starting at
11541 + *--------------------------------------------------------------------------*/
11542 + int psp_get_conf_line(char *p_in_data, char **next_line);
11544 + /*----------------------------------------------------------------------------
11545 + * Function: psp_conf_is_data_line
11548 + * in: line - the array of bytes.
11551 + * Tests the first byte in the array for '\0' or '\n' or '#'. Lines
11552 + * starting with these characters are not considered data.
11555 + * 1 if the line has data.
11558 + *--------------------------------------------------------------------------*/
11559 + int psp_conf_is_data_line(char *line);
11561 + /*----------------------------------------------------------------------------
11562 + * Function: psp_conf_eat_white_spaces
11565 + * in: line - the array of bytes.
11568 + * Eats white spaces at the begining of the line while looking out for
11569 + * '\0' or '\n' or ' '.
11572 + * Pointer to the begining of the non white space character.
11573 + * NULL if '\0' or '\n' is found.
11575 + *--------------------------------------------------------------------------*/
11576 + char *psp_conf_eat_white_spaces(char *line);
11578 + /*---------------------------------------------------------------------------
11579 + * Function: psp_conf_get_key_size
11582 + * in: line - the array of bytes.
11585 + * Identifies the size of the 'key' in array formatted as
11586 + * key(id=[key1]....). This function also checks out for '\0' and '\n'.
11589 + * On success, The number of bytes that forms the key.
11592 + *-------------------------------------------------------------------------*/
11593 + int psp_conf_get_key_size(char *line);
11597 +#endif /* __PSP_CONF_BUILD_H__ */
11599 diff -urN linux.old/drivers/net/avalanche_cpmac/psp_config_mgr.c linux.dev/drivers/net/avalanche_cpmac/psp_config_mgr.c
11600 --- linux.old/drivers/net/avalanche_cpmac/psp_config_mgr.c 1970-01-01 01:00:00.000000000 +0100
11601 +++ linux.dev/drivers/net/avalanche_cpmac/psp_config_mgr.c 2005-07-12 02:48:42.177573000 +0200
11603 +/******************************************************************************
11604 + * FILE PURPOSE: PSP Config Manager Source
11605 + ******************************************************************************
11606 + * FILE NAME: psp_config_mgr.c
11610 + * Manages configuration information. The repository is managed on the basis of
11611 + * <key, info> pair. It is possible to have multiple occurrence of the same key.
11612 + * Multiple occurences of the same keys are referred to as 'instances'.
11613 + * 'instances' are assigned in the order of configuration arrival. The first
11614 + * config for a 'key' added to the repository would be treated as instance 0 and
11615 + * next config to arrive for the same key would be treated as instance '1' and
11618 + * Info is retrieved from the repository based on the 'key' and 'instance' value.
11620 + * No assumption is made about the format of the information that is put in the
11621 + * repository. The only requirement is that 'key' should be NULL terminated
11624 + * REVISION HISTORY:
11625 + * 27 Nov 02 - PSP TII
11627 + * (C) Copyright 2002, Texas Instruments, Inc
11628 + *******************************************************************************/
11630 +//#include <stdio.h>
11631 +//#include <stdlib.h>
11632 +#include "psp_config_mgr.h"
11633 +#include "psp_config_util.h"
11635 +#include <linux/slab.h>
11637 +/*-----------------------------------------------------------
11638 + Implemented elsewhere
11639 + -----------------------------------------------------------*/
11640 +extern int sys_read_options_conf(void);
11641 +extern int sys_write_options_conf(char *cfg_info);
11642 +extern int sys_load_default_static_cfg(void);
11643 +extern int sys_run_enumerator(void);
11645 +#define os_malloc(size) kmalloc(size, GFP_KERNEL)
11647 +/*---------------------------------------------------------
11648 + * Data structures.
11649 + *--------------------------------------------------------*/
11650 +struct device_cfg_data;
11652 +typedef struct device_instance_cfg_data
11654 + struct device_instance_cfg_data *next;
11655 + char locale[100];
11656 + unsigned int data_size;
11659 +} DEV_INSTANCE_CFG_DATA_T;
11661 +struct device_cfg_collection;
11663 +typedef struct device_cfg_collection
11665 + struct device_cfg_collection *next;
11666 + char *device_name;
11667 + CFG_TYPE_T cfg_type;
11669 + DEV_INSTANCE_CFG_DATA_T *dev_inst_list_begin;
11670 + DEV_INSTANCE_CFG_DATA_T *dev_inst_list_end;
11674 +typedef struct device_cfg_list
11676 + DEVICE_CFG_T *device_cfg_begin;
11678 +} DEVICE_CFG_LIST_T;
11680 +/*-----------------------------------------------------------------------------
11681 + * Functions used locally with in the file.
11682 + *---------------------------------------------------------------------------*/
11683 +static void p_init_device_cfg_list(void);
11684 +static int p_add_instance_cfg_data(DEVICE_CFG_T *p_dev_cfg,
11685 + DEV_INSTANCE_CFG_DATA_T *p_dev_inst_data);
11686 +static DEVICE_CFG_T* p_create_dev_cfg(char *device_name);
11687 +static DEVICE_CFG_T* p_get_dev_cfg(char *device_name);
11688 +static int p_set_device_cfg_type(DEVICE_CFG_T *p_dev_cfg,
11689 + CFG_TYPE_T cfg_type);
11691 +/* PSP Config manager debug */
11692 +#define PSP_CFG_MGR_DEBUG 0
11694 +#define dbgPrint if (PSP_CFG_MGR_DEBUG) printk
11696 +/*-----------------------------------------------------------------------------
11697 + * The repository.
11698 + *---------------------------------------------------------------------------*/
11699 +static DEVICE_CFG_LIST_T g_device_cfg_list;
11701 +/*---------------------------------------------
11702 + * Initialize the device collection pool.
11703 + *--------------------------------------------*/
11704 +void p_init_device_cfg_list(void)
11706 + g_device_cfg_list.count = 0;
11707 + g_device_cfg_list.device_cfg_begin = NULL;
11710 +/*----------------------------------------------------------------------
11711 + * Add the device cfg into the device linked list.
11712 + *---------------------------------------------------------------------*/
11713 +int p_add_dev_cfg_to_list(DEVICE_CFG_LIST_T *p_dev_list,
11714 + DEVICE_CFG_T *p_dev_cfg)
11716 + if(p_dev_list->count != 0)
11717 + p_dev_cfg->next = p_dev_list->device_cfg_begin;
11719 + p_dev_list->device_cfg_begin = p_dev_cfg;
11721 + p_dev_list->count++;
11726 +/*------------------------------------------------------------------
11727 + * Add the cfg data into the cfg data linked list of the collection.
11728 + *------------------------------------------------------------------*/
11729 +int p_add_instance_cfg_data(DEVICE_CFG_T *p_dev_cfg,
11730 + DEV_INSTANCE_CFG_DATA_T *p_dev_inst_data)
11732 + if(p_dev_cfg->count == 0)
11733 + p_dev_cfg->dev_inst_list_begin = p_dev_inst_data;
11735 + p_dev_cfg->dev_inst_list_end->next = p_dev_inst_data;
11737 + p_dev_cfg->dev_inst_list_end = p_dev_inst_data;
11739 + p_dev_cfg->count++;
11744 +/*-----------------------------------------------------------------------------
11745 + * Create the device cfg.
11746 + *---------------------------------------------------------------------------*/
11747 +DEVICE_CFG_T *p_create_dev_cfg(char *device_name)
11749 + DEVICE_CFG_T *p_dev_cfg = NULL;
11751 + if((p_dev_cfg = os_malloc(sizeof(DEVICE_CFG_T))) == NULL)
11753 + dbgPrint("Failed to allocate memory for DEVICE_CFG_T.\n");
11755 + else if((p_dev_cfg->device_name = os_malloc(psp_config_strlen(device_name) + 1))==NULL)
11757 + dbgPrint("Failed to allocate memory for device name.\n");
11761 + psp_config_strcpy(p_dev_cfg->device_name, device_name);
11762 + p_dev_cfg->cfg_type = en_raw;
11763 + p_dev_cfg->count = 0;
11764 + p_dev_cfg->dev_inst_list_begin = NULL;
11765 + p_dev_cfg->dev_inst_list_end = NULL;
11766 + p_dev_cfg->next = NULL;
11769 + return(p_dev_cfg);
11772 +/*------------------------------------------------------------------------------
11773 + * Get the device cfg collection.
11774 + *-----------------------------------------------------------------------------*/
11775 +DEVICE_CFG_T *p_get_dev_cfg(char *device_name)
11778 + DEVICE_CFG_T *p_dev_cfg = g_device_cfg_list.device_cfg_begin;
11780 + for(count=0; count < g_device_cfg_list.count; count++)
11782 + if(psp_config_strcmp(device_name, p_dev_cfg->device_name) == 0)
11787 + p_dev_cfg = p_dev_cfg->next;
11790 + return(p_dev_cfg);
11793 +/*-------------------------------------------------------------------------
11794 + * Gets the name for the static cfg type. Utility function. Debug purposes.
11795 + *-------------------------------------------------------------------------*/
11796 +char *p_get_cfg_type_name_for_en(CFG_TYPE_T cfg_type)
11798 + static char raw_str [] = "still raw";
11799 + static char compile_str [] = "configured at compile time";
11800 + static char optconf_str [] = "configured by options.conf";
11801 + static char vlynq_str [] = "configured by VLYNQ";
11802 + static char no_static_str[] = "no static configuration";
11804 + if(cfg_type == en_raw)
11805 + return (raw_str);
11806 + else if(cfg_type == en_compile)
11807 + return (compile_str);
11808 + else if(cfg_type == en_opt_conf)
11809 + return (optconf_str);
11810 + else if(cfg_type == en_vlynq)
11811 + return (vlynq_str);
11813 + return (no_static_str);
11817 +/*-----------------------------------------------------------------------------
11818 + * Sets the static cfg status of the device collection.
11820 + * If the collection is en_virgin then, the collection is assigned to cfg_type.
11821 + * If the cfg_type is en_vlynq then, the old cfg_type is retained.
11822 + * en_compile and en_opt_conf are mutually exclusive. One of these can be
11825 + *---------------------------------------------------------------------------*/
11826 +int p_set_device_cfg_type(DEVICE_CFG_T *p_dev_cfg,
11827 + CFG_TYPE_T cfg_type)
11831 + if(p_dev_cfg->cfg_type == en_raw)
11832 + p_dev_cfg->cfg_type = cfg_type;
11833 + else if((cfg_type == en_vlynq) || (p_dev_cfg->cfg_type == cfg_type))
11837 + dbgPrint("Device %s has been %s which overrides %s.\n",
11838 + p_dev_cfg->device_name,
11839 + p_get_cfg_type_name_for_en(p_dev_cfg->cfg_type),
11840 + p_get_cfg_type_name_for_en(cfg_type));
11847 +/*------------------------------------------------------------------------
11848 + * Add the config str into the repository. The cfg type indicates
11849 + * whether the device has been configured statically, from options.conf or
11850 + * by vlynq enumeration.
11851 + *------------------------------------------------------------------------*/
11852 +int psp_config_add(char *key, void *p_cfg_str, unsigned int cfg_len,
11853 + CFG_TYPE_T cfg_type)
11855 + int ret_val = -1;
11856 + DEVICE_CFG_T *p_dev_cfg = NULL;
11857 + DEV_INSTANCE_CFG_DATA_T *p_dev_inst_data = NULL;
11859 + if(p_cfg_str == NULL || key == NULL)
11861 + dbgPrint("Null input pointer(s).\n");
11863 + /* check if there exist a dev_cfg for the given key, if not,
11864 + then create one and add it to the device list. */
11865 + else if(((p_dev_cfg = p_get_dev_cfg(key)) == NULL) &&
11866 + (((p_dev_cfg = p_create_dev_cfg(key)) == NULL) ||
11867 + p_add_dev_cfg_to_list(&g_device_cfg_list, p_dev_cfg) != 0))
11869 + dbgPrint("Failed to allocate mem or add dev cfg for %s.\n", key);
11871 + /* make sure that we can add this cfg type to the repository */
11872 + else if(p_set_device_cfg_type(p_dev_cfg, cfg_type) == -1)
11874 + dbgPrint("Ignoring \"%s\" for device \"%s\".\n",
11875 + p_get_cfg_type_name_for_en(cfg_type),
11876 + p_dev_cfg->device_name);
11878 + else if((p_dev_inst_data = os_malloc(sizeof(DEV_INSTANCE_CFG_DATA_T)))== NULL)
11880 + dbgPrint("Failed to allocate memory for DEV_INSTANCE_CFG_DATA_T.\n");
11882 + else if((p_dev_inst_data->data = os_malloc(cfg_len) + 1) == NULL)
11884 + dbgPrint("Failed to allocate memory for the config data.\n");
11888 + p_dev_inst_data->next = NULL;
11890 + if(cfg_type == en_opt_conf || cfg_type == en_compile)
11891 + psp_config_strcpy(p_dev_inst_data->locale, "dev on chip ");
11892 + else if(cfg_type == en_vlynq)
11893 + psp_config_strcpy(p_dev_inst_data->locale, "dev on vlynq");
11895 + psp_config_strcpy(p_dev_inst_data->locale, "dev locale ?");
11897 + psp_config_memcpy(p_dev_inst_data->data, p_cfg_str, cfg_len);
11898 + p_dev_inst_data->data_size = cfg_len;
11899 + *(p_dev_inst_data->data + cfg_len) = '\0';
11901 + ret_val = p_add_instance_cfg_data(p_dev_cfg, p_dev_inst_data);
11907 +/*-------------------------------------------------------------
11908 + * Get the total number of device instances in the repository
11909 + *------------------------------------------------------------*/
11910 +int psp_config_get_num_keys(void)
11912 + return(g_device_cfg_list.count);
11916 +/*--------------------------------------------------------------------
11917 + * Get the device configuration info from the repository.
11918 + *-------------------------------------------------------------------*/
11919 +int psp_config_get(char *key, int instance, char **cfg_data_out)
11921 + int ret_val = -1;
11922 + DEVICE_CFG_T *p_dev_cfg = NULL;
11923 + *cfg_data_out = NULL;
11925 + if(key == NULL && cfg_data_out == NULL)
11927 + dbgPrint("Key has a NULL value.\n");
11929 + else if((p_dev_cfg = p_get_dev_cfg(key)) == NULL)
11931 + dbgPrint("cfg information for %s could not be found.\n", key);
11933 + else if(p_dev_cfg->count)
11935 + DEV_INSTANCE_CFG_DATA_T *p_dev_inst_data =
11936 + p_dev_cfg->dev_inst_list_begin;
11939 + index != instance && index < p_dev_cfg->count;
11942 + p_dev_inst_data = p_dev_inst_data->next;
11945 + if(p_dev_inst_data != NULL && p_dev_inst_data->data != NULL)
11947 + *cfg_data_out = p_dev_inst_data->data;
11948 + ret_val = p_dev_inst_data->data_size;
11952 + return (ret_val);
11955 +/*----------------------------------------------------------------
11956 + * Returns the number of instances found in the repository for the
11958 + *---------------------------------------------------------------*/
11959 +int psp_config_get_num_instances(char *key)
11962 + DEVICE_CFG_T *p_dev_cfg = NULL;
11966 + dbgPrint("Key has a NULL value.\n");
11968 + else if((p_dev_cfg = p_get_dev_cfg(key)) == NULL)
11970 + dbgPrint("cfg information for %s could not be found.\n", key);
11974 + ret_val = p_dev_cfg->count;
11977 + return (ret_val);
11980 +/*------------------------------------------------------------------
11981 + * Dump the configuration repository.
11982 + * Caution: DO NOT USE THIS FOR ANY NON NBU specified config format.
11983 + *-----------------------------------------------------------------*/
11984 +void psp_config_print(char *key)
11986 + DEVICE_CFG_T *p_dev_cfg = NULL;
11990 + dbgPrint("Key has a NULL value.\n");
11992 + else if((p_dev_cfg = p_get_dev_cfg(key)) == NULL)
11994 + dbgPrint("cfg information for %s could not be found.\n", key);
11996 + else if(p_dev_cfg && p_dev_cfg->count)
11998 + DEV_INSTANCE_CFG_DATA_T *p_dev_inst_data;
12000 + p_dev_inst_data = p_dev_cfg->dev_inst_list_begin;
12004 + dbgPrint("%s : %s\n", p_dev_inst_data->locale,
12005 + p_dev_inst_data->data);
12006 + p_dev_inst_data = p_dev_inst_data->next;
12008 + } while(p_dev_inst_data);
12012 + dbgPrint("Nothing was found for %s.\n", key);
12016 +void dump_device_cfg_pool(void)
12018 + DEVICE_CFG_T *p_dev_cfg = g_device_cfg_list.device_cfg_begin;
12020 + if(p_dev_cfg != NULL && g_device_cfg_list.count)
12024 + for(index=0; index < g_device_cfg_list.count; index++)
12026 + psp_config_print(p_dev_cfg->device_name);
12027 + p_dev_cfg = p_dev_cfg->next;
12032 + dbgPrint("repository is empty.\n");
12036 +void psp_config_init(void)
12038 + p_init_device_cfg_list();
12041 +void psp_config_cleanup()
12043 + int dev_count = 0;
12044 + int inst_count = 0;
12045 + DEVICE_CFG_T *p = g_device_cfg_list.device_cfg_begin;
12046 + DEV_INSTANCE_CFG_DATA_T *q = NULL;
12048 + for(dev_count = 0; dev_count < g_device_cfg_list.count; dev_count++)
12050 + DEVICE_CFG_T *p_temp = NULL;
12051 + if(p) q = p->dev_inst_list_begin;
12053 + for(inst_count = 0; inst_count < p->count && q != NULL; inst_count++)
12055 + DEV_INSTANCE_CFG_DATA_T *q_temp = q;
12056 + q_temp = q->next;
12062 + p_temp = p->next;
12067 diff -urN linux.old/drivers/net/avalanche_cpmac/psp_config_mgr.h linux.dev/drivers/net/avalanche_cpmac/psp_config_mgr.h
12068 --- linux.old/drivers/net/avalanche_cpmac/psp_config_mgr.h 1970-01-01 01:00:00.000000000 +0100
12069 +++ linux.dev/drivers/net/avalanche_cpmac/psp_config_mgr.h 2005-07-12 02:48:42.177573000 +0200
12071 +/******************************************************************************
12072 + * FILE PURPOSE: PSP Config Manager Header
12073 + ******************************************************************************
12074 + * FILE NAME: psp_config_mgr.h
12076 + * DESCRIPTION: Storing and retrieving the configuration based on key
12077 + * A set of APIs to be used by one and sundry (including drivers and enumerator) to build
12078 + * and read cfg information of the devices for an avalanche SOC.
12080 + * This set of APIs isolates the configuration management from the world and provides simple
12081 + * access convinience.
12083 + * Device in this set refers to the peripherals that can be found on the SOC or on VLYNQ.
12084 + * The configuration is stored in the form of string and drivers can use these APIs to get
12085 + * a particular parameter value.
12087 + * The memory allocation for the pass back parameters is done by the caller.
12089 + * 0 is returned for SUCCESS or TRUE.
12090 + * -1 is returned for FAILURE or FALSE.
12092 + * REVISION HISTORY:
12093 + * 27 Nov 02 - PSP TII
12095 + * (C) Copyright 2002, Texas Instruments, Inc
12096 + *******************************************************************************/
12098 +#ifndef __PSP_CONFIG_MGR_H__
12099 +#define __PSP_CONFIG_MGR_H__
12101 +typedef enum cfg_type
12109 +/* Build psp configuration */
12110 +void build_psp_config(void);
12112 +/********************************************************
12113 + * Access Operations.
12114 + ********************************************************/
12116 +/*-------------------------------------------------------------------------
12117 + initializes the configuration repository.
12118 + -------------------------------------------------------------------------*/
12119 +void psp_config_init(void);
12121 +/*--------------------------------------------------------------------------
12122 + Adds the configuration information into the repository. 'key' is required
12123 + to be NULL terminated string. 'cfg_ptr' points to the configuration data.
12124 + 'cfg_len' is the length of the data pointed to by 'cfg_ptr' in bytes.
12125 + 'cfg_type' indicates the type of config information.
12127 + psp_config_mgr copies the 'cfg_len' bytes of data pointed to by 'cfg_ptr'
12128 + into its internal repository.
12130 + Returns: 0 on success, -1 on failure.
12131 + -------------------------------------------------------------------------*/
12132 +int psp_config_add(char *key, void *cfg_ptr,
12133 + unsigned int cfg_len, CFG_TYPE_T cfg_type);
12136 +/* --------------------------------------------------------------------------
12137 + Passes back, in "*cfg_out_val" a pointer to the config data in the repository
12138 + for the specified 'key' and 'instance'. It returns the size of the config
12141 + psp_config_mgr passes back a pointer in '*cfg_out_val' which refers to
12142 + some location in its internal repository. It is strongly recommended that
12143 + if the user intends to modify the contents of the config info for reasons
12144 + whatsoever, then, user should allocate memory of size returned by this
12145 + routine and copy the contents from '*cfg_out_val'.
12147 + Any, modification carried out on the repository would lead to un-expected
12150 + Returns: 0 or more for the size of config info, -1 on error.
12151 + --------------------------------------------------------------------------*/
12152 +int psp_config_get(char *key, int instance, char **cfg_out_val);
12155 +/*--------------------------------------------------------------------------
12156 + Get the number of keys that have been added in the repository so far.
12158 + Returns: 0 or more for the num of keys, -1 on error.
12159 + -------------------------------------------------------------------------*/
12160 +int psp_config_get_num_keys(void);
12163 +/*--------------------------------------------------------------------------
12164 + Get the number of instances that are present in the repository for the
12167 + Returns: 0 or more for the num of instances, -1 on error.
12168 + -------------------------------------------------------------------------*/
12169 +int psp_config_get_num_instances(char *key);
12172 +/*--------------------------------------------------------------------------
12173 + Prints the config data for all instances associated with the specified
12175 + -------------------------------------------------------------------------*/
12176 +void psp_config_print(char *key);
12178 +void dump_device_cfg_pool(void);
12180 +#endif /* __PSP_CONFIG_MGR_H__ */
12181 diff -urN linux.old/drivers/net/avalanche_cpmac/psp_config_parse.c linux.dev/drivers/net/avalanche_cpmac/psp_config_parse.c
12182 --- linux.old/drivers/net/avalanche_cpmac/psp_config_parse.c 1970-01-01 01:00:00.000000000 +0100
12183 +++ linux.dev/drivers/net/avalanche_cpmac/psp_config_parse.c 2005-07-12 02:48:42.178573000 +0200
12185 +/******************************************************************************
12186 + * FILE PURPOSE: PSP Config Manager - Parse API Source
12187 + ******************************************************************************
12188 + * FILE NAME: psp_config_parse.c
12190 + * DESCRIPTION: These APIs should be used only for scanvenging parameters which
12191 + * are stored in the following format.
12193 + * str[] = "module(id=[module], k1=v1, k2=[k3=v3, k4=v4], k5=v5)"
12195 + * REVISION HISTORY:
12196 + * 27 Nov 02 - PSP TII
12198 + * (C) Copyright 2002, Texas Instruments, Inc
12199 + *******************************************************************************/
12201 +//#include <stdio.h>
12202 +#include <linux/stddef.h>
12204 +/*--------------------------------------------------
12206 + *-------------------------------------------------*/
12207 +#define my_isdigit(c) (c >= '0' && c <= '9')
12208 +#define my_isoct(c) (c >= '0' && c <= '7')
12209 +#define my_xtod(c) ((c) <= '9' ? (c) - '0' : (c) - 'a' + 10)
12210 +#define my_ifupper(c) (c >= 'A' && c <= 'F')
12211 +#define XTOD(c) ((c) - 'A' + 10)
12212 +#define my_ishex(c) ((c >= 'a' && c <='f') || (c >= 'A' && c<='F') || my_isdigit(c) )
12214 +/*---------------------------------------------------
12215 + * Local Functions.
12216 + *--------------------------------------------------*/
12217 +static int p_get_substr_from_str(char *p_in_str, char begin_delimiter,
12218 + char end_delimiter, int pair_flag,
12219 + char **p_out_str);
12220 +static int p_get_u_int_from_str(char *p_in_str, char begin_delimiter,
12221 + char end_delimiter, unsigned long *out_val);
12223 +/*---------------------------------------------------
12224 + * Return pointer to first instance of the char.
12225 + *--------------------------------------------------*/
12226 +static char* psp_config_strchr(char *str, char chr)
12235 + return((*str) ? str : NULL);
12238 +/*------------------------------------------------------------------------
12239 + * Convert the string upto delimiter to unsigned long.
12240 + *-----------------------------------------------------------------------*/
12241 +unsigned long my_atoul(char *p, char end_delimiter, unsigned long *out_val)
12246 + /* check the for null input */
12252 + /* pass through the leading spaces */
12253 + if (!my_isdigit(c))
12255 + while ( c == ' ')
12262 + if(*(p + 1) == 'x' || *(p+1) == 'X' )
12264 + /* string is in hex format */
12271 + if(my_ifupper(c))
12277 + return -1; /* invalid hex string format */
12279 + while ((c = *++p) && my_ishex(c))
12282 + if(my_ifupper(c))
12290 + /* string is in octal format */
12292 + if( my_isoct(c) )
12295 + return -1; /* invalid octal string format */
12297 + while ((c = *++p) && my_isoct(c))
12307 + /* string is in decimal format */
12309 + if( my_isdigit(c) )
12312 + return -1; /* invalid decimal string format */
12314 + while ((c = *++p) && my_isdigit(c))
12321 + /* move through the trailing spaces */
12325 + if(*p == end_delimiter)
12332 + return -1; /* invalid string format */
12335 +/*---------------------------------------------------------------------------------
12336 + * Gets the substring de-limited by the 'begin_delimiter' and 'end_delimiter'.
12337 + * and returns the size of the substring.
12339 + * Parses the NULL terminated p_in_str for a character array delimited by
12340 + * begin_delimiter and end_delimiter, passes back the pointer to the character
12341 + * array in ' *p_out_str '. The passed pointer ' *p_out_str ' should point to
12342 + * the location next (byte) to the begin_delimiter. The function routine returns
12343 + * the number of characters excluding the begin_delimiter and end_delimiter,
12344 + * found in the array delimited by the said delimiters.
12346 + * If the pair_flag is set to 1, then, number of begin_delimiter and end_delimiter
12347 + * found in the parsing should match (equal) and this routine passes back the
12348 + * pointer to the character array, starting at a location next (byte) to the
12349 + * first begin_delimiter, inclusive of all intermediate matching delimiter
12350 + * characters found between outer delimiters. If the pair flag is set and if
12351 + * begin_delimiter and end_delimiter happens to be same, then error (-1) is
12354 + * Return: 0 or more to indicate the size of the substring, -1 on error.
12355 + *-------------------------------------------------------------------------------*/
12356 +int p_get_substr_from_str(char *p_in_str, char begin_delimiter,
12357 + char end_delimiter, int pair_flag,
12358 + char **p_out_str)
12362 + if(pair_flag && begin_delimiter == end_delimiter)
12365 + if((p_in_str = psp_config_strchr(p_in_str, begin_delimiter)) == 0)
12366 + return -1; /* no start delimiter found */
12369 + *p_out_str = p_in_str;
12371 + for(pos = 0,cnt =1; cnt && p_in_str[pos] ; pos++)
12373 + if(p_in_str[pos] == end_delimiter)
12375 + if(pair_flag == 0)
12380 + else if(p_in_str[pos] == begin_delimiter)
12383 + ; /* We do nothing */
12390 + return -1; /* no corresponding end delimiter found */
12393 +/*--------------------------------------------------------------------------
12394 + * Parses the NULL terminated p_in_str for unsigned long value delimited by
12395 + * begin_delimiter and end_delimiter, passes back the found in ' *out_val '.
12396 + * The function routine returns 0 on success and returns -1 on failure.
12397 + * The first instance of the de-limiter should be accounted for the parsing.
12399 + * The base for unsigned value would 10, octal and hex. The value passed back
12400 + * would be of the base 10. Spaces at the begining of the byte array are valid
12401 + * and should be ingnored in the calculation of the value. Space character in
12402 + * the middle of the byte array or any character other than the valid ones
12403 + * (based on base type) should return error. The octal value begins with '0',
12404 + * the hex value begins with "0x" or "0X", the base value can begin with
12407 + * Returns: 0 on success, -1 on failure.
12408 + *-------------------------------------------------------------------------*/
12409 +int p_get_u_int_from_str(char *p_in_str, char begin_delimiter,
12410 + char end_delimiter, unsigned long *out_val)
12413 + unsigned long num;
12415 + num = p_get_substr_from_str(p_in_str, begin_delimiter, end_delimiter,
12418 + if(num == (unsigned long)-1)
12421 + return my_atoul(start,end_delimiter,out_val);
12424 +/*--------------------------------------------------------------------------
12425 + * Finds the first occurrence of the substring p_find_str in the string
12427 + *-------------------------------------------------------------------------*/
12428 +char *my_strstr(char *p_in_str, const char *p_find_str)
12430 + char *p = (char *)p_find_str;
12431 + char *ret = NULL;
12437 + else if(*p_in_str == *p)
12439 + if(!ret) ret = p_in_str;
12445 + p = (char *)p_find_str;
12446 + p_in_str = ret + 1;
12453 + if(*p_in_str != *p) ret = NULL;
12459 +/*------------------------------------------------------------------------------
12460 + * Gets the value of the config param in the unsigned int format. The value is
12461 + * stored in the following format in the string.
12462 + * str[] = "module(id=[module], k1=v1, k2=[k3=v3, k4=v4], k5=v5)"
12463 + *-----------------------------------------------------------------------------*/
12464 +int psp_config_get_param_uint(char *p_in_str, const char *param, unsigned int *out_val)
12466 + int ret_val = -1;
12469 + if(!p_in_str || !param || !out_val)
12473 + else if((p_strstr = my_strstr(p_in_str, param)) == NULL)
12477 + else if(p_get_u_int_from_str(p_strstr, '=', ',', (unsigned long *)out_val) == 0)
12481 + else if(p_get_u_int_from_str(p_strstr, '=', ']', (unsigned long*)out_val) == 0)
12485 + else if(p_get_u_int_from_str(p_strstr, '=', ')', (unsigned long*)out_val) == 0)
12494 + return (ret_val);
12497 +/*------------------------------------------------------------------------------
12498 + * Gets the value of the config param in the Non NULL terminated format. The value
12499 + * is stored in the following format in the string.
12500 + * str[] = "module(id=[module], k1=v1, k2=[k3=v3, k4=v4], k5=v5)"
12501 + *-----------------------------------------------------------------------------*/
12502 +int psp_config_get_param_string(char *p_in_str, const char *param, char **out_val)
12504 + int ret_val = -1;
12507 + if(!p_in_str || !param || !(out_val))
12509 + else if((p_strstr = my_strstr(p_in_str, param)) == NULL)
12513 + else if((ret_val = p_get_substr_from_str(p_strstr, '[', ']', 1, out_val)) == -1)
12519 + ; /* we got the value */
12522 + return (ret_val);
12525 +#ifdef PSP_CONFIG_MGR_DEBUG_TEST
12528 + unsigned long num =999;
12530 + char *val1 = NULL;
12532 + char str1[] = "cpmac(id=[cpmac], k0=[a1=[a2=[test], a3=2], k1=100, k2=[k3=300, k4=200], k7=722)";
12534 + psp_config_get_param_uint(str1, "k7", &num);
12535 + printf("%u.\n", num);
12536 + ret = psp_config_get_param_string(str1, "a1", &val1);
12537 + if(ret >= 0) { printf("%d.\n", ret); strncpy(val, val1, ret); val[ret] = '\0';}
12539 + printf("val = \"%s\", and size = %d \n", val, ret);
12541 + if(val[ret]) ; else printf("jeee.\n");
12543 +#endif /* PSP_CONFIG_MGR_DEBUG_TEST */
12547 diff -urN linux.old/drivers/net/avalanche_cpmac/psp_config_parse.h linux.dev/drivers/net/avalanche_cpmac/psp_config_parse.h
12548 --- linux.old/drivers/net/avalanche_cpmac/psp_config_parse.h 1970-01-01 01:00:00.000000000 +0100
12549 +++ linux.dev/drivers/net/avalanche_cpmac/psp_config_parse.h 2005-07-12 02:48:42.178573000 +0200
12551 +/******************************************************************************
12552 + * FILE PURPOSE: PSP Config Manager - Parse API Header
12553 + ******************************************************************************
12554 + * FILE NAME: psp_config_parse.h
12556 + * DESCRIPTION: Parsing for params from string available in the NBU format.
12557 + * These APIs should be used only for scanvenging parameters which
12558 + * are stored in the following format.
12560 + * str[] = "module(id=[module], k1=v1, k2=[k3=v3, k4=v4], k5=v5)"
12562 + * REVISION HISTORY:
12563 + * 27 Nov 02 - PSP TII
12565 + * (C) Copyright 2002, Texas Instruments, Inc
12566 + *******************************************************************************/
12568 +#ifndef __PSP_CONFIG_PARSER_H__
12569 +#define __PSP_CONFIG_PARSER_H__
12571 +/*------------------------------------------------------------------
12572 + * These APIs should be used only for scanvenging parameters which
12573 + * are stored in the following format.
12575 + * str[] = "module(id=[module], k1=v1, k2=[k3=v3, k4=v4], k5=v5)"
12576 + *-----------------------------------------------------------------*/
12577 +int psp_config_get_param_uint(char *p_in_str, const char *param,
12578 + unsigned int *out_val);
12579 +int psp_config_get_param_string(char *p_in_str, const char *param,
12582 +#endif /* __PSP_CONFIG_PARSER_H__ */
12583 diff -urN linux.old/drivers/net/avalanche_cpmac/psp_config_util.c linux.dev/drivers/net/avalanche_cpmac/psp_config_util.c
12584 --- linux.old/drivers/net/avalanche_cpmac/psp_config_util.c 1970-01-01 01:00:00.000000000 +0100
12585 +++ linux.dev/drivers/net/avalanche_cpmac/psp_config_util.c 2005-07-12 02:48:42.178573000 +0200
12587 +/******************************************************************************
12588 + * FILE PURPOSE: PSP Config Manager - Utilities API Source
12589 + ******************************************************************************
12590 + * FILE NAME: psp_config_util.c
12592 + * DESCRIPTION: These APIs provide the standard "C" string interfaces.
12593 + * Provided here to reduce dependencies on the standard libraries
12594 + * and for cases where psp_config would required to run before
12595 + * the whole system is loaded or outside the scope of the OS.
12597 + * REVISION HISTORY:
12598 + * 27 Nov 02 - PSP TII
12600 + * (C) Copyright 2002, Texas Instruments, Inc
12601 + *******************************************************************************/
12603 +//#include <stdio.h>
12604 +#include "psp_config_util.h"
12605 +#include <linux/stddef.h>
12607 +/*---------------------------------------------
12609 + *-------------------------------------------*/
12610 +int psp_config_strlen(char *p)
12612 + char *p_orig = p;
12615 + return(p - p_orig);
12618 +/*--------------------------------------------
12620 + *-------------------------------------------*/
12621 +int psp_config_strcmp(char *s1, char *s2)
12623 + while(*s1 && *s2)
12631 + return(*s1 - *s2);
12634 +/*--------------------------------------------
12636 + *------------------------------------------*/
12637 +char* psp_config_strcpy(char *dest, char *src)
12639 + char *dest_orig = dest;
12643 + *dest++ = *src++;
12648 + return(dest_orig);
12651 +/*----------------------------------------------
12652 + * psp_config_memcpy.
12653 + *--------------------------------------------*/
12654 +void* psp_config_memcpy(void* dest, void* src, unsigned int n)
12656 + void *dest_orig = dest;
12660 + *(char *)dest++ = *(char *)src++;
12664 + return (dest_orig);
12667 +/*---------------------------------------------------
12668 + * Return pointer to first instance of the char.
12669 + *--------------------------------------------------*/
12670 +char* psp_config_strchr(char *str, char chr)
12679 + return((*str) ? str : NULL);
12682 +#ifdef PSP_CONFIG_MGR_DEBUG_TEST
12686 + char s[] = "hello ";
12687 + printf("%d.\n", psp_config_strlen("hello\n"));
12688 + printf("%d.\n", psp_config_strcmp("hells", "hellq"));
12689 + printf("%s %s.\n", psp_config_strcpy(s + 6, "test1"), s);
12692 +#endif /* PSP_CONFIG_MGR_DEBUG_TEST */
12693 diff -urN linux.old/drivers/net/avalanche_cpmac/psp_config_util.h linux.dev/drivers/net/avalanche_cpmac/psp_config_util.h
12694 --- linux.old/drivers/net/avalanche_cpmac/psp_config_util.h 1970-01-01 01:00:00.000000000 +0100
12695 +++ linux.dev/drivers/net/avalanche_cpmac/psp_config_util.h 2005-07-12 02:48:42.179573000 +0200
12697 +/******************************************************************************
12698 + * FILE PURPOSE: PSP Config Manager - Utilities API Header
12699 + ******************************************************************************
12700 + * FILE NAME: psp_config_util.h
12702 + * DESCRIPTION: These APIs provide the standard "C" string interfaces.
12703 + * Provided here to reduce dependencies on the standard libraries
12704 + * and for cases where psp_config would required to run before
12705 + * the whole system is loaded or outside the scope of the OS.
12707 + * REVISION HISTORY:
12708 + * 27 Nov 02 - PSP TII
12710 + * (C) Copyright 2002, Texas Instruments, Inc
12711 + *******************************************************************************/
12713 +#ifndef __PSP_CONFIG_UTIL_H__
12714 +#define __PSP_CONFIG_UTIL_H__
12716 +extern int psp_config_strlen(char*);
12717 +extern int psp_config_strcmp(char*, char*);
12718 +extern char* psp_config_strcpy(char*, char*);
12719 +extern void* psp_config_memcpy(void*, void*, unsigned int n);
12720 +extern char* psp_config_strchr(char*, char);
12722 +#endif /* __PSP_CONFIG_UTIL_H__ */
12723 diff -urN linux.old/drivers/net/avalanche_cpmac/readme.txt linux.dev/drivers/net/avalanche_cpmac/readme.txt
12724 --- linux.old/drivers/net/avalanche_cpmac/readme.txt 1970-01-01 01:00:00.000000000 +0100
12725 +++ linux.dev/drivers/net/avalanche_cpmac/readme.txt 2005-07-12 02:48:42.179573000 +0200
12727 +23 August 2004 CPMAC 1.7.8 (NSP Performance Team Release)
12729 +CC Labels: REL_20040823_HALdallas_cpmac_01.07.08
12731 +New features: Key "MacAddr" can now be used to set the Mac Address after Open.
12733 + unsigned char MacAddr[6];
12735 + // Set Mac Address to "00.B0.D0.10.80.C1"
12736 + MacAddr[0] = 0x00;
12737 + MacAddr[1] = 0xB0;
12738 + MacAddr[2] = 0xD0;
12739 + MacAddr[3] = 0x10;
12740 + MacAddr[4] = 0x80;
12741 + MacAddr[5] = 0xC1;
12743 + HalFunc->Control(HalDev, "MacAddr", hcSet, &MacAddr);
12745 +Bug fixes: in Send(), Threshold is not checked if Tx Ints are re-enabled.
12747 +Modules affected: hcpmac.c, hcpmac.h, cppi_cpmac.c
12749 +22 June 2004 CPMAC 1.7.6 (NSP Performance Team Release)
12751 +CC Labels: REL_20040622_HALdallas_cpmac_01.07.06
12753 +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.
12756 + HalFunc->Control(HalDev, "TxIntDisable", "Set", &On);
12760 +10 June 2004 CPMAC 1.7.5 (external release)
12762 +CC Labels: REL_20040610_HALdallas_cpmac_01.07.05
12766 +Bug fixes: Fixed an issue with calculation for the multicast hash.
12768 +27 May 2004 CPSAR 1.7.4, CPMAC 1.7.4 (external release)
12770 +CC Labels: REL_20040527_HALdallas_cpsar_01.07.04
12771 + REL_20040527_HALdallas_cpmac_01.07.04
12775 +Bug fixes: A flaw was fixed in the critical sectioning of the CPPI file, affecting both
12776 + the MAC and the SAR releases. This flaw was detected on Titan PSP 4.7 BFT2.
12778 +05 May 2004 CPSAR 1.7.3, CPMAC 1.7.3 (external release)
12780 +CC Labels: REL_20040505_HALdallas_cpsar_01.07.03
12781 + REL_20040505_HALdallas_cpmac_01.07.03
12785 +Bug fixes: 1) Firmware has been updated to fix a problem with Host OAM mode operation.
12786 + 2) Cache macros have been fixed.
12788 +Notes: This release contains all performance enhancements currently available for CPHAL 1.x.
12790 +19 April 2004 CPSAR 1.7.2, CPMAC 1.7.2 (external release)
12792 +CC Labels: REL_20040419_HALdallas_cpsar_01.07.02
12793 + REL_20040419_HALdallas_cpmac_01.07.02
12797 +Bug fixes: Fixes merge problem in 1.7.1.
12799 +Notes: This is a branch release which contains only a subset of the performance improvements.
12800 + The remaining performance improvements are stiill being qualified at this time.
12802 +1 April 2004 CPSAR 1.7.1, CPMAC 1.7.1 (external release)
12804 +NOTICE: DO NOT USE 1.7.1. It has a known problem (see 1.7.2 notes)
12806 +CC Labels: REL_20040401_HALdallas_cpsar_01.07.01
12807 + REL_20040401_HALdallas_cpmac_01.07.01
12809 +New features: Performance improvement in CPPI layer, affecting both CPSAR and CPMAC.
12813 +17 Februrary 2004 CPSAR 1.7.0 (external release)
12815 +CC Labels: REL_20040217_HALdallas_cpsar_01.07.00
12817 +New features: Added support for "TxFlush" feature. This allows the upper
12818 + layer to flush all or part of a given Tx queue for a given
12819 + channel. This is to be used during call setup for a voice
12822 +30 January 2004 CPMAC 1.7.0 (external release)
12824 +CC Labels: REL_20040130_HALdallas_cpmac_01.07.00
12826 +Bug fixes: CPMDIO - When in manual negotiate mode and linked, dropping link would move into NWAY state rather than manual state.
12827 + CPMDIO - Extraneous debug message corrected
12828 +New features: CPMDIO - Support for AutoMdix usage added.
12830 +25 September 2003 CPSAR 1.6.6 (external release)
12832 +CC Labels: REL_20030925_HALdallas_cpsar_01.06.06
12834 +Bug fixes: PDSP firmware has been updated to fix the OAM padding problem. It previously
12835 + wrote pad bytes into a reserved field of the OAM cell. There is a small
12836 + change to the CPSAR configuration code which corresponds to the PDSP spec
12841 +09 September 2003 CPMAC 1.6.6 (external release)
12843 +CC Labels: REL_20030909_HALdallas_cpmac_01.06.06
12845 +Bug fixes: CPMAC : When _CPMDIO_NOPHY is set, Cpmac COntrol is set to Full Duplex
12846 + Bridge loopback test does not show a problem using 1.6.5 if packet rate is
12847 + below 50,000 pbs. Now testing with a 100% send from Ixia.
12851 +05 August 2003 CPHAL 1.6.5 (external release)
12853 +CC Labels: REL_20030805_HALdallas_cpmac_01.06.05
12857 +New features: CPMAC : Added support for CPMAC modules that do not have a Phy connected.
12858 + The CPMAC is informed of this by the MdioConnect option
12859 + _CPMDIO_NOPHY. This is the only driver change needed to
12860 + receive and transmit packets through the Marvel switch.
12861 + Note In this mode Link status will reported linked at 100/FD to
12862 + PhyNum 0xFFFFFFFF.
12864 + ALL: Cleaned up some Vlynq support logic.
12866 +16 July 2003 CPSAR 1.6.3 (external release), no CPMAC release
12868 +CC Labels: REL_20030716_HALdallas_cpsar_01.06.03
12870 +Bug fixes: 1) Changed default value of CPCS_UU from 0x5aa5 to 0. The old default value caused
12871 + problems with Cisco routers.
12875 +Known issues not addressed in this release: NTR.
12877 +01 July 2003 CPHAL 1.6.2 (external release)
12879 +CC Labels: REL_20030701_HALdallas_cpmac_01.06.02
12880 + REL_20030701_HALdallas_cpsar_01.06.02
12882 +Bug fixes: 1) A previous firmware upgrade caused firmware OAM loopback cells to only work on every other
12883 + command. This has been fixed in the new firmware version (0.47).
12884 + 2) Problem with PTI values changing on transparent mode packets has been resolved.
12885 + 3) Previously, successful firmware OAM loopback cells waited 5 seconds before notifying the
12886 + OS of success, rather that notifying immediately. This has been resolved in firmware.
12887 + 4) PITS #148 (MAC and SAR), #149 (MAC) have been fixed.
12889 +New features: 1) AAL5 HAL now capable of receiving unknown VCI/VPI cells on a single transparent channel.
12890 + See updated HAL document (AAL5 appendix) for implementation details.
12891 + 2) AAL5 HAL now allows OS to modify the OAM loopback timeout window. Previously, failed
12892 + OAM loopback attempts timed out after a nominal 5 seconds (based on the SAR frequency
12893 + provided by the OS). Now, the default is 5 seconds, but the OS may change the
12894 + value via halControl() to any integer number of milliseconds. See updated HAL document
12895 + (AAL5 appendix) for implementation details.
12896 + 3) MAC (cpmdio): added loopback to Istate. Used for debug.
12898 +Known issues not addressed in this release: NTR.
12900 +09 June 2003 CPSAR 1.6.1 (external release), CPMAC 1.6.1 (internal release - no functional change)
12902 +Note: This is the same set of fixes being applied to 1.6.0 that were applied to 1.5.3. The only difference
12903 + between 1.6.1 and 1.5.4 is that 1.6.1 has the TurboDSL fix.
12905 +CC Labels: REL_20030609_HALdallas_cpmac_01.06.01
12906 + REL_20030609_HALdallas_cpsar_01.06.01
12908 +Bug fixes: 1) Bug in OamLoopbackConfig fixed.
12909 + 2) New firmware version (.43) to fix Westell issue of dropped downstream packets in
12910 + presence of OAM traffic when operating at or near line rate.
12912 +New features: NTR.
12914 +09 June 2003 CPSAR 1.5.4 (external release), CPMAC 1.5.4 (internal release - no functional change)
12916 +Note: This is a branch release from 1.5.3. This does not contain anything from 1.6.0. The CPMAC is
12917 +only being labeled to keep the release flow consistent.
12919 +CC Labels: REL_20030609_HALdallas_cpmac_01.05.04
12920 + REL_20030609_HALdallas_cpsar_01.05.04
12922 +Bug fixes: 1) Bug in OamLoopbackConfig fixed.
12923 + 2) New firmware version (.43) to fix Westell issue of dropped downstream packets in
12924 + presence of OAM traffic when operating at or near line rate.
12926 +New features: NTR.
12928 +30 May 2003 CPSAR 1.6.0 (external release), CPMAC 1.6.0 (internal release - no functional change)
12930 +CC Labels: REL_20030530_HALdallas_cpmac_01.06.00
12931 + REL_20030530_HALdallas_cpsar_01.06.00
12933 +Bug fixes: 1) TurboDSL issue has been fixed with a software workaround in TxInt. This workaround
12934 + has been verified under Adam2 ONLY at this point. Testing remains to be done on
12935 + Linux and VxWorks.
12937 +New features: NTR.
12939 +Known issues not addressed in this release: NTR.
12941 +30 May 2003 CPSAR 1.5.3 (external release), CPMAC 1.5.3 (internal release - no functional change)
12943 +CC Labels: REL_20030530_HALdallas_cpmac_01.05.03
12944 + REL_20030530_HALdallas_cpsar_01.05.03
12948 +New features: 1) AAL5 Send() has been modified to accept an ATM Header either in the first
12949 + fragment by itself, or in the first fragment directly in front of payload data.
12950 + The API() does not change.
12951 + 2) Documentation updates throughout, reflected in latest version of CPHAL user's
12953 + 3) AAL5 MaxFrags default value is now 46. This is based upon the default AAL5
12954 + RxBufSize of 1518 (MaxFrags = (65568/1518) + 2). IF THE OS CHOOSES A SMALLER
12955 + RxBufSize, IT MUST INCREASE THE VALUE OF MaxFrags ACCORDINGLY. This is done
12956 + via halControl(), prior to Open().
12958 +Known issues not addressed in this release:
12959 + 1) The Linux SAR driver is seeing an issue in which it cannot
12960 + reliably send traffic simultaneously on both the high and
12961 + low priority queues of a single AAL5 channel. (TurboDSL)
12963 +23 May 2003 CPHAL 1.5.2 (external release)
12965 +CC Labels: REL_20030523_HALdallas_cpmac_01.05.02
12966 + REL_20030523_HALdallas_cpsar_01.05.02
12968 +Bug fixes: 1) PITS #138: CPMAC flooding issue resolved.
12969 + 2) PITS #142: OS may now set "MaxFrags" via Control(). This controls the
12970 + maximum number of fragments expected by the CPHAL. The default value is 2 for
12971 + CPMAC and 1028 for AAL5. If the OS chooses a RxBufSize that will cause more
12972 + fragments than the defaults, the OS must set "MaxFrags" to a correct value
12973 + ((maximum packet length / RxBufSize) + 2).
12974 + 3) PITS #143: Fixed.
12975 + 4) Firmware OAM bug fixed. (new firmware release in this version)
12977 +New features: NTR.
12979 +Known issues not addressed in this release:
12980 + 1) The Linux SAR driver is seeing an issue in which it cannot
12981 + reliably send traffic simultaneously on both the high and
12982 + low priority queues of a single AAL5 channel. (TurboDSL)
12984 +14 May 2003 CPHAL 1.5.1 (external release)
12986 +CC Labels: REL_20030514_HALdallas_cpmac_01.05.01
12987 + REL_20030514_HALdallas_cpsar_01.05.01
12989 +Bug fixes: 1) PITS 132 - (CPMAC) Frames < 60 bytes and split into
12991 + 2) BCIL MR PSP00000353 - (CPMAC) PhyDev not free'd on halClose()
12992 + 3) PITS 113 - OsSetup bug in ChannelSetup fixed.
12993 + 4) Fixed AAL5 to check return values of InitTcb/InitRcb.
12994 + 5) Fixed Shutdown to properly free resources in the case of a Close
12995 + mode 1 followed by Shutdown. Previously, buffer and descriptor
12996 + resources were left unfreed in this case.
12998 +New features: 1) AAL5 Send() modified to be capable of accepting ATM header as first four
12999 + bytes of first fragment. This allows the OS to "override" the
13000 + default ATM header which is constructed from preconfigured channel
13002 + 2) AAL5 Receive() modified to be capable of passing the received ATM header (4 bytes, no HEC)
13003 + in the first fragment (by itself). It also passes up the OS an indication
13004 + of what the received packet type was. For Host OAM and transparent mode
13005 + packets, the ATM header is passed in this manner, and for other types of packets
13006 + (AAL5, NULL AAL) no ATM header is passed currently.
13008 +Known issues not addressed in this release:
13009 + 1) The Linux SAR driver is seeing an issue in which it cannot
13010 + reliably send traffic simultaneously on both the high and
13011 + low priority queues of a single AAL5 channel.
13013 +30 April 2003 CPHAL 1.5.0 (external release)
13015 +CC Labels: REL_20030430_HALdallas_cpmac_01.05.00
13016 + REL_20030430_HALdallas_cpsar_01.05.00
13018 +Bug fixes: 1) Fixed AAL5 bug that rendered the low priority queue
13020 + 2) Fixed a bug in AAL5's Oam Rate calculations.
13021 + 3) Fixed use of "DeviceCPID" key in AAL5's halControl().
13022 + 4) Fixed RxReturn logic in HAL. The HAL now can handle
13023 + failing MallocRxBuffer calls when multiple fragments
13026 +New features: 1) AAL5 Stats now available on a per queue basis.
13027 + 2) AAL5 adds two new keys to halControl() for "Set" actions:
13028 + RxVc_OamCh and RxVp_OamCh.
13029 + 3) Shutdown() has been modified for both AAL5 and CPMAC to
13030 + call Close() if the module is still in the Open state.
13031 + 4) CPMAC adds the following access keys to halControl():
13032 + hcPhyAccess,hcPhyNum,hcCpmacBase,hcSize,and hcCpmacSize.
13033 + 5) CPHAL no longer requests an extra 15 bytes on data buffer
13036 +Known issues not addressed in this release:
13037 + 1) The Linux SAR driver is seeing an issue in which it cannot
13038 + reliably send traffic simultaneously on both the high and
13039 + low priority queues of a single AAL5 channel.
13041 +21 April 2003 CPHAL 1.4.1 (external release)
13043 +CC Labels: REL_20030421_HALdallas_cpmac_01.04.01
13044 + REL_20030421_HALdallas_cpsar_01.04.01
13046 +Bug fixes: 1) Fixed OAM logic in SAR portion of CPHAL.
13048 +New features: 1) OAM loopback counters exposed through halControl.
13049 + 2) Host OAM Send() can now use a single channel to send
13050 + OAM cells on unlimited number of VP's/VC's.
13051 + 3) CPHAL now requests "SarFreq" through osControl.
13052 + 4) CPHAL now calculates all OAM function rates based on
13053 + "SarFreq"; function OamRateConfig removed for API.
13054 + 5) New OAM function OamLoopbackConfig, used for configuring
13055 + loopback functions in firmware OAM mode.
13057 +Known issues not addressed in this release: Bug fix 1) in release 1.4
13058 + (see below) does not work properly for multiple fragments.
13060 +10 April 2003 CPHAL 1.4 (external release)
13062 +CC Labels: REL_20030410_HALdallas_cpmac_01.04.00
13063 + REL_20030410_HALdallas_cpsar_01.04.00
13065 +This release is for SAR and MAC.
13067 + Bug fixes: 1) Implemented logic in HAL to re-request buffer mallocs
13068 + in the case of MallocRxBuffer failing. The HAL now maintains
13069 + a NeedsBuffer queue of all RCB's that are without buffers.
13070 + On interrupts, or on Send(), the HAL checks to see if any
13071 + RCB's are on the queue, and if so, calls MallocRxBuffer
13072 + to attempt to get a new buffer and return the RCB to
13074 + 2) SAR now properly returns all error codes from halOpen and
13077 + New features: NTR
13079 + Known issues not addressed in this release: NTR
13081 +08 April 2003 CPHAL 1.3.1 (internal release - SAR only)
13083 + CC Labels: REL_20030408_HALdallas_cpsar_01.03.01
13085 + This is a SAR only release. The current CPMAC release is still 1.3.
13087 + Bug fixes: 1) PDSP State RAM / Scratchpad RAM is now completely cleared after reset.
13088 + This resolves a stability issue.
13090 + New features: 1) OamMode is now a parameter in halControl(). Both "Set" and "Get"
13091 + actions are available. The value may be "0" (Host OAM), or "1"
13094 + Known issues not addressed in this release:
13095 + 1) Appropriate action for HAL in the case of MallocRxBuffer failing. We
13096 + are investigating whether the HAL should implement a needs buffer
13099 +04 April 2003 CPHAL 1.3 (external release)
13101 + CC Labels: REL_20030404_HALdallas_cpmac_01.03.00
13102 + REL_20030404_HALdallas_cpsar_01.03.00
13103 + REL_20030404_HALdallas_cpaal5_01.03.00
13104 + REL_20030404_HALdallas_cpaal2_01.03.00
13106 + This release requires no changes for the ethernet end driver. The changes necessary
13107 + for the sar driver (firmware file name changes) have already been implemented.
13109 + Bug fixes: 1) RxReturn now returns an error if MallocRxBuffer fails. On RxReturn error, the driver should
13110 + call RxReturn again at a later time (when the malloc may succeed) in order for the CPHAL
13111 + to maintain a full complement of Rx buffers. We recommend holding off making this driver
13112 + change until we verify that this condition occurs.
13114 + New features: 1) Removed benign compiler warnings.
13115 + 2) PITS 122: http://www.nbu.sc.ti.com/cgi-bin/pits/redisplay_archive?product=cphal_dev&report=122
13116 + 3) Cpsar label (above) now is applied to everything
13118 + 4) PITS 14: http://www.nbu.sc.ti.com/cgi-bin/pits/redisplay_archive?product=cphal_dev&report=14
13119 + Transferred to MR PSP 00000089.
13120 + 5) PITS 120: http://www.nbu.sc.ti.com/cgi-bin/pits/redisplay_archive?product=cphal_dev&report=120
13122 + Known issues not addressed in this release:
13123 + 1) PITS 102 (as relating to OamMode configuration):
13124 + http://www.nbu.sc.ti.com/cgi-bin/pits/redisplay_archive?product=cphal_dev&report=102
13125 + Future release will make OamMode configurable
13126 + through halControl(), not on per channel basis.
13128 +20 March 2003 CPHAL 1.2.1 (internal release)
13130 + CC Labels: REL_20030320_HALdallas_cpmac_01.02.01
13131 + REL_20030320_HALdallas_cpsar_01.02.01
13132 + REL_20030320_HALdallas_cpaal5_01.02.01
13133 + REL_20030320_HALdallas_cpaal2_01.02.01
13135 + Bug fixes: 1. Fixed modification of buffer pointer following
13136 + MallocRxBuffer in cppi.c.
13137 + 2. Removed extra firmware files from /cpsar.
13139 + New features: NTR.
13141 + Known issues not addressed in this release: NTR.
13143 +07 March 2003 CPHAL 1.2 (external release)
13145 + CPMAC/CPSAR feature complete release. SAR added
13146 + several features including full OAM support and various
13147 + other features and bug fixes to address PITS 99-106, and
13148 + 114. CPMAC cleaned up details raised by India PSP
13151 +29 January 2003 CPHAL RC 3.01a (external release)
13153 + Corrects non-static functions to be static in cppi.c.
13155 +09 Janurary 2003 CPHAL RC 3.01 (external release)
13157 + PITS 88: Fixed MDIO re-connection problem (hcpmac.c)
13158 + PITS 90: Corrected Rx Buffer Pointer modification (cppi.c)
13160 + Corrected error in cpremap.c
13162 +20 December 2002 CPHAL RC 3 (external release)
13164 + Statistics support via halControl(). See Appendix A of guide.
13165 + Fixed errors in ChannelTeardown/ChannelSetup CPHAL logic.
13166 + Added multicast support as requested.
13167 + Several new OS string functions added to OS_FUNCTIONS.
13168 + "DebugLevel" configuration parameter changed to "Debug".
13169 + "Stats0" changed to "StatsDump" for CPMAC.
13171 +13 December 2002 CPHAL RC 2.03 (internal release)
13173 + Performance improvements.
13174 + More debug statements implemented (esp AAL5).
13175 + Updated makefile with "make debug" option.
13176 + Hbridge performance: [debug library] 15774 tps (53% line rate)
13177 + [non-debug library] 13700 tps (46%)
13179 +10 December 2002 CPHAL Release Candidate 2.02 (internal release)
13181 + Much of the configuration code internal to CPMAC and AAL5 has been made common.
13182 + [os]Receive API had been modified to remove OsReceiveInfo. This information is now
13183 + available as third member of the FRAGLIST structure, on a per buffer basis.
13184 + Successfully tested multi-fragment support on CPMAC, using 32 byte buffers.
13185 + Code is now Emerald compliant - all buffer descriptors now aligned to cache-line
13188 +2 December 2002 CPHAL Release Candidate 2.01
13190 + Updates to comments in hcpmac.c, cpmdio.c, hcpmac.h
13191 + Nested comment in hcpmac.c in RC2 can cause compile errors.
13193 +25 November 2002 CPHAL Release Candidate 2
13195 +Project Items not completed for RC2
13196 +#6 Ship as Library - Once under CC. Moved to RC3
13197 +#8 Under Clearcase - Moved to RC3
13198 +#25 Emerald compliant - Moved to RC3
13199 +#26 Statistics support - Moved to RC3 (some support in RC2)
13200 +#36 Debug scheme implemented - Moved to RC3 (some support in RC2)
13202 +8 November 2002 CPHAL Release Candidate 1
13206 +Project Items not completed for RC1
13208 +#8 Under Clearcase - Clearcase server failure this week. Moved to RC2
13209 +#6 Ship as Library - Once under CC. Moved to RC2
13210 +#13 Verify Datatypes. Moved to RC2
13211 +#14 Review APIs. Moved to RC2
13213 +APIs under review for RC2
13222 +CPMAC Build Instructions
13224 +Compile the file 'hcpmac.c'.
13227 +AAL5 Build Instructions
13229 +The AAL5 build is composed of the source files aal5sar.c and cpsar.c.
13230 +Refer to the provided makefile for an example of compiling these files
13233 +Example CPHAL Code
13237 +Example CPMAC code is provided in the file hbridge.c.
13238 +This program is provided simply as an example of using the CPHAL API.
13239 +It is not intended to be compiled and executed in your environment.
13243 +Example AAL5 code is provided in the file loopback.c. This program
13244 +is provided simply as an example of using the CPHAL API. It is not
13245 +intended to be compiled and executed in your environment.
13248 +Performance Baseline
13253 +RC1: hbridge.bin, running with IXIA cpahl_1.cfg.
13254 + This sends 64-byte packets from each Ixia port, with mac destination the other Ixia port.
13257 +RC2: hbridge.bin, running with IXIA cpahl_1.cfg.
13258 + This sends 64-byte packets from each Ixia port, with mac destination the other Ixia port.
13260 + CPHAL now includes Emerald support, but this has been disabled by using 'cache -wt' to emulate 4Kc.
13262 +RC3: 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 + Running as Emerald processor.
13267 +Release Total Receive Rate Throughput Setting
13272 diff -urN linux.old/drivers/net/Config.in linux.dev/drivers/net/Config.in
13273 --- linux.old/drivers/net/Config.in 2005-07-12 03:20:45.726149872 +0200
13274 +++ linux.dev/drivers/net/Config.in 2005-07-12 02:48:42.180573000 +0200
13276 comment 'Ethernet (10 or 100Mbit)'
13277 bool 'Ethernet (10 or 100Mbit)' CONFIG_NET_ETHERNET
13278 if [ "$CONFIG_NET_ETHERNET" = "y" ]; then
13279 + if [ "$CONFIG_MIPS_TITAN" = "y" -o "$CONFIG_AR7" = "y" ]; then
13280 + tristate ' Texas Instruments Avalanche CPMAC support' CONFIG_MIPS_AVALANCHE_CPMAC
13282 + if [ "$CONFIG_MIPS_AVALANCHE_CPMAC" != "n" ]; then
13283 + if [ "$CONFIG_AR7WRD" = "y" -o "$CONFIG_AR7VWI" = "y" -o "$CONFIG_AR7VW" = "y" ]; then
13284 + define_bool CONFIG_MIPS_CPMAC_INIT_BUF_MALLOC y
13285 + define_int CONFIG_MIPS_CPMAC_PORTS 1
13286 + if [ "$CONFIG_MIPS_AVALANCHE_MARVELL" = "y" ]; then
13287 + define_bool CONFIG_AVALANCHE_LOW_CPMAC n
13288 + define_bool CONFIG_AVALANCHE_HIGH_CPMAC y
13290 + define_bool CONFIG_AVALANCHE_CPMAC_AUTO y
13291 + define_bool CONFIG_AVALANCHE_LOW_CPMAC n
13292 + define_bool CONFIG_AVALANCHE_HIGH_CPMAC n
13297 if [ "$CONFIG_ARM" = "y" ]; then
13298 dep_bool ' ARM EBSA110 AM79C961A support' CONFIG_ARM_AM79C961A $CONFIG_ARCH_EBSA110
13299 tristate ' Cirrus Logic CS8900A support' CONFIG_ARM_CIRRUS
13300 diff -urN linux.old/drivers/net/Makefile linux.dev/drivers/net/Makefile
13301 --- linux.old/drivers/net/Makefile 2005-07-12 03:20:45.726149872 +0200
13302 +++ linux.dev/drivers/net/Makefile 2005-07-12 02:48:42.181573000 +0200
13304 subdir-$(CONFIG_BONDING) += bonding
13307 +# Texas Instruments AVALANCHE CPMAC driver
13310 +subdir-$(CONFIG_MIPS_AVALANCHE_CPMAC) += avalanche_cpmac
13311 +#obj-$(CONFIG_MIPS_AVALANCHE_CPMAC) += avalanche_cpmac/avalanche_cpmac.o
13312 +ifeq ($(CONFIG_MIPS_AVALANCHE_CPMAC),y)
13313 + obj-y += avalanche_cpmac/avalanche_cpmac.o
13317 # link order important here
13319 obj-$(CONFIG_PLIP) += plip.o