patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH 18.11] net/sfc: fix MTU change to check Rx scatter consistency
@ 2019-05-14 11:57 Andrew Rybchenko
  2019-05-15  9:25 ` Kevin Traynor
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Rybchenko @ 2019-05-14 11:57 UTC (permalink / raw)
  To: Kevin Traynor; +Cc: stable, Igor Romanov

From: Igor Romanov <igor.romanov@oktetlabs.ru>

[ backported from upstream commit 6c0cc77a2dd3806c5366586d818b1796a610e260 ]

Rx queue setup function checks configured MTU to make sure that
no oversized packets can be received. But a following call to
set MTU function might make this check irrelevant.

Add a function to check MTU size against Rx buffer size and
additional Rx queue info, including Rx scatter offload.

Fixes: e961cf425e02 ("net/sfc: support MTU change")

Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/sfc/sfc_ethdev.c | 33 +++++++++++++++++++++++++++++++++
 drivers/net/sfc/sfc_rx.c     | 22 ++++++++++++++++++----
 drivers/net/sfc/sfc_rx.h     |  4 ++++
 3 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 83dd088..052d38c 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -860,6 +860,33 @@
 }
 
 static int
+sfc_check_scatter_on_all_rx_queues(struct sfc_adapter *sa, size_t pdu)
+{
+	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	boolean_t scatter_enabled;
+	const char *error;
+	unsigned int i;
+
+	for (i = 0; i < sa->rxq_count; i++) {
+		if ((sa->rxq_info[i].rxq->state & SFC_RXQ_INITIALIZED) == 0)
+			continue;
+
+		scatter_enabled = (sa->rxq_info[i].type_flags &
+				   EFX_RXQ_FLAG_SCATTER);
+
+		if (!sfc_rx_check_scatter(pdu, sa->rxq_info[i].rxq->buf_size,
+					  encp->enc_rx_prefix_size,
+					  scatter_enabled, &error)) {
+			sfc_err(sa, "MTU check for RxQ %u failed: %s", i,
+				error);
+			return EINVAL;
+		}
+	}
+
+	return 0;
+}
+
+static int
 sfc_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
 {
 	struct sfc_adapter *sa = dev->data->dev_private;
@@ -885,6 +912,10 @@
 
 	sfc_adapter_lock(sa);
 
+	rc = sfc_check_scatter_on_all_rx_queues(sa, pdu);
+	if (rc != 0)
+		goto fail_check_scatter;
+
 	if (pdu != sa->port.pdu) {
 		if (sa->state == SFC_ADAPTER_STARTED) {
 			sfc_stop(sa);
@@ -921,6 +952,8 @@
 		sfc_err(sa, "cannot start with neither new (%u) nor old (%u) "
 			"PDU max size - port is stopped",
 			(unsigned int)pdu, (unsigned int)old_pdu);
+
+fail_check_scatter:
 	sfc_adapter_unlock(sa);
 
 fail_inval:
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index c792e0b..a78d35a 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -360,6 +360,18 @@
 	return RTE_ETH_RX_DESC_UNAVAIL;
 }
 
+boolean_t
+sfc_rx_check_scatter(size_t pdu, size_t rx_buf_size, uint32_t rx_prefix_size,
+		     boolean_t rx_scatter_enabled, const char **error)
+{
+	if ((rx_buf_size < pdu + rx_prefix_size) && !rx_scatter_enabled) {
+		*error = "Rx scatter is disabled and RxQ mbuf pool object size is too small";
+		return B_FALSE;
+	}
+
+	return B_TRUE;
+}
+
 struct sfc_rxq *
 sfc_rxq_by_dp_rxq(const struct sfc_dp_rxq *dp_rxq)
 {
@@ -964,6 +976,7 @@ struct sfc_dp_rx sfc_efx_rx = {
 	struct sfc_evq *evq;
 	struct sfc_rxq *rxq;
 	struct sfc_dp_rx_qcreate_info info;
+	const char *error;
 
 	rc = sa->dp_rx->qsize_up_rings(nb_rx_desc, mb_pool, &rxq_entries,
 				       &evq_entries, &rxq_max_fill_level);
@@ -987,10 +1000,11 @@ struct sfc_dp_rx sfc_efx_rx = {
 		goto fail_bad_conf;
 	}
 
-	if ((buf_size < sa->port.pdu + encp->enc_rx_prefix_size) &&
-	    (~offloads & DEV_RX_OFFLOAD_SCATTER)) {
-		sfc_err(sa, "Rx scatter is disabled and RxQ %u mbuf pool "
-			"object size is too small", sw_index);
+	if (!sfc_rx_check_scatter(sa->port.pdu, buf_size,
+				  encp->enc_rx_prefix_size,
+				  (offloads & DEV_RX_OFFLOAD_SCATTER),
+				  &error)) {
+		sfc_err(sa, "RxQ %u MTU check failed: %s", sw_index, error);
 		sfc_err(sa, "RxQ %u calculated Rx buffer size is %u vs "
 			"PDU size %u plus Rx prefix %u bytes",
 			sw_index, buf_size, (unsigned int)sa->port.pdu,
diff --git a/drivers/net/sfc/sfc_rx.h b/drivers/net/sfc/sfc_rx.h
index 3fba7d8..65724b0 100644
--- a/drivers/net/sfc/sfc_rx.h
+++ b/drivers/net/sfc/sfc_rx.h
@@ -159,6 +159,10 @@ int sfc_rx_hf_rte_to_efx(struct sfc_adapter *sa, uint64_t rte,
 			 efx_rx_hash_type_t *efx);
 uint64_t sfc_rx_hf_efx_to_rte(struct sfc_adapter *sa,
 			      efx_rx_hash_type_t efx);
+boolean_t sfc_rx_check_scatter(size_t pdu, size_t rx_buf_size,
+			       uint32_t rx_prefix_size,
+			       boolean_t rx_scatter_enabled,
+			       const char **error);
 
 #ifdef __cplusplus
 }
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-stable] [PATCH 18.11] net/sfc: fix MTU change to check Rx scatter consistency
  2019-05-14 11:57 [dpdk-stable] [PATCH 18.11] net/sfc: fix MTU change to check Rx scatter consistency Andrew Rybchenko
@ 2019-05-15  9:25 ` Kevin Traynor
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Traynor @ 2019-05-15  9:25 UTC (permalink / raw)
  To: Andrew Rybchenko; +Cc: stable, Igor Romanov

On 14/05/2019 12:57, Andrew Rybchenko wrote:
> From: Igor Romanov <igor.romanov@oktetlabs.ru>
> 
> [ backported from upstream commit 6c0cc77a2dd3806c5366586d818b1796a610e260 ]
> 
> Rx queue setup function checks configured MTU to make sure that
> no oversized packets can be received. But a following call to
> set MTU function might make this check irrelevant.
> 
> Add a function to check MTU size against Rx buffer size and
> additional Rx queue info, including Rx scatter offload.
> 
> Fixes: e961cf425e02 ("net/sfc: support MTU change")
> 
> Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>

Thanks Andrew, added into the queue to be pushed next Monday.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-15  9:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-14 11:57 [dpdk-stable] [PATCH 18.11] net/sfc: fix MTU change to check Rx scatter consistency Andrew Rybchenko
2019-05-15  9:25 ` Kevin Traynor

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).