summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorEvan Lojewski <github@meklort.com>2020-07-12 20:00:04 -0600
committerGitHub <noreply@github.com>2020-07-12 20:00:04 -0600
commit74c4f25d634429c02cb7654bbd1a7ce742a3433e (patch)
treeafef711588e25a2480b843a3573a8d0efa28ba16 /libs
parentfebfab9c23390b9c32dafb72cfb541b482b51a01 (diff)
downloadbcm5719-ortega-74c4f25d634429c02cb7654bbd1a7ce742a3433e.tar.gz
bcm5719-ortega-74c4f25d634429c02cb7654bbd1a7ce742a3433e.zip
network: Fix an issue where small packets (< 64 bytes) were incorrectly sent. (#90)
Diffstat (limited to 'libs')
-rw-r--r--libs/NCSI/include/Ethernet.h4
-rw-r--r--libs/NCSI/ncsi.c8
2 files changed, 6 insertions, 6 deletions
diff --git a/libs/NCSI/include/Ethernet.h b/libs/NCSI/include/Ethernet.h
index 0a9fccd..ce7ba34 100644
--- a/libs/NCSI/include/Ethernet.h
+++ b/libs/NCSI/include/Ethernet.h
@@ -47,7 +47,7 @@
#include <types.h>
-#define ETHERNET_FRAME_MIN 64
+#define ETHERNET_FRAME_MIN (64 - 4) /* Hardware automatically adds FCS (last 4 bytes) */
typedef struct
{
@@ -496,4 +496,4 @@ typedef union {
-#endif /* ETHERNET_H */ \ No newline at end of file
+#endif /* ETHERNET_H */
diff --git a/libs/NCSI/ncsi.c b/libs/NCSI/ncsi.c
index 55b7dbc..c54eb72 100644
--- a/libs/NCSI/ncsi.c
+++ b/libs/NCSI/ncsi.c
@@ -461,7 +461,7 @@ static void getCapabilities(NetworkFrame_t *frame)
{
int ch = frame->controlPacket.ChannelID & CHANNEL_ID_MASK;
// NetworkPort_t *port = gPackageState.port[ch];
- uint32_t packetSize = MAX(sizeof(gCapabilitiesFrame.capabilities), ETHERNET_FRAME_MIN - 4);
+ uint32_t packetSize = MAX(sizeof(gCapabilitiesFrame.capabilities), ETHERNET_FRAME_MIN);
gCapabilitiesFrame.capabilities.ChannelID = ch;
gCapabilitiesFrame.capabilities.ControlPacketType = frame->controlPacket.ControlPacketType | CONTROL_PACKET_TYPE_RESPONSE;
@@ -477,7 +477,7 @@ static void getVersionID(NetworkFrame_t *frame)
int ch = frame->controlPacket.ChannelID & CHANNEL_ID_MASK;
NetworkPort_t *port = gPackageState.port[ch];
DEVICE_t *device = (DEVICE_t *)port->device;
- uint32_t packetSize = MAX(sizeof(gVersionFrame.version), ETHERNET_FRAME_MIN - 4);
+ uint32_t packetSize = MAX(sizeof(gVersionFrame.version), ETHERNET_FRAME_MIN);
gVersionFrame.version.ChannelID = ch;
gVersionFrame.version.ControlPacketType = frame->controlPacket.ControlPacketType | CONTROL_PACKET_TYPE_RESPONSE;
@@ -746,7 +746,7 @@ void NCSI_TxPacket(uint32_t *packet, uint32_t packet_len)
}
void sendNCSILinkStatusResponse(uint8_t InstanceID, uint8_t channelID, uint32_t LinkStatus, uint32_t OEMLinkStatus, uint32_t OtherIndications)
{
- uint32_t packetSize = MAX(sizeof(gLinkStatusResponseFrame.linkStatusResponse), ETHERNET_FRAME_MIN - 4);
+ uint32_t packetSize = MAX(sizeof(gLinkStatusResponseFrame.linkStatusResponse), ETHERNET_FRAME_MIN);
gLinkStatusResponseFrame.linkStatusResponse.ChannelID = channelID;
gLinkStatusResponseFrame.linkStatusResponse.InstanceID = InstanceID;
@@ -765,7 +765,7 @@ void sendNCSILinkStatusResponse(uint8_t InstanceID, uint8_t channelID, uint32_t
void sendNCSIResponse(uint8_t InstanceID, uint8_t channelID, uint16_t controlID, uint16_t response_code, uint16_t reasons_code)
{
- uint32_t packetSize = MAX(sizeof(gResponseFrame.responsePacket), ETHERNET_FRAME_MIN - 4);
+ uint32_t packetSize = MAX(sizeof(gResponseFrame.responsePacket), ETHERNET_FRAME_MIN);
gResponseFrame.responsePacket.ChannelID = channelID;
gResponseFrame.responsePacket.ControlPacketType = controlID | CONTROL_PACKET_TYPE_RESPONSE;
OpenPOWER on IntegriCloud