Skip to content

Commit 9f57973

Browse files
ahduyckNipaLocal
authored andcommitted
fbnic: Do not consider mailbox "initialized" until we have verified fw version
In order for us to make use of the information in the PHY we need to verify that the FW capabilities message has been processed. To do so we should poll until the FW version in the capabilities message is at least at the minimum level needed to verify that the FW can support the basic PHY config messages. As such this change adds logic so that we will poll the mailbox until such time as the FW version can be populated with an acceptable value. If it doesn't reach a sufficicient value the mailbox will be considered to have timed out. Signed-off-by: Alexander Duyck <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 98143b5 commit 9f57973

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

drivers/net/ethernet/meta/fbnic/fbnic_fw.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ void fbnic_mbx_init(struct fbnic_dev *fbd)
9595
/* Initialize lock to protect Tx ring */
9696
spin_lock_init(&fbd->fw_tx_lock);
9797

98+
/* Reset FW Capabilities */
99+
memset(&fbd->fw_cap, 0, sizeof(fbd->fw_cap));
100+
98101
/* Reinitialize mailbox memory */
99102
for (i = 0; i < FBNIC_IPC_MBX_INDICES; i++)
100103
memset(&fbd->mbx[i], 0, sizeof(struct fbnic_fw_mbx));
@@ -1117,6 +1120,7 @@ void fbnic_mbx_poll(struct fbnic_dev *fbd)
11171120

11181121
int fbnic_mbx_poll_tx_ready(struct fbnic_dev *fbd)
11191122
{
1123+
struct fbnic_fw_mbx *tx_mbx = &fbd->mbx[FBNIC_IPC_MBX_TX_IDX];
11201124
unsigned long timeout = jiffies + 10 * HZ + 1;
11211125
int err, i;
11221126

@@ -1149,8 +1153,23 @@ int fbnic_mbx_poll_tx_ready(struct fbnic_dev *fbd)
11491153
if (err)
11501154
goto clean_mbx;
11511155

1152-
/* Use "1" to indicate we entered the state waiting for a response */
1153-
fbd->fw_cap.running.mgmt.version = 1;
1156+
/* Poll until we get a current management firmware version, use "1"
1157+
* to indicate we entered the polling state waiting for a response
1158+
*/
1159+
for (fbd->fw_cap.running.mgmt.version = 1;
1160+
fbd->fw_cap.running.mgmt.version < MIN_FW_VERSION_CODE;) {
1161+
if (!tx_mbx->ready)
1162+
err = -ENODEV;
1163+
if (err)
1164+
goto clean_mbx;
1165+
1166+
msleep(20);
1167+
fbnic_mbx_poll(fbd);
1168+
1169+
/* set err, but wait till mgmt.version check to report it */
1170+
if (!time_is_after_jiffies(timeout))
1171+
err = -ETIMEDOUT;
1172+
}
11541173

11551174
return 0;
11561175
clean_mbx:

0 commit comments

Comments
 (0)