[dpdk-dev] [PATCH v2 3/5] szedata2: add handling of scattered packets in TX

2015-10-27 Thread Matej Vido
Hi Thomas,

2015-10-26 15:55 GMT+01:00 Thomas Monjalon :

> Hi Matej,
>
> 2015-09-18 10:32, Matej Vido:
> > - 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);
>
> You could avoid this change by keeping "if (likely(mbuf_segs == 1))"
> in the first patch.
> By the way, it seems to be an abusive use of "likely".
>
>
I will edit it in v3. Thanks.

Best regards,
Matej Vido


[dpdk-dev] [PATCH v2 3/5] szedata2: add handling of scattered packets in TX

2015-10-26 Thread Thomas Monjalon
Hi Matej,

2015-09-18 10:32, Matej Vido:
> - 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);

You could avoid this change by keeping "if (likely(mbuf_segs == 1))"
in the first patch.
By the way, it seems to be an abusive use of "likely".



[dpdk-dev] [PATCH v2 3/5] szedata2: add handling of scattered packets in TX

2015-09-18 Thread Matej Vido
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