1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2018 Solarflare Communications Inc.
6 * This software was jointly developed between OKTET Labs (under contract
7 * for Solarflare) and Solarflare Communications, Inc.
10 #ifndef _SFC_EF10_RX_EV_H
11 #define _SFC_EF10_RX_EV_H
15 #include "efx_types.h"
17 #include "efx_regs_ef10.h"
24 sfc_ef10_rx_ev_to_offloads(const efx_qword_t rx_ev, struct rte_mbuf *m,
27 uint32_t tun_ptype = 0;
28 /* Which event bit is mapped to PKT_RX_IP_CKSUM_* */
29 int8_t ip_csum_err_bit;
30 /* Which event bit is mapped to PKT_RX_L4_CKSUM_* */
31 int8_t l4_csum_err_bit;
32 uint32_t l2_ptype = 0;
33 uint32_t l3_ptype = 0;
34 uint32_t l4_ptype = 0;
35 uint64_t ol_flags = 0;
37 if (unlikely(rx_ev.eq_u64[0] &
38 rte_cpu_to_le_64((1ull << ESF_DZ_RX_ECC_ERR_LBN) |
39 (1ull << ESF_DZ_RX_ECRC_ERR_LBN) |
40 (1ull << ESF_DZ_RX_PARSE_INCOMPLETE_LBN))))
43 #if SFC_EF10_RX_EV_ENCAP_SUPPORT
44 switch (EFX_QWORD_FIELD(rx_ev, ESF_EZ_RX_ENCAP_HDR)) {
46 /* Unexpected encapsulation tag class */
49 case ESE_EZ_ENCAP_HDR_NONE:
51 case ESE_EZ_ENCAP_HDR_VXLAN:
53 * It is definitely UDP, but we have no information
54 * about IPv4 vs IPv6 and VLAN tagging.
56 tun_ptype = RTE_PTYPE_TUNNEL_VXLAN | RTE_PTYPE_L4_UDP;
58 case ESE_EZ_ENCAP_HDR_GRE:
60 * We have no information about IPv4 vs IPv6 and VLAN tagging.
62 tun_ptype = RTE_PTYPE_TUNNEL_NVGRE;
68 ip_csum_err_bit = ESF_DZ_RX_IPCKSUM_ERR_LBN;
69 l4_csum_err_bit = ESF_DZ_RX_TCPUDP_CKSUM_ERR_LBN;
71 ip_csum_err_bit = ESF_EZ_RX_IP_INNER_CHKSUM_ERR_LBN;
72 l4_csum_err_bit = ESF_EZ_RX_TCP_UDP_INNER_CHKSUM_ERR_LBN;
73 if (unlikely(EFX_TEST_QWORD_BIT(rx_ev,
74 ESF_DZ_RX_IPCKSUM_ERR_LBN)))
75 ol_flags |= PKT_RX_EIP_CKSUM_BAD;
78 switch (EFX_QWORD_FIELD(rx_ev, ESF_DZ_RX_ETH_TAG_CLASS)) {
79 case ESE_DZ_ETH_TAG_CLASS_NONE:
80 l2_ptype = (tun_ptype == 0) ? RTE_PTYPE_L2_ETHER :
81 RTE_PTYPE_INNER_L2_ETHER;
83 case ESE_DZ_ETH_TAG_CLASS_VLAN1:
84 l2_ptype = (tun_ptype == 0) ? RTE_PTYPE_L2_ETHER_VLAN :
85 RTE_PTYPE_INNER_L2_ETHER_VLAN;
87 case ESE_DZ_ETH_TAG_CLASS_VLAN2:
88 l2_ptype = (tun_ptype == 0) ? RTE_PTYPE_L2_ETHER_QINQ :
89 RTE_PTYPE_INNER_L2_ETHER_QINQ;
92 /* Unexpected Eth tag class */
96 switch (EFX_QWORD_FIELD(rx_ev, ESF_DZ_RX_L3_CLASS)) {
97 case ESE_DZ_L3_CLASS_IP4_FRAG:
98 l4_ptype = (tun_ptype == 0) ? RTE_PTYPE_L4_FRAG :
99 RTE_PTYPE_INNER_L4_FRAG;
101 case ESE_DZ_L3_CLASS_IP4:
102 l3_ptype = (tun_ptype == 0) ? RTE_PTYPE_L3_IPV4_EXT_UNKNOWN :
103 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
104 ol_flags |= PKT_RX_RSS_HASH |
105 ((EFX_TEST_QWORD_BIT(rx_ev, ip_csum_err_bit)) ?
106 PKT_RX_IP_CKSUM_BAD : PKT_RX_IP_CKSUM_GOOD);
108 case ESE_DZ_L3_CLASS_IP6_FRAG:
109 l4_ptype = (tun_ptype == 0) ? RTE_PTYPE_L4_FRAG :
110 RTE_PTYPE_INNER_L4_FRAG;
112 case ESE_DZ_L3_CLASS_IP6:
113 l3_ptype = (tun_ptype == 0) ? RTE_PTYPE_L3_IPV6_EXT_UNKNOWN :
114 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
115 ol_flags |= PKT_RX_RSS_HASH;
117 case ESE_DZ_L3_CLASS_ARP:
118 /* Override Layer 2 packet type */
119 /* There is no ARP classification for inner packets */
121 l2_ptype = RTE_PTYPE_L2_ETHER_ARP;
124 /* Unexpected Layer 3 class */
129 * RX_L4_CLASS is 3 bits wide on Huntington and Medford, but is only
130 * 2 bits wide on Medford2. Check it is safe to use the Medford2 field
131 * and values for all EF10 controllers.
133 RTE_BUILD_BUG_ON(ESF_FZ_RX_L4_CLASS_LBN != ESF_DE_RX_L4_CLASS_LBN);
134 switch (EFX_QWORD_FIELD(rx_ev, ESF_FZ_RX_L4_CLASS)) {
135 case ESE_FZ_L4_CLASS_TCP:
136 RTE_BUILD_BUG_ON(ESE_FZ_L4_CLASS_TCP != ESE_DE_L4_CLASS_TCP);
137 l4_ptype = (tun_ptype == 0) ? RTE_PTYPE_L4_TCP :
138 RTE_PTYPE_INNER_L4_TCP;
140 (EFX_TEST_QWORD_BIT(rx_ev, l4_csum_err_bit)) ?
141 PKT_RX_L4_CKSUM_BAD : PKT_RX_L4_CKSUM_GOOD;
143 case ESE_FZ_L4_CLASS_UDP:
144 RTE_BUILD_BUG_ON(ESE_FZ_L4_CLASS_UDP != ESE_DE_L4_CLASS_UDP);
145 l4_ptype = (tun_ptype == 0) ? RTE_PTYPE_L4_UDP :
146 RTE_PTYPE_INNER_L4_UDP;
148 (EFX_TEST_QWORD_BIT(rx_ev, l4_csum_err_bit)) ?
149 PKT_RX_L4_CKSUM_BAD : PKT_RX_L4_CKSUM_GOOD;
151 case ESE_FZ_L4_CLASS_UNKNOWN:
152 RTE_BUILD_BUG_ON(ESE_FZ_L4_CLASS_UNKNOWN !=
153 ESE_DE_L4_CLASS_UNKNOWN);
156 /* Unexpected Layer 4 class */
161 m->ol_flags = ol_flags & ol_mask;
162 m->packet_type = tun_ptype | l2_ptype | l3_ptype | l4_ptype;
169 #endif /* _SFC_EF10_RX_EV_H */