net/bnxt: fix Rx checksum flags
[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_L4_CS_UNKNOWN(rxcmp1)                                    \
40             !((rxcmp1)->flags2 & RX_CMP_L4_CS_BITS)
41
42 #define RX_CMP_IP_CS_ERR_BITS   \
43         rte_cpu_to_le_32(RX_PKT_CMPL_ERRORS_IP_CS_ERROR | \
44                          RX_PKT_CMPL_ERRORS_T_IP_CS_ERROR)
45
46 #define RX_CMP_IP_CS_BITS       \
47         rte_cpu_to_le_32(RX_PKT_CMPL_FLAGS2_IP_CS_CALC | \
48                          RX_PKT_CMPL_FLAGS2_T_IP_CS_CALC)
49
50 #define RX_CMP_IP_CS_OK(rxcmp1)                                         \
51                 (((rxcmp1)->flags2 & RX_CMP_IP_CS_BITS) &&      \
52                 !((rxcmp1)->errors_v2 & RX_CMP_IP_CS_ERR_BITS))
53
54 #define RX_CMP_IP_CS_UNKNOWN(rxcmp1)                                    \
55                 !((rxcmp1)->flags2 & RX_CMP_IP_CS_BITS)
56
57 enum pkt_hash_types {
58         PKT_HASH_TYPE_NONE,     /* Undefined type */
59         PKT_HASH_TYPE_L2,       /* Input: src_MAC, dest_MAC */
60         PKT_HASH_TYPE_L3,       /* Input: src_IP, dst_IP */
61         PKT_HASH_TYPE_L4,       /* Input: src_IP, dst_IP, src_port, dst_port */
62 };
63
64 struct bnxt_tpa_info {
65         struct rte_mbuf         *mbuf;
66         uint16_t                        len;
67         unsigned short          gso_type;
68         uint32_t                        flags2;
69         uint32_t                        metadata;
70         enum pkt_hash_types     hash_type;
71         uint32_t                        rss_hash;
72         uint32_t                        hdr_info;
73 };
74
75 struct bnxt_sw_rx_bd {
76         struct rte_mbuf         *mbuf; /* data associated with RX descriptor */
77 };
78
79 struct bnxt_rx_ring_info {
80         uint16_t                rx_prod;
81         uint16_t                ag_prod;
82         void                    *rx_doorbell;
83         void                    *ag_doorbell;
84
85         struct rx_prod_pkt_bd   *rx_desc_ring;
86         struct rx_prod_pkt_bd   *ag_desc_ring;
87         struct bnxt_sw_rx_bd    *rx_buf_ring; /* sw ring */
88         struct bnxt_sw_rx_bd    *ag_buf_ring; /* sw ring */
89
90         rte_iova_t              rx_desc_mapping;
91         rte_iova_t              ag_desc_mapping;
92
93         struct bnxt_ring        *rx_ring_struct;
94         struct bnxt_ring        *ag_ring_struct;
95
96         /*
97          * To deal with out of order return from TPA, use free buffer indicator
98          */
99         struct rte_bitmap       *ag_bitmap;
100
101         struct bnxt_tpa_info *tpa_info;
102 };
103
104 uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
105                                uint16_t nb_pkts);
106 void bnxt_free_rx_rings(struct bnxt *bp);
107 int bnxt_init_rx_ring_struct(struct bnxt_rx_queue *rxq, unsigned int socket_id);
108 int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq);
109 int bnxt_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
110 int bnxt_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
111 #endif