[i40e] can i40e NIC send tcp packets split by rte_gso_segment
jiangheng (G)
jiangheng14 at huawei.com
Wed Sep 28 03:51:59 CEST 2022
Hello
I coded a dameon based on dpdk, and I am using GSO(generic segment offload) feature in dpdk19.11, however this feature does not work on i40e NIC. below is some of my code:
struct rte_gso_ctx gso_ctx;
int gso_ctx_setup(struct rte_gso_ctx *gso_ctx, int port_id) {
struct rte_mempool *mp = rte_mempool_lookup("gso_pool", 128 * 10, 4, 0, RTE_PKTMBUF_HEADROOM + 128, SOCKET_ID_ANY);
gso_ctx->direct_pool = mp;
gso_ctx->indirect_pool = mp;
gso_ctx->gso_types = DEV_TX_OFFLOAD_TCP_TSO;
gso_ctx->gso_szie = 1514;
gso_ctx->flag = 0;
return 0;
}
then I use the following function to split and send the input large tcp packets:
#define GSO_MAX_PKT_BURST 128
// pkt have 3 nb_segs, pkt_len is 1514 + 1460 + 1460 ....
tx_xmit (struct rte_mbuf *pkt)
{
uint32_t sent_pkts = 0;
struct rte_mbuf *gso_segments[GSO_MAX_PKT_BURST];
uint16_t nb_segments = 0;
int ret;
ret = rte_gso_segment(pkt, &gso_ctx, &gso_segments[nb_segments], GSO_MAX_PKT_BURST - nb_segments);
if (ret > 0) {
nb_segments += ret;
} else {
printf("unable to segment packet\n");
rte_pktmbuf_free(pkt);
}
rte_eth_tx_burst(port_id, queue_id, &gso_segments[0], nb_segments)
}
mbuf initialization:
struct rte_mbuf *head = m;
for (int i =0; i < head->nb_segs; i++) { // head->nb_segs = 3
m->ol_flags = PKT_TX_IPV4 | PKT_TX_TCP_CKSUM | PKT_TX_IP_CKSUM | PKT_TX_TCP_SEG | DEV_TX_OFFLOAD_TCP_TSO; // 0xd4000000000020
// i am sure the tcp header and data are correct
m->data_len = 1514 or 1460;
m->pkt_len = 1514 + 1460 + 1460;
m->l2_len = 14;
m->l3_len = 20;
m->l4_len = 20;
m = m->next;
}
tx_xmit(head);
The tcp package split by rte_gso_segment can transfer to i40e_xmit_pkts function:
nb_segments = 3;
gso_segments[i]->nb_segs = 2;
gso_segments[0]->pkt_len = 1514;
gso_segments[0]->data_len = 54, gso_segments[0]->next->data_len = 1460;
gso_segments[0]->ol_flags = 0xd0000000000020
i40e_xmit_pkts returns ok, but the tcp data cannot be sent out.
The same code can sent tcp data correctly if the hinic NIC is used.
please help check whether the above configuration are correct if used i40e NIC? By the way, how do i enable TSO feature for i40e NIC in dpdk19.11 ?
More information about the users
mailing list