[dpdk-dev,48/56] net/sfc: validate Rx queue buffers setup

Message ID 1479740470-6723-49-git-send-email-arybchenko@solarflare.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
checkpatch/checkpatch success coding style OK

Commit Message

Andrew Rybchenko Nov. 21, 2016, 3:01 p.m. UTC
  Check that Rx mbuf pool, MTU and Rx scatter config are in sync.

Reviewed-by: Andy Moreton <amoreton@solarflare.com>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 doc/guides/nics/sfc_efx.rst  | 10 ++++++++++
 drivers/net/sfc/efx/sfc_rx.c | 14 ++++++++++++++
 2 files changed, 24 insertions(+)
  

Patch

diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index 87b217f8..8145a6b 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -73,6 +73,16 @@  The features not yet supported include:
 - LRO
 
 
+Limitations
+-----------
+
+Due to requirements on receive buffer alignment and usage of the receive
+buffer for the auxiliary packet information provided by the NIC up to
+extra 269 (14 bytes prefix plus up to 255 bytes for end padding) bytes may be
+required in the receive buffer.
+It should be taken into account when mbuf pool for receive is created.
+
+
 Supported NICs
 --------------
 
diff --git a/drivers/net/sfc/efx/sfc_rx.c b/drivers/net/sfc/efx/sfc_rx.c
index bfe92bf..0e1e399 100644
--- a/drivers/net/sfc/efx/sfc_rx.c
+++ b/drivers/net/sfc/efx/sfc_rx.c
@@ -172,6 +172,7 @@  sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 	     const struct rte_eth_rxconf *rx_conf,
 	     struct rte_mempool *mb_pool)
 {
+	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
 	int rc;
 	uint16_t buf_size;
 	struct sfc_rxq_info *rxq_info;
@@ -187,6 +188,19 @@  sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 	if (buf_size == 0) {
 		sfc_err(sa, "RxQ %u mbuf pool object size is too small",
 			sw_index);
+		rc = EINVAL;
+		goto fail_bad_conf;
+	}
+
+	if ((buf_size < sa->port.pdu + encp->enc_rx_prefix_size) &&
+	    !sa->eth_dev->data->dev_conf.rxmode.enable_scatter) {
+		sfc_err(sa, "Rx scatter is disabled and RxQ %u mbuf pool "
+			"object size is too small", sw_index);
+		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,
+			encp->enc_rx_prefix_size);
+		rc = EINVAL;
 		goto fail_bad_conf;
 	}