diff options
author | Evan Lojewski <github@meklort.com> | 2020-02-28 20:26:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-28 20:26:39 -0700 |
commit | d290d312a8494e73b03d6870a60344db1d698bc1 (patch) | |
tree | 1e7154e0fdb13d39e5f0191341eb069402217dc6 /libs | |
parent | b43a7470d4cb61a0e26a15e667a77ab64e839220 (diff) | |
download | bcm5719-ortega-d290d312a8494e73b03d6870a60344db1d698bc1.tar.gz bcm5719-ortega-d290d312a8494e73b03d6870a60344db1d698bc1.zip |
network: Initialize ape tx/rx only when a port is enabled. (#48)
Diffstat (limited to 'libs')
-rw-r--r-- | libs/Network/CMakeLists.txt | 1 | ||||
-rw-r--r-- | libs/Network/include/Network.h | 4 | ||||
-rw-r--r-- | libs/Network/init.c | 72 | ||||
-rw-r--r-- | libs/Network/ports.c | 26 |
4 files changed, 29 insertions, 74 deletions
diff --git a/libs/Network/CMakeLists.txt b/libs/Network/CMakeLists.txt index b2b349b..b0fb993 100644 --- a/libs/Network/CMakeLists.txt +++ b/libs/Network/CMakeLists.txt @@ -45,7 +45,6 @@ project(Network) SET(SOURCES - init.c ports.c tx.c rx.c diff --git a/libs/Network/include/Network.h b/libs/Network/include/Network.h index 059e04c..b90e96e 100644 --- a/libs/Network/include/Network.h +++ b/libs/Network/include/Network.h @@ -78,6 +78,9 @@ typedef struct VOLATILE DEVICE_t *device; VOLATILE FILTERS_t *filters; VOLATILE SHM_CHANNEL_t* shm_channel; + + /* APE Registers */ + VOLATILE RegAPEMode_t APEModeEnable; } NetworkPort_t; typedef union @@ -98,7 +101,6 @@ extern NetworkPort_t gPort2; extern NetworkPort_t gPort3; void Network_InitPort(NetworkPort_t *port); -void Network_InitTxRx(void); void Network_resetTX(NetworkPort_t *port); void Network_resetRX(NetworkPort_t *port); diff --git a/libs/Network/init.c b/libs/Network/init.c deleted file mode 100644 index a5733b7..0000000 --- a/libs/Network/init.c +++ /dev/null @@ -1,72 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// -/// @file init.c -/// -/// @project -/// -/// @brief Initialization code for TX to network / RX from network. -/// -//////////////////////////////////////////////////////////////////////////////// -/// -//////////////////////////////////////////////////////////////////////////////// -/// -/// @copyright Copyright (c) 2018, Evan Lojewski -/// @cond -/// -/// All rights reserved. -/// -/// Redistribution and use in source and binary forms, with or without -/// modification, are permitted provided that the following conditions are met: -/// 1. Redistributions of source code must retain the above copyright notice, -/// this list of conditions and the following disclaimer. -/// 2. Redistributions in binary form must reproduce the above copyright notice, -/// this list of conditions and the following disclaimer in the documentation -/// and/or other materials provided with the distribution. -/// 3. Neither the name of the copyright holder nor the -/// names of its contributors may be used to endorse or promote products -/// derived from this software without specific prior written permission. -/// -//////////////////////////////////////////////////////////////////////////////// -/// -/// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -/// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -/// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -/// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -/// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -/// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -/// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -/// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -/// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -/// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -/// POSSIBILITY OF SUCH DAMAGE. -/// @endcond -//////////////////////////////////////////////////////////////////////////////// - -#include <APE_APE.h> -#include <Network.h> - -void Network_InitTxRx(void) -{ - // REG_APE_PERFECT_MATCH1_{HIGH,LOW}. For non-broadcast/multicast traffic, the hardware uses this register to match MACs and pass traffic to the APE. - // The first two bytes of a MAC are put in the HIGH register, and the remaining four bytes in the LOW. - // Note that this is a device (PCI) register, not an APE register. Set it to the BMC MAC. - - // REG_APE__BMC_NC_RX_SRC_MAC_MATCHN_{HIGH,LOW}. - // This appears to relate to the RMU, not network RX, but its exact purpose is unknown. - // Set it to the BMC MAC. Unlike the "perfect match" register above, it takes a different format: - // for an example MAC AABB.CCDD.EEFF, set HIGH=0xAABBCCDD, LOW=0xEEFF0000. - // *** NOTE: set to 0 in rmu.c *** - - // Ensure REG_EMAC_MODE__ENABLE_APE_{TX,RX}_PATH are set. - // *** NOTE: Both bits are set in rmu.c ***/ - - // Enable APE channel 0, 1, 2, 3 - RegAPEMode_t mode; - mode = APE.Mode; - mode.bits.Event1 = 1; - mode.bits.Channel0Enable = 1; - mode.bits.Channel1Enable = 1; - mode.bits.Channel2Enable = 1; - mode.bits.Channel3Enable = 1; - APE.Mode = mode; -} diff --git a/libs/Network/ports.c b/libs/Network/ports.c index e9244db..2308308 100644 --- a/libs/Network/ports.c +++ b/libs/Network/ports.c @@ -82,6 +82,12 @@ NetworkPort_t gPort0 = { .rx_offset = &APE.RxbufoffsetFunc0, .rx_retire = &APE.RxPoolRetire0, .rx_mode = &APE.RxPoolModeStatus0, + +#ifndef CXX_SIMULATOR + .APEModeEnable = { + .r32 = APE_MODE_CHANNEL_0_ENABLE_MASK | APE_MODE_CHANNEL_2_ENABLE_MASK, + } +#endif }; NetworkPort_t gPort1 = { @@ -98,6 +104,12 @@ NetworkPort_t gPort1 = { .rx_offset = &APE.RxbufoffsetFunc1, .rx_retire = &APE.RxPoolRetire1, .rx_mode = &APE.RxPoolModeStatus1, + +#ifndef CXX_SIMULATOR + .APEModeEnable = { + .r32 = APE_MODE_CHANNEL_1_ENABLE_MASK | APE_MODE_CHANNEL_3_ENABLE_MASK, + } +#endif }; NetworkPort_t gPort2 = { @@ -114,6 +126,12 @@ NetworkPort_t gPort2 = { .rx_offset = &APE.RxbufoffsetFunc2, .rx_retire = &APE.RxPoolRetire2, .rx_mode = &APE.RxPoolModeStatus2, + +#ifndef CXX_SIMULATOR + .APEModeEnable = { + .r32 = APE_MODE_CHANNEL_0_ENABLE_MASK | APE_MODE_CHANNEL_2_ENABLE_MASK, + } +#endif }; NetworkPort_t gPort3 = { @@ -130,6 +148,12 @@ NetworkPort_t gPort3 = { .rx_offset = &APE.RxbufoffsetFunc3, .rx_retire = &APE.RxPoolRetire3, .rx_mode = &APE.RxPoolModeStatus3, + +#ifndef CXX_SIMULATOR + .APEModeEnable = { + .r32 = APE_MODE_CHANNEL_1_ENABLE_MASK | APE_MODE_CHANNEL_3_ENABLE_MASK, + } +#endif }; #ifndef CXX_SIMULATOR @@ -788,6 +812,8 @@ void Network_InitPort(NetworkPort_t *port) Network_resetTX(port); Network_resetRX(port); + APE.Mode.r32 |= port->APEModeEnable.r32; + // Ensure REG_RECEIVE_MAC_MODE has ENABLE set. // I recommend also setting APE_PROMISCUOUS_MODE and PROMISCUOUS_MODE, // as these will cause you less headaches during development. |