ethdev: add port ID item and action to flow API
[dpdk.git] / lib / librte_ether / rte_flow.h
index 58b75e9..09a21e5 100644 (file)
@@ -179,6 +179,16 @@ enum rte_flow_item_type {
         */
        RTE_FLOW_ITEM_TYPE_PHY_PORT,
 
+       /**
+        * [META]
+        *
+        * Matches traffic originating from (ingress) or going to (egress) a
+        * given DPDK port ID.
+        *
+        * See struct rte_flow_item_port_id.
+        */
+       RTE_FLOW_ITEM_TYPE_PORT_ID,
+
        /**
         * Matches a byte string of a given length at a given offset.
         *
@@ -413,6 +423,32 @@ static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
 };
 #endif
 
+/**
+ * RTE_FLOW_ITEM_TYPE_PORT_ID
+ *
+ * Matches traffic originating from (ingress) or going to (egress) a given
+ * DPDK port ID.
+ *
+ * Normally only supported if the port ID in question is known by the
+ * underlying PMD and related to the device the flow rule is created
+ * against.
+ *
+ * This must not be confused with @p PHY_PORT which refers to the physical
+ * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
+ * object on the application side (also known as "port representor"
+ * depending on the kind of underlying device).
+ */
+struct rte_flow_item_port_id {
+       uint32_t id; /**< DPDK port ID. */
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
+#ifndef __cplusplus
+static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
+       .id = 0xffffffff,
+};
+#endif
+
 /**
  * RTE_FLOW_ITEM_TYPE_RAW
  *
@@ -996,6 +1032,13 @@ enum rte_flow_action_type {
         */
        RTE_FLOW_ACTION_TYPE_PHY_PORT,
 
+       /**
+        * Directs matching traffic to a given DPDK port ID.
+        *
+        * See struct rte_flow_action_port_id.
+        */
+       RTE_FLOW_ACTION_TYPE_PORT_ID,
+
        /**
         * Traffic metering and policing (MTR).
         *
@@ -1133,6 +1176,19 @@ struct rte_flow_action_phy_port {
        uint32_t index; /**< Physical port index. */
 };
 
+/**
+ * RTE_FLOW_ACTION_TYPE_PORT_ID
+ *
+ * Directs matching traffic to a given DPDK port ID.
+ *
+ * @see RTE_FLOW_ITEM_TYPE_PORT_ID
+ */
+struct rte_flow_action_port_id {
+       uint32_t original:1; /**< Use original DPDK port ID if possible. */
+       uint32_t reserved:31; /**< Reserved, must be zero. */
+       uint32_t id; /**< DPDK port ID. */
+};
+
 /**
  * RTE_FLOW_ACTION_TYPE_METER
  *