+/* Calculate TCP header length for PKT_TX_TCP_CKSUM if not provided */
+static inline uint16_t
+ice_calc_pkt_tcp_hdr(struct rte_mbuf *tx_pkt, union ice_tx_offload tx_offload)
+{
+ uint16_t tcpoff = tx_offload.l2_len + tx_offload.l3_len;
+ const struct rte_tcp_hdr *tcp_hdr;
+ struct rte_tcp_hdr _tcp_hdr;
+
+ if (tcpoff + sizeof(struct rte_tcp_hdr) < tx_pkt->data_len) {
+ tcp_hdr = rte_pktmbuf_mtod_offset(tx_pkt, struct rte_tcp_hdr *,
+ tcpoff);
+
+ return (tcp_hdr->data_off & 0xf0) >> 2;
+ }
+
+ tcp_hdr = rte_pktmbuf_read(tx_pkt, tcpoff, sizeof(_tcp_hdr), &_tcp_hdr);
+ if (tcp_hdr)
+ return (tcp_hdr->data_off & 0xf0) >> 2;
+ else
+ return 0;
+}
+