Imported Upstream version 16.04
[deb_dpdk.git] / drivers / net / bnx2x / bnx2x_rxtx.h
1 /*
2  * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
3  *
4  * Copyright (c) 2015 QLogic Corporation.
5  * All rights reserved.
6  * www.qlogic.com
7  *
8  * See LICENSE.bnx2x_pmd for copyright and licensing details.
9  */
10
11 #ifndef _BNX2X_RXTX_H_
12 #define _BNX2X_RXTX_H_
13
14
15 #define DEFAULT_RX_FREE_THRESH   0
16 #define DEFAULT_TX_FREE_THRESH   512
17 #define RTE_PMD_BNX2X_TX_MAX_BURST 1
18
19 /**
20  * Structure associated with each descriptor of the RX ring of a RX queue.
21  */
22 struct bnx2x_rx_entry {
23         struct rte_mbuf     *mbuf;                /**< mbuf associated with RX descriptor. */
24 };
25
26 /**
27  * Structure associated with each RX queue.
28  */
29 struct bnx2x_rx_queue {
30         struct rte_mempool         *mb_pool;             /**< mbuf pool to populate RX ring. */
31         union eth_rx_cqe           *cq_ring;             /**< RCQ ring virtual address. */
32         uint64_t                   cq_ring_phys_addr;    /**< RCQ ring DMA address. */
33         uint64_t                   *rx_ring;             /**< RX ring virtual address. */
34         uint64_t                   rx_ring_phys_addr;    /**< RX ring DMA address. */
35         struct rte_mbuf            **sw_ring;            /**< address of RX software ring. */
36         struct rte_mbuf            *pkt_first_seg;       /**< First segment of current packet. */
37         struct rte_mbuf            *pkt_last_seg;        /**< Last segment of current packet. */
38         uint16_t                   nb_cq_pages;          /**< number of RCQ pages. */
39         uint16_t                   nb_rx_desc;           /**< number of RX descriptors. */
40         uint16_t                   nb_rx_pages;          /**< number of RX pages. */
41         uint16_t                   rx_bd_head;           /**< Index of current rx bd. */
42         uint16_t                   rx_bd_tail;           /**< Index of last rx bd. */
43         uint16_t                   rx_cq_head;           /**< Index of current rcq bd. */
44         uint16_t                   rx_cq_tail;           /**< Index of last rcq bd. */
45         uint16_t                   nb_rx_hold;           /**< number of held free RX desc. */
46         uint16_t                   rx_free_thresh;       /**< max free RX desc to hold. */
47         uint16_t                   queue_id;             /**< RX queue index. */
48         uint8_t                    port_id;              /**< Device port identifier. */
49         uint8_t                    crc_len;              /**< 0 if CRC stripped, 4 otherwise. */
50         struct bnx2x_softc           *sc;                  /**< Ptr to dev_private data. */
51         uint64_t                   rx_mbuf_alloc;        /**< Number of allocated mbufs. */
52 };
53
54 /**
55  * Structure associated with each TX queue.
56  */
57 struct bnx2x_tx_queue {
58         /** TX ring virtual address. */
59         union eth_tx_bd_types      *tx_ring;             /**< TX ring virtual address. */
60         uint64_t                   tx_ring_phys_addr;    /**< TX ring DMA address. */
61         struct rte_mbuf            **sw_ring;            /**< virtual address of SW ring. */
62         uint16_t                   tx_pkt_tail;          /**< Index of current tx pkt. */
63         uint16_t                   tx_pkt_head;          /**< Index of last pkt counted by txeof. */
64         uint16_t                   tx_bd_tail;           /**< Index of current tx bd. */
65         uint16_t                   tx_bd_head;           /**< Index of last bd counted by txeof. */
66         uint16_t                   nb_tx_desc;           /**< number of TX descriptors. */
67         uint16_t                   tx_free_thresh;       /**< minimum TX before freeing. */
68         uint16_t                   nb_tx_avail;          /**< Number of TX descriptors available. */
69         uint16_t                   nb_tx_pages;          /**< number of TX pages */
70         uint16_t                   queue_id;             /**< TX queue index. */
71         uint8_t                    port_id;              /**< Device port identifier. */
72         struct bnx2x_softc           *sc;                  /**< Ptr to dev_private data */
73 };
74
75 int bnx2x_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
76                               uint16_t nb_rx_desc, unsigned int socket_id,
77                               const struct rte_eth_rxconf *rx_conf,
78                               struct rte_mempool *mb_pool);
79
80 int bnx2x_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
81                               uint16_t nb_tx_desc, unsigned int socket_id,
82                               const struct rte_eth_txconf *tx_conf);
83
84 void bnx2x_dev_rx_queue_release(void *rxq);
85 void bnx2x_dev_tx_queue_release(void *txq);
86 int bnx2x_dev_rx_init(struct rte_eth_dev *dev);
87 void bnx2x_dev_clear_queues(struct rte_eth_dev *dev);
88
89 #endif /* _BNX2X_RXTX_H_ */