net/af_packet: support Tx scattered mbuf input
authorWenfeng Liu <liuwf@arraynetworks.com.cn>
Mon, 7 Aug 2017 09:45:38 +0000 (09:45 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 6 Oct 2017 00:49:47 +0000 (02:49 +0200)
Signed-off-by: Wenfeng Liu <liuwf@arraynetworks.com.cn>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
drivers/net/af_packet/rte_eth_af_packet.c

index 9a47852..7aa26e5 100644 (file)
@@ -216,7 +216,7 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
                mbuf = *bufs++;
 
                /* drop oversized packets */
-               if (rte_pktmbuf_data_len(mbuf) > pkt_q->frame_data_size) {
+               if (mbuf->pkt_len > pkt_q->frame_data_size) {
                        rte_pktmbuf_free(mbuf);
                        continue;
                }
@@ -237,8 +237,17 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
                /* copy the tx frame data */
                pbuf = (uint8_t *) ppd + TPACKET2_HDRLEN -
                        sizeof(struct sockaddr_ll);
-               memcpy(pbuf, rte_pktmbuf_mtod(mbuf, void*), rte_pktmbuf_data_len(mbuf));
-               ppd->tp_len = ppd->tp_snaplen = rte_pktmbuf_data_len(mbuf);
+
+               struct rte_mbuf *tmp_mbuf = mbuf;
+               while (tmp_mbuf) {
+                       uint16_t data_len = rte_pktmbuf_data_len(tmp_mbuf);
+                       memcpy(pbuf, rte_pktmbuf_mtod(tmp_mbuf, void*), data_len);
+                       pbuf += data_len;
+                       tmp_mbuf = tmp_mbuf->next;
+               }
+
+               ppd->tp_len = mbuf->pkt_len;
+               ppd->tp_snaplen = mbuf->pkt_len;
 
                /* release incoming frame and advance ring buffer */
                ppd->tp_status = TP_STATUS_SEND_REQUEST;