sfc: move various functions
authorAlex Maftei (amaftei) <amaftei@solarflare.com>
Fri, 10 Jan 2020 13:27:17 +0000 (13:27 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 10 Jan 2020 19:24:37 +0000 (11:24 -0800)
Signed-off-by: Alexandru-Mihai Maftei <amaftei@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/sfc/ef10.c
drivers/net/ethernet/sfc/efx.c
drivers/net/ethernet/sfc/efx_common.c
drivers/net/ethernet/sfc/efx_common.h
drivers/net/ethernet/sfc/mcdi.h
drivers/net/ethernet/sfc/mcdi_functions.c
drivers/net/ethernet/sfc/mcdi_functions.h
drivers/net/ethernet/sfc/mcdi_port.c
drivers/net/ethernet/sfc/mcdi_port_common.c
drivers/net/ethernet/sfc/mcdi_port_common.h
drivers/net/ethernet/sfc/siena.c

index dc037dd..6853b5c 100644 (file)
@@ -277,24 +277,9 @@ static int efx_ef10_init_datapath_caps(struct efx_nic *efx)
                u8 vi_window_mode = MCDI_BYTE(outbuf,
                                GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE);
 
-               switch (vi_window_mode) {
-               case MC_CMD_GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE_8K:
-                       efx->vi_stride = 8192;
-                       break;
-               case MC_CMD_GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE_16K:
-                       efx->vi_stride = 16384;
-                       break;
-               case MC_CMD_GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE_64K:
-                       efx->vi_stride = 65536;
-                       break;
-               default:
-                       netif_err(efx, probe, efx->net_dev,
-                                 "Unrecognised VI window mode %d\n",
-                                 vi_window_mode);
-                       return -EIO;
-               }
-               netif_dbg(efx, probe, efx->net_dev, "vi_stride = %u\n",
-                         efx->vi_stride);
+               rc = efx_mcdi_window_mode_to_stride(efx, vi_window_mode);
+               if (rc)
+                       return rc;
        } else {
                /* keep default VI stride */
                netif_dbg(efx, probe, efx->net_dev,
index 4affae7..7ad9709 100644 (file)
@@ -692,17 +692,6 @@ int efx_net_stop(struct net_device *net_dev)
        return 0;
 }
 
-/* Context: process, dev_base_lock or RTNL held, non-blocking. */
-static void efx_net_stats(struct net_device *net_dev,
-                         struct rtnl_link_stats64 *stats)
-{
-       struct efx_nic *efx = netdev_priv(net_dev);
-
-       spin_lock_bh(&efx->stats_lock);
-       efx->type->update_stats(efx, NULL, stats);
-       spin_unlock_bh(&efx->stats_lock);
-}
-
 /* Context: netif_tx_lock held, BHs disabled. */
 static void efx_watchdog(struct net_device *net_dev, unsigned int txqueue)
 {
index 33b523b..0875507 100644 (file)
@@ -454,6 +454,16 @@ void efx_stop_all(struct efx_nic *efx)
        efx_stop_datapath(efx);
 }
 
+/* Context: process, dev_base_lock or RTNL held, non-blocking. */
+void efx_net_stats(struct net_device *net_dev, struct rtnl_link_stats64 *stats)
+{
+       struct efx_nic *efx = netdev_priv(net_dev);
+
+       spin_lock_bh(&efx->stats_lock);
+       efx->type->update_stats(efx, NULL, stats);
+       spin_unlock_bh(&efx->stats_lock);
+}
+
 /* Push loopback/power/transmit disable settings to the PHY, and reconfigure
  * the MAC appropriately. All other PHY configuration changes are pushed
  * through phy_op->set_settings(), and pushed asynchronously to the MAC
index e03404d..32a23ec 100644 (file)
@@ -21,6 +21,8 @@ void efx_fini_struct(struct efx_nic *efx);
 void efx_start_all(struct efx_nic *efx);
 void efx_stop_all(struct efx_nic *efx);
 
+void efx_net_stats(struct net_device *net_dev, struct rtnl_link_stats64 *stats);
+
 int efx_create_reset_workqueue(void);
 void efx_queue_reset_work(struct efx_nic *efx);
 void efx_flush_reset_workqueue(struct efx_nic *efx);
index 65e454a..54a4501 100644 (file)
@@ -348,8 +348,6 @@ void efx_mcdi_port_remove(struct efx_nic *efx);
 int efx_mcdi_port_reconfigure(struct efx_nic *efx);
 u32 efx_mcdi_phy_get_caps(struct efx_nic *efx);
 void efx_mcdi_process_link_change(struct efx_nic *efx, efx_qword_t *ev);
-int efx_mcdi_set_mac(struct efx_nic *efx);
-#define EFX_MC_STATS_GENERATION_INVALID ((__force __le64)(-1))
 void efx_mcdi_mac_start_stats(struct efx_nic *efx);
 void efx_mcdi_mac_stop_stats(struct efx_nic *efx);
 void efx_mcdi_mac_pull_stats(struct efx_nic *efx);
index f022e2b..0f57186 100644 (file)
@@ -347,3 +347,26 @@ fail:
        efx_mcdi_display_error(efx, MC_CMD_FINI_RXQ, MC_CMD_FINI_RXQ_IN_LEN,
                               outbuf, outlen, rc);
 }
+
+int efx_mcdi_window_mode_to_stride(struct efx_nic *efx, u8 vi_window_mode)
+{
+       switch (vi_window_mode) {
+       case MC_CMD_GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE_8K:
+               efx->vi_stride = 8192;
+               break;
+       case MC_CMD_GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE_16K:
+               efx->vi_stride = 16384;
+               break;
+       case MC_CMD_GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE_64K:
+               efx->vi_stride = 65536;
+               break;
+       default:
+               netif_err(efx, probe, efx->net_dev,
+                         "Unrecognised VI window mode %d\n",
+                         vi_window_mode);
+               return -EIO;
+       }
+       netif_dbg(efx, probe, efx->net_dev, "vi_stride = %u\n",
+                 efx->vi_stride);
+       return 0;
+}
index 3c9e760..0396294 100644 (file)
@@ -26,5 +26,6 @@ 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_mcdi_window_mode_to_stride(struct efx_nic *efx, u8 vi_window_mode);
 
 #endif
index 0db6068..a578520 100644 (file)
@@ -708,51 +708,6 @@ void efx_mcdi_process_link_change(struct efx_nic *efx, efx_qword_t *ev)
        efx_link_status_changed(efx);
 }
 
-int efx_mcdi_set_mac(struct efx_nic *efx)
-{
-       u32 fcntl;
-       MCDI_DECLARE_BUF(cmdbytes, MC_CMD_SET_MAC_IN_LEN);
-
-       BUILD_BUG_ON(MC_CMD_SET_MAC_OUT_LEN != 0);
-
-       /* This has no effect on EF10 */
-       ether_addr_copy(MCDI_PTR(cmdbytes, SET_MAC_IN_ADDR),
-                       efx->net_dev->dev_addr);
-
-       MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_MTU,
-                       EFX_MAX_FRAME_LEN(efx->net_dev->mtu));
-       MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_DRAIN, 0);
-
-       /* Set simple MAC filter for Siena */
-       MCDI_POPULATE_DWORD_1(cmdbytes, SET_MAC_IN_REJECT,
-                             SET_MAC_IN_REJECT_UNCST, efx->unicast_filter);
-
-       MCDI_POPULATE_DWORD_1(cmdbytes, SET_MAC_IN_FLAGS,
-                             SET_MAC_IN_FLAG_INCLUDE_FCS,
-                             !!(efx->net_dev->features & NETIF_F_RXFCS));
-
-       switch (efx->wanted_fc) {
-       case EFX_FC_RX | EFX_FC_TX:
-               fcntl = MC_CMD_FCNTL_BIDIR;
-               break;
-       case EFX_FC_RX:
-               fcntl = MC_CMD_FCNTL_RESPOND;
-               break;
-       default:
-               fcntl = MC_CMD_FCNTL_OFF;
-               break;
-       }
-       if (efx->wanted_fc & EFX_FC_AUTO)
-               fcntl = MC_CMD_FCNTL_AUTO;
-       if (efx->fc_disable)
-               fcntl = MC_CMD_FCNTL_OFF;
-
-       MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_FCNTL, fcntl);
-
-       return efx_mcdi_rpc(efx, MC_CMD_SET_MAC, cmdbytes, sizeof(cmdbytes),
-                           NULL, 0, NULL);
-}
-
 bool efx_mcdi_mac_check_fault(struct efx_nic *efx)
 {
        MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_LINK_OUT_LEN);
index 3b1c559..0f3237f 100644 (file)
@@ -474,6 +474,51 @@ int efx_mcdi_phy_test_alive(struct efx_nic *efx)
        return 0;
 }
 
+int efx_mcdi_set_mac(struct efx_nic *efx)
+{
+       u32 fcntl;
+       MCDI_DECLARE_BUF(cmdbytes, MC_CMD_SET_MAC_IN_LEN);
+
+       BUILD_BUG_ON(MC_CMD_SET_MAC_OUT_LEN != 0);
+
+       /* This has no effect on EF10 */
+       ether_addr_copy(MCDI_PTR(cmdbytes, SET_MAC_IN_ADDR),
+                       efx->net_dev->dev_addr);
+
+       MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_MTU,
+                      EFX_MAX_FRAME_LEN(efx->net_dev->mtu));
+       MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_DRAIN, 0);
+
+       /* Set simple MAC filter for Siena */
+       MCDI_POPULATE_DWORD_1(cmdbytes, SET_MAC_IN_REJECT,
+                             SET_MAC_IN_REJECT_UNCST, efx->unicast_filter);
+
+       MCDI_POPULATE_DWORD_1(cmdbytes, SET_MAC_IN_FLAGS,
+                             SET_MAC_IN_FLAG_INCLUDE_FCS,
+                             !!(efx->net_dev->features & NETIF_F_RXFCS));
+
+       switch (efx->wanted_fc) {
+       case EFX_FC_RX | EFX_FC_TX:
+               fcntl = MC_CMD_FCNTL_BIDIR;
+               break;
+       case EFX_FC_RX:
+               fcntl = MC_CMD_FCNTL_RESPOND;
+               break;
+       default:
+               fcntl = MC_CMD_FCNTL_OFF;
+               break;
+       }
+       if (efx->wanted_fc & EFX_FC_AUTO)
+               fcntl = MC_CMD_FCNTL_AUTO;
+       if (efx->fc_disable)
+               fcntl = MC_CMD_FCNTL_OFF;
+
+       MCDI_SET_DWORD(cmdbytes, SET_MAC_IN_FCNTL, fcntl);
+
+       return efx_mcdi_rpc(efx, MC_CMD_SET_MAC, cmdbytes, sizeof(cmdbytes),
+                           NULL, 0, NULL);
+}
+
 /* Get physical port number (EF10 only; on Siena it is same as PF number) */
 int efx_mcdi_port_get_number(struct efx_nic *efx)
 {
index 10772de..6b08a2b 100644 (file)
@@ -28,6 +28,8 @@ struct efx_mcdi_phy_data {
        u32 forced_cap;
 };
 
+#define EFX_MC_STATS_GENERATION_INVALID ((__force __le64)(-1))
+
 int efx_mcdi_get_phy_cfg(struct efx_nic *efx, struct efx_mcdi_phy_data *cfg);
 void efx_link_set_advertising(struct efx_nic *efx,
                              const unsigned long *advertising);
@@ -48,6 +50,7 @@ bool efx_mcdi_phy_poll(struct efx_nic *efx);
 int efx_mcdi_phy_get_fecparam(struct efx_nic *efx,
                              struct ethtool_fecparam *fec);
 int efx_mcdi_phy_test_alive(struct efx_nic *efx);
+int efx_mcdi_set_mac(struct efx_nic *efx);
 int efx_mcdi_port_get_number(struct efx_nic *efx);
 
 #endif
index 810f6fc..baa4641 100644 (file)
@@ -21,6 +21,7 @@
 #include "workarounds.h"
 #include "mcdi.h"
 #include "mcdi_pcol.h"
+#include "mcdi_port_common.h"
 #include "selftest.h"
 #include "siena_sriov.h"