New upstream version 17.11-rc3
[deb_dpdk.git] / lib / librte_ether / rte_flow.h
index bba6169..47c88ea 100644 (file)
@@ -50,6 +50,7 @@
 #include <rte_tcp.h>
 #include <rte_udp.h>
 #include <rte_byteorder.h>
+#include <rte_esp.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -309,6 +310,40 @@ enum rte_flow_item_type {
         * See struct rte_flow_item_fuzzy.
         */
        RTE_FLOW_ITEM_TYPE_FUZZY,
+
+       /**
+        * Matches a GTP header.
+        *
+        * Configure flow for GTP packets.
+        *
+        * See struct rte_flow_item_gtp.
+        */
+       RTE_FLOW_ITEM_TYPE_GTP,
+
+       /**
+        * Matches a GTP header.
+        *
+        * Configure flow for GTP-C packets.
+        *
+        * See struct rte_flow_item_gtp.
+        */
+       RTE_FLOW_ITEM_TYPE_GTPC,
+
+       /**
+        * Matches a GTP header.
+        *
+        * Configure flow for GTP-U packets.
+        *
+        * See struct rte_flow_item_gtp.
+        */
+       RTE_FLOW_ITEM_TYPE_GTPU,
+
+       /**
+        * Matches a ESP header.
+        *
+        * See struct rte_flow_item_esp.
+        */
+       RTE_FLOW_ITEM_TYPE_ESP,
 };
 
 /**
@@ -734,6 +769,49 @@ static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
 };
 #endif
 
+/**
+ * RTE_FLOW_ITEM_TYPE_GTP.
+ *
+ * Matches a GTPv1 header.
+ */
+struct rte_flow_item_gtp {
+       /**
+        * Version (3b), protocol type (1b), reserved (1b),
+        * Extension header flag (1b),
+        * Sequence number flag (1b),
+        * N-PDU number flag (1b).
+        */
+       uint8_t v_pt_rsv_flags;
+       uint8_t msg_type; /**< Message type. */
+       rte_be16_t msg_len; /**< Message length. */
+       rte_be32_t teid; /**< Tunnel endpoint identifier. */
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
+#ifndef __cplusplus
+static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
+       .teid = RTE_BE32(0xffffffff),
+};
+#endif
+
+/**
+ * RTE_FLOW_ITEM_TYPE_ESP
+ *
+ * Matches an ESP header.
+ */
+struct rte_flow_item_esp {
+       struct esp_hdr hdr; /**< ESP header definition. */
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
+#ifndef __cplusplus
+static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
+       .hdr = {
+               .spi = 0xffffffff,
+       },
+};
+#endif
+
 /**
  * Matching pattern item definition.
  *
@@ -915,6 +993,22 @@ enum rte_flow_action_type {
         * See struct rte_flow_action_vf.
         */
        RTE_FLOW_ACTION_TYPE_VF,
+
+       /**
+        * Traffic metering and policing (MTR).
+        *
+        * See struct rte_flow_action_meter.
+        * See file rte_mtr.h for MTR object configuration.
+        */
+       RTE_FLOW_ACTION_TYPE_METER,
+
+       /**
+        * Redirects packets to security engine of current device for security
+        * processing as specified by security session.
+        *
+        * See struct rte_flow_action_security.
+        */
+       RTE_FLOW_ACTION_TYPE_SECURITY
 };
 
 /**
@@ -1007,6 +1101,51 @@ struct rte_flow_action_vf {
        uint32_t id; /**< VF ID to redirect packets to. */
 };
 
+/**
+ * RTE_FLOW_ACTION_TYPE_METER
+ *
+ * Traffic metering and policing (MTR).
+ *
+ * Packets matched by items of this type can be either dropped or passed to the
+ * next item with their color set by the MTR object.
+ *
+ * Non-terminating by default.
+ */
+struct rte_flow_action_meter {
+       uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
+};
+
+/**
+ * RTE_FLOW_ACTION_TYPE_SECURITY
+ *
+ * Perform the security action on flows matched by the pattern items
+ * according to the configuration of the security session.
+ *
+ * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
+ * security protocol headers and IV are fully provided by the application as
+ * specified in the flow pattern. The payload of matching packets is
+ * encrypted on egress, and decrypted and authenticated on ingress.
+ * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
+ * providing full encapsulation and decapsulation of packets in security
+ * protocols. The flow pattern specifies both the outer security header fields
+ * and the inner packet fields. The security session specified in the action
+ * must match the pattern parameters.
+ *
+ * The security session specified in the action must be created on the same
+ * port as the flow action that is being specified.
+ *
+ * The ingress/egress flow attribute should match that specified in the
+ * security session if the security session supports the definition of the
+ * direction.
+ *
+ * Multiple flows can be configured to use the same security session.
+ *
+ * Non-terminating by default.
+ */
+struct rte_flow_action_security {
+       void *security_session; /**< Pointer to security session structure. */
+};
+
 /**
  * Definition of a single action.
  *
@@ -1116,7 +1255,7 @@ struct rte_flow_error {
  *   state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
  */
 int
-rte_flow_validate(uint8_t port_id,
+rte_flow_validate(uint16_t port_id,
                  const struct rte_flow_attr *attr,
                  const struct rte_flow_item pattern[],
                  const struct rte_flow_action actions[],
@@ -1143,7 +1282,7 @@ rte_flow_validate(uint8_t port_id,
  *   rte_flow_validate().
  */
 struct rte_flow *
-rte_flow_create(uint8_t port_id,
+rte_flow_create(uint16_t port_id,
                const struct rte_flow_attr *attr,
                const struct rte_flow_item pattern[],
                const struct rte_flow_action actions[],
@@ -1170,7 +1309,7 @@ rte_flow_create(uint8_t port_id,
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
 int
-rte_flow_destroy(uint8_t port_id,
+rte_flow_destroy(uint16_t port_id,
                 struct rte_flow *flow,
                 struct rte_flow_error *error);
 
@@ -1191,7 +1330,7 @@ rte_flow_destroy(uint8_t port_id,
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
 int
-rte_flow_flush(uint8_t port_id,
+rte_flow_flush(uint16_t port_id,
               struct rte_flow_error *error);
 
 /**
@@ -1219,7 +1358,7 @@ rte_flow_flush(uint8_t port_id,
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
 int
-rte_flow_query(uint8_t port_id,
+rte_flow_query(uint16_t port_id,
               struct rte_flow *flow,
               enum rte_flow_action_type action,
               void *data,
@@ -1267,7 +1406,31 @@ rte_flow_query(uint8_t port_id,
  *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
 int
-rte_flow_isolate(uint8_t port_id, int set, struct rte_flow_error *error);
+rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
+
+/**
+ * Initialize flow error structure.
+ *
+ * @param[out] error
+ *   Pointer to flow error structure (may be NULL).
+ * @param code
+ *   Related error code (rte_errno).
+ * @param type
+ *   Cause field and error types.
+ * @param cause
+ *   Object responsible for the error.
+ * @param message
+ *   Human-readable error message.
+ *
+ * @return
+ *   Negative error code (errno value) and rte_errno is set.
+ */
+int
+rte_flow_error_set(struct rte_flow_error *error,
+                  int code,
+                  enum rte_flow_error_type type,
+                  const void *cause,
+                  const char *message);
 
 /**
  * Generic flow representation.