From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com [209.85.212.171]) by dpdk.org (Postfix) with ESMTP id 0CA358E5F for ; Fri, 18 Sep 2015 10:34:30 +0200 (CEST) Received: by wiclk2 with SMTP id lk2so21290244wic.1 for ; Fri, 18 Sep 2015 01:34:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=05WZEbww3VKj3hnLX4ciMPvN5m7JgDzt9OOA7CLWdD0=; b=k++mE2QLqzyj4OoWFwH15OaPLfU4oIq3r8ApBT4iGSpHr+OXBZo/KwtLai+c8tu3bS KXgXmlT9WMqJuGXoKXCy8uajTV+FvRFTdlqPWESTLwcoEG1RAx0WPYzfG/O93kjEsvwm T5qVOvo38LX6yKOUX64IgAdcc+Z4T0aVSpkf0kqTDD9KrZ9qJdw+SD6wXrExGn0Yv5p6 hrJG6nt9S5LpdmowP+vR1VBgIu6fkd5MkNIWAwVZe4kWJrreQHW6WNaZrz63cHvzbQNy ZSsv0IU+m1CHRyndxyuCLe8J+cCAjLMftCcUSmbWsd6T1O+3VGGNnmGU8AKrbp6D5ZV6 oPVA== X-Received: by 10.180.187.227 with SMTP id fv3mr14265845wic.57.1442565269947; Fri, 18 Sep 2015 01:34:29 -0700 (PDT) Received: from nbmato.fit.vutbr.cz ([2001:67c:1220:80e:7cf4:95f9:f390:9a4b]) by smtp.gmail.com with ESMTPSA id xw2sm7620553wjc.12.2015.09.18.01.34.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Sep 2015 01:34:29 -0700 (PDT) From: Matej Vido To: dev@dpdk.org Date: Fri, 18 Sep 2015 10:32:50 +0200 Message-Id: <1442565172-5338-4-git-send-email-matejvido@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442565172-5338-1-git-send-email-matejvido@gmail.com> References: <1434702301-4509-1-git-send-email-vido@cesnet.cz> <1442565172-5338-1-git-send-email-matejvido@gmail.com> Subject: [dpdk-dev] [PATCH v2 3/5] szedata2: add handling of scattered packets in TX 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: Fri, 18 Sep 2015 08:34:30 -0000 TX function modified to handle chained mbufs. Signed-off-by: Matej Vido Reviewed-by: Jan Viktorin --- drivers/net/szedata2/rte_eth_szedata2.c | 108 +++++++++++++++++++++++++++----- 1 file changed, 91 insertions(+), 17 deletions(-) diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c index ddb45e4..e2d6501 100644 --- a/drivers/net/szedata2/rte_eth_szedata2.c +++ b/drivers/net/szedata2/rte_eth_szedata2.c @@ -737,7 +737,7 @@ eth_szedata2_tx(void *queue, next_packet: mbuf = bufs[nb_pkts - pkt_left]; - pkt_len = mbuf->data_len; + pkt_len = mbuf->pkt_len; mbuf_segs = mbuf->nb_segs; hwpkt_len = RTE_SZE2_PACKET_HEADER_SIZE_ALIGNED + @@ -764,9 +764,28 @@ next_packet: /* copy packet from mbuf */ tmp_dst = ((uint8_t *)(dst)) + RTE_SZE2_PACKET_HEADER_SIZE_ALIGNED; - rte_memcpy(tmp_dst, - rte_pktmbuf_mtod(mbuf, const void *), - pkt_len); + if (likely(mbuf_segs == 1)) { + /* + * non-scattered packet, + * transmit from one mbuf + */ + rte_memcpy(tmp_dst, + rte_pktmbuf_mtod(mbuf, const void *), + pkt_len); + } else { + /* scattered packet, transmit from more mbufs */ + struct rte_mbuf * m = mbuf; + while (m) { + rte_memcpy(tmp_dst, + rte_pktmbuf_mtod(m, + const void *), + m->data_len); + tmp_dst = ((uint8_t *)(tmp_dst)) + + m->data_len; + m = m->next; + } + } + dst = ((uint8_t *)dst) + hwpkt_len; unlock_size += hwpkt_len; @@ -805,19 +824,74 @@ next_packet: tmp_dst = ((uint8_t *)(dst)) + RTE_SZE2_PACKET_HEADER_SIZE_ALIGNED; - /* copy part of packet to first area */ - rte_memcpy(tmp_dst, - rte_pktmbuf_mtod(mbuf, const void *), - write_len); - - if (lck->next) - dst = lck->next->start; - - /* copy part of packet to second area */ - rte_memcpy(dst, - (const void *) (rte_pktmbuf_mtod(mbuf, - const uint8_t *) + - write_len), pkt_len - write_len); + if (likely(mbuf_segs == 1)) { + /* + * non-scattered packet, + * transmit from one mbuf + */ + /* copy part of packet to first area */ + rte_memcpy(tmp_dst, + rte_pktmbuf_mtod(mbuf, const void *), + write_len); + + if (lck->next) + dst = lck->next->start; + + /* copy part of packet to second area */ + rte_memcpy(dst, + (const void *) (rte_pktmbuf_mtod(mbuf, + const uint8_t *) + + write_len), pkt_len - write_len); + } else { + /* scattered packet, transmit from more mbufs */ + struct rte_mbuf * m = mbuf; + uint16_t written = 0; + uint16_t to_write = 0; + bool new_mbuf = true; + uint16_t write_off = 0; + + /* copy part of packet to first area */ + while (m && written < write_len) { + to_write = RTE_MIN(m->data_len, + write_len - written); + rte_memcpy(tmp_dst, + rte_pktmbuf_mtod(m, + const void *), + to_write); + + tmp_dst = ((uint8_t *)(tmp_dst)) + + to_write; + if (m->data_len <= write_len - + written) { + m = m->next; + new_mbuf = true; + } else { + new_mbuf = false; + } + written += to_write; + } + + if (lck->next) + dst = lck->next->start; + + tmp_dst = dst; + written = 0; + write_off = new_mbuf ? 0 : to_write; + + /* copy part of packet to second area */ + while (m && written < pkt_len - write_len) { + rte_memcpy(tmp_dst, (const void *) + (rte_pktmbuf_mtod(m, + uint8_t *) + write_off), + m->data_len - write_off); + + tmp_dst = ((uint8_t *)(tmp_dst)) + + (m->data_len - write_off); + written += m->data_len - write_off; + m = m->next; + write_off = 0; + } + } dst = ((uint8_t *)dst) + rem_len; unlock_size += hwpkt_len; -- 1.9.1