* [dpdk-dev] [PATCH 0/6] Support running Solarflare PMD over PCI VFs
@ 2017-03-02 15:46 Andrew Rybchenko
2017-03-02 15:46 ` [dpdk-dev] [PATCH 1/6] net/sfc: add VFs to the table of PCI IDs for supported NICs Andrew Rybchenko
` (6 more replies)
0 siblings, 7 replies; 19+ messages in thread
From: Andrew Rybchenko @ 2017-03-02 15:46 UTC (permalink / raw)
To: dev
Running Solarflare PMD over PCI virtual functions requires few fixes:
- periodic MAC stats DMA is not supported for VFs
- promiscious and all-multicast modes may be denied by FW/PF
- MCDI proxy authorization made by FW should be properly handled by
the VF driver
Andrew Rybchenko (1):
net/sfc/base: don't ignore requested MAC stats update period
Ivan Malov (5):
net/sfc: add VFs to the table of PCI IDs for supported NICs
net/sfc: add kvarg control for MAC statistics update period
net/sfc: port HW stats must work if periodic DMA is absent
net/sfc: port must not fail to start if Rx mode is rejected
net/sfc: add support for MCDI proxy
doc/guides/nics/sfc_efx.rst | 9 ++++
drivers/net/sfc/base/efx_mcdi.c | 24 +++++----
drivers/net/sfc/base/efx_mcdi.h | 2 +-
drivers/net/sfc/efsys.h | 2 +-
drivers/net/sfc/sfc.h | 13 +++++
drivers/net/sfc/sfc_ethdev.c | 4 ++
drivers/net/sfc/sfc_kvargs.c | 20 ++++++++
drivers/net/sfc/sfc_kvargs.h | 5 ++
drivers/net/sfc/sfc_mcdi.c | 74 ++++++++++++++++++++++++---
drivers/net/sfc/sfc_port.c | 107 +++++++++++++++++++++++++++++++++++-----
drivers/net/sfc/sfc_rx.c | 54 ++++++++++++++++++--
11 files changed, 280 insertions(+), 34 deletions(-)
--
2.9.3
^ permalink raw reply [flat|nested] 19+ messages in thread
* [dpdk-dev] [PATCH 1/6] net/sfc: add VFs to the table of PCI IDs for supported NICs
2017-03-02 15:46 [dpdk-dev] [PATCH 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
@ 2017-03-02 15:46 ` Andrew Rybchenko
2017-03-06 10:10 ` Ferruh Yigit
2017-03-02 15:46 ` [dpdk-dev] [PATCH 2/6] net/sfc/base: don't ignore requested MAC stats update period Andrew Rybchenko
` (5 subsequent siblings)
6 siblings, 1 reply; 19+ messages in thread
From: Andrew Rybchenko @ 2017-03-02 15:46 UTC (permalink / raw)
To: dev; +Cc: Ivan Malov
From: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andrew Lee <alee@solarflare.com>
---
drivers/net/sfc/sfc_ethdev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 71587fb..be19453 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -1335,8 +1335,11 @@ sfc_eth_dev_uninit(struct rte_eth_dev *dev)
static const struct rte_pci_id pci_id_sfc_efx_map[] = {
{ RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_FARMINGDALE) },
+ { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_FARMINGDALE_VF) },
{ RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_GREENPORT) },
+ { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_GREENPORT_VF) },
{ RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_MEDFORD) },
+ { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_MEDFORD_VF) },
{ .vendor_id = 0 /* sentinel */ }
};
--
2.9.3
^ permalink raw reply [flat|nested] 19+ messages in thread
* [dpdk-dev] [PATCH 2/6] net/sfc/base: don't ignore requested MAC stats update period
2017-03-02 15:46 [dpdk-dev] [PATCH 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
2017-03-02 15:46 ` [dpdk-dev] [PATCH 1/6] net/sfc: add VFs to the table of PCI IDs for supported NICs Andrew Rybchenko
@ 2017-03-02 15:46 ` Andrew Rybchenko
2017-03-02 15:46 ` [dpdk-dev] [PATCH 3/6] net/sfc: add kvarg control for MAC statistics " Andrew Rybchenko
` (4 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Andrew Rybchenko @ 2017-03-02 15:46 UTC (permalink / raw)
To: dev
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
drivers/net/sfc/base/efx_mcdi.c | 24 ++++++++++++++----------
drivers/net/sfc/base/efx_mcdi.h | 2 +-
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/drivers/net/sfc/base/efx_mcdi.c b/drivers/net/sfc/base/efx_mcdi.c
index ac432a6..c9d29a7 100644
--- a/drivers/net/sfc/base/efx_mcdi.c
+++ b/drivers/net/sfc/base/efx_mcdi.c
@@ -1722,7 +1722,8 @@ static __checkReturn efx_rc_t
efx_mcdi_mac_stats(
__in efx_nic_t *enp,
__in_opt efsys_mem_t *esmp,
- __in efx_stats_action_t action)
+ __in efx_stats_action_t action,
+ __in uint16_t period_ms)
{
efx_mcdi_req_t req;
uint8_t payload[MAX(MC_CMD_MAC_STATS_IN_LEN,
@@ -1747,7 +1748,7 @@ efx_mcdi_mac_stats(
MAC_STATS_IN_PERIODIC_CHANGE, enable | events | disable,
MAC_STATS_IN_PERIODIC_ENABLE, enable | events,
MAC_STATS_IN_PERIODIC_NOEVENT, !events,
- MAC_STATS_IN_PERIOD_MS, (enable | events) ? 1000 : 0);
+ MAC_STATS_IN_PERIOD_MS, (enable | events) ? period_ms : 0);
if (esmp != NULL) {
int bytes = MC_CMD_MAC_NSTATS * sizeof (uint64_t);
@@ -1797,7 +1798,7 @@ efx_mcdi_mac_stats_clear(
{
efx_rc_t rc;
- if ((rc = efx_mcdi_mac_stats(enp, NULL, EFX_STATS_CLEAR)) != 0)
+ if ((rc = efx_mcdi_mac_stats(enp, NULL, EFX_STATS_CLEAR, 0)) != 0)
goto fail1;
return (0);
@@ -1820,7 +1821,7 @@ efx_mcdi_mac_stats_upload(
* avoid having to pull the statistics buffer into the cache to
* maintain cumulative statistics.
*/
- if ((rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_UPLOAD)) != 0)
+ if ((rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_UPLOAD, 0)) != 0)
goto fail1;
return (0);
@@ -1835,7 +1836,7 @@ efx_mcdi_mac_stats_upload(
efx_mcdi_mac_stats_periodic(
__in efx_nic_t *enp,
__in efsys_mem_t *esmp,
- __in uint16_t period,
+ __in uint16_t period_ms,
__in boolean_t events)
{
efx_rc_t rc;
@@ -1844,14 +1845,17 @@ efx_mcdi_mac_stats_periodic(
* The MC DMAs aggregate statistics for our convenience, so we can
* avoid having to pull the statistics buffer into the cache to
* maintain cumulative statistics.
- * Huntington uses a fixed 1sec period, so use that on Siena too.
+ * Huntington uses a fixed 1sec period.
+ * Medford uses a fixed 1sec period before v6.2.1.1033 firmware.
*/
- if (period == 0)
- rc = efx_mcdi_mac_stats(enp, NULL, EFX_STATS_DISABLE);
+ if (period_ms == 0)
+ rc = efx_mcdi_mac_stats(enp, NULL, EFX_STATS_DISABLE, 0);
else if (events)
- rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_ENABLE_EVENTS);
+ rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_ENABLE_EVENTS,
+ period_ms);
else
- rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_ENABLE_NOEVENTS);
+ rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_ENABLE_NOEVENTS,
+ period_ms);
if (rc != 0)
goto fail1;
diff --git a/drivers/net/sfc/base/efx_mcdi.h b/drivers/net/sfc/base/efx_mcdi.h
index 814f3f4..7faabbb 100644
--- a/drivers/net/sfc/base/efx_mcdi.h
+++ b/drivers/net/sfc/base/efx_mcdi.h
@@ -216,7 +216,7 @@ extern __checkReturn efx_rc_t
efx_mcdi_mac_stats_periodic(
__in efx_nic_t *enp,
__in efsys_mem_t *esmp,
- __in uint16_t period,
+ __in uint16_t period_ms,
__in boolean_t events);
--
2.9.3
^ permalink raw reply [flat|nested] 19+ messages in thread
* [dpdk-dev] [PATCH 3/6] net/sfc: add kvarg control for MAC statistics update period
2017-03-02 15:46 [dpdk-dev] [PATCH 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
2017-03-02 15:46 ` [dpdk-dev] [PATCH 1/6] net/sfc: add VFs to the table of PCI IDs for supported NICs Andrew Rybchenko
2017-03-02 15:46 ` [dpdk-dev] [PATCH 2/6] net/sfc/base: don't ignore requested MAC stats update period Andrew Rybchenko
@ 2017-03-02 15:46 ` Andrew Rybchenko
2017-03-02 15:46 ` [dpdk-dev] [PATCH 4/6] net/sfc: port HW stats must work if periodic DMA is absent Andrew Rybchenko
` (3 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Andrew Rybchenko @ 2017-03-02 15:46 UTC (permalink / raw)
To: dev; +Cc: Ivan Malov
From: Ivan Malov <ivan.malov@oktetlabs.ru>
The patch is to make MAC statistics update interval tunable
by means of 'stats_update_period_ms' kvarg parameter making
it possible to use values different from 1000 ms in case of
SFN8xxx boards provided that firmware version is 6.2.1.1033
Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andrew Lee <alee@solarflare.com>
---
doc/guides/nics/sfc_efx.rst | 9 +++++
drivers/net/sfc/sfc.h | 2 ++
drivers/net/sfc/sfc_ethdev.c | 1 +
drivers/net/sfc/sfc_kvargs.c | 20 +++++++++++
drivers/net/sfc/sfc_kvargs.h | 5 +++
drivers/net/sfc/sfc_port.c | 86 +++++++++++++++++++++++++++++++++++++-------
6 files changed, 110 insertions(+), 13 deletions(-)
diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index 0a05a0a..0130290 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -197,3 +197,12 @@ boolean parameters value.
Enable extra logging of the communication with the NIC's management CPU.
The logging is done using RTE_LOG() with INFO level and PMD type.
The format is consumed by the Solarflare netlogdecode cross-platform tool.
+
+- ``stats_update_period_ms`` [long] (default **1000**)
+
+ Adjust period in milliseconds to update port hardware statistics.
+ The accepted range is 0 to 65535. The value of **0** may be used
+ to disable periodic statistics update. One should note that it's
+ only possible to set an arbitrary value on SFN8xxx provided that
+ firmware version is 6.2.1.1033 or higher, otherwise any positive
+ value will select a fixed update period of **1000** milliseconds
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index 8c6c02f..8e094e0 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -153,6 +153,8 @@ struct sfc_port {
rte_spinlock_t mac_stats_lock;
uint64_t *mac_stats_buf;
efsys_mem_t mac_stats_dma_mem;
+ uint16_t mac_stats_update_period_ms;
+ uint32_t mac_stats_update_generation;
uint32_t mac_stats_mask[EFX_MAC_STATS_MASK_NPAGES];
};
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index be19453..07f126f 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -1362,5 +1362,6 @@ RTE_PMD_REGISTER_PCI_TABLE(net_sfc_efx, pci_id_sfc_efx_map);
RTE_PMD_REGISTER_KMOD_DEP(net_sfc_efx, "* igb_uio | uio_pci_generic | vfio");
RTE_PMD_REGISTER_PARAM_STRING(net_sfc_efx,
SFC_KVARG_PERF_PROFILE "=" SFC_KVARG_VALUES_PERF_PROFILE " "
+ SFC_KVARG_STATS_UPDATE_PERIOD_MS "=<long> "
SFC_KVARG_MCDI_LOGGING "=" SFC_KVARG_VALUES_BOOL " "
SFC_KVARG_DEBUG_INIT "=" SFC_KVARG_VALUES_BOOL);
diff --git a/drivers/net/sfc/sfc_kvargs.c b/drivers/net/sfc/sfc_kvargs.c
index 227a8db..60a7ac1 100644
--- a/drivers/net/sfc/sfc_kvargs.c
+++ b/drivers/net/sfc/sfc_kvargs.c
@@ -42,6 +42,7 @@ sfc_kvargs_parse(struct sfc_adapter *sa)
struct rte_eth_dev *eth_dev = (sa)->eth_dev;
struct rte_devargs *devargs = eth_dev->device->devargs;
const char **params = (const char *[]){
+ SFC_KVARG_STATS_UPDATE_PERIOD_MS,
SFC_KVARG_DEBUG_INIT,
SFC_KVARG_MCDI_LOGGING,
SFC_KVARG_PERF_PROFILE,
@@ -110,3 +111,22 @@ sfc_kvarg_bool_handler(__rte_unused const char *key,
return 0;
}
+
+int
+sfc_kvarg_long_handler(__rte_unused const char *key,
+ const char *value_str, void *opaque)
+{
+ long value;
+ char *endptr;
+
+ if (!value_str || !opaque)
+ return -EINVAL;
+
+ value = strtol(value_str, &endptr, 0);
+ if (endptr == value_str)
+ return -EINVAL;
+
+ *(long *)opaque = value;
+
+ return 0;
+}
diff --git a/drivers/net/sfc/sfc_kvargs.h b/drivers/net/sfc/sfc_kvargs.h
index 2fea9c7..6c6003a 100644
--- a/drivers/net/sfc/sfc_kvargs.h
+++ b/drivers/net/sfc/sfc_kvargs.h
@@ -52,6 +52,8 @@ extern "C" {
SFC_KVARG_PERF_PROFILE_THROUGHPUT "|" \
SFC_KVARG_PERF_PROFILE_LOW_LATENCY "]"
+#define SFC_KVARG_STATS_UPDATE_PERIOD_MS "stats_update_period_ms"
+
struct sfc_adapter;
int sfc_kvargs_parse(struct sfc_adapter *sa);
@@ -63,6 +65,9 @@ int sfc_kvargs_process(struct sfc_adapter *sa, const char *key_match,
int sfc_kvarg_bool_handler(const char *key, const char *value_str,
void *opaque);
+int sfc_kvarg_long_handler(const char *key, const char *value_str,
+ void *opaque);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c
index 5998a99..07a61c4 100644
--- a/drivers/net/sfc/sfc_port.c
+++ b/drivers/net/sfc/sfc_port.c
@@ -31,6 +31,16 @@
#include "sfc.h"
#include "sfc_log.h"
+#include "sfc_kvargs.h"
+
+/** Default MAC statistics update period is 1 second */
+#define SFC_MAC_STATS_UPDATE_PERIOD_MS_DEF MS_PER_S
+
+/** The number of microseconds to sleep on attempt to get statistics update */
+#define SFC_MAC_STATS_UPDATE_RETRY_INTERVAL_US 10
+
+/** The number of attempts to await arrival of freshly generated statistics */
+#define SFC_MAC_STATS_UPDATE_NB_ATTEMPTS 50
/**
* Update MAC statistics in the buffer.
@@ -46,6 +56,10 @@ int
sfc_port_update_mac_stats(struct sfc_adapter *sa)
{
struct sfc_port *port = &sa->port;
+ efsys_mem_t *esmp = &port->mac_stats_dma_mem;
+ uint32_t *genp = NULL;
+ uint32_t gen_old;
+ unsigned int nb_attempts = 0;
int rc;
SFC_ASSERT(rte_spinlock_is_locked(&port->mac_stats_lock));
@@ -53,10 +67,27 @@ sfc_port_update_mac_stats(struct sfc_adapter *sa)
if (sa->state != SFC_ADAPTER_STARTED)
return EINVAL;
- rc = efx_mac_stats_update(sa->nic, &port->mac_stats_dma_mem,
- port->mac_stats_buf, NULL);
- if (rc != 0)
- return rc;
+ /* If periodic statistics DMA'ing is off, request explicitly */
+ if (port->mac_stats_update_period_ms == 0) {
+ rc = efx_mac_stats_upload(sa->nic, esmp);
+ if (rc != 0)
+ return rc;
+
+ genp = &port->mac_stats_update_generation;
+ gen_old = *genp;
+ }
+
+ do {
+ if (nb_attempts > 0)
+ rte_delay_us(SFC_MAC_STATS_UPDATE_RETRY_INTERVAL_US);
+
+ rc = efx_mac_stats_update(sa->nic, esmp,
+ port->mac_stats_buf, genp);
+ if (rc != 0)
+ return rc;
+
+ } while ((genp != NULL) && (*genp == gen_old) &&
+ (++nb_attempts < SFC_MAC_STATS_UPDATE_NB_ATTEMPTS));
return 0;
}
@@ -143,15 +174,22 @@ sfc_port_start(struct sfc_adapter *sa)
efx_mac_stats_get_mask(sa->nic, port->mac_stats_mask,
sizeof(port->mac_stats_mask));
- /* Update MAC stats using periodic DMA.
- * Common code always uses 1000ms update period, so period_ms
- * parameter only needs to be non-zero to start updates.
- */
- sfc_log_init(sa, "request MAC stats DMA'ing");
- rc = efx_mac_stats_periodic(sa->nic, &port->mac_stats_dma_mem,
- 1000, B_FALSE);
- if (rc != 0)
- goto fail_mac_stats_periodic;
+ port->mac_stats_update_generation = 0;
+
+ if (port->mac_stats_update_period_ms != 0) {
+ /*
+ * Update MAC stats using periodic DMA;
+ * any positive update interval different from
+ * 1000 ms can be set only on SFN8xxx provided
+ * that FW version is 6.2.1.1033 or higher
+ */
+ sfc_log_init(sa, "request MAC stats DMA'ing");
+ rc = efx_mac_stats_periodic(sa->nic, &port->mac_stats_dma_mem,
+ port->mac_stats_update_period_ms,
+ B_FALSE);
+ if (rc != 0)
+ goto fail_mac_stats_periodic;
+ }
sfc_log_init(sa, "disable MAC drain");
rc = efx_mac_drain(sa->nic, B_FALSE);
@@ -210,6 +248,7 @@ sfc_port_init(struct sfc_adapter *sa)
{
const struct rte_eth_dev_data *dev_data = sa->eth_dev->data;
struct sfc_port *port = &sa->port;
+ long kvarg_stats_update_period_ms;
int rc;
sfc_log_init(sa, "entry");
@@ -237,9 +276,30 @@ sfc_port_init(struct sfc_adapter *sa)
if (rc != 0)
goto fail_mac_stats_dma_alloc;
+ kvarg_stats_update_period_ms = SFC_MAC_STATS_UPDATE_PERIOD_MS_DEF;
+
+ rc = sfc_kvargs_process(sa, SFC_KVARG_STATS_UPDATE_PERIOD_MS,
+ sfc_kvarg_long_handler,
+ &kvarg_stats_update_period_ms);
+ if ((rc == 0) &&
+ ((kvarg_stats_update_period_ms < 0) ||
+ (kvarg_stats_update_period_ms > UINT16_MAX))) {
+ sfc_err(sa, "wrong '" SFC_KVARG_STATS_UPDATE_PERIOD_MS "' "
+ "was set (%ld);", kvarg_stats_update_period_ms);
+ sfc_err(sa, "it must not be less than 0 "
+ "or greater than %" PRIu16, UINT16_MAX);
+ rc = EINVAL;
+ goto fail_kvarg_stats_update_period_ms;
+ } else if (rc != 0) {
+ goto fail_kvarg_stats_update_period_ms;
+ }
+
+ port->mac_stats_update_period_ms = kvarg_stats_update_period_ms;
+
sfc_log_init(sa, "done");
return 0;
+fail_kvarg_stats_update_period_ms:
fail_mac_stats_dma_alloc:
rte_free(port->mac_stats_buf);
fail_mac_stats_buf_alloc:
--
2.9.3
^ permalink raw reply [flat|nested] 19+ messages in thread
* [dpdk-dev] [PATCH 4/6] net/sfc: port HW stats must work if periodic DMA is absent
2017-03-02 15:46 [dpdk-dev] [PATCH 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
` (2 preceding siblings ...)
2017-03-02 15:46 ` [dpdk-dev] [PATCH 3/6] net/sfc: add kvarg control for MAC statistics " Andrew Rybchenko
@ 2017-03-02 15:46 ` Andrew Rybchenko
2017-03-02 15:46 ` [dpdk-dev] [PATCH 5/6] net/sfc: port must not fail to start if Rx mode is rejected Andrew Rybchenko
` (2 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Andrew Rybchenko @ 2017-03-02 15:46 UTC (permalink / raw)
To: dev; +Cc: Ivan Malov
From: Ivan Malov <ivan.malov@oktetlabs.ru>
If periodic DMA statistics feature is absent (particularly,
while running over VF), the PMD must provide an ability to
cope with it using explicit update requests which are kept
restrained according to 'stats_update_period_ms' parameter
Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@solarflare.com>
---
drivers/net/sfc/sfc.h | 9 +++++++++
drivers/net/sfc/sfc_port.c | 27 ++++++++++++++++++++++++---
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index 8e094e0..204a054 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -155,6 +155,8 @@ struct sfc_port {
efsys_mem_t mac_stats_dma_mem;
uint16_t mac_stats_update_period_ms;
uint32_t mac_stats_update_generation;
+ boolean_t mac_stats_periodic_dma_supported;
+ uint64_t mac_stats_last_request_timestamp;
uint32_t mac_stats_mask[EFX_MAC_STATS_MASK_NPAGES];
};
@@ -254,6 +256,13 @@ sfc_adapter_lock_fini(__rte_unused struct sfc_adapter *sa)
/* Just for symmetry of the API */
}
+/** Get the number of milliseconds since boot from the default timer */
+static inline uint64_t
+sfc_get_system_msecs(void)
+{
+ return rte_get_timer_cycles() * MS_PER_S / rte_get_timer_hz();
+}
+
int sfc_dma_alloc(const struct sfc_adapter *sa, const char *name, uint16_t id,
size_t len, int socket_id, efsys_mem_t *esmp);
void sfc_dma_free(const struct sfc_adapter *sa, efsys_mem_t *esmp);
diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c
index 07a61c4..5a9740c 100644
--- a/drivers/net/sfc/sfc_port.c
+++ b/drivers/net/sfc/sfc_port.c
@@ -67,8 +67,23 @@ sfc_port_update_mac_stats(struct sfc_adapter *sa)
if (sa->state != SFC_ADAPTER_STARTED)
return EINVAL;
- /* If periodic statistics DMA'ing is off, request explicitly */
- if (port->mac_stats_update_period_ms == 0) {
+ /*
+ * If periodic statistics DMA'ing is off or if not supported,
+ * make a manual request and keep an eye on timer if need be
+ */
+ if (!port->mac_stats_periodic_dma_supported ||
+ (port->mac_stats_update_period_ms == 0)) {
+ if (port->mac_stats_update_period_ms != 0) {
+ uint64_t timestamp = sfc_get_system_msecs();
+
+ if ((timestamp -
+ port->mac_stats_last_request_timestamp) <
+ port->mac_stats_update_period_ms)
+ return 0;
+
+ port->mac_stats_last_request_timestamp = timestamp;
+ }
+
rc = efx_mac_stats_upload(sa->nic, esmp);
if (rc != 0)
return rc;
@@ -187,8 +202,14 @@ sfc_port_start(struct sfc_adapter *sa)
rc = efx_mac_stats_periodic(sa->nic, &port->mac_stats_dma_mem,
port->mac_stats_update_period_ms,
B_FALSE);
- if (rc != 0)
+ if (rc == 0) {
+ port->mac_stats_periodic_dma_supported = B_TRUE;
+ } else if (rc == EOPNOTSUPP) {
+ port->mac_stats_periodic_dma_supported = B_FALSE;
+ port->mac_stats_last_request_timestamp = 0;
+ } else {
goto fail_mac_stats_periodic;
+ }
}
sfc_log_init(sa, "disable MAC drain");
--
2.9.3
^ permalink raw reply [flat|nested] 19+ messages in thread
* [dpdk-dev] [PATCH 5/6] net/sfc: port must not fail to start if Rx mode is rejected
2017-03-02 15:46 [dpdk-dev] [PATCH 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
` (3 preceding siblings ...)
2017-03-02 15:46 ` [dpdk-dev] [PATCH 4/6] net/sfc: port HW stats must work if periodic DMA is absent Andrew Rybchenko
@ 2017-03-02 15:46 ` Andrew Rybchenko
2017-03-06 10:24 ` Ferruh Yigit
2017-03-02 15:46 ` [dpdk-dev] [PATCH 6/6] net/sfc: add support for MCDI proxy Andrew Rybchenko
2017-03-09 17:22 ` [dpdk-dev] [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
6 siblings, 1 reply; 19+ messages in thread
From: Andrew Rybchenko @ 2017-03-02 15:46 UTC (permalink / raw)
To: dev; +Cc: Ivan Malov
From: Ivan Malov <ivan.malov@oktetlabs.ru>
If Rx mode is unacceptable, in particular, when promiscuous
or all-multicast filters are not allowed while running over
PCI function which is not a member of appropriate privilege
groups, the driver has to cope with the failures gracefully
Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andrew Lee <alee@solarflare.com>
---
drivers/net/sfc/sfc_rx.c | 54 +++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 51 insertions(+), 3 deletions(-)
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index 906536e..0a9fa42 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -401,6 +401,56 @@ sfc_rx_qflush(struct sfc_adapter *sa, unsigned int sw_index)
sfc_rx_qpurge(rxq);
}
+static int
+sfc_rx_default_rxq_set_filter(struct sfc_adapter *sa, struct sfc_rxq *rxq)
+{
+ boolean_t rss = (sa->rss_channels > 1) ? B_TRUE : B_FALSE;
+ struct sfc_port *port = &sa->port;
+ int rc;
+
+ /*
+ * If promiscuous or all-multicast mode has been requested, setting
+ * filter for the default Rx queue might fail, in particular, while
+ * running over PCI function which is not a member of corresponding
+ * privilege groups; if this occurs, few iterations will be made to
+ * repeat this step without promiscuous and all-multicast flags set
+ */
+retry:
+ rc = efx_mac_filter_default_rxq_set(sa->nic, rxq->common, rss);
+ if (rc == 0)
+ return 0;
+ else if (rc != EOPNOTSUPP)
+ return rc;
+
+ if (port->promisc) {
+ sfc_warn(sa, "promiscuous mode has been requested, "
+ "but the HW rejects it");
+ sfc_warn(sa, "promiscuous mode will be disabled");
+
+ port->promisc = B_FALSE;
+ rc = sfc_set_rx_mode(sa);
+ if (rc != 0)
+ return rc;
+
+ goto retry;
+ }
+
+ if (port->allmulti) {
+ sfc_warn(sa, "all-multicast mode has been requested, "
+ "but the HW rejects it");
+ sfc_warn(sa, "all-multicast mode will be disabled");
+
+ port->allmulti = B_FALSE;
+ rc = sfc_set_rx_mode(sa);
+ if (rc != 0)
+ return rc;
+
+ goto retry;
+ }
+
+ return rc;
+}
+
int
sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index)
{
@@ -439,9 +489,7 @@ sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index)
sfc_rx_qrefill(rxq);
if (sw_index == 0) {
- rc = efx_mac_filter_default_rxq_set(sa->nic, rxq->common,
- (sa->rss_channels > 1) ?
- B_TRUE : B_FALSE);
+ rc = sfc_rx_default_rxq_set_filter(sa, rxq);
if (rc != 0)
goto fail_mac_filter_default_rxq_set;
}
--
2.9.3
^ permalink raw reply [flat|nested] 19+ messages in thread
* [dpdk-dev] [PATCH 6/6] net/sfc: add support for MCDI proxy
2017-03-02 15:46 [dpdk-dev] [PATCH 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
` (4 preceding siblings ...)
2017-03-02 15:46 ` [dpdk-dev] [PATCH 5/6] net/sfc: port must not fail to start if Rx mode is rejected Andrew Rybchenko
@ 2017-03-02 15:46 ` Andrew Rybchenko
2017-03-09 17:22 ` [dpdk-dev] [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
6 siblings, 0 replies; 19+ messages in thread
From: Andrew Rybchenko @ 2017-03-02 15:46 UTC (permalink / raw)
To: dev; +Cc: Ivan Malov
From: Ivan Malov <ivan.malov@oktetlabs.ru>
The patch is to add support for MCDI proxy which comes in
useful, particularly, while running over VF: few commands
will normally fail with EPERM, but in some cases the host
driver (i.e. running over the corresponding PF, typically,
within a hypervisor) may set itself as a proxy to conduct
authorization for the commands coming from VFs; these are
forwarded to the corresponding access control application
which may decline or approve authorization by replying to
the requests; all in all, the guest driver has to process
the replies forwarded back by the firmware MC in order to
give up gracefully (by setting return code which could be
understood by 'libefx') or re-issue the original commands
Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
drivers/net/sfc/efsys.h | 2 +-
drivers/net/sfc/sfc.h | 2 ++
drivers/net/sfc/sfc_mcdi.c | 74 ++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 71 insertions(+), 7 deletions(-)
diff --git a/drivers/net/sfc/efsys.h b/drivers/net/sfc/efsys.h
index 60829be..d52552b 100644
--- a/drivers/net/sfc/efsys.h
+++ b/drivers/net/sfc/efsys.h
@@ -177,7 +177,7 @@ prefetch_read_once(const volatile void *addr)
/* MCDI is required for SFN7xxx and SFN8xx */
#define EFSYS_OPT_MCDI 1
#define EFSYS_OPT_MCDI_LOGGING 1
-#define EFSYS_OPT_MCDI_PROXY_AUTH 0
+#define EFSYS_OPT_MCDI_PROXY_AUTH 1
#define EFSYS_OPT_MAC_STATS 1
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index 204a054..5c633c8 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -125,6 +125,8 @@ struct sfc_mcdi {
enum sfc_mcdi_state state;
efx_mcdi_transport_t transport;
bool logging;
+ uint32_t proxy_handle;
+ efx_rc_t proxy_result;
};
struct sfc_intr {
diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 3bed2e0..43dbf13 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -36,6 +36,7 @@
#include "sfc.h"
#include "sfc_log.h"
#include "sfc_kvargs.h"
+#include "sfc_ev.h"
#define SFC_MCDI_POLL_INTERVAL_MIN_US 10 /* 10us in 1us units */
#define SFC_MCDI_POLL_INTERVAL_MAX_US (US_PER_S / 10) /* 100ms in 1us units */
@@ -49,8 +50,22 @@ sfc_mcdi_timeout(struct sfc_adapter *sa)
sfc_panic(sa, "MCDI timeout handling is not implemented\n");
}
+static inline boolean_t
+sfc_mcdi_proxy_event_available(struct sfc_adapter *sa)
+{
+ struct sfc_mcdi *mcdi = &sa->mcdi;
+
+ mcdi->proxy_handle = 0;
+ mcdi->proxy_result = ETIMEDOUT;
+ sfc_ev_mgmt_qpoll(sa);
+ if (mcdi->proxy_result != ETIMEDOUT)
+ return B_TRUE;
+
+ return B_FALSE;
+}
+
static void
-sfc_mcdi_poll(struct sfc_adapter *sa)
+sfc_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
{
efx_nic_t *enp;
unsigned int delay_total;
@@ -62,13 +77,20 @@ sfc_mcdi_poll(struct sfc_adapter *sa)
enp = sa->nic;
do {
- if (efx_mcdi_request_poll(enp))
+ boolean_t poll_completed;
+
+ poll_completed = (proxy) ? sfc_mcdi_proxy_event_available(sa) :
+ efx_mcdi_request_poll(enp);
+ if (poll_completed)
return;
if (delay_total > SFC_MCDI_WATCHDOG_INTERVAL_US) {
- aborted = efx_mcdi_request_abort(enp);
- SFC_ASSERT(aborted);
- sfc_mcdi_timeout(sa);
+ if (!proxy) {
+ aborted = efx_mcdi_request_abort(enp);
+ SFC_ASSERT(aborted);
+ sfc_mcdi_timeout(sa);
+ }
+
return;
}
@@ -90,13 +112,42 @@ sfc_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
{
struct sfc_adapter *sa = (struct sfc_adapter *)arg;
struct sfc_mcdi *mcdi = &sa->mcdi;
+ uint32_t proxy_handle;
rte_spinlock_lock(&mcdi->lock);
SFC_ASSERT(mcdi->state == SFC_MCDI_INITIALIZED);
efx_mcdi_request_start(sa->nic, emrp, B_FALSE);
- sfc_mcdi_poll(sa);
+ sfc_mcdi_poll(sa, B_FALSE);
+
+ if (efx_mcdi_get_proxy_handle(sa->nic, emrp, &proxy_handle) == 0) {
+ /*
+ * Authorization is required for the MCDI request;
+ * wait for an MCDI proxy response event to bring
+ * a non-zero proxy handle (should be the same as
+ * the value obtained above) and operation status
+ */
+ sfc_mcdi_poll(sa, B_TRUE);
+
+ if ((mcdi->proxy_handle != 0) &&
+ (mcdi->proxy_handle != proxy_handle)) {
+ sfc_err(sa, "Unexpected MCDI proxy event");
+ emrp->emr_rc = EFAULT;
+ } else if (mcdi->proxy_result == 0) {
+ /*
+ * Authorization succeeded; re-issue the original
+ * request and poll for an ordinary MCDI response
+ */
+ efx_mcdi_request_start(sa->nic, emrp, B_FALSE);
+ sfc_mcdi_poll(sa, B_FALSE);
+ } else {
+ emrp->emr_rc = mcdi->proxy_result;
+ sfc_err(sa, "MCDI proxy authorization failed "
+ "(handle=%08x, result=%d)",
+ proxy_handle, mcdi->proxy_result);
+ }
+ }
rte_spinlock_unlock(&mcdi->lock);
}
@@ -185,6 +236,16 @@ sfc_mcdi_logger(void *arg, efx_log_msg_t type,
}
}
+static void
+sfc_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
+{
+ struct sfc_adapter *sa = (struct sfc_adapter *)arg;
+ struct sfc_mcdi *mcdi = &sa->mcdi;
+
+ mcdi->proxy_handle = handle;
+ mcdi->proxy_result = result;
+}
+
int
sfc_mcdi_init(struct sfc_adapter *sa)
{
@@ -222,6 +283,7 @@ sfc_mcdi_init(struct sfc_adapter *sa)
emtp->emt_ev_cpl = sfc_mcdi_ev_cpl;
emtp->emt_exception = sfc_mcdi_exception;
emtp->emt_logger = sfc_mcdi_logger;
+ emtp->emt_ev_proxy_response = sfc_mcdi_ev_proxy_response;
sfc_log_init(sa, "init MCDI");
rc = efx_mcdi_init(sa->nic, emtp);
--
2.9.3
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [dpdk-dev] [PATCH 1/6] net/sfc: add VFs to the table of PCI IDs for supported NICs
2017-03-02 15:46 ` [dpdk-dev] [PATCH 1/6] net/sfc: add VFs to the table of PCI IDs for supported NICs Andrew Rybchenko
@ 2017-03-06 10:10 ` Ferruh Yigit
2017-03-06 14:00 ` Andrew Rybchenko
0 siblings, 1 reply; 19+ messages in thread
From: Ferruh Yigit @ 2017-03-06 10:10 UTC (permalink / raw)
To: Andrew Rybchenko, dev; +Cc: Ivan Malov
On 3/2/2017 3:46 PM, Andrew Rybchenko wrote:
> From: Ivan Malov <ivan.malov@oktetlabs.ru>
>
> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> Reviewed-by: Andrew Lee <alee@solarflare.com>
> ---
> drivers/net/sfc/sfc_ethdev.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
> index 71587fb..be19453 100644
> --- a/drivers/net/sfc/sfc_ethdev.c
> +++ b/drivers/net/sfc/sfc_ethdev.c
> @@ -1335,8 +1335,11 @@ sfc_eth_dev_uninit(struct rte_eth_dev *dev)
>
> static const struct rte_pci_id pci_id_sfc_efx_map[] = {
> { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_FARMINGDALE) },
> + { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_FARMINGDALE_VF) },
Since driver now support VF devices, it is possible to set "SR-IOV"
feature enabled in sfc_efx.ini.
> { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_GREENPORT) },
> + { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_GREENPORT_VF) },
> { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_MEDFORD) },
> + { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_MEDFORD_VF) },
> { .vendor_id = 0 /* sentinel */ }
> };
>
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [dpdk-dev] [PATCH 5/6] net/sfc: port must not fail to start if Rx mode is rejected
2017-03-02 15:46 ` [dpdk-dev] [PATCH 5/6] net/sfc: port must not fail to start if Rx mode is rejected Andrew Rybchenko
@ 2017-03-06 10:24 ` Ferruh Yigit
0 siblings, 0 replies; 19+ messages in thread
From: Ferruh Yigit @ 2017-03-06 10:24 UTC (permalink / raw)
To: Andrew Rybchenko, dev; +Cc: Ivan Malov
On 3/2/2017 3:46 PM, Andrew Rybchenko wrote:
> From: Ivan Malov <ivan.malov@oktetlabs.ru>
Hi Ivan,
Can you please update patch title to indicate what has been done,
starting with a verb. It is harder to understand patch content from
statements.
Thanks,
ferruh
>
> If Rx mode is unacceptable, in particular, when promiscuous
> or all-multicast filters are not allowed while running over
> PCI function which is not a member of appropriate privilege
> groups, the driver has to cope with the failures gracefully
>
> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> Reviewed-by: Andrew Lee <alee@solarflare.com>
<...>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [dpdk-dev] [PATCH 1/6] net/sfc: add VFs to the table of PCI IDs for supported NICs
2017-03-06 10:10 ` Ferruh Yigit
@ 2017-03-06 14:00 ` Andrew Rybchenko
0 siblings, 0 replies; 19+ messages in thread
From: Andrew Rybchenko @ 2017-03-06 14:00 UTC (permalink / raw)
To: Ferruh Yigit, dev; +Cc: Ivan Malov
On 03/06/2017 01:10 PM, Ferruh Yigit wrote:
> On 3/2/2017 3:46 PM, Andrew Rybchenko wrote:
>> From: Ivan Malov <ivan.malov@oktetlabs.ru>
>>
>> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
>> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
>> Reviewed-by: Andrew Lee <alee@solarflare.com>
>> ---
>> drivers/net/sfc/sfc_ethdev.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
>> index 71587fb..be19453 100644
>> --- a/drivers/net/sfc/sfc_ethdev.c
>> +++ b/drivers/net/sfc/sfc_ethdev.c
>> @@ -1335,8 +1335,11 @@ sfc_eth_dev_uninit(struct rte_eth_dev *dev)
>>
>> static const struct rte_pci_id pci_id_sfc_efx_map[] = {
>> { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_FARMINGDALE) },
>> + { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_FARMINGDALE_VF) },
> Since driver now support VF devices, it is possible to set "SR-IOV"
> feature enabled in sfc_efx.ini.
Thanks a lot. We will add the feature.
>> { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_GREENPORT) },
>> + { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_GREENPORT_VF) },
>> { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_MEDFORD) },
>> + { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_MEDFORD_VF) },
>> { .vendor_id = 0 /* sentinel */ }
>> };
^ permalink raw reply [flat|nested] 19+ messages in thread
* [dpdk-dev] [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs
2017-03-02 15:46 [dpdk-dev] [PATCH 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
` (5 preceding siblings ...)
2017-03-02 15:46 ` [dpdk-dev] [PATCH 6/6] net/sfc: add support for MCDI proxy Andrew Rybchenko
@ 2017-03-09 17:22 ` Andrew Rybchenko
2017-03-09 17:22 ` [dpdk-dev] [PATCH v2 1/6] net/sfc/base: don't ignore requested MAC stats update period Andrew Rybchenko
` (6 more replies)
6 siblings, 7 replies; 19+ messages in thread
From: Andrew Rybchenko @ 2017-03-09 17:22 UTC (permalink / raw)
To: dev; +Cc: Ferruh Yigit
Running Solarflare PMD over PCI virtual functions requires few fixes:
- periodic MAC stats DMA is not supported for VFs
- promiscious and all-multicast modes may be denied by FW/PF
- MCDI proxy authorization made by FW should be properly handled by
the VF driver
v1 -> v2
* rephrase git logs
* add release notes
* add SR-IOV feature to the driver list
* reorder patches to advertise VF support when it works
Andrew Rybchenko (1):
net/sfc/base: don't ignore requested MAC stats update period
Ivan Malov (5):
net/sfc: add kvarg control for MAC statistics update period
net/sfc: poll MAC stats if periodic DMA is not supported
net/sfc: avoid failure on port start if Rx mode is rejected
net/sfc: add support for MCDI proxy
net/sfc: add VFs to the table of PCI IDs for supported NICs
doc/guides/nics/features/sfc_efx.ini | 1 +
doc/guides/nics/sfc_efx.rst | 9 +++
doc/guides/rel_notes/release_17_05.rst | 4 ++
drivers/net/sfc/base/efx_mcdi.c | 24 +++++---
drivers/net/sfc/base/efx_mcdi.h | 2 +-
drivers/net/sfc/efsys.h | 2 +-
drivers/net/sfc/sfc.h | 13 ++++
drivers/net/sfc/sfc_ethdev.c | 4 ++
drivers/net/sfc/sfc_kvargs.c | 20 ++++++
drivers/net/sfc/sfc_kvargs.h | 5 ++
drivers/net/sfc/sfc_mcdi.c | 74 +++++++++++++++++++++--
drivers/net/sfc/sfc_port.c | 107 +++++++++++++++++++++++++++++----
drivers/net/sfc/sfc_rx.c | 54 ++++++++++++++++-
13 files changed, 285 insertions(+), 34 deletions(-)
--
2.9.3
^ permalink raw reply [flat|nested] 19+ messages in thread
* [dpdk-dev] [PATCH v2 1/6] net/sfc/base: don't ignore requested MAC stats update period
2017-03-09 17:22 ` [dpdk-dev] [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
@ 2017-03-09 17:22 ` Andrew Rybchenko
2017-03-09 17:22 ` [dpdk-dev] [PATCH v2 2/6] net/sfc: add kvarg control for MAC statistics " Andrew Rybchenko
` (5 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Andrew Rybchenko @ 2017-03-09 17:22 UTC (permalink / raw)
To: dev; +Cc: Ferruh Yigit
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
drivers/net/sfc/base/efx_mcdi.c | 24 ++++++++++++++----------
drivers/net/sfc/base/efx_mcdi.h | 2 +-
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/drivers/net/sfc/base/efx_mcdi.c b/drivers/net/sfc/base/efx_mcdi.c
index ac432a6..c9d29a7 100644
--- a/drivers/net/sfc/base/efx_mcdi.c
+++ b/drivers/net/sfc/base/efx_mcdi.c
@@ -1722,7 +1722,8 @@ static __checkReturn efx_rc_t
efx_mcdi_mac_stats(
__in efx_nic_t *enp,
__in_opt efsys_mem_t *esmp,
- __in efx_stats_action_t action)
+ __in efx_stats_action_t action,
+ __in uint16_t period_ms)
{
efx_mcdi_req_t req;
uint8_t payload[MAX(MC_CMD_MAC_STATS_IN_LEN,
@@ -1747,7 +1748,7 @@ efx_mcdi_mac_stats(
MAC_STATS_IN_PERIODIC_CHANGE, enable | events | disable,
MAC_STATS_IN_PERIODIC_ENABLE, enable | events,
MAC_STATS_IN_PERIODIC_NOEVENT, !events,
- MAC_STATS_IN_PERIOD_MS, (enable | events) ? 1000 : 0);
+ MAC_STATS_IN_PERIOD_MS, (enable | events) ? period_ms : 0);
if (esmp != NULL) {
int bytes = MC_CMD_MAC_NSTATS * sizeof (uint64_t);
@@ -1797,7 +1798,7 @@ efx_mcdi_mac_stats_clear(
{
efx_rc_t rc;
- if ((rc = efx_mcdi_mac_stats(enp, NULL, EFX_STATS_CLEAR)) != 0)
+ if ((rc = efx_mcdi_mac_stats(enp, NULL, EFX_STATS_CLEAR, 0)) != 0)
goto fail1;
return (0);
@@ -1820,7 +1821,7 @@ efx_mcdi_mac_stats_upload(
* avoid having to pull the statistics buffer into the cache to
* maintain cumulative statistics.
*/
- if ((rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_UPLOAD)) != 0)
+ if ((rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_UPLOAD, 0)) != 0)
goto fail1;
return (0);
@@ -1835,7 +1836,7 @@ efx_mcdi_mac_stats_upload(
efx_mcdi_mac_stats_periodic(
__in efx_nic_t *enp,
__in efsys_mem_t *esmp,
- __in uint16_t period,
+ __in uint16_t period_ms,
__in boolean_t events)
{
efx_rc_t rc;
@@ -1844,14 +1845,17 @@ efx_mcdi_mac_stats_periodic(
* The MC DMAs aggregate statistics for our convenience, so we can
* avoid having to pull the statistics buffer into the cache to
* maintain cumulative statistics.
- * Huntington uses a fixed 1sec period, so use that on Siena too.
+ * Huntington uses a fixed 1sec period.
+ * Medford uses a fixed 1sec period before v6.2.1.1033 firmware.
*/
- if (period == 0)
- rc = efx_mcdi_mac_stats(enp, NULL, EFX_STATS_DISABLE);
+ if (period_ms == 0)
+ rc = efx_mcdi_mac_stats(enp, NULL, EFX_STATS_DISABLE, 0);
else if (events)
- rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_ENABLE_EVENTS);
+ rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_ENABLE_EVENTS,
+ period_ms);
else
- rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_ENABLE_NOEVENTS);
+ rc = efx_mcdi_mac_stats(enp, esmp, EFX_STATS_ENABLE_NOEVENTS,
+ period_ms);
if (rc != 0)
goto fail1;
diff --git a/drivers/net/sfc/base/efx_mcdi.h b/drivers/net/sfc/base/efx_mcdi.h
index 814f3f4..7faabbb 100644
--- a/drivers/net/sfc/base/efx_mcdi.h
+++ b/drivers/net/sfc/base/efx_mcdi.h
@@ -216,7 +216,7 @@ extern __checkReturn efx_rc_t
efx_mcdi_mac_stats_periodic(
__in efx_nic_t *enp,
__in efsys_mem_t *esmp,
- __in uint16_t period,
+ __in uint16_t period_ms,
__in boolean_t events);
--
2.9.3
^ permalink raw reply [flat|nested] 19+ messages in thread
* [dpdk-dev] [PATCH v2 2/6] net/sfc: add kvarg control for MAC statistics update period
2017-03-09 17:22 ` [dpdk-dev] [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
2017-03-09 17:22 ` [dpdk-dev] [PATCH v2 1/6] net/sfc/base: don't ignore requested MAC stats update period Andrew Rybchenko
@ 2017-03-09 17:22 ` Andrew Rybchenko
2017-03-09 17:23 ` [dpdk-dev] [PATCH v2 3/6] net/sfc: poll MAC stats if periodic DMA is not supported Andrew Rybchenko
` (4 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Andrew Rybchenko @ 2017-03-09 17:22 UTC (permalink / raw)
To: dev; +Cc: Ferruh Yigit, Ivan Malov
From: Ivan Malov <ivan.malov@oktetlabs.ru>
The patch is to make MAC statistics update interval tunable
by means of 'stats_update_period_ms' kvarg parameter making
it possible to use values different from 1000 ms in case of
SFN8xxx boards provided that firmware version is 6.2.1.1033
Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andrew Lee <alee@solarflare.com>
---
doc/guides/nics/sfc_efx.rst | 9 +++++
drivers/net/sfc/sfc.h | 2 ++
drivers/net/sfc/sfc_ethdev.c | 1 +
drivers/net/sfc/sfc_kvargs.c | 20 +++++++++++
drivers/net/sfc/sfc_kvargs.h | 5 +++
drivers/net/sfc/sfc_port.c | 86 +++++++++++++++++++++++++++++++++++++-------
6 files changed, 110 insertions(+), 13 deletions(-)
diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index 0a05a0a..0130290 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -197,3 +197,12 @@ boolean parameters value.
Enable extra logging of the communication with the NIC's management CPU.
The logging is done using RTE_LOG() with INFO level and PMD type.
The format is consumed by the Solarflare netlogdecode cross-platform tool.
+
+- ``stats_update_period_ms`` [long] (default **1000**)
+
+ Adjust period in milliseconds to update port hardware statistics.
+ The accepted range is 0 to 65535. The value of **0** may be used
+ to disable periodic statistics update. One should note that it's
+ only possible to set an arbitrary value on SFN8xxx provided that
+ firmware version is 6.2.1.1033 or higher, otherwise any positive
+ value will select a fixed update period of **1000** milliseconds
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index 655328f..f634f92 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -154,6 +154,8 @@ struct sfc_port {
uint64_t *mac_stats_buf;
efsys_mem_t mac_stats_dma_mem;
boolean_t mac_stats_reset_pending;
+ uint16_t mac_stats_update_period_ms;
+ uint32_t mac_stats_update_generation;
uint32_t mac_stats_mask[EFX_MAC_STATS_MASK_NPAGES];
};
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index cac01ac..4115454 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -1382,5 +1382,6 @@ RTE_PMD_REGISTER_PCI_TABLE(net_sfc_efx, pci_id_sfc_efx_map);
RTE_PMD_REGISTER_KMOD_DEP(net_sfc_efx, "* igb_uio | uio_pci_generic | vfio");
RTE_PMD_REGISTER_PARAM_STRING(net_sfc_efx,
SFC_KVARG_PERF_PROFILE "=" SFC_KVARG_VALUES_PERF_PROFILE " "
+ SFC_KVARG_STATS_UPDATE_PERIOD_MS "=<long> "
SFC_KVARG_MCDI_LOGGING "=" SFC_KVARG_VALUES_BOOL " "
SFC_KVARG_DEBUG_INIT "=" SFC_KVARG_VALUES_BOOL);
diff --git a/drivers/net/sfc/sfc_kvargs.c b/drivers/net/sfc/sfc_kvargs.c
index 227a8db..60a7ac1 100644
--- a/drivers/net/sfc/sfc_kvargs.c
+++ b/drivers/net/sfc/sfc_kvargs.c
@@ -42,6 +42,7 @@ sfc_kvargs_parse(struct sfc_adapter *sa)
struct rte_eth_dev *eth_dev = (sa)->eth_dev;
struct rte_devargs *devargs = eth_dev->device->devargs;
const char **params = (const char *[]){
+ SFC_KVARG_STATS_UPDATE_PERIOD_MS,
SFC_KVARG_DEBUG_INIT,
SFC_KVARG_MCDI_LOGGING,
SFC_KVARG_PERF_PROFILE,
@@ -110,3 +111,22 @@ sfc_kvarg_bool_handler(__rte_unused const char *key,
return 0;
}
+
+int
+sfc_kvarg_long_handler(__rte_unused const char *key,
+ const char *value_str, void *opaque)
+{
+ long value;
+ char *endptr;
+
+ if (!value_str || !opaque)
+ return -EINVAL;
+
+ value = strtol(value_str, &endptr, 0);
+ if (endptr == value_str)
+ return -EINVAL;
+
+ *(long *)opaque = value;
+
+ return 0;
+}
diff --git a/drivers/net/sfc/sfc_kvargs.h b/drivers/net/sfc/sfc_kvargs.h
index 2fea9c7..6c6003a 100644
--- a/drivers/net/sfc/sfc_kvargs.h
+++ b/drivers/net/sfc/sfc_kvargs.h
@@ -52,6 +52,8 @@ extern "C" {
SFC_KVARG_PERF_PROFILE_THROUGHPUT "|" \
SFC_KVARG_PERF_PROFILE_LOW_LATENCY "]"
+#define SFC_KVARG_STATS_UPDATE_PERIOD_MS "stats_update_period_ms"
+
struct sfc_adapter;
int sfc_kvargs_parse(struct sfc_adapter *sa);
@@ -63,6 +65,9 @@ int sfc_kvargs_process(struct sfc_adapter *sa, const char *key_match,
int sfc_kvarg_bool_handler(const char *key, const char *value_str,
void *opaque);
+int sfc_kvarg_long_handler(const char *key, const char *value_str,
+ void *opaque);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c
index e2f5043..84dde76 100644
--- a/drivers/net/sfc/sfc_port.c
+++ b/drivers/net/sfc/sfc_port.c
@@ -31,6 +31,16 @@
#include "sfc.h"
#include "sfc_log.h"
+#include "sfc_kvargs.h"
+
+/** Default MAC statistics update period is 1 second */
+#define SFC_MAC_STATS_UPDATE_PERIOD_MS_DEF MS_PER_S
+
+/** The number of microseconds to sleep on attempt to get statistics update */
+#define SFC_MAC_STATS_UPDATE_RETRY_INTERVAL_US 10
+
+/** The number of attempts to await arrival of freshly generated statistics */
+#define SFC_MAC_STATS_UPDATE_NB_ATTEMPTS 50
/**
* Update MAC statistics in the buffer.
@@ -46,6 +56,10 @@ int
sfc_port_update_mac_stats(struct sfc_adapter *sa)
{
struct sfc_port *port = &sa->port;
+ efsys_mem_t *esmp = &port->mac_stats_dma_mem;
+ uint32_t *genp = NULL;
+ uint32_t gen_old;
+ unsigned int nb_attempts = 0;
int rc;
SFC_ASSERT(rte_spinlock_is_locked(&port->mac_stats_lock));
@@ -53,10 +67,27 @@ sfc_port_update_mac_stats(struct sfc_adapter *sa)
if (sa->state != SFC_ADAPTER_STARTED)
return EINVAL;
- rc = efx_mac_stats_update(sa->nic, &port->mac_stats_dma_mem,
- port->mac_stats_buf, NULL);
- if (rc != 0)
- return rc;
+ /* If periodic statistics DMA'ing is off, request explicitly */
+ if (port->mac_stats_update_period_ms == 0) {
+ rc = efx_mac_stats_upload(sa->nic, esmp);
+ if (rc != 0)
+ return rc;
+
+ genp = &port->mac_stats_update_generation;
+ gen_old = *genp;
+ }
+
+ do {
+ if (nb_attempts > 0)
+ rte_delay_us(SFC_MAC_STATS_UPDATE_RETRY_INTERVAL_US);
+
+ rc = efx_mac_stats_update(sa->nic, esmp,
+ port->mac_stats_buf, genp);
+ if (rc != 0)
+ return rc;
+
+ } while ((genp != NULL) && (*genp == gen_old) &&
+ (++nb_attempts < SFC_MAC_STATS_UPDATE_NB_ATTEMPTS));
return 0;
}
@@ -165,15 +196,22 @@ sfc_port_start(struct sfc_adapter *sa)
efx_mac_stats_get_mask(sa->nic, port->mac_stats_mask,
sizeof(port->mac_stats_mask));
- /* Update MAC stats using periodic DMA.
- * Common code always uses 1000ms update period, so period_ms
- * parameter only needs to be non-zero to start updates.
- */
- sfc_log_init(sa, "request MAC stats DMA'ing");
- rc = efx_mac_stats_periodic(sa->nic, &port->mac_stats_dma_mem,
- 1000, B_FALSE);
- if (rc != 0)
- goto fail_mac_stats_periodic;
+ port->mac_stats_update_generation = 0;
+
+ if (port->mac_stats_update_period_ms != 0) {
+ /*
+ * Update MAC stats using periodic DMA;
+ * any positive update interval different from
+ * 1000 ms can be set only on SFN8xxx provided
+ * that FW version is 6.2.1.1033 or higher
+ */
+ sfc_log_init(sa, "request MAC stats DMA'ing");
+ rc = efx_mac_stats_periodic(sa->nic, &port->mac_stats_dma_mem,
+ port->mac_stats_update_period_ms,
+ B_FALSE);
+ if (rc != 0)
+ goto fail_mac_stats_periodic;
+ }
sfc_log_init(sa, "disable MAC drain");
rc = efx_mac_drain(sa->nic, B_FALSE);
@@ -232,6 +270,7 @@ sfc_port_init(struct sfc_adapter *sa)
{
const struct rte_eth_dev_data *dev_data = sa->eth_dev->data;
struct sfc_port *port = &sa->port;
+ long kvarg_stats_update_period_ms;
int rc;
sfc_log_init(sa, "entry");
@@ -261,9 +300,30 @@ sfc_port_init(struct sfc_adapter *sa)
port->mac_stats_reset_pending = B_FALSE;
+ kvarg_stats_update_period_ms = SFC_MAC_STATS_UPDATE_PERIOD_MS_DEF;
+
+ rc = sfc_kvargs_process(sa, SFC_KVARG_STATS_UPDATE_PERIOD_MS,
+ sfc_kvarg_long_handler,
+ &kvarg_stats_update_period_ms);
+ if ((rc == 0) &&
+ ((kvarg_stats_update_period_ms < 0) ||
+ (kvarg_stats_update_period_ms > UINT16_MAX))) {
+ sfc_err(sa, "wrong '" SFC_KVARG_STATS_UPDATE_PERIOD_MS "' "
+ "was set (%ld);", kvarg_stats_update_period_ms);
+ sfc_err(sa, "it must not be less than 0 "
+ "or greater than %" PRIu16, UINT16_MAX);
+ rc = EINVAL;
+ goto fail_kvarg_stats_update_period_ms;
+ } else if (rc != 0) {
+ goto fail_kvarg_stats_update_period_ms;
+ }
+
+ port->mac_stats_update_period_ms = kvarg_stats_update_period_ms;
+
sfc_log_init(sa, "done");
return 0;
+fail_kvarg_stats_update_period_ms:
fail_mac_stats_dma_alloc:
rte_free(port->mac_stats_buf);
fail_mac_stats_buf_alloc:
--
2.9.3
^ permalink raw reply [flat|nested] 19+ messages in thread
* [dpdk-dev] [PATCH v2 3/6] net/sfc: poll MAC stats if periodic DMA is not supported
2017-03-09 17:22 ` [dpdk-dev] [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
2017-03-09 17:22 ` [dpdk-dev] [PATCH v2 1/6] net/sfc/base: don't ignore requested MAC stats update period Andrew Rybchenko
2017-03-09 17:22 ` [dpdk-dev] [PATCH v2 2/6] net/sfc: add kvarg control for MAC statistics " Andrew Rybchenko
@ 2017-03-09 17:23 ` Andrew Rybchenko
2017-03-09 17:23 ` [dpdk-dev] [PATCH v2 4/6] net/sfc: avoid failure on port start if Rx mode is rejected Andrew Rybchenko
` (3 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Andrew Rybchenko @ 2017-03-09 17:23 UTC (permalink / raw)
To: dev; +Cc: Ferruh Yigit, Ivan Malov
From: Ivan Malov <ivan.malov@oktetlabs.ru>
If periodic DMA statistics feature is absent (particularly,
while running over VF), the PMD must provide an ability to
cope with it using explicit update requests which are kept
restrained according to 'stats_update_period_ms' parameter
Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@solarflare.com>
---
drivers/net/sfc/sfc.h | 9 +++++++++
drivers/net/sfc/sfc_port.c | 27 ++++++++++++++++++++++++---
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index f634f92..96cd38c 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -156,6 +156,8 @@ struct sfc_port {
boolean_t mac_stats_reset_pending;
uint16_t mac_stats_update_period_ms;
uint32_t mac_stats_update_generation;
+ boolean_t mac_stats_periodic_dma_supported;
+ uint64_t mac_stats_last_request_timestamp;
uint32_t mac_stats_mask[EFX_MAC_STATS_MASK_NPAGES];
};
@@ -255,6 +257,13 @@ sfc_adapter_lock_fini(__rte_unused struct sfc_adapter *sa)
/* Just for symmetry of the API */
}
+/** Get the number of milliseconds since boot from the default timer */
+static inline uint64_t
+sfc_get_system_msecs(void)
+{
+ return rte_get_timer_cycles() * MS_PER_S / rte_get_timer_hz();
+}
+
int sfc_dma_alloc(const struct sfc_adapter *sa, const char *name, uint16_t id,
size_t len, int socket_id, efsys_mem_t *esmp);
void sfc_dma_free(const struct sfc_adapter *sa, efsys_mem_t *esmp);
diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c
index 84dde76..2276131 100644
--- a/drivers/net/sfc/sfc_port.c
+++ b/drivers/net/sfc/sfc_port.c
@@ -67,8 +67,23 @@ sfc_port_update_mac_stats(struct sfc_adapter *sa)
if (sa->state != SFC_ADAPTER_STARTED)
return EINVAL;
- /* If periodic statistics DMA'ing is off, request explicitly */
- if (port->mac_stats_update_period_ms == 0) {
+ /*
+ * If periodic statistics DMA'ing is off or if not supported,
+ * make a manual request and keep an eye on timer if need be
+ */
+ if (!port->mac_stats_periodic_dma_supported ||
+ (port->mac_stats_update_period_ms == 0)) {
+ if (port->mac_stats_update_period_ms != 0) {
+ uint64_t timestamp = sfc_get_system_msecs();
+
+ if ((timestamp -
+ port->mac_stats_last_request_timestamp) <
+ port->mac_stats_update_period_ms)
+ return 0;
+
+ port->mac_stats_last_request_timestamp = timestamp;
+ }
+
rc = efx_mac_stats_upload(sa->nic, esmp);
if (rc != 0)
return rc;
@@ -209,8 +224,14 @@ sfc_port_start(struct sfc_adapter *sa)
rc = efx_mac_stats_periodic(sa->nic, &port->mac_stats_dma_mem,
port->mac_stats_update_period_ms,
B_FALSE);
- if (rc != 0)
+ if (rc == 0) {
+ port->mac_stats_periodic_dma_supported = B_TRUE;
+ } else if (rc == EOPNOTSUPP) {
+ port->mac_stats_periodic_dma_supported = B_FALSE;
+ port->mac_stats_last_request_timestamp = 0;
+ } else {
goto fail_mac_stats_periodic;
+ }
}
sfc_log_init(sa, "disable MAC drain");
--
2.9.3
^ permalink raw reply [flat|nested] 19+ messages in thread
* [dpdk-dev] [PATCH v2 4/6] net/sfc: avoid failure on port start if Rx mode is rejected
2017-03-09 17:22 ` [dpdk-dev] [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
` (2 preceding siblings ...)
2017-03-09 17:23 ` [dpdk-dev] [PATCH v2 3/6] net/sfc: poll MAC stats if periodic DMA is not supported Andrew Rybchenko
@ 2017-03-09 17:23 ` Andrew Rybchenko
2017-03-09 17:23 ` [dpdk-dev] [PATCH v2 5/6] net/sfc: add support for MCDI proxy Andrew Rybchenko
` (2 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Andrew Rybchenko @ 2017-03-09 17:23 UTC (permalink / raw)
To: dev; +Cc: Ferruh Yigit, Ivan Malov
From: Ivan Malov <ivan.malov@oktetlabs.ru>
If Rx mode is unacceptable, in particular, when promiscuous
or all-multicast filters are not allowed while running over
PCI function which is not a member of appropriate privilege
groups, the driver has to cope with the failures gracefully
Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andrew Lee <alee@solarflare.com>
---
drivers/net/sfc/sfc_rx.c | 54 +++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 51 insertions(+), 3 deletions(-)
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index 906536e..0a9fa42 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -401,6 +401,56 @@ sfc_rx_qflush(struct sfc_adapter *sa, unsigned int sw_index)
sfc_rx_qpurge(rxq);
}
+static int
+sfc_rx_default_rxq_set_filter(struct sfc_adapter *sa, struct sfc_rxq *rxq)
+{
+ boolean_t rss = (sa->rss_channels > 1) ? B_TRUE : B_FALSE;
+ struct sfc_port *port = &sa->port;
+ int rc;
+
+ /*
+ * If promiscuous or all-multicast mode has been requested, setting
+ * filter for the default Rx queue might fail, in particular, while
+ * running over PCI function which is not a member of corresponding
+ * privilege groups; if this occurs, few iterations will be made to
+ * repeat this step without promiscuous and all-multicast flags set
+ */
+retry:
+ rc = efx_mac_filter_default_rxq_set(sa->nic, rxq->common, rss);
+ if (rc == 0)
+ return 0;
+ else if (rc != EOPNOTSUPP)
+ return rc;
+
+ if (port->promisc) {
+ sfc_warn(sa, "promiscuous mode has been requested, "
+ "but the HW rejects it");
+ sfc_warn(sa, "promiscuous mode will be disabled");
+
+ port->promisc = B_FALSE;
+ rc = sfc_set_rx_mode(sa);
+ if (rc != 0)
+ return rc;
+
+ goto retry;
+ }
+
+ if (port->allmulti) {
+ sfc_warn(sa, "all-multicast mode has been requested, "
+ "but the HW rejects it");
+ sfc_warn(sa, "all-multicast mode will be disabled");
+
+ port->allmulti = B_FALSE;
+ rc = sfc_set_rx_mode(sa);
+ if (rc != 0)
+ return rc;
+
+ goto retry;
+ }
+
+ return rc;
+}
+
int
sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index)
{
@@ -439,9 +489,7 @@ sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index)
sfc_rx_qrefill(rxq);
if (sw_index == 0) {
- rc = efx_mac_filter_default_rxq_set(sa->nic, rxq->common,
- (sa->rss_channels > 1) ?
- B_TRUE : B_FALSE);
+ rc = sfc_rx_default_rxq_set_filter(sa, rxq);
if (rc != 0)
goto fail_mac_filter_default_rxq_set;
}
--
2.9.3
^ permalink raw reply [flat|nested] 19+ messages in thread
* [dpdk-dev] [PATCH v2 5/6] net/sfc: add support for MCDI proxy
2017-03-09 17:22 ` [dpdk-dev] [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
` (3 preceding siblings ...)
2017-03-09 17:23 ` [dpdk-dev] [PATCH v2 4/6] net/sfc: avoid failure on port start if Rx mode is rejected Andrew Rybchenko
@ 2017-03-09 17:23 ` Andrew Rybchenko
2017-03-15 11:13 ` Ferruh Yigit
2017-03-09 17:23 ` [dpdk-dev] [PATCH v2 6/6] net/sfc: add VFs to the table of PCI IDs for supported NICs Andrew Rybchenko
2017-03-15 11:11 ` [dpdk-dev] [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs Ferruh Yigit
6 siblings, 1 reply; 19+ messages in thread
From: Andrew Rybchenko @ 2017-03-09 17:23 UTC (permalink / raw)
To: dev; +Cc: Ferruh Yigit, Ivan Malov
From: Ivan Malov <ivan.malov@oktetlabs.ru>
The patch is to add support for MCDI proxy which comes in
useful, particularly, while running over VF: few commands
will normally fail with EPERM, but in some cases the host
driver (i.e. running over the corresponding PF, typically,
within a hypervisor) may set itself as a proxy to conduct
authorization for the commands coming from VFs; these are
forwarded to the corresponding access control application
which may decline or approve authorization by replying to
the requests; all in all, the guest driver has to process
the replies forwarded back by the firmware MC in order to
give up gracefully (by setting return code which could be
understood by 'libefx') or re-issue the original commands
Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@solarflare.com>
---
drivers/net/sfc/efsys.h | 2 +-
drivers/net/sfc/sfc.h | 2 ++
drivers/net/sfc/sfc_mcdi.c | 74 ++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 71 insertions(+), 7 deletions(-)
diff --git a/drivers/net/sfc/efsys.h b/drivers/net/sfc/efsys.h
index 60829be..d52552b 100644
--- a/drivers/net/sfc/efsys.h
+++ b/drivers/net/sfc/efsys.h
@@ -177,7 +177,7 @@ prefetch_read_once(const volatile void *addr)
/* MCDI is required for SFN7xxx and SFN8xx */
#define EFSYS_OPT_MCDI 1
#define EFSYS_OPT_MCDI_LOGGING 1
-#define EFSYS_OPT_MCDI_PROXY_AUTH 0
+#define EFSYS_OPT_MCDI_PROXY_AUTH 1
#define EFSYS_OPT_MAC_STATS 1
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index 96cd38c..114bf95 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -125,6 +125,8 @@ struct sfc_mcdi {
enum sfc_mcdi_state state;
efx_mcdi_transport_t transport;
bool logging;
+ uint32_t proxy_handle;
+ efx_rc_t proxy_result;
};
struct sfc_intr {
diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 3bed2e0..43dbf13 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -36,6 +36,7 @@
#include "sfc.h"
#include "sfc_log.h"
#include "sfc_kvargs.h"
+#include "sfc_ev.h"
#define SFC_MCDI_POLL_INTERVAL_MIN_US 10 /* 10us in 1us units */
#define SFC_MCDI_POLL_INTERVAL_MAX_US (US_PER_S / 10) /* 100ms in 1us units */
@@ -49,8 +50,22 @@ sfc_mcdi_timeout(struct sfc_adapter *sa)
sfc_panic(sa, "MCDI timeout handling is not implemented\n");
}
+static inline boolean_t
+sfc_mcdi_proxy_event_available(struct sfc_adapter *sa)
+{
+ struct sfc_mcdi *mcdi = &sa->mcdi;
+
+ mcdi->proxy_handle = 0;
+ mcdi->proxy_result = ETIMEDOUT;
+ sfc_ev_mgmt_qpoll(sa);
+ if (mcdi->proxy_result != ETIMEDOUT)
+ return B_TRUE;
+
+ return B_FALSE;
+}
+
static void
-sfc_mcdi_poll(struct sfc_adapter *sa)
+sfc_mcdi_poll(struct sfc_adapter *sa, boolean_t proxy)
{
efx_nic_t *enp;
unsigned int delay_total;
@@ -62,13 +77,20 @@ sfc_mcdi_poll(struct sfc_adapter *sa)
enp = sa->nic;
do {
- if (efx_mcdi_request_poll(enp))
+ boolean_t poll_completed;
+
+ poll_completed = (proxy) ? sfc_mcdi_proxy_event_available(sa) :
+ efx_mcdi_request_poll(enp);
+ if (poll_completed)
return;
if (delay_total > SFC_MCDI_WATCHDOG_INTERVAL_US) {
- aborted = efx_mcdi_request_abort(enp);
- SFC_ASSERT(aborted);
- sfc_mcdi_timeout(sa);
+ if (!proxy) {
+ aborted = efx_mcdi_request_abort(enp);
+ SFC_ASSERT(aborted);
+ sfc_mcdi_timeout(sa);
+ }
+
return;
}
@@ -90,13 +112,42 @@ sfc_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
{
struct sfc_adapter *sa = (struct sfc_adapter *)arg;
struct sfc_mcdi *mcdi = &sa->mcdi;
+ uint32_t proxy_handle;
rte_spinlock_lock(&mcdi->lock);
SFC_ASSERT(mcdi->state == SFC_MCDI_INITIALIZED);
efx_mcdi_request_start(sa->nic, emrp, B_FALSE);
- sfc_mcdi_poll(sa);
+ sfc_mcdi_poll(sa, B_FALSE);
+
+ if (efx_mcdi_get_proxy_handle(sa->nic, emrp, &proxy_handle) == 0) {
+ /*
+ * Authorization is required for the MCDI request;
+ * wait for an MCDI proxy response event to bring
+ * a non-zero proxy handle (should be the same as
+ * the value obtained above) and operation status
+ */
+ sfc_mcdi_poll(sa, B_TRUE);
+
+ if ((mcdi->proxy_handle != 0) &&
+ (mcdi->proxy_handle != proxy_handle)) {
+ sfc_err(sa, "Unexpected MCDI proxy event");
+ emrp->emr_rc = EFAULT;
+ } else if (mcdi->proxy_result == 0) {
+ /*
+ * Authorization succeeded; re-issue the original
+ * request and poll for an ordinary MCDI response
+ */
+ efx_mcdi_request_start(sa->nic, emrp, B_FALSE);
+ sfc_mcdi_poll(sa, B_FALSE);
+ } else {
+ emrp->emr_rc = mcdi->proxy_result;
+ sfc_err(sa, "MCDI proxy authorization failed "
+ "(handle=%08x, result=%d)",
+ proxy_handle, mcdi->proxy_result);
+ }
+ }
rte_spinlock_unlock(&mcdi->lock);
}
@@ -185,6 +236,16 @@ sfc_mcdi_logger(void *arg, efx_log_msg_t type,
}
}
+static void
+sfc_mcdi_ev_proxy_response(void *arg, uint32_t handle, efx_rc_t result)
+{
+ struct sfc_adapter *sa = (struct sfc_adapter *)arg;
+ struct sfc_mcdi *mcdi = &sa->mcdi;
+
+ mcdi->proxy_handle = handle;
+ mcdi->proxy_result = result;
+}
+
int
sfc_mcdi_init(struct sfc_adapter *sa)
{
@@ -222,6 +283,7 @@ sfc_mcdi_init(struct sfc_adapter *sa)
emtp->emt_ev_cpl = sfc_mcdi_ev_cpl;
emtp->emt_exception = sfc_mcdi_exception;
emtp->emt_logger = sfc_mcdi_logger;
+ emtp->emt_ev_proxy_response = sfc_mcdi_ev_proxy_response;
sfc_log_init(sa, "init MCDI");
rc = efx_mcdi_init(sa->nic, emtp);
--
2.9.3
^ permalink raw reply [flat|nested] 19+ messages in thread
* [dpdk-dev] [PATCH v2 6/6] net/sfc: add VFs to the table of PCI IDs for supported NICs
2017-03-09 17:22 ` [dpdk-dev] [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
` (4 preceding siblings ...)
2017-03-09 17:23 ` [dpdk-dev] [PATCH v2 5/6] net/sfc: add support for MCDI proxy Andrew Rybchenko
@ 2017-03-09 17:23 ` Andrew Rybchenko
2017-03-15 11:11 ` [dpdk-dev] [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs Ferruh Yigit
6 siblings, 0 replies; 19+ messages in thread
From: Andrew Rybchenko @ 2017-03-09 17:23 UTC (permalink / raw)
To: dev; +Cc: Ferruh Yigit, Ivan Malov
From: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andrew Lee <alee@solarflare.com>
---
doc/guides/nics/features/sfc_efx.ini | 1 +
doc/guides/rel_notes/release_17_05.rst | 4 ++++
drivers/net/sfc/sfc_ethdev.c | 3 +++
3 files changed, 8 insertions(+)
diff --git a/doc/guides/nics/features/sfc_efx.ini b/doc/guides/nics/features/sfc_efx.ini
index 3a15baa..e811395 100644
--- a/doc/guides/nics/features/sfc_efx.ini
+++ b/doc/guides/nics/features/sfc_efx.ini
@@ -18,6 +18,7 @@ Multicast MAC filter = Y
RSS hash = Y
RSS key update = Y
RSS reta update = Y
+SR-IOV = Y
Flow control = Y
VLAN offload = P
L3 checksum offload = Y
diff --git a/doc/guides/rel_notes/release_17_05.rst b/doc/guides/rel_notes/release_17_05.rst
index 123eeb4..5ae8d97 100644
--- a/doc/guides/rel_notes/release_17_05.rst
+++ b/doc/guides/rel_notes/release_17_05.rst
@@ -64,6 +64,10 @@ New Features
performance enhancements viz. configurable TX data ring, Receive
Data Ring, ability to register memory regions.
+* **Updated the sfc_efx driver.**
+
+ * Support virtual functions (VFs)
+
Resolved Issues
---------------
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 4115454..240e87d 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -1358,8 +1358,11 @@ sfc_eth_dev_uninit(struct rte_eth_dev *dev)
static const struct rte_pci_id pci_id_sfc_efx_map[] = {
{ RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_FARMINGDALE) },
+ { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_FARMINGDALE_VF) },
{ RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_GREENPORT) },
+ { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_GREENPORT_VF) },
{ RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_MEDFORD) },
+ { RTE_PCI_DEVICE(EFX_PCI_VENID_SFC, EFX_PCI_DEVID_MEDFORD_VF) },
{ .vendor_id = 0 /* sentinel */ }
};
--
2.9.3
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [dpdk-dev] [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs
2017-03-09 17:22 ` [dpdk-dev] [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
` (5 preceding siblings ...)
2017-03-09 17:23 ` [dpdk-dev] [PATCH v2 6/6] net/sfc: add VFs to the table of PCI IDs for supported NICs Andrew Rybchenko
@ 2017-03-15 11:11 ` Ferruh Yigit
6 siblings, 0 replies; 19+ messages in thread
From: Ferruh Yigit @ 2017-03-15 11:11 UTC (permalink / raw)
To: Andrew Rybchenko, dev
On 3/9/2017 5:22 PM, Andrew Rybchenko wrote:
> Running Solarflare PMD over PCI virtual functions requires few fixes:
> - periodic MAC stats DMA is not supported for VFs
> - promiscious and all-multicast modes may be denied by FW/PF
> - MCDI proxy authorization made by FW should be properly handled by
> the VF driver
>
> v1 -> v2
> * rephrase git logs
> * add release notes
> * add SR-IOV feature to the driver list
> * reorder patches to advertise VF support when it works
>
> Andrew Rybchenko (1):
> net/sfc/base: don't ignore requested MAC stats update period
>
> Ivan Malov (5):
> net/sfc: add kvarg control for MAC statistics update period
> net/sfc: poll MAC stats if periodic DMA is not supported
> net/sfc: avoid failure on port start if Rx mode is rejected
> net/sfc: add support for MCDI proxy
> net/sfc: add VFs to the table of PCI IDs for supported NICs
Series applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [dpdk-dev] [PATCH v2 5/6] net/sfc: add support for MCDI proxy
2017-03-09 17:23 ` [dpdk-dev] [PATCH v2 5/6] net/sfc: add support for MCDI proxy Andrew Rybchenko
@ 2017-03-15 11:13 ` Ferruh Yigit
0 siblings, 0 replies; 19+ messages in thread
From: Ferruh Yigit @ 2017-03-15 11:13 UTC (permalink / raw)
To: Andrew Rybchenko, dev; +Cc: Ivan Malov
On 3/9/2017 5:23 PM, Andrew Rybchenko wrote:
> From: Ivan Malov <ivan.malov@oktetlabs.ru>
>
> The patch is to add support for MCDI proxy which comes in
> useful, particularly, while running over VF: few commands
> will normally fail with EPERM, but in some cases the host
> driver (i.e. running over the corresponding PF, typically,
> within a hypervisor) may set itself as a proxy to conduct
> authorization for the commands coming from VFs; these are
> forwarded to the corresponding access control application
> which may decline or approve authorization by replying to
> the requests; all in all, the guest driver has to process
> the replies forwarded back by the firmware MC in order to
> give up gracefully (by setting return code which could be
> understood by 'libefx') or re-issue the original commands
Hi Andrew, Ivan,
I noticed that all lines in the commit log end in same column,
interestingly this is true for other patches in this patchset [1],
is this mere coincidence or is there a poetic effort here :)
Thanks for the patches,
ferruh
[1]
If Rx mode is unacceptable, in particular, when promiscuous
or all-multicast filters are not allowed while running over
PCI function which is not a member of appropriate privilege
groups, the driver has to cope with the failures gracefully
...
If periodic DMA statistics feature is absent (particularly,
while running over VF), the PMD must provide an ability to
cope with it using explicit update requests which are kept
restrained according to 'stats_update_period_ms' parameter
...
The patch is to make MAC statistics update interval tunable
by means of 'stats_update_period_ms' kvarg parameter making
it possible to use values different from 1000 ms in case of
SFN8xxx boards provided that firmware version is 6.2.1.1033
>
> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> Reviewed-by: Andy Moreton <amoreton@solarflare.com>
<...>
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2017-03-15 11:13 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-02 15:46 [dpdk-dev] [PATCH 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
2017-03-02 15:46 ` [dpdk-dev] [PATCH 1/6] net/sfc: add VFs to the table of PCI IDs for supported NICs Andrew Rybchenko
2017-03-06 10:10 ` Ferruh Yigit
2017-03-06 14:00 ` Andrew Rybchenko
2017-03-02 15:46 ` [dpdk-dev] [PATCH 2/6] net/sfc/base: don't ignore requested MAC stats update period Andrew Rybchenko
2017-03-02 15:46 ` [dpdk-dev] [PATCH 3/6] net/sfc: add kvarg control for MAC statistics " Andrew Rybchenko
2017-03-02 15:46 ` [dpdk-dev] [PATCH 4/6] net/sfc: port HW stats must work if periodic DMA is absent Andrew Rybchenko
2017-03-02 15:46 ` [dpdk-dev] [PATCH 5/6] net/sfc: port must not fail to start if Rx mode is rejected Andrew Rybchenko
2017-03-06 10:24 ` Ferruh Yigit
2017-03-02 15:46 ` [dpdk-dev] [PATCH 6/6] net/sfc: add support for MCDI proxy Andrew Rybchenko
2017-03-09 17:22 ` [dpdk-dev] [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
2017-03-09 17:22 ` [dpdk-dev] [PATCH v2 1/6] net/sfc/base: don't ignore requested MAC stats update period Andrew Rybchenko
2017-03-09 17:22 ` [dpdk-dev] [PATCH v2 2/6] net/sfc: add kvarg control for MAC statistics " Andrew Rybchenko
2017-03-09 17:23 ` [dpdk-dev] [PATCH v2 3/6] net/sfc: poll MAC stats if periodic DMA is not supported Andrew Rybchenko
2017-03-09 17:23 ` [dpdk-dev] [PATCH v2 4/6] net/sfc: avoid failure on port start if Rx mode is rejected Andrew Rybchenko
2017-03-09 17:23 ` [dpdk-dev] [PATCH v2 5/6] net/sfc: add support for MCDI proxy Andrew Rybchenko
2017-03-15 11:13 ` Ferruh Yigit
2017-03-09 17:23 ` [dpdk-dev] [PATCH v2 6/6] net/sfc: add VFs to the table of PCI IDs for supported NICs Andrew Rybchenko
2017-03-15 11:11 ` [dpdk-dev] [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs Ferruh Yigit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).