X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_ethdev%2Frte_flow.h;h=7f3e08fad3ba2d365bb1b11560734bf6a99d6492;hb=3d26a70ae33853ac4116b135e55f3d475f148939;hp=f8ba71cdb78b51bbc9b6d7bafde48b206df9e6d1;hpb=01eb53eefeb40e82915fef92be64fd46a6178282;p=dpdk.git diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index f8ba71cdb7..7f3e08fad3 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -18,8 +18,8 @@ #include #include +#include #include -#include #include #include #include @@ -27,6 +27,9 @@ #include #include #include +#include +#include +#include #ifdef __cplusplus extern "C" { @@ -413,7 +416,140 @@ enum rte_flow_item_type { * See struct rte_flow_item_mark. */ RTE_FLOW_ITEM_TYPE_MARK, + + /** + * [META] + * + * Matches a metadata value. + * + * See struct rte_flow_item_meta. + */ + RTE_FLOW_ITEM_TYPE_META, + + /** + * Matches a GRE optional key field. + * + * The value should a big-endian 32bit integer. + * + * When this item present the K bit is implicitly matched as "1" + * in the default mask. + * + * @p spec/mask type: + * @code rte_be32_t * @endcode + */ + RTE_FLOW_ITEM_TYPE_GRE_KEY, + + /** + * Matches a GTP extension header: PDU session container. + * + * Configure flow for GTP packets with extension header type 0x85. + * + * See struct rte_flow_item_gtp_psc. + */ + RTE_FLOW_ITEM_TYPE_GTP_PSC, + + /** + * Matches a PPPoE header. + * + * Configure flow for PPPoE session packets. + * + * See struct rte_flow_item_pppoe. + */ + RTE_FLOW_ITEM_TYPE_PPPOES, + + /** + * Matches a PPPoE header. + * + * Configure flow for PPPoE discovery packets. + * + * See struct rte_flow_item_pppoe. + */ + RTE_FLOW_ITEM_TYPE_PPPOED, + + /** + * Matches a PPPoE optional proto_id field. + * + * It only applies to PPPoE session packets. + * + * See struct rte_flow_item_pppoe_proto_id. + */ + RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID, + + /** + * Matches Network service header (NSH). + * See struct rte_flow_item_nsh. + * + */ + RTE_FLOW_ITEM_TYPE_NSH, + + /** + * Matches Internet Group Management Protocol (IGMP). + * See struct rte_flow_item_igmp. + * + */ + 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 @@ -576,8 +712,8 @@ static const struct rte_flow_item_raw rte_flow_item_raw_mask = { * same order as on the wire. */ struct rte_flow_item_eth { - struct ether_addr dst; /**< Destination MAC. */ - struct ether_addr src; /**< Source MAC. */ + struct rte_ether_addr dst; /**< Destination MAC. */ + struct rte_ether_addr src; /**< Source MAC. */ rte_be16_t type; /**< EtherType or TPID. */ }; @@ -596,8 +732,8 @@ static const struct rte_flow_item_eth rte_flow_item_eth_mask = { * Matches an 802.1Q/ad VLAN tag. * * The corresponding standard outer EtherType (TPID) values are - * ETHER_TYPE_VLAN or ETHER_TYPE_QINQ. It can be overridden by the preceding - * pattern item. + * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by + * the preceding pattern item. */ struct rte_flow_item_vlan { rte_be16_t tci; /**< Tag control information. */ @@ -620,7 +756,7 @@ static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = { * Note: IPv4 options are handled by dedicated pattern items. */ struct rte_flow_item_ipv4 { - struct ipv4_hdr hdr; /**< IPv4 header definition. */ + struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */ @@ -642,7 +778,7 @@ static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = { * RTE_FLOW_ITEM_TYPE_IPV6_EXT. */ struct rte_flow_item_ipv6 { - struct ipv6_hdr hdr; /**< IPv6 header definition. */ + struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */ @@ -665,7 +801,7 @@ static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = { * Matches an ICMP header. */ struct rte_flow_item_icmp { - struct icmp_hdr hdr; /**< ICMP header definition. */ + struct rte_icmp_hdr hdr; /**< ICMP header definition. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */ @@ -684,7 +820,7 @@ static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = { * Matches a UDP header. */ struct rte_flow_item_udp { - struct udp_hdr hdr; /**< UDP header definition. */ + struct rte_udp_hdr hdr; /**< UDP header definition. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */ @@ -703,7 +839,7 @@ static const struct rte_flow_item_udp rte_flow_item_udp_mask = { * Matches a TCP header. */ struct rte_flow_item_tcp { - struct tcp_hdr hdr; /**< TCP header definition. */ + struct rte_tcp_hdr hdr; /**< TCP header definition. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */ @@ -722,7 +858,7 @@ static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = { * Matches a SCTP header. */ struct rte_flow_item_sctp { - struct sctp_hdr hdr; /**< SCTP header definition. */ + struct rte_sctp_hdr hdr; /**< SCTP header definition. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */ @@ -760,7 +896,7 @@ static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = { * Matches a E-tag header. * * The corresponding standard outer EtherType (TPID) value is - * ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item. + * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item. */ struct rte_flow_item_e_tag { /** @@ -907,14 +1043,14 @@ static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = { * Matches an ESP header. */ struct rte_flow_item_esp { - struct esp_hdr hdr; /**< ESP header definition. */ + struct rte_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, + .spi = RTE_BE32(0xffffffff), }, }; #endif @@ -973,9 +1109,9 @@ struct rte_flow_item_arp_eth_ipv4 { uint8_t hln; /**< Hardware address length, normally 6. */ uint8_t pln; /**< Protocol address length, normally 4. */ rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */ - struct ether_addr sha; /**< Sender hardware address. */ + struct rte_ether_addr sha; /**< Sender hardware address. */ rte_be32_t spa; /**< Sender IPv4 address. */ - struct ether_addr tha; /**< Target hardware address. */ + struct rte_ether_addr tha; /**< Target hardware address. */ rte_be32_t tpa; /**< Target IPv4 address. */ }; @@ -1119,7 +1255,7 @@ rte_flow_item_icmp6_nd_opt_mask = { struct rte_flow_item_icmp6_nd_opt_sla_eth { uint8_t type; /**< ND option type, normally 1. */ uint8_t length; /**< ND option length, normally 1. */ - struct ether_addr sla; /**< Source Ethernet LLA. */ + struct rte_ether_addr sla; /**< Source Ethernet LLA. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */ @@ -1144,7 +1280,7 @@ rte_flow_item_icmp6_nd_opt_sla_eth_mask = { struct rte_flow_item_icmp6_nd_opt_tla_eth { uint8_t type; /**< ND option type, normally 2. */ uint8_t length; /**< ND option length, normally 1. */ - struct ether_addr tla; /**< Target Ethernet LLA. */ + struct rte_ether_addr tla; /**< Target Ethernet LLA. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */ @@ -1155,6 +1291,122 @@ rte_flow_item_icmp6_nd_opt_tla_eth_mask = { }; #endif +/** + * RTE_FLOW_ITEM_TYPE_META + * + * 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 { + 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 = UINT32_MAX, +}; +#endif + +/** + * RTE_FLOW_ITEM_TYPE_GTP_PSC. + * + * Matches a GTP PDU extension header with type 0x85. + */ +struct rte_flow_item_gtp_psc { + uint8_t pdu_type; /**< PDU type. */ + uint8_t qfi; /**< QoS flow identifier. */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */ +#ifndef __cplusplus +static const struct rte_flow_item_gtp_psc +rte_flow_item_gtp_psc_mask = { + .qfi = 0x3f, +}; +#endif + +/** + * RTE_FLOW_ITEM_TYPE_PPPOE. + * + * Matches a PPPoE header. + */ +struct rte_flow_item_pppoe { + /** + * Version (4b), type (4b). + */ + uint8_t version_type; + uint8_t code; /**< Message type. */ + rte_be16_t session_id; /**< Session identifier. */ + rte_be16_t length; /**< Payload length. */ +}; + +/** + * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. + * + * Matches a PPPoE optional proto_id field. + * + * It only applies to PPPoE session packets. + * + * Normally preceded by any of: + * + * - RTE_FLOW_ITEM_TYPE_PPPOE + * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID + */ +struct rte_flow_item_pppoe_proto_id { + rte_be16_t proto_id; /**< PPP protocol identifier. */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */ +#ifndef __cplusplus +static const struct rte_flow_item_pppoe_proto_id +rte_flow_item_pppoe_proto_id_mask = { + .proto_id = RTE_BE16(0xffff), +}; +#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 @@ -1177,6 +1429,115 @@ 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 + * + * RTE_FLOW_ITEM_TYPE_NSH + * + * Match network service header (NSH), RFC 8300 + * + */ +struct rte_flow_item_nsh { + uint32_t version:2; + uint32_t oam_pkt:1; + uint32_t reserved:1; + uint32_t ttl:6; + uint32_t length:6; + uint32_t reserved1:4; + uint32_t mdtype:4; + uint32_t next_proto:8; + uint32_t spi:24; + uint32_t sindex:8; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */ +#ifndef __cplusplus +static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = { + .mdtype = 0xf, + .next_proto = 0xff, + .spi = 0xffffff, + .sindex = 0xff, +}; +#endif + +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ITEM_TYPE_IGMP + * + * Match Internet Group Management Protocol (IGMP), RFC 2236 + * + */ +struct rte_flow_item_igmp { + uint32_t type:8; + uint32_t max_resp_time:8; + uint32_t checksum:16; + uint32_t group_addr; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */ +#ifndef __cplusplus +static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = { + .group_addr = 0xffffffff, +}; +#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(0xffffffffffffffff), +}; +#endif + /** * Matching pattern item definition. * @@ -1220,9 +1581,10 @@ struct rte_flow_item { /** * Action types. * - * Each possible action is represented by a type. Some have associated - * configuration structures. Several actions combined in a list can be - * assigned to a flow rule and are performed in order. + * Each possible action is represented by a type. + * An action can have an associated configuration object. + * Several actions combined in a list can be assigned + * to a flow rule and are performed in order. * * They fall in three categories: * @@ -1505,6 +1867,220 @@ enum rte_flow_action_type { * error. */ RTE_FLOW_ACTION_TYPE_NVGRE_DECAP, + + /** + * Add outer header whose template is provided in its data buffer + * + * See struct rte_flow_action_raw_encap. + */ + RTE_FLOW_ACTION_TYPE_RAW_ENCAP, + + /** + * Remove outer header whose template is provided in its data buffer. + * + * See struct rte_flow_action_raw_decap + */ + RTE_FLOW_ACTION_TYPE_RAW_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, + + /** + * Increase sequence number in the outermost TCP header. + * + * Action configuration specifies the value to increase + * TCP sequence number as a big-endian 32 bit integer. + * + * @p conf type: + * @code rte_be32_t * @endcode + * + * Using this action on non-matching traffic will result in + * undefined behavior. + */ + RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ, + + /** + * Decrease sequence number in the outermost TCP header. + * + * Action configuration specifies the value to decrease + * TCP sequence number as a big-endian 32 bit integer. + * + * @p conf type: + * @code rte_be32_t * @endcode + * + * Using this action on non-matching traffic will result in + * undefined behavior. + */ + RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ, + + /** + * Increase acknowledgment number in the outermost TCP header. + * + * Action configuration specifies the value to increase + * TCP acknowledgment number as a big-endian 32 bit integer. + * + * @p conf type: + * @code rte_be32_t * @endcode + + * Using this action on non-matching traffic will result in + * undefined behavior. + */ + RTE_FLOW_ACTION_TYPE_INC_TCP_ACK, + + /** + * Decrease acknowledgment number in the outermost TCP header. + * + * Action configuration specifies the value to decrease + * TCP acknowledgment number as a big-endian 32 bit integer. + * + * @p conf type: + * @code rte_be32_t * @endcode + * + * Using this action on non-matching traffic will result in + * 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, }; /** @@ -1592,6 +2168,22 @@ struct rte_flow_query_count { uint64_t bytes; /**< Number of bytes through this rule [out]. */ }; +/** + * Hash function types. + */ +enum rte_eth_hash_function { + RTE_ETH_HASH_FUNCTION_DEFAULT = 0, + RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */ + RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */ + /** + * Symmetric Toeplitz: src, dst will be replaced by + * xor(src, dst). For the case with src/dst only, + * src or dst address will xor with zero pair. + */ + RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ, + RTE_ETH_HASH_FUNCTION_MAX, +}; + /** * RTE_FLOW_ACTION_TYPE_RSS * @@ -1724,6 +2316,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. */ @@ -1868,16 +2465,202 @@ 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_RAW_ENCAP + * + * Raw tunnel end-point encapsulation data definition. + * + * The data holds the headers definitions to be applied on the packet. + * The data must start with ETH header up to the tunnel item header itself. + * When used right after RAW_DECAP (for decapsulating L3 tunnel type for + * example MPLSoGRE) the data will just hold layer 2 header. + * + * The preserve parameter holds which bits in the packet the PMD is not allowed + * to change, this parameter can also be NULL and then the PMD is allowed + * to update any field. + * + * size holds the number of bytes in @p data and @p preserve. + */ +struct rte_flow_action_raw_encap { + uint8_t *data; /**< Encapsulation data. */ + uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */ + size_t size; /**< Size of @p data and @p preserve. */ +}; + +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ACTION_TYPE_RAW_DECAP + * + * Raw tunnel end-point decapsulation data definition. + * + * The data holds the headers definitions to be removed from the packet. + * The data must start with ETH header up to the tunnel item header itself. + * When used right before RAW_DECAP (for encapsulating L3 tunnel type for + * example MPLSoGRE) the data will just hold layer 2 header. + * + * size holds the number of bytes in @p data. + */ +struct rte_flow_action_raw_decap { + uint8_t *data; /**< Encapsulation data. */ + size_t size; /**< Size of @p data and @p preserve. */ +}; + +/** + * @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[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 int 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. * * A list of actions is terminated by a END action. * - * For simple actions without a configuration structure, conf remains NULL. + * For simple actions without a configuration object, conf remains NULL. */ struct rte_flow_action { enum rte_flow_action_type type; /**< Action type. */ - const void *conf; /**< Pointer to action configuration structure. */ + const void *conf; /**< Pointer to action configuration object. */ }; /** @@ -1931,6 +2714,223 @@ struct rte_flow_error { const char *message; /**< Human-readable error message. */ }; +/** + * Complete flow rule description. + * + * This object type is used when converting a flow rule description. + * + * @see RTE_FLOW_CONV_OP_RULE + * @see rte_flow_conv() + */ +RTE_STD_C11 +struct rte_flow_conv_rule { + union { + const struct rte_flow_attr *attr_ro; /**< RO attributes. */ + struct rte_flow_attr *attr; /**< Attributes. */ + }; + union { + const struct rte_flow_item *pattern_ro; /**< RO pattern. */ + struct rte_flow_item *pattern; /**< Pattern items. */ + }; + union { + const struct rte_flow_action *actions_ro; /**< RO actions. */ + struct rte_flow_action *actions; /**< List of actions. */ + }; +}; + +/** + * Conversion operations for flow API objects. + * + * @see rte_flow_conv() + */ +enum rte_flow_conv_op { + /** + * No operation to perform. + * + * rte_flow_conv() simply returns 0. + */ + RTE_FLOW_CONV_OP_NONE, + + /** + * Convert attributes structure. + * + * This is a basic copy of an attributes structure. + * + * - @p src type: + * @code const struct rte_flow_attr * @endcode + * - @p dst type: + * @code struct rte_flow_attr * @endcode + */ + RTE_FLOW_CONV_OP_ATTR, + + /** + * Convert a single item. + * + * Duplicates @p spec, @p last and @p mask but not outside objects. + * + * - @p src type: + * @code const struct rte_flow_item * @endcode + * - @p dst type: + * @code struct rte_flow_item * @endcode + */ + RTE_FLOW_CONV_OP_ITEM, + + /** + * Convert a single action. + * + * Duplicates @p conf but not outside objects. + * + * - @p src type: + * @code const struct rte_flow_action * @endcode + * - @p dst type: + * @code struct rte_flow_action * @endcode + */ + RTE_FLOW_CONV_OP_ACTION, + + /** + * Convert an entire pattern. + * + * Duplicates all pattern items at once with the same constraints as + * RTE_FLOW_CONV_OP_ITEM. + * + * - @p src type: + * @code const struct rte_flow_item * @endcode + * - @p dst type: + * @code struct rte_flow_item * @endcode + */ + RTE_FLOW_CONV_OP_PATTERN, + + /** + * Convert a list of actions. + * + * Duplicates the entire list of actions at once with the same + * constraints as RTE_FLOW_CONV_OP_ACTION. + * + * - @p src type: + * @code const struct rte_flow_action * @endcode + * - @p dst type: + * @code struct rte_flow_action * @endcode + */ + RTE_FLOW_CONV_OP_ACTIONS, + + /** + * Convert a complete flow rule description. + * + * Comprises attributes, pattern and actions together at once with + * the usual constraints. + * + * - @p src type: + * @code const struct rte_flow_conv_rule * @endcode + * - @p dst type: + * @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, +}; + +/** + * @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. * @@ -2162,10 +3162,8 @@ rte_flow_error_set(struct rte_flow_error *error, const char *message); /** - * Generic flow representation. - * - * This form is sufficient to describe an rte_flow independently from any - * PMD implementation and allows for replayability and identification. + * @deprecated + * @see rte_flow_copy() */ struct rte_flow_desc { size_t size; /**< Allocated space including data[]. */ @@ -2176,8 +3174,14 @@ 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(). 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. * @param[in] len @@ -2195,12 +3199,61 @@ 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, const struct rte_flow_item *items, const struct rte_flow_action *actions); +/** + * Flow object conversion helper. + * + * This function performs conversion of various flow API objects to a + * pre-allocated destination buffer. See enum rte_flow_conv_op for possible + * operations and details about each of them. + * + * Since destination buffer must be large enough, it works in a manner + * reminiscent of snprintf(): + * + * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be + * non-NULL. + * - If positive, the returned value represents the number of bytes needed + * to store the conversion of @p src to @p dst according to @p op + * regardless of the @p size parameter. + * - Since no more than @p size bytes can be written to @p dst, output is + * truncated and may be inconsistent when the returned value is larger + * than that. + * - In case of conversion error, a negative error code is returned and + * @p dst contents are unspecified. + * + * @param op + * Operation to perform, related to the object type of @p dst. + * @param[out] dst + * Destination buffer address. Must be suitably aligned by the caller. + * @param size + * Destination buffer size in bytes. + * @param[in] src + * Source object to copy. Depending on @p op, its type may differ from + * that of @p dst. + * @param[out] error + * Perform verbose error reporting if not NULL. Initialized in case of + * error only. + * + * @return + * The number of bytes required to convert @p src to @p dst on success, a + * negative errno value otherwise and rte_errno is set. + * + * @see rte_flow_conv_op + */ +__rte_experimental +int +rte_flow_conv(enum rte_flow_conv_op op, + void *dst, + size_t size, + const void *src, + struct rte_flow_error *error); + #ifdef __cplusplus } #endif