xref: /freebsd/sys/contrib/ncsw/Peripherals/FM/MAC/fm_mac.c (revision ebacd8013fe5f7fdf9f6a5b286f6680dd2891036)
1 /*
2  * Copyright 2008-2012 Freescale Semiconductor Inc.
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 /******************************************************************************
35  @File          fm_mac.c
36 
37  @Description   FM MAC ...
38 *//***************************************************************************/
39 #include "std_ext.h"
40 #include "string_ext.h"
41 #include "sprint_ext.h"
42 #include "error_ext.h"
43 #include "fm_ext.h"
44 
45 #include "fm_common.h"
46 #include "fm_mac.h"
47 
48 
49 /* ......................................................................... */
50 
51 t_Handle FM_MAC_Config (t_FmMacParams *p_FmMacParam)
52 {
53     t_FmMacControllerDriver *p_FmMacControllerDriver;
54     uint16_t                fmClkFreq;
55 
56     SANITY_CHECK_RETURN_VALUE(p_FmMacParam, E_INVALID_HANDLE, NULL);
57 
58     fmClkFreq = FmGetClockFreq(p_FmMacParam->h_Fm);
59     if (fmClkFreq == 0)
60     {
61         REPORT_ERROR(MAJOR, E_INVALID_STATE, ("Can't get clock for MAC!"));
62         return NULL;
63     }
64 
65 #if (DPAA_VERSION == 10)
66     if (ENET_SPEED_FROM_MODE(p_FmMacParam->enetMode) < e_ENET_SPEED_10000)
67         p_FmMacControllerDriver = (t_FmMacControllerDriver *)DTSEC_Config(p_FmMacParam);
68     else
69 #if FM_MAX_NUM_OF_10G_MACS > 0
70         p_FmMacControllerDriver = (t_FmMacControllerDriver *)TGEC_Config(p_FmMacParam);
71 #else
72         p_FmMacControllerDriver = NULL;
73 #endif /* FM_MAX_NUM_OF_10G_MACS > 0 */
74 #else
75     p_FmMacControllerDriver = (t_FmMacControllerDriver *)MEMAC_Config(p_FmMacParam);
76 #endif /* (DPAA_VERSION == 10) */
77 
78     if (!p_FmMacControllerDriver)
79         return NULL;
80 
81     p_FmMacControllerDriver->h_Fm           = p_FmMacParam->h_Fm;
82     p_FmMacControllerDriver->enetMode       = p_FmMacParam->enetMode;
83     p_FmMacControllerDriver->macId          = p_FmMacParam->macId;
84     p_FmMacControllerDriver->resetOnInit    = DEFAULT_resetOnInit;
85 
86     p_FmMacControllerDriver->clkFreq        = fmClkFreq;
87 
88     return (t_Handle)p_FmMacControllerDriver;
89 }
90 
91 /* ......................................................................... */
92 
93 t_Error FM_MAC_Init (t_Handle h_FmMac)
94 {
95     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
96 
97     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
98 
99     if (p_FmMacControllerDriver->resetOnInit &&
100         !p_FmMacControllerDriver->f_FM_MAC_ConfigResetOnInit &&
101         (FmResetMac(p_FmMacControllerDriver->h_Fm,
102                     ((ENET_INTERFACE_FROM_MODE(p_FmMacControllerDriver->enetMode) == e_ENET_IF_XGMII) ?
103                         e_FM_MAC_10G : e_FM_MAC_1G),
104                     p_FmMacControllerDriver->macId) != E_OK))
105         RETURN_ERROR(MAJOR, E_INVALID_STATE, ("Can't reset MAC!"));
106 
107     if (p_FmMacControllerDriver->f_FM_MAC_Init)
108         return p_FmMacControllerDriver->f_FM_MAC_Init(h_FmMac);
109     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
110 }
111 
112 /* ......................................................................... */
113 
114 t_Error FM_MAC_Free (t_Handle h_FmMac)
115 {
116     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
117 
118     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
119 
120     if (p_FmMacControllerDriver->f_FM_MAC_Free)
121         return p_FmMacControllerDriver->f_FM_MAC_Free(h_FmMac);
122 
123     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
124 }
125 
126 /* ......................................................................... */
127 
128 t_Error FM_MAC_ConfigResetOnInit (t_Handle h_FmMac, bool enable)
129 {
130     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
131 
132     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
133 
134     if (p_FmMacControllerDriver->f_FM_MAC_ConfigResetOnInit)
135         return p_FmMacControllerDriver->f_FM_MAC_ConfigResetOnInit(h_FmMac, enable);
136 
137     p_FmMacControllerDriver->resetOnInit = enable;
138 
139     return E_OK;
140 }
141 
142 /* ......................................................................... */
143 
144 t_Error FM_MAC_ConfigLoopback (t_Handle h_FmMac, bool newVal)
145 {
146     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
147 
148     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
149 
150     if (p_FmMacControllerDriver->f_FM_MAC_ConfigLoopback)
151         return p_FmMacControllerDriver->f_FM_MAC_ConfigLoopback(h_FmMac, newVal);
152 
153     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
154 }
155 
156 /* ......................................................................... */
157 
158 t_Error FM_MAC_ConfigMaxFrameLength (t_Handle h_FmMac, uint16_t newVal)
159 {
160     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
161 
162     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
163 
164     if (p_FmMacControllerDriver->f_FM_MAC_ConfigMaxFrameLength)
165         return p_FmMacControllerDriver->f_FM_MAC_ConfigMaxFrameLength(h_FmMac, newVal);
166     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
167 }
168 
169 /* ......................................................................... */
170 
171 t_Error FM_MAC_ConfigWan (t_Handle h_FmMac, bool flag)
172 {
173    t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
174 
175     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
176 
177     if (p_FmMacControllerDriver->f_FM_MAC_ConfigWan)
178         return p_FmMacControllerDriver->f_FM_MAC_ConfigWan(h_FmMac, flag);
179 
180     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
181 }
182 
183 /* ......................................................................... */
184 
185 t_Error FM_MAC_ConfigPadAndCrc (t_Handle h_FmMac, bool newVal)
186 {
187     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
188 
189     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
190 
191     if (p_FmMacControllerDriver->f_FM_MAC_ConfigPadAndCrc)
192         return p_FmMacControllerDriver->f_FM_MAC_ConfigPadAndCrc(h_FmMac, newVal);
193 
194     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
195 }
196 
197 /* ......................................................................... */
198 
199 t_Error FM_MAC_ConfigHalfDuplex (t_Handle h_FmMac, bool newVal)
200 {
201     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
202 
203     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
204 
205     if (p_FmMacControllerDriver->f_FM_MAC_ConfigHalfDuplex)
206         return p_FmMacControllerDriver->f_FM_MAC_ConfigHalfDuplex(h_FmMac,newVal);
207 
208     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
209 }
210 
211 /* ......................................................................... */
212 
213 t_Error FM_MAC_ConfigTbiPhyAddr (t_Handle h_FmMac, uint8_t newVal)
214 {
215     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
216 
217     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
218 
219     if (p_FmMacControllerDriver->f_FM_MAC_ConfigTbiPhyAddr)
220         return p_FmMacControllerDriver->f_FM_MAC_ConfigTbiPhyAddr(h_FmMac,newVal);
221 
222     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
223 }
224 
225 /* ......................................................................... */
226 
227 t_Error FM_MAC_ConfigLengthCheck (t_Handle h_FmMac, bool newVal)
228 {
229     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
230 
231     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
232 
233     if (p_FmMacControllerDriver->f_FM_MAC_ConfigLengthCheck)
234         return p_FmMacControllerDriver->f_FM_MAC_ConfigLengthCheck(h_FmMac,newVal);
235 
236     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
237 }
238 
239 /* ......................................................................... */
240 
241 t_Error FM_MAC_ConfigException (t_Handle h_FmMac, e_FmMacExceptions ex, bool enable)
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_ConfigException)
248         return p_FmMacControllerDriver->f_FM_MAC_ConfigException(h_FmMac, ex, enable);
249 
250     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
251 }
252 
253 #ifdef FM_TX_ECC_FRMS_ERRATA_10GMAC_A004
254 /* ......................................................................... */
255 
256 t_Error FM_MAC_ConfigSkipFman11Workaround (t_Handle h_FmMac)
257 {
258     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
259 
260     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
261 
262     if (p_FmMacControllerDriver->f_FM_MAC_ConfigSkipFman11Workaround)
263         return p_FmMacControllerDriver->f_FM_MAC_ConfigSkipFman11Workaround(h_FmMac);
264 
265     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
266 }
267 #endif /* FM_TX_ECC_FRMS_ERRATA_10GMAC_A004 */
268 
269 
270 /*****************************************************************************/
271 /* Run Time Control                                                          */
272 /*****************************************************************************/
273 
274 /* ......................................................................... */
275 
276 t_Error FM_MAC_Enable  (t_Handle h_FmMac,  e_CommMode mode)
277 {
278     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
279 
280     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
281 
282     if (p_FmMacControllerDriver->f_FM_MAC_Enable)
283         return p_FmMacControllerDriver->f_FM_MAC_Enable(h_FmMac, mode);
284 
285     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
286 }
287 
288 /* ......................................................................... */
289 
290 t_Error FM_MAC_Disable (t_Handle h_FmMac, e_CommMode mode)
291 {
292     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
293 
294     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
295 
296     if (p_FmMacControllerDriver->f_FM_MAC_Disable)
297         return p_FmMacControllerDriver->f_FM_MAC_Disable(h_FmMac, mode);
298 
299     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
300 }
301 
302 t_Error FM_MAC_Resume (t_Handle h_FmMac)
303 {
304     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
305 
306     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
307 
308     if (p_FmMacControllerDriver->f_FM_MAC_Resume)
309         return p_FmMacControllerDriver->f_FM_MAC_Resume(h_FmMac);
310 
311     return E_OK;
312 }
313 
314 /* ......................................................................... */
315 
316 t_Error FM_MAC_Enable1588TimeStamp (t_Handle h_FmMac)
317 {
318     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
319 
320     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
321 
322     if (p_FmMacControllerDriver->f_FM_MAC_Enable1588TimeStamp)
323         return p_FmMacControllerDriver->f_FM_MAC_Enable1588TimeStamp(h_FmMac);
324 
325     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
326 }
327 
328 /* ......................................................................... */
329 
330 t_Error FM_MAC_Disable1588TimeStamp (t_Handle h_FmMac)
331 {
332     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
333 
334     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
335 
336     if (p_FmMacControllerDriver->f_FM_MAC_Disable1588TimeStamp)
337         return p_FmMacControllerDriver->f_FM_MAC_Disable1588TimeStamp(h_FmMac);
338 
339     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
340 }
341 
342 /* ......................................................................... */
343 
344 t_Error FM_MAC_SetTxAutoPauseFrames(t_Handle h_FmMac,
345                                     uint16_t pauseTime)
346 {
347     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
348 
349     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
350 
351     if (p_FmMacControllerDriver->f_FM_MAC_SetTxAutoPauseFrames)
352         return p_FmMacControllerDriver->f_FM_MAC_SetTxAutoPauseFrames(h_FmMac,
353                                                                       pauseTime);
354 
355     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
356 }
357 
358 /* ......................................................................... */
359 
360 t_Error FM_MAC_SetTxPauseFrames(t_Handle h_FmMac,
361                                 uint8_t  priority,
362                                 uint16_t pauseTime,
363                                 uint16_t threshTime)
364 {
365     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
366 
367     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
368 
369     if (p_FmMacControllerDriver->f_FM_MAC_SetTxPauseFrames)
370         return p_FmMacControllerDriver->f_FM_MAC_SetTxPauseFrames(h_FmMac,
371                                                                   priority,
372                                                                   pauseTime,
373                                                                   threshTime);
374 
375     RETURN_ERROR(MAJOR, E_NOT_SUPPORTED, NO_MSG);
376 }
377 
378 /* ......................................................................... */
379 
380 t_Error FM_MAC_SetRxIgnorePauseFrames (t_Handle h_FmMac, bool en)
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_SetRxIgnorePauseFrames)
387         return p_FmMacControllerDriver->f_FM_MAC_SetRxIgnorePauseFrames(h_FmMac, en);
388 
389     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
390 }
391 
392 /* ......................................................................... */
393 
394 t_Error FM_MAC_SetWakeOnLan (t_Handle h_FmMac, bool en)
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_SetWakeOnLan)
401         return p_FmMacControllerDriver->f_FM_MAC_SetWakeOnLan(h_FmMac, en);
402 
403     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
404 }
405 
406 /* ......................................................................... */
407 
408 t_Error FM_MAC_ResetCounters (t_Handle h_FmMac)
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_ResetCounters)
415         return p_FmMacControllerDriver->f_FM_MAC_ResetCounters(h_FmMac);
416 
417     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
418 }
419 
420 /* ......................................................................... */
421 
422 t_Error FM_MAC_SetException(t_Handle h_FmMac, e_FmMacExceptions ex, bool enable)
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_SetException)
429         return p_FmMacControllerDriver->f_FM_MAC_SetException(h_FmMac, ex, enable);
430 
431     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
432 }
433 
434 /* ......................................................................... */
435 
436 t_Error FM_MAC_SetStatistics (t_Handle h_FmMac, e_FmMacStatisticsLevel statisticsLevel)
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_SetStatistics)
443         return p_FmMacControllerDriver->f_FM_MAC_SetStatistics(h_FmMac, statisticsLevel);
444 
445     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
446 }
447 
448 /* ......................................................................... */
449 
450 t_Error FM_MAC_GetStatistics (t_Handle h_FmMac, t_FmMacStatistics *p_Statistics)
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_GetStatistics)
457         return p_FmMacControllerDriver->f_FM_MAC_GetStatistics(h_FmMac, p_Statistics);
458 
459     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
460 }
461 
462 /* ......................................................................... */
463 
464 t_Error FM_MAC_ModifyMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
465 {
466     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
467 
468     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
469 
470     if (p_FmMacControllerDriver->f_FM_MAC_ModifyMacAddr)
471         return p_FmMacControllerDriver->f_FM_MAC_ModifyMacAddr(h_FmMac, p_EnetAddr);
472 
473     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
474 }
475 
476 /* ......................................................................... */
477 
478 t_Error FM_MAC_AddHashMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
479 {
480     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
481 
482     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
483 
484     if (p_FmMacControllerDriver->f_FM_MAC_AddHashMacAddr)
485         return p_FmMacControllerDriver->f_FM_MAC_AddHashMacAddr(h_FmMac, p_EnetAddr);
486 
487     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
488 }
489 
490 /* ......................................................................... */
491 
492 t_Error FM_MAC_RemoveHashMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
493 {
494     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
495 
496     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
497 
498     if (p_FmMacControllerDriver->f_FM_MAC_RemoveHashMacAddr)
499         return p_FmMacControllerDriver->f_FM_MAC_RemoveHashMacAddr(h_FmMac, p_EnetAddr);
500 
501     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
502 }
503 
504 /* ......................................................................... */
505 
506 t_Error FM_MAC_AddExactMatchMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
507 {
508     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
509 
510     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
511 
512     if (p_FmMacControllerDriver->f_FM_MAC_AddExactMatchMacAddr)
513         return p_FmMacControllerDriver->f_FM_MAC_AddExactMatchMacAddr(h_FmMac, p_EnetAddr);
514 
515     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
516 }
517 
518 /* ......................................................................... */
519 
520 t_Error FM_MAC_RemovelExactMatchMacAddr (t_Handle h_FmMac, t_EnetAddr *p_EnetAddr)
521 {
522     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
523 
524     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
525 
526     if (p_FmMacControllerDriver->f_FM_MAC_RemovelExactMatchMacAddr)
527         return p_FmMacControllerDriver->f_FM_MAC_RemovelExactMatchMacAddr(h_FmMac, p_EnetAddr);
528 
529     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
530 }
531 
532 /* ......................................................................... */
533 
534 t_Error FM_MAC_GetVesrion (t_Handle h_FmMac, uint32_t *macVresion)
535 {
536     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
537 
538     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
539 
540     if (p_FmMacControllerDriver->f_FM_MAC_GetVersion)
541         return p_FmMacControllerDriver->f_FM_MAC_GetVersion(h_FmMac, macVresion);
542 
543     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
544 
545 }
546 
547 /* ......................................................................... */
548 
549 t_Error FM_MAC_GetId (t_Handle h_FmMac, uint32_t *macId)
550 {
551     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
552 
553     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
554 
555     if (p_FmMacControllerDriver->f_FM_MAC_GetId)
556         return p_FmMacControllerDriver->f_FM_MAC_GetId(h_FmMac, macId);
557 
558     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
559 }
560 
561 /* ......................................................................... */
562 
563 t_Error FM_MAC_SetPromiscuous (t_Handle h_FmMac, bool newVal)
564 {
565     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
566 
567     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
568 
569     if (p_FmMacControllerDriver->f_FM_MAC_SetPromiscuous)
570         return p_FmMacControllerDriver->f_FM_MAC_SetPromiscuous(h_FmMac, newVal);
571 
572     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
573 }
574 
575 /* ......................................................................... */
576 
577 t_Error FM_MAC_AdjustLink(t_Handle h_FmMac, e_EnetSpeed speed, bool fullDuplex)
578 {
579     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
580 
581     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
582 
583     if (p_FmMacControllerDriver->f_FM_MAC_AdjustLink)
584         return p_FmMacControllerDriver->f_FM_MAC_AdjustLink(h_FmMac, speed, fullDuplex);
585 
586     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
587 }
588 
589 /* ......................................................................... */
590 
591 t_Error FM_MAC_RestartAutoneg(t_Handle h_FmMac)
592 {
593     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
594 
595     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
596 
597     if (p_FmMacControllerDriver->f_FM_MAC_RestartAutoneg)
598         return p_FmMacControllerDriver->f_FM_MAC_RestartAutoneg(h_FmMac);
599 
600     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
601 }
602 
603 /* ......................................................................... */
604 
605 t_Error FM_MAC_MII_WritePhyReg (t_Handle h_FmMac, uint8_t phyAddr, uint8_t reg, uint16_t data)
606 {
607     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
608 
609     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
610 
611     if (p_FmMacControllerDriver->f_FM_MAC_MII_WritePhyReg)
612         return p_FmMacControllerDriver->f_FM_MAC_MII_WritePhyReg(h_FmMac, phyAddr, reg, data);
613 
614     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
615 }
616 
617 /* ......................................................................... */
618 
619 t_Error FM_MAC_MII_ReadPhyReg(t_Handle h_FmMac,  uint8_t phyAddr, uint8_t reg, uint16_t *p_Data)
620 {
621     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
622 
623     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
624 
625     if (p_FmMacControllerDriver->f_FM_MAC_MII_ReadPhyReg)
626         return p_FmMacControllerDriver->f_FM_MAC_MII_ReadPhyReg(h_FmMac, phyAddr, reg, p_Data);
627 
628     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
629 }
630 
631 /* ......................................................................... */
632 
633 uint16_t FM_MAC_GetMaxFrameLength(t_Handle h_FmMac)
634 {
635     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
636 
637     SANITY_CHECK_RETURN_VALUE(p_FmMacControllerDriver, E_INVALID_HANDLE, 0);
638 
639     if (p_FmMacControllerDriver->f_FM_MAC_GetMaxFrameLength)
640         return p_FmMacControllerDriver->f_FM_MAC_GetMaxFrameLength(h_FmMac);
641 
642     REPORT_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
643     return 0;
644 }
645 
646 #if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
647 /*****************************************************************************/
648 t_Error FM_MAC_DumpRegs(t_Handle h_FmMac)
649 {
650     t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
651 
652     SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
653 
654     if (p_FmMacControllerDriver->f_FM_MAC_DumpRegs)
655          return p_FmMacControllerDriver->f_FM_MAC_DumpRegs(h_FmMac);
656     RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
657 }
658 #endif /* (defined(DEBUG_ERRORS) && ... */
659