| 244 | } |
| 245 | |
| 246 | static inline void dpaa_checksum(struct rte_mbuf *mbuf) |
| 247 | { |
| 248 | struct rte_ether_hdr *eth_hdr = |
| 249 | rte_pktmbuf_mtod(mbuf, struct rte_ether_hdr *); |
| 250 | char *l3_hdr = (char *)eth_hdr + mbuf->l2_len; |
| 251 | struct rte_ipv4_hdr *ipv4_hdr = (struct rte_ipv4_hdr *)l3_hdr; |
| 252 | struct rte_ipv6_hdr *ipv6_hdr = (struct rte_ipv6_hdr *)l3_hdr; |
| 253 | |
| 254 | DPAA_DP_LOG(DEBUG, "Calculating checksum for mbuf: %p", mbuf); |
| 255 | |
| 256 | if (((mbuf->packet_type & RTE_PTYPE_L3_MASK) == RTE_PTYPE_L3_IPV4) || |
| 257 | ((mbuf->packet_type & RTE_PTYPE_L3_MASK) == |
| 258 | RTE_PTYPE_L3_IPV4_EXT)) { |
| 259 | ipv4_hdr = (struct rte_ipv4_hdr *)l3_hdr; |
| 260 | ipv4_hdr->hdr_checksum = 0; |
| 261 | ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); |
| 262 | } else if (((mbuf->packet_type & RTE_PTYPE_L3_MASK) == |
| 263 | RTE_PTYPE_L3_IPV6) || |
| 264 | ((mbuf->packet_type & RTE_PTYPE_L3_MASK) == |
| 265 | RTE_PTYPE_L3_IPV6_EXT)) |
| 266 | ipv6_hdr = (struct rte_ipv6_hdr *)l3_hdr; |
| 267 | |
| 268 | if ((mbuf->packet_type & RTE_PTYPE_L4_MASK) == RTE_PTYPE_L4_TCP) { |
| 269 | struct rte_tcp_hdr *tcp_hdr = (struct rte_tcp_hdr *)(l3_hdr + |
| 270 | mbuf->l3_len); |
| 271 | tcp_hdr->cksum = 0; |
| 272 | if (eth_hdr->ether_type == htons(RTE_ETHER_TYPE_IPV4)) |
| 273 | tcp_hdr->cksum = rte_ipv4_udptcp_cksum(ipv4_hdr, |
| 274 | tcp_hdr); |
| 275 | else /* assume ethertype == RTE_ETHER_TYPE_IPV6 */ |
| 276 | tcp_hdr->cksum = rte_ipv6_udptcp_cksum(ipv6_hdr, |
| 277 | tcp_hdr); |
| 278 | } else if ((mbuf->packet_type & RTE_PTYPE_L4_MASK) == |
| 279 | RTE_PTYPE_L4_UDP) { |
| 280 | struct rte_udp_hdr *udp_hdr = (struct rte_udp_hdr *)(l3_hdr + |
| 281 | mbuf->l3_len); |
| 282 | udp_hdr->dgram_cksum = 0; |
| 283 | if (eth_hdr->ether_type == htons(RTE_ETHER_TYPE_IPV4)) |
| 284 | udp_hdr->dgram_cksum = rte_ipv4_udptcp_cksum(ipv4_hdr, |
| 285 | udp_hdr); |
| 286 | else /* assume ethertype == RTE_ETHER_TYPE_IPV6 */ |
| 287 | udp_hdr->dgram_cksum = rte_ipv6_udptcp_cksum(ipv6_hdr, |
| 288 | udp_hdr); |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | static inline void dpaa_checksum_offload(struct rte_mbuf *mbuf, |
| 293 | struct qm_fd *fd, char *prs_buf) |
no test coverage detected