sfc: make firmware-variant printing a nic_type function
authorEdward Cree <ecree@solarflare.com>
Mon, 11 May 2020 12:30:00 +0000 (13:30 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 11 May 2020 20:31:49 +0000 (13:31 -0700)
Instead of having efx_mcdi_print_fwver() look at efx_nic_rev and
 conditionally poke around inside ef10-specific nic_data, add a new
 efx->type->print_additional_fwver() method to do this work.

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.c
drivers/net/ethernet/sfc/net_driver.h

index d7d2edc..e634e81 100644 (file)
@@ -3978,6 +3978,19 @@ out_unlock:
        return rc;
 }
 
+/* EF10 may have multiple datapath firmware variants within a
+ * single version.  Report which variants are running.
+ */
+static size_t efx_ef10_print_additional_fwver(struct efx_nic *efx, char *buf,
+                                             size_t len)
+{
+       struct efx_ef10_nic_data *nic_data = efx->nic_data;
+
+       return scnprintf(buf, len, " rx%x tx%x",
+                        nic_data->rx_dpcpu_fw_id,
+                        nic_data->tx_dpcpu_fw_id);
+}
+
 static unsigned int ef10_check_caps(const struct efx_nic *efx,
                                    u8 flag,
                                    u32 offset)
@@ -4107,6 +4120,7 @@ const struct efx_nic_type efx_hunt_a0_vf_nic_type = {
                            1 << HWTSTAMP_FILTER_ALL,
        .rx_hash_key_size = 40,
        .check_caps = ef10_check_caps,
+       .print_additional_fwver = efx_ef10_print_additional_fwver,
 };
 
 const struct efx_nic_type efx_hunt_a0_nic_type = {
@@ -4243,4 +4257,5 @@ const struct efx_nic_type efx_hunt_a0_nic_type = {
                            1 << HWTSTAMP_FILTER_ALL,
        .rx_hash_key_size = 40,
        .check_caps = ef10_check_caps,
+       .print_additional_fwver = efx_ef10_print_additional_fwver,
 };
index 15c731d..a8cc388 100644 (file)
@@ -1425,23 +1425,16 @@ void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len)
                           le16_to_cpu(ver_words[2]),
                           le16_to_cpu(ver_words[3]));
 
-       /* EF10 may have multiple datapath firmware variants within a
-        * single version.  Report which variants are running.
-        */
-       if (efx_nic_rev(efx) >= EFX_REV_HUNT_A0) {
-               struct efx_ef10_nic_data *nic_data = efx->nic_data;
-
-               offset += scnprintf(buf + offset, len - offset, " rx%x tx%x",
-                                   nic_data->rx_dpcpu_fw_id,
-                                   nic_data->tx_dpcpu_fw_id);
+       if (efx->type->print_additional_fwver)
+               offset += efx->type->print_additional_fwver(efx, buf + offset,
+                                                           len - offset);
 
-               /* It's theoretically possible for the string to exceed 31
-                * characters, though in practice the first three version
-                * components are short enough that this doesn't happen.
-                */
-               if (WARN_ON(offset >= len))
-                       buf[0] = 0;
-       }
+       /* It's theoretically possible for the string to exceed 31
+        * characters, though in practice the first three version
+        * components are short enough that this doesn't happen.
+        */
+       if (WARN_ON(offset >= len))
+               buf[0] = 0;
 
        return;
 
index ae97568..1afb58f 100644 (file)
@@ -1296,6 +1296,7 @@ struct efx_udp_tunnel {
  * @udp_tnl_add_port: Add a UDP tunnel port
  * @udp_tnl_has_port: Check if a port has been added as UDP tunnel
  * @udp_tnl_del_port: Remove a UDP tunnel port
+ * @print_additional_fwver: Dump NIC-specific additional FW version info
  * @revision: Hardware architecture revision
  * @txd_ptr_tbl_base: TX descriptor ring base address
  * @rxd_ptr_tbl_base: RX descriptor ring base address
@@ -1469,6 +1470,8 @@ struct efx_nic_type {
        int (*udp_tnl_add_port)(struct efx_nic *efx, struct efx_udp_tunnel tnl);
        bool (*udp_tnl_has_port)(struct efx_nic *efx, __be16 port);
        int (*udp_tnl_del_port)(struct efx_nic *efx, struct efx_udp_tunnel tnl);
+       size_t (*print_additional_fwver)(struct efx_nic *efx, char *buf,
+                                        size_t len);
 
        int revision;
        unsigned int txd_ptr_tbl_base;