ionic: pull out common bits from fw_up
authorShannon Nelson <shannon.nelson@amd.com>
Thu, 20 Jul 2023 19:08:15 +0000 (12:08 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 24 Jul 2023 09:42:34 +0000 (10:42 +0100)
Pull out some code from ionic_lif_handle_fw_up() that can be
used in the coming FLR recovery patch.

Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/pensando/ionic/ionic_lif.c

index 612b001..2d03c1b 100644 (file)
@@ -3266,27 +3266,11 @@ static void ionic_lif_handle_fw_down(struct ionic_lif *lif)
        dev_info(ionic->dev, "FW Down: LIFs stopped\n");
 }
 
-static void ionic_lif_handle_fw_up(struct ionic_lif *lif)
+static int ionic_restart_lif(struct ionic_lif *lif)
 {
        struct ionic *ionic = lif->ionic;
        int err;
 
-       if (!test_bit(IONIC_LIF_F_FW_RESET, lif->state))
-               return;
-
-       dev_info(ionic->dev, "FW Up: restarting LIFs\n");
-
-       ionic_init_devinfo(ionic);
-       err = ionic_identify(ionic);
-       if (err)
-               goto err_out;
-       err = ionic_port_identify(ionic);
-       if (err)
-               goto err_out;
-       err = ionic_port_init(ionic);
-       if (err)
-               goto err_out;
-
        mutex_lock(&lif->queue_lock);
 
        if (test_and_clear_bit(IONIC_LIF_F_BROKEN, lif->state))
@@ -3322,12 +3306,8 @@ static void ionic_lif_handle_fw_up(struct ionic_lif *lif)
        clear_bit(IONIC_LIF_F_FW_RESET, lif->state);
        ionic_link_status_check_request(lif, CAN_SLEEP);
        netif_device_attach(lif->netdev);
-       dev_info(ionic->dev, "FW Up: LIFs restarted\n");
-
-       /* restore the hardware timestamping queues */
-       ionic_lif_hwstamp_replay(lif);
 
-       return;
+       return 0;
 
 err_txrx_free:
        ionic_txrx_free(lif);
@@ -3337,6 +3317,46 @@ err_qcqs_free:
        ionic_qcqs_free(lif);
 err_unlock:
        mutex_unlock(&lif->queue_lock);
+
+       return err;
+}
+
+static void ionic_lif_handle_fw_up(struct ionic_lif *lif)
+{
+       struct ionic *ionic = lif->ionic;
+       int err;
+
+       if (!test_bit(IONIC_LIF_F_FW_RESET, lif->state))
+               return;
+
+       dev_info(ionic->dev, "FW Up: restarting LIFs\n");
+
+       /* This is a little different from what happens at
+        * probe time because the LIF already exists so we
+        * just need to reanimate it.
+        */
+       ionic_init_devinfo(ionic);
+       err = ionic_identify(ionic);
+       if (err)
+               goto err_out;
+       err = ionic_port_identify(ionic);
+       if (err)
+               goto err_out;
+       err = ionic_port_init(ionic);
+       if (err)
+               goto err_out;
+
+       err = ionic_restart_lif(lif);
+       if (err)
+               goto err_out;
+
+       dev_info(ionic->dev, "FW Up: LIFs restarted\n");
+
+       /* restore the hardware timestamping queues */
+       ionic_lif_hwstamp_replay(lif);
+
+       return;
+
 err_out:
        dev_err(ionic->dev, "FW Up: LIFs restart failed - err %d\n", err);
 }