ethdev: add generic MAC address rewrite actions
[dpdk.git] / lib / librte_ethdev / rte_flow.h
index 1288e76..26e2fcf 100644 (file)
@@ -1506,6 +1506,113 @@ enum rte_flow_action_type {
         * error.
         */
        RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
+
+       /**
+        * Modify IPv4 source address in the outermost IPv4 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_ipv4.
+        */
+       RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
+
+       /**
+        * Modify IPv4 destination address in the outermost IPv4 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_ipv4.
+        */
+       RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
+
+       /**
+        * Modify IPv6 source address in the outermost IPv6 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_ipv6.
+        */
+       RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
+
+       /**
+        * Modify IPv6 destination address in the outermost IPv6 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_ipv6.
+        */
+       RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
+
+       /**
+        * Modify source port number in the outermost TCP/UDP header.
+        *
+        * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
+        * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
+        * RTE_FLOW_ERROR_TYPE_ACTION error.
+        *
+        * See struct rte_flow_action_set_tp.
+        */
+       RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
+
+       /**
+        * Modify destination port number in the outermost TCP/UDP header.
+        *
+        * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
+        * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
+        * RTE_FLOW_ERROR_TYPE_ACTION error.
+        *
+        * See struct rte_flow_action_set_tp.
+        */
+       RTE_FLOW_ACTION_TYPE_SET_TP_DST,
+
+       /**
+        * Swap the source and destination MAC addresses in the outermost
+        * Ethernet header.
+        *
+        * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
+        * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
+        *
+        * No associated configuration structure.
+        */
+       RTE_FLOW_ACTION_TYPE_MAC_SWAP,
+
+       /**
+        * Decrease TTL value directly
+        *
+        * No associated configuration structure.
+        */
+       RTE_FLOW_ACTION_TYPE_DEC_TTL,
+
+       /**
+        * Set TTL value
+        *
+        * See struct rte_flow_action_set_ttl
+        */
+       RTE_FLOW_ACTION_TYPE_SET_TTL,
+
+       /**
+        * Set source MAC address from matched flow.
+        *
+        * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
+        * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
+        *
+        * See struct rte_flow_action_set_mac.
+        */
+       RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
+
+       /**
+        * Set destination MAC address from matched flow.
+        *
+        * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
+        * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
+        *
+        * See struct rte_flow_action_set_mac.
+        */
+       RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
 };
 
 /**
@@ -1869,6 +1976,69 @@ struct rte_flow_action_nvgre_encap {
        struct rte_flow_item *definition;
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
+ * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
+ *
+ * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
+ * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
+ * specified outermost IPv4 header.
+ */
+struct rte_flow_action_set_ipv4 {
+       rte_be32_t ipv4_addr;
+};
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
+ * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
+ *
+ * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
+ * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
+ * specified outermost IPv6 header.
+ */
+struct rte_flow_action_set_ipv6 {
+       uint8_t ipv6_addr[16];
+};
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
+ * RTE_FLOW_ACTION_TYPE_SET_TP_DST
+ *
+ * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
+ * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
+ * in the specified outermost TCP/UDP header.
+ */
+struct rte_flow_action_set_tp {
+       rte_be16_t port;
+};
+
+/**
+ * RTE_FLOW_ACTION_TYPE_SET_TTL
+ *
+ * Set the TTL value directly for IPv4 or IPv6
+ */
+struct rte_flow_action_set_ttl {
+       uint8_t ttl_value;
+};
+
+/**
+ * RTE_FLOW_ACTION_TYPE_SET_MAC
+ *
+ * Set MAC address from the matched flow
+ */
+struct rte_flow_action_set_mac {
+       uint8_t mac_addr[ETHER_ADDR_LEN];
+};
+
 /*
  * Definition of a single action.
  *
@@ -2043,6 +2213,62 @@ enum rte_flow_conv_op {
         *   @code struct rte_flow_conv_rule * @endcode
         */
        RTE_FLOW_CONV_OP_RULE,
+
+       /**
+        * Convert item type to its name string.
+        *
+        * Writes a NUL-terminated string to @p dst. Like snprintf(), the
+        * returned value excludes the terminator which is always written
+        * nonetheless.
+        *
+        * - @p src type:
+        *   @code (const void *)enum rte_flow_item_type @endcode
+        * - @p dst type:
+        *   @code char * @endcode
+        **/
+       RTE_FLOW_CONV_OP_ITEM_NAME,
+
+       /**
+        * Convert action type to its name string.
+        *
+        * Writes a NUL-terminated string to @p dst. Like snprintf(), the
+        * returned value excludes the terminator which is always written
+        * nonetheless.
+        *
+        * - @p src type:
+        *   @code (const void *)enum rte_flow_action_type @endcode
+        * - @p dst type:
+        *   @code char * @endcode
+        **/
+       RTE_FLOW_CONV_OP_ACTION_NAME,
+
+       /**
+        * Convert item type to pointer to item name.
+        *
+        * Retrieves item name pointer from its type. The string itself is
+        * not copied; instead, a unique pointer to an internal static
+        * constant storage is written to @p dst.
+        *
+        * - @p src type:
+        *   @code (const void *)enum rte_flow_item_type @endcode
+        * - @p dst type:
+        *   @code const char ** @endcode
+        */
+       RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
+
+       /**
+        * Convert action type to pointer to action name.
+        *
+        * Retrieves action name pointer from its type. The string itself is
+        * not copied; instead, a unique pointer to an internal static
+        * constant storage is written to @p dst.
+        *
+        * - @p src type:
+        *   @code (const void *)enum rte_flow_action_type @endcode
+        * - @p dst type:
+        *   @code const char ** @endcode
+        */
+       RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
 };
 
 /**
@@ -2276,6 +2502,7 @@ rte_flow_error_set(struct rte_flow_error *error,
                   const char *message);
 
 /**
+ * @deprecated
  * @see rte_flow_copy()
  */
 struct rte_flow_desc {
@@ -2287,10 +2514,13 @@ struct rte_flow_desc {
 };
 
 /**
+ * @deprecated
  * Copy an rte_flow rule description.
  *
  * This interface is kept for compatibility with older applications but is
- * implemented as a wrapper to rte_flow_conv().
+ * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
+ * lack of flexibility and reliance on a type unusable with C++ programs
+ * (struct rte_flow_desc).
  *
  * @param[in] fd
  *   Flow rule description.
@@ -2309,6 +2539,7 @@ struct rte_flow_desc {
  *   If len is lower than the size of the flow, the number of bytes that would
  *   have been written to desc had it been sufficient. Nothing is written.
  */
+__rte_deprecated
 size_t
 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
              const struct rte_flow_attr *attr,