* [dpdk-dev] [PATCH 1/3] net/sfc/base: add support to choose firmware variant
2018-03-26 12:50 [dpdk-dev] [PATCH 0/3] net/sfc: add device parameter to choose FW variant Andrew Rybchenko
@ 2018-03-26 12:50 ` Andrew Rybchenko
2018-03-26 12:50 ` [dpdk-dev] [PATCH 2/3] net/sfc/base: add values for RxDPCPU firmware id recognition Andrew Rybchenko
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Andrew Rybchenko @ 2018-03-26 12:50 UTC (permalink / raw)
To: dev; +Cc: Gautam Dawar
From: Gautam Dawar <gdawar@solarflare.com>
Signed-off-by: Gautam Dawar <gdawar@solarflare.com>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
drivers/net/sfc/base/efx.h | 15 ++++++++++++++-
drivers/net/sfc/base/efx_impl.h | 1 +
drivers/net/sfc/base/efx_mcdi.c | 14 ++++++++++----
drivers/net/sfc/base/efx_nic.c | 23 ++++++++++++++++++++++-
drivers/net/sfc/sfc.c | 2 +-
5 files changed, 48 insertions(+), 7 deletions(-)
diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index bb903e5..4994745 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -129,9 +129,22 @@ efx_nic_create(
__in efsys_lock_t *eslp,
__deref_out efx_nic_t **enpp);
+/* EFX_FW_VARIANT codes map one to one on MC_CMD_FW codes */
+typedef enum efx_fw_variant_e {
+ EFX_FW_VARIANT_FULL_FEATURED,
+ EFX_FW_VARIANT_LOW_LATENCY,
+ EFX_FW_VARIANT_PACKED_STREAM,
+ EFX_FW_VARIANT_HIGH_TX_RATE,
+ EFX_FW_VARIANT_PACKED_STREAM_HASH_MODE_1,
+ EFX_FW_VARIANT_RULES_ENGINE,
+ EFX_FW_VARIANT_DPDK,
+ EFX_FW_VARIANT_DONT_CARE = 0xffffffff
+} efx_fw_variant_t;
+
extern __checkReturn efx_rc_t
efx_nic_probe(
- __in efx_nic_t *enp);
+ __in efx_nic_t *enp,
+ __in efx_fw_variant_t efv);
extern __checkReturn efx_rc_t
efx_nic_init(
diff --git a/drivers/net/sfc/base/efx_impl.h b/drivers/net/sfc/base/efx_impl.h
index a1bd03d..b1d4f57 100644
--- a/drivers/net/sfc/base/efx_impl.h
+++ b/drivers/net/sfc/base/efx_impl.h
@@ -647,6 +647,7 @@ struct efx_nic_s {
const efx_ev_ops_t *en_eevop;
const efx_tx_ops_t *en_etxop;
const efx_rx_ops_t *en_erxop;
+ efx_fw_variant_t efv;
#if EFSYS_OPT_FILTER
efx_filter_t en_filter;
const efx_filter_ops_t *en_efop;
diff --git a/drivers/net/sfc/base/efx_mcdi.c b/drivers/net/sfc/base/efx_mcdi.c
index a78a226..d8b4598 100644
--- a/drivers/net/sfc/base/efx_mcdi.c
+++ b/drivers/net/sfc/base/efx_mcdi.c
@@ -1264,13 +1264,19 @@ efx_mcdi_drv_attach(
req.emr_out_length = MC_CMD_DRV_ATTACH_EXT_OUT_LEN;
/*
- * Use DONT_CARE for the datapath firmware type to ensure that the
- * driver can attach to an unprivileged function. The datapath firmware
- * type to use is controlled by the 'sfboot' utility.
+ * Typically, client drivers use DONT_CARE for the datapath firmware
+ * type to ensure that the driver can attach to an unprivileged
+ * function. The datapath firmware type to use is controlled by the
+ * 'sfboot' utility.
+ * If a client driver wishes to attach with a specific datapath firmware
+ * type, that can be passed in second argument of efx_nic_probe API. One
+ * such example is the ESXi native driver that attempts attaching with
+ * FULL_FEATURED datapath firmware type first and fall backs to
+ * DONT_CARE datapath firmware type if MC_CMD_DRV_ATTACH fails.
*/
MCDI_IN_SET_DWORD(req, DRV_ATTACH_IN_NEW_STATE, attach ? 1 : 0);
MCDI_IN_SET_DWORD(req, DRV_ATTACH_IN_UPDATE, 1);
- MCDI_IN_SET_DWORD(req, DRV_ATTACH_IN_FIRMWARE_ID, MC_CMD_FW_DONT_CARE);
+ MCDI_IN_SET_DWORD(req, DRV_ATTACH_IN_FIRMWARE_ID, enp->efv);
efx_mcdi_execute(enp, &req);
diff --git a/drivers/net/sfc/base/efx_nic.c b/drivers/net/sfc/base/efx_nic.c
index 35e84e3..3be32ad 100644
--- a/drivers/net/sfc/base/efx_nic.c
+++ b/drivers/net/sfc/base/efx_nic.c
@@ -290,7 +290,8 @@ efx_nic_create(
__checkReturn efx_rc_t
efx_nic_probe(
- __in efx_nic_t *enp)
+ __in efx_nic_t *enp,
+ __in efx_fw_variant_t efv)
{
const efx_nic_ops_t *enop;
efx_rc_t rc;
@@ -301,7 +302,27 @@ efx_nic_probe(
#endif /* EFSYS_OPT_MCDI */
EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_PROBE));
+ /* Ensure FW variant codes match with MC_CMD_FW codes */
+ EFX_STATIC_ASSERT(EFX_FW_VARIANT_FULL_FEATURED ==
+ MC_CMD_FW_FULL_FEATURED);
+ EFX_STATIC_ASSERT(EFX_FW_VARIANT_LOW_LATENCY ==
+ MC_CMD_FW_LOW_LATENCY);
+ EFX_STATIC_ASSERT(EFX_FW_VARIANT_PACKED_STREAM ==
+ MC_CMD_FW_PACKED_STREAM);
+ EFX_STATIC_ASSERT(EFX_FW_VARIANT_HIGH_TX_RATE ==
+ MC_CMD_FW_HIGH_TX_RATE);
+ EFX_STATIC_ASSERT(EFX_FW_VARIANT_PACKED_STREAM_HASH_MODE_1 ==
+ MC_CMD_FW_PACKED_STREAM_HASH_MODE_1);
+ EFX_STATIC_ASSERT(EFX_FW_VARIANT_RULES_ENGINE ==
+ MC_CMD_FW_RULES_ENGINE);
+ EFX_STATIC_ASSERT(EFX_FW_VARIANT_DPDK ==
+ MC_CMD_FW_DPDK);
+ EFX_STATIC_ASSERT(EFX_FW_VARIANT_DONT_CARE ==
+ (int)MC_CMD_FW_DONT_CARE);
+
enop = enp->en_enop;
+ enp->efv = efv;
+
if ((rc = enop->eno_probe(enp)) != 0)
goto fail1;
diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c
index 681e117..2a326fc 100644
--- a/drivers/net/sfc/sfc.c
+++ b/drivers/net/sfc/sfc.c
@@ -780,7 +780,7 @@ sfc_probe(struct sfc_adapter *sa)
goto fail_mcdi_init;
sfc_log_init(sa, "probe nic");
- rc = efx_nic_probe(enp);
+ rc = efx_nic_probe(enp, EFX_FW_VARIANT_DONT_CARE);
if (rc != 0)
goto fail_nic_probe;
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH 2/3] net/sfc/base: add values for RxDPCPU firmware id recognition
2018-03-26 12:50 [dpdk-dev] [PATCH 0/3] net/sfc: add device parameter to choose FW variant Andrew Rybchenko
2018-03-26 12:50 ` [dpdk-dev] [PATCH 1/3] net/sfc/base: add support to choose firmware variant Andrew Rybchenko
@ 2018-03-26 12:50 ` Andrew Rybchenko
2018-03-26 12:50 ` [dpdk-dev] [PATCH 3/3] net/sfc: add device parameter to choose FW variant Andrew Rybchenko
2018-03-27 19:29 ` [dpdk-dev] [PATCH 0/3] " Ferruh Yigit
3 siblings, 0 replies; 5+ messages in thread
From: Andrew Rybchenko @ 2018-03-26 12:50 UTC (permalink / raw)
To: dev; +Cc: Roman Zhukov
From: Roman Zhukov <Roman.Zhukov@oktetlabs.ru>
Signed-off-by: Roman Zhukov <Roman.Zhukov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
drivers/net/sfc/base/efx.h | 7 +++++++
drivers/net/sfc/base/efx_nic.c | 12 ++++++++++++
2 files changed, 19 insertions(+)
diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 4994745..fd9f059 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -1294,6 +1294,13 @@ extern const efx_nic_cfg_t *
efx_nic_cfg_get(
__in efx_nic_t *enp);
+/* RxDPCPU firmware id values by which FW variant can be identified */
+#define EFX_RXDP_FULL_FEATURED_FW_ID 0x0
+#define EFX_RXDP_LOW_LATENCY_FW_ID 0x1
+#define EFX_RXDP_PACKED_STREAM_FW_ID 0x2
+#define EFX_RXDP_RULES_ENGINE_FW_ID 0x5
+#define EFX_RXDP_DPDK_FW_ID 0x6
+
typedef struct efx_nic_fw_info_s {
/* Basic FW version information */
uint16_t enfi_mc_fw_version[4];
diff --git a/drivers/net/sfc/base/efx_nic.c b/drivers/net/sfc/base/efx_nic.c
index 3be32ad..8014dee 100644
--- a/drivers/net/sfc/base/efx_nic.c
+++ b/drivers/net/sfc/base/efx_nic.c
@@ -604,6 +604,18 @@ efx_nic_get_fw_version(
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MCDI);
EFSYS_ASSERT3U(enp->en_features, &, EFX_FEATURE_MCDI);
+ /* Ensure RXDP_FW_ID codes match with MC_CMD_GET_CAPABILITIES codes */
+ EFX_STATIC_ASSERT(EFX_RXDP_FULL_FEATURED_FW_ID ==
+ MC_CMD_GET_CAPABILITIES_OUT_RXDP);
+ EFX_STATIC_ASSERT(EFX_RXDP_LOW_LATENCY_FW_ID ==
+ MC_CMD_GET_CAPABILITIES_OUT_RXDP_LOW_LATENCY);
+ EFX_STATIC_ASSERT(EFX_RXDP_PACKED_STREAM_FW_ID ==
+ MC_CMD_GET_CAPABILITIES_OUT_RXDP_PACKED_STREAM);
+ EFX_STATIC_ASSERT(EFX_RXDP_RULES_ENGINE_FW_ID ==
+ MC_CMD_GET_CAPABILITIES_OUT_RXDP_RULES_ENGINE);
+ EFX_STATIC_ASSERT(EFX_RXDP_DPDK_FW_ID ==
+ MC_CMD_GET_CAPABILITIES_OUT_RXDP_DPDK);
+
rc = efx_mcdi_version(enp, mc_fw_version, NULL, NULL);
if (rc != 0)
goto fail2;
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH 3/3] net/sfc: add device parameter to choose FW variant
2018-03-26 12:50 [dpdk-dev] [PATCH 0/3] net/sfc: add device parameter to choose FW variant Andrew Rybchenko
2018-03-26 12:50 ` [dpdk-dev] [PATCH 1/3] net/sfc/base: add support to choose firmware variant Andrew Rybchenko
2018-03-26 12:50 ` [dpdk-dev] [PATCH 2/3] net/sfc/base: add values for RxDPCPU firmware id recognition Andrew Rybchenko
@ 2018-03-26 12:50 ` Andrew Rybchenko
2018-03-27 19:29 ` [dpdk-dev] [PATCH 0/3] " Ferruh Yigit
3 siblings, 0 replies; 5+ messages in thread
From: Andrew Rybchenko @ 2018-03-26 12:50 UTC (permalink / raw)
To: dev; +Cc: Roman Zhukov
From: Roman Zhukov <Roman.Zhukov@oktetlabs.ru>
Add support of choice the preferred firmware variant to use in device
parameters.
Signed-off-by: Roman Zhukov <Roman.Zhukov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
doc/guides/nics/sfc_efx.rst | 15 ++++++
drivers/net/sfc/sfc.c | 123 ++++++++++++++++++++++++++++++++++++++++++-
drivers/net/sfc/sfc_ethdev.c | 1 +
drivers/net/sfc/sfc_kvargs.c | 1 +
drivers/net/sfc/sfc_kvargs.h | 12 +++++
5 files changed, 151 insertions(+), 1 deletion(-)
diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index 2e4c3d8..2bd29cc 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -330,6 +330,21 @@ boolean parameters value.
firmware version is 6.2.1.1033 or higher, otherwise any positive
value will select a fixed update period of **1000** milliseconds
+- ``fw_variant`` [dont-care|full-feature|ultra-low-latency|
+ capture-packed-stream] (default **dont-care**)
+
+ Choose the preferred firmware variant to use. In order for the selected
+ option to have an effect, the **sfboot** utility must be configured with the
+ **auto** firmware-variant option. The preferred firmware variant applies to
+ all ports on the NIC.
+ **dont-care** ensures that the driver can attach to an unprivileged function.
+ The datapath firmware type to use is controlled by the **sfboot**
+ utility.
+ **full-feature** chooses full featured firmware.
+ **ultra-low-latency** chooses firmware with fewer features but lower latency.
+ **capture-packed-stream** chooses firmware for SolarCapture packed stream
+ mode.
+
Dynamic Logging Parameters
~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c
index 2a326fc..e2ba720 100644
--- a/drivers/net/sfc/sfc.c
+++ b/drivers/net/sfc/sfc.c
@@ -20,6 +20,7 @@
#include "sfc_ev.h"
#include "sfc_rx.h"
#include "sfc_tx.h"
+#include "sfc_kvargs.h"
int
@@ -740,6 +741,126 @@ sfc_detach(struct sfc_adapter *sa)
sa->state = SFC_ADAPTER_UNINITIALIZED;
}
+static int
+sfc_kvarg_fv_variant_handler(__rte_unused const char *key,
+ const char *value_str, void *opaque)
+{
+ uint32_t *value = opaque;
+
+ if (strcasecmp(value_str, SFC_KVARG_FW_VARIANT_DONT_CARE) == 0)
+ *value = EFX_FW_VARIANT_DONT_CARE;
+ else if (strcasecmp(value_str, SFC_KVARG_FW_VARIANT_FULL_FEATURED) == 0)
+ *value = EFX_FW_VARIANT_FULL_FEATURED;
+ else if (strcasecmp(value_str, SFC_KVARG_FW_VARIANT_LOW_LATENCY) == 0)
+ *value = EFX_FW_VARIANT_LOW_LATENCY;
+ else if (strcasecmp(value_str, SFC_KVARG_FW_VARIANT_PACKED_STREAM) == 0)
+ *value = EFX_FW_VARIANT_PACKED_STREAM;
+ else
+ return -EINVAL;
+
+ return 0;
+}
+
+static int
+sfc_get_fw_variant(struct sfc_adapter *sa, efx_fw_variant_t *efv)
+{
+ efx_nic_fw_info_t enfi;
+ int rc;
+
+ rc = efx_nic_get_fw_version(sa->nic, &enfi);
+ if (rc != 0)
+ return rc;
+ else if (!enfi.enfi_dpcpu_fw_ids_valid)
+ return ENOTSUP;
+
+ /*
+ * Firmware variant can be uniquely identified by the RxDPCPU
+ * firmware id
+ */
+ switch (enfi.enfi_rx_dpcpu_fw_id) {
+ case EFX_RXDP_FULL_FEATURED_FW_ID:
+ *efv = EFX_FW_VARIANT_FULL_FEATURED;
+ break;
+
+ case EFX_RXDP_LOW_LATENCY_FW_ID:
+ *efv = EFX_FW_VARIANT_LOW_LATENCY;
+ break;
+
+ case EFX_RXDP_PACKED_STREAM_FW_ID:
+ *efv = EFX_FW_VARIANT_PACKED_STREAM;
+ break;
+
+ default:
+ /*
+ * Other firmware variants are not considered, since they are
+ * not supported in the device parameters
+ */
+ *efv = EFX_FW_VARIANT_DONT_CARE;
+ break;
+ }
+
+ return 0;
+}
+
+static const char *
+sfc_fw_variant2str(efx_fw_variant_t efv)
+{
+ switch (efv) {
+ case EFX_RXDP_FULL_FEATURED_FW_ID:
+ return SFC_KVARG_FW_VARIANT_FULL_FEATURED;
+ case EFX_RXDP_LOW_LATENCY_FW_ID:
+ return SFC_KVARG_FW_VARIANT_LOW_LATENCY;
+ case EFX_RXDP_PACKED_STREAM_FW_ID:
+ return SFC_KVARG_FW_VARIANT_PACKED_STREAM;
+ default:
+ return "unknown";
+ }
+}
+
+static int
+sfc_nic_probe(struct sfc_adapter *sa)
+{
+ efx_nic_t *enp = sa->nic;
+ efx_fw_variant_t preferred_efv;
+ efx_fw_variant_t efv;
+ int rc;
+
+ preferred_efv = EFX_FW_VARIANT_DONT_CARE;
+ rc = sfc_kvargs_process(sa, SFC_KVARG_FW_VARIANT,
+ sfc_kvarg_fv_variant_handler,
+ &preferred_efv);
+ if (rc != 0) {
+ sfc_err(sa, "invalid %s parameter value", SFC_KVARG_FW_VARIANT);
+ return rc;
+ }
+
+ rc = efx_nic_probe(enp, preferred_efv);
+ if (rc == EACCES) {
+ /* Unprivileged functions cannot set FW variant */
+ rc = efx_nic_probe(enp, EFX_FW_VARIANT_DONT_CARE);
+ }
+ if (rc != 0)
+ return rc;
+
+ rc = sfc_get_fw_variant(sa, &efv);
+ if (rc == ENOTSUP) {
+ sfc_warn(sa, "FW variant can not be obtained");
+ return 0;
+ }
+ if (rc != 0)
+ return rc;
+
+ /* Check that firmware variant was changed to the requested one */
+ if (preferred_efv != EFX_FW_VARIANT_DONT_CARE && preferred_efv != efv) {
+ sfc_warn(sa, "FW variant has not changed to the requested %s",
+ sfc_fw_variant2str(preferred_efv));
+ }
+
+ sfc_notice(sa, "running FW variant is %s", sfc_fw_variant2str(efv));
+
+ return 0;
+}
+
int
sfc_probe(struct sfc_adapter *sa)
{
@@ -780,7 +901,7 @@ sfc_probe(struct sfc_adapter *sa)
goto fail_mcdi_init;
sfc_log_init(sa, "probe nic");
- rc = efx_nic_probe(enp, EFX_FW_VARIANT_DONT_CARE);
+ rc = sfc_nic_probe(sa);
if (rc != 0)
goto fail_nic_probe;
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index f16d520..e140f8f 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -2065,6 +2065,7 @@ RTE_PMD_REGISTER_PARAM_STRING(net_sfc_efx,
SFC_KVARG_RX_DATAPATH "=" SFC_KVARG_VALUES_RX_DATAPATH " "
SFC_KVARG_TX_DATAPATH "=" SFC_KVARG_VALUES_TX_DATAPATH " "
SFC_KVARG_PERF_PROFILE "=" SFC_KVARG_VALUES_PERF_PROFILE " "
+ SFC_KVARG_FW_VARIANT "=" SFC_KVARG_VALUES_FW_VARIANT " "
SFC_KVARG_STATS_UPDATE_PERIOD_MS "=<long>");
RTE_INIT(sfc_driver_register_logtype);
diff --git a/drivers/net/sfc/sfc_kvargs.c b/drivers/net/sfc/sfc_kvargs.c
index 9c08bff..53fa939 100644
--- a/drivers/net/sfc/sfc_kvargs.c
+++ b/drivers/net/sfc/sfc_kvargs.c
@@ -26,6 +26,7 @@ sfc_kvargs_parse(struct sfc_adapter *sa)
SFC_KVARG_PERF_PROFILE,
SFC_KVARG_RX_DATAPATH,
SFC_KVARG_TX_DATAPATH,
+ SFC_KVARG_FW_VARIANT,
NULL,
};
diff --git a/drivers/net/sfc/sfc_kvargs.h b/drivers/net/sfc/sfc_kvargs.h
index a84dc6b..1e578e7 100644
--- a/drivers/net/sfc/sfc_kvargs.h
+++ b/drivers/net/sfc/sfc_kvargs.h
@@ -45,6 +45,18 @@ extern "C" {
SFC_KVARG_DATAPATH_EF10 "|" \
SFC_KVARG_DATAPATH_EF10_SIMPLE "]"
+#define SFC_KVARG_FW_VARIANT "fw_variant"
+
+#define SFC_KVARG_FW_VARIANT_DONT_CARE "dont-care"
+#define SFC_KVARG_FW_VARIANT_FULL_FEATURED "full-feature"
+#define SFC_KVARG_FW_VARIANT_LOW_LATENCY "ultra-low-latency"
+#define SFC_KVARG_FW_VARIANT_PACKED_STREAM "capture-packed-stream"
+#define SFC_KVARG_VALUES_FW_VARIANT \
+ "[" SFC_KVARG_FW_VARIANT_DONT_CARE "|" \
+ SFC_KVARG_FW_VARIANT_FULL_FEATURED "|" \
+ SFC_KVARG_FW_VARIANT_LOW_LATENCY "|" \
+ SFC_KVARG_FW_VARIANT_PACKED_STREAM "]"
+
struct sfc_adapter;
int sfc_kvargs_parse(struct sfc_adapter *sa);
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH 0/3] net/sfc: add device parameter to choose FW variant
2018-03-26 12:50 [dpdk-dev] [PATCH 0/3] net/sfc: add device parameter to choose FW variant Andrew Rybchenko
` (2 preceding siblings ...)
2018-03-26 12:50 ` [dpdk-dev] [PATCH 3/3] net/sfc: add device parameter to choose FW variant Andrew Rybchenko
@ 2018-03-27 19:29 ` Ferruh Yigit
3 siblings, 0 replies; 5+ messages in thread
From: Ferruh Yigit @ 2018-03-27 19:29 UTC (permalink / raw)
To: Andrew Rybchenko, dev
On 3/26/2018 1:50 PM, Andrew Rybchenko wrote:
> Patch 'net/sfc: add device parameter to choose FW variant' has
> checkpatches.sh warning since positive errno is used inside the driver.
>
> Gautam Dawar (1):
> net/sfc/base: add support to choose firmware variant
>
> Roman Zhukov (2):
> net/sfc/base: add values for RxDPCPU firmware id recognition
> net/sfc: add device parameter to choose FW variant
Series applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread