X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fsfc%2Fsfc_tso.c;h=29d0836b65c053335901ccf800b079bb1fc8ab4d;hb=0475c7770502cb4166b2577df3ff446af9d85515;hp=076a25d44793b4dc6a4d7b2fe106aa729dd29b6a;hpb=f1f575be9b76ffd2afc5211dcfc0fed8db1014b2;p=dpdk.git diff --git a/drivers/net/sfc/sfc_tso.c b/drivers/net/sfc/sfc_tso.c index 076a25d447..29d0836b65 100644 --- a/drivers/net/sfc/sfc_tso.c +++ b/drivers/net/sfc/sfc_tso.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2016-2018 Solarflare Communications Inc. - * All rights reserved. + * Copyright(c) 2019-2021 Xilinx, Inc. + * Copyright(c) 2016-2019 Solarflare Communications Inc. * * This software was jointly developed between OKTET Labs (under contract * for Solarflare) and Solarflare Communications, Inc. @@ -95,29 +95,16 @@ sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx, unsigned int *pkt_descs, size_t *pkt_len) { uint8_t *tsoh; - const struct tcp_hdr *th; + const struct rte_tcp_hdr *th; efsys_dma_addr_t header_paddr; - uint16_t packet_id; + uint16_t packet_id = 0; uint32_t sent_seq; struct rte_mbuf *m = *in_seg; size_t nh_off = m->l2_len; /* IP header offset */ size_t tcph_off = m->l2_len + m->l3_len; /* TCP header offset */ size_t header_len = m->l2_len + m->l3_len + m->l4_len; - const efx_nic_cfg_t *encp = efx_nic_cfg_get(txq->evq->sa->nic); - idx += SFC_TSO_OPT_DESCS_NUM; - - /* Packets which have too big headers should be discarded */ - if (unlikely(header_len > SFC_TSOH_STD_LEN)) - return EMSGSIZE; - - /* - * The TCP header must start at most 208 bytes into the frame. - * If it starts later than this then the NIC won't realise - * it's a TCP packet and TSO edits won't be applied - */ - if (unlikely(tcph_off > encp->enc_tx_tso_tcp_header_offset_limit)) - return EMSGSIZE; + idx += SFC_EF10_TSO_OPT_DESCS_NUM; header_paddr = rte_pktmbuf_iova(m); @@ -129,6 +116,15 @@ sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx, * limitations on address boundaries crossing by DMA descriptor data. */ if (m->data_len < header_len) { + /* + * Discard a packet if header linearization is needed but + * the header is too big. + * Duplicate Tx prepare check here to avoid spoil of + * memory if Tx prepare is skipped. + */ + if (unlikely(header_len > SFC_TSOH_STD_LEN)) + return EMSGSIZE; + tsoh = txq->sw_ring[idx & txq->ptr_mask].tsoh; sfc_tso_prepare_header(tsoh, header_len, in_seg, in_off); @@ -144,21 +140,24 @@ sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx, tsoh = rte_pktmbuf_mtod(m, uint8_t *); } - /* Handle IP header */ - if (m->ol_flags & PKT_TX_IPV4) { - const struct ipv4_hdr *iphe4; + /* + * 8000-series EF10 hardware requires that innermost IP length + * be greater than or equal to the value which each segment is + * supposed to have; otherwise, TCP checksum will be incorrect. + */ + sfc_tso_innermost_ip_fix_len(m, tsoh, nh_off); - iphe4 = (const struct ipv4_hdr *)(tsoh + nh_off); - rte_memcpy(&packet_id, &iphe4->packet_id, sizeof(uint16_t)); - packet_id = rte_be_to_cpu_16(packet_id); - } else if (m->ol_flags & PKT_TX_IPV6) { - packet_id = 0; - } else { - return EINVAL; - } + /* + * Handle IP header. Tx prepare has debug-only checks that offload flags + * are correctly filled in in TSO mbuf. Use zero IPID if there is no + * IPv4 flag. If the packet is still IPv4, HW will simply start from + * zero IPID. + */ + if (m->ol_flags & PKT_TX_IPV4) + packet_id = sfc_tso_ip4_get_ipid(tsoh, nh_off); /* Handle TCP header */ - th = (const struct tcp_hdr *)(tsoh + tcph_off); + th = (const struct rte_tcp_hdr *)(tsoh + tcph_off); rte_memcpy(&sent_seq, &th->sent_seq, sizeof(uint32_t)); sent_seq = rte_be_to_cpu_32(sent_seq);