API Reference Manual  1.47.0
api/spec/classification.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2014-2018 Linaro Limited
3  * Copyright (c) 2021-2025 Nokia
4  */
5 
12 #ifndef ODP_API_SPEC_CLASSIFICATION_H_
13 #define ODP_API_SPEC_CLASSIFICATION_H_
14 #include <odp/visibility_begin.h>
15 
17 #include <odp/api/pool_types.h>
18 #include <odp/api/std_types.h>
19 #include <odp/api/threshold.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
68 typedef enum {
72 
80 
83 
90 
97 
104 
107 
110 
117 
120 
123 
126 
129 
132 
135 
138 
141 
144 
147 
156 
165 
168 
171 
174 
177 
180 
183 
191 
194 
196 
202 typedef union odp_cls_pmr_terms_t {
204  struct {
206  uint64_t len:1;
208  uint64_t ethtype_0:1;
210  uint64_t ethtype_x:1;
212  uint64_t vlan_id_0:1;
214  uint64_t vlan_id_x:1;
216  uint64_t vlan_pcp_0:1;
218  uint64_t dmac:1;
220  uint64_t ip_proto:1;
222  uint64_t ip_dscp:1;
224  uint64_t udp_dport:1;
226  uint64_t tcp_dport:1;
228  uint64_t udp_sport:1;
230  uint64_t tcp_sport:1;
232  uint64_t sip_addr:1;
234  uint64_t dip_addr:1;
236  uint64_t sip6_addr:1;
238  uint64_t dip6_addr:1;
240  uint64_t ipsec_spi:1;
242  uint64_t ld_vni:1;
245  uint64_t custom_frame:1;
248  uint64_t custom_l3:1;
250  uint64_t igmp_grp_addr:1;
252  uint64_t icmp_id:1;
254  uint64_t icmp_type:1;
256  uint64_t icmp_code:1;
258  uint64_t sctp_sport:1;
260  uint64_t sctp_dport:1;
262  uint64_t gtpv1_teid:1;
263  } bit;
264 
266  uint64_t all_bits;
267 
269 
278 typedef struct odp_pmr_param_t {
281 
284 
286  union {
288  struct {
293  const void *value;
294 
297  const void *mask;
298  } match;
299 
301  struct {
303  const void *val_start;
304 
306  const void *val_end;
307  } range;
308  };
309 
311  uint32_t val_sz;
312 
319  uint32_t offset;
320 
322 
326 typedef struct odp_pmr_create_opt_t {
333 
336 
343  uint64_t mark;
344 
346 
370 typedef struct odp_red_param_t {
376 
382 
384 
410 typedef struct odp_bp_param_t {
417 
425 
433  uint8_t pfc_level;
434 
436 
443 typedef struct odp_cls_cos_stats_t {
446  uint64_t octets;
447 
450  uint64_t packets;
451 
454  uint64_t discards;
455 
457  uint64_t errors;
458 
460 
467 typedef struct odp_cls_queue_stats_t {
470  uint64_t octets;
471 
473  uint64_t packets;
474 
477  uint64_t discards;
478 
481  uint64_t errors;
482 
484 
490  struct {
492  union {
494  struct {
496  uint64_t octets : 1;
497 
499  uint64_t packets : 1;
500 
502  uint64_t discards : 1;
503 
505  uint64_t errors : 1;
506 
508 
513  uint64_t all_counters;
514  };
515  } cos;
516 
518  struct {
520  union {
522  struct {
524  uint64_t octets : 1;
525 
527  uint64_t packets : 1;
528 
530  uint64_t discards : 1;
531 
533  uint64_t errors : 1;
534 
536 
541  uint64_t all_counters;
542  };
543  } queue;
544 
546 
551  struct {
553  uint64_t ipv4_frag : 1;
554 
556  uint64_t ipv6_frag : 1;
557 
559  uint64_t custom : 1;
560 
562 
564 
569 typedef struct odp_cls_capability_t {
574 
580  uint32_t max_pmr;
581 
583  uint32_t max_pmr_per_cos;
584 
587 
589  uint32_t max_cos;
590 
596  uint32_t max_cos_stats;
597 
601  uint32_t max_hash_queues;
602 
605 
608 
611 
614 
617 
620 
622  uint64_t max_mark;
623 
626 
629 
631 
635 typedef enum {
642 
650 
652 
657 typedef struct odp_cls_cos_param {
670 
677 
690  uint32_t num_queue;
691 
693  union {
698 
701  struct {
704 
708  };
709  };
720 
723 
726 
735 
747 
749 
758 
770 
788 odp_cos_t odp_cls_cos_create(const char *name,
789  const odp_cls_cos_param_t *param);
790 
811 int odp_cls_cos_create_multi(const char *name[],
812  const odp_cls_cos_param_t param[],
813  odp_cos_t cos[], int num);
814 
830 
845 
858 int odp_cos_destroy_multi(odp_cos_t cos[], int num);
859 
874 
885 
894 
906 uint32_t odp_cls_cos_queues(odp_cos_t cos, odp_queue_t queue[], uint32_t num);
907 
926 
947  odp_cls_queue_stats_t *stats);
948 
957 
966 
996 odp_pmr_t odp_cls_pmr_create(const odp_pmr_param_t *terms, int num_terms,
997  odp_cos_t src_cos, odp_cos_t dst_cos);
998 
1017  odp_cos_t src_cos, odp_cos_t dst_cos);
1018 
1039  odp_cos_t src_cos[], odp_cos_t dst_cos[],
1040  odp_pmr_t pmr[], int num);
1041 
1060 
1074 
1090 
1100 
1113 
1126 
1134 
1139 #ifdef __cplusplus
1140 }
1141 #endif
1142 
1143 #include <odp/visibility_end.h>
1144 #endif
ODP Packet IO.
ODP pool.
Standard C language types and definitions for ODP.
int odp_cls_pmr_create_multi(const odp_pmr_create_opt_t opt[], odp_cos_t src_cos[], odp_cos_t dst_cos[], odp_pmr_t pmr[], int num)
Create multiple packet matching rules.
int odp_cls_cos_stats(odp_cos_t cos, odp_cls_cos_stats_t *stats)
Get statistics for a CoS.
uint64_t odp_pmr_to_u64(odp_pmr_t pmr)
Get printable value for an odp_pmr_t.
union odp_cls_pmr_terms_t odp_cls_pmr_terms_t
Supported PMR term values.
struct odp_pmr_param_t odp_pmr_param_t
Packet Matching Rule parameter structure.
struct odp_cls_queue_stats_t odp_cls_queue_stats_t
Classifier queue specific statistics counters.
int odp_cos_queue_set(odp_cos_t cos, odp_queue_t queue)
Assign a queue for a class-of-service.
uint32_t odp_cls_cos_num_queue(odp_cos_t cos)
Get the number of queues linked with the specific class-of-service.
odp_pmr_t odp_cls_pmr_create_opt(const odp_pmr_create_opt_t *opt, odp_cos_t src_cos, odp_cos_t dst_cos)
Create a packet matching rule with options.
int odp_cos_destroy(odp_cos_t cos)
Discard a class-of-service along with all its associated resources.
odp_queue_t odp_cls_hash_result(odp_cos_t cos, odp_packet_t packet)
Queue hash result Returns the queue within a CoS in which a particular packet will be enqueued based ...
void odp_cls_pmr_create_opt_init(odp_pmr_create_opt_t *opt)
Initialize packet matching rule creation option.
struct odp_cls_stats_capability_t odp_cls_stats_capability_t
Classifier statistics capabilities.
odp_pmr_t odp_cls_pmr_create(const odp_pmr_param_t *terms, int num_terms, odp_cos_t src_cos, odp_cos_t dst_cos)
Create Packet Matching Rule (PMR)
int odp_cos_destroy_multi(odp_cos_t cos[], int num)
Destroy multiple class-of-services.
int odp_cls_capability(odp_cls_capability_t *capability)
Query classification capabilities.
struct odp_cls_capability_t odp_cls_capability_t
Classification capabilities This capability structure defines system level classification capability.
uint64_t odp_cos_to_u64(odp_cos_t cos)
Get printable value for an odp_cos_t.
struct odp_bp_param_t odp_bp_param_t
Back pressure (BP)
struct odp_cls_aggr_capability_t odp_cls_aggr_capability_t
Event aggregator related capabilities.
uint32_t odp_cls_cos_queues(odp_cos_t cos, odp_queue_t queue[], uint32_t num)
Get the list of queue associated with the specific class-of-service.
odp_cls_pmr_term_t
Packet Matching Rule terms.
struct odp_red_param_t odp_red_param_t
Random Early Detection (RED) Random Early Detection is enabled to initiate a drop probability for the...
int odp_cls_pmr_destroy_multi(odp_pmr_t pmr[], int num)
Destroy multiple packet matching rules.
int odp_cls_cos_create_multi(const char *name[], const odp_cls_cos_param_t param[], odp_cos_t cos[], int num)
Create multiple class-of-services.
int odp_cls_cos_pool_set(odp_cos_t cos, odp_pool_t pool_id)
Assigns a packet pool for a specific class of service.
struct odp_cls_cos_param odp_cls_cos_param_t
Class of service parameters Used to communicate class of service creation options.
int odp_cls_queue_stats(odp_cos_t cos, odp_queue_t queue, odp_cls_queue_stats_t *stats)
Get statistics for a queue assigned to a CoS.
void odp_cls_print_all(void)
Print classifier info.
int odp_cls_pmr_destroy(odp_pmr_t pmr)
Function to destroy a packet match rule.
odp_cos_action_t
Enumeration of actions for CoS.
odp_cos_t odp_cls_cos_create(const char *name, const odp_cls_cos_param_t *param)
Create a class-of-service.
void odp_cls_cos_param_init(odp_cls_cos_param_t *param)
Initialize class of service parameters.
odp_queue_t odp_cos_queue(odp_cos_t cos)
Get the queue associated with the specific class-of-service.
void odp_cls_pmr_param_init(odp_pmr_param_t *param)
Initialize packet matching rule parameters.
odp_pool_t odp_cls_cos_pool(odp_cos_t cos)
Get the pool associated with the given class of service.
struct odp_pmr_create_opt_t odp_pmr_create_opt_t
Packet Matching Rule creation options.
struct odp_cls_cos_stats_t odp_cls_cos_stats_t
Classifier CoS specific statistics counters.
@ ODP_PMR_IGMP_GRP_ADDR
IGMP Group address (val_sz = 4), implies IPPROTO=2.
@ ODP_PMR_TCP_DPORT
Destination TCP port (val_sz = 2)
@ ODP_PMR_ETHTYPE_0
Initial (outer) Ethertype only (val_sz = 2)
@ ODP_PMR_VLAN_PCP_0
PCP bits in the first (outer) VLAN header (val_sz = 1)
@ ODP_PMR_ICMP_TYPE
ICMP type (val_sz = 1), implies IPPROTO=1.
@ ODP_PMR_SIP_ADDR
Source IPv4 address (val_sz = 4)
@ ODP_PMR_DIP_ADDR
Destination IPv4 address (val_sz = 4)
@ ODP_PMR_SCTP_SPORT
Source SCTP port (val_sz = 2), implies IPPROTO=132.
@ ODP_PMR_TCP_SPORT
Source TCP port (val_sz = 2)
@ ODP_PMR_IPPROTO
IPv4 Protocol or IPv6 Next Header (val_sz = 1)
@ ODP_PMR_LD_VNI
NVGRE/VXLAN network identifier (val_sz = 4)
@ ODP_PMR_VLAN_ID_X
Last (most inner) VLAN ID (val_sz = 2)
@ ODP_PMR_GTPV1_TEID
GTPv1 tunnel endpoint identifier (val_sz = 4)
@ ODP_PMR_DIP6_ADDR
Destination IPv6 address (val_sz = 16)
@ ODP_PMR_SCTP_DPORT
Destination SCTP port (val_sz = 2), implies IPPROTO=132.
@ ODP_PMR_CUSTOM_FRAME
Custom frame match rule.
@ ODP_PMR_IPSEC_SPI
IPsec session identifier (val_sz = 4)
@ ODP_PMR_UDP_SPORT
Source UDP port (val_sz = 2)
@ ODP_PMR_VLAN_ID_0
First (outer) VLAN ID (val_sz = 2)
@ ODP_PMR_ICMP_ID
ICMP identifier (val_sz = 2), implies IPPROTO=1 and ICMP_TYPE=0 or ICMP_TYPE=8.
@ ODP_PMR_ICMP_CODE
ICMP code (val_sz = 1), implies IPPROTO=1.
@ ODP_PMR_UDP_DPORT
Destination UDP port (val_sz = 2)
@ ODP_PMR_LEN
Total length of received packet.
@ ODP_PMR_DMAC
Destination MAC address (val_sz = 6)
@ ODP_PMR_SIP6_ADDR
Source IPv6 address (val_sz = 16)
@ ODP_PMR_ETHTYPE_X
Ethertype of most inner VLAN tag (val_sz = 2)
@ ODP_PMR_INNER_HDR_OFF
Inner header may repeat above values with this offset.
@ ODP_PMR_CUSTOM_L3
Custom layer 3 match rule.
@ ODP_PMR_IP_DSCP
Differentiated Services Code Point (DSCP) bits in IPv4 or IPv6 header (val_sz = 1)
@ ODP_COS_ACTION_DROP
Drop packet.
@ ODP_COS_ACTION_ENQUEUE
Enqueue packet.
bool odp_bool_t
Boolean type.
odp_support_t
ODP support.
Dummy type for strong typing.
Event aggregator enqueuing profile.
Back pressure (BP)
odp_bool_t enable
A boolean to enable Back pressure When true, back pressure is enabled and configured with the BP para...
odp_threshold_t threshold
Threshold value for back pressure.
uint8_t pfc_level
PFC priority level.
Event aggregator related capabilities.
struct odp_cls_aggr_capability_t::@20 enq_profile_type
Supported enqueuing profile types in addition to ODP_AEP_TYPE_NONE, which is always supported.
uint64_t ipv6_frag
IPv6 fragment profile (ODP_AEP_TYPE_IPV6_FRAG)
uint64_t custom
Custom profile (ODP_AEP_TYPE_CUSTOM)
uint64_t ipv4_frag
IPv4 fragment profile (ODP_AEP_TYPE_IPV4_FRAG)
Classification capabilities This capability structure defines system level classification capability.
uint32_t max_pmr
Maximum number of single-term PMRs.
uint64_t max_mark
Maximum value of odp_pmr_create_opt_t::mark.
odp_cls_aggr_capability_t aggr
Event aggregator related capabilities.
uint32_t max_hash_queues
Maximum number of queues supported per CoS.
odp_threshold_types_t threshold_red
Supported threshold type for RED.
odp_support_t back_pressure
Support for Back Pressure to the remote peer.
uint32_t max_terms_per_pmr
Maximum number of terms per composite PMR.
odp_threshold_types_t threshold_bp
Supported threshold type for BP.
odp_cls_pmr_terms_t supported_terms
PMR terms supported by the classifier.
uint32_t max_cos
Maximum number of CoS supported.
odp_support_t random_early_detection
Support for Random Early Detection.
odp_pktin_hash_proto_t hash_protocols
Protocol header combination supported for Hashing.
uint32_t max_cos_stats
Maximum number of concurrent CoS stats.
odp_bool_t pmr_range_supported
A Boolean to denote support of PMR range.
uint32_t max_pmr_per_cos
Maximum number of PMRs per CoS.
odp_cls_stats_capability_t stats
Statistics counters capabilities.
Class of service parameters Used to communicate class of service creation options.
odp_queue_t queue
Mapping used when num_queue = 1, hashing is disabled in this case and application has to configure th...
odp_aggr_enq_profile_t aggr_enq_profile
Event aggregator enqueuing profile.
odp_pool_t pool
Pool associated with CoS.
odp_bool_t stats_enable
Enable statistics.
uint32_t num_queue
Number of queues to be linked to this CoS.
odp_pktin_vector_config_t vector
Packet input vector configuration.
odp_bp_param_t bp
Back Pressure configuration.
odp_queue_param_t queue_param
Queue parameters.
odp_red_param_t red
Random Early Detection configuration.
odp_cos_action_t action
Action to take.
odp_pktin_hash_proto_t hash_proto
Protocol header fields which are included in packet input hash calculation.
Classifier CoS specific statistics counters.
uint64_t errors
Number of packets with errors.
uint64_t octets
Number of octets in classified packets.
uint64_t packets
Number of classified packets, including packets dropped due to drop action.
uint64_t discards
Number of discarded packets due to other reasons than packet errors or drop action.
Classifier queue specific statistics counters.
uint64_t errors
Number of packets with errors.
uint64_t octets
Number of octets in successfully delivered packets.
uint64_t discards
Number of discarded packets due to other reasons (e.g.
uint64_t packets
Number of successfully delivered packets.
Classifier statistics capabilities.
struct odp_cls_stats_capability_t::@13 queue
Queue level capabilities.
uint64_t discards
See odp_cls_cos_stats_t::discards.
uint64_t errors
See odp_cls_cos_stats_t::errors.
struct odp_cls_stats_capability_t::@12::@14::@16 counter
Statistics counters in a bit field structure.
struct odp_cls_stats_capability_t::@12 cos
CoS level capabilities.
uint64_t packets
See odp_cls_cos_stats_t::packets.
uint64_t octets
See odp_cls_cos_stats_t::octets.
uint64_t all_counters
All bits of the bit field structure.
Packet input vector configuration.
Packet Matching Rule creation options.
uint64_t mark
Classification mark value.
int num_terms
Number of terms in the match rule.
odp_pmr_param_t * terms
PMR terms.
Packet Matching Rule parameter structure.
const void * val_start
Start value of the range.
uint32_t offset
Offset to the value.
uint32_t val_sz
Size of the value to be matched.
struct odp_pmr_param_t::@8::@10 match
Parameters for single-valued matches.
const void * value
Points to the value to be matched.
odp_bool_t range_term
True if the value is range and false if match.
const void * mask
Mask of the bits to be matched.
odp_cls_pmr_term_t term
Packet Matching Rule term.
const void * val_end
End value of the range.
struct odp_pmr_param_t::@8::@11 range
Parameter for range value matches.
ODP Queue parameters.
Random Early Detection (RED) Random Early Detection is enabled to initiate a drop probability for the...
odp_threshold_t threshold
Threshold parameters for RED RED is enabled when the resource usage is equal to or greater than the m...
odp_bool_t enable
A boolean to enable RED When true, RED is enabled and configured with RED parameters.
ODP Threshold.
ODP threshold API - platform specific header.
Supported PMR term values.
uint64_t vlan_pcp_0
PCP in the first VLAN header (ODP_PMR_VLAN_PCP_0)
uint64_t dip_addr
Destination IP address.
uint64_t udp_dport
Destination UDP port, implies IPPROTO=17.
uint64_t dmac
destination MAC address
uint64_t tcp_dport
Destination TCP port implies IPPROTO=6.
uint64_t ld_vni
NVGRE/VXLAN network identifier.
uint64_t sip_addr
Source IP address.
uint64_t icmp_id
ICMP identifier, implies IPPROTO=1 and ICMP_TYPE=0 or ICMP_TYPE=8.
uint64_t igmp_grp_addr
IGMP Group address, implies IPPROTO=2.
uint64_t ipsec_spi
IPsec session identifier.
uint64_t vlan_id_0
First VLAN ID (outer)
uint64_t custom_l3
Custom layer 3 match rule.
uint64_t custom_frame
Custom frame match rule.
uint64_t ethtype_0
Initial (outer) Ethertype only.
uint64_t udp_sport
Source UDP Port.
uint64_t sip6_addr
Source IP address.
uint64_t ip_proto
IP Protocol or IPv6 Next Header.
uint64_t dip6_addr
Destination IP address.
uint64_t ethtype_x
Ethertype of most inner VLAN tag.
uint64_t ip_dscp
DSCP in IP header (ODP_PMR_IP_DSCP)
uint64_t icmp_type
ICMP type, implies IPPROTO=1.
uint64_t all_bits
All bits of the bit field structure.
uint64_t sctp_sport
Source SCTP port, implies IPPROTO=132.
uint64_t tcp_sport
Source TCP port.
struct odp_cls_pmr_terms_t::@7 bit
Packet Matching Rule term fields.
uint64_t icmp_code
ICMP code, implies IPPROTO=1.
uint64_t vlan_id_x
Last VLAN ID (inner)
uint64_t sctp_dport
Destination SCTP port, implies IPPROTO=132.
uint64_t gtpv1_teid
GTPv1 tunnel endpoint identifier.
uint64_t len
Total length of received packet.
Packet input hash protocols.
Supported threshold types.