2018-10-05 14:47:01 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*
|
2021-03-11 10:00:40 +00:00
|
|
|
* Copyright(c) 2019-2021 Xilinx, Inc.
|
2020-03-30 10:27:26 +00:00
|
|
|
* Copyright(c) 2018-2019 Solarflare Communications Inc.
|
2018-10-05 14:47:01 +00:00
|
|
|
*
|
|
|
|
* This software was jointly developed between OKTET Labs (under contract
|
|
|
|
* for Solarflare) and Solarflare Communications, Inc.
|
|
|
|
*/
|
|
|
|
|
2019-01-09 11:05:13 +00:00
|
|
|
#ifndef _SFC_TSO_H
|
|
|
|
#define _SFC_TSO_H
|
|
|
|
|
2021-03-26 16:46:15 +00:00
|
|
|
#include <rte_udp.h>
|
|
|
|
|
2019-01-09 11:05:13 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-10-05 14:47:01 +00:00
|
|
|
/** Standard TSO header length */
|
|
|
|
#define SFC_TSOH_STD_LEN 256
|
|
|
|
|
|
|
|
/** The number of TSO option descriptors that precede the packet descriptors */
|
2019-04-02 09:28:35 +00:00
|
|
|
#define SFC_EF10_TSO_OPT_DESCS_NUM 2
|
2018-10-05 14:47:01 +00:00
|
|
|
|
2018-10-05 14:47:02 +00:00
|
|
|
/**
|
|
|
|
* The number of DMA descriptors for TSO header that may or may not precede the
|
|
|
|
* packet's payload descriptors
|
|
|
|
*/
|
2019-04-02 09:28:35 +00:00
|
|
|
#define SFC_EF10_TSO_HDR_DESCS_NUM 1
|
2018-10-05 14:47:02 +00:00
|
|
|
|
2019-04-02 09:28:42 +00:00
|
|
|
static inline uint16_t
|
|
|
|
sfc_tso_ip4_get_ipid(const uint8_t *pkt_hdrp, size_t ip_hdr_off)
|
|
|
|
{
|
2019-05-21 16:13:10 +00:00
|
|
|
const struct rte_ipv4_hdr *ip_hdrp;
|
2019-04-02 09:28:42 +00:00
|
|
|
uint16_t ipid;
|
|
|
|
|
2019-05-21 16:13:10 +00:00
|
|
|
ip_hdrp = (const struct rte_ipv4_hdr *)(pkt_hdrp + ip_hdr_off);
|
2019-04-02 09:28:42 +00:00
|
|
|
rte_memcpy(&ipid, &ip_hdrp->packet_id, sizeof(ipid));
|
|
|
|
|
|
|
|
return rte_be_to_cpu_16(ipid);
|
|
|
|
}
|
|
|
|
|
2021-02-02 15:23:45 +00:00
|
|
|
static inline void
|
|
|
|
sfc_tso_outer_udp_fix_len(const struct rte_mbuf *m, uint8_t *tsoh)
|
|
|
|
{
|
|
|
|
rte_be16_t len = rte_cpu_to_be_16(m->l2_len + m->l3_len + m->l4_len +
|
|
|
|
m->tso_segsz);
|
|
|
|
|
|
|
|
rte_memcpy(tsoh + m->outer_l2_len + m->outer_l3_len +
|
|
|
|
offsetof(struct rte_udp_hdr, dgram_len),
|
|
|
|
&len, sizeof(len));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
sfc_tso_innermost_ip_fix_len(const struct rte_mbuf *m, uint8_t *tsoh,
|
|
|
|
size_t iph_ofst)
|
|
|
|
{
|
|
|
|
size_t ip_payload_len = m->l4_len + m->tso_segsz;
|
|
|
|
size_t field_ofst;
|
|
|
|
rte_be16_t len;
|
|
|
|
|
2021-10-15 19:24:08 +00:00
|
|
|
if (m->ol_flags & RTE_MBUF_F_TX_IPV4) {
|
2021-02-02 15:23:45 +00:00
|
|
|
field_ofst = offsetof(struct rte_ipv4_hdr, total_length);
|
|
|
|
len = rte_cpu_to_be_16(m->l3_len + ip_payload_len);
|
|
|
|
} else {
|
|
|
|
field_ofst = offsetof(struct rte_ipv6_hdr, payload_len);
|
|
|
|
len = rte_cpu_to_be_16(ip_payload_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
rte_memcpy(tsoh + iph_ofst + field_ofst, &len, sizeof(len));
|
|
|
|
}
|
|
|
|
|
2018-10-05 14:47:01 +00:00
|
|
|
unsigned int sfc_tso_prepare_header(uint8_t *tsoh, size_t header_len,
|
|
|
|
struct rte_mbuf **in_seg, size_t *in_off);
|
2019-01-09 11:05:13 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _SFC_TSO_H */
|