Merged,
Maxim.

On 04/01/16 20:00, Balasubramanian Manoharan wrote:
For the series:
Reviewed-by: Balasubramanian Manoharan <bala.manoha...@linaro.org>

On 31/03/16 9:41 PM, Petri Savolainen wrote:
Added API calls and definitions for pktio interface level
configuration options. Timestamping is one of those options.
Added definitions to query and enable packet input timestamping.
Packet timestamps are stored in odp_time_t, direct nanoseconds
calls can be added later if needed. Timestamp HW resolution is
expressed in hertz to enable high resolution. Advanced time
protocol handling (e.g. PTP packet timestamping on output)
can be added later.

Signed-off-by: Petri Savolainen <petri.savolai...@nokia.com>
---
  include/odp/api/spec/packet.h       |  32 +++++++++++
  include/odp/api/spec/packet_flags.h |  24 ++++++++
include/odp/api/spec/packet_io.h | 106 +++++++++++++++++++++++++++++++++++-
  3 files changed, 160 insertions(+), 2 deletions(-)

diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
index 9c63b5f..7da353b 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -18,6 +18,8 @@
  extern "C" {
  #endif
  +#include <odp/api/time.h>
+
  /** @defgroup odp_packet ODP PACKET
   *  Operations on a packet.
   *  @{
@@ -691,6 +693,36 @@ uint32_t odp_packet_flow_hash(odp_packet_t pkt);
  void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t flow_hash);
    /**
+ * Packet timestamp
+ *
+ * Returns packet timestamp value as odp_time_t type. Use time API for
+ * additional operations on packet timestamp values or conversion into
+ * nanoseconds. Use odp_packet_has_ts() to check if packet has a valid
+ * timestamp. Packet input interface timestamp resolution can be checked with
+ * odp_pktin_ts_res().
+ *
+ * @param pkt  Packet handle
+ *
+ * @return Timestamp value
+ *
+ * @see odp_pktin_ts_res(), odp_packet_has_ts(), odp_time_to_ns()
+ */
+odp_time_t odp_packet_ts(odp_packet_t pkt);
+
+/**
+ * Set packet timestamp
+ *
+ * Stores timestamp value and sets timestamp flag for the packet.
+ *
+ * @param pkt        Packet handle
+ * @param timestamp  Timestamp value
+ *
+ * @see odp_packet_ts(), odp_packet_has_ts(),
+ * odp_pktin_ts_from_ns()
+ */
+void odp_packet_ts_set(odp_packet_t pkt, odp_time_t timestamp);
+
+/**
   * Tests if packet is segmented
   *
   * @param pkt  Packet handle
diff --git a/include/odp/api/spec/packet_flags.h b/include/odp/api/spec/packet_flags.h
index a095ed7..35d44e1 100644
--- a/include/odp/api/spec/packet_flags.h
+++ b/include/odp/api/spec/packet_flags.h
@@ -285,6 +285,18 @@ int odp_packet_has_icmp(odp_packet_t pkt);
  int odp_packet_has_flow_hash(odp_packet_t pkt);
    /**
+ * Check for packet timestamp
+ *
+ * @param pkt Packet handle
+ *
+ * @retval non-zero if packet contains a timestamp value
+ * @retval 0 if packet does not contain a timestamp value
+ *
+ * @see odp_packet_has_ts_clr()
+ */
+int odp_packet_has_ts(odp_packet_t pkt);
+
+/**
   * Set flag for L2 header, e.g. ethernet
   *
   * @param pkt Packet handle
@@ -462,6 +474,18 @@ void odp_packet_has_icmp_set(odp_packet_t pkt, int val);
  void odp_packet_has_flow_hash_clr(odp_packet_t pkt);
    /**
+ * Clear flag for packet timestamp
+ *
+ * This call clears the timestamp flag. A odp_packet_ts_set() call sets
+ * the flag in addition to the timestamp value.
+ *
+ * @param pkt Packet handle
+ *
+ * @see odp_packet_has_ts(), odp_packet_ts_set()
+ */
+void odp_packet_has_ts_clr(odp_packet_t pkt);
+
+/**
   * @}
   */
diff --git a/include/odp/api/spec/packet_io.h b/include/odp/api/spec/packet_io.h
index 3695e52..58b341b 100644
--- a/include/odp/api/spec/packet_io.h
+++ b/include/odp/api/spec/packet_io.h
@@ -20,6 +20,7 @@ extern "C" {
    #include <odp/api/spec/packet_io_stats.h>
  #include <odp/api/spec/queue.h>
+#include <odp/api/time.h>
    /** @defgroup odp_packet_io ODP PACKET IO
   *  Operations on a packet Input/Output interface.
@@ -206,21 +207,63 @@ typedef struct odp_pktout_queue_param_t {
  /**
   * Packet IO parameters
   *
- * In minimum, user must select input and output modes. Use 0 for defaults.
- * Initialize entire struct with zero to maintain API compatibility.
+ * Packet IO interface level parameters. Use odp_pktio_param_init() to
+ * initialize the structure with default values.
   */
  typedef struct odp_pktio_param_t {
      /** Packet input mode
        *
        * The default value is ODP_PKTIN_MODE_DIRECT. */
      odp_pktin_mode_t in_mode;
+
      /** Packet output mode
        *
        * The default value is ODP_PKTOUT_MODE_DIRECT. */
      odp_pktout_mode_t out_mode;
+
  } odp_pktio_param_t;
    /**
+ * Packet input configuration options bit field
+ *
+ * Packet input configuration options listed in a bit field structure. Packet + * input timestamping may be enabled for all packets or at least for those that
+ * belong to time synchronization protocol (PTP).
+ */
+typedef union odp_pktin_config_opt_t {
+    /** Option flags */
+    struct {
+        /** Timestamp all packets on packet input */
+        uint64_t ts_all        : 1;
+
+        /** Timestamp (at least) IEEE1588 / PTP packets
+          * on packet input */
+        uint64_t ts_ptp        : 1;
+    } bit;
+
+    /** All bits of the bit field structure
+      *
+      * This field can be used to set/clear all flags, or bitwise
+      * operations over the entire structure. */
+    uint64_t all_bits;
+} odp_pktin_config_opt_t;
+
+/**
+ * Packet IO configuration options
+ *
+ * Packet IO interface level configuration options. Use odp_pktio_capability()
+ * to see which options are supported by the implementation.
+ * Use odp_pktio_config_init() to initialize the structure with default values.
+ */
+typedef struct odp_pktio_config_t {
+    /** Packet input configuration options bit field
+     *
+     *  Default value for all bits is zero. */
+    odp_pktin_config_opt_t pktin;
+
+} odp_pktio_config_t;
+
+/**
   * Packet IO set operations
   *
* Supported packet IO interface set operations listed in a bit field structure.
@@ -243,8 +286,13 @@ typedef union odp_pktio_set_op_t {
  typedef struct odp_pktio_capability_t {
      /** Maximum number of input queues */
      unsigned max_input_queues;
+
      /** Maximum number of output queues */
      unsigned max_output_queues;
+
+    /** Supported pktio configuration options */
+    odp_pktio_config_t config;
+
      /** Supported set operations
       *
* A bit set to one indicates a supported operation. All other bits are @@ -323,6 +371,25 @@ odp_pktio_t odp_pktio_open(const char *name, odp_pool_t pool, int odp_pktio_capability(odp_pktio_t pktio, odp_pktio_capability_t *capa);
    /**
+ * Configure packet IO interface options
+ *
+ * Select interface level configuration options before the interface is
+ * activated (before odp_pktio_start() call). This step is optional in pktio + * interface setup sequence. Use odp_pktio_capability() to query configuration
+ * capabilities. Use odp_pktio_config_init() to initialize
+ * configuration options into their default values. Default values are used
+ * when 'config' pointer is NULL.
+ *
+ * @param pktio    Packet IO handle
+ * @param config   Packet IO interface configuration. Uses defaults
+ *                 when NULL.
+ *
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_pktio_config(odp_pktio_t pktio, const odp_pktio_config_t *config);
+
+/**
   * Configure packet input queues
   *
* Setup a number of packet input queues and configure those. The maximum number @@ -778,6 +845,15 @@ void odp_pktin_queue_param_init(odp_pktin_queue_param_t *param);
  void odp_pktout_queue_param_init(odp_pktout_queue_param_t *param);
    /**
+ * Initialize packet IO configuration options
+ *
+ * Initialize an odp_pktio_config_t to its default values.
+ *
+ * @param config  Packet IO interface configuration
+ */
+void odp_pktio_config_init(odp_pktio_config_t *config);
+
+/**
   * Print pktio info to the console
   *
* Print implementation-defined pktio debug information to the console.
@@ -826,6 +902,32 @@ typedef struct odp_pktio_info_t {
  int odp_pktio_info(odp_pktio_t pktio, odp_pktio_info_t *info);
    /**
+ * Packet input timestamp resolution in hertz
+ *
+ * This is the resolution of packet input timestamps. Returns zero on a failure
+ * or when timestamping is disabled.
+ *
+ * @param      pktio   Packet IO handle
+ *
+ * @return Packet input timestamp resolution in hertz
+ * @retval 0 on failure
+ */
+uint64_t odp_pktin_ts_res(odp_pktio_t pktio);
+
+/**
+ * Convert nanoseconds to packet input time
+ *
+ * Packet input time source is used for timestamping incoming packets.
+ * This function is used convert nanosecond time to packet input timestamp time.
+ *
+ * @param      pktio   Packet IO handle
+ * @param      ns      Time in nanoseconds
+ *
+ * @return Packet input timestamp
+ */
+odp_time_t odp_pktin_ts_from_ns(odp_pktio_t pktio, uint64_t ns);
+
+/**
   * @}
   */

_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp

_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to