X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_gso%2Frte_gso.c;h=822693fa02828952d77f7511e454d789c43ea462;hb=119583797b6ae44990934d7b965e76463530ca7a;hp=b77363682b25729aae1fc0cc228552c79dbcc118;hpb=ec51443cc99a6e20e8e2210d92d59ae760971f90;p=dpdk.git diff --git a/lib/librte_gso/rte_gso.c b/lib/librte_gso/rte_gso.c index b77363682b..822693fa02 100644 --- a/lib/librte_gso/rte_gso.c +++ b/lib/librte_gso/rte_gso.c @@ -33,7 +33,12 @@ #include +#include +#include + #include "rte_gso.h" +#include "gso_common.h" +#include "gso_tcp4.h" int rte_gso_segment(struct rte_mbuf *pkt, @@ -41,12 +46,52 @@ rte_gso_segment(struct rte_mbuf *pkt, struct rte_mbuf **pkts_out, uint16_t nb_pkts_out) { + struct rte_mempool *direct_pool, *indirect_pool; + struct rte_mbuf *pkt_seg; + uint64_t ol_flags; + uint16_t gso_size; + uint8_t ipid_delta; + int ret = 1; + if (pkt == NULL || pkts_out == NULL || gso_ctx == NULL || - nb_pkts_out < 1) + nb_pkts_out < 1 || + gso_ctx->gso_size < RTE_GSO_SEG_SIZE_MIN || + gso_ctx->gso_types != DEV_TX_OFFLOAD_TCP_TSO) return -EINVAL; - pkt->ol_flags &= (~PKT_TX_TCP_SEG); - pkts_out[0] = pkt; + if (gso_ctx->gso_size >= pkt->pkt_len) { + pkt->ol_flags &= (~PKT_TX_TCP_SEG); + pkts_out[0] = pkt; + return 1; + } + + direct_pool = gso_ctx->direct_pool; + indirect_pool = gso_ctx->indirect_pool; + gso_size = gso_ctx->gso_size; + ipid_delta = (gso_ctx->flag != RTE_GSO_FLAG_IPID_FIXED); + ol_flags = pkt->ol_flags; + + if (IS_IPV4_TCP(pkt->ol_flags)) { + pkt->ol_flags &= (~PKT_TX_TCP_SEG); + ret = gso_tcp4_segment(pkt, gso_size, ipid_delta, + direct_pool, indirect_pool, + pkts_out, nb_pkts_out); + } else { + pkts_out[0] = pkt; + RTE_LOG(DEBUG, GSO, "Unsupported packet type\n"); + return 1; + } + + if (ret > 1) { + pkt_seg = pkt; + while (pkt_seg) { + rte_mbuf_refcnt_update(pkt_seg, -1); + pkt_seg = pkt_seg->next; + } + } else if (ret < 0) { + /* Revert the ol_flags in the event of failure. */ + pkt->ol_flags = ol_flags; + } - return 1; + return ret; }