blob: dbe32e133c2d2103da4a11cfc8e864aed4ebe28a [file] [log] [blame]
Wolfgang Denkba94a1b2006-05-30 15:56:48 +02001/**
2 * @file IxEthAccControlInterface.c
3 *
4 * @author Intel Corporation
5 * @date
6 *
7 * @brief IX_ETH_ACC_PUBLIC wrappers for control plane functions
8 *
9 * Design Notes:
10 *
11 * @par
12 * IXP400 SW Release version 2.0
13 *
14 * -- Copyright Notice --
15 *
16 * @par
17 * Copyright 2001-2005, Intel Corporation.
18 * All rights reserved.
19 *
20 * @par
Wolfgang Denkcb3761e2013-07-28 22:12:47 +020021 * SPDX-License-Identifier: BSD-3-Clause
Wolfgang Denkba94a1b2006-05-30 15:56:48 +020022 * @par
23 * -- End of Copyright Notice --
24 */
25
26#include "IxOsal.h"
27#include "IxEthAcc.h"
28#include "IxEthAcc_p.h"
29
30PUBLIC IxOsalMutex ixEthAccControlInterfaceMutex;
31
32IX_ETH_ACC_PUBLIC IxEthAccStatus
33ixEthAccPortEnable(IxEthAccPortId portId)
34{
35 IxEthAccStatus result;
36
37 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
38 {
39 printf("EthAcc: (Mac) cannot enable port %d, service not initialized\n", portId);
40 return (IX_ETH_ACC_FAIL);
41 }
42
43 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
44 result = ixEthAccPortEnablePriv(portId);
45 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
46 return result;
47}
48
49IX_ETH_ACC_PUBLIC IxEthAccStatus
50ixEthAccPortDisable(IxEthAccPortId portId)
51{
52 IxEthAccStatus result;
53
54 /* check the context is iinitialized */
55 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
56 {
57 return (IX_ETH_ACC_FAIL);
58 }
59
60 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
61 result = ixEthAccPortDisablePriv(portId);
62 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
63 return result;
64}
65
66IX_ETH_ACC_PUBLIC IxEthAccStatus
67ixEthAccPortEnabledQuery(IxEthAccPortId portId, BOOL *enabled)
68{
69 IxEthAccStatus result;
70
71 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
72 {
73 return (IX_ETH_ACC_FAIL);
74 }
75
76 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
77 result = ixEthAccPortEnabledQueryPriv(portId, enabled);
78 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
79 return result;
80}
81
82IX_ETH_ACC_PUBLIC IxEthAccStatus
83ixEthAccPortPromiscuousModeClear(IxEthAccPortId portId)
84{
85 IxEthAccStatus result;
86
87 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
88 {
89 return (IX_ETH_ACC_FAIL);
90 }
91
92 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
93 result = ixEthAccPortPromiscuousModeClearPriv(portId);
94 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
95 return result;
96}
97
98IX_ETH_ACC_PUBLIC IxEthAccStatus
99ixEthAccPortPromiscuousModeSet(IxEthAccPortId portId)
100{
101 IxEthAccStatus result;
102
103 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
104 {
105 return (IX_ETH_ACC_FAIL);
106 }
107
108 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
109 result = ixEthAccPortPromiscuousModeSetPriv(portId);
110 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
111 return result;
112}
113
114IX_ETH_ACC_PUBLIC IxEthAccStatus
115ixEthAccPortUnicastMacAddressSet(IxEthAccPortId portId, IxEthAccMacAddr *macAddr)
116{
117 IxEthAccStatus result;
118
119 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
120 {
121 return (IX_ETH_ACC_FAIL);
122 }
123
124 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
125 result = ixEthAccPortUnicastMacAddressSetPriv(portId, macAddr);
126 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
127 return result;
128}
129
130IX_ETH_ACC_PUBLIC IxEthAccStatus
131ixEthAccPortUnicastMacAddressGet(IxEthAccPortId portId, IxEthAccMacAddr *macAddr)
132{
133 IxEthAccStatus result;
134
135 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
136 {
137 return (IX_ETH_ACC_FAIL);
138 }
139
140 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
141 result = ixEthAccPortUnicastMacAddressGetPriv(portId, macAddr);
142 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
143 return result;
144}
145
146IX_ETH_ACC_PUBLIC IxEthAccStatus
147ixEthAccPortMulticastAddressJoin(IxEthAccPortId portId, IxEthAccMacAddr *macAddr)
148{
149 IxEthAccStatus result;
150
151 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
152 {
153 return (IX_ETH_ACC_FAIL);
154 }
155
156 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
157 result = ixEthAccPortMulticastAddressJoinPriv(portId, macAddr);
158 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
159 return result;
160}
161
162IX_ETH_ACC_PUBLIC IxEthAccStatus
163ixEthAccPortMulticastAddressJoinAll(IxEthAccPortId portId)
164{
165 IxEthAccStatus result;
166
167 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
168 {
169 return (IX_ETH_ACC_FAIL);
170 }
171
172 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
173 result = ixEthAccPortMulticastAddressJoinAllPriv(portId);
174 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
175 return result;
176}
177
178IX_ETH_ACC_PUBLIC IxEthAccStatus
179ixEthAccPortMulticastAddressLeave(IxEthAccPortId portId, IxEthAccMacAddr *macAddr)
180{
181 IxEthAccStatus result;
182
183 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
184 {
185 return (IX_ETH_ACC_FAIL);
186 }
187
188 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
189 result = ixEthAccPortMulticastAddressLeavePriv(portId, macAddr);
190 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
191 return result;
192}
193
194IX_ETH_ACC_PUBLIC IxEthAccStatus
195ixEthAccPortMulticastAddressLeaveAll(IxEthAccPortId portId)
196{
197 IxEthAccStatus result;
198
199 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
200 {
201 return (IX_ETH_ACC_FAIL);
202 }
203
204 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
205 result = ixEthAccPortMulticastAddressLeaveAllPriv(portId);
206 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
207 return result;
208}
209
210IX_ETH_ACC_PUBLIC IxEthAccStatus
211ixEthAccPortUnicastAddressShow(IxEthAccPortId portId)
212{
213 IxEthAccStatus result;
214
215 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
216 {
217 return (IX_ETH_ACC_FAIL);
218 }
219
220 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
221 result = ixEthAccPortUnicastAddressShowPriv(portId);
222 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
223 return result;
224}
225
226IX_ETH_ACC_PUBLIC void
227ixEthAccPortMulticastAddressShow(IxEthAccPortId portId)
228{
229 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
230 {
231 return;
232 }
233
234 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
235 ixEthAccPortMulticastAddressShowPriv(portId);
236 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
237}
238
239IX_ETH_ACC_PUBLIC IxEthAccStatus
240ixEthAccPortDuplexModeSet(IxEthAccPortId portId, IxEthAccDuplexMode mode)
241{
242 IxEthAccStatus result;
243
244 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
245 {
246 return (IX_ETH_ACC_FAIL);
247 }
248
249 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
250 result = ixEthAccPortDuplexModeSetPriv(portId, mode);
251 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
252 return result;
253}
254
255IX_ETH_ACC_PUBLIC IxEthAccStatus
256ixEthAccPortDuplexModeGet(IxEthAccPortId portId, IxEthAccDuplexMode *mode)
257{
258 IxEthAccStatus result;
259
260 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
261 {
262 return (IX_ETH_ACC_FAIL);
263 }
264
265 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
266 result = ixEthAccPortDuplexModeGetPriv(portId, mode);
267 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
268 return result;
269}
270
271IX_ETH_ACC_PUBLIC IxEthAccStatus
272ixEthAccPortTxFrameAppendPaddingEnable(IxEthAccPortId portId)
273{
274 IxEthAccStatus result;
275
276 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
277 {
278 return (IX_ETH_ACC_FAIL);
279 }
280
281 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
282 result = ixEthAccPortTxFrameAppendPaddingEnablePriv(portId);
283 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
284 return result;
285}
286
287IX_ETH_ACC_PUBLIC IxEthAccStatus
288ixEthAccPortTxFrameAppendPaddingDisable(IxEthAccPortId portId)
289{
290 IxEthAccStatus result;
291
292 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
293 {
294 return (IX_ETH_ACC_FAIL);
295 }
296
297 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
298 result = ixEthAccPortTxFrameAppendPaddingDisablePriv(portId);
299 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
300 return result;
301}
302
303IX_ETH_ACC_PUBLIC IxEthAccStatus
304ixEthAccPortTxFrameAppendFCSEnable(IxEthAccPortId portId)
305{
306 IxEthAccStatus result;
307
308 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
309 {
310 return (IX_ETH_ACC_FAIL);
311 }
312
313 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
314 result = ixEthAccPortTxFrameAppendFCSEnablePriv(portId);
315 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
316 return result;
317}
318
319IX_ETH_ACC_PUBLIC IxEthAccStatus
320ixEthAccPortTxFrameAppendFCSDisable(IxEthAccPortId portId)
321{
322 IxEthAccStatus result;
323
324 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
325 {
326 return (IX_ETH_ACC_FAIL);
327 }
328
329 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
330 result = ixEthAccPortTxFrameAppendFCSDisablePriv(portId);
331 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
332 return result;
333}
334
335IX_ETH_ACC_PUBLIC IxEthAccStatus
336ixEthAccPortRxFrameAppendFCSEnable(IxEthAccPortId portId)
337{
338 IxEthAccStatus result;
339
340 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
341 {
342 return (IX_ETH_ACC_FAIL);
343 }
344
345 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
346 result = ixEthAccPortRxFrameAppendFCSEnablePriv(portId);
347 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
348 return result;
349}
350
351IX_ETH_ACC_PUBLIC IxEthAccStatus
352ixEthAccPortRxFrameAppendFCSDisable(IxEthAccPortId portId)
353{
354 IxEthAccStatus result;
355
356 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
357 {
358 return (IX_ETH_ACC_FAIL);
359 }
360
361 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
362 result = ixEthAccPortRxFrameAppendFCSDisablePriv(portId);
363 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
364 return result;
365}
366
367IX_ETH_ACC_PUBLIC IxEthAccStatus
368ixEthAccTxSchedulingDisciplineSet(IxEthAccPortId portId, IxEthAccSchedulerDiscipline sched)
369{
370 IxEthAccStatus result;
371
372 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
373 {
374 return (IX_ETH_ACC_FAIL);
375 }
376
377 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
378 result = ixEthAccTxSchedulingDisciplineSetPriv(portId, sched);
379 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
380 return result;
381}
382
383IX_ETH_ACC_PUBLIC IxEthAccStatus
384ixEthAccRxSchedulingDisciplineSet(IxEthAccSchedulerDiscipline sched)
385{
386 IxEthAccStatus result;
387
388 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
389 {
390 return (IX_ETH_ACC_FAIL);
391 }
392
393 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
394 result = ixEthAccRxSchedulingDisciplineSetPriv(sched);
395 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
396 return result;
397}
398
399IX_ETH_ACC_PUBLIC IxEthAccStatus
400ixEthAccPortNpeLoopbackEnable(IxEthAccPortId portId)
401{
402 IxEthAccStatus result;
403
404 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
405 {
406 return (IX_ETH_ACC_FAIL);
407 }
408
409 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
410 result = ixEthAccNpeLoopbackEnablePriv(portId);
411 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
412 return result;
413}
414
415IX_ETH_ACC_PUBLIC IxEthAccStatus
416ixEthAccPortTxEnable(IxEthAccPortId portId)
417{
418 IxEthAccStatus result;
419
420 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
421 {
422 return (IX_ETH_ACC_FAIL);
423 }
424
425 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
426 result = ixEthAccPortTxEnablePriv(portId);
427 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
428 return result;
429}
430
431IX_ETH_ACC_PUBLIC IxEthAccStatus
432ixEthAccPortRxEnable(IxEthAccPortId portId)
433{
434 IxEthAccStatus result;
435
436 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
437 {
438 return (IX_ETH_ACC_FAIL);
439 }
440
441 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
442 result = ixEthAccPortRxEnablePriv(portId);
443 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
444 return result;
445}
446
447IX_ETH_ACC_PUBLIC IxEthAccStatus
448ixEthAccPortNpeLoopbackDisable(IxEthAccPortId portId)
449{
450 IxEthAccStatus result;
451
452 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
453 {
454 return (IX_ETH_ACC_FAIL);
455 }
456
457 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
458 result = ixEthAccNpeLoopbackDisablePriv(portId);
459 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
460 return result;
461}
462
463IX_ETH_ACC_PUBLIC IxEthAccStatus
464ixEthAccPortTxDisable(IxEthAccPortId portId)
465{
466 IxEthAccStatus result;
467
468 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
469 {
470 return (IX_ETH_ACC_FAIL);
471 }
472
473 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
474 result = ixEthAccPortTxDisablePriv(portId);
475 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
476 return result;
477}
478
479IX_ETH_ACC_PUBLIC IxEthAccStatus
480ixEthAccPortRxDisable(IxEthAccPortId portId)
481{
482 IxEthAccStatus result;
483
484 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
485 {
486 return (IX_ETH_ACC_FAIL);
487 }
488
489 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
490 result = ixEthAccPortRxDisablePriv(portId);
491 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
492 return result;
493}
494
495IX_ETH_ACC_PUBLIC IxEthAccStatus
496ixEthAccPortMacReset(IxEthAccPortId portId)
497{
498 IxEthAccStatus result;
499
500 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
501 {
502 return (IX_ETH_ACC_FAIL);
503 }
504
505 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
506 result = ixEthAccPortMacResetPriv(portId);
507 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
508 return result;
509}