net/sfc: validate Rx queue buffers setup
authorAndrew Rybchenko <arybchenko@solarflare.com>
Tue, 29 Nov 2016 16:19:19 +0000 (16:19 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 17 Jan 2017 18:39:26 +0000 (19:39 +0100)
Check that Rx mbuf pool, MTU and Rx scatter config are in sync.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@solarflare.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
doc/guides/nics/sfc_efx.rst
drivers/net/sfc/sfc_rx.c

index 87b217f..8145a6b 100644 (file)
@@ -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
 --------------
 
index 0a37776..a6b9aea 100644 (file)
@@ -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;
        }