]> git.droids-corp.org - dpdk.git/commitdiff
net/sfc/base: support FW subvariant choice
authorAndrew Rybchenko <arybchenko@solarflare.com>
Wed, 4 Apr 2018 14:23:56 +0000 (15:23 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 13 Apr 2018 22:41:44 +0000 (00:41 +0200)
If DPDK application or OS does not need checksumming on transmit,
it may be disabled in firmware to achieve higher packet rates.
Choice must be done before VIS allocation and is allowed if
no other non-preboot and firmware subvariant-unaware drivers are
attached.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@solarflare.com>
Reviewed-by: Andrew Lee <alee@solarflare.com>
drivers/net/sfc/base/ef10_impl.h
drivers/net/sfc/base/ef10_nic.c
drivers/net/sfc/base/efx.h
drivers/net/sfc/base/efx_nic.c

index 7089a60f770506b7d1abe76e5fa77eaf5e316f05..b4ad59518d79194060d47bb6afa94a484e4cee97 100644 (file)
@@ -1167,6 +1167,22 @@ ef10_get_privilege_mask(
        __in                    efx_nic_t *enp,
        __out                   uint32_t *maskp);
 
+#if EFSYS_OPT_FW_SUBVARIANT_AWARE
+
+extern __checkReturn   efx_rc_t
+efx_mcdi_get_nic_global(
+       __in            efx_nic_t *enp,
+       __in            uint32_t key,
+       __out           uint32_t *valuep);
+
+extern __checkReturn   efx_rc_t
+efx_mcdi_set_nic_global(
+       __in            efx_nic_t *enp,
+       __in            uint32_t key,
+       __in            uint32_t value);
+
+#endif /* EFSYS_OPT_FW_SUBVARIANT_AWARE */
+
 
 #if EFSYS_OPT_RX_PACKED_STREAM
 
index 05db363ad40c141d92bb776b72e87018a9a316c1..ca11ff415117d2176792f4fa3d6fa28e8c708bfd 100644 (file)
@@ -2297,5 +2297,87 @@ fail1:
 
 #endif /* EFSYS_OPT_DIAG */
 
+#if EFSYS_OPT_FW_SUBVARIANT_AWARE
+
+       __checkReturn   efx_rc_t
+efx_mcdi_get_nic_global(
+       __in            efx_nic_t *enp,
+       __in            uint32_t key,
+       __out           uint32_t *valuep)
+{
+       efx_mcdi_req_t req;
+       uint8_t payload[MAX(MC_CMD_GET_NIC_GLOBAL_IN_LEN,
+                           MC_CMD_GET_NIC_GLOBAL_OUT_LEN)];
+       efx_rc_t rc;
+
+       (void) memset(payload, 0, sizeof (payload));
+       req.emr_cmd = MC_CMD_GET_NIC_GLOBAL;
+       req.emr_in_buf = payload;
+       req.emr_in_length = MC_CMD_GET_NIC_GLOBAL_IN_LEN;
+       req.emr_out_buf = payload;
+       req.emr_out_length = MC_CMD_GET_NIC_GLOBAL_OUT_LEN;
+
+       MCDI_IN_SET_DWORD(req, GET_NIC_GLOBAL_IN_KEY, key);
+
+       efx_mcdi_execute(enp, &req);
+
+       if (req.emr_rc != 0) {
+               rc = req.emr_rc;
+               goto fail1;
+       }
+
+       if (req.emr_out_length_used != MC_CMD_GET_NIC_GLOBAL_OUT_LEN) {
+               rc = EMSGSIZE;
+               goto fail2;
+       }
+
+       *valuep = MCDI_OUT_DWORD(req, GET_NIC_GLOBAL_OUT_VALUE);
+
+       return (0);
+
+fail2:
+       EFSYS_PROBE(fail2);
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+       return (rc);
+}
+
+       __checkReturn   efx_rc_t
+efx_mcdi_set_nic_global(
+       __in            efx_nic_t *enp,
+       __in            uint32_t key,
+       __in            uint32_t value)
+{
+       efx_mcdi_req_t req;
+       uint8_t payload[MC_CMD_SET_NIC_GLOBAL_IN_LEN];
+       efx_rc_t rc;
+
+       (void) memset(payload, 0, sizeof (payload));
+       req.emr_cmd = MC_CMD_SET_NIC_GLOBAL;
+       req.emr_in_buf = payload;
+       req.emr_in_length = MC_CMD_SET_NIC_GLOBAL_IN_LEN;
+       req.emr_out_buf = NULL;
+       req.emr_out_length = 0;
+
+       MCDI_IN_SET_DWORD(req, SET_NIC_GLOBAL_IN_KEY, key);
+       MCDI_IN_SET_DWORD(req, SET_NIC_GLOBAL_IN_VALUE, value);
+
+       efx_mcdi_execute(enp, &req);
+
+       if (req.emr_rc != 0) {
+               rc = req.emr_rc;
+               goto fail1;
+       }
+
+       return (0);
+
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+       return (rc);
+}
+
+#endif /* EFSYS_OPT_FW_SUBVARIANT_AWARE */
 
 #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
index e334b963971152eb5072409718bbee06f15327ec..63f0ba52d73715d5b7160768a7f97a0720b70c18 100644 (file)
@@ -2862,6 +2862,38 @@ efx_tunnel_reconfigure(
 
 #endif /* EFSYS_OPT_TUNNEL */
 
+#if EFSYS_OPT_FW_SUBVARIANT_AWARE
+
+/**
+ * Firmware subvariant choice options.
+ *
+ * It may be switched to no Tx checksum if attached drivers are either
+ * preboot or firmware subvariant aware and no VIS are allocated.
+ * If may be always switched to default explicitly using set request or
+ * implicitly if unaware driver is attaching. If switching is done when
+ * a driver is attached, it gets MC_REBOOT event and should recreate its
+ * datapath.
+ *
+ * See SF-119419-TC DPDK Firmware Driver Interface and
+ * SF-109306-TC EF10 for Driver Writers for details.
+ */
+typedef enum efx_nic_fw_subvariant_e {
+       EFX_NIC_FW_SUBVARIANT_DEFAULT = 0,
+       EFX_NIC_FW_SUBVARIANT_NO_TX_CSUM = 1,
+       EFX_NIC_FW_SUBVARIANT_NTYPES
+} efx_nic_fw_subvariant_t;
+
+extern __checkReturn   efx_rc_t
+efx_nic_get_fw_subvariant(
+       __in            efx_nic_t *enp,
+       __out           efx_nic_fw_subvariant_t *subvariantp);
+
+extern __checkReturn   efx_rc_t
+efx_nic_set_fw_subvariant(
+       __in            efx_nic_t *enp,
+       __in            efx_nic_fw_subvariant_t subvariant);
+
+#endif /* EFSYS_OPT_FW_SUBVARIANT_AWARE */
 
 #ifdef __cplusplus
 }
index 8014deea7ab594c46646d36cc9ae571301ee5341..6c162e0351946b98298177d5f27c5df087314c63 100644 (file)
@@ -944,6 +944,82 @@ fail1:
        return (rc);
 }
 
+#if EFSYS_OPT_FW_SUBVARIANT_AWARE
+
+       __checkReturn   efx_rc_t
+efx_nic_get_fw_subvariant(
+       __in            efx_nic_t *enp,
+       __out           efx_nic_fw_subvariant_t *subvariantp)
+{
+       efx_rc_t rc;
+       uint32_t value;
+
+       rc = efx_mcdi_get_nic_global(enp,
+           MC_CMD_SET_NIC_GLOBAL_IN_FIRMWARE_SUBVARIANT, &value);
+       if (rc != 0)
+               goto fail1;
+
+       /* Mapping is not required since values match MCDI */
+       EFX_STATIC_ASSERT(EFX_NIC_FW_SUBVARIANT_DEFAULT ==
+           MC_CMD_SET_NIC_GLOBAL_IN_FW_SUBVARIANT_DEFAULT);
+       EFX_STATIC_ASSERT(EFX_NIC_FW_SUBVARIANT_NO_TX_CSUM ==
+           MC_CMD_SET_NIC_GLOBAL_IN_FW_SUBVARIANT_NO_TX_CSUM);
+
+       switch (value) {
+       case MC_CMD_SET_NIC_GLOBAL_IN_FW_SUBVARIANT_DEFAULT:
+       case MC_CMD_SET_NIC_GLOBAL_IN_FW_SUBVARIANT_NO_TX_CSUM:
+               *subvariantp = value;
+               break;
+       default:
+               rc = EINVAL;
+               goto fail2;
+       }
+
+       return (0);
+
+fail2:
+       EFSYS_PROBE(fail2);
+
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+       return (rc);
+}
+
+       __checkReturn   efx_rc_t
+efx_nic_set_fw_subvariant(
+       __in            efx_nic_t *enp,
+       __in            efx_nic_fw_subvariant_t subvariant)
+{
+       efx_rc_t rc;
+
+       switch (subvariant) {
+       case EFX_NIC_FW_SUBVARIANT_DEFAULT:
+       case EFX_NIC_FW_SUBVARIANT_NO_TX_CSUM:
+               /* Mapping is not required since values match MCDI */
+               break;
+       default:
+               rc = EINVAL;
+               goto fail1;
+       }
+
+       rc = efx_mcdi_set_nic_global(enp,
+           MC_CMD_SET_NIC_GLOBAL_IN_FIRMWARE_SUBVARIANT, subvariant);
+       if (rc != 0)
+               goto fail2;
+
+       return (0);
+
+fail2:
+       EFSYS_PROBE(fail2);
+
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+       return (rc);
+}
+
+#endif /* EFSYS_OPT_FW_SUBVARIANT_AWARE */
 
        __checkReturn   efx_rc_t
 efx_nic_check_pcie_link_speed(