From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 27E932949 for ; Tue, 26 Apr 2016 08:49:59 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 25 Apr 2016 23:49:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,535,1455004800"; d="scan'208";a="692319536" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by FMSMGA003.fm.intel.com with ESMTP; 25 Apr 2016 23:49:46 -0700 Received: from fmsmsx121.amr.corp.intel.com (10.18.125.36) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 25 Apr 2016 23:49:44 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx121.amr.corp.intel.com (10.18.125.36) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 25 Apr 2016 23:49:44 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.229]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.155]) with mapi id 14.03.0248.002; Tue, 26 Apr 2016 14:49:42 +0800 From: "Zhang, Helin" To: "Yigit, Ferruh" CC: "dev@dpdk.org" Thread-Topic: [PATCH] kni: add chained mbufs support Thread-Index: AQHRnw0YeqrabMR24ECb2aqbBM/5np+bzZNA Date: Tue, 26 Apr 2016 06:49:41 +0000 Message-ID: References: <1461600664-16481-1-git-send-email-ferruh.yigit@intel.com> In-Reply-To: <1461600664-16481-1-git-send-email-ferruh.yigit@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] kni: add chained mbufs support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Apr 2016 06:50:00 -0000 Have you tested with it? I think we need to test it in a longer time, e.g. 1 hour My commetns inlined. Thanks, Helin > -----Original Message----- > From: Yigit, Ferruh > Sent: Tuesday, April 26, 2016 12:11 AM > To: dev@dpdk.org > Cc: Zhang, Helin; Yigit, Ferruh > Subject: [PATCH] kni: add chained mbufs support >=20 > rx_q fifo may have chained mbufs, merge them into single skb before > handing to the network stack. >=20 > Signed-off-by: Ferruh Yigit > --- > .../linuxapp/eal/include/exec-env/rte_kni_common.h | 4 +- > lib/librte_eal/linuxapp/kni/kni_net.c | 83 ++++++++++++++++= ------ > 2 files changed, 64 insertions(+), 23 deletions(-) >=20 > diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.= h > b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h > index 7e5e598..2acdfd9 100644 > --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h > +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h > @@ -113,7 +113,9 @@ struct rte_kni_mbuf { > void *buf_addr __attribute__((__aligned__(RTE_CACHE_LINE_SIZE))); > char pad0[10]; > uint16_t data_off; /**< Start address of data in segment buffer. > */ > - char pad1[4]; > + char pad1[2]; > + uint8_t nb_segs; /**< Number of segments. */ > + char pad4[1]; > uint64_t ol_flags; /**< Offload features. */ > char pad2[4]; > uint32_t pkt_len; /**< Total pkt len: sum of all segment data_len= . > */ > diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c > b/lib/librte_eal/linuxapp/kni/kni_net.c > index cfa8339..570de71 100644 > --- a/lib/librte_eal/linuxapp/kni/kni_net.c > +++ b/lib/librte_eal/linuxapp/kni/kni_net.c > @@ -156,7 +156,8 @@ kni_net_rx_normal(struct kni_dev *kni) > /* Transfer received packets to netif */ > for (i =3D 0; i < num_rx; i++) { > kva =3D (void *)va[i] - kni->mbuf_va + kni->mbuf_kva; > - len =3D kva->data_len; > + len =3D kva->pkt_len; > + > data_kva =3D kva->buf_addr + kva->data_off - kni->mbuf_va > + kni->mbuf_kva; >=20 > @@ -165,22 +166,41 @@ kni_net_rx_normal(struct kni_dev *kni) > KNI_ERR("Out of mem, dropping pkts\n"); > /* Update statistics */ > kni->stats.rx_dropped++; > + continue; > } > - else { > - /* Align IP on 16B boundary */ > - skb_reserve(skb, 2); > + > + /* Align IP on 16B boundary */ > + skb_reserve(skb, 2); > + > + if (kva->nb_segs =3D=3D 0) { I guess it should compare nb_segs with 1, but not 0. Am I wrong? > memcpy(skb_put(skb, len), data_kva, len); > - skb->dev =3D dev; > - skb->protocol =3D eth_type_trans(skb, dev); > - skb->ip_summed =3D CHECKSUM_UNNECESSARY; > + } else { > + int nb_segs; > + int kva_nb_segs =3D kva->nb_segs; >=20 > - /* Call netif interface */ > - netif_rx_ni(skb); > + for (nb_segs =3D 0; nb_segs < kva_nb_segs; nb_segs++) Kva_nb_segs might not needed at all, use kva->nb_segs directly? > { > + memcpy(skb_put(skb, kva->data_len), > + data_kva, kva->data_len); >=20 > - /* Update statistics */ > - kni->stats.rx_bytes +=3D len; > - kni->stats.rx_packets++; > + if (!kva->next) > + break; > + > + kva =3D kva->next - kni->mbuf_va + kni- > >mbuf_kva; > + data_kva =3D kva->buf_addr + kva->data_off > + - kni->mbuf_va + kni->mbuf_kva; > + } > } > + > + skb->dev =3D dev; > + skb->protocol =3D eth_type_trans(skb, dev); > + skb->ip_summed =3D CHECKSUM_UNNECESSARY; > + > + /* Call netif interface */ > + netif_rx_ni(skb); > + > + /* Update statistics */ > + kni->stats.rx_bytes +=3D len; > + kni->stats.rx_packets++; > } >=20 > /* Burst enqueue mbufs into free_q */ > @@ -317,7 +337,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni) > /* Copy mbufs to sk buffer and then call tx interface */ > for (i =3D 0; i < num; i++) { > kva =3D (void *)va[i] - kni->mbuf_va + kni->mbuf_kva; > - len =3D kva->data_len; > + len =3D kva->pkt_len; > data_kva =3D kva->buf_addr + kva->data_off - kni->mbuf_va + > kni->mbuf_kva; >=20 > @@ -338,20 +358,39 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni) > if (skb =3D=3D NULL) { > KNI_ERR("Out of mem, dropping pkts\n"); > kni->stats.rx_dropped++; > + continue; > } > - else { > - /* Align IP on 16B boundary */ > - skb_reserve(skb, 2); > + > + /* Align IP on 16B boundary */ > + skb_reserve(skb, 2); > + > + if (kva->nb_segs =3D=3D 0) { The same commnets as above. > memcpy(skb_put(skb, len), data_kva, len); > - skb->dev =3D dev; > - skb->ip_summed =3D CHECKSUM_UNNECESSARY; > + } else { > + int nb_segs; > + int kva_nb_segs =3D kva->nb_segs; >=20 > - kni->stats.rx_bytes +=3D len; > - kni->stats.rx_packets++; > + for (nb_segs =3D 0; nb_segs < kva_nb_segs; nb_segs++) The same comments as above. > { > + memcpy(skb_put(skb, kva->data_len), > + data_kva, kva->data_len); > + > + if (!kva->next) > + break; >=20 > - /* call tx interface */ > - kni_net_tx(skb, dev); > + kva =3D kva->next - kni->mbuf_va + kni- > >mbuf_kva; > + data_kva =3D kva->buf_addr + kva->data_off > + - kni->mbuf_va + kni->mbuf_kva; > + } > } > + > + skb->dev =3D dev; > + skb->ip_summed =3D CHECKSUM_UNNECESSARY; > + > + kni->stats.rx_bytes +=3D len; > + kni->stats.rx_packets++; > + > + /* call tx interface */ > + kni_net_tx(skb, dev); > } >=20 > /* enqueue all the mbufs from rx_q into free_q */ > -- > 2.5.5