#include "nfb_rx.h"
#include "nfb.h"
+uint64_t nfb_timestamp_rx_dynflag;
+int nfb_timestamp_dynfield_offset = -1;
+
static int
timestamp_check_handler(__rte_unused const char *key,
const char *value, __rte_unused void *opaque)
nfb_check_timestamp(struct rte_devargs *devargs)
{
struct rte_kvargs *kvlist;
+ int ret;
if (devargs == NULL)
return 0;
}
/* Timestamps are enabled when there is
* key-value pair: enable_timestamp=1
+ * TODO: timestamp should be enabled with DEV_RX_OFFLOAD_TIMESTAMP
*/
if (rte_kvargs_process(kvlist, TIMESTAMP_ARG,
timestamp_check_handler, NULL) < 0) {
}
rte_kvargs_free(kvlist);
+ ret = rte_mbuf_dyn_rx_timestamp_register(
+ &nfb_timestamp_dynfield_offset,
+ &nfb_timestamp_rx_dynflag);
+ if (ret != 0) {
+ RTE_LOG(ERR, PMD, "Cannot register Rx timestamp field/flag\n");
+ return -rte_errno;
+ }
+
return 1;
}
else
rte_free(rxq);
- if (nfb_check_timestamp(dev->device->devargs))
+ if (nfb_check_timestamp(dev->device->devargs) > 0)
rxq->flags |= NFB_TIMESTAMP_FLAG;
return ret;
#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 */
mbuf->ol_flags = 0;
if (timestamping_enabled) {
+ rte_mbuf_timestamp_t timestamp;
+
/* nanoseconds */
- mbuf->timestamp =
+ timestamp =
rte_le_to_cpu_32(*((uint32_t *)
(packets[i].header + 4)));
- mbuf->timestamp <<= 32;
+ timestamp <<= 32;
/* seconds */
- mbuf->timestamp |=
+ timestamp |=
rte_le_to_cpu_32(*((uint32_t *)
(packets[i].header + 8)));
- mbuf->ol_flags |= PKT_RX_TIMESTAMP;
+ *nfb_timestamp_dynfield(mbuf) = timestamp;
+ mbuf->ol_flags |= nfb_timestamp_rx_dynflag;
}
bufs[num_rx++] = mbuf;