From 04879352c4f5fbb4f1aeaf9b644c2b8408847894 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 16 Aug 2022 17:59:37 +0100 Subject: [PATCH] [intelxl] Allow for admin commands that trigger a VF reset The RESET_VF admin queue command does not complete via the usual mechanism, but instead requires us to poll registers to wait for the reset to take effect and then reopen the admin queue. Allow for the existence of other admin queue commands that also trigger a VF reset, by separating out the logic that waits for the reset to complete. Signed-off-by: Michael Brown --- src/drivers/net/intelxlvf.c | 47 ++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/src/drivers/net/intelxlvf.c b/src/drivers/net/intelxlvf.c index 79245b46f..e30d8c6db 100644 --- a/src/drivers/net/intelxlvf.c +++ b/src/drivers/net/intelxlvf.c @@ -102,6 +102,32 @@ static int intelxlvf_reset_wait_active ( struct intelxl_nic *intelxl ) { return -ETIMEDOUT; } +/** + * Wait for reset to complete + * + * @v intelxl Intel device + * @ret rc Return status code + */ +static int intelxlvf_reset_wait ( struct intelxl_nic *intelxl ) { + int rc; + + /* Wait for minimum reset time */ + mdelay ( INTELXLVF_RESET_DELAY_MS ); + + /* Wait for reset to take effect */ + if ( ( rc = intelxlvf_reset_wait_teardown ( intelxl ) ) != 0 ) + goto err_teardown; + + /* Wait for virtual function to become active */ + if ( ( rc = intelxlvf_reset_wait_active ( intelxl ) ) != 0 ) + goto err_active; + + err_active: + err_teardown: + intelxl_reopen_admin ( intelxl ); + return rc; +} + /** * Reset hardware via admin queue * @@ -119,24 +145,13 @@ static int intelxlvf_reset_admin ( struct intelxl_nic *intelxl ) { /* Issue command */ if ( ( rc = intelxl_admin_command ( intelxl ) ) != 0 ) - goto err_command; + return rc; - /* Wait for minimum reset time */ - mdelay ( INTELXLVF_RESET_DELAY_MS ); + /* Wait for reset to complete */ + if ( ( rc = intelxlvf_reset_wait ( intelxl ) ) != 0 ) + return rc; - /* Wait for reset to take effect */ - if ( ( rc = intelxlvf_reset_wait_teardown ( intelxl ) ) != 0 ) - goto err_teardown; - - /* Wait for virtual function to become active */ - if ( ( rc = intelxlvf_reset_wait_active ( intelxl ) ) != 0 ) - goto err_active; - - err_active: - err_teardown: - intelxl_reopen_admin ( intelxl ); - err_command: - return rc; + return 0; } /******************************************************************************