blob: 44328473e63cd75128c57147614b6633ce8b3981 [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
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions
23 * are met:
24 * 1. Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * 2. Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in the
28 * documentation and/or other materials provided with the distribution.
29 * 3. Neither the name of the Intel Corporation nor the names of its contributors
30 * may be used to endorse or promote products derived from this software
31 * without specific prior written permission.
32 *
33 * @par
34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
35 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
38 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
40 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
41 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
42 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
43 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 * SUCH DAMAGE.
45 *
46 * @par
47 * -- End of Copyright Notice --
48 */
49
50#include "IxOsal.h"
51#include "IxEthAcc.h"
52#include "IxEthAcc_p.h"
53
54PUBLIC IxOsalMutex ixEthAccControlInterfaceMutex;
55
56IX_ETH_ACC_PUBLIC IxEthAccStatus
57ixEthAccPortEnable(IxEthAccPortId portId)
58{
59 IxEthAccStatus result;
60
61 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
62 {
63 printf("EthAcc: (Mac) cannot enable port %d, service not initialized\n", portId);
64 return (IX_ETH_ACC_FAIL);
65 }
66
67 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
68 result = ixEthAccPortEnablePriv(portId);
69 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
70 return result;
71}
72
73IX_ETH_ACC_PUBLIC IxEthAccStatus
74ixEthAccPortDisable(IxEthAccPortId portId)
75{
76 IxEthAccStatus result;
77
78 /* check the context is iinitialized */
79 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
80 {
81 return (IX_ETH_ACC_FAIL);
82 }
83
84 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
85 result = ixEthAccPortDisablePriv(portId);
86 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
87 return result;
88}
89
90IX_ETH_ACC_PUBLIC IxEthAccStatus
91ixEthAccPortEnabledQuery(IxEthAccPortId portId, BOOL *enabled)
92{
93 IxEthAccStatus result;
94
95 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
96 {
97 return (IX_ETH_ACC_FAIL);
98 }
99
100 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
101 result = ixEthAccPortEnabledQueryPriv(portId, enabled);
102 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
103 return result;
104}
105
106IX_ETH_ACC_PUBLIC IxEthAccStatus
107ixEthAccPortPromiscuousModeClear(IxEthAccPortId portId)
108{
109 IxEthAccStatus result;
110
111 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
112 {
113 return (IX_ETH_ACC_FAIL);
114 }
115
116 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
117 result = ixEthAccPortPromiscuousModeClearPriv(portId);
118 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
119 return result;
120}
121
122IX_ETH_ACC_PUBLIC IxEthAccStatus
123ixEthAccPortPromiscuousModeSet(IxEthAccPortId portId)
124{
125 IxEthAccStatus result;
126
127 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
128 {
129 return (IX_ETH_ACC_FAIL);
130 }
131
132 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
133 result = ixEthAccPortPromiscuousModeSetPriv(portId);
134 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
135 return result;
136}
137
138IX_ETH_ACC_PUBLIC IxEthAccStatus
139ixEthAccPortUnicastMacAddressSet(IxEthAccPortId portId, IxEthAccMacAddr *macAddr)
140{
141 IxEthAccStatus result;
142
143 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
144 {
145 return (IX_ETH_ACC_FAIL);
146 }
147
148 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
149 result = ixEthAccPortUnicastMacAddressSetPriv(portId, macAddr);
150 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
151 return result;
152}
153
154IX_ETH_ACC_PUBLIC IxEthAccStatus
155ixEthAccPortUnicastMacAddressGet(IxEthAccPortId portId, IxEthAccMacAddr *macAddr)
156{
157 IxEthAccStatus result;
158
159 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
160 {
161 return (IX_ETH_ACC_FAIL);
162 }
163
164 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
165 result = ixEthAccPortUnicastMacAddressGetPriv(portId, macAddr);
166 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
167 return result;
168}
169
170IX_ETH_ACC_PUBLIC IxEthAccStatus
171ixEthAccPortMulticastAddressJoin(IxEthAccPortId portId, IxEthAccMacAddr *macAddr)
172{
173 IxEthAccStatus result;
174
175 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
176 {
177 return (IX_ETH_ACC_FAIL);
178 }
179
180 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
181 result = ixEthAccPortMulticastAddressJoinPriv(portId, macAddr);
182 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
183 return result;
184}
185
186IX_ETH_ACC_PUBLIC IxEthAccStatus
187ixEthAccPortMulticastAddressJoinAll(IxEthAccPortId portId)
188{
189 IxEthAccStatus result;
190
191 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
192 {
193 return (IX_ETH_ACC_FAIL);
194 }
195
196 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
197 result = ixEthAccPortMulticastAddressJoinAllPriv(portId);
198 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
199 return result;
200}
201
202IX_ETH_ACC_PUBLIC IxEthAccStatus
203ixEthAccPortMulticastAddressLeave(IxEthAccPortId portId, IxEthAccMacAddr *macAddr)
204{
205 IxEthAccStatus result;
206
207 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
208 {
209 return (IX_ETH_ACC_FAIL);
210 }
211
212 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
213 result = ixEthAccPortMulticastAddressLeavePriv(portId, macAddr);
214 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
215 return result;
216}
217
218IX_ETH_ACC_PUBLIC IxEthAccStatus
219ixEthAccPortMulticastAddressLeaveAll(IxEthAccPortId portId)
220{
221 IxEthAccStatus result;
222
223 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
224 {
225 return (IX_ETH_ACC_FAIL);
226 }
227
228 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
229 result = ixEthAccPortMulticastAddressLeaveAllPriv(portId);
230 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
231 return result;
232}
233
234IX_ETH_ACC_PUBLIC IxEthAccStatus
235ixEthAccPortUnicastAddressShow(IxEthAccPortId portId)
236{
237 IxEthAccStatus result;
238
239 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
240 {
241 return (IX_ETH_ACC_FAIL);
242 }
243
244 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
245 result = ixEthAccPortUnicastAddressShowPriv(portId);
246 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
247 return result;
248}
249
250IX_ETH_ACC_PUBLIC void
251ixEthAccPortMulticastAddressShow(IxEthAccPortId portId)
252{
253 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
254 {
255 return;
256 }
257
258 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
259 ixEthAccPortMulticastAddressShowPriv(portId);
260 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
261}
262
263IX_ETH_ACC_PUBLIC IxEthAccStatus
264ixEthAccPortDuplexModeSet(IxEthAccPortId portId, IxEthAccDuplexMode mode)
265{
266 IxEthAccStatus result;
267
268 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
269 {
270 return (IX_ETH_ACC_FAIL);
271 }
272
273 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
274 result = ixEthAccPortDuplexModeSetPriv(portId, mode);
275 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
276 return result;
277}
278
279IX_ETH_ACC_PUBLIC IxEthAccStatus
280ixEthAccPortDuplexModeGet(IxEthAccPortId portId, IxEthAccDuplexMode *mode)
281{
282 IxEthAccStatus result;
283
284 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
285 {
286 return (IX_ETH_ACC_FAIL);
287 }
288
289 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
290 result = ixEthAccPortDuplexModeGetPriv(portId, mode);
291 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
292 return result;
293}
294
295IX_ETH_ACC_PUBLIC IxEthAccStatus
296ixEthAccPortTxFrameAppendPaddingEnable(IxEthAccPortId portId)
297{
298 IxEthAccStatus result;
299
300 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
301 {
302 return (IX_ETH_ACC_FAIL);
303 }
304
305 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
306 result = ixEthAccPortTxFrameAppendPaddingEnablePriv(portId);
307 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
308 return result;
309}
310
311IX_ETH_ACC_PUBLIC IxEthAccStatus
312ixEthAccPortTxFrameAppendPaddingDisable(IxEthAccPortId portId)
313{
314 IxEthAccStatus result;
315
316 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
317 {
318 return (IX_ETH_ACC_FAIL);
319 }
320
321 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
322 result = ixEthAccPortTxFrameAppendPaddingDisablePriv(portId);
323 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
324 return result;
325}
326
327IX_ETH_ACC_PUBLIC IxEthAccStatus
328ixEthAccPortTxFrameAppendFCSEnable(IxEthAccPortId portId)
329{
330 IxEthAccStatus result;
331
332 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
333 {
334 return (IX_ETH_ACC_FAIL);
335 }
336
337 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
338 result = ixEthAccPortTxFrameAppendFCSEnablePriv(portId);
339 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
340 return result;
341}
342
343IX_ETH_ACC_PUBLIC IxEthAccStatus
344ixEthAccPortTxFrameAppendFCSDisable(IxEthAccPortId portId)
345{
346 IxEthAccStatus result;
347
348 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
349 {
350 return (IX_ETH_ACC_FAIL);
351 }
352
353 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
354 result = ixEthAccPortTxFrameAppendFCSDisablePriv(portId);
355 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
356 return result;
357}
358
359IX_ETH_ACC_PUBLIC IxEthAccStatus
360ixEthAccPortRxFrameAppendFCSEnable(IxEthAccPortId portId)
361{
362 IxEthAccStatus result;
363
364 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
365 {
366 return (IX_ETH_ACC_FAIL);
367 }
368
369 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
370 result = ixEthAccPortRxFrameAppendFCSEnablePriv(portId);
371 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
372 return result;
373}
374
375IX_ETH_ACC_PUBLIC IxEthAccStatus
376ixEthAccPortRxFrameAppendFCSDisable(IxEthAccPortId portId)
377{
378 IxEthAccStatus result;
379
380 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
381 {
382 return (IX_ETH_ACC_FAIL);
383 }
384
385 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
386 result = ixEthAccPortRxFrameAppendFCSDisablePriv(portId);
387 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
388 return result;
389}
390
391IX_ETH_ACC_PUBLIC IxEthAccStatus
392ixEthAccTxSchedulingDisciplineSet(IxEthAccPortId portId, IxEthAccSchedulerDiscipline sched)
393{
394 IxEthAccStatus result;
395
396 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
397 {
398 return (IX_ETH_ACC_FAIL);
399 }
400
401 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
402 result = ixEthAccTxSchedulingDisciplineSetPriv(portId, sched);
403 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
404 return result;
405}
406
407IX_ETH_ACC_PUBLIC IxEthAccStatus
408ixEthAccRxSchedulingDisciplineSet(IxEthAccSchedulerDiscipline sched)
409{
410 IxEthAccStatus result;
411
412 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
413 {
414 return (IX_ETH_ACC_FAIL);
415 }
416
417 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
418 result = ixEthAccRxSchedulingDisciplineSetPriv(sched);
419 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
420 return result;
421}
422
423IX_ETH_ACC_PUBLIC IxEthAccStatus
424ixEthAccPortNpeLoopbackEnable(IxEthAccPortId portId)
425{
426 IxEthAccStatus result;
427
428 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
429 {
430 return (IX_ETH_ACC_FAIL);
431 }
432
433 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
434 result = ixEthAccNpeLoopbackEnablePriv(portId);
435 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
436 return result;
437}
438
439IX_ETH_ACC_PUBLIC IxEthAccStatus
440ixEthAccPortTxEnable(IxEthAccPortId portId)
441{
442 IxEthAccStatus result;
443
444 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
445 {
446 return (IX_ETH_ACC_FAIL);
447 }
448
449 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
450 result = ixEthAccPortTxEnablePriv(portId);
451 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
452 return result;
453}
454
455IX_ETH_ACC_PUBLIC IxEthAccStatus
456ixEthAccPortRxEnable(IxEthAccPortId portId)
457{
458 IxEthAccStatus result;
459
460 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
461 {
462 return (IX_ETH_ACC_FAIL);
463 }
464
465 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
466 result = ixEthAccPortRxEnablePriv(portId);
467 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
468 return result;
469}
470
471IX_ETH_ACC_PUBLIC IxEthAccStatus
472ixEthAccPortNpeLoopbackDisable(IxEthAccPortId portId)
473{
474 IxEthAccStatus result;
475
476 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
477 {
478 return (IX_ETH_ACC_FAIL);
479 }
480
481 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
482 result = ixEthAccNpeLoopbackDisablePriv(portId);
483 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
484 return result;
485}
486
487IX_ETH_ACC_PUBLIC IxEthAccStatus
488ixEthAccPortTxDisable(IxEthAccPortId portId)
489{
490 IxEthAccStatus result;
491
492 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
493 {
494 return (IX_ETH_ACC_FAIL);
495 }
496
497 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
498 result = ixEthAccPortTxDisablePriv(portId);
499 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
500 return result;
501}
502
503IX_ETH_ACC_PUBLIC IxEthAccStatus
504ixEthAccPortRxDisable(IxEthAccPortId portId)
505{
506 IxEthAccStatus result;
507
508 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
509 {
510 return (IX_ETH_ACC_FAIL);
511 }
512
513 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
514 result = ixEthAccPortRxDisablePriv(portId);
515 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
516 return result;
517}
518
519IX_ETH_ACC_PUBLIC IxEthAccStatus
520ixEthAccPortMacReset(IxEthAccPortId portId)
521{
522 IxEthAccStatus result;
523
524 if (!IX_ETH_ACC_IS_SERVICE_INITIALIZED())
525 {
526 return (IX_ETH_ACC_FAIL);
527 }
528
529 ixOsalMutexLock(&ixEthAccControlInterfaceMutex, IX_OSAL_WAIT_FOREVER);
530 result = ixEthAccPortMacResetPriv(portId);
531 ixOsalMutexUnlock(&ixEthAccControlInterfaceMutex);
532 return result;
533}