X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fnfb%2Fnfb_rx.h;h=c9708259af17485a27adfb02b8d316af895d152a;hb=a9e3a4a9e2dc583d827fbb4c7e427aa5af98281a;hp=88a03074fb273ed8d44bf329390ad6a076f5fed5;hpb=6435f9a0ac222ad8a1c53a2a039891c6f46cadb3;p=dpdk.git diff --git a/drivers/net/nfb/nfb_rx.h b/drivers/net/nfb/nfb_rx.h index 88a03074fb..c9708259af 100644 --- a/drivers/net/nfb/nfb_rx.h +++ b/drivers/net/nfb/nfb_rx.h @@ -11,13 +11,27 @@ #include #include +#include #include +#define NFB_TIMESTAMP_FLAG (1 << 0) + +extern uint64_t nfb_timestamp_rx_dynflag; +extern int nfb_timestamp_dynfield_offset; + +static inline rte_mbuf_timestamp_t * +nfb_timestamp_dynfield(struct rte_mbuf *mbuf) +{ + return RTE_MBUF_DYNFIELD(mbuf, + nfb_timestamp_dynfield_offset, rte_mbuf_timestamp_t *); +} + struct ndp_rx_queue { struct nfb_device *nfb; /* nfb dev structure */ struct ndp_queue *queue; /* rx queue */ uint16_t rx_queue_id; /* index */ uint8_t in_port; /* port */ + uint8_t flags; /* setup flags */ struct rte_mempool *mb_pool; /* memory pool to allocate packets */ uint16_t buf_size; /* mbuf size */ @@ -129,6 +143,7 @@ nfb_eth_ndp_rx(void *queue, uint16_t nb_pkts) { struct ndp_rx_queue *ndp = queue; + uint8_t timestamping_enabled; uint16_t packet_size; uint64_t num_bytes = 0; uint16_t num_rx; @@ -146,6 +161,8 @@ nfb_eth_ndp_rx(void *queue, return 0; } + timestamping_enabled = ndp->flags & NFB_TIMESTAMP_FLAG; + /* returns either all or nothing */ i = rte_pktmbuf_alloc_bulk(ndp->mb_pool, mbufs, nb_pkts); if (unlikely(i != 0)) @@ -181,6 +198,24 @@ nfb_eth_ndp_rx(void *queue, mbuf->pkt_len = packet_size; mbuf->port = ndp->in_port; + mbuf->ol_flags = 0; + + if (timestamping_enabled) { + rte_mbuf_timestamp_t timestamp; + + /* nanoseconds */ + timestamp = + rte_le_to_cpu_32(*((uint32_t *) + (packets[i].header + 4))); + timestamp <<= 32; + /* seconds */ + timestamp |= + rte_le_to_cpu_32(*((uint32_t *) + (packets[i].header + 8))); + *nfb_timestamp_dynfield(mbuf) = timestamp; + mbuf->ol_flags |= nfb_timestamp_rx_dynflag; + } + bufs[num_rx++] = mbuf; num_bytes += packet_size; } else {