ethdev: add maximum LRO packet size
authorDekel Peled <dekelp@mellanox.com>
Mon, 11 Nov 2019 17:47:33 +0000 (19:47 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 12 Nov 2019 00:43:01 +0000 (01:43 +0100)
This patch implements API for configuration and
validation of max size for LRO aggregated packet.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Matan Azrad <matan@mellanox.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
doc/guides/nics/features.rst
doc/guides/rel_notes/deprecation.rst
doc/guides/rel_notes/release_19_11.rst
lib/librte_ethdev/rte_ethdev.c
lib/librte_ethdev/rte_ethdev.h

index b200e72..8394a65 100644 (file)
@@ -193,10 +193,12 @@ LRO
 Supports Large Receive Offload.
 
 * **[uses]       rte_eth_rxconf,rte_eth_rxmode**: ``offloads:DEV_RX_OFFLOAD_TCP_LRO``.
+  ``dev_conf.rxmode.max_lro_pkt_size``.
 * **[implements] datapath**: ``LRO functionality``.
 * **[implements] rte_eth_dev_data**: ``lro``.
 * **[provides]   mbuf**: ``mbuf.ol_flags:PKT_RX_LRO``, ``mbuf.tso_segsz``.
 * **[provides]   rte_eth_dev_info**: ``rx_offload_capa,rx_queue_offload_capa:DEV_RX_OFFLOAD_TCP_LRO``.
+* **[provides]   rte_eth_dev_info**: ``max_lro_pkt_size``.
 
 
 .. _nic_features_tso:
index fad208b..dbfb059 100644 (file)
@@ -83,10 +83,6 @@ Deprecation Notices
   This scheme will allow PMDs to avoid lookup to internal ptype table on Rx and
   thereby improve Rx performance if application wishes do so.
 
-* ethdev: New 32-bit fields may be added for maximum LRO session size, in
-  struct ``rte_eth_dev_info`` for the port capability and in struct
-  ``rte_eth_rxmode`` for the port configuration.
-
 * cryptodev: support for using IV with all sizes is added, J0 still can
   be used but only when IV length in following structs ``rte_crypto_auth_xform``,
   ``rte_crypto_aead_xform`` is set to zero. When IV length is greater or equal
index 0d04b8d..682c1bd 100644 (file)
@@ -460,6 +460,14 @@ ABI Changes
 * ipsec: The field ``replay_win_sz`` has been removed from the structure
   ``rte_ipsec_sa_prm`` as it has been added to the security library.
 
+* ethdev: Added 32-bit fields for maximum LRO aggregated packet size, in
+  struct ``rte_eth_dev_info`` for the port capability and in struct
+  ``rte_eth_rxmode`` for the port configuration.
+  Application should use the new field in struct ``rte_eth_rxmode`` to configure
+  the requested size.
+  PMD should use the new field in struct ``rte_eth_dev_info`` to report the
+  supported port capability.
+
 
 Shared Library Versions
 -----------------------
index bebd522..c43f9f5 100644 (file)
@@ -1137,6 +1137,33 @@ rte_eth_dev_tx_offload_name(uint64_t offload)
        return name;
 }
 
+static inline int
+check_lro_pkt_size(uint16_t port_id, uint32_t config_size,
+                  uint32_t max_rx_pkt_len, uint32_t dev_info_size)
+{
+       int ret = 0;
+
+       if (dev_info_size == 0) {
+               if (config_size != max_rx_pkt_len) {
+                       RTE_ETHDEV_LOG(ERR, "Ethdev port_id=%d max_lro_pkt_size"
+                                      " %u != %u is not allowed\n",
+                                      port_id, config_size, max_rx_pkt_len);
+                       ret = -EINVAL;
+               }
+       } else if (config_size > dev_info_size) {
+               RTE_ETHDEV_LOG(ERR, "Ethdev port_id=%d max_lro_pkt_size %u "
+                              "> max allowed value %u\n", port_id, config_size,
+                              dev_info_size);
+               ret = -EINVAL;
+       } else if (config_size < RTE_ETHER_MIN_LEN) {
+               RTE_ETHDEV_LOG(ERR, "Ethdev port_id=%d max_lro_pkt_size %u "
+                              "< min allowed value %u\n", port_id, config_size,
+                              (unsigned int)RTE_ETHER_MIN_LEN);
+               ret = -EINVAL;
+       }
+       return ret;
+}
+
 /*
  * Validate offloads that are requested through rte_eth_dev_configure against
  * the offloads successfuly set by the ethernet device.
@@ -1318,6 +1345,22 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
                                                        RTE_ETHER_MAX_LEN;
        }
 
+       /*
+        * If LRO is enabled, check that the maximum aggregated packet
+        * size is supported by the configured device.
+        */
+       if (dev_conf->rxmode.offloads & DEV_RX_OFFLOAD_TCP_LRO) {
+               if (dev_conf->rxmode.max_lro_pkt_size == 0)
+                       dev->data->dev_conf.rxmode.max_lro_pkt_size =
+                               dev->data->dev_conf.rxmode.max_rx_pkt_len;
+               ret = check_lro_pkt_size(port_id,
+                               dev->data->dev_conf.rxmode.max_lro_pkt_size,
+                               dev->data->dev_conf.rxmode.max_rx_pkt_len,
+                               dev_info.max_lro_pkt_size);
+               if (ret != 0)
+                       goto rollback;
+       }
+
        /* Any requested offloading must be within its device capabilities */
        if ((dev_conf->rxmode.offloads & dev_info.rx_offload_capa) !=
             dev_conf->rxmode.offloads) {
@@ -1851,6 +1894,22 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
                return -EINVAL;
        }
 
+       /*
+        * If LRO is enabled, check that the maximum aggregated packet
+        * size is supported by the configured device.
+        */
+       if (local_conf.offloads & DEV_RX_OFFLOAD_TCP_LRO) {
+               if (dev->data->dev_conf.rxmode.max_lro_pkt_size == 0)
+                       dev->data->dev_conf.rxmode.max_lro_pkt_size =
+                               dev->data->dev_conf.rxmode.max_rx_pkt_len;
+               int ret = check_lro_pkt_size(port_id,
+                               dev->data->dev_conf.rxmode.max_lro_pkt_size,
+                               dev->data->dev_conf.rxmode.max_rx_pkt_len,
+                               dev_info.max_lro_pkt_size);
+               if (ret != 0)
+                       return ret;
+       }
+
        ret = (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc,
                                              socket_id, &local_conf, mp);
        if (!ret) {
index fbfb309..18a9def 100644 (file)
@@ -395,6 +395,8 @@ struct rte_eth_rxmode {
        /** The multi-queue packet distribution mode to be used, e.g. RSS. */
        enum rte_eth_rx_mq_mode mq_mode;
        uint32_t max_rx_pkt_len;  /**< Only used if JUMBO_FRAME enabled. */
+       /** Maximum allowed size of LRO aggregated packet. */
+       uint32_t max_lro_pkt_size;
        uint16_t split_hdr_size;  /**< hdr buf size (header_split enabled).*/
        /**
         * Per-port Rx offloads to be set using DEV_RX_OFFLOAD_* flags.
@@ -1231,6 +1233,8 @@ struct rte_eth_dev_info {
        const uint32_t *dev_flags; /**< Device flags */
        uint32_t min_rx_bufsize; /**< Minimum size of RX buffer. */
        uint32_t max_rx_pktlen; /**< Maximum configurable length of RX pkt. */
+       /** Maximum configurable size of LRO aggregated packet. */
+       uint32_t max_lro_pkt_size;
        uint16_t max_rx_queues; /**< Maximum number of RX queues. */
        uint16_t max_tx_queues; /**< Maximum number of TX queues. */
        uint32_t max_mac_addrs; /**< Maximum number of MAC addresses. */