e8c47ca56044bd4f2eacdc1329d3b8f67120878f
[dpdk.git] / drivers / net / bnxt / bnxt_rxr.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2014-2018 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef _BNXT_RXR_H_
7 #define _BNXT_RXR_H_
8
9 #define B_RX_DB(db, prod)                                               \
10                 (*(uint32_t *)db = (DB_KEY_RX | prod))
11
12 #define BNXT_TPA_L4_SIZE(x)     \
13         { \
14                 typeof(x) hdr_info = (x); \
15                 (((hdr_info) & 0xf8000000) ? ((hdr_info) >> 27) : 32) \
16         }
17
18 #define BNXT_TPA_INNER_L3_OFF(hdr_info) \
19         (((hdr_info) >> 18) & 0x1ff)
20
21 #define BNXT_TPA_INNER_L2_OFF(hdr_info) \
22         (((hdr_info) >> 9) & 0x1ff)
23
24 #define BNXT_TPA_OUTER_L3_OFF(hdr_info) \
25         ((hdr_info) & 0x1ff)
26
27 #define RX_CMP_L4_CS_BITS       \
28         rte_cpu_to_le_32(RX_PKT_CMPL_FLAGS2_L4_CS_CALC | \
29                          RX_PKT_CMPL_FLAGS2_T_L4_CS_CALC)
30
31 #define RX_CMP_L4_CS_ERR_BITS   \
32         rte_cpu_to_le_32(RX_PKT_CMPL_ERRORS_L4_CS_ERROR | \
33                          RX_PKT_CMPL_ERRORS_T_L4_CS_ERROR)
34
35 #define RX_CMP_L4_CS_OK(rxcmp1)                                         \
36             (((rxcmp1)->flags2 & RX_CMP_L4_CS_BITS) &&          \
37              !((rxcmp1)->errors_v2 & RX_CMP_L4_CS_ERR_BITS))
38
39 #define RX_CMP_IP_CS_ERR_BITS   \
40         rte_cpu_to_le_32(RX_PKT_CMPL_ERRORS_IP_CS_ERROR | \
41                          RX_PKT_CMPL_ERRORS_T_IP_CS_ERROR)
42
43 #define RX_CMP_IP_CS_BITS       \
44         rte_cpu_to_le_32(RX_PKT_CMPL_FLAGS2_IP_CS_CALC | \
45                          RX_PKT_CMPL_FLAGS2_T_IP_CS_CALC)
46
47 #define RX_CMP_IP_CS_OK(rxcmp1)                                         \
48                 (((rxcmp1)->flags2 & RX_CMP_IP_CS_BITS) &&      \
49                 !((rxcmp1)->errors_v2 & RX_CMP_IP_CS_ERR_BITS))
50
51 enum pkt_hash_types {
52         PKT_HASH_TYPE_NONE,     /* Undefined type */
53         PKT_HASH_TYPE_L2,       /* Input: src_MAC, dest_MAC */
54         PKT_HASH_TYPE_L3,       /* Input: src_IP, dst_IP */
55         PKT_HASH_TYPE_L4,       /* Input: src_IP, dst_IP, src_port, dst_port */
56 };
57
58 struct bnxt_tpa_info {
59         struct rte_mbuf         *mbuf;
60         uint16_t                        len;
61         unsigned short          gso_type;
62         uint32_t                        flags2;
63         uint32_t                        metadata;
64         enum pkt_hash_types     hash_type;
65         uint32_t                        rss_hash;
66         uint32_t                        hdr_info;
67 };
68
69 struct bnxt_sw_rx_bd {
70         struct rte_mbuf         *mbuf; /* data associated with RX descriptor */
71 };
72
73 struct bnxt_rx_ring_info {
74         uint16_t                rx_prod;
75         uint16_t                ag_prod;
76         void                    *rx_doorbell;
77         void                    *ag_doorbell;
78
79         struct rx_prod_pkt_bd   *rx_desc_ring;
80         struct rx_prod_pkt_bd   *ag_desc_ring;
81         struct bnxt_sw_rx_bd    *rx_buf_ring; /* sw ring */
82         struct bnxt_sw_rx_bd    *ag_buf_ring; /* sw ring */
83
84         rte_iova_t              rx_desc_mapping;
85         rte_iova_t              ag_desc_mapping;
86
87         struct bnxt_ring        *rx_ring_struct;
88         struct bnxt_ring        *ag_ring_struct;
89
90         /*
91          * To deal with out of order return from TPA, use free buffer indicator
92          */
93         struct rte_bitmap       *ag_bitmap;
94
95         struct bnxt_tpa_info *tpa_info;
96 };
97
98 uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
99                                uint16_t nb_pkts);
100 void bnxt_free_rx_rings(struct bnxt *bp);
101 int bnxt_init_rx_ring_struct(struct bnxt_rx_queue *rxq, unsigned int socket_id);
102 int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq);
103 int bnxt_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
104 int bnxt_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
105 #endif