sfc: commonise efx_fini_dmaq
authorEdward Cree <ecree@solarflare.com>
Thu, 2 Jul 2020 16:30:56 +0000 (17:30 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 2 Jul 2020 21:47:40 +0000 (14:47 -0700)
Signed-off-by: Edward Cree <ecree@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/sfc/ef10.c
drivers/net/ethernet/sfc/mcdi_functions.c
drivers/net/ethernet/sfc/mcdi_functions.h

index 311a2d2a906dd96b49e5242c1698d9e233187344..d2101d2a55bef6cf94bd4d2235234cc782c220ea 100644 (file)
@@ -3117,44 +3117,6 @@ fail:
        netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", __func__, rc);
 }
 
-static int efx_ef10_fini_dmaq(struct efx_nic *efx)
-{
-       struct efx_tx_queue *tx_queue;
-       struct efx_rx_queue *rx_queue;
-       struct efx_channel *channel;
-       int pending;
-
-       /* If the MC has just rebooted, the TX/RX queues will have already been
-        * torn down, but efx->active_queues needs to be set to zero.
-        */
-       if (efx->must_realloc_vis) {
-               atomic_set(&efx->active_queues, 0);
-               return 0;
-       }
-
-       /* Do not attempt to write to the NIC during EEH recovery */
-       if (efx->state != STATE_RECOVERY) {
-               efx_for_each_channel(channel, efx) {
-                       efx_for_each_channel_rx_queue(rx_queue, channel)
-                               efx_mcdi_rx_fini(rx_queue);
-                       efx_for_each_channel_tx_queue(tx_queue, channel)
-                               efx_mcdi_tx_fini(tx_queue);
-               }
-
-               wait_event_timeout(efx->flush_wq,
-                                  atomic_read(&efx->active_queues) == 0,
-                                  msecs_to_jiffies(EFX_MAX_FLUSH_TIME));
-               pending = atomic_read(&efx->active_queues);
-               if (pending) {
-                       netif_err(efx, hw, efx->net_dev, "failed to flush %d queues\n",
-                                 pending);
-                       return -ETIMEDOUT;
-               }
-       }
-
-       return 0;
-}
-
 static void efx_ef10_prepare_flr(struct efx_nic *efx)
 {
        atomic_set(&efx->active_queues, 0);
@@ -4026,7 +3988,7 @@ const struct efx_nic_type efx_hunt_a0_vf_nic_type = {
        .reset = efx_ef10_reset,
        .probe_port = efx_mcdi_port_probe,
        .remove_port = efx_mcdi_port_remove,
-       .fini_dmaq = efx_ef10_fini_dmaq,
+       .fini_dmaq = efx_fini_dmaq,
        .prepare_flr = efx_ef10_prepare_flr,
        .finish_flr = efx_port_dummy_op_void,
        .describe_stats = efx_ef10_describe_stats,
@@ -4134,7 +4096,7 @@ const struct efx_nic_type efx_hunt_a0_nic_type = {
        .reset = efx_ef10_reset,
        .probe_port = efx_mcdi_port_probe,
        .remove_port = efx_mcdi_port_remove,
-       .fini_dmaq = efx_ef10_fini_dmaq,
+       .fini_dmaq = efx_fini_dmaq,
        .prepare_flr = efx_ef10_prepare_flr,
        .finish_flr = efx_port_dummy_op_void,
        .describe_stats = efx_ef10_describe_stats,
index b3a8aa88db062397a9cf63b137476f021e3cfd2d..92b9a741c286f03f92b9836c95aa3751b0b9b892 100644 (file)
@@ -341,6 +341,44 @@ fail:
                               outbuf, outlen, rc);
 }
 
+int efx_fini_dmaq(struct efx_nic *efx)
+{
+       struct efx_tx_queue *tx_queue;
+       struct efx_rx_queue *rx_queue;
+       struct efx_channel *channel;
+       int pending;
+
+       /* If the MC has just rebooted, the TX/RX queues will have already been
+        * torn down, but efx->active_queues needs to be set to zero.
+        */
+       if (efx->must_realloc_vis) {
+               atomic_set(&efx->active_queues, 0);
+               return 0;
+       }
+
+       /* Do not attempt to write to the NIC during EEH recovery */
+       if (efx->state != STATE_RECOVERY) {
+               efx_for_each_channel(channel, efx) {
+                       efx_for_each_channel_rx_queue(rx_queue, channel)
+                               efx_mcdi_rx_fini(rx_queue);
+                       efx_for_each_channel_tx_queue(tx_queue, channel)
+                               efx_mcdi_tx_fini(tx_queue);
+               }
+
+               wait_event_timeout(efx->flush_wq,
+                                  atomic_read(&efx->active_queues) == 0,
+                                  msecs_to_jiffies(EFX_MAX_FLUSH_TIME));
+               pending = atomic_read(&efx->active_queues);
+               if (pending) {
+                       netif_err(efx, hw, efx->net_dev, "failed to flush %d queues\n",
+                                 pending);
+                       return -ETIMEDOUT;
+               }
+       }
+
+       return 0;
+}
+
 int efx_mcdi_window_mode_to_stride(struct efx_nic *efx, u8 vi_window_mode)
 {
        switch (vi_window_mode) {
index ca4a5ac1a66bb79a2382ce3769024356fe9975b2..687be8b00cd8b17a28b9879cef9fafff83f7d126 100644 (file)
@@ -26,6 +26,7 @@ int efx_mcdi_rx_probe(struct efx_rx_queue *rx_queue);
 void efx_mcdi_rx_init(struct efx_rx_queue *rx_queue);
 void efx_mcdi_rx_remove(struct efx_rx_queue *rx_queue);
 void efx_mcdi_rx_fini(struct efx_rx_queue *rx_queue);
+int efx_fini_dmaq(struct efx_nic *efx);
 int efx_mcdi_window_mode_to_stride(struct efx_nic *efx, u8 vi_window_mode);
 int efx_get_pf_index(struct efx_nic *efx, unsigned int *pf_index);