summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/NCSI/ncsi.c33
-rw-r--r--libs/Network/CMakeLists.txt4
-rw-r--r--libs/Network/ports.c34
3 files changed, 43 insertions, 28 deletions
diff --git a/libs/NCSI/ncsi.c b/libs/NCSI/ncsi.c
index f29a13d..3e27755 100644
--- a/libs/NCSI/ncsi.c
+++ b/libs/NCSI/ncsi.c
@@ -373,7 +373,7 @@ static void AENEnableHandler(NetworkFrame_t *frame)
debug("AEN Enable: AENControl %x\n", AENControl);
gPackageState.port[ch]->shm_channel->NcsiChannelMcid.r32 = frame->AENEnable.AEN_MC_ID;
- gPackageState.port[ch]->shm_channel->NcsiChannelMcid.r32 = AENControl;
+ gPackageState.port[ch]->shm_channel->NcsiChannelAen.r32 = AENControl;
sendNCSIResponse(frame->controlPacket.InstanceID, frame->controlPacket.ChannelID, frame->controlPacket.ControlPacketType,
NCSI_RESPONSE_CODE_COMMAND_COMPLETE, NCSI_REASON_CODE_NONE);
@@ -397,10 +397,7 @@ static void setLinkHandler(NetworkFrame_t *frame)
static void getLinkStatusHandler(NetworkFrame_t *frame)
{
- // If not
- RegMIIStatus_t stat;
- RegMIIIeeeExtendedStatus_t ext_stat;
- ext_stat.r16 = 0;
+ RegMIIAuxiliaryStatusSummary_t stat;
int ch = frame->controlPacket.ChannelID & CHANNEL_ID_MASK;
NetworkPort_t *port = gPackageState.port[ch];
@@ -412,32 +409,16 @@ static void getLinkStatusHandler(NetworkFrame_t *frame)
debug("Link Status [%d], TX %d, RX %d\n", frame->controlPacket.ChannelID, tx, rx);
APE_aquireLock();
- uint16_t status_value = MII_readRegister(port->device, phy, (mii_reg_t)REG_MII_STATUS);
- stat.r16 = status_value;
- if (stat.bits.ExtendedStatusSupported)
- {
- uint16_t ext_status_value = MII_readRegister(port->device, phy, (mii_reg_t)REG_MII_IEEE_EXTENDED_STATUS);
- ext_stat.r16 = ext_status_value;
- }
-
+ stat.r16 = MII_readRegister(port->device, phy, (mii_reg_t)REG_MII_AUXILIARY_STATUS_SUMMARY);
APE_releaseLock();
- RegSHM_CHANNELNcsiChannelStatus_t linkStatus;
- linkStatus.r32 = 0;
- linkStatus.bits.Linkup = stat.bits.LinkOK;
- linkStatus.bits.LinkStatus = SHM_CHANNEL_NCSI_CHANNEL_STATUS_LINK_STATUS_1000BASE_T_FULL_DUPLEX; // FIXME
+ RegSHM_CHANNELNcsiChannelStatus_t linkStatus = port->shm_channel->NcsiChannelStatus;
+
+ linkStatus.bits.Linkup = stat.bits.LinkStatus;
+ linkStatus.bits.LinkStatus = stat.bits.AutoNegotiationHCD;
linkStatus.bits.AutonegotiationEnabled = 1;
linkStatus.bits.AutonegotiationComplete = stat.bits.AutoNegotiationComplete;
- linkStatus.bits.LinkSpeed1000MFullDuplexCapable = ext_stat.bits._1000BASE_TFullDuplexCapable;
- linkStatus.bits.LinkSpeed1000MHalfDuplexCapable = ext_stat.bits._1000BASE_THalfDuplexCapable;
-
- linkStatus.bits.LinkSpeed100M_TXFullDuplexCapable = stat.bits._100BASE_XFullDuplexCapable;
- linkStatus.bits.LinkSpeed100M_TXHalfDuplexCapable = stat.bits._100BASE_XHalfDuplexCapable;
-
- linkStatus.bits.LinkSpeed10M_TFullDuplexCapable = stat.bits._10BASE_TFullDuplexCapable;
- linkStatus.bits.LinkSpeed10M_THalfDuplexCapable = stat.bits._10BASE_THalfDuplexCapable;
-
port->shm_channel->NcsiChannelStatus = linkStatus;
uint32_t LinkStatus = linkStatus.r32;
diff --git a/libs/Network/CMakeLists.txt b/libs/Network/CMakeLists.txt
index 67650c2..b2b349b 100644
--- a/libs/Network/CMakeLists.txt
+++ b/libs/Network/CMakeLists.txt
@@ -55,13 +55,13 @@ SET(SOURCES
# Host Simulation library
simulator_add_library(${PROJECT_NAME} STATIC ${SOURCES})
-target_link_libraries(${PROJECT_NAME} PRIVATE simulator NCSI MII)
+target_link_libraries(${PROJECT_NAME} PRIVATE simulator NCSI MII APE)
target_include_directories(${PROJECT_NAME} PUBLIC ../../include)
target_include_directories(${PROJECT_NAME} PUBLIC include)
# ARM Library
arm_add_library(${PROJECT_NAME}-arm STATIC ${SOURCES})
-target_link_libraries(${PROJECT_NAME}-arm PRIVATE NCSI-arm printf-arm MII-arm)
+target_link_libraries(${PROJECT_NAME}-arm PRIVATE NCSI-arm printf-arm MII-arm APE-arm)
target_include_directories(${PROJECT_NAME}-arm PUBLIC ../../include)
target_include_directories(${PROJECT_NAME}-arm PUBLIC include)
diff --git a/libs/Network/ports.c b/libs/Network/ports.c
index fad9d30..e9244db 100644
--- a/libs/Network/ports.c
+++ b/libs/Network/ports.c
@@ -42,6 +42,7 @@
/// @endcond
////////////////////////////////////////////////////////////////////////////////
+#include <APE.h>
#include <APE_DEVICE1.h>
#include <APE_DEVICE2.h>
#include <APE_DEVICE3.h>
@@ -777,6 +778,11 @@ void Network_resetRX(NetworkPort_t *port)
void Network_InitPort(NetworkPort_t *port)
{
+ RegMIIStatus_t stat;
+ RegMIIIeeeExtendedStatus_t ext_stat;
+ RegSHM_CHANNELNcsiChannelStatus_t linkStatus;
+ uint8_t phy;
+
Network_InitFilters(port);
Network_resetTX(port);
@@ -852,7 +858,35 @@ void Network_InitPort(NetworkPort_t *port)
port->device->GrcModeControl.bits.HostStackUp = 1; // Enable packet RX
+ phy = MII_getPhy(port->device);
+
+ APE_aquireLock();
+
Network_updatePortState(port);
+
+ uint16_t status_value = MII_readRegister(port->device, phy, (mii_reg_t)REG_MII_STATUS);
+ stat.r16 = status_value;
+ if (stat.bits.ExtendedStatusSupported)
+ {
+ uint16_t ext_status_value = MII_readRegister(port->device, phy, (mii_reg_t)REG_MII_IEEE_EXTENDED_STATUS);
+ ext_stat.r16 = ext_status_value;
+ }
+
+ APE_releaseLock();
+
+ // Set link status capabilities.
+ linkStatus.r32 = 0;
+
+ linkStatus.bits.LinkSpeed1000MFullDuplexCapable = ext_stat.bits._1000BASE_TFullDuplexCapable;
+ linkStatus.bits.LinkSpeed1000MHalfDuplexCapable = ext_stat.bits._1000BASE_THalfDuplexCapable;
+
+ linkStatus.bits.LinkSpeed100M_TXFullDuplexCapable = stat.bits._100BASE_XFullDuplexCapable;
+ linkStatus.bits.LinkSpeed100M_TXHalfDuplexCapable = stat.bits._100BASE_XHalfDuplexCapable;
+
+ linkStatus.bits.LinkSpeed10M_TFullDuplexCapable = stat.bits._10BASE_TFullDuplexCapable;
+ linkStatus.bits.LinkSpeed10M_THalfDuplexCapable = stat.bits._10BASE_THalfDuplexCapable;
+
+ port->shm_channel->NcsiChannelStatus = linkStatus;
}
void Network_checkPortState(NetworkPort_t *port)
OpenPOWER on IntegriCloud