1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright(c) 2019-2021 Xilinx, Inc.
4 * Copyright(c) 2018-2019 Solarflare Communications Inc.
6 * This software was jointly developed between OKTET Labs (under contract
7 * for Solarflare) and Solarflare Communications, Inc.
19 /** Standard TSO header length */
20 #define SFC_TSOH_STD_LEN 256
22 /** The number of TSO option descriptors that precede the packet descriptors */
23 #define SFC_EF10_TSO_OPT_DESCS_NUM 2
26 * The number of DMA descriptors for TSO header that may or may not precede the
27 * packet's payload descriptors
29 #define SFC_EF10_TSO_HDR_DESCS_NUM 1
31 static inline uint16_t
32 sfc_tso_ip4_get_ipid(const uint8_t *pkt_hdrp, size_t ip_hdr_off)
34 const struct rte_ipv4_hdr *ip_hdrp;
37 ip_hdrp = (const struct rte_ipv4_hdr *)(pkt_hdrp + ip_hdr_off);
38 rte_memcpy(&ipid, &ip_hdrp->packet_id, sizeof(ipid));
40 return rte_be_to_cpu_16(ipid);
44 sfc_tso_outer_udp_fix_len(const struct rte_mbuf *m, uint8_t *tsoh)
46 rte_be16_t len = rte_cpu_to_be_16(m->l2_len + m->l3_len + m->l4_len +
49 rte_memcpy(tsoh + m->outer_l2_len + m->outer_l3_len +
50 offsetof(struct rte_udp_hdr, dgram_len),
55 sfc_tso_innermost_ip_fix_len(const struct rte_mbuf *m, uint8_t *tsoh,
58 size_t ip_payload_len = m->l4_len + m->tso_segsz;
62 if (m->ol_flags & PKT_TX_IPV4) {
63 field_ofst = offsetof(struct rte_ipv4_hdr, total_length);
64 len = rte_cpu_to_be_16(m->l3_len + ip_payload_len);
66 field_ofst = offsetof(struct rte_ipv6_hdr, payload_len);
67 len = rte_cpu_to_be_16(ip_payload_len);
70 rte_memcpy(tsoh + iph_ofst + field_ofst, &len, sizeof(len));
73 unsigned int sfc_tso_prepare_header(uint8_t *tsoh, size_t header_len,
74 struct rte_mbuf **in_seg, size_t *in_off);
80 #endif /* _SFC_TSO_H */