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,
+ con