Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(c) 2014-2023 Broadcom 3 : : * All rights reserved. 4 : : */ 5 : : 6 : : #ifndef _BNXT_RXR_H_ 7 : : #define _BNXT_RXR_H_ 8 : : #include "hsi_struct_def_dpdk.h" 9 : : 10 : : #define BNXT_TPA_START_AGG_ID_PRE_TH(cmp) \ 11 : : ((rte_le_to_cpu_16((cmp)->agg_id) & RX_TPA_START_CMPL_AGG_ID_MASK) >> \ 12 : : RX_TPA_START_CMPL_AGG_ID_SFT) 13 : : 14 : : #define BNXT_TPA_START_AGG_ID_TH(cmp) \ 15 : : rte_le_to_cpu_16((cmp)->agg_id) 16 : : 17 : : static inline uint16_t bnxt_tpa_start_agg_id(struct bnxt *bp, 18 : : struct rx_tpa_start_cmpl *cmp) 19 : : { 20 [ # # ]: 0 : if (BNXT_CHIP_P5_P7(bp)) 21 : 0 : return BNXT_TPA_START_AGG_ID_TH(cmp); 22 : : else 23 : 0 : return BNXT_TPA_START_AGG_ID_PRE_TH(cmp); 24 : : } 25 : : 26 : : #define BNXT_TPA_END_AGG_BUFS(cmp) \ 27 : : (((cmp)->agg_bufs_v1 & RX_TPA_END_CMPL_AGG_BUFS_MASK) \ 28 : : >> RX_TPA_END_CMPL_AGG_BUFS_SFT) 29 : : 30 : : #define BNXT_TPA_END_AGG_BUFS_TH(cmp) \ 31 : : ((cmp)->tpa_agg_bufs) 32 : : 33 : : #define BNXT_TPA_END_AGG_ID(cmp) \ 34 : : (((cmp)->agg_id & RX_TPA_END_CMPL_AGG_ID_MASK) >> \ 35 : : RX_TPA_END_CMPL_AGG_ID_SFT) 36 : : 37 : : #define BNXT_TPA_END_AGG_ID_TH(cmp) \ 38 : : rte_le_to_cpu_16((cmp)->agg_id) 39 : : 40 : : #define BNXT_RX_L2_AGG_BUFS(cmp) \ 41 : : (((cmp)->agg_bufs_v1 & RX_PKT_CMPL_AGG_BUFS_MASK) >> \ 42 : : RX_PKT_CMPL_AGG_BUFS_SFT) 43 : : 44 : : /* Number of descriptors to process per inner loop in vector mode. */ 45 : : #define BNXT_RX_DESCS_PER_LOOP_VEC128 4U /* SSE, Neon */ 46 : : #define BNXT_RX_DESCS_PER_LOOP_VEC256 8U /* AVX2 */ 47 : : 48 : : /* Number of extra Rx mbuf ring entries to allocate for vector mode. */ 49 : : #define BNXT_RX_EXTRA_MBUF_ENTRIES \ 50 : : RTE_MAX(BNXT_RX_DESCS_PER_LOOP_VEC128, BNXT_RX_DESCS_PER_LOOP_VEC256) 51 : : 52 : : #define BNXT_OL_FLAGS_TBL_DIM 64 53 : : #define BNXT_OL_FLAGS_ERR_TBL_DIM 32 54 : : 55 : : #define BNXT_CRX_CQE_OPAQUE_MASK \ 56 : : RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_OPAQUE_MASK 57 : : #define BNXT_CRX_CQE_AGG_BUF_MASK \ 58 : : RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_AGG_BUFS_MASK 59 : : #define BNXT_CRX_CQE_AGG_BUF_SFT \ 60 : : RX_PKT_COMPRESS_CMPL_ERRORS_AGG_BUFS_OPAQUE_AGG_BUFS_SFT 61 : : #define BNXT_CRX_CQE_AGG_BUFS(cmp) \ 62 : : (((cmp)->errors_agg_bufs_opaque & BNXT_CRX_CQE_AGG_BUF_MASK) >> \ 63 : : BNXT_CRX_CQE_AGG_BUF_SFT) 64 : : #define BNXT_CRX_CQE_CSUM_CALC_MASK \ 65 : : (RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_IP_CS_CALC | \ 66 : : RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_L4_CS_CALC | \ 67 : : RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_T_IP_CS_CALC | \ 68 : : RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_T_L4_CS_CALC) 69 : : #define BNXT_CRX_CQE_CSUM_CALC_SFT 8 70 : : #define BNXT_PKT_CMPL_T_IP_CS_CALC 0x4 71 : : 72 : : #define BNXT_CRX_TUN_CS_CALC \ 73 : : (!!(RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_T_IP_CS_CALC | \ 74 : : RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_T_L4_CS_CALC)) 75 : : 76 : : # define BNXT_CRX_CQE_CSUM_ERROR_MASK \ 77 : : (RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_IP_CS_ERROR | \ 78 : : RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_L4_CS_ERROR | \ 79 : : RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_T_IP_CS_ERROR | \ 80 : : RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_T_L4_CS_ERROR) 81 : : 82 : : /* meta_format != 0 and bit3 is valid, the value in meta is VLAN. 83 : : * Use the bit as VLAN valid bit 84 : : */ 85 : : #define BNXT_RXC_METADATA1_VLAN_VALID \ 86 : : RX_PKT_COMPRESS_CMPL_METADATA1_VALID 87 : : 88 : : static inline void bnxt_set_vlan_crx(struct rx_pkt_compress_cmpl *rxcmp, 89 : : struct rte_mbuf *mbuf) 90 : : { 91 : : uint16_t metadata = rte_le_to_cpu_16(rxcmp->metadata1_cs_error_calc_v1); 92 : 0 : uint16_t vlan_tci = rte_le_to_cpu_16(rxcmp->vlanc_tcid); 93 : : 94 [ # # ]: 0 : if (metadata & RX_PKT_COMPRESS_CMPL_METADATA1_VALID) 95 : 0 : mbuf->vlan_tci = 96 : : vlan_tci & (RX_PKT_COMPRESS_CMPL_VLANC_TCID_VID_MASK | 97 : : RX_PKT_COMPRESS_CMPL_VLANC_TCID_DE | 98 : : RX_PKT_COMPRESS_CMPL_VLANC_TCID_PRI_MASK); 99 : : } 100 : : 101 : : struct bnxt_tpa_info { 102 : : struct rte_mbuf *mbuf; 103 : : uint16_t len; 104 : : uint32_t agg_count; 105 : : struct rx_tpa_v2_abuf_cmpl agg_arr[TPA_MAX_NUM_SEGS]; 106 : : 107 : : uint32_t rss_hash; 108 : : uint32_t vlan; 109 : : uint16_t cfa_code; 110 : : uint8_t hash_valid:1; 111 : : uint8_t vlan_valid:1; 112 : : uint8_t cfa_code_valid:1; 113 : : uint8_t l4_csum_valid:1; 114 : : }; 115 : : 116 : : struct bnxt_rx_ring_info { 117 : : uint16_t rx_raw_prod; 118 : : uint16_t ag_raw_prod; 119 : : uint16_t ag_cons; /* Needed with compressed CQE */ 120 : : uint16_t rx_cons; /* Needed for representor */ 121 : : uint16_t rx_next_cons; 122 : : struct bnxt_db_info rx_db; 123 : : struct bnxt_db_info ag_db; 124 : : 125 : : struct rx_prod_pkt_bd *rx_desc_ring; 126 : : struct rx_prod_pkt_bd *ag_desc_ring; 127 : : struct rte_mbuf **rx_buf_ring; /* sw ring */ 128 : : struct rte_mbuf **ag_buf_ring; /* sw ring */ 129 : : 130 : : rte_iova_t rx_desc_mapping; 131 : : rte_iova_t ag_desc_mapping; 132 : : 133 : : struct bnxt_ring *rx_ring_struct; 134 : : struct bnxt_ring *ag_ring_struct; 135 : : 136 : : /* 137 : : * To deal with out of order return from TPA, use free buffer indicator 138 : : */ 139 : : struct rte_bitmap *ag_bitmap; 140 : : 141 : : struct bnxt_tpa_info *tpa_info; 142 : : 143 : : uint32_t ol_flags_table[BNXT_OL_FLAGS_TBL_DIM]; 144 : : uint32_t ol_flags_err_table[BNXT_OL_FLAGS_ERR_TBL_DIM]; 145 : : uint8_t dpi; /* Doorbell page index for multi-doorbell support */ 146 : : }; 147 : : 148 : : uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, 149 : : uint16_t nb_pkts); 150 : : void bnxt_free_rx_rings(struct bnxt *bp); 151 : : int bnxt_init_rx_ring_struct(struct bnxt_rx_queue *rxq, unsigned int socket_id); 152 : : int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq); 153 : : int bnxt_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id); 154 : : int bnxt_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id); 155 : : int bnxt_flush_rx_cmp(struct bnxt_cp_ring_info *cpr); 156 : : 157 : : #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64) 158 : : uint16_t bnxt_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, 159 : : uint16_t nb_pkts); 160 : : uint16_t bnxt_crx_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, 161 : : uint16_t nb_pkts); 162 : : int bnxt_rxq_vec_setup(struct bnxt_rx_queue *rxq); 163 : : #endif 164 : : 165 : : #if defined(RTE_ARCH_X86) 166 : : uint16_t bnxt_recv_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, 167 : : uint16_t nb_pkts); 168 : : uint16_t bnxt_crx_pkts_vec_avx2(void *rx_queue, struct rte_mbuf **rx_pkts, 169 : : uint16_t nb_pkts); 170 : : #endif 171 : : void bnxt_set_mark_in_mbuf(struct bnxt *bp, 172 : : struct rx_pkt_cmpl_hi *rxcmp1, 173 : : struct rte_mbuf *mbuf); 174 : : 175 : : typedef uint32_t bnxt_cfa_code_dynfield_t; 176 : : extern int bnxt_cfa_code_dynfield_offset; 177 : : 178 : : static inline bnxt_cfa_code_dynfield_t * 179 : : bnxt_cfa_code_dynfield(struct rte_mbuf *mbuf) 180 : : { 181 : 0 : return RTE_MBUF_DYNFIELD(mbuf, 182 : : bnxt_cfa_code_dynfield_offset, bnxt_cfa_code_dynfield_t *); 183 : : } 184 : : 185 : : static __rte_always_inline void 186 : : bnxt_timestamp_dynfield_set(struct rte_mbuf *mbuf, int offset, 187 : : rte_mbuf_timestamp_t ts) 188 : : { 189 : : *RTE_MBUF_DYNFIELD(mbuf, offset, rte_mbuf_timestamp_t *) = ts; 190 : : } 191 : : 192 : : #define BNXT_RX_META_CFA_CODE_SHIFT 19 193 : : #define BNXT_CFA_CODE_META_SHIFT 16 194 : : #define BNXT_RX_META_CFA_CODE_INT_ACT_REC_BIT 0x8000000 195 : : #define BNXT_RX_META_CFA_CODE_EEM_BIT 0x4000000 196 : : #define BNXT_CFA_META_FMT_MASK 0x70 197 : : #define BNXT_CFA_META_FMT_SHFT 4 198 : : #define BNXT_CFA_META_FMT_EM_EEM_SHFT 1 199 : : #define BNXT_CFA_META_FMT_EEM 3 200 : : #define BNXT_CFA_META_EEM_TCAM_SHIFT 31 201 : : #define BNXT_CFA_META_EM_TEST(x) ((x) >> BNXT_CFA_META_EEM_TCAM_SHIFT) 202 : : 203 : : /* Definitions for translation of hardware packet type to mbuf ptype. */ 204 : : #define BNXT_PTYPE_TBL_DIM 128 205 : : #define BNXT_PTYPE_TBL_TUN_SFT 0 /* Set if tunneled packet. */ 206 : : #define BNXT_PTYPE_TBL_TUN_MSK BIT(BNXT_PTYPE_TBL_TUN_SFT) 207 : : #define BNXT_PTYPE_TBL_IP_VER_SFT 1 /* Set if IPv6, clear if IPv4. */ 208 : : #define BNXT_PTYPE_TBL_IP_VER_MSK BIT(BNXT_PTYPE_TBL_IP_VER_SFT) 209 : : #define BNXT_PTYPE_TBL_VLAN_SFT 2 /* Set if VLAN encapsulated. */ 210 : : #define BNXT_PTYPE_TBL_VLAN_MSK BIT(BNXT_PTYPE_TBL_VLAN_SFT) 211 : : #define BNXT_PTYPE_TBL_TYPE_SFT 3 /* Hardware packet type field. */ 212 : : #define BNXT_PTYPE_TBL_TYPE_MSK 0x78 /* Hardware itype field mask. */ 213 : : #define BNXT_PTYPE_TBL_TYPE_IP 1 214 : : #define BNXT_PTYPE_TBL_TYPE_TCP 2 215 : : #define BNXT_PTYPE_TBL_TYPE_UDP 3 216 : : #define BNXT_PTYPE_TBL_TYPE_ICMP 7 217 : : 218 : : #define RX_PKT_CMPL_FLAGS2_IP_TYPE_SFT 8 219 : : #define CMPL_FLAGS2_VLAN_TUN_MSK \ 220 : : (RX_PKT_CMPL_FLAGS2_META_FORMAT_VLAN | RX_PKT_CMPL_FLAGS2_T_IP_CS_CALC) 221 : : 222 : : #define CMPL_FLAGS2_VLAN_TUN_MSK_CRX \ 223 : : (RX_PKT_COMPRESS_CMPL_METADATA1_VALID | \ 224 : : RX_PKT_COMPRESS_CMPL_CS_ERROR_CALC_T_IP_CS_CALC) 225 : : 226 : : #define BNXT_CMPL_ITYPE_TO_IDX(ft) \ 227 : : (((ft) & RX_PKT_CMPL_FLAGS_ITYPE_MASK) >> \ 228 : : (RX_PKT_CMPL_FLAGS_ITYPE_SFT - BNXT_PTYPE_TBL_TYPE_SFT)) 229 : : 230 : : #define BNXT_CMPL_VLAN_TUN_TO_IDX(f2) \ 231 : : (((f2) & CMPL_FLAGS2_VLAN_TUN_MSK) >> \ 232 : : (RX_PKT_CMPL_FLAGS2_META_FORMAT_SFT - BNXT_PTYPE_TBL_VLAN_SFT)) 233 : : 234 : : #define BNXT_CMPL_VLAN_TUN_TO_IDX_CRX(md) \ 235 : : (((md) & CMPL_FLAGS2_VLAN_TUN_MSK_CRX) >> \ 236 : : (RX_PKT_COMPRESS_CMPL_METADATA1_SFT - BNXT_PTYPE_TBL_VLAN_SFT)) 237 : : 238 : : #define BNXT_CMPL_IP_VER_TO_IDX(f2) \ 239 : : (((f2) & RX_PKT_CMPL_FLAGS2_IP_TYPE) >> \ 240 : : (RX_PKT_CMPL_FLAGS2_IP_TYPE_SFT - BNXT_PTYPE_TBL_IP_VER_SFT)) 241 : : 242 : : static inline void 243 : : bnxt_check_ptype_constants(void) 244 : : { 245 : : RTE_BUILD_BUG_ON(BNXT_CMPL_ITYPE_TO_IDX(RX_PKT_CMPL_FLAGS_ITYPE_MASK) != 246 : : BNXT_PTYPE_TBL_TYPE_MSK); 247 : : RTE_BUILD_BUG_ON(BNXT_CMPL_VLAN_TUN_TO_IDX(CMPL_FLAGS2_VLAN_TUN_MSK) != 248 : : (BNXT_PTYPE_TBL_VLAN_MSK | BNXT_PTYPE_TBL_TUN_MSK)); 249 : : RTE_BUILD_BUG_ON(BNXT_CMPL_IP_VER_TO_IDX(RX_PKT_CMPL_FLAGS2_IP_TYPE) != 250 : : BNXT_PTYPE_TBL_IP_VER_MSK); 251 : : } 252 : : 253 : : extern uint32_t bnxt_ptype_table[BNXT_PTYPE_TBL_DIM]; 254 : : 255 : : static inline void bnxt_set_vlan(struct rx_pkt_cmpl_hi *rxcmp1, 256 : : struct rte_mbuf *mbuf) 257 : : { 258 : 0 : uint32_t metadata = rte_le_to_cpu_32(rxcmp1->metadata); 259 : : 260 [ # # ]: 0 : mbuf->vlan_tci = metadata & (RX_PKT_CMPL_METADATA_VID_MASK | 261 : : RX_PKT_CMPL_METADATA_DE | 262 : : RX_PKT_CMPL_METADATA_PRI_MASK); 263 : : } 264 : : 265 : : /* Stingray2 specific code for RX completion parsing */ 266 : : #define RX_CMP_VLAN_VALID(rxcmp) \ 267 : : (((struct rx_pkt_v2_cmpl *)rxcmp)->metadata1_payload_offset & \ 268 : : RX_PKT_V2_CMPL_METADATA1_VALID) 269 : : 270 : : #define RX_CMP_METADATA0_VID(rxcmp1) \ 271 : : ((((struct rx_pkt_v2_cmpl_hi *)rxcmp1)->metadata0) & \ 272 : : (RX_PKT_V2_CMPL_HI_METADATA0_VID_MASK | \ 273 : : RX_PKT_V2_CMPL_HI_METADATA0_DE | \ 274 : : RX_PKT_V2_CMPL_HI_METADATA0_PRI_MASK)) 275 : : 276 : : static inline void bnxt_rx_vlan_v2(struct rte_mbuf *mbuf, 277 : : struct rx_pkt_cmpl *rxcmp, 278 : : struct rx_pkt_cmpl_hi *rxcmp1) 279 : : { 280 [ # # ]: 0 : if (RX_CMP_VLAN_VALID(rxcmp)) { 281 : 0 : mbuf->vlan_tci = RX_CMP_METADATA0_VID(rxcmp1); 282 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED; 283 : : } 284 : : } 285 : : 286 : : #define RX_CMP_FLAGS2_CS_ALL_OK_MODE_MASK (0x1 << 3) 287 : : #define RX_CMP_FLAGS2_CS_OK_HDR_CNT_MASK (0x7 << 10) 288 : : #define RX_CMP_FLAGS2_IP_CSUM_ALL_OK_MASK (0x1 << 13) 289 : : #define RX_CMP_FLAGS2_L4_CSUM_ALL_OK_MASK (0x1 << 14) 290 : : 291 : : #define RX_CMP_V2_CS_OK_HDR_CNT(flags) \ 292 : : (((flags) & RX_CMP_FLAGS2_CS_OK_HDR_CNT_MASK) >> \ 293 : : RX_PKT_V2_CMPL_HI_FLAGS2_CS_OK_SFT) 294 : : 295 : : #define RX_CMP_V2_CS_ALL_OK_MODE(flags) \ 296 : : (((flags) & RX_CMP_FLAGS2_CS_ALL_OK_MODE_MASK)) 297 : : 298 : : #define RX_CMP_FLAGS2_L3_CS_OK_MASK (0x7 << 10) 299 : : #define RX_CMP_FLAGS2_L4_CS_OK_MASK (0x38 << 10) 300 : : #define RX_CMP_FLAGS2_L3_CS_OK_SFT 10 301 : : #define RX_CMP_FLAGS2_L4_CS_OK_SFT 13 302 : : 303 : : #define RX_CMP_V2_L4_CS_OK(flags2) \ 304 : : (((flags2) & RX_CMP_FLAGS2_L4_CS_OK_MASK) >> \ 305 : : RX_CMP_FLAGS2_L4_CS_OK_SFT) 306 : : 307 : : #define RX_CMP_V2_L3_CS_OK(flags2) \ 308 : : (((flags2) & RX_CMP_FLAGS2_L3_CS_OK_MASK) >> \ 309 : : RX_CMP_FLAGS2_L3_CS_OK_SFT) 310 : : 311 : : #define RX_CMP_V2_L4_CS_ERR(err) \ 312 : : (((err) & RX_PKT_V2_CMPL_HI_ERRORS_PKT_ERROR_MASK) == \ 313 : : RX_PKT_V2_CMPL_HI_ERRORS_PKT_ERROR_L4_CS_ERROR) 314 : : 315 : : #define RX_CMP_V2_L3_CS_ERR(err) \ 316 : : (((err) & RX_PKT_V2_CMPL_HI_ERRORS_PKT_ERROR_MASK) == \ 317 : : RX_PKT_V2_CMPL_HI_ERRORS_PKT_ERROR_IP_CS_ERROR) 318 : : 319 : : #define RX_CMP_V2_T_IP_CS_ERR(err) \ 320 : : (((err) & RX_PKT_V2_CMPL_HI_ERRORS_T_PKT_ERROR_MASK) == \ 321 : : RX_PKT_V2_CMPL_HI_ERRORS_T_PKT_ERROR_T_IP_CS_ERROR) 322 : : 323 : : #define RX_CMP_V2_T_L4_CS_ERR(err) \ 324 : : (((err) & RX_PKT_V2_CMPL_HI_ERRORS_T_PKT_ERROR_MASK) == \ 325 : : RX_PKT_V2_CMPL_HI_ERRORS_T_PKT_ERROR_T_L4_CS_ERROR) 326 : : 327 : : #define RX_CMP_V2_OT_L4_CS_ERR(err) \ 328 : : (((err) & RX_PKT_V2_CMPL_HI_ERRORS_OT_PKT_ERROR_MASK) == \ 329 : : RX_PKT_V2_CMPL_HI_ERRORS_OT_PKT_ERROR_OT_L4_CS_ERROR) 330 : : 331 : 0 : static inline void bnxt_parse_csum_v2(struct rte_mbuf *mbuf, 332 : : struct rx_pkt_cmpl_hi *rxcmp1) 333 : : { 334 : : struct rx_pkt_v2_cmpl_hi *v2_cmp = 335 : : (struct rx_pkt_v2_cmpl_hi *)(rxcmp1); 336 : 0 : uint16_t error_v2 = rte_le_to_cpu_16(v2_cmp->errors_v2); 337 : 0 : uint32_t flags2 = rte_le_to_cpu_32(v2_cmp->flags2); 338 : : uint32_t hdr_cnt = 0, t_pkt = 0; 339 : : 340 [ # # ]: 0 : if (RX_CMP_V2_CS_ALL_OK_MODE(flags2)) { 341 : 0 : hdr_cnt = RX_CMP_V2_CS_OK_HDR_CNT(flags2); 342 [ # # ]: 0 : if (hdr_cnt > 1) 343 : : t_pkt = 1; 344 : : 345 [ # # ]: 0 : if (unlikely(RX_CMP_V2_L4_CS_ERR(error_v2))) 346 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD; 347 [ # # ]: 0 : else if (flags2 & RX_CMP_FLAGS2_L4_CSUM_ALL_OK_MASK) 348 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD; 349 : : else 350 : : mbuf->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_UNKNOWN; 351 : : 352 [ # # ]: 0 : if (unlikely(RX_CMP_V2_L3_CS_ERR(error_v2))) 353 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD; 354 [ # # ]: 0 : else if (flags2 & RX_CMP_FLAGS2_IP_CSUM_ALL_OK_MASK) 355 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD; 356 : : else 357 : : mbuf->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_UNKNOWN; 358 : : } else { 359 : 0 : hdr_cnt = RX_CMP_V2_L4_CS_OK(flags2); 360 [ # # ]: 0 : if (hdr_cnt > 1) 361 : : t_pkt = 1; 362 : : 363 [ # # ]: 0 : if (RX_CMP_V2_L4_CS_OK(flags2)) 364 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD; 365 [ # # ]: 0 : else if (RX_CMP_V2_L4_CS_ERR(error_v2)) 366 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD; 367 : : else 368 : : mbuf->ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_UNKNOWN; 369 : : 370 [ # # ]: 0 : if (RX_CMP_V2_L3_CS_OK(flags2)) 371 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD; 372 [ # # ]: 0 : else if (RX_CMP_V2_L3_CS_ERR(error_v2)) 373 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD; 374 : : else 375 : : mbuf->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_UNKNOWN; 376 : : } 377 : : 378 [ # # ]: 0 : if (t_pkt) { 379 [ # # # # ]: 0 : if (unlikely(RX_CMP_V2_OT_L4_CS_ERR(error_v2) || 380 : : RX_CMP_V2_T_L4_CS_ERR(error_v2))) 381 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_BAD; 382 : : else 383 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD; 384 : : 385 [ # # ]: 0 : if (unlikely(RX_CMP_V2_T_IP_CS_ERR(error_v2))) 386 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD; 387 : : } 388 : 0 : } 389 : : 390 : : static inline void 391 : 0 : bnxt_parse_pkt_type_v2(struct rte_mbuf *mbuf, 392 : : struct rx_pkt_cmpl *rxcmp, 393 : : struct rx_pkt_cmpl_hi *rxcmp1) 394 : : { 395 : : struct rx_pkt_v2_cmpl *v2_cmp = 396 : : (struct rx_pkt_v2_cmpl *)(rxcmp); 397 : : struct rx_pkt_v2_cmpl_hi *v2_cmp1 = 398 : : (struct rx_pkt_v2_cmpl_hi *)(rxcmp1); 399 : 0 : uint16_t flags_type = v2_cmp->flags_type & 400 : : rte_cpu_to_le_32(RX_PKT_V2_CMPL_FLAGS_ITYPE_MASK); 401 : 0 : uint32_t flags2 = rte_le_to_cpu_32(v2_cmp1->flags2); 402 : : uint32_t l3, pkt_type = 0, vlan = 0; 403 : : uint32_t ip6 = 0, t_pkt = 0; 404 : : uint32_t hdr_cnt, csum_count; 405 : : 406 [ # # ]: 0 : if (RX_CMP_V2_CS_ALL_OK_MODE(flags2)) { 407 : 0 : hdr_cnt = RX_CMP_V2_CS_OK_HDR_CNT(flags2); 408 [ # # ]: 0 : if (hdr_cnt > 1) 409 : : t_pkt = 1; 410 : : } else { 411 : 0 : csum_count = RX_CMP_V2_L4_CS_OK(flags2); 412 [ # # ]: 0 : if (csum_count > 1) 413 : : t_pkt = 1; 414 : : } 415 : : 416 : 0 : vlan = !!RX_CMP_VLAN_VALID(rxcmp); 417 [ # # ]: 0 : pkt_type |= vlan ? RTE_PTYPE_L2_ETHER_VLAN : RTE_PTYPE_L2_ETHER; 418 : : 419 : 0 : ip6 = !!(flags2 & RX_PKT_V2_CMPL_HI_FLAGS2_IP_TYPE); 420 : : 421 [ # # ]: 0 : if (!t_pkt && !ip6) 422 : : l3 = RTE_PTYPE_L3_IPV4_EXT_UNKNOWN; 423 [ # # ]: 0 : else if (!t_pkt && ip6) 424 : : l3 = RTE_PTYPE_L3_IPV6_EXT_UNKNOWN; 425 [ # # ]: 0 : else if (t_pkt && !ip6) 426 : : l3 = RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN; 427 : : else 428 : : l3 = RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN; 429 : : 430 [ # # # # : 0 : switch (flags_type) { # ] 431 : 0 : case RTE_LE32(RX_PKT_V2_CMPL_FLAGS_ITYPE_ICMP): 432 [ # # ]: 0 : if (!t_pkt) 433 : 0 : pkt_type |= l3 | RTE_PTYPE_L4_ICMP; 434 : : else 435 : 0 : pkt_type |= l3 | RTE_PTYPE_INNER_L4_ICMP; 436 : : break; 437 : 0 : case RTE_LE32(RX_PKT_V2_CMPL_FLAGS_ITYPE_TCP): 438 [ # # ]: 0 : if (!t_pkt) 439 : 0 : pkt_type |= l3 | RTE_PTYPE_L4_TCP; 440 : : else 441 : 0 : pkt_type |= l3 | RTE_PTYPE_INNER_L4_TCP; 442 : : break; 443 : 0 : case RTE_LE32(RX_PKT_V2_CMPL_FLAGS_ITYPE_UDP): 444 [ # # ]: 0 : if (!t_pkt) 445 : 0 : pkt_type |= l3 | RTE_PTYPE_L4_UDP; 446 : : else 447 : 0 : pkt_type |= l3 | RTE_PTYPE_INNER_L4_UDP; 448 : : break; 449 : 0 : case RTE_LE32(RX_PKT_V2_CMPL_FLAGS_ITYPE_IP): 450 : 0 : pkt_type |= l3; 451 : 0 : break; 452 : : } 453 : : 454 : 0 : mbuf->packet_type = pkt_type; 455 : 0 : } 456 : : 457 : : /* Thor2 specific code for RX completion parsing */ 458 : : #define RX_PKT_V3_CMPL_FLAGS2_IP_TYPE_SFT 8 459 : : #define RX_PKT_V3_CMPL_METADATA1_VALID_SFT 15 460 : : 461 : : #define BNXT_CMPL_V3_ITYPE_TO_IDX(ft) \ 462 : : (((ft) & RX_PKT_V3_CMPL_FLAGS_ITYPE_MASK) >> \ 463 : : (RX_PKT_V3_CMPL_FLAGS_ITYPE_SFT - BNXT_PTYPE_TBL_TYPE_SFT)) 464 : : 465 : : #define BNXT_CMPL_V3_VLAN_TO_IDX(meta) \ 466 : : (((meta) & (1 << RX_PKT_V3_CMPL_METADATA1_VALID_SFT)) >> \ 467 : : (RX_PKT_V3_CMPL_METADATA1_VALID_SFT - BNXT_PTYPE_TBL_VLAN_SFT)) 468 : : 469 : : #define BNXT_CMPL_V3_IP_VER_TO_IDX(f2) \ 470 : : (((f2) & RX_PKT_V3_CMPL_HI_FLAGS2_IP_TYPE) >> \ 471 : : (RX_PKT_V3_CMPL_FLAGS2_IP_TYPE_SFT - BNXT_PTYPE_TBL_IP_VER_SFT)) 472 : : 473 : : #define RX_CMP_V3_VLAN_VALID(rxcmp) \ 474 : : (((struct rx_pkt_v3_cmpl *)rxcmp)->metadata1_payload_offset & \ 475 : : RX_PKT_V3_CMPL_METADATA1_VALID) 476 : : 477 : : #define RX_CMP_V3_METADATA0_VID(rxcmp1) \ 478 : : ((((struct rx_pkt_v3_cmpl_hi *)rxcmp1)->metadata0) & \ 479 : : (RX_PKT_V3_CMPL_HI_METADATA0_VID_MASK | \ 480 : : RX_PKT_V3_CMPL_HI_METADATA0_DE | \ 481 : : RX_PKT_V3_CMPL_HI_METADATA0_PRI_MASK)) 482 : : 483 : : static inline void bnxt_rx_vlan_v3(struct rte_mbuf *mbuf, 484 : : struct rx_pkt_cmpl *rxcmp, 485 : : struct rx_pkt_cmpl_hi *rxcmp1, 486 : : bool stripped) 487 : : { 488 [ # # ]: 0 : if (RX_CMP_V3_VLAN_VALID(rxcmp)) { 489 : 0 : mbuf->vlan_tci = RX_CMP_V3_METADATA0_VID(rxcmp1); 490 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_VLAN; 491 [ # # ]: 0 : if (stripped) 492 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_VLAN_STRIPPED; 493 : : } 494 : : } 495 : : 496 : : #define RX_CMP_V3_L4_CS_ERR(err) \ 497 : : (((err) & RX_PKT_CMPL_ERRORS_MASK) \ 498 : : & (RX_PKT_CMPL_ERRORS_L4_CS_ERROR)) 499 : : #define RX_CMP_V3_L3_CS_ERR(err) \ 500 : : (((err) & RX_PKT_CMPL_ERRORS_MASK) \ 501 : : & (RX_PKT_CMPL_ERRORS_IP_CS_ERROR)) 502 : : #define RX_CMP_V3_T_IP_CS_ERR(err) \ 503 : : (((err) & RX_PKT_CMPL_ERRORS_MASK) \ 504 : : & (RX_PKT_CMPL_ERRORS_T_IP_CS_ERROR)) 505 : : #define RX_CMP_V3_T_L4_CS_ERR(err) \ 506 : : (((err) & RX_PKT_CMPL_ERRORS_MASK) \ 507 : : & (RX_PKT_CMPL_ERRORS_T_L4_CS_ERROR)) 508 : : #define RX_PKT_CMPL_CALC \ 509 : : (RX_PKT_CMPL_FLAGS2_IP_CS_CALC | \ 510 : : RX_PKT_CMPL_FLAGS2_L4_CS_CALC | \ 511 : : RX_PKT_CMPL_FLAGS2_T_IP_CS_CALC | \ 512 : : RX_PKT_CMPL_FLAGS2_T_L4_CS_CALC) 513 : : 514 : : static inline uint64_t 515 : 0 : bnxt_parse_csum_fields_v3(uint32_t flags2, uint32_t error_v2) 516 : : { 517 : : uint64_t ol_flags = 0; 518 : : 519 [ # # ]: 0 : if (flags2 & RX_PKT_CMPL_CALC) { 520 [ # # ]: 0 : if (unlikely(RX_CMP_V3_L4_CS_ERR(error_v2))) 521 : : ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD; 522 : : else 523 : : ol_flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD; 524 [ # # ]: 0 : if (unlikely(RX_CMP_V3_L3_CS_ERR(error_v2))) 525 : 0 : ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD; 526 [ # # ]: 0 : if (unlikely(RX_CMP_V3_T_L4_CS_ERR(error_v2))) 527 : 0 : ol_flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_BAD; 528 : : else 529 : 0 : ol_flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD; 530 [ # # ]: 0 : if (unlikely(RX_CMP_V3_T_IP_CS_ERR(error_v2))) 531 : 0 : ol_flags |= RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD; 532 [ # # ]: 0 : if (!(ol_flags & (RTE_MBUF_F_RX_IP_CKSUM_BAD | RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD))) 533 : 0 : ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD; 534 : : } else { 535 : : /* Unknown is defined as 0 for all packets types hence using below for all */ 536 : : ol_flags |= RTE_MBUF_F_RX_IP_CKSUM_UNKNOWN; 537 : : } 538 : 0 : return ol_flags; 539 : : } 540 : : 541 : : static inline void 542 : : bnxt_parse_csum_v3(struct rte_mbuf *mbuf, struct rx_pkt_cmpl_hi *rxcmp1) 543 : : { 544 : : struct rx_pkt_v3_cmpl_hi *v3_cmp = 545 : : (struct rx_pkt_v3_cmpl_hi *)(rxcmp1); 546 : 0 : uint16_t error_v2 = rte_le_to_cpu_16(v3_cmp->errors_v2); 547 : 0 : uint32_t flags2 = rte_le_to_cpu_32(v3_cmp->flags2); 548 : : 549 [ # # ]: 0 : mbuf->ol_flags |= bnxt_parse_csum_fields_v3(flags2, error_v2); 550 : : } 551 : : #endif /* _BNXT_RXR_H_ */