ethdev: support flow aging
[dpdk.git] / lib / librte_ethdev / rte_flow.h
index 58b5026..fab44f6 100644 (file)
@@ -510,6 +510,23 @@ enum rte_flow_item_type {
         * See struct rte_flow_item_tag.
         */
        RTE_FLOW_ITEM_TYPE_TAG,
+
+       /**
+        * Matches a L2TPv3 over IP header.
+        *
+        * Configure flow for L2TPv3 over IP packets.
+        *
+        * See struct rte_flow_item_l2tpv3oip.
+        */
+       RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
+
+       /**
+        * Matches PFCP Header.
+        * See struct rte_flow_item_pfcp.
+        *
+        */
+       RTE_FLOW_ITEM_TYPE_PFCP,
+
 };
 
 /**
@@ -1373,6 +1390,23 @@ static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
 };
 #endif
 
+/**
+ * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
+ *
+ * Matches a L2TPv3 over IP header.
+ */
+struct rte_flow_item_l2tpv3oip {
+       rte_be32_t session_id; /**< Session ID. */
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
+#ifndef __cplusplus
+static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
+       .session_id = RTE_BE32(UINT32_MAX),
+};
+#endif
+
+
 /**
  * @warning
  * @b EXPERIMENTAL: this structure may change without prior notice
@@ -1481,6 +1515,29 @@ static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
 };
 #endif
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ITEM_TYPE_PFCP
+ *
+ * Match PFCP Header
+ */
+struct rte_flow_item_pfcp {
+       uint8_t s_field;
+       uint8_t msg_type;
+       rte_be16_t msg_len;
+       rte_be64_t seid;
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
+#ifndef __cplusplus
+static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
+       .s_field = 0x01,
+       .seid = RTE_BE64(0xffffffffffffffff),
+};
+#endif
+
 /**
  * Matching pattern item definition.
  *
@@ -2004,6 +2061,36 @@ enum rte_flow_action_type {
         * See struct rte_flow_action_set_meta.
         */
        RTE_FLOW_ACTION_TYPE_SET_META,
+
+       /**
+        * Modify IPv4 DSCP in the outermost IP header.
+        *
+        * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
+        * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
+        *
+        * See struct rte_flow_action_set_dscp.
+        */
+       RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
+
+       /**
+        * Modify IPv6 DSCP in the outermost IP header.
+        *
+        * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
+        * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
+        *
+        * See struct rte_flow_action_set_dscp.
+        */
+       RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
+
+       /**
+        * Report as aged flow if timeout passed without any matching on the
+        * flow.
+        *
+        * See struct rte_flow_action_age.
+        * See function rte_flow_get_aged_flows
+        * see enum RTE_ETH_EVENT_FLOW_AGED
+        */
+       RTE_FLOW_ACTION_TYPE_AGE,
 };
 
 /**
@@ -2045,6 +2132,25 @@ struct rte_flow_action_queue {
        uint16_t index; /**< Queue index to use. */
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_AGE
+ *
+ * Report flow as aged-out if timeout passed without any matching
+ * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
+ * port detects new aged-out flows.
+ *
+ * The flow context and the flow handle will be reported by the
+ * rte_flow_get_aged_flows API.
+ */
+struct rte_flow_action_age {
+       uint32_t timeout:24; /**< Time in seconds. */
+       uint32_t reserved:8; /**< Reserved, must be zero. */
+       void *context;
+               /**< The user flow context, NULL means the rte_flow pointer. */
+};
 
 /**
  * @warning
@@ -2239,6 +2345,11 @@ struct rte_flow_action_meter {
  * direction.
  *
  * Multiple flows can be configured to use the same security session.
+ *
+ * The NULL value is allowed for security session. If security session is NULL,
+ * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
+ * 'IPv6' will be allowed to be a range. The rule thus created can enable
+ * security processing on multiple flows.
  */
 struct rte_flow_action_security {
        void *security_session; /**< Pointer to security session structure. */
@@ -2530,6 +2641,17 @@ struct rte_flow_action_set_meta {
        uint32_t mask;
 };
 
+/**
+ * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
+ * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
+ *
+ * Set the DSCP value for IPv4/IPv6 header.
+ * DSCP in low 6 bits, rest ignored.
+ */
+struct rte_flow_action_set_dscp {
+       uint8_t dscp;
+};
+
 /* Mbuf dynamic field offset for metadata. */
 extern int rte_flow_dynf_metadata_offs;
 
@@ -2790,6 +2912,27 @@ enum rte_flow_conv_op {
        RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Dump hardware internal representation information of
+ * rte flow to file.
+ *
+ * @param[in] port_id
+ *    The port identifier of the Ethernet device.
+ * @param[in] file
+ *   A pointer to a file for output.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL. PMDs initialize this
+ *   structure in case of error only.
+ * @return
+ *   0 on success, a nagative value otherwise.
+ */
+__rte_experimental
+int
+rte_flow_dev_dump(uint16_t port_id, FILE *file, struct rte_flow_error *error);
+
 /**
  * Check if mbuf dynamic field for metadata is registered.
  *
@@ -3140,6 +3283,39 @@ rte_flow_conv(enum rte_flow_conv_op op,
              const void *src,
              struct rte_flow_error *error);
 
+/**
+ * Get aged-out flows of a given port.
+ *
+ * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
+ * out flow was detected after the last call to rte_flow_get_aged_flows.
+ * This function can be called to get the aged flows usynchronously from the
+ * event callback or synchronously regardless the event.
+ * This is not safe to call rte_flow_get_aged_flows function with other flow
+ * functions from multiple threads simultaneously.
+ *
+ * @param port_id
+ *   Port identifier of Ethernet device.
+ * @param[in, out] contexts
+ *   The address of an array of pointers to the aged-out flows contexts.
+ * @param[in] nb_contexts
+ *   The length of context array pointers.
+ * @param[out] error
+ *   Perform verbose error reporting if not NULL. Initialized in case of
+ *   error only.
+ *
+ * @return
+ *   if nb_contexts is 0, return the amount of all aged contexts.
+ *   if nb_contexts is not 0 , return the amount of aged flows reported
+ *   in the context array, otherwise negative errno value.
+ *
+ * @see rte_flow_action_age
+ * @see RTE_ETH_EVENT_FLOW_AGED
+ */
+__rte_experimental
+int
+rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
+                       uint32_t nb_contexts, struct rte_flow_error *error);
+
 #ifdef __cplusplus
 }
 #endif