net/i40e: fix Tx queue info get
[dpdk.git] / lib / librte_pipeline / rte_table_action.h
index 57ac4f9..c7f751a 100644 (file)
@@ -61,6 +61,7 @@ extern "C" {
 #include <rte_compat.h>
 #include <rte_ether.h>
 #include <rte_meter.h>
+#include <rte_table_hash.h>
 
 #include "rte_pipeline.h"
 
@@ -69,6 +70,9 @@ enum rte_table_action_type {
        /** Forward to next pipeline table, output port or drop. */
        RTE_TABLE_ACTION_FWD = 0,
 
+       /**  Load balance. */
+       RTE_TABLE_ACTION_LB,
+
        /**  Traffic Metering and Policing. */
        RTE_TABLE_ACTION_MTR,
 
@@ -83,6 +87,12 @@ enum rte_table_action_type {
 
        /** Time to Live (TTL) update. */
        RTE_TABLE_ACTION_TTL,
+
+       /** Statistics. */
+       RTE_TABLE_ACTION_STATS,
+
+       /** Timestamp. */
+       RTE_TABLE_ACTION_TIME,
 };
 
 /** Common action configuration (per table action profile). */
@@ -110,6 +120,54 @@ struct rte_table_action_fwd_params {
        uint32_t id;
 };
 
+/**
+ * RTE_TABLE_ACTION_LB
+ */
+/** Load balance key size min (number of bytes). */
+#define RTE_TABLE_ACTION_LB_KEY_SIZE_MIN                    8
+
+/** Load balance key size max (number of bytes). */
+#define RTE_TABLE_ACTION_LB_KEY_SIZE_MAX                    64
+
+/** Load balance table size. */
+#define RTE_TABLE_ACTION_LB_TABLE_SIZE                      8
+
+/** Load balance action configuration (per table action profile). */
+struct rte_table_action_lb_config {
+       /** Key size (number of bytes). */
+       uint32_t key_size;
+
+       /** Key offset within the input packet buffer. Offset 0 points to the
+        * first byte of the MBUF structure.
+        */
+       uint32_t key_offset;
+
+       /** Key mask (*key_size* bytes are valid). */
+       uint8_t key_mask[RTE_TABLE_ACTION_LB_KEY_SIZE_MAX];
+
+       /** Hash function. */
+       rte_table_hash_op_hash f_hash;
+
+       /** Seed value for *f_hash*. */
+       uint64_t seed;
+
+       /** Output value offset within the input packet buffer. Offset 0 points
+        * to the first byte of the MBUF structure.
+        */
+       uint32_t out_offset;
+};
+
+/** Load balance action parameters (per table rule). */
+struct rte_table_action_lb_params {
+       /** Table defining the output values and their weights. The weights are
+        * set in 1/RTE_TABLE_ACTION_LB_TABLE_SIZE increments. To assign a
+        * weight of N/RTE_TABLE_ACTION_LB_TABLE_SIZE to a given output value
+        * (0 <= N <= RTE_TABLE_ACTION_LB_TABLE_SIZE), the same output value
+        * needs to show up exactly N times in this table.
+        */
+       uint32_t out[RTE_TABLE_ACTION_LB_TABLE_SIZE];
+};
+
 /**
  * RTE_TABLE_ACTION_MTR
  */
@@ -488,6 +546,65 @@ struct rte_table_action_ttl_counters {
        uint64_t n_packets;
 };
 
+/**
+ * RTE_TABLE_ACTION_STATS
+ */
+/** Stats action configuration (per table action profile). */
+struct rte_table_action_stats_config {
+       /** When non-zero, the *n_packets* stats counter is enabled, otherwise
+        * disabled.
+        *
+        * @see struct rte_table_action_stats_counters
+        */
+       int n_packets_enabled;
+
+       /** When non-zero, the *n_bytes* stats counter is enabled, otherwise
+        * disabled.
+        *
+        * @see struct rte_table_action_stats_counters
+        */
+       int n_bytes_enabled;
+};
+
+/** Stats action parameters (per table rule). */
+struct rte_table_action_stats_params {
+       /** Initial value for the *n_packets* stats counter. Typically set to 0.
+        *
+        * @see struct rte_table_action_stats_counters
+        */
+       uint64_t n_packets;
+
+       /** Initial value for the *n_bytes* stats counter. Typically set to 0.
+        *
+        * @see struct rte_table_action_stats_counters
+        */
+       uint64_t n_bytes;
+};
+
+/** Stats action counters (per table rule). */
+struct rte_table_action_stats_counters {
+       /** Number of packets. Valid only when *n_packets_valid* is non-zero. */
+       uint64_t n_packets;
+
+       /** Number of bytes. Valid only when *n_bytes_valid* is non-zero. */
+       uint64_t n_bytes;
+
+       /** When non-zero, the *n_packets* field is valid, otherwise invalid. */
+       int n_packets_valid;
+
+       /** When non-zero, the *n_bytes* field is valid, otherwise invalid. */
+       int n_bytes_valid;
+};
+
+/**
+ * RTE_TABLE_ACTION_TIME
+ */
+/** Timestamp action parameters (per table rule). */
+struct rte_table_action_time_params {
+       /** Initial timestamp value. Typically set to current time. */
+       uint64_t time;
+};
+
 /**
  * Table action profile.
  */
@@ -737,6 +854,50 @@ rte_table_action_ttl_read(struct rte_table_action *action,
        struct rte_table_action_ttl_counters *stats,
        int clear);
 
+/**
+ * Table action stats read.
+ *
+ * @param[in] action
+ *   Handle to table action object (needs to be valid).
+ * @param[in] data
+ *   Data byte array (typically table rule data) with stats action previously
+ *   applied on it.
+ * @param[inout] stats
+ *   When non-NULL, it points to the area where the stats counters read from
+ *   *data* are saved.
+ * @param[in] clear
+ *   When non-zero, the stats counters are cleared (i.e. set to zero), otherwise
+ *   the counters are not modified. When the read operation is enabled (*stats*
+ *   is non-NULL), the clear operation is performed after the read operation is
+ *   completed.
+ * @return
+ *   Zero on success, non-zero error code otherwise.
+ */
+int __rte_experimental
+rte_table_action_stats_read(struct rte_table_action *action,
+       void *data,
+       struct rte_table_action_stats_counters *stats,
+       int clear);
+
+/**
+ * Table action timestamp read.
+ *
+ * @param[in] action
+ *   Handle to table action object (needs to be valid).
+ * @param[in] data
+ *   Data byte array (typically table rule data) with timestamp action
+ *   previously applied on it.
+ * @param[inout] timestamp
+ *   Pre-allocated memory where the timestamp read from *data* is saved (has to
+ *   be non-NULL).
+ * @return
+ *   Zero on success, non-zero error code otherwise.
+ */
+int __rte_experimental
+rte_table_action_time_read(struct rte_table_action *action,
+       void *data,
+       uint64_t *timestamp);
+
 #ifdef __cplusplus
 }
 #endif