From: Matej Vido <matejvido@gmail.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 3/5] szedata2: add handling of scattered packets in TX
Date: Fri, 18 Sep 2015 10:32:50 +0200 [thread overview]
Message-ID: <1442565172-5338-4-git-send-email-matejvido@gmail.com> (raw)
In-Reply-To: <1442565172-5338-1-git-send-email-matejvido@gmail.com>
TX function modified to handle chained mbufs.
Signed-off-by: Matej Vido <matejvido@gmail.com>
Reviewed-by: Jan Viktorin <viktorin@rehivetech.com>
---
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
next prev parent reply other threads:[~2015-09-18 8:34 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-19 8:24 [dpdk-dev] [PATCH 0/2] Virtual PMD using sze2 layer for COMBO cards Matej Vido
2015-06-19 8:25 ` [dpdk-dev] [PATCH 1/2] szedata2: new poll mode driver Matej Vido
2016-03-21 17:45 ` Stephen Hemminger
2016-03-24 17:52 ` Matej Vido
2015-06-19 8:25 ` [dpdk-dev] [PATCH 2/2] doc: added documentation for szedata2 PMD Matej Vido
2015-09-18 8:32 ` [dpdk-dev] [PATCH v2 0/5] Virtual PMD using sze2 layer for COMBO cards Matej Vido
2015-09-18 8:32 ` [dpdk-dev] [PATCH v2 1/5] szedata2: add new poll mode driver Matej Vido
2015-10-26 15:10 ` Thomas Monjalon
2015-09-18 8:32 ` [dpdk-dev] [PATCH v2 2/5] szedata2: add handling of scattered packets in RX Matej Vido
2015-09-18 8:32 ` Matej Vido [this message]
2015-10-26 14:55 ` [dpdk-dev] [PATCH v2 3/5] szedata2: add handling of scattered packets in TX Thomas Monjalon
2015-10-27 17:40 ` Matej Vido
2015-09-18 8:32 ` [dpdk-dev] [PATCH v2 4/5] doc: add documentation for szedata2 PMD Matej Vido
2015-10-26 15:00 ` Thomas Monjalon
2015-10-26 15:09 ` Thomas Monjalon
2015-10-27 17:33 ` Matej Vido
2015-10-27 18:00 ` Thomas Monjalon
2015-11-02 14:26 ` Matej Vido
2015-10-30 12:16 ` Mcnamara, John
2015-11-06 14:34 ` Matej Vido
2015-09-18 8:32 ` [dpdk-dev] [PATCH v2 5/5] doc: update 2.2 release notes Matej Vido
2015-09-24 16:23 ` [dpdk-dev] [PATCH v2] doc: update the dpdk " John McNamara
2015-09-24 21:14 ` Thomas Monjalon
2015-11-10 14:18 ` [dpdk-dev] [PATCH v3 0/6] Virtual PMD using sze2 layer for COMBO cards Matej Vido
2015-11-10 14:18 ` [dpdk-dev] [PATCH v3 1/6] szedata2: add new poll mode driver Matej Vido
2015-11-20 15:04 ` Thomas Monjalon
2015-11-20 19:25 ` Matej Vido
2015-11-21 10:27 ` Thomas Monjalon
2015-11-10 14:18 ` [dpdk-dev] [PATCH v3 2/6] szedata2: add non-scattered RX function Matej Vido
2015-11-10 14:18 ` [dpdk-dev] [PATCH v3 3/6] szedata2: add TX function Matej Vido
2015-11-10 14:18 ` [dpdk-dev] [PATCH v3 4/6] szedata2: add support for scattered packets in RX Matej Vido
2015-11-10 14:18 ` [dpdk-dev] [PATCH v3 5/6] doc: add documentation for szedata2 PMD Matej Vido
2015-11-10 14:55 ` Mcnamara, John
2015-11-10 14:18 ` [dpdk-dev] [PATCH v3 6/6] doc: update 2.2 release notes Matej Vido
2015-11-16 14:22 ` Mcnamara, John
2015-11-20 16:19 ` [dpdk-dev] [PATCH v3 0/6] Virtual PMD using sze2 layer for COMBO cards Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1442565172-5338-4-git-send-email-matejvido@gmail.com \
--to=matejvido@gmail.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).