From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by dpdk.org (Postfix) with ESMTP id 2AE054CA1 for ; Wed, 28 Mar 2018 17:44:32 +0200 (CEST) Received: by mail-wr0-f196.google.com with SMTP id p53so2676182wrc.10 for ; Wed, 28 Mar 2018 08:44:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=OFqoCrSxs/2HnosfT1FHcyM/ZbPsD7lQQl0T7KqyIEk=; b=Ubt4LLQ0QbU3pty+/xxPPpHIMEuFbpDXa1jg/yDXXpwmqDH6fK52OvBOAx8CTbyId/ EgaKsyCsZqGu457yMjQcDSwRFxy5G9wayoMKPrGg/qKg/4jtqjQPRJhSPzaJvUK2ZvQA NL5ExNx75y1o1LmtetRCsJtW4Yi3IPLwoawuIeCQwHfT6CYF7mH5USUSwcpeKqoGJcBr fcDugDu9pF3PFeqkuxQdZqcSiKWwmIrREQVXKfXnH0/OGg+jqQXzvg7oFyAKERDKtkh4 hbCe1d9XBpUC0iEEAUdLCkCYMXC8hN2/wQFDZOoo3I0I375UixWSieYUZVtskMVpvXfB k3ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=OFqoCrSxs/2HnosfT1FHcyM/ZbPsD7lQQl0T7KqyIEk=; b=N7Z7yq1X2XiEeQung8V64T/eWUJ715H0W/qpEZgCCLiPeL/0Ex6NnvGqzxrIEbFr9+ 2x+3s0Dw/uteIQ7kwiRms0TpFKntsaDgcgC9qnQUJ7OW2Hf0ommw+7Khba9+E9N3vbqv 6Tbu3Ul7T19QAr0osxiAt34oJMvugZLfKak6VmxREIZpDpYWAoUaumvErNGAuOoBwPQQ zY+QRXYhT5b/ti2rrBIXDffACFZBr9sEP6djV/37Y17xa+rzqkkzC1KSrwcpmdCtkYov nmRlwepZHYr292g5iemSinPpjMZY6gOEUaMnUnEreRQg2EVXlypCdEshqQf55SmlaFOH e6QQ== X-Gm-Message-State: AElRT7EaJwDyy1hZ6R8OsQzEyTsFfrQih80GW9GNHhVYKYlYeqStWO1m gXB1I+fpMRIWoKDbucccmB0IGj1A X-Google-Smtp-Source: AIpwx4/LFVqov4o1VMtkr7nr0/33THi3kVh8PmIdh/78rrQMiUqV/+mjOD7cVH7unM1SvsWUm2bnIg== X-Received: by 10.223.158.6 with SMTP id u6mr3407246wre.142.1522251871516; Wed, 28 Mar 2018 08:44:31 -0700 (PDT) Received: from pala.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id o23sm7957279wrf.93.2018.03.28.08.44.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Mar 2018 08:44:30 -0700 (PDT) From: Didier Pallard To: dev@dpdk.org Date: Wed, 28 Mar 2018 17:43:47 +0200 Message-Id: <20180328154349.24976-7-didier.pallard@6wind.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180328154349.24976-1-didier.pallard@6wind.com> References: <20180328154349.24976-1-didier.pallard@6wind.com> Subject: [dpdk-dev] [PATCH 6/8] net/vmxnet3: guess mss if not provided in LRO mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Mar 2018 15:44:32 -0000 Not so old variants of vmxnet3 do not provide MSS value along with LRO packet. When this case happens, try to guess MSS value with information at hand. Signed-off-by: Didier Pallard --- drivers/net/vmxnet3/Makefile | 1 + drivers/net/vmxnet3/vmxnet3_ethdev.c | 2 ++ drivers/net/vmxnet3/vmxnet3_ethdev.h | 1 + drivers/net/vmxnet3/vmxnet3_rxtx.c | 59 ++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+) diff --git a/drivers/net/vmxnet3/Makefile b/drivers/net/vmxnet3/Makefile index 6bfbf0195..8cd007d3b 100644 --- a/drivers/net/vmxnet3/Makefile +++ b/drivers/net/vmxnet3/Makefile @@ -8,6 +8,7 @@ include $(RTE_SDK)/mk/rte.vars.mk # LIB = librte_pmd_vmxnet3_uio.a +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c index 4e68aae6b..32a68262e 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -615,6 +615,8 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) uint32_t i; int ret; + hw->mtu = mtu; + shared->magic = VMXNET3_REV1_MAGIC; devRead->misc.driverInfo.version = VMXNET3_DRIVER_VERSION_NUM; diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.h b/drivers/net/vmxnet3/vmxnet3_ethdev.h index b2a8cf35b..d3f2b3529 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.h +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.h @@ -87,6 +87,7 @@ struct vmxnet3_hw { uint64_t queueDescPA; uint16_t queue_desc_len; + uint16_t mtu; VMXNET3_RSSConf *rss_conf; uint64_t rss_confPA; diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c b/drivers/net/vmxnet3/vmxnet3_rxtx.c index 8ed7bd403..1f273f88e 100644 --- a/drivers/net/vmxnet3/vmxnet3_rxtx.c +++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c @@ -646,6 +646,59 @@ vmxnet3_post_rx_bufs(vmxnet3_rx_queue_t *rxq, uint8_t ring_id) return i; } +/* MSS not provided by vmxnet3, guess one with available information */ +static uint16_t +vmxnet3_guess_mss(struct vmxnet3_hw *hw, const Vmxnet3_RxCompDesc *rcd, + struct rte_mbuf *rxm) +{ + uint32_t hlen, slen; + struct ipv4_hdr *ipv4_hdr; + struct ipv6_hdr *ipv6_hdr; + struct tcp_hdr *tcp_hdr; + char *ptr; + + RTE_ASSERT(rcd->tcp); + + ptr = rte_pktmbuf_mtod(rxm, char *); + slen = rte_pktmbuf_data_len(rxm); + hlen = sizeof(struct ether_hdr); + + if (rcd->v4) { + if (unlikely(slen < hlen + sizeof(struct ipv4_hdr))) + return hw->mtu - sizeof(struct ipv4_hdr) + - sizeof(struct tcp_hdr); + + ipv4_hdr = (struct ipv4_hdr *)(ptr + hlen); + hlen += (ipv4_hdr->version_ihl & IPV4_HDR_IHL_MASK) * + IPV4_IHL_MULTIPLIER; + } else if (rcd->v6) { + if (unlikely(slen < hlen + sizeof(struct ipv6_hdr))) + return hw->mtu - sizeof(struct ipv6_hdr) - + sizeof(struct tcp_hdr); + + ipv6_hdr = (struct ipv6_hdr *)(ptr + hlen); + hlen += sizeof(struct ipv6_hdr); + if (unlikely(ipv6_hdr->proto != IPPROTO_TCP)) { + int frag; + + rte_net_skip_ip6_ext(ipv6_hdr->proto, rxm, + &hlen, &frag); + } + } + + if (unlikely(slen < hlen + sizeof(struct tcp_hdr))) + return hw->mtu - hlen - sizeof(struct tcp_hdr) + + sizeof(struct ether_hdr); + + tcp_hdr = (struct tcp_hdr *)(ptr + hlen); + hlen += (tcp_hdr->data_off & 0xf0) >> 2; + + if (rxm->udata64 > 1) + return (rte_pktmbuf_pkt_len(rxm) - hlen + + rxm->udata64 - 1) / rxm->udata64; + else + return hw->mtu - hlen + sizeof(struct ether_hdr); +} /* Receive side checksum and other offloads */ static inline void @@ -667,6 +720,7 @@ vmxnet3_rx_offload(struct vmxnet3_hw *hw, const Vmxnet3_RxCompDesc *rcd, (const Vmxnet3_RxCompDescExt *)rcd; rxm->tso_segsz = rcde->mss; + rxm->udata64 = rcde->segCnt; ol_flags |= PKT_RX_LRO; } } else { /* Offloads set in eop */ @@ -730,6 +784,11 @@ vmxnet3_rx_offload(struct vmxnet3_hw *hw, const Vmxnet3_RxCompDesc *rcd, } else { packet_type |= RTE_PTYPE_UNKNOWN; } + + /* Old variants of vmxnet3 do not provide MSS */ + if ((ol_flags & PKT_RX_LRO) && rxm->tso_segsz == 0) + rxm->tso_segsz = vmxnet3_guess_mss(hw, + rcd, rxm); } } -- 2.11.0