net/qede: fix minimum buffer size and scatter Rx check
authorHarish Patil <harish.patil@qlogic.com>
Fri, 6 Jan 2017 08:16:46 +0000 (00:16 -0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 17 Jan 2017 18:40:54 +0000 (19:40 +0100)
 - Fix minimum RX buffer size to 1024B
 - Force enable scatter/gather mode if given RX buf size is lesser than MTU
 - Adjust RX buffer size to cache-line size with overhead included

Fixes: bec0228816c0 ("net/qede: support scatter gather")
Fixes: 2ea6f76aff40 ("qede: add core driver")

Signed-off-by: Harish Patil <harish.patil@qlogic.com>
drivers/net/qede/qede_ethdev.c
drivers/net/qede/qede_rxtx.c
drivers/net/qede/qede_rxtx.h

index 12f2a74..5263587 100644 (file)
@@ -969,8 +969,7 @@ qede_dev_info_get(struct rte_eth_dev *eth_dev,
        PMD_INIT_FUNC_TRACE(edev);
 
        dev_info->pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
-       dev_info->min_rx_bufsize = (uint32_t)(ETHER_MIN_MTU +
-                                             QEDE_ETH_OVERHEAD);
+       dev_info->min_rx_bufsize = (uint32_t)QEDE_MIN_RX_BUFF_SIZE;
        dev_info->max_rx_pktlen = (uint32_t)ETH_TX_MAX_NON_LSO_PKT_LEN;
        dev_info->rx_desc_lim = qede_rx_desc_lim;
        dev_info->tx_desc_lim = qede_tx_desc_lim;
index ecff5bc..aebe8cb 100644 (file)
@@ -89,11 +89,11 @@ qede_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
 {
        struct qede_dev *qdev = dev->data->dev_private;
        struct ecore_dev *edev = &qdev->edev;
-       struct rte_eth_dev_data *eth_data = dev->data;
+       struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
        struct qede_rx_queue *rxq;
-       uint16_t pkt_len = (uint16_t)dev->data->dev_conf.rxmode.max_rx_pkt_len;
+       uint16_t max_rx_pkt_len;
+       uint16_t bufsz;
        size_t size;
-       uint16_t data_size;
        int rc;
        int i;
 
@@ -127,34 +127,27 @@ qede_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
        rxq->nb_rx_desc = nb_desc;
        rxq->queue_id = queue_idx;
        rxq->port_id = dev->data->port_id;
-
-       /* Sanity check */
-       data_size = (uint16_t)rte_pktmbuf_data_room_size(mp) -
-                               RTE_PKTMBUF_HEADROOM;
-
-       if (pkt_len > data_size && !dev->data->scattered_rx) {
-               DP_ERR(edev, "MTU %u should not exceed dataroom %u\n",
-                      pkt_len, data_size);
-               rte_free(rxq);
-               return -EINVAL;
+       max_rx_pkt_len = (uint16_t)rxmode->max_rx_pkt_len;
+       qdev->mtu = max_rx_pkt_len;
+
+       /* Fix up RX buffer size */
+       bufsz = (uint16_t)rte_pktmbuf_data_room_size(mp) - RTE_PKTMBUF_HEADROOM;
+       if ((rxmode->enable_scatter)                    ||
+           (max_rx_pkt_len + QEDE_ETH_OVERHEAD) > bufsz) {
+               if (!dev->data->scattered_rx) {
+                       DP_INFO(edev, "Forcing scatter-gather mode\n");
+                       dev->data->scattered_rx = 1;
+               }
        }
-
        if (dev->data->scattered_rx)
-               rxq->rx_buf_size = data_size;
+               rxq->rx_buf_size = bufsz + QEDE_ETH_OVERHEAD;
        else
-               rxq->rx_buf_size = pkt_len + QEDE_ETH_OVERHEAD;
-
-       qdev->mtu = pkt_len;
+               rxq->rx_buf_size = qdev->mtu + QEDE_ETH_OVERHEAD;
+       /* Align to cache-line size if needed */
+       rxq->rx_buf_size = QEDE_CEIL_TO_CACHE_LINE_SIZE(rxq->rx_buf_size);
 
-       DP_INFO(edev, "MTU = %u ; RX buffer = %u\n",
-               qdev->mtu, rxq->rx_buf_size);
-
-       if (pkt_len > ETHER_MAX_LEN) {
-               dev->data->dev_conf.rxmode.jumbo_frame = 1;
-               DP_NOTICE(edev, false, "jumbo frame enabled\n");
-       } else {
-               dev->data->dev_conf.rxmode.jumbo_frame = 0;
-       }
+       DP_INFO(edev, "mtu %u mbufsz %u bd_max_bytes %u scatter_mode %d\n",
+               qdev->mtu, bufsz, rxq->rx_buf_size, dev->data->scattered_rx);
 
        /* Allocate the parallel driver ring for Rx buffers */
        size = sizeof(*rxq->sw_rx_ring) * rxq->nb_rx_desc;
index a95b4ab..9a393e9 100644 (file)
        ((flags) & (PARSING_AND_ERR_FLAGS_TUNNEL8021QTAGEXIST_MASK \
                << PARSING_AND_ERR_FLAGS_TUNNEL8021QTAGEXIST_SHIFT))
 
+#define QEDE_MIN_RX_BUFF_SIZE          (1024)
+#define QEDE_VLAN_TAG_SIZE             (4)
+#define QEDE_LLC_SNAP_HDR_LEN          (8)
+
 /* Max supported alignment is 256 (8 shift)
  * minimal alignment shift 6 is optimal for 57xxx HW performance
  */
 #define QEDE_L1_CACHE_SHIFT    6
 #define QEDE_RX_ALIGN_SHIFT    (RTE_MAX(6, RTE_MIN(8, QEDE_L1_CACHE_SHIFT)))
 #define QEDE_FW_RX_ALIGN_END   (1UL << QEDE_RX_ALIGN_SHIFT)
-
-#define QEDE_ETH_OVERHEAD       (ETHER_HDR_LEN + 8 + 8 + QEDE_FW_RX_ALIGN_END)
+#define QEDE_CEIL_TO_CACHE_LINE_SIZE(n) (((n) + (QEDE_FW_RX_ALIGN_END - 1)) & \
+                                       ~(QEDE_FW_RX_ALIGN_END - 1))
+/* Note: QEDE_LLC_SNAP_HDR_LEN is optional */
+#define QEDE_ETH_OVERHEAD      ((ETHER_HDR_LEN) + ((2 * QEDE_VLAN_TAG_SIZE)) \
+                               + (QEDE_LLC_SNAP_HDR_LEN))
 
 #define QEDE_RSS_OFFLOAD_ALL    (ETH_RSS_IPV4                  |\
                                 ETH_RSS_NONFRAG_IPV4_TCP       |\