#include <rte_sctp.h>
#include <rte_udp.h>
#include <rte_ip.h>
-#ifdef __ARM64_NEON__
+#ifdef RTE_ARCH_ARM64
#include <arm_neon.h>
#endif
/* packet header and tx offload info */
#define ETHER_LEN_NO_VLAN 14
#define ETHER_LEN_WITH_VLAN 18
-#define HEADER_LEN_OFFSET 2
#define VXLANLEN 8
#define MAX_PLD_OFFSET 221
#define MAX_SINGLE_SGE_SIZE 65536
#define HINIC_TSO_PKT_MAX_SGE 127 /* tso max sge 127 */
#define HINIC_TSO_SEG_NUM_INVALID(num) ((num) > HINIC_TSO_PKT_MAX_SGE)
-#define HINIC_TX_OUTER_CHECKSUM_FLAG_SET 1
-#define HINIC_TX_OUTER_CHECKSUM_FLAG_NO_SET 0
-
/* sizeof(struct hinic_sq_bufdesc) == 16, shift 4 */
#define HINIC_BUF_DESC_SIZE(nr_descs) (SIZE_8BYTES(((u32)nr_descs) << 4))
static inline void hinic_sq_wqe_cpu_to_be32(void *data, int nr_wqebb)
{
-#if defined(__X86_64_SSE__)
+#if defined(RTE_ARCH_X86_64)
int i;
__m128i *wqe_line = (__m128i *)data;
__m128i shuf_mask = _mm_set_epi8(12, 13, 14, 15, 8, 9, 10,
wqe_line[3] = _mm_shuffle_epi8(wqe_line[3], shuf_mask);
wqe_line += 4;
}
-#elif defined(__ARM64_NEON__)
+#elif defined(RTE_ARCH_ARM64)
int i;
uint8x16_t *wqe_line = (uint8x16_t *)data;
const uint8x16_t shuf_mask = {3, 2, 1, 0, 7, 6, 5, 4, 11, 10,
static inline void hinic_sge_cpu_to_be32(void *data, int nr_sge)
{
-#if defined(__X86_64_SSE__)
+#if defined(RTE_ARCH_X86_64)
int i;
__m128i *sge_line = (__m128i *)data;
__m128i shuf_mask = _mm_set_epi8(12, 13, 14, 15, 8, 9, 10,
*sge_line = _mm_shuffle_epi8(*sge_line, shuf_mask);
sge_line++;
}
-#elif defined(__ARM64_NEON__)
+#elif defined(RTE_ARCH_ARM64)
int i;
uint8x16_t *sge_line = (uint8x16_t *)data;
const uint8x16_t shuf_mask = {3, 2, 1, 0, 7, 6, 5, 4, 11, 10,
static inline struct hinic_sq_wqe *
hinic_get_sq_wqe(struct hinic_txq *txq, int wqebb_cnt,
- struct hinic_wqe_info *wqe_info)
+ struct hinic_wqe_info *wqe_info)
{
u32 cur_pi, end_pi;
u16 remain_wqebbs;
uint8_t proto; /* L4 protocol type. */
uint16_t len; /* L4 length. */
} psd_hdr;
- uint8_t ihl;
psd_hdr.src_addr = ipv4_hdr->src_addr;
psd_hdr.dst_addr = ipv4_hdr->dst_addr;
if (ol_flags & PKT_TX_TCP_SEG) {
psd_hdr.len = 0;
} else {
- /* ipv4_hdr->version_ihl is uint8_t big endian, ihl locates
- * lower 4 bits and unit is 4 bytes
- */
- ihl = (ipv4_hdr->version_ihl & 0xF) << 2;
psd_hdr.len =
rte_cpu_to_be_16(rte_be_to_cpu_16(ipv4_hdr->total_length) -
- ihl);
+ rte_ipv4_hdr_len(ipv4_hdr));
}
return rte_raw_cksum(&psd_hdr, sizeof(psd_hdr));
}
return __rte_raw_cksum_reduce(sum);
}
-static inline void
-hinic_get_pld_offset(struct rte_mbuf *m, struct hinic_tx_offload_info *off_info,
- int outer_cs_flag)
+static inline void hinic_get_outer_cs_pld_offset(struct rte_mbuf *m,
+ struct hinic_tx_offload_info *off_info)
{
uint64_t ol_flags = m->ol_flags;
- if (outer_cs_flag == 1) {
- if ((ol_flags & PKT_TX_UDP_CKSUM) == PKT_TX_UDP_CKSUM) {
- off_info->payload_offset = m->outer_l2_len +
- m->outer_l3_len + m->l2_len + m->l3_len;
- } else if ((ol_flags & PKT_TX_TCP_CKSUM) ||
- (ol_flags & PKT_TX_TCP_SEG)) {
- off_info->payload_offset = m->outer_l2_len +
- m->outer_l3_len + m->l2_len +
- m->l3_len + m->l4_len;
- }
- } else {
- if ((ol_flags & PKT_TX_UDP_CKSUM) == PKT_TX_UDP_CKSUM) {
- off_info->payload_offset = m->l2_len + m->l3_len;
- } else if ((ol_flags & PKT_TX_TCP_CKSUM) ||
- (ol_flags & PKT_TX_TCP_SEG)) {
- off_info->payload_offset = m->l2_len + m->l3_len +
- m->l4_len;
- }
- }
+ if ((ol_flags & PKT_TX_L4_MASK) == PKT_TX_UDP_CKSUM)
+ off_info->payload_offset = m->outer_l2_len + m->outer_l3_len +
+ m->l2_len + m->l3_len;
+ else if ((ol_flags & PKT_TX_TCP_CKSUM) || (ol_flags & PKT_TX_TCP_SEG))
+ off_info->payload_offset = m->outer_l2_len + m->outer_l3_len +
+ m->l2_len + m->l3_len + m->l4_len;
}
-static inline void
-hinic_analyze_tx_info(struct rte_mbuf *mbuf,
- struct hinic_tx_offload_info *off_info)
+static inline void hinic_get_pld_offset(struct rte_mbuf *m,
+ struct hinic_tx_offload_info *off_info)
+{
+ uint64_t ol_flags = m->ol_flags;
+
+ if (((ol_flags & PKT_TX_L4_MASK) == PKT_TX_UDP_CKSUM) ||
+ ((ol_flags & PKT_TX_L4_MASK) == PKT_TX_SCTP_CKSUM))
+ off_info->payload_offset = m->l2_len + m->l3_len;
+ else if ((ol_flags & PKT_TX_TCP_CKSUM) || (ol_flags & PKT_TX_TCP_SEG))
+ off_info->payload_offset = m->l2_len + m->l3_len +
+ m->l4_len;
+}
+
+static inline void hinic_analyze_tx_info(struct rte_mbuf *mbuf,
+ struct hinic_tx_offload_info *off_info)
{
struct rte_ether_hdr *eth_hdr;
struct rte_vlan_hdr *vlan_hdr;
- struct rte_ipv4_hdr *ip4h;
- u16 pkt_type;
- u8 *hdr;
+ struct rte_ipv4_hdr *ipv4_hdr;
+ u16 eth_type;
- hdr = (u8 *)rte_pktmbuf_mtod(mbuf, u8*);
- eth_hdr = (struct rte_ether_hdr *)hdr;
- pkt_type = rte_be_to_cpu_16(eth_hdr->ether_type);
+ eth_hdr = rte_pktmbuf_mtod(mbuf, struct rte_ether_hdr *);
+ eth_type = rte_be_to_cpu_16(eth_hdr->ether_type);
- if (pkt_type == RTE_ETHER_TYPE_VLAN) {
+ if (eth_type == RTE_ETHER_TYPE_VLAN) {
off_info->outer_l2_len = ETHER_LEN_WITH_VLAN;
- vlan_hdr = (struct rte_vlan_hdr *)(hdr + 1);
- pkt_type = rte_be_to_cpu_16(vlan_hdr->eth_proto);
+ vlan_hdr = (struct rte_vlan_hdr *)(eth_hdr + 1);
+ eth_type = rte_be_to_cpu_16(vlan_hdr->eth_proto);
} else {
off_info->outer_l2_len = ETHER_LEN_NO_VLAN;
}
- if (pkt_type == RTE_ETHER_TYPE_IPV4) {
- ip4h = (struct rte_ipv4_hdr *)(hdr + off_info->outer_l2_len);
- off_info->outer_l3_len = (ip4h->version_ihl & 0xf) <<
- HEADER_LEN_OFFSET;
- } else if (pkt_type == RTE_ETHER_TYPE_IPV6) {
+ if (eth_type == RTE_ETHER_TYPE_IPV4) {
+ ipv4_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv4_hdr *,
+ off_info->outer_l2_len);
+ off_info->outer_l3_len = rte_ipv4_hdr_len(ipv4_hdr);
+ } else if (eth_type == RTE_ETHER_TYPE_IPV6) {
/* not support ipv6 extension header */
off_info->outer_l3_len = sizeof(struct rte_ipv6_hdr);
}
}
-static inline int
-hinic_tx_offload_pkt_prepare(struct rte_mbuf *m,
- struct hinic_tx_offload_info *off_info)
+static inline void hinic_analyze_outer_ip_vxlan(struct rte_mbuf *mbuf,
+ struct hinic_tx_offload_info *off_info)
+{
+ struct rte_ether_hdr *eth_hdr;
+ struct rte_vlan_hdr *vlan_hdr;
+ struct rte_ipv4_hdr *ipv4_hdr;
+ struct rte_udp_hdr *udp_hdr;
+ u16 eth_type = 0;
+
+ eth_hdr = rte_pktmbuf_mtod(mbuf, struct rte_ether_hdr *);
+ eth_type = rte_be_to_cpu_16(eth_hdr->ether_type);
+
+ if (eth_type == RTE_ETHER_TYPE_VLAN) {
+ vlan_hdr = (struct rte_vlan_hdr *)(eth_hdr + 1);
+ eth_type = rte_be_to_cpu_16(vlan_hdr->eth_proto);
+ }
+
+ if (eth_type == RTE_ETHER_TYPE_IPV4) {
+ ipv4_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv4_hdr *,
+ mbuf->outer_l2_len);
+ off_info->outer_l3_type = IPV4_PKT_WITH_CHKSUM_OFFLOAD;
+ ipv4_hdr->hdr_checksum = 0;
+
+ udp_hdr = (struct rte_udp_hdr *)((char *)ipv4_hdr +
+ mbuf->outer_l3_len);
+ udp_hdr->dgram_cksum = 0;
+ } else if (eth_type == RTE_ETHER_TYPE_IPV6) {
+ off_info->outer_l3_type = IPV6_PKT;
+
+ udp_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_udp_hdr *,
+ (mbuf->outer_l2_len +
+ mbuf->outer_l3_len));
+ udp_hdr->dgram_cksum = 0;
+ }
+}
+
+static inline uint8_t hinic_analyze_l3_type(struct rte_mbuf *mbuf)
+{
+ uint8_t l3_type;
+ uint64_t ol_flags = mbuf->ol_flags;
+
+ if (ol_flags & PKT_TX_IPV4)
+ l3_type = (ol_flags & PKT_TX_IP_CKSUM) ?
+ IPV4_PKT_WITH_CHKSUM_OFFLOAD :
+ IPV4_PKT_NO_CHKSUM_OFFLOAD;
+ else if (ol_flags & PKT_TX_IPV6)
+ l3_type = IPV6_PKT;
+ else
+ l3_type = UNKNOWN_L3TYPE;
+
+ return l3_type;
+}
+
+static inline void hinic_calculate_tcp_checksum(struct rte_mbuf *mbuf,
+ struct hinic_tx_offload_info *off_info,
+ uint64_t inner_l3_offset)
{
struct rte_ipv4_hdr *ipv4_hdr;
struct rte_ipv6_hdr *ipv6_hdr;
struct rte_tcp_hdr *tcp_hdr;
+ uint64_t ol_flags = mbuf->ol_flags;
+
+ if (ol_flags & PKT_TX_IPV4) {
+ ipv4_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv4_hdr *,
+ inner_l3_offset);
+
+ if (ol_flags & PKT_TX_IP_CKSUM)
+ ipv4_hdr->hdr_checksum = 0;
+
+ tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr +
+ mbuf->l3_len);
+ tcp_hdr->cksum = hinic_ipv4_phdr_cksum(ipv4_hdr, ol_flags);
+ } else {
+ ipv6_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv6_hdr *,
+ inner_l3_offset);
+ tcp_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_tcp_hdr *,
+ (inner_l3_offset +
+ mbuf->l3_len));
+ tcp_hdr->cksum = hinic_ipv6_phdr_cksum(ipv6_hdr, ol_flags);
+ }
+
+ off_info->inner_l4_type = TCP_OFFLOAD_ENABLE;
+ off_info->inner_l4_tcp_udp = 1;
+}
+
+static inline void hinic_calculate_udp_checksum(struct rte_mbuf *mbuf,
+ struct hinic_tx_offload_info *off_info,
+ uint64_t inner_l3_offset)
+{
+ struct rte_ipv4_hdr *ipv4_hdr;
+ struct rte_ipv6_hdr *ipv6_hdr;
struct rte_udp_hdr *udp_hdr;
- struct rte_ether_hdr *eth_hdr;
- struct rte_vlan_hdr *vlan_hdr;
- u16 eth_type = 0;
+ uint64_t ol_flags = mbuf->ol_flags;
+
+ if (ol_flags & PKT_TX_IPV4) {
+ ipv4_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv4_hdr *,
+ inner_l3_offset);
+
+ if (ol_flags & PKT_TX_IP_CKSUM)
+ ipv4_hdr->hdr_checksum = 0;
+
+ udp_hdr = (struct rte_udp_hdr *)((char *)ipv4_hdr +
+ mbuf->l3_len);
+ udp_hdr->dgram_cksum = hinic_ipv4_phdr_cksum(ipv4_hdr,
+ ol_flags);
+ } else {
+ ipv6_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv6_hdr *,
+ inner_l3_offset);
+
+ udp_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_udp_hdr *,
+ (inner_l3_offset +
+ mbuf->l3_len));
+ udp_hdr->dgram_cksum = hinic_ipv6_phdr_cksum(ipv6_hdr,
+ ol_flags);
+ }
+
+ off_info->inner_l4_type = UDP_OFFLOAD_ENABLE;
+ off_info->inner_l4_tcp_udp = 1;
+}
+
+static inline void
+hinic_calculate_sctp_checksum(struct hinic_tx_offload_info *off_info)
+{
+ off_info->inner_l4_type = SCTP_OFFLOAD_ENABLE;
+ off_info->inner_l4_tcp_udp = 0;
+ off_info->inner_l4_len = sizeof(struct rte_sctp_hdr);
+}
+
+static inline void hinic_calculate_checksum(struct rte_mbuf *mbuf,
+ struct hinic_tx_offload_info *off_info,
+ uint64_t inner_l3_offset)
+{
+ uint64_t ol_flags = mbuf->ol_flags;
+
+ switch (ol_flags & PKT_TX_L4_MASK) {
+ case PKT_TX_UDP_CKSUM:
+ hinic_calculate_udp_checksum(mbuf, off_info, inner_l3_offset);
+ break;
+
+ case PKT_TX_TCP_CKSUM:
+ hinic_calculate_tcp_checksum(mbuf, off_info, inner_l3_offset);
+ break;
+
+ case PKT_TX_SCTP_CKSUM:
+ hinic_calculate_sctp_checksum(off_info);
+ break;
+
+ default:
+ if (ol_flags & PKT_TX_TCP_SEG)
+ hinic_calculate_tcp_checksum(mbuf, off_info,
+ inner_l3_offset);
+ break;
+ }
+}
+
+static inline int hinic_tx_offload_pkt_prepare(struct rte_mbuf *m,
+ struct hinic_tx_offload_info *off_info)
+{
uint64_t inner_l3_offset;
uint64_t ol_flags = m->ol_flags;
return 0;
/* Support only vxlan offload */
- if ((ol_flags & PKT_TX_TUNNEL_MASK) &&
- !(ol_flags & PKT_TX_TUNNEL_VXLAN))
+ if (unlikely((ol_flags & PKT_TX_TUNNEL_MASK) &&
+ !(ol_flags & PKT_TX_TUNNEL_VXLAN)))
return -ENOTSUP;
#ifdef RTE_LIBRTE_ETHDEV_DEBUG
#endif
if (ol_flags & PKT_TX_TUNNEL_VXLAN) {
+ off_info->tunnel_type = TUNNEL_UDP_NO_CSUM;
+
+ /* inner_l4_tcp_udp csum should be set to calculate outer
+ * udp checksum when vxlan packets without inner l3 and l4
+ */
+ off_info->inner_l4_tcp_udp = 1;
+
if ((ol_flags & PKT_TX_OUTER_IP_CKSUM) ||
(ol_flags & PKT_TX_OUTER_IPV6) ||
(ol_flags & PKT_TX_TCP_SEG)) {
inner_l3_offset = m->l2_len + m->outer_l2_len +
- m->outer_l3_len;
+ m->outer_l3_len;
off_info->outer_l2_len = m->outer_l2_len;
off_info->outer_l3_len = m->outer_l3_len;
/* just support vxlan tunneling pkt */
off_info->inner_l2_len = m->l2_len - VXLANLEN -
- sizeof(*udp_hdr);
- off_info->inner_l3_len = m->l3_len;
- off_info->inner_l4_len = m->l4_len;
+ sizeof(struct rte_udp_hdr);
off_info->tunnel_length = m->l2_len;
- off_info->tunnel_type = TUNNEL_UDP_NO_CSUM;
- hinic_get_pld_offset(m, off_info,
- HINIC_TX_OUTER_CHECKSUM_FLAG_SET);
+ hinic_analyze_outer_ip_vxlan(m, off_info);
+
+ hinic_get_outer_cs_pld_offset(m, off_info);
} else {
inner_l3_offset = m->l2_len;
hinic_analyze_tx_info(m, off_info);
/* just support vxlan tunneling pkt */
off_info->inner_l2_len = m->l2_len - VXLANLEN -
- sizeof(*udp_hdr) - off_info->outer_l2_len -
- off_info->outer_l3_len;
- off_info->inner_l3_len = m->l3_len;
- off_info->inner_l4_len = m->l4_len;
+ sizeof(struct rte_udp_hdr) -
+ off_info->outer_l2_len -
+ off_info->outer_l3_len;
off_info->tunnel_length = m->l2_len -
- off_info->outer_l2_len - off_info->outer_l3_len;
- off_info->tunnel_type = TUNNEL_UDP_NO_CSUM;
+ off_info->outer_l2_len -
+ off_info->outer_l3_len;
+ off_info->outer_l3_type = IPV4_PKT_NO_CHKSUM_OFFLOAD;
- hinic_get_pld_offset(m, off_info,
- HINIC_TX_OUTER_CHECKSUM_FLAG_NO_SET);
+ hinic_get_pld_offset(m, off_info);
}
} else {
inner_l3_offset = m->l2_len;
off_info->inner_l2_len = m->l2_len;
- off_info->inner_l3_len = m->l3_len;
- off_info->inner_l4_len = m->l4_len;
off_info->tunnel_type = NOT_TUNNEL;
- hinic_get_pld_offset(m, off_info,
- HINIC_TX_OUTER_CHECKSUM_FLAG_NO_SET);
+ hinic_get_pld_offset(m, off_info);
}
/* invalid udp or tcp header */
if (unlikely(off_info->payload_offset > MAX_PLD_OFFSET))
return -EINVAL;
- /* Process outter udp pseudo-header checksum */
- if ((ol_flags & PKT_TX_TUNNEL_VXLAN) && ((ol_flags & PKT_TX_TCP_SEG) ||
- (ol_flags & PKT_TX_OUTER_IP_CKSUM) ||
- (ol_flags & PKT_TX_OUTER_IPV6))) {
-
- /* inner_l4_tcp_udp csum should be setted to calculate outter
- * udp checksum when vxlan packets without inner l3 and l4
- */
- off_info->inner_l4_tcp_udp = 1;
-
- eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
- eth_type = rte_be_to_cpu_16(eth_hdr->ether_type);
-
- if (eth_type == RTE_ETHER_TYPE_VLAN) {
- vlan_hdr = (struct rte_vlan_hdr *)(eth_hdr + 1);
- eth_type = rte_be_to_cpu_16(vlan_hdr->eth_proto);
- }
-
- if (eth_type == RTE_ETHER_TYPE_IPV4) {
- ipv4_hdr =
- rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
- m->outer_l2_len);
- off_info->outer_l3_type = IPV4_PKT_WITH_CHKSUM_OFFLOAD;
- ipv4_hdr->hdr_checksum = 0;
-
- udp_hdr = (struct rte_udp_hdr *)((char *)ipv4_hdr +
- m->outer_l3_len);
- udp_hdr->dgram_cksum = 0;
- } else if (eth_type == RTE_ETHER_TYPE_IPV6) {
- off_info->outer_l3_type = IPV6_PKT;
- ipv6_hdr =
- rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *,
- m->outer_l2_len);
-
- udp_hdr =
- rte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *,
- (m->outer_l2_len +
- m->outer_l3_len));
- udp_hdr->dgram_cksum = 0;
- }
- } else if (ol_flags & PKT_TX_OUTER_IPV4) {
- off_info->tunnel_type = TUNNEL_UDP_NO_CSUM;
- off_info->inner_l4_tcp_udp = 1;
- off_info->outer_l3_type = IPV4_PKT_NO_CHKSUM_OFFLOAD;
- }
-
- if (ol_flags & PKT_TX_IPV4)
- off_info->inner_l3_type = (ol_flags & PKT_TX_IP_CKSUM) ?
- IPV4_PKT_WITH_CHKSUM_OFFLOAD :
- IPV4_PKT_NO_CHKSUM_OFFLOAD;
- else if (ol_flags & PKT_TX_IPV6)
- off_info->inner_l3_type = IPV6_PKT;
+ off_info->inner_l3_len = m->l3_len;
+ off_info->inner_l4_len = m->l4_len;
+ off_info->inner_l3_type = hinic_analyze_l3_type(m);
/* Process the pseudo-header checksum */
- if ((ol_flags & PKT_TX_L4_MASK) == PKT_TX_UDP_CKSUM) {
- if (ol_flags & PKT_TX_IPV4) {
- ipv4_hdr =
- rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
- inner_l3_offset);
-
- if (ol_flags & PKT_TX_IP_CKSUM)
- ipv4_hdr->hdr_checksum = 0;
-
- udp_hdr = (struct rte_udp_hdr *)((char *)ipv4_hdr +
- m->l3_len);
- udp_hdr->dgram_cksum =
- hinic_ipv4_phdr_cksum(ipv4_hdr, ol_flags);
- } else {
- ipv6_hdr =
- rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *,
- inner_l3_offset);
-
- udp_hdr =
- rte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *,
- (inner_l3_offset + m->l3_len));
- udp_hdr->dgram_cksum =
- hinic_ipv6_phdr_cksum(ipv6_hdr, ol_flags);
- }
-
- off_info->inner_l4_type = UDP_OFFLOAD_ENABLE;
- off_info->inner_l4_tcp_udp = 1;
- } else if (((ol_flags & PKT_TX_L4_MASK) == PKT_TX_TCP_CKSUM) ||
- (ol_flags & PKT_TX_TCP_SEG)) {
- if (ol_flags & PKT_TX_IPV4) {
- ipv4_hdr =
- rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
- inner_l3_offset);
-
- if (ol_flags & PKT_TX_IP_CKSUM)
- ipv4_hdr->hdr_checksum = 0;
-
- /* non-TSO tcp */
- tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr +
- m->l3_len);
- tcp_hdr->cksum =
- hinic_ipv4_phdr_cksum(ipv4_hdr, ol_flags);
- } else {
- ipv6_hdr =
- rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *,
- inner_l3_offset);
- /* non-TSO tcp */
- tcp_hdr =
- rte_pktmbuf_mtod_offset(m, struct rte_tcp_hdr *,
- (inner_l3_offset + m->l3_len));
- tcp_hdr->cksum =
- hinic_ipv6_phdr_cksum(ipv6_hdr, ol_flags);
- }
-
- off_info->inner_l4_type = TCP_OFFLOAD_ENABLE;
- off_info->inner_l4_tcp_udp = 1;
- } else if ((ol_flags & PKT_TX_L4_MASK) == PKT_TX_SCTP_CKSUM) {
- off_info->inner_l4_type = SCTP_OFFLOAD_ENABLE;
- off_info->inner_l4_tcp_udp = 0;
- off_info->inner_l4_len = sizeof(struct rte_sctp_hdr);
- }
+ hinic_calculate_checksum(m, off_info, inner_l3_offset);
return 0;
}