net/af_packet: remove timestamp from packet status
[dpdk.git] / drivers / net / af_packet / rte_eth_af_packet.c
index 2e90e29..fcd8090 100644 (file)
@@ -167,6 +167,26 @@ eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
        return num_rx;
 }
 
+/*
+ * Check if there is an available frame in the ring
+ */
+static inline bool
+tx_ring_status_available(uint32_t tp_status)
+{
+       /*
+        * We eliminate the timestamp status from the packet status.
+        * This should only matter if timestamping is enabled on the socket,
+        * but there is a bug in the kernel which is fixed in newer releases.
+        *
+        * See the following kernel commit for reference:
+        *     commit 171c3b151118a2fe0fc1e2a9d1b5a1570cfe82d2
+        *     net: packetmmap: fix only tx timestamp on request
+        */
+       tp_status &= ~(TP_STATUS_TS_SOFTWARE | TP_STATUS_TS_RAW_HARDWARE);
+
+       return tp_status == TP_STATUS_AVAILABLE;
+}
+
 /*
  * Callback to handle sending packets through a real NIC.
  */
@@ -212,8 +232,8 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
                }
 
                /* point at the next incoming frame */
-               if ((ppd->tp_status != TP_STATUS_AVAILABLE) &&
-                   (poll(&pfd, 1, -1) < 0))
+               if (!tx_ring_status_available(ppd->tp_status) &&
+                   poll(&pfd, 1, -1) < 0)
                        break;
 
                /* copy the tx frame data */
@@ -748,18 +768,18 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
                        goto error;
                }
 
+               if (qdisc_bypass) {
 #if defined(PACKET_QDISC_BYPASS)
-               rc = setsockopt(qsockfd, SOL_PACKET, PACKET_QDISC_BYPASS,
-                               &qdisc_bypass, sizeof(qdisc_bypass));
-               if (rc == -1) {
-                       PMD_LOG_ERRNO(ERR,
-                               "%s: could not set PACKET_QDISC_BYPASS on AF_PACKET socket for %s",
-                               name, pair->value);
-                       goto error;
-               }
-#else
-               RTE_SET_USED(qdisc_bypass);
+                       rc = setsockopt(qsockfd, SOL_PACKET, PACKET_QDISC_BYPASS,
+                                       &qdisc_bypass, sizeof(qdisc_bypass));
+                       if (rc == -1) {
+                               PMD_LOG_ERRNO(ERR,
+                                       "%s: could not set PACKET_QDISC_BYPASS on AF_PACKET socket for %s",
+                                       name, pair->value);
+                               goto error;
+                       }
 #endif
+               }
 
                rc = setsockopt(qsockfd, SOL_PACKET, PACKET_RX_RING, req, sizeof(*req));
                if (rc == -1) {