X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_ethdev%2Frte_flow.h;h=b0e41991922cc64a501e28842ac3c7137382d6a7;hb=17ad3af9f4de9df82cba654027c47e6cecbe7b55;hp=350566cac8fa33e04916d65c5812b0dd441279b0;hpb=30f9f9f451531e41a1c51fe93ca965adb5a12e27;p=dpdk.git diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index 350566cac8..b0e4199192 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -27,6 +27,9 @@ #include #include #include +#include +#include +#include #ifdef __cplusplus extern "C" { @@ -417,7 +420,8 @@ enum rte_flow_item_type { /** * [META] * - * Matches a metadata value specified in mbuf metadata field. + * Matches a metadata value. + * * See struct rte_flow_item_meta. */ RTE_FLOW_ITEM_TYPE_META, @@ -484,8 +488,69 @@ enum rte_flow_item_type { * */ RTE_FLOW_ITEM_TYPE_IGMP, + + /** + * Matches IP Authentication Header (AH). + * See struct rte_flow_item_ah. + * + */ + RTE_FLOW_ITEM_TYPE_AH, + + /** + * Matches a HIGIG header. + * see struct rte_flow_item_higig2_hdr. + */ + RTE_FLOW_ITEM_TYPE_HIGIG2, + + /** + * [META] + * + * Matches a tag value. + * + * 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, + +}; + +/** + * + * RTE_FLOW_ITEM_TYPE_HIGIG2 + * Matches higig2 header + */ +RTE_STD_C11 +struct rte_flow_item_higig2_hdr { + struct rte_higig2_hdr hdr; }; +/** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */ +#ifndef __cplusplus +static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = { + .hdr = { + .ppt1 = { + .classification = 0xffff, + .vid = 0xfff, + }, + }, +}; +#endif + /** * RTE_FLOW_ITEM_TYPE_ANY * @@ -645,6 +710,12 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = { * the latter case, @p type refers to that of the outer header, with the * inner EtherType/TPID provided by the subsequent pattern item. This is the * same order as on the wire. + * If the @p type field contains a TPID value, then only tagged packets with the + * specified TPID will match the pattern. + * Otherwise, only untagged packets will match the pattern. + * If the @p ETH item is the only item in the pattern, and the @p type field + * is not specified, then both tagged and untagged packets will match the + * pattern. */ struct rte_flow_item_eth { struct rte_ether_addr dst; /**< Destination MAC. */ @@ -669,6 +740,8 @@ static const struct rte_flow_item_eth rte_flow_item_eth_mask = { * The corresponding standard outer EtherType (TPID) values are * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by * the preceding pattern item. + * If a @p VLAN item is present in the pattern, then only tagged packets will + * match the pattern. */ struct rte_flow_item_vlan { rte_be16_t tci; /**< Tag control information. */ @@ -1227,18 +1300,23 @@ rte_flow_item_icmp6_nd_opt_tla_eth_mask = { #endif /** - * RTE_FLOW_ITEM_TYPE_META. + * RTE_FLOW_ITEM_TYPE_META * - * Matches a specified metadata value. + * Matches a specified metadata value. On egress, metadata can be set + * either by mbuf dynamic metadata field with PKT_TX_DYNF_METADATA flag or + * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META + * sets metadata for a packet and the metadata will be reported via mbuf + * metadata dynamic field with PKT_RX_DYNF_METADATA flag. The dynamic mbuf + * field must be registered in advance by rte_flow_dynf_metadata_register(). */ struct rte_flow_item_meta { - rte_be32_t data; + uint32_t data; }; /** Default mask for RTE_FLOW_ITEM_TYPE_META. */ #ifndef __cplusplus static const struct rte_flow_item_meta rte_flow_item_meta_mask = { - .data = RTE_BE32(UINT32_MAX), + .data = UINT32_MAX, }; #endif @@ -1299,6 +1377,44 @@ rte_flow_item_pppoe_proto_id_mask = { }; #endif +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ITEM_TYPE_TAG + * + * Matches a specified tag value at the specified index. + */ +struct rte_flow_item_tag { + uint32_t data; + uint8_t index; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */ +#ifndef __cplusplus +static const struct rte_flow_item_tag rte_flow_item_tag_mask = { + .data = 0xffffffff, + .index = 0xff, +}; +#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 @@ -1321,6 +1437,13 @@ struct rte_flow_item_mark { uint32_t id; /**< Integer value to match against. */ }; +/** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */ +#ifndef __cplusplus +static const struct rte_flow_item_mark rte_flow_item_mark_mask = { + .id = 0xffffffff, +}; +#endif + /** * @warning * @b EXPERIMENTAL: this structure may change without prior notice @@ -1376,6 +1499,53 @@ static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = { }; #endif +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ITEM_TYPE_AH + * + * Match IP Authentication Header (AH), RFC 4302 + * + */ +struct rte_flow_item_ah { + uint32_t next_hdr:8; + uint32_t payload_len:8; + uint32_t reserved:16; + uint32_t spi; + uint32_t seq_num; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_AH. */ +#ifndef __cplusplus +static const struct rte_flow_item_ah rte_flow_item_ah_mask = { + .spi = 0xffffffff, +}; +#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(UINT64_C(0xffffffffffffffff)), +}; +#endif + /** * Matching pattern item definition. * @@ -1882,6 +2052,53 @@ enum rte_flow_action_type { * undefined behavior. */ RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK, + + /** + * Set Tag. + * + * Tag is for internal flow usage only and + * is not delivered to the application. + * + * See struct rte_flow_action_set_tag. + */ + RTE_FLOW_ACTION_TYPE_SET_TAG, + + /** + * Set metadata on ingress or egress path. + * + * 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, }; /** @@ -1923,6 +2140,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 @@ -2117,6 +2353,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. */ @@ -2369,6 +2610,84 @@ struct rte_flow_action_set_mac { uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; }; +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ACTION_TYPE_SET_TAG + * + * Set a tag which is a transient data used during flow matching. This is not + * delivered to application. Multiple tags are supported by specifying index. + */ +struct rte_flow_action_set_tag { + uint32_t data; + uint32_t mask; + uint8_t index; +}; + +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ACTION_TYPE_SET_META + * + * Set metadata. Metadata set by mbuf metadata dynamic field with + * PKT_TX_DYNF_DATA flag on egress will be overridden by this action. On + * ingress, the metadata will be carried by mbuf metadata dynamic field + * with PKT_RX_DYNF_METADATA flag if set. The dynamic mbuf field must be + * registered in advance by rte_flow_dynf_metadata_register(). + * + * Altering partial bits is supported with mask. For bits which have never + * been set, unpredictable value will be seen depending on driver + * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may + * or may not be propagated to the other path depending on HW capability. + * + * RTE_FLOW_ITEM_TYPE_META matches metadata. + */ +struct rte_flow_action_set_meta { + uint32_t data; + 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 int32_t rte_flow_dynf_metadata_offs; + +/* Mbuf dynamic field flag mask for metadata. */ +extern uint64_t rte_flow_dynf_metadata_mask; + +/* Mbuf dynamic field pointer for metadata. */ +#define RTE_FLOW_DYNF_METADATA(m) \ + RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *) + +/* Mbuf dynamic flags for metadata. */ +#define PKT_RX_DYNF_METADATA (rte_flow_dynf_metadata_mask) +#define PKT_TX_DYNF_METADATA (rte_flow_dynf_metadata_mask) + +__rte_experimental +static inline uint32_t +rte_flow_dynf_metadata_get(struct rte_mbuf *m) +{ + return *RTE_FLOW_DYNF_METADATA(m); +} + +__rte_experimental +static inline void +rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v) +{ + *RTE_FLOW_DYNF_METADATA(m) = v; +} + /* * Definition of a single action. * @@ -2601,6 +2920,54 @@ 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. + * + * @return + * True if registered, false otherwise. + */ +__rte_experimental +static inline int +rte_flow_dynf_metadata_avail(void) +{ + return !!rte_flow_dynf_metadata_mask; +} + +/** + * Register mbuf dynamic field and flag for metadata. + * + * This function must be called prior to use SET_META action in order to + * register the dynamic mbuf field. Otherwise, the data cannot be delivered to + * application. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +__rte_experimental +int +rte_flow_dynf_metadata_register(void); + /** * Check whether a flow rule can be created on a given port. * @@ -2924,6 +3291,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