4 * @author Intel Corporation
7 * @brief This file contains the implementation of the IXP425 Ethernet Access Component
12 * IXP400 SW Release version 2.0
14 * -- Copyright Notice --
17 * Copyright 2001-2005, Intel Corporation.
18 * All rights reserved.
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions
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.
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
47 * -- End of Copyright Notice --
53 #ifdef CONFIG_IXP425_COMPONENT_ETHDB
56 #include "IxFeatureCtrl.h"
58 #include "IxEthAcc_p.h"
59 #include "IxEthAccMac_p.h"
60 #include "IxEthAccMii_p.h"
63 * @addtogroup IxEthAcc
69 * @brief System-wide information data strucure.
71 * @ingroup IxEthAccPri
75 IxEthAccInfo ixEthAccDataInfo
;
76 extern PUBLIC IxEthAccMacState ixEthAccMacState
[];
77 extern PUBLIC IxOsalMutex ixEthAccControlInterfaceMutex
;
80 * @brief System-wide information
82 * @ingroup IxEthAccPri
85 BOOL ixEthAccServiceInit
= FALSE
;
87 /* global filtering bit mask */
88 PUBLIC UINT32 ixEthAccNewSrcMask
;
91 * @brief Per port information data strucure.
93 * @ingroup IxEthAccPri
97 IxEthAccPortDataInfo ixEthAccPortData
[IX_ETH_ACC_NUMBER_OF_PORTS
];
99 PUBLIC IxEthAccStatus
ixEthAccInit()
101 #ifdef CONFIG_IXP425_COMPONENT_ETHDB
103 * Initialize Control plane
105 if (ixEthDBInit() != IX_ETH_ACC_SUCCESS
)
107 IX_ETH_ACC_WARNING_LOG("ixEthAccInit: EthDB init failed\n", 0, 0, 0, 0, 0, 0);
109 return IX_ETH_ACC_FAIL
;
113 if (IX_FEATURE_CTRL_SWCONFIG_ENABLED
== ixFeatureCtrlSwConfigurationCheck (IX_FEATURECTRL_ETH_LEARNING
))
115 ixEthAccNewSrcMask
= (~0); /* want all the bits */
119 ixEthAccNewSrcMask
= (~IX_ETHACC_NE_NEWSRCMASK
); /* want all but the NewSrc bit */
123 * Initialize Data plane
125 if ( ixEthAccInitDataPlane() != IX_ETH_ACC_SUCCESS
)
127 IX_ETH_ACC_WARNING_LOG("ixEthAccInit: data plane init failed\n", 0, 0, 0, 0, 0, 0);
129 return IX_ETH_ACC_FAIL
;
133 if ( ixEthAccQMgrQueuesConfig() != IX_ETH_ACC_SUCCESS
)
135 IX_ETH_ACC_WARNING_LOG("ixEthAccInit: queue config failed\n", 0, 0, 0, 0, 0, 0);
137 return IX_ETH_ACC_FAIL
;
143 if ( ixEthAccMiiInit() != IX_ETH_ACC_SUCCESS
)
145 IX_ETH_ACC_WARNING_LOG("ixEthAccInit: Mii init failed\n", 0, 0, 0, 0, 0, 0);
147 return IX_ETH_ACC_FAIL
;
151 * Initialize MAC I/O memory
153 if (ixEthAccMacMemInit() != IX_ETH_ACC_SUCCESS
)
155 IX_ETH_ACC_WARNING_LOG("ixEthAccInit: Mac init failed\n", 0, 0, 0, 0, 0, 0);
157 return IX_ETH_ACC_FAIL
;
161 * Initialize control plane interface lock
163 if (ixOsalMutexInit(&ixEthAccControlInterfaceMutex
) != IX_SUCCESS
)
165 IX_ETH_ACC_WARNING_LOG("ixEthAccInit: Control plane interface lock initialization failed\n", 0, 0, 0, 0, 0, 0);
167 return IX_ETH_ACC_FAIL
;
170 /* initialiasation is complete */
171 ixEthAccServiceInit
= TRUE
;
173 return IX_ETH_ACC_SUCCESS
;
177 PUBLIC
void ixEthAccUnload(void)
179 IxEthAccPortId portId
;
181 if ( IX_ETH_ACC_IS_SERVICE_INITIALIZED() )
183 /* check none of the port is still active */
184 for (portId
= 0; portId
< IX_ETH_ACC_NUMBER_OF_PORTS
; portId
++)
186 if ( IX_ETH_IS_PORT_INITIALIZED(portId
) )
188 if (ixEthAccMacState
[portId
].portDisableState
== ACTIVE
)
190 IX_ETH_ACC_WARNING_LOG("ixEthAccUnload: port %u still active, bail out\n", portId
, 0, 0, 0, 0, 0);
196 /* unmap the memory areas */
200 /* set all ports as uninitialized */
201 for (portId
= 0; portId
< IX_ETH_ACC_NUMBER_OF_PORTS
; portId
++)
203 ixEthAccPortData
[portId
].portInitialized
= FALSE
;
206 /* uninitialize the service */
207 ixEthAccServiceInit
= FALSE
;
211 PUBLIC IxEthAccStatus
ixEthAccPortInit( IxEthAccPortId portId
)
214 IxEthAccStatus ret
=IX_ETH_ACC_SUCCESS
;
216 if ( ! IX_ETH_ACC_IS_SERVICE_INITIALIZED() )
218 return(IX_ETH_ACC_FAIL
);
222 * Check for valid port
225 if ( ! IX_ETH_ACC_IS_PORT_VALID(portId
) )
227 return (IX_ETH_ACC_INVALID_PORT
);
230 if (IX_ETH_ACC_SUCCESS
!= ixEthAccSingleEthNpeCheck(portId
))
232 IX_ETH_ACC_WARNING_LOG("EthAcc: Unavailable Eth %d: Cannot initialize Eth port.\n",(INT32
) portId
,0,0,0,0,0);
233 return IX_ETH_ACC_SUCCESS
;
236 if ( IX_ETH_IS_PORT_INITIALIZED(portId
) )
238 /* Already initialized */
239 return(IX_ETH_ACC_FAIL
);
242 if(ixEthAccMacInit(portId
)!=IX_ETH_ACC_SUCCESS
)
244 return IX_ETH_ACC_FAIL
;
248 * Set the port init flag.
251 ixEthAccPortData
[portId
].portInitialized
= TRUE
;
253 #ifdef CONFIG_IXP425_COMPONENT_ETHDB
254 /* init learning/filtering database structures for this port */
255 ixEthDBPortInit(portId
);