diff options
author | Nithin Dabilpuram <ndabilpuram@marvell.com> | 2020-09-24 23:22:19 +0530 |
---|---|---|
committer | Matias Elo <matias.elo@nokia.com> | 2020-11-02 17:32:42 +0200 |
commit | ddfb9a95e21b8ea39f155ad0c5abdf737ef3f76b (patch) | |
tree | 07792a4e59f78fc1af6491f6c78102c6fe27e057 | |
parent | 4689d5d769b439dc5493dc76b2172f9ffab07958 (diff) |
linux-gen: pktio: update rx and tx timestamp implementation
This patch adds framework for new pktio and packet API
to support retrieval of timestamps from Packet IO time source.
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
-rw-r--r-- | platform/linux-generic/include/odp_packet_io_internal.h | 5 | ||||
-rw-r--r-- | platform/linux-generic/odp_packet_io.c | 51 | ||||
-rw-r--r-- | platform/linux-generic/pktio/dpdk.c | 5 | ||||
-rw-r--r-- | platform/linux-generic/pktio/ipc.c | 5 | ||||
-rw-r--r-- | platform/linux-generic/pktio/loop.c | 5 | ||||
-rw-r--r-- | platform/linux-generic/pktio/netmap.c | 5 | ||||
-rw-r--r-- | platform/linux-generic/pktio/null.c | 5 | ||||
-rw-r--r-- | platform/linux-generic/pktio/pcap.c | 5 | ||||
-rw-r--r-- | platform/linux-generic/pktio/socket.c | 5 | ||||
-rw-r--r-- | platform/linux-generic/pktio/socket_mmap.c | 5 | ||||
-rw-r--r-- | platform/linux-generic/pktio/tap.c | 5 |
11 files changed, 72 insertions, 29 deletions
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 737725d89..6d3454df4 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -167,8 +167,9 @@ typedef struct pktio_if_ops { int (*stop)(pktio_entry_t *pktio_entry); int (*stats)(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats); int (*stats_reset)(pktio_entry_t *pktio_entry); - uint64_t (*pktin_ts_res)(pktio_entry_t *pktio_entry); - odp_time_t (*pktin_ts_from_ns)(pktio_entry_t *pktio_entry, uint64_t ns); + uint64_t (*pktio_ts_res)(pktio_entry_t *pktio_entry); + odp_time_t (*pktio_ts_from_ns)(pktio_entry_t *pktio_entry, uint64_t ns); + odp_time_t (*pktio_time)(pktio_entry_t *pktio_entry, odp_time_t *global_ts); int (*recv)(pktio_entry_t *entry, int index, odp_packet_t packets[], int num); int (*recv_tmo)(pktio_entry_t *entry, int index, odp_packet_t packets[], diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 1ba429035..7ff567ddb 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -1260,40 +1260,73 @@ int odp_pktio_link_info(odp_pktio_t hdl, odp_pktio_link_info_t *info) return -1; } -uint64_t odp_pktin_ts_res(odp_pktio_t hdl) +uint64_t odp_pktio_ts_res(odp_pktio_t hdl) { pktio_entry_t *entry; entry = get_pktio_entry(hdl); - if (entry == NULL) { - ODP_DBG("pktio entry %d does not exist\n", hdl); + ODP_ERR("pktio entry %d does not exist\n", hdl); return 0; } - if (entry->s.ops->pktin_ts_res) - return entry->s.ops->pktin_ts_res(entry); + if (entry->s.ops->pktio_ts_res) + return entry->s.ops->pktio_ts_res(entry); return odp_time_global_res(); } -odp_time_t odp_pktin_ts_from_ns(odp_pktio_t hdl, uint64_t ns) +odp_time_t odp_pktio_ts_from_ns(odp_pktio_t hdl, uint64_t ns) { pktio_entry_t *entry; entry = get_pktio_entry(hdl); if (entry == NULL) { - ODP_DBG("pktio entry %d does not exist\n", hdl); + ODP_ERR("pktio entry %d does not exist\n", hdl); return ODP_TIME_NULL; } - if (entry->s.ops->pktin_ts_from_ns) - return entry->s.ops->pktin_ts_from_ns(entry, ns); + if (entry->s.ops->pktio_ts_from_ns) + return entry->s.ops->pktio_ts_from_ns(entry, ns); return odp_time_global_from_ns(ns); } +odp_time_t odp_pktio_time(odp_pktio_t hdl, odp_time_t *global_ts) +{ + pktio_entry_t *entry; + odp_time_t ts; + + entry = get_pktio_entry(hdl); + if (entry == NULL) { + ODP_ERR("pktio entry %d does not exist\n", hdl); + return ODP_TIME_NULL; + } + + /* Callback if present */ + if (entry->s.ops->pktio_time) + return entry->s.ops->pktio_time(entry, global_ts); + + /* By default both Packet IO time source and + * global time source are same. + */ + ts = odp_time_global(); + if (global_ts) + *global_ts = ts; + return ts; +} + +uint64_t odp_pktin_ts_res(odp_pktio_t hdl) +{ + return odp_pktio_ts_res(hdl); +} + +odp_time_t odp_pktin_ts_from_ns(odp_pktio_t hdl, uint64_t ns) +{ + return odp_pktio_ts_from_ns(hdl, ns); +} + void odp_pktio_print(odp_pktio_t hdl) { pktio_entry_t *entry; diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 7aee73dc1..8e07c3c69 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -2168,8 +2168,9 @@ const pktio_if_ops_t dpdk_pktio_ops = { .mac_get = dpdk_mac_addr_get, .mac_set = dpdk_mac_addr_set, .capability = dpdk_capability, - .pktin_ts_res = NULL, - .pktin_ts_from_ns = NULL, + .pktio_ts_res = NULL, + .pktio_ts_from_ns = NULL, + .pktio_time = NULL, .config = NULL, .input_queues_config = dpdk_input_queues_config, .output_queues_config = dpdk_output_queues_config diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c index 34b32ae2c..972697137 100644 --- a/platform/linux-generic/pktio/ipc.c +++ b/platform/linux-generic/pktio/ipc.c @@ -983,7 +983,8 @@ const pktio_if_ops_t ipc_pktio_ops = { .promisc_mode_get = NULL, .mac_get = ipc_mac_addr_get, .mac_set = NULL, - .pktin_ts_res = NULL, - .pktin_ts_from_ns = NULL, + .pktio_ts_res = NULL, + .pktio_ts_from_ns = NULL, + .pktio_time = NULL, .config = NULL }; diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index 3de096139..6523386f4 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -484,8 +484,9 @@ const pktio_if_ops_t loopback_pktio_ops = { .link_status = loopback_link_status, .link_info = loopback_link_info, .capability = loopback_capability, - .pktin_ts_res = NULL, - .pktin_ts_from_ns = NULL, + .pktio_ts_res = NULL, + .pktio_ts_from_ns = NULL, + .pktio_time = NULL, .config = NULL, .input_queues_config = NULL, .output_queues_config = NULL, diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index 0f608c6f6..b867a4ec3 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -1255,8 +1255,9 @@ const pktio_if_ops_t netmap_pktio_ops = { .mac_get = netmap_mac_addr_get, .mac_set = NULL, .capability = netmap_capability, - .pktin_ts_res = NULL, - .pktin_ts_from_ns = NULL, + .pktio_ts_res = NULL, + .pktio_ts_from_ns = NULL, + .pktio_time = NULL, .config = NULL, .input_queues_config = netmap_input_queues_config, .output_queues_config = netmap_output_queues_config, diff --git a/platform/linux-generic/pktio/null.c b/platform/linux-generic/pktio/null.c index d739ccafe..5e771b631 100644 --- a/platform/linux-generic/pktio/null.c +++ b/platform/linux-generic/pktio/null.c @@ -194,8 +194,9 @@ const pktio_if_ops_t null_pktio_ops = { .promisc_mode_get = null_promisc_mode_get, .mac_get = null_mac_addr_get, .capability = null_capability, - .pktin_ts_res = NULL, - .pktin_ts_from_ns = NULL, + .pktio_ts_res = NULL, + .pktio_ts_from_ns = NULL, + .pktio_time = NULL, .config = NULL, .input_queues_config = null_inqueues_config, .output_queues_config = null_outqueues_config, diff --git a/platform/linux-generic/pktio/pcap.c b/platform/linux-generic/pktio/pcap.c index 262528abc..bac03b8f7 100644 --- a/platform/linux-generic/pktio/pcap.c +++ b/platform/linux-generic/pktio/pcap.c @@ -481,8 +481,9 @@ const pktio_if_ops_t pcap_pktio_ops = { .mac_get = pcapif_mac_addr_get, .mac_set = NULL, .capability = pcapif_capability, - .pktin_ts_res = NULL, - .pktin_ts_from_ns = NULL, + .pktio_ts_res = NULL, + .pktio_ts_from_ns = NULL, + .pktio_time = NULL, .config = NULL, .input_queues_config = NULL, .output_queues_config = NULL, diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index ed2df4fab..9f60894d2 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -573,8 +573,9 @@ const pktio_if_ops_t sock_mmsg_pktio_ops = { .link_status = sock_link_status, .link_info = sock_link_info, .capability = sock_capability, - .pktin_ts_res = NULL, - .pktin_ts_from_ns = NULL, + .pktio_ts_res = NULL, + .pktio_ts_from_ns = NULL, + .pktio_time = NULL, .config = NULL, .input_queues_config = NULL, .output_queues_config = NULL, diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index 61bd56e39..12260fb50 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -890,8 +890,9 @@ const pktio_if_ops_t sock_mmap_pktio_ops = { .link_status = sock_mmap_link_status, .link_info = sock_mmap_link_info, .capability = sock_mmap_capability, - .pktin_ts_res = NULL, - .pktin_ts_from_ns = NULL, + .pktio_ts_res = NULL, + .pktio_ts_from_ns = NULL, + .pktio_time = NULL, .config = NULL, .input_queues_config = NULL, .output_queues_config = NULL, diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c index 13a9feaf8..325c585ca 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -508,7 +508,8 @@ const pktio_if_ops_t tap_pktio_ops = { .link_status = tap_link_status, .link_info = tap_link_info, .capability = tap_capability, - .pktin_ts_res = NULL, - .pktin_ts_from_ns = NULL, + .pktio_ts_res = NULL, + .pktio_ts_from_ns = NULL, + .pktio_time = NULL, .config = NULL }; |