summaryrefslogtreecommitdiffstats
path: root/libs/NCSI
diff options
context:
space:
mode:
authorEvan Lojewski <github@meklort.com>2019-06-18 20:13:15 -0600
committerEvan Lojewski <github@meklort.com>2019-06-18 20:13:15 -0600
commita4debd18e245c3bf7323dca454ce0b5b65cc89f8 (patch)
treec2307cd687f564c5d4283b851ddd633c7daee2fe /libs/NCSI
parent2d4d71129d367997cdd9b588ef4131cc5093e508 (diff)
downloadbcm5719-ortega-a4debd18e245c3bf7323dca454ce0b5b65cc89f8.tar.gz
bcm5719-ortega-a4debd18e245c3bf7323dca454ce0b5b65cc89f8.zip
Add support for printing command responses in test code and begin adding additional commands.
Diffstat (limited to 'libs/NCSI')
-rw-r--r--libs/NCSI/tests/tests.cpp159
-rw-r--r--libs/NCSI/tests/valid_commands.c24
2 files changed, 175 insertions, 8 deletions
diff --git a/libs/NCSI/tests/tests.cpp b/libs/NCSI/tests/tests.cpp
index efcc35a..7aa2a6f 100644
--- a/libs/NCSI/tests/tests.cpp
+++ b/libs/NCSI/tests/tests.cpp
@@ -27,6 +27,8 @@ extern uint8_t get_link_status_ch3[];
extern uint8_t disable_network_tx[];
extern uint8_t disable_channel[];
extern uint8_t deselect_package[];
+extern uint8_t get_capabilities[];
+extern uint8_t get_version_id[];
extern uint32_t select_package1_len;
extern uint32_t clear_initial_state_len;
@@ -44,6 +46,8 @@ extern uint32_t get_link_status_ch3_len;
extern uint32_t disable_network_tx_len;
extern uint32_t disable_channel_len;
extern uint32_t deselect_package_len;
+extern uint32_t get_capabilities_len;
+extern uint32_t get_version_id_len;
static uint32_t read_packet(uint32_t val, uint32_t offset, void *args)
{
@@ -66,7 +70,7 @@ static uint32_t read_packet(uint32_t val, uint32_t offset, void *args)
static uint32_t write_packet(uint32_t val, uint32_t offset, void *args)
{
- val = le32toh(val);
+ val = htobe32(le32toh(val));
// printf("Writing packet %x\n", val);
gTXPacket[gTXPacketPos++] = le32toh(val); // Value from APE fw is in LE
return val;
@@ -91,6 +95,110 @@ static uint32_t read_tx_status(uint32_t val, uint32_t offset, void *args)
return stat.r32;
}
+void print_version(uint8_t* packet)
+{
+ printf("========== Version ================\n");
+ printf("NCSI Version: %d.%d.%d %c%c\n", packet[20], packet[21], packet[22], packet[23], packet[27]);
+
+ printf("Firmware Name: %.12s\n", (char*)&packet[28]);
+
+ printf("Firmware Version: %02X.%02X.%02X.%02X\n", packet[40], packet[41], packet[42], packet[43]);
+ printf("PCI Vendor: 0x%04X\n", packet[44] << 8 | packet[45]);
+ printf("PCI Device: 0x%04X\n", packet[46] << 8 | packet[47]);
+ printf("PCI Subsystem Vendor: 0x%04X\n", packet[48] << 8 | packet[49]);
+ printf("PCI Subsystem Device: 0x%04X\n", packet[50] << 8 | packet[51]);
+ printf("Manufacturer ID: 0x%08X\n", packet[52] << 24 | packet[53] << 16 | packet[54] << 8 | packet[55]);
+ printf("Checksum: 0x%08X\n", packet[56] << 24 | packet[57] << 16 | packet[58] << 8 | packet[59]);
+}
+
+void print_capabilities(uint8_t* packet)
+{
+ printf("========== Capabilities ================\n");
+ printf("Capabilities: 0x%08X\n", packet[20] << 24 | packet[21] << 16 | packet[22] << 8 | packet[23]);
+ printf("Broadcast Capabilities: 0x%08X\n", packet[24] << 24 | packet[25] << 16 | packet[26] << 8 | packet[27]);
+ printf("Multicast Capabilities: 0x%08X\n", packet[28] << 24 | packet[29] << 16 | packet[30] << 8 | packet[31]);
+ printf("Buffering Capabilities: 0x%08X\n", packet[32] << 24 | packet[33] << 16 | packet[34] << 8 | packet[35]);
+ printf("AEN Control Support: 0x%08X\n", packet[36] << 24 | packet[37] << 16 | packet[38] << 8 | packet[39]);
+ printf("VLAN Filter Count: %d\n", packet[40]);
+ printf("Mixed Filter Count: %d\n", packet[41]);
+ printf("Multicast Filter Count: %d\n", packet[42]);
+ printf("Unicast Filter Count: %d\n", packet[43]);
+ printf("Reserved[44-45]: 0x%02X 0x%02X\n", packet[44], packet[45]);
+ printf("VLAN Mode Support: %d\n", packet[46]);
+ printf("Channel Count: %d\n", packet[47]);
+ printf("Checksum: 0x%08X\n", packet[48] << 24 | packet[49] << 16 | packet[50] << 8 | packet[51]);
+}
+
+void print_packet(uint32_t *packet_u32, size_t len)
+{
+ // Correct endian
+ for(int i = 0; i < len; i++)
+ {
+ printf("0x%08X\n", packet_u32[i]);
+ }
+ uint8_t* packet = (uint8_t*)packet_u32;
+
+ /** Ethernet Header **/
+ printf("========= Ethernet Header ==============\n");
+ printf("DA MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
+ packet[0], packet[1], packet[2],packet[3], packet[4], packet[5]);
+ printf("SA MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
+ packet[6], packet[7], packet[8],packet[9], packet[10], packet[11]);
+
+ printf("Ethertype: 0x%04X\n", packet[12] << 8 | packet[13]);
+ packet += 14;
+ /* NCSI Header */
+ printf("=========== NCSI Header ================\n");
+ printf("MC ID: 0x%02X\n", packet[0]);
+ printf("Header Revision: 0x%02X\n", packet[1]);
+ printf("Reserved[2]: 0x%02X\n", packet[2]);
+ printf("IID: 0x%02X\n", packet[3]);
+ printf("Command Type: 0x%02X\n", packet[4]);
+ std::string type = "";
+ if(packet[5] == 0x1f)
+ {
+ type = "(Package)";
+ }
+ printf("Channel: 0x%02X %s\n", packet[5], type.c_str());
+ printf("Reserved[6]: 0x%02X\n", packet[6]);
+ printf("Payload Length: 0x%02X\n", packet[7]);
+ printf("Total Length: 0x%02lX\n", len * 4);
+ printf("Reserved[8-15]: 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n",
+ packet[8], packet[9], packet[10], packet[11], packet[12], packet[13], packet[14], packet[15]);
+
+ uint8_t command = packet[4];
+ uint8_t payload_len = packet[7];
+ printf("=========== NCSI Command ===============\n");
+ if(command & 0x80)
+ {
+ printf("Response Code: 0x%04X\n", packet[16] << 8 | packet[17]);
+ printf("Reason Code: 0x%04X\n", packet[18] << 8 | packet[19]);
+ printf("Checksum: 0x%08X\n", packet[16 + payload_len] << 24 |
+ packet[17 + payload_len] << 16 |
+ packet[18 + payload_len] << 8 |
+ packet[19 + payload_len]);
+ }
+
+ if(payload_len <= 4)
+ {
+ // No more data.
+ return;
+ }
+
+ switch (command)
+ {
+ case 0x96:
+ print_capabilities(packet);
+ break;
+
+ case 0x95:
+ print_version(packet);
+ break;
+ }
+
+
+}
+
void send_packet(uint8_t *packet, uint32_t len)
{
gTXPacketPos = 0; // reset response position.
@@ -128,14 +236,14 @@ void send_packet(uint8_t *packet, uint32_t len)
else if (!stat.bits.Passthru)
{
handleNCSIFrame(frame);
-
EXPECT_EQ(gTXPacket[0], 0xffffffff); // Source MAC
EXPECT_EQ(gTXPacket[1], 0xffffffff); // Source/Dest MAC
EXPECT_EQ(gTXPacket[2], 0xffffffff); // Dest MAC
- EXPECT_EQ(gTXPacket[3], 0x88f80001); // NCSI Type, Revision 1.
- EXPECT_EQ(gTXPacket[4],
- buffer[4] |
- 0x8000); // IID, Channel, Package, Command | 0x80
+ EXPECT_EQ(be32toh(gTXPacket[3]), 0x88f80001); // NCSI Type, Revision 1.
+ EXPECT_EQ(be32toh(gTXPacket[4]),
+ buffer[4] |0x8000); // IID, Channel, Package, Command | 0x80
+
+ print_packet((uint32_t*)gTXPacket, gTXPacketPos);
}
else
{
@@ -147,6 +255,8 @@ void send_packet(uint8_t *packet, uint32_t len)
namespace
{
+
+
TEST(Packet, SelectPackage)
{
APE_PERI.BmcToNcRxStatus.r32.installReadCallback(read_rx_status, NULL);
@@ -156,7 +266,42 @@ TEST(Packet, SelectPackage)
APE_PERI.BmcToNcTxBuffer.r32.installWriteCallback(write_packet, NULL);
APE_PERI.BmcToNcTxBufferLast.r32.installWriteCallback(write_packet, NULL);
- send_packet(select_package1, select_package1_len);
+ send_packet(deselect_package, deselect_package_len);
+ // send_packet(select_package1, select_package1_len);
+ // send_packet(clear_initial_state, clear_initial_state_len);
+ // send_packet(get_version_id, get_version_id_len);
+ // send_packet(get_capabilities, get_capabilities_len);
}
+// TEST(Packet, GetCapabilities)
+// {
+// // APE_PERI.BmcToNcRxStatus.r32.installReadCallback(read_rx_status, NULL);
+// // APE_PERI.BmcToNcReadBuffer.r32.installReadCallback(read_packet, NULL);
+// // APE_PERI.BmcToNcTxStatus.r32.installReadCallback(read_tx_status, NULL);
+
+// // APE_PERI.BmcToNcTxBuffer.r32.installWriteCallback(write_packet, NULL);
+// // APE_PERI.BmcToNcTxBufferLast.r32.installWriteCallback(write_packet, NULL);
+// send_packet(clear_initial_state, clear_initial_state_len);
+
+// send_packet(get_capabilities, get_capabilities_len);
+
+// uint32_t buffer[clear_initial_state_len];
+// memcpy(buffer, clear_initial_state, clear_initial_state_len);
+// print_packet(buffer, clear_initial_state_len);
+// }
+
+// TEST(Packet, GetVersionID)
+// {
+// // APE_PERI.BmcToNcRxStatus.r32.installReadCallback(read_rx_status, NULL);
+// // APE_PERI.BmcToNcReadBuffer.r32.installReadCallback(read_packet, NULL);
+// // APE_PERI.BmcToNcTxStatus.r32.installReadCallback(read_tx_status, NULL);
+
+// // APE_PERI.BmcToNcTxBuffer.r32.installWriteCallback(write_packet, NULL);
+// // APE_PERI.BmcToNcTxBufferLast.r32.installWriteCallback(write_packet, NULL);
+// send_packet(clear_initial_state, clear_initial_state_len);
+
+// send_packet(get_version_id, get_version_id_len);
+// }
+
+
} // namespace
diff --git a/libs/NCSI/tests/valid_commands.c b/libs/NCSI/tests/valid_commands.c
index 0346093..e900878 100644
--- a/libs/NCSI/tests/valid_commands.c
+++ b/libs/NCSI/tests/valid_commands.c
@@ -1,6 +1,6 @@
#include <types.h>
-// Select Packate
+// Select Package
uint8_t select_package1[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x88, 0xf8, 0x00, 0x01, 0x00, 0xed, 0x01, 0x1f, 0x00, 0x04,
@@ -175,3 +175,25 @@ uint8_t deselect_package[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
uint32_t deselect_package_len = sizeof(deselect_package);
+
+// Get Capabilities
+uint8_t get_capabilities[] = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x88, 0xf8, 0x00, 0x01, 0x00, 0xfe, 0x16, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0xff, 0xff, 0xfa, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+uint32_t get_capabilities_len = sizeof(get_capabilities);
+
+// Get Version ID
+uint8_t get_version_id[] = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x88, 0xf8, 0x00, 0x01, 0x00, 0xfe, 0x15, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0xff, 0xff, 0xfa, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+uint32_t get_version_id_len = sizeof(get_version_id);
OpenPOWER on IntegriCloud