summaryrefslogtreecommitdiff
path: root/lib/efi_selftest/efi_selftest_snp.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/efi_selftest/efi_selftest_snp.c')
-rw-r--r--lib/efi_selftest/efi_selftest_snp.c64
1 files changed, 56 insertions, 8 deletions
diff --git a/lib/efi_selftest/efi_selftest_snp.c b/lib/efi_selftest/efi_selftest_snp.c
index 4c26619001..9797ecaf42 100644
--- a/lib/efi_selftest/efi_selftest_snp.c
+++ b/lib/efi_selftest/efi_selftest_snp.c
@@ -228,6 +228,26 @@ static int setup(const efi_handle_t handle,
efi_st_error("WaitForPacket event missing\n");
return EFI_ST_FAILURE;
}
+ if (net->mode->state == EFI_NETWORK_INITIALIZED) {
+ /*
+ * Shut down network adapter.
+ */
+ ret = net->shutdown(net);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Failed to shut down network adapter\n");
+ return EFI_ST_FAILURE;
+ }
+ }
+ if (net->mode->state == EFI_NETWORK_STARTED) {
+ /*
+ * Stop network adapter.
+ */
+ ret = net->stop(net);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Failed to stop network adapter\n");
+ return EFI_ST_FAILURE;
+ }
+ }
/*
* Start network adapter.
*/
@@ -236,6 +256,10 @@ static int setup(const efi_handle_t handle,
efi_st_error("Failed to start network adapter\n");
return EFI_ST_FAILURE;
}
+ if (net->mode->state != EFI_NETWORK_STARTED) {
+ efi_st_error("Failed to start network adapter\n");
+ return EFI_ST_FAILURE;
+ }
/*
* Initialize network adapter.
*/
@@ -244,6 +268,10 @@ static int setup(const efi_handle_t handle,
efi_st_error("Failed to initialize network adapter\n");
return EFI_ST_FAILURE;
}
+ if (net->mode->state != EFI_NETWORK_INITIALIZED) {
+ efi_st_error("Failed to initialize network adapter\n");
+ return EFI_ST_FAILURE;
+ }
return EFI_ST_SUCCESS;
}
@@ -268,6 +296,7 @@ static int execute(void)
struct efi_mac_address destaddr;
size_t buffer_size;
u8 *addr;
+
/*
* The timeout is to occur after 10 s.
*/
@@ -298,6 +327,8 @@ static int execute(void)
events[0] = timer;
events[1] = net->wait_for_packet;
for (;;) {
+ u32 int_status;
+
/*
* Wait for packet to be received or timer event.
*/
@@ -323,8 +354,17 @@ static int execute(void)
* Receive packet
*/
buffer_size = sizeof(buffer);
- net->receive(net, NULL, &buffer_size, &buffer,
- &srcaddr, &destaddr, NULL);
+ ret = net->get_status(net, &int_status, NULL);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Failed to get status");
+ return EFI_ST_FAILURE;
+ }
+ if (!(int_status & EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT)) {
+ efi_st_error("RX interrupt not set");
+ return EFI_ST_FAILURE;
+ }
+ ret = net->receive(net, NULL, &buffer_size, &buffer,
+ &srcaddr, &destaddr, NULL);
if (ret != EFI_SUCCESS) {
efi_st_error("Failed to receive packet");
return EFI_ST_FAILURE;
@@ -400,21 +440,29 @@ static int teardown(void)
}
if (net) {
/*
- * Stop network adapter.
+ * Shut down network adapter.
*/
- ret = net->stop(net);
+ ret = net->shutdown(net);
if (ret != EFI_SUCCESS) {
- efi_st_error("Failed to stop network adapter\n");
+ efi_st_error("Failed to shut down network adapter\n");
exit_status = EFI_ST_FAILURE;
}
+ if (net->mode->state != EFI_NETWORK_STARTED) {
+ efi_st_error("Failed to shutdown network adapter\n");
+ return EFI_ST_FAILURE;
+ }
/*
- * Shut down network adapter.
+ * Stop network adapter.
*/
- ret = net->shutdown(net);
+ ret = net->stop(net);
if (ret != EFI_SUCCESS) {
- efi_st_error("Failed to shut down network adapter\n");
+ efi_st_error("Failed to stop network adapter\n");
exit_status = EFI_ST_FAILURE;
}
+ if (net->mode->state != EFI_NETWORK_STOPPED) {
+ efi_st_error("Failed to stop network adapter\n");
+ return EFI_ST_FAILURE;
+ }
}
return exit_status;