net/i40e: fix Rx data segment buffer length
[dpdk.git] / drivers / net / i40e / i40e_rxtx.c
index 9f697d7..d42c23c 100644 (file)
@@ -610,6 +610,7 @@ static inline uint16_t
 rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 {
        struct i40e_rx_queue *rxq = (struct i40e_rx_queue *)rx_queue;
+       struct rte_eth_dev *dev;
        uint16_t nb_rx = 0;
 
        if (!nb_pkts)
@@ -627,9 +628,10 @@ rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
                if (i40e_rx_alloc_bufs(rxq) != 0) {
                        uint16_t i, j;
 
-                       PMD_RX_LOG(DEBUG, "Rx mbuf alloc failed for "
-                                  "port_id=%u, queue_id=%u",
-                                  rxq->port_id, rxq->queue_id);
+                       dev = I40E_VSI_TO_ETH_DEV(rxq->vsi);
+                       dev->data->rx_mbuf_alloc_failed +=
+                               rxq->rx_free_thresh;
+
                        rxq->rx_nb_avail = 0;
                        rxq->rx_tail = (uint16_t)(rxq->rx_tail - nb_rx);
                        for (i = 0, j = rxq->rx_tail; i < nb_rx; i++, j++)
@@ -691,6 +693,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
        union i40e_rx_desc rxd;
        struct i40e_rx_entry *sw_ring;
        struct i40e_rx_entry *rxe;
+       struct rte_eth_dev *dev;
        struct rte_mbuf *rxm;
        struct rte_mbuf *nmb;
        uint16_t nb_rx;
@@ -721,10 +724,13 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
                        break;
 
                nmb = rte_mbuf_raw_alloc(rxq->mp);
-               if (unlikely(!nmb))
+               if (unlikely(!nmb)) {
+                       dev = I40E_VSI_TO_ETH_DEV(rxq->vsi);
+                       dev->data->rx_mbuf_alloc_failed++;
                        break;
-               rxd = *rxdp;
+               }
 
+               rxd = *rxdp;
                nb_hold++;
                rxe = &sw_ring[rx_id];
                rx_id++;
@@ -816,6 +822,7 @@ i40e_recv_scattered_pkts(void *rx_queue,
        struct rte_mbuf *nmb, *rxm;
        uint16_t rx_id = rxq->rx_tail;
        uint16_t nb_rx = 0, nb_hold = 0, rx_packet_len;
+       struct rte_eth_dev *dev;
        uint32_t rx_status;
        uint64_t qword1;
        uint64_t dma_addr;
@@ -833,8 +840,12 @@ i40e_recv_scattered_pkts(void *rx_queue,
                        break;
 
                nmb = rte_mbuf_raw_alloc(rxq->mp);
-               if (unlikely(!nmb))
+               if (unlikely(!nmb)) {
+                       dev = I40E_VSI_TO_ETH_DEV(rxq->vsi);
+                       dev->data->rx_mbuf_alloc_failed++;
                        break;
+               }
+
                rxd = *rxdp;
                nb_hold++;
                rxe = &sw_ring[rx_id];
@@ -1246,7 +1257,7 @@ end_of_tx:
        return nb_tx;
 }
 
-static inline int __attribute__((always_inline))
+static __rte_always_inline int
 i40e_tx_free_bufs(struct i40e_tx_queue *txq)
 {
        struct i40e_tx_entry *txep;
@@ -1597,7 +1608,7 @@ i40e_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
                rxq = dev->data->rx_queues[rx_queue_id];
 
                /*
-               * rx_queue_id is queue id aplication refers to, while
+               * rx_queue_id is queue id application refers to, while
                * rxq->reg_idx is the real queue index.
                */
                err = i40e_switch_rx_queue(hw, rxq->reg_idx, FALSE);
@@ -1628,7 +1639,7 @@ i40e_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
                txq = dev->data->tx_queues[tx_queue_id];
 
                /*
-               * tx_queue_id is queue id aplication refers to, while
+               * tx_queue_id is queue id application refers to, while
                * rxq->reg_idx is the real queue index.
                */
                err = i40e_switch_tx_queue(hw, txq->reg_idx, TRUE);
@@ -1653,7 +1664,7 @@ i40e_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
                txq = dev->data->tx_queues[tx_queue_id];
 
                /*
-               * tx_queue_id is queue id aplication refers to, while
+               * tx_queue_id is queue id application refers to, while
                * txq->reg_idx is the real queue index.
                */
                err = i40e_switch_tx_queue(hw, txq->reg_idx, FALSE);
@@ -2463,7 +2474,7 @@ i40e_rx_queue_config(struct i40e_rx_queue *rxq)
        case I40E_FLAG_HEADER_SPLIT_DISABLED:
        default:
                rxq->rx_hdr_len = 0;
-               rxq->rx_buf_len = RTE_ALIGN(buf_size,
+               rxq->rx_buf_len = RTE_ALIGN_FLOOR(buf_size,
                        (1 << I40E_RXQ_CTX_DBUFF_SHIFT));
                rxq->hs_mode = i40e_header_split_none;
                break;
@@ -2926,7 +2937,7 @@ i40e_set_default_ptype_table(struct rte_eth_dev *dev)
                I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
        int i;
 
-       for (i = 0; i <= I40E_MAX_PKT_TYPE; i++)
+       for (i = 0; i < I40E_MAX_PKT_TYPE; i++)
                ad->ptype_tbl[i] = i40e_get_default_pkt_type(i);
 }