| 309 | } |
| 310 | |
| 311 | static inline void ff_offload_set(struct ff_dpdk_if_context *ctx, void *m, struct rte_mbuf *head) |
| 312 | { |
| 313 | void *data = NULL; |
| 314 | struct ff_tx_offload offload = {0}; |
| 315 | |
| 316 | ff_mbuf_tx_offload(m, &offload); |
| 317 | data = rte_pktmbuf_mtod(head, void*); |
| 318 | |
| 319 | if (offload.ip_csum) { |
| 320 | /* ipv6 not supported yet */ |
| 321 | struct rte_ipv4_hdr *iph; |
| 322 | int iph_len; |
| 323 | iph = (struct rte_ipv4_hdr *)(data + RTE_ETHER_HDR_LEN); |
| 324 | iph_len = (iph->version_ihl & 0x0f) << 2; |
| 325 | |
| 326 | head->ol_flags |= RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_IPV4; |
| 327 | head->l2_len = RTE_ETHER_HDR_LEN; |
| 328 | head->l3_len = iph_len; |
| 329 | } |
| 330 | |
| 331 | if (ctx->hw_features.tx_csum_l4) { |
| 332 | struct rte_ipv4_hdr *iph; |
| 333 | int iph_len; |
| 334 | iph = (struct rte_ipv4_hdr *)(data + RTE_ETHER_HDR_LEN); |
| 335 | iph_len = (iph->version_ihl & 0x0f) << 2; |
| 336 | |
| 337 | if (offload.tcp_csum) { |
| 338 | head->ol_flags |= RTE_MBUF_F_TX_TCP_CKSUM; |
| 339 | head->l2_len = RTE_ETHER_HDR_LEN; |
| 340 | head->l3_len = iph_len; |
| 341 | } |
| 342 | |
| 343 | /* |
| 344 | * TCP segmentation offload. |
| 345 | * |
| 346 | * - set the PKT_TX_TCP_SEG flag in mbuf->ol_flags (this flag |
| 347 | * implies PKT_TX_TCP_CKSUM) |
| 348 | * - set the flag PKT_TX_IPV4 or PKT_TX_IPV6 |
| 349 | * - if it's IPv4, set the PKT_TX_IP_CKSUM flag and |
| 350 | * write the IP checksum to 0 in the packet |
| 351 | * - fill the mbuf offload information: l2_len, |
| 352 | * l3_len, l4_len, tso_segsz |
| 353 | * - calculate the pseudo header checksum without taking ip_len |
| 354 | * in account, and set it in the TCP header. Refer to |
| 355 | * rte_ipv4_phdr_cksum() and rte_ipv6_phdr_cksum() that can be |
| 356 | * used as helpers. |
| 357 | */ |
| 358 | if (offload.tso_seg_size) { |
| 359 | struct rte_tcp_hdr *tcph; |
| 360 | int tcph_len; |
| 361 | tcph = (struct rte_tcp_hdr *)((char *)iph + iph_len); |
| 362 | tcph_len = (tcph->data_off & 0xf0) >> 2; |
| 363 | tcph->cksum = rte_ipv4_phdr_cksum(iph, RTE_MBUF_F_TX_TCP_SEG); |
| 364 | |
| 365 | head->ol_flags |= RTE_MBUF_F_TX_TCP_SEG; |
| 366 | head->l4_len = tcph_len; |
| 367 | head->tso_segsz = offload.tso_seg_size; |
| 368 | } |
no test coverage detected