From dcc3285f07368775740c376d3907b78ac8e5c77c Mon Sep 17 00:00:00 2001 From: Andrew Rybchenko Date: Tue, 29 Nov 2016 16:19:19 +0000 Subject: [PATCH] net/sfc: validate Rx queue buffers setup Check that Rx mbuf pool, MTU and Rx scatter config are in sync. Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton Reviewed-by: Ferruh Yigit --- doc/guides/nics/sfc_efx.rst | 10 ++++++++++ drivers/net/sfc/sfc_rx.c | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst index 87b217f847..8145a6bd3e 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/sfc_rx.c b/drivers/net/sfc/sfc_rx.c index 0a37776242..a6b9aeafff 100644 --- a/drivers/net/sfc/sfc_rx.c +++ b/drivers/net/sfc/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; } -- 2.20.1