l4p/udp: enqueue fragmented packets as a whole 98/20398/2
authorJielong Zhou <jielong.zjl@antfin.com>
Fri, 28 Jun 2019 07:04:00 +0000 (15:04 +0800)
committerKonstantin Ananyev <konstantin.ananyev@intel.com>
Tue, 2 Jul 2019 08:06:37 +0000 (08:06 +0000)
Send or discard fragments of single IP/UDP packet as a whole, because part
of fragments could not be reassembled. Also avoid mbuf leak, for former
version would never free part of segments which are not sended.

Change-Id: I8cd13e60ced973a8f5d7d24369c3cbee64a38836
Signed-off-by: Jielong Zhou <jielong.zjl@antfin.com>
lib/libtle_l4p/udp_rxtx.c

index 76f6316..84a13ea 100644 (file)
@@ -457,7 +457,7 @@ stream_drb_alloc(struct tle_udp_stream *s, struct tle_drb *drbs[],
 static inline uint16_t
 queue_pkt_out(struct tle_udp_stream *s, struct tle_dev *dev,
                const void *pkt[], uint16_t nb_pkt,
-               struct tle_drb *drbs[], uint32_t *nb_drb)
+               struct tle_drb *drbs[], uint32_t *nb_drb, uint8_t all_or_nothing)
 {
        uint32_t bsz, i, n, nb, nbc, nbm;
 
@@ -479,8 +479,11 @@ queue_pkt_out(struct tle_udp_stream *s, struct tle_dev *dev,
                return 0;
 
        /* not enough free drbs, reduce number of packets to send. */
-       else if (nb != nbm)
+       else if (nb != nbm) {
+               if (all_or_nothing)
+                       return 0;
                nb_pkt = nb * bsz;
+       }
 
        /* enqueue packets to the destination device. */
        nbc = nb;
@@ -581,7 +584,7 @@ tle_udp_stream_send(struct tle_stream *us, struct rte_mbuf *pkt[],
                if (k != i) {
                        k += queue_pkt_out(s, dst.dev,
                                (const void **)(uintptr_t)&pkt[k], i - k,
-                               drb, &nb);
+                               drb, &nb, 0);
 
                        /* stream TX queue is full. */
                        if (k != i) {
@@ -603,7 +606,7 @@ tle_udp_stream_send(struct tle_stream *us, struct rte_mbuf *pkt[],
                        }
 
                        n = queue_pkt_out(s, dst.dev,
-                               (const void **)(uintptr_t)frag, rc, drb, &nb);
+                               (const void **)(uintptr_t)frag, rc, drb, &nb, 1);
                        if (n == 0) {
                                while (rc-- != 0)
                                        rte_pktmbuf_free(frag[rc]);