net/sfc: check for maximum number of Rx scatter buffers
authorIgor Romanov <igor.romanov@oktetlabs.ru>
Tue, 13 Oct 2020 13:45:24 +0000 (14:45 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 16 Oct 2020 17:48:17 +0000 (19:48 +0200)
Update generic code to check that MTU and Rx buffer sizes
do not result in more Rx scatter segments than NIC can make.

Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
drivers/net/sfc/sfc_ethdev.c
drivers/net/sfc/sfc_rx.c
drivers/net/sfc/sfc_rx.h

index f41d0f5..ca1b99a 100644 (file)
@@ -954,7 +954,8 @@ sfc_check_scatter_on_all_rx_queues(struct sfc_adapter *sa, size_t pdu)
 
                if (!sfc_rx_check_scatter(pdu, sa->rxq_ctrl[i].buf_size,
                                          encp->enc_rx_prefix_size,
-                                         scatter_enabled, &error)) {
+                                         scatter_enabled,
+                                         encp->enc_rx_scatter_max, &error)) {
                        sfc_err(sa, "MTU check for RxQ %u failed: %s", i,
                                error);
                        return EINVAL;
index 3e5c8e4..7c50fe5 100644 (file)
@@ -378,10 +378,20 @@ sfc_efx_rx_qdesc_status(struct sfc_dp_rxq *dp_rxq, uint16_t offset)
 
 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)
+                    boolean_t rx_scatter_enabled, uint32_t rx_scatter_max,
+                    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";
+       uint32_t effective_rx_scatter_max;
+       uint32_t rx_scatter_bufs;
+
+       effective_rx_scatter_max = rx_scatter_enabled ? rx_scatter_max : 1;
+       rx_scatter_bufs = EFX_DIV_ROUND_UP(pdu + rx_prefix_size, rx_buf_size);
+
+       if (rx_scatter_bufs > effective_rx_scatter_max) {
+               if (rx_scatter_enabled)
+                       *error = "Possible number of Rx scatter buffers exceeds maximum number";
+               else
+                       *error = "Rx scatter is disabled and RxQ mbuf pool object size is too small";
                return B_FALSE;
        }
 
@@ -1084,6 +1094,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
        if (!sfc_rx_check_scatter(sa->port.pdu, buf_size,
                                  encp->enc_rx_prefix_size,
                                  (offloads & DEV_RX_OFFLOAD_SCATTER),
+                                 encp->enc_rx_scatter_max,
                                  &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 "
index b0b5327..d6ee9cf 100644 (file)
@@ -147,6 +147,7 @@ uint64_t sfc_rx_hf_efx_to_rte(struct sfc_rss *rss, 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,
+                              uint32_t rx_scatter_max,
                               const char **error);
 
 #ifdef __cplusplus