xref: /freebsd/sys/contrib/ncsw/Peripherals/FM/MAC/fm_mac.c (revision ec65e4f8d0654361df5e97d4de3518edebf76b46)
1 /* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *     * Redistributions of source code must retain the above copyright
7  *       notice, this list of conditions and the following disclaimer.
8  *     * Redistributions in binary form must reproduce the above copyright
9  *       notice, this list of conditions and the following disclaimer in the
10  *       documentation and/or other materials provided with the distribution.
11  *     * Neither the name of Freescale Semiconductor nor the
12  *       names of its contributors may be used to endorse or promote products
13  *       derived from this software without specific prior written permission.
14  *
15  *
16  * ALTERNATIVELY, this software may be distributed under the terms of the
17  * GNU General Public License ("GPL") as published by the Free Software
18  * Foundation, either version 2 of that License or (at your option) any
19  * later version.
20  *
21  * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
22  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
25  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 /******************************************************************************
34  @File          fm_mac.c
35 
36  @Description   FM MAC ...
37 *//***************************************************************************/
38 #include "std_ext.h"
39 #include "string_ext.h"
40 #include "sprint_ext.h"
41 #include "error_ext.h"
42 #include "fm_ext.h"
43 
44 #include "fm_common.h"
45 #include "fm_mac.h"
46 
47 
48 /* ........................................................................... */
49 
50 t_Handle FM_MAC_Config (t_FmMacParams *p_FmMacParam)
51 {
52     t_FmMacControllerDriver *p_FmMacControllerDriver;
53 
54     SANITY_CHECK_RETURN_VALUE(p_FmMacParam, E_INVALID_HANDLE, NULL);
55 
56     if(ENET_SPEED_FROM_MODE(p_FmMacParam->enetMode) < e_ENET_SPEED_10000)
57         p_FmMacControllerDriver = (t_FmMacControllerDriver *)DTSEC_Config(p_FmMacParam);
58     else
59        p_FmMacControllerDriver = (t_FmMacControllerDriver *)TGEC_Config(p_FmMacParam);
60 
61     if (!p_FmMacControllerDriver)
62         return NULL;
63 
64     p_FmMacControllerDriver->h_Fm           = p_FmMacParam->h_Fm;
65     p_FmMacControllerDriver->enetMode       = p_FmMacParam->enetMode;
66     p_FmMacControllerDriver->macId          = p_FmMacParam->macId;
67     p_FmMacControllerDriver->resetOnInit    = DEFAULT_resetOnInit;
68 
69     return (t_Handle)p_FmMacControllerDriver;
70 }
71 
72 /* ........................................................................... */
73 
74 t_Error FM_MAC_Init (t_Handle h_FmMac)
75 {
76     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
77 
78     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
79 
80     if (p_FmMacControllerDriver->resetOnInit &&
81         (FmResetMac(p_FmMacControllerDriver->h_Fm,
82                     ((ENET_INTERFACE_FROM_MODE(p_FmMacControllerDriver->enetMode) == e_ENET_IF_XGMII) ? e_FM_MAC_10G : e_FM_MAC_1G),
83                      p_FmMacControllerDriver->macId) != E_OK))
84         RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Can't reset MAC!"));
85 
86     if ((p_FmMacControllerDriver->clkFreq = FmGetClockFreq(p_FmMacControllerDriver->h_Fm)) == 0)
87         RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Can't get clock for MAC!"));
88 
89     if (p_FmMacControllerDriver->f_FM_MAC_Init)
90         return p_FmMacControllerDriver->f_FM_MAC_Init(h_FmMac);
91     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
92 }
93 
94 /* ........................................................................... */
95 
96 t_Error FM_MAC_Free (t_Handle h_FmMac)
97 {
98     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
99 
100     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
101 
102     if (p_FmMacControllerDriver->f_FM_MAC_Free)
103         return p_FmMacControllerDriver->f_FM_MAC_Free(h_FmMac);
104 
105     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
106 }
107 
108 /* ........................................................................... */
109 
110 t_Error FM_MAC_ConfigResetOnInit (t_Handle h_FmMac, bool enable)
111 {
112     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
113 
114     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
115 
116     p_FmMacControllerDriver->resetOnInit = enable;
117 
118     return E_OK;
119 }
120 
121 /* ........................................................................... */
122 
123 t_Error FM_MAC_ConfigLoopback (t_Handle h_FmMac, bool newVal)
124 {
125     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
126 
127     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
128 
129     if (p_FmMacControllerDriver->f_FM_MAC_ConfigLoopback)
130         return p_FmMacControllerDriver->f_FM_MAC_ConfigLoopback(h_FmMac, newVal);
131 
132     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
133 }
134 
135 /* ........................................................................... */
136 
137 t_Error FM_MAC_ConfigMaxFrameLength (t_Handle h_FmMac, uint16_t newVal)
138 {
139     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
140 
141     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
142 
143     if (p_FmMacControllerDriver->f_FM_MAC_ConfigMaxFrameLength)
144         return p_FmMacControllerDriver->f_FM_MAC_ConfigMaxFrameLength(h_FmMac, newVal);
145     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
146 }
147 
148 /* ........................................................................... */
149 
150 t_Error FM_MAC_ConfigWan (t_Handle h_FmMac, bool flag)
151 {
152    t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
153 
154     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
155 
156     if (p_FmMacControllerDriver->f_FM_MAC_ConfigWan)
157         return p_FmMacControllerDriver->f_FM_MAC_ConfigWan(h_FmMac, flag);
158 
159     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
160 }
161 
162 /* ........................................................................... */
163 
164 t_Error FM_MAC_ConfigPadAndCrc (t_Handle h_FmMac, bool newVal)
165 {
166     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
167 
168     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
169 
170     if (p_FmMacControllerDriver->f_FM_MAC_ConfigPadAndCrc)
171         return p_FmMacControllerDriver->f_FM_MAC_ConfigPadAndCrc(h_FmMac, newVal);
172 
173     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
174 }
175 
176 /* ........................................................................... */
177 
178 t_Error FM_MAC_ConfigHalfDuplex (t_Handle h_FmMac, bool newVal)
179 {
180     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
181 
182     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
183 
184     if (p_FmMacControllerDriver->f_FM_MAC_ConfigHalfDuplex)
185         return p_FmMacControllerDriver->f_FM_MAC_ConfigHalfDuplex(h_FmMac,newVal);
186 
187     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
188 }
189 
190 /* ........................................................................... */
191 
192 t_Error FM_MAC_ConfigLengthCheck (t_Handle h_FmMac, bool newVal)
193 {
194     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
195 
196     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
197 
198     if (p_FmMacControllerDriver->f_FM_MAC_ConfigLengthCheck)
199         return p_FmMacControllerDriver->f_FM_MAC_ConfigLengthCheck(h_FmMac,newVal);
200 
201     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
202 }
203 
204 /* ........................................................................... */
205 
206 t_Error FM_MAC_ConfigException (t_Handle h_FmMac, e_FmMacExceptions ex, bool enable)
207 {
208     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
209 
210     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
211 
212     if (p_FmMacControllerDriver->f_FM_MAC_ConfigException)
213         return p_FmMacControllerDriver->f_FM_MAC_ConfigException(h_FmMac, ex, enable);
214 
215     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
216 }
217 
218 #ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
219 /* ........................................................................... */
220 
221 t_Error FM_MAC_ConfigSkipFman11Workaround (t_Handle h_FmMac)
222 {
223     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
224 
225     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
226 
227     if (p_FmMacControllerDriver->f_FM_MAC_ConfigSkipFman11Workaround)
228         return p_FmMacControllerDriver->f_FM_MAC_ConfigSkipFman11Workaround(h_FmMac);
229 
230     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
231 }
232 #endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
233 
234 
235 /*****************************************************************************/
236 /* Run Time Control                                                          */
237 /*****************************************************************************/
238 
239 /* ........................................................................... */
240 
241 t_Error FM_MAC_Enable  (t_Handle h_FmMac,  e_CommMode mode)
242 {
243     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
244 
245     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
246 
247     if (p_FmMacControllerDriver->f_FM_MAC_Enable)
248         return p_FmMacControllerDriver->f_FM_MAC_Enable(h_FmMac, mode);
249 
250     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
251 }
252 
253 /* ........................................................................... */
254 
255 t_Error FM_MAC_Disable (t_Handle h_FmMac, e_CommMode mode)
256 {
257     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
258 
259     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
260 
261     if (p_FmMacControllerDriver->f_FM_MAC_Disable)
262         return p_FmMacControllerDriver->f_FM_MAC_Disable(h_FmMac, mode);
263 
264     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
265 }
266 
267 /* ........................................................................... */
268 
269 t_Error FM_MAC_Enable1588TimeStamp (t_Handle h_FmMac)
270 {
271     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
272 
273     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
274 
275     if (p_FmMacControllerDriver->f_FM_MAC_Enable1588TimeStamp)
276         return p_FmMacControllerDriver->f_FM_MAC_Enable1588TimeStamp(h_FmMac);
277 
278     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
279 }
280 
281 /* ........................................................................... */
282 
283 t_Error FM_MAC_Disable1588TimeStamp (t_Handle h_FmMac)
284 {
285     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
286 
287     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
288 
289     if (p_FmMacControllerDriver->f_FM_MAC_Disable1588TimeStamp)
290         return p_FmMacControllerDriver->f_FM_MAC_Disable1588TimeStamp(h_FmMac);
291 
292     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
293 }
294 
295 /* ........................................................................... */
296 
297 t_Error FM_MAC_SetTxAutoPauseFrames (t_Handle h_FmMac, uint16_t pauseTime)
298 {
299     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
300 
301     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
302 
303     if (p_FmMacControllerDriver->f_FM_MAC_SetTxAutoPauseFrames)
304         return p_FmMacControllerDriver->f_FM_MAC_SetTxAutoPauseFrames(h_FmMac, pauseTime);
305 
306     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
307 }
308 
309 /* ........................................................................... */
310 
311 t_Error FM_MAC_SetRxIgnorePauseFrames (t_Handle h_FmMac, bool en)
312 {
313     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
314 
315     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
316 
317     if (p_FmMacControllerDriver->f_FM_MAC_SetRxIgnorePauseFrames)
318         return p_FmMacControllerDriver->f_FM_MAC_SetRxIgnorePauseFrames(h_FmMac, en);
319 
320     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
321 }
322 
323 /* ........................................................................... */
324 
325 t_Error FM_MAC_ResetCounters (t_Handle h_FmMac)
326 {
327     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
328 
329     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
330 
331     if (p_FmMacControllerDriver->f_FM_MAC_ResetCounters)
332         return p_FmMacControllerDriver->f_FM_MAC_ResetCounters(h_FmMac);
333 
334     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
335 }
336 
337 /* ........................................................................... */
338 
339 t_Error FM_MAC_SetException(t_Handle h_FmMac, e_FmMacExceptions ex, bool enable)
340 {
341    t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
342 
343     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
344 
345     if (p_FmMacControllerDriver->f_FM_MAC_SetException)
346         return p_FmMacControllerDriver->f_FM_MAC_SetException(h_FmMac, ex, enable);
347 
348     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
349 }
350 
351 /* ........................................................................... */
352 
353 t_Error FM_MAC_SetStatistics (t_Handle h_FmMac, e_FmMacStatisticsLevel statisticsLevel)
354 {
355     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
356 
357     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
358 
359     if (p_FmMacControllerDriver->f_FM_MAC_SetStatistics)
360         return p_FmMacControllerDriver->f_FM_MAC_SetStatistics(h_FmMac, statisticsLevel);
361     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
362 }
363 
364 /* ........................................................................... */
365 
366 t_Error FM_MAC_GetStatistics (t_Handle h_FmMac, t_FmMacStatistics *p_Statistics)
367 {
368     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
369 
370     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
371 
372     if (p_FmMacControllerDriver->f_FM_MAC_GetStatistics)
373         return p_FmMacControllerDriver->f_FM_MAC_GetStatistics(h_FmMac, p_Statistics);
374 
375     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
376 }
377 
378 /* ........................................................................... */
379 
380 t_Error FM_MAC_ModifyMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
381 {
382     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
383 
384     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
385 
386     if (p_FmMacControllerDriver->f_FM_MAC_ModifyMacAddr)
387         return p_FmMacControllerDriver->f_FM_MAC_ModifyMacAddr(h_FmMac, p_EnetAddr);
388 
389     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
390 }
391 
392 /* ........................................................................... */
393 
394 t_Error FM_MAC_AddHashMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
395 {
396     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
397 
398     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
399 
400     if (p_FmMacControllerDriver->f_FM_MAC_AddHashMacAddr)
401         return p_FmMacControllerDriver->f_FM_MAC_AddHashMacAddr(h_FmMac, p_EnetAddr);
402 
403     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
404 }
405 
406 /* ........................................................................... */
407 
408 t_Error FM_MAC_RemoveHashMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
409 {
410     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
411 
412     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
413 
414     if (p_FmMacControllerDriver->f_FM_MAC_RemoveHashMacAddr)
415         return p_FmMacControllerDriver->f_FM_MAC_RemoveHashMacAddr(h_FmMac, p_EnetAddr);
416 
417     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
418 }
419 
420 /* ........................................................................... */
421 
422 t_Error FM_MAC_AddExactMatchMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
423 {
424     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
425 
426     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
427 
428     if (p_FmMacControllerDriver->f_FM_MAC_AddExactMatchMacAddr)
429         return p_FmMacControllerDriver->f_FM_MAC_AddExactMatchMacAddr(h_FmMac, p_EnetAddr);
430 
431     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
432 }
433 
434 /* ........................................................................... */
435 
436 t_Error FM_MAC_RemovelExactMatchMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
437 {
438     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
439 
440     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
441 
442     if (p_FmMacControllerDriver->f_FM_MAC_RemovelExactMatchMacAddr)
443         return p_FmMacControllerDriver->f_FM_MAC_RemovelExactMatchMacAddr(h_FmMac, p_EnetAddr);
444 
445     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
446 }
447 
448 /* ........................................................................... */
449 
450 t_Error FM_MAC_GetVesrion (t_Handle h_FmMac, uint32_t *macVresion)
451 {
452     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
453 
454     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
455 
456     if (p_FmMacControllerDriver->f_FM_MAC_GetVersion)
457         return p_FmMacControllerDriver->f_FM_MAC_GetVersion(h_FmMac, macVresion);
458 
459     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
460 
461 }
462 
463 /* ........................................................................... */
464 
465 t_Error FM_MAC_GetId (t_Handle h_FmMac, uint32_t *macId)
466 {
467     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
468 
469     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
470 
471     if (p_FmMacControllerDriver->f_FM_MAC_GetId)
472         return p_FmMacControllerDriver->f_FM_MAC_GetId(h_FmMac, macId);
473 
474     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
475 }
476 
477 /* ........................................................................... */
478 
479 t_Error FM_MAC_SetPromiscuous (t_Handle h_FmMac, bool newVal)
480 {
481     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
482 
483     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
484 
485     if (p_FmMacControllerDriver->f_FM_MAC_SetPromiscuous)
486         return p_FmMacControllerDriver->f_FM_MAC_SetPromiscuous(h_FmMac, newVal);
487 
488     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
489 }
490 
491 /* ........................................................................... */
492 
493 t_Error FM_MAC_AdjustLink(t_Handle h_FmMac, e_EnetSpeed speed, bool fullDuplex)
494 {
495     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
496 
497     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
498 
499     if (p_FmMacControllerDriver->f_FM_MAC_AdjustLink)
500         return p_FmMacControllerDriver->f_FM_MAC_AdjustLink(h_FmMac, speed, fullDuplex);
501 
502     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
503 }
504 
505 /* ........................................................................... */
506 
507 t_Error FM_MAC_MII_WritePhyReg (t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, uint16_t data)
508 {
509     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
510 
511     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
512 
513     if (p_FmMacControllerDriver->f_FM_MAC_MII_WritePhyReg)
514         return p_FmMacControllerDriver->f_FM_MAC_MII_WritePhyReg(h_FmMac, phyAddr, reg, data);
515 
516     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
517 }
518 
519 /* ........................................................................... */
520 
521 t_Error FM_MAC_MII_ReadPhyReg(t_Handle h_FmMac,  uint8_t phyAddr, uint8_t reg, uint16_t *p_Data)
522 {
523     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
524 
525     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
526 
527     if (p_FmMacControllerDriver->f_FM_MAC_MII_ReadPhyReg)
528         return p_FmMacControllerDriver->f_FM_MAC_MII_ReadPhyReg(h_FmMac, phyAddr, reg, p_Data);
529 
530     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
531 }
532 
533 /* ........................................................................... */
534 
535 uint16_t FM_MAC_GetMaxFrameLength(t_Handle h_FmMac)
536 {
537     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
538 
539     SANITY_CHECK_RETURN_VALUE(p_FmMacControllerDriver, E_INVALID_HANDLE, 0);
540 
541     if (p_FmMacControllerDriver->f_FM_MAC_GetMaxFrameLength)
542         return p_FmMacControllerDriver->f_FM_MAC_GetMaxFrameLength(h_FmMac);
543 
544     REPORT_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
545     return 0;
546 }
547 
548 #if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
549 /*****************************************************************************/
550 t_Error FM_MAC_DumpRegs(t_Handle h_FmMac)
551 {
552     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
553 
554     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
555 
556     if (p_FmMacControllerDriver->f_FM_MAC_DumpRegs)
557          return p_FmMacControllerDriver->f_FM_MAC_DumpRegs(h_FmMac);
558     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
559 }
560 #endif /* (defined(DEBUG_ERRORS) && ... */
561