return -EBUSY;
*rx_pkt = mbuf;
goto next_rx;
- } else if (cmp_type != 0x11) {
+ } else if ((cmp_type != CMPL_BASE_TYPE_RX_L2) &&
+ (cmp_type != CMPL_BASE_TYPE_RX_L2_V2)) {
rc = -EINVAL;
goto next_rx;
}
mbuf->data_len = mbuf->pkt_len;
mbuf->port = rxq->port_id;
- bnxt_set_ol_flags(rxr, rxcmp, rxcmp1, mbuf);
-
#ifdef RTE_LIBRTE_IEEE1588
if (unlikely((rte_le_to_cpu_16(rxcmp->flags_type) &
RX_PKT_CMPL_FLAGS_MASK) ==
}
#endif
+ if (cmp_type == CMPL_BASE_TYPE_RX_L2_V2) {
+ bnxt_parse_csum_v2(mbuf, rxcmp1);
+ bnxt_parse_pkt_type_v2(mbuf, rxcmp, rxcmp1);
+ bnxt_rx_vlan_v2(mbuf, rxcmp, rxcmp1);
+ /* TODO Add support for cfa_code parsing */
+ goto reuse_rx_mbuf;
+ }
+
+ bnxt_set_ol_flags(rxr, rxcmp, rxcmp1, mbuf);
+
+ mbuf->packet_type = bnxt_parse_pkt_type(rxcmp, rxcmp1);
+
if (BNXT_TRUFLOW_EN(bp))
mark_id = bnxt_ulp_set_mark_in_mbuf(rxq->bp, rxcmp1, mbuf,
&vfr_flag);
else
bnxt_set_mark_in_mbuf(rxq->bp, rxcmp1, mbuf);
+reuse_rx_mbuf:
if (agg_buf)
bnxt_rx_pages(rxq, mbuf, &tmp_raw_cons, agg_buf, NULL);
- mbuf->packet_type = bnxt_parse_pkt_type(rxcmp, rxcmp1);
-
#ifdef BNXT_DEBUG
if (rxcmp1->errors_v2 & RX_CMP_L2_ERRORS) {
/* Re-install the mbuf back to the rx ring */
cpr->cp_ring_struct->ring_mask,
cpr->valid);
- /* TODO: Avoid magic numbers... */
- if ((CMP_TYPE(rxcmp) & 0x30) == 0x10) {
+ if ((CMP_TYPE(rxcmp) >= CMPL_BASE_TYPE_RX_TPA_START_V2) &&
+ (CMP_TYPE(rxcmp) <= RX_TPA_V2_ABUF_CMPL_TYPE_RX_TPA_AGG)) {
rc = bnxt_rx_pkt(&rx_pkts[nb_rx_pkts], rxq, &raw_cons);
if (!rc)
nb_rx_pkts++;
#define BNXT_PTYPE_TBL_DIM 128
extern uint32_t bnxt_ptype_table[BNXT_PTYPE_TBL_DIM];
+/* Stingray2 specific code for RX completion parsing */
+#define RX_CMP_VLAN_VALID(rxcmp) \
+ (((struct rx_pkt_v2_cmpl *)rxcmp)->metadata1_payload_offset & \
+ RX_PKT_V2_CMPL_METADATA1_VALID)
+
+#define RX_CMP_METADATA0_VID(rxcmp1) \
+ ((((struct rx_pkt_v2_cmpl_hi *)rxcmp1)->metadata0) & \
+ (RX_PKT_V2_CMPL_HI_METADATA0_VID_MASK | \
+ RX_PKT_V2_CMPL_HI_METADATA0_DE | \
+ RX_PKT_V2_CMPL_HI_METADATA0_PRI_MASK))
+
+static inline void bnxt_rx_vlan_v2(struct rte_mbuf *mbuf,
+ struct rx_pkt_cmpl *rxcmp,
+ struct rx_pkt_cmpl_hi *rxcmp1)
+{
+ if (RX_CMP_VLAN_VALID(rxcmp)) {
+ mbuf->vlan_tci = RX_CMP_METADATA0_VID(rxcmp1);
+ mbuf->ol_flags |= PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED;
+ }
+}
+
+#define RX_CMP_FLAGS2_CS_ALL_OK_MODE_MASK (0x1 << 3)
+#define RX_CMP_FLAGS2_CS_OK_HDR_CNT_MASK (0x7 << 10)
+#define RX_CMP_FLAGS2_IP_CSUM_ALL_OK_MASK (0x1 << 13)
#define RX_CMP_FLAGS2_L4_CSUM_ALL_OK_MASK (0x1 << 14)
+
+#define RX_CMP_V2_CS_OK_HDR_CNT(flags) \
+ (((flags) & RX_CMP_FLAGS2_CS_OK_HDR_CNT_MASK) >> \
+ RX_PKT_V2_CMPL_HI_FLAGS2_CS_OK_SFT)
+
+#define RX_CMP_V2_CS_ALL_OK_MODE(flags) \
+ (((flags) & RX_CMP_FLAGS2_CS_ALL_OK_MODE_MASK))
+
+#define RX_CMP_FLAGS2_L3_CS_OK_MASK (0x7 << 10)
+#define RX_CMP_FLAGS2_L4_CS_OK_MASK (0x38 << 10)
+#define RX_CMP_FLAGS2_L3_CS_OK_SFT 10
+#define RX_CMP_FLAGS2_L4_CS_OK_SFT 13
+
+#define RX_CMP_V2_L4_CS_OK(flags2) \
+ (((flags2) & RX_CMP_FLAGS2_L4_CS_OK_MASK) >> \
+ RX_CMP_FLAGS2_L4_CS_OK_SFT)
+
+#define RX_CMP_V2_L3_CS_OK(flags2) \
+ (((flags2) & RX_CMP_FLAGS2_L3_CS_OK_MASK) >> \
+ RX_CMP_FLAGS2_L3_CS_OK_SFT)
+
+#define RX_CMP_V2_L4_CS_ERR(err) \
+ (((err) & RX_PKT_V2_CMPL_HI_ERRORS_PKT_ERROR_MASK) == \
+ RX_PKT_V2_CMPL_HI_ERRORS_PKT_ERROR_L4_CS_ERROR)
+
+#define RX_CMP_V2_L3_CS_ERR(err) \
+ (((err) & RX_PKT_V2_CMPL_HI_ERRORS_PKT_ERROR_MASK) == \
+ RX_PKT_V2_CMPL_HI_ERRORS_PKT_ERROR_IP_CS_ERROR)
+
+#define RX_CMP_V2_T_IP_CS_ERR(err) \
+ (((err) & RX_PKT_V2_CMPL_HI_ERRORS_T_PKT_ERROR_MASK) == \
+ RX_PKT_V2_CMPL_HI_ERRORS_T_PKT_ERROR_T_IP_CS_ERROR)
+
+#define RX_CMP_V2_T_L4_CS_ERR(err) \
+ (((err) & RX_PKT_V2_CMPL_HI_ERRORS_T_PKT_ERROR_MASK) == \
+ RX_PKT_V2_CMPL_HI_ERRORS_T_PKT_ERROR_T_L4_CS_ERROR)
+
+#define RX_CMP_V2_OT_L4_CS_ERR(err) \
+ (((err) & RX_PKT_V2_CMPL_HI_ERRORS_OT_PKT_ERROR_MASK) == \
+ RX_PKT_V2_CMPL_HI_ERRORS_OT_PKT_ERROR_OT_L4_CS_ERROR)
+
+static inline void bnxt_parse_csum_v2(struct rte_mbuf *mbuf,
+ struct rx_pkt_cmpl_hi *rxcmp1)
+{
+ struct rx_pkt_v2_cmpl_hi *v2_cmp =
+ (struct rx_pkt_v2_cmpl_hi *)(rxcmp1);
+ uint16_t error_v2 = rte_le_to_cpu_16(v2_cmp->errors_v2);
+ uint32_t flags2 = rte_le_to_cpu_32(v2_cmp->flags2);
+ uint32_t hdr_cnt = 0, t_pkt = 0;
+
+ if (RX_CMP_V2_CS_ALL_OK_MODE(flags2)) {
+ hdr_cnt = RX_CMP_V2_CS_OK_HDR_CNT(flags2);
+ if (hdr_cnt > 1)
+ t_pkt = 1;
+
+ if (unlikely(RX_CMP_V2_L4_CS_ERR(error_v2)))
+ mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
+ else if (flags2 & RX_CMP_FLAGS2_L4_CSUM_ALL_OK_MASK)
+ mbuf->ol_flags |= PKT_RX_L4_CKSUM_GOOD;
+ else
+ mbuf->ol_flags |= PKT_RX_L4_CKSUM_UNKNOWN;
+
+ if (unlikely(RX_CMP_V2_L3_CS_ERR(error_v2)))
+ mbuf->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+ else if (flags2 & RX_CMP_FLAGS2_IP_CSUM_ALL_OK_MASK)
+ mbuf->ol_flags |= PKT_RX_IP_CKSUM_GOOD;
+ else
+ mbuf->ol_flags |= PKT_RX_IP_CKSUM_UNKNOWN;
+ } else {
+ hdr_cnt = RX_CMP_V2_L4_CS_OK(flags2);
+ if (hdr_cnt > 1)
+ t_pkt = 1;
+
+ if (RX_CMP_V2_L4_CS_OK(flags2))
+ mbuf->ol_flags |= PKT_RX_L4_CKSUM_GOOD;
+ else if (RX_CMP_V2_L4_CS_ERR(error_v2))
+ mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
+ else
+ mbuf->ol_flags |= PKT_RX_L4_CKSUM_UNKNOWN;
+
+ if (RX_CMP_V2_L3_CS_OK(flags2))
+ mbuf->ol_flags |= PKT_RX_IP_CKSUM_GOOD;
+ else if (RX_CMP_V2_L3_CS_ERR(error_v2))
+ mbuf->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+ else
+ mbuf->ol_flags |= PKT_RX_IP_CKSUM_UNKNOWN;
+ }
+
+ if (t_pkt) {
+ if (unlikely(RX_CMP_V2_OT_L4_CS_ERR(error_v2) ||
+ RX_CMP_V2_T_L4_CS_ERR(error_v2)))
+ mbuf->ol_flags |= PKT_RX_OUTER_L4_CKSUM_BAD;
+ else
+ mbuf->ol_flags |= PKT_RX_OUTER_L4_CKSUM_GOOD;
+
+ if (unlikely(RX_CMP_V2_T_IP_CS_ERR(error_v2)))
+ mbuf->ol_flags |= PKT_RX_IP_CKSUM_BAD;
+ }
+}
+
+static inline void
+bnxt_parse_pkt_type_v2(struct rte_mbuf *mbuf,
+ struct rx_pkt_cmpl *rxcmp,
+ struct rx_pkt_cmpl_hi *rxcmp1)
+{
+ struct rx_pkt_v2_cmpl *v2_cmp =
+ (struct rx_pkt_v2_cmpl *)(rxcmp);
+ struct rx_pkt_v2_cmpl_hi *v2_cmp1 =
+ (struct rx_pkt_v2_cmpl_hi *)(rxcmp1);
+ uint16_t flags_type = v2_cmp->flags_type &
+ rte_cpu_to_le_32(RX_PKT_V2_CMPL_FLAGS_ITYPE_MASK);
+ uint32_t flags2 = rte_le_to_cpu_32(v2_cmp1->flags2);
+ uint32_t l3, pkt_type = 0, vlan = 0;
+ uint32_t ip6 = 0, t_pkt = 0;
+ uint32_t hdr_cnt, csum_count;
+
+ if (RX_CMP_V2_CS_ALL_OK_MODE(flags2)) {
+ hdr_cnt = RX_CMP_V2_CS_OK_HDR_CNT(flags2);
+ if (hdr_cnt > 1)
+ t_pkt = 1;
+ } else {
+ csum_count = RX_CMP_V2_L4_CS_OK(flags2);
+ if (csum_count > 1)
+ t_pkt = 1;
+ }
+
+ vlan = !!RX_CMP_VLAN_VALID(rxcmp);
+ pkt_type |= vlan ? RTE_PTYPE_L2_ETHER_VLAN : RTE_PTYPE_L2_ETHER;
+
+ ip6 = !!(flags2 & RX_PKT_V2_CMPL_HI_FLAGS2_IP_TYPE);
+
+ if (!t_pkt && !ip6)
+ l3 = RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
+ else if (!t_pkt && ip6)
+ l3 = RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
+ else if (t_pkt && !ip6)
+ l3 = RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
+ else
+ l3 = RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
+
+ switch (flags_type) {
+ case RTE_LE32(RX_PKT_V2_CMPL_FLAGS_ITYPE_ICMP):
+ if (!t_pkt)
+ pkt_type |= l3 | RTE_PTYPE_L4_ICMP;
+ else
+ pkt_type |= l3 | RTE_PTYPE_INNER_L4_ICMP;
+ break;
+ case RTE_LE32(RX_PKT_V2_CMPL_FLAGS_ITYPE_TCP):
+ if (!t_pkt)
+ pkt_type |= l3 | RTE_PTYPE_L4_TCP;
+ else
+ pkt_type |= l3 | RTE_PTYPE_INNER_L4_TCP;
+ break;
+ case RTE_LE32(RX_PKT_V2_CMPL_FLAGS_ITYPE_UDP):
+ if (!t_pkt)
+ pkt_type |= l3 | RTE_PTYPE_L4_UDP;
+ else
+ pkt_type |= l3 | RTE_PTYPE_INNER_L4_UDP;
+ break;
+ case RTE_LE32(RX_PKT_V2_CMPL_FLAGS_ITYPE_IP):
+ pkt_type |= l3;
+ break;
+ }
+
+ mbuf->packet_type = pkt_type;
+}
+
#endif /* _BNXT_RXR_H_ */