openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

bregex.h (30566B)


      1 /*
      2  * 
      3  * 
      4  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      5  * 
      6  * Copyright 2007-2020 Broadcom Inc. All rights reserved.
      7  * 
      8  * DO NOT EDIT THIS FILE!
      9  * This file is auto-generated.
     10  * Edits to this file will be lost when it is regenerated.
     11  */
     12 
     13 #ifndef __BCM_BREGEX_H__
     14 #define __BCM_BREGEX_H__
     15 
     16 #if defined(INCLUDE_REGEX)
     17 
     18 #include <bcm/types.h>
     19 #include <bcm/field.h>
     20 
     21 #ifndef BCM_HIDE_DISPATCHABLE
     22 
     23 /* Initialize BCM regex module. */
     24 extern int bcm_regex_init(
     25     int unit);
     26 
     27 #endif /* BCM_HIDE_DISPATCHABLE */
     28 
     29 /* Regex Configuration structure. */
     30 typedef struct bcm_regex_config_s {
     31     uint32 flags;                   /* Flags for Regex configuration. */
     32     int max_flows;                  /* maximum number of flows to be tracked. */
     33     int payload_depth;              /* Maximum payload length to be inspected. */
     34     int inspect_num_pkt;            /* maximum number of packets to be inspected
     35                                        per flow. */
     36     int inactivity_timeout_usec;    /* Inactivity timeout. */
     37     bcm_mac_t dst_mac;              /* Destination MAC address */
     38     bcm_mac_t src_mac;              /* Source MAC address */
     39     uint16 ethertype;               /* Ethertype */
     40     uint32 report_flags;            /* Bitmap of report types enabled. */
     41     uint32 report_buffer_size;      /* The number of entries which the report
     42                                        buffer can hold. */
     43 } bcm_regex_config_t;
     44 
     45 #define BCM_REGEX_CONFIG_ENABLE             0x0001     /* Enable Regex feature */
     46 #define BCM_REGEX_CONFIG_TCP_SESSION_DETECT 0x0002     /* Enable TCP session
     47                                                           termination */
     48 #define BCM_REGEX_CONFIG_IP4                0x0004     /* Enable tracking on
     49                                                           IPv4 packets */
     50 #define BCM_REGEX_CONFIG_IP6                0x0008     /* Enable tracking on
     51                                                           IPv6 packets */
     52 #define BCM_REGEX_CONFIG_AGING              0x0010     /* Enable aging on
     53                                                           tracked flows */
     54 #define BCM_REGEX_COUNTER_ENABLE            0x0020     /* Enable counter and
     55                                                           statistics */
     56 #define BCM_REGEX_PER_DIRECTION_COUNTER_ENABLE 0x0040     /* Enable counter and
     57                                                           statistics per
     58                                                           direction */
     59 #define BCM_REGEX_USE_POLICY_ID             0x0080     /* Use only actions in
     60                                                           the referenced policy */
     61 
     62 #define BCM_REGEX_REPORT_NEW        0x0001     /* Enable report generation for
     63                                                   new flows */
     64 #define BCM_REGEX_REPORT_MATCHED    0x0002     /* Enable report generation for
     65                                                   flows that matched pattern */
     66 #define BCM_REGEX_REPORT_END        0x0004     /* Enable report generation when
     67                                                   flow is retired */
     68 #define BCM_REGEX_REPORT_ALL        0x0008     /* Enable generation of all
     69                                                   reports */
     70 
     71 /*  bcm_regex_config_t_init */
     72 extern void bcm_regex_config_t_init(
     73     bcm_regex_config_t *config);
     74 
     75 #ifndef BCM_HIDE_DISPATCHABLE
     76 
     77 /*  Set configuration for Regex module. */
     78 extern int bcm_regex_config_set(
     79     int unit, 
     80     bcm_regex_config_t *config);
     81 
     82 /*  Get configuration for Regex module. */
     83 extern int bcm_regex_config_get(
     84     int unit, 
     85     bcm_regex_config_t *config);
     86 
     87 /* Add a range of L4 ports to be excluded from flow tracking. */
     88 extern int bcm_regex_exclude_add(
     89     int unit, 
     90     uint8 protocol, 
     91     uint16 l4_start, 
     92     uint16 l4_end);
     93 
     94 /* Delete L4 ports range excluded from flow tracking. */
     95 extern int bcm_regex_exclude_delete(
     96     int unit, 
     97     uint8 protocol, 
     98     uint16 l4_start, 
     99     uint16 l4_end);
    100 
    101 /* Delete all L4 ports excluded from flow tracking. */
    102 extern int bcm_regex_exclude_delete_all(
    103     int unit);
    104 
    105 /* Delete L4 ports range excluded from flow tracking. */
    106 extern int bcm_regex_exclude_get(
    107     int unit, 
    108     int array_size, 
    109     uint8 *protocol, 
    110     uint16 *l4low, 
    111     uint16 *l4high, 
    112     int *array_count);
    113 
    114 #endif /* BCM_HIDE_DISPATCHABLE */
    115 
    116 /* bcm_regex_engine_t */
    117 typedef int bcm_regex_engine_t;
    118 
    119 /* Regex Engine Configuration structure. */
    120 typedef struct bcm_regex_engine_config_s {
    121     uint32 flags;   /* Flags for Regex configuration. */
    122 } bcm_regex_engine_config_t;
    123 
    124 #define BCM_REGEX_ENGINE_CONFIG_MULTI_PACKET 0x0001     /* Match pattern across
    125                                                           packet boundary */
    126 
    127 /*  bcm_regex_engine_config_t_init */
    128 extern void bcm_regex_engine_config_t_init(
    129     bcm_regex_engine_config_t *config);
    130 
    131 #ifndef BCM_HIDE_DISPATCHABLE
    132 
    133 /* Create regex engine. */
    134 extern int bcm_regex_engine_create(
    135     int unit, 
    136     bcm_regex_engine_config_t *config, 
    137     bcm_regex_engine_t *engid);
    138 
    139 /* destroy regex engine. */
    140 extern int bcm_regex_engine_destroy(
    141     int unit, 
    142     bcm_regex_engine_t engid);
    143 
    144 #endif /* BCM_HIDE_DISPATCHABLE */
    145 
    146 /*  Prototype for regex engine traverse callback. */
    147 typedef int (*bcm_regex_engine_traverse_cb)(
    148     int unit, 
    149     bcm_regex_engine_t engine, 
    150     bcm_regex_engine_config_t *config, 
    151     void *user_data);
    152 
    153 #ifndef BCM_HIDE_DISPATCHABLE
    154 
    155 /* Traverse regex engines. */
    156 extern int bcm_regex_engine_traverse(
    157     int unit, 
    158     bcm_regex_engine_traverse_cb cb, 
    159     void *user_data);
    160 
    161 /* Get regex engine configuration. */
    162 extern int bcm_regex_engine_get(
    163     int unit, 
    164     bcm_regex_engine_t engid, 
    165     bcm_regex_engine_config_t *config);
    166 
    167 #endif /* BCM_HIDE_DISPATCHABLE */
    168 
    169 #define BCM_REGEX_MAX_PATTERN_SIZE  256        
    170 
    171 /* Policy identifier */
    172 typedef int bcm_regex_policy_t;
    173 
    174 /* Regex Configuration structure. */
    175 typedef struct bcm_regex_match_s {
    176     uint32 flags;                       /* Flags for Regex match. */
    177     int match_id;                       /* User specified match object
    178                                            identifier */
    179     char pattern[BCM_REGEX_MAX_PATTERN_SIZE]; /* Regex Pattern. */
    180     int sequence;                       /* first packet (0), any packet
    181                                            (non-zero). */
    182     int payload_length_max;             /* Check payload length of the match
    183                                            packet is less than this. */
    184     int payload_length_min;             /* Check payload length of the match
    185                                            packet is greater than this. */
    186     uint16 l4_src_port_low;             /* L4 port value to qualify source port
    187                                            range. */
    188     uint16 l4_src_port_high;            /* L4 port value to qualify source port
    189                                            range. */
    190     uint16 l4_dst_port_low;             /* L4 port value to qualify destination
    191                                            port range. */
    192     uint16 l4_dst_port_high;            /* L4 port value to qualify destination
    193                                            port range. */
    194     uint16 priority;                    /* priority for match. */
    195     int provides;                       /* Identifier of this match object in
    196                                            link list */
    197     int requires;                       /* Identifier of the next match object
    198                                            in chain */
    199     int inactivity_timeout_usec;        /* timeout value in microsec */
    200     uint32 action_flags;                /* action flags for Regex match. */
    201     int new_int_pri;                    /* Assign new internal priority to
    202                                            packets */
    203     int new_dscp;                       /* reassign DSCP value */
    204     int new_pkt_pri;                    /* reassign new .1x priority */
    205     int policer_id;                     /* meter using the specified policer id */
    206     int sig_id;                         /* The signature ID assigned by the SDK */
    207     bcm_regex_policy_t policy_id;       /* The ID of the policy to be used if
    208                                            BCM_REGEX_USE_POLICY_ID is
    209                                            configured. */
    210 } bcm_regex_match_t;
    211 
    212 /*  bcm_regex_engine_config_t_init */
    213 extern void bcm_regex_match_t_init(
    214     bcm_regex_match_t *match);
    215 
    216 #ifndef BCM_HIDE_DISPATCHABLE
    217 
    218 /* check Regex match objects. */
    219 extern int bcm_regex_match_check(
    220     int unit, 
    221     bcm_regex_match_t *matches, 
    222     int count, 
    223     int *metric);
    224 
    225 /* Add Regex match objects to engine. */
    226 extern int bcm_regex_match_set(
    227     int unit, 
    228     bcm_regex_engine_t engid, 
    229     bcm_regex_match_t *matches, 
    230     int count);
    231 
    232 #endif /* BCM_HIDE_DISPATCHABLE */
    233 
    234 #define BCM_REGEX_MATCH_TO_SERVER           0x00000001 
    235 #define BCM_REGEX_MATCH_TO_CLIENT           0x00000002 
    236 #define BCM_REGEX_MATCH_MULTI_FLOW          0x00000004 /* HTTP Persistent Flow */
    237 #define BCM_REGEX_MATCH_CASE_INSENSITIVE    0x00000008 
    238 #define BCM_REGEX_MATCH_L4_SRC_PORT         0x00000010 
    239 #define BCM_REGEX_MATCH_L4_DST_PORT         0x00000020 
    240 #define BCM_REGEX_MATCH_PKT_SEQUENCE        0x00000040 /* Qualify match only if
    241                                                           packets are received
    242                                                           without error in
    243                                                           sequence */
    244 #define BCM_REGEX_MATCH_SIG_ID_RETURN       0x00000080 /* Set if the hardware
    245                                                           signature ID
    246                                                           corresponding to the
    247                                                           Match ID is to be
    248                                                           returned */
    249 
    250 #define BCM_REGEX_MATCH_ACTION_IGNORE       0x00000001 /* Deprecated, use
    251                                                           separate policy API */
    252 #define BCM_REGEX_MATCH_ACTION_DROP         0x00000002 /* Deprecated, use
    253                                                           separate policy API */
    254 #define BCM_REGEX_MATCH_ACTION_COPY_TO_CPU  0x00000004 /* Deprecated, use
    255                                                           separate policy API */
    256 #define BCM_REGEX_MATCH_ACTION_INT_PRI      0x00000008 /* Deprecated, use
    257                                                           separate policy API */
    258 #define BCM_REGEX_MATCH_ACTION_DSCP         0x00000010 /* Deprecated, use
    259                                                           separate policy API */
    260 #define BCM_REGEX_MATCH_ACTION_PKT_PRI      0x00000020 /* Deprecated, use
    261                                                           separate policy API */
    262 #define BCM_REGEX_MATCH_ACTION_NON_POLICY_ACTIONS 0x0000003F /* Used to check for
    263                                                           deprecated actions */
    264 #define BCM_REGEX_MATCH_ACTION_NOTIFY_HEADER_ONLY 0x00000040 
    265 #define BCM_REGEX_MATCH_ACTION_NOTIFY_COPY_TO_CPU 0x00000080 
    266 
    267 /* Flow Tracker's Flow End Reasons. */
    268 typedef enum bcm_regex_flow_end_reason_e {
    269     bcmRegexFlowEndReasonFirst = 0,     /* Beginning of Flow End Reason */
    270     bcmRegexFlowEndReasonTcpAgeout = 0, /* Flow session ended because of age out */
    271     bcmRegexFlowEndReasonTcpFINr = 1,   /* Flow session ended because TCP FIN
    272                                            received in reverse direction */
    273     bcmRegexFlowEndReasonTcpFINf = 2,   /* Flow session ended because TCP FIN
    274                                            received in forward direction */
    275     bcmRegexFlowEndReasonTcpReset = 3,  /* Flow session ended because TCP RESET
    276                                            received in either direction */
    277     bcmRegexFlowEndReasonCount = 3      /* End of list */
    278 } bcm_regex_flow_end_reason_t;
    279 
    280 /* Regex report structure. */
    281 typedef struct bcm_regex_report_s {
    282     int match_id;                       /* Match identifier. */
    283     uint32 flags;                       /* flags. */
    284     bcm_ip_t sip;                       /* Source IPV4 address. */
    285     bcm_ip_t dip;                       /* destination IPV4 address. */
    286     bcm_ip6_t sip6;                     /* Source IPV6 address. */
    287     uint8 protocol;                     /* IP protocol */
    288     bcm_regex_flow_end_reason_t flow_end_reason; /* FT flow end reason */
    289     bcm_ip6_t dip6;                     /* destination IPV6 address. */
    290     uint32 dst_port;                    /* L4 dst port. */
    291     uint32 src_port;                    /* L4 src port */
    292     uint32 match_flags;                 /* match flags. */
    293     uint64 packet_count;                /* Packet count. */
    294     uint64 byte_count;                  /* byte count. */
    295     uint64 packet_count_to_server;      /* Packet count to server. */
    296     uint64 byte_count_to_server;        /* byte count to server . */
    297     uint64 packet_count_to_client;      /* Packet count to client. */
    298     uint64 byte_count_to_client;        /* byte count to client . */
    299     uint32 start_timestamp;             /* Session start timestamp (10ms
    300                                            granularity) */
    301     uint32 last_timestamp;              /* Session last packet timestamp (10ms
    302                                            granularity). */
    303     uint32 refresh_timestamp;           /* Session refresh packet timestamp
    304                                            (10ms granularity). */
    305 } bcm_regex_report_t;
    306 
    307 /*  bcm_regex_engine_config_t_init */
    308 extern void bcm_regex_report_t_init(
    309     bcm_regex_report_t *match);
    310 
    311 /*  Prototype for user provided report callback. */
    312 typedef void (*bcm_regex_report_cb)(
    313     int unit, 
    314     bcm_regex_report_t *report, 
    315     void *user_data);
    316 
    317 #ifndef BCM_HIDE_DISPATCHABLE
    318 
    319 /* register user provided callback for regex report. */
    320 extern int bcm_regex_report_register(
    321     int unit, 
    322     uint32 reports, 
    323     bcm_regex_report_cb callback, 
    324     void *user_data);
    325 
    326 /* Unregister user provided callback for regex report. */
    327 extern int bcm_regex_report_unregister(
    328     int unit, 
    329     uint32 reports, 
    330     bcm_regex_report_cb callback, 
    331     void *user_data);
    332 
    333 /* Return user-provided Match ID for a created signature ID. */
    334 extern int bcm_regex_get_match_id(
    335     int unit, 
    336     int signature_id, 
    337     int *match_id);
    338 
    339 /* Return hardware Signature ID for a user provided Match ID. */
    340 extern int bcm_regex_get_sig_id(
    341     int unit, 
    342     int match_id, 
    343     int *signature_id);
    344 
    345 #endif /* BCM_HIDE_DISPATCHABLE */
    346 
    347 /* Regex engine info structure. */
    348 typedef struct bcm_regex_engine_info_s {
    349     int size;       /* Static size of largest memory that a single engine (or
    350                        SME) can use. */
    351     int free_size;  /* Available free memory on the specified engine, or on all
    352                        engines. */
    353 } bcm_regex_engine_info_t;
    354 
    355 #define BCM_REGEX_ENGINE_ALL    -1         
    356 
    357 #ifndef BCM_HIDE_DISPATCHABLE
    358 
    359 /* Return information about the Signature Matching Engine. */
    360 extern int bcm_regex_engine_info_get(
    361     int unit, 
    362     int engine_id, 
    363     bcm_regex_engine_info_t *regex_engine_info);
    364 
    365 #endif /* BCM_HIDE_DISPATCHABLE */
    366 
    367 /* Regex session info structure. */
    368 typedef struct bcm_regex_info_s {
    369     int session_size;           /* Static size of entire Flow Tracker session
    370                                    table. */
    371     int session_free_size_ipv4; /* Total free memory for IPv4 sessions available
    372                                    in the FT. */
    373     int session_free_size_ipv6; /* Total free memory for IPv6 sessions available
    374                                    in the FT. */
    375     int policy_size;            /* Static size of entire Flow Tracker policy
    376                                    table. */
    377     int policy_free_size;       /* Total free size of Flow Tracker policy table. */
    378 } bcm_regex_info_t;
    379 
    380 #ifndef BCM_HIDE_DISPATCHABLE
    381 
    382 /* Return various info about the Flow Tracker Session and Policy tables. */
    383 extern int bcm_regex_info_get(
    384     int unit, 
    385     bcm_regex_info_t *regex_info);
    386 
    387 #endif /* BCM_HIDE_DISPATCHABLE */
    388 
    389 /* Flow Tracker global statistics. */
    390 typedef enum bcm_regex_stat_e {
    391     bcmStatRegexSessionFirst = 0,       /* Beginning of Session part of list */
    392     bcmStatRegexSessionEntriesInUse = 0, /* 32-bit counter, Current number of
    393                                            session entries in use */
    394     bcmStatRegexSessionFlowsCreated = 1, /* 32-bit counter, Cumulative number of
    395                                            flows created in flow tracker session
    396                                            table */
    397     bcmStatRegexSessionMaxFlowsInUse = 2, /* 32-bit counter, Maximum number of
    398                                            flows in use, high watermark */
    399     bcmStatRegexSessionFlowsMissedTCP = 3, /* 32-bit counter, Cumulative number of
    400                                            TCP flows that could not be inserted
    401                                            because of bucket full */
    402     bcmStatRegexSessionFlowsMissedUDP = 4, /* 32-bit counter, Cumulative number of
    403                                            UDP flows that could not be inserted
    404                                            because of bucket full */
    405     bcmStatRegexSessionCmdWaitTimeouts = 5, /* 32-bit counter, Number of flows for
    406                                            which no results packet was received */
    407     bcmStatRegexSessionUnusedResults = 6, /* 32-bit counter, Number of results
    408                                            packets that were ignored */
    409     bcmStatRegexSessionSuppressedActions = 7, /* 32-bit counter, Number of flows
    410                                            created where actions inhibited by
    411                                            VFP */
    412     bcmStatRegexSessionTcpSynData = 8,  /* 32-bit counter, Number of flows
    413                                            created with TCP SYN data */
    414     bcmStatRegexSessionL4Invalid = 9,   /* 32-bit counter, Number of packets
    415                                            seen where L4 offset/length could not
    416                                            be determined */
    417     bcmStatRegexSessionL4PortsExcluded = 10, /* 32-bit counter, Number of flows not
    418                                            created because of L4Port Table
    419                                            exclusion */
    420     bcmStatRegexSessionLast = 10,       /* End of Session part of list */
    421     bcmStatRegexSigMatchFirst = 21,     /* Beginning of SigMatch part of list */
    422     bcmStatRegexSigMatchPacketsReceived = 21, /* 32-bit counter, Number of packets
    423                                            received by the Signature Match for
    424                                            inspection */
    425     bcmStatRegexSigMatchPacketsSent = 22, /* 32-bit counter, Number of packets
    426                                            sent by Signature Match for reporting
    427                                            to the Flow Tracker */
    428     bcmStatRegexSigMatchPacketsDropped = 23, /* 32-bit counter, Total number of
    429                                            packets dropped without match
    430                                            processing */
    431     bcmStatRegexSigMatchBytesMatched = 24, /* 32-bit counter, Number of L4 payload
    432                                            bytes processed by the regex engines */
    433     bcmStatRegexSigMatchMatchedFlows = 25, /* 32-bit counter, Number of flows that
    434                                            were successfully matched */
    435     bcmStatRegexSigMatchUnmatchedFlows = 26, /* 32-bit counter, Number of flows that
    436                                            were not successfully matches */
    437     bcmStatRegexSigMatchTotalMatch = 27, /* 32-bit counter, Number of matches
    438                                            successfully detected by the Regex
    439                                            engines (includes unreported matches) */
    440     bcmStatRegexSigMatchCrossSigFlags = 28, /* 32-bit counter, Number of updates to
    441                                            cross-signature flags */
    442     bcmStatRegexSigMatchFragmentsReceived = 29, /* 32-bit counter, Number of fragmented
    443                                            packets received */
    444     bcmStatRegexSigMatchInPacketError = 30, /* 32-bit counter, Number of packets
    445                                            dropped for incorrect framing signals
    446                                            (SOP, EOP) or error signal asserted
    447                                            anywhere in the packet */
    448     bcmStatRegexSigMatchFlowTrackerError = 31, /* 32-bit counter, Number of packets
    449                                            dropped because the FT indicated an
    450                                            error in a queued packet before EOP */
    451     bcmStatRegexSigMatchPacketLengthError = 32, /* 32-bit counter, Number of packets
    452                                            dropped because of a length error */
    453     bcmStatRegexSigMatchL4ChecksumError = 33, /* 32-bit counter, Number of packets
    454                                            dropped because of an invalid L4
    455                                            (TCP/UDP) checksum */
    456     bcmStatRegexSigMatchFlowDonePacketDrop = 34, /* 32-bit counter, Number of flows that
    457                                            encountered an invalid Flow Table
    458                                            entry error */
    459     bcmStatRegexSigMatchFlowTimestampError = 35, /* 32-bit counter, Number of packets
    460                                            with timestamp errors -- the first
    461                                            packet of the current flow was lost */
    462     bcmStatRegexSigMatchFlowPacketNumError = 36, /* 32-bit counter, Number of flows that
    463                                            encountered an FT packet number
    464                                            mismatch */
    465     bcmStatRegexSigMatchECCError = 37,  /* 32-bit counter, Number of
    466                                            uncorrectable ECC errors detected */
    467     bcmStatRegexSigMatchLast = 37,      /* End of SigMatch part of list */
    468     bcmStatRegexLast = 37,              /* End of list */
    469     bcmStatRegexCount = 27              /* Number of unique enums in the list */
    470 } bcm_regex_stat_t;
    471 
    472 #ifndef BCM_HIDE_DISPATCHABLE
    473 
    474 /* Retrieve a specified regex Flow Tracker statistic. */
    475 extern int bcm_regex_stat_get(
    476     int unit, 
    477     bcm_regex_stat_t type, 
    478     uint64 *val);
    479 
    480 /* Set a specified regex Flow Tracker statistic. */
    481 extern int bcm_regex_stat_set(
    482     int unit, 
    483     bcm_regex_stat_t type, 
    484     uint64 val);
    485 
    486 #endif /* BCM_HIDE_DISPATCHABLE */
    487 
    488 #define BCM_REGEX_POLICY_WITH_ID    0x0001     /* Create policy with supplied ID */
    489 
    490 #ifndef BCM_HIDE_DISPATCHABLE
    491 
    492 /* Create a blank regex policy. */
    493 extern int bcm_regex_policy_create(
    494     int unit, 
    495     int flags, 
    496     bcm_regex_policy_t *policy);
    497 
    498 /* Destroy a regex policy. This deallocates memory only. */
    499 extern int bcm_regex_policy_destroy(
    500     int unit, 
    501     bcm_regex_policy_t policy);
    502 
    503 /* Destroy all regex policy entries. */
    504 extern int bcm_regex_policy_destroy_all(
    505     int unit);
    506 
    507 /* Install a regex policy into the hardware tables. */
    508 extern int bcm_regex_policy_install(
    509     int unit, 
    510     bcm_regex_policy_t policy);
    511 
    512 /* Remove a regex policy from the hardware tables. */
    513 extern int bcm_regex_policy_remove(
    514     int unit, 
    515     bcm_regex_policy_t policy);
    516 
    517 /* Add an action to a regex policy. */
    518 extern int bcm_regex_policy_action_add(
    519     int unit, 
    520     bcm_regex_policy_t policy, 
    521     bcm_field_action_t action, 
    522     uint32 param0, 
    523     uint32 param1);
    524 
    525 /* Add an action to a policy. */
    526 extern int bcm_regex_policy_action_mac_add(
    527     int unit, 
    528     bcm_regex_policy_t policy, 
    529     bcm_field_action_t action, 
    530     bcm_mac_t mac);
    531 
    532 /* Add an action to a regex policy. */
    533 extern int bcm_regex_policy_action_ports_add(
    534     int unit, 
    535     bcm_regex_policy_t policy, 
    536     bcm_field_action_t action, 
    537     bcm_pbmp_t pbmp);
    538 
    539 /* Delete an action from a regex policy. */
    540 extern int bcm_regex_policy_action_delete(
    541     int unit, 
    542     bcm_regex_policy_t policy, 
    543     bcm_field_action_t action, 
    544     uint32 param0, 
    545     uint32 param1);
    546 
    547 /* 
    548  * Retrieve the parameters for an action previously added to a regex
    549  * policy.
    550  */
    551 extern int bcm_regex_policy_action_get(
    552     int unit, 
    553     bcm_regex_policy_t policy, 
    554     bcm_field_action_t action, 
    555     uint32 *param0, 
    556     uint32 *param1);
    557 
    558 /* 
    559  * Retrieve the parameters for an action previously added to a regex
    560  * policy.
    561  */
    562 extern int bcm_regex_policy_action_mac_get(
    563     int unit, 
    564     bcm_regex_policy_t policy, 
    565     bcm_field_action_t action, 
    566     bcm_mac_t *mac);
    567 
    568 /* 
    569  * Retrieve the parameters for an action previously added to a regex
    570  * policy.
    571  */
    572 extern int bcm_regex_policy_action_ports_get(
    573     int unit, 
    574     bcm_regex_policy_t policy, 
    575     bcm_field_action_t action, 
    576     bcm_pbmp_t *pbmp);
    577 
    578 /* 
    579  * Remove an action from a regex_policy.  Same as
    580  * bcm_regex_policy_action_delete for actions without parameters.
    581  */
    582 extern int bcm_regex_policy_action_remove(
    583     int unit, 
    584     bcm_regex_policy_t policy, 
    585     bcm_field_action_t action);
    586 
    587 /* Remove all actions from a regex_policy. */
    588 extern int bcm_regex_policy_action_remove_all(
    589     int unit, 
    590     bcm_regex_policy_t policy);
    591 
    592 /* Attach a policer to a regex policy. */
    593 extern int bcm_regex_policy_policer_attach(
    594     int unit, 
    595     bcm_regex_policy_t policy, 
    596     int level, 
    597     bcm_policer_t policer_id);
    598 
    599 /* Detach a policer from a regex policy. */
    600 extern int bcm_regex_policy_policer_detach(
    601     int unit, 
    602     bcm_regex_policy_t policy, 
    603     int level);
    604 
    605 /* Detach all policers from a regex policy. */
    606 extern int bcm_regex_policy_policer_detach_all(
    607     int unit, 
    608     bcm_regex_policy_t policy);
    609 
    610 /* Get the policer(s) attached to a regex policy. */
    611 extern int bcm_regex_policy_policer_get(
    612     int unit, 
    613     bcm_regex_policy_t policy, 
    614     int level, 
    615     bcm_policer_t *policer_id);
    616 
    617 #endif /* BCM_HIDE_DISPATCHABLE */
    618 
    619 #define BCM_REGEX_STAT_WITH_ID  0x0001     /* Create stat with supplied ID */
    620 
    621 #ifndef BCM_HIDE_DISPATCHABLE
    622 
    623 /* Create stat collection entity. */
    624 extern int bcm_regex_stat_create(
    625     int unit, 
    626     int flags, 
    627     int nstat, 
    628     bcm_field_stat_t *stat_arr, 
    629     int *stat_id);
    630 
    631 /* Create stat collection entity. */
    632 extern int bcm_regex_stat_destroy(
    633     int unit, 
    634     int stat_id);
    635 
    636 /* Attach statistics entity to Regex policy. */
    637 extern int bcm_regex_policy_stat_attach(
    638     int unit, 
    639     bcm_regex_policy_t policy, 
    640     int stat_id);
    641 
    642 /* Detach statistics entity from Regex policy. */
    643 extern int bcm_regex_policy_stat_detach(
    644     int unit, 
    645     bcm_regex_policy_t policy, 
    646     int stat_id);
    647 
    648 /* Get 64 bit counter value for specific statistic type. */
    649 extern int bcm_regex_policy_stat_get(
    650     int unit, 
    651     bcm_regex_policy_t policy, 
    652     int *stat_id);
    653 
    654 #endif /* BCM_HIDE_DISPATCHABLE */
    655 
    656 #define BCM_REGEX_SESSION_KEY_IPV6      0x0001     /* Key is IPv6.  If not set,
    657                                                       key is IPV4. */
    658 #define BCM_REGEX_SESSION_KEY_REPLACE   0x0002     /* If key found in table when
    659                                                       adding, replace entry. */
    660 
    661 /* Regex session key structure. */
    662 typedef struct bcm_regex_session_key_s {
    663     int flags;          /* REGEX_SESSION_KEY_xxx flags */
    664     bcm_ip_t sip;       /* Source IPV4 address. */
    665     bcm_ip_t dip;       /* Destination IPV4 address. */
    666     bcm_ip6_t sip6;     /* Source IPV6 address. */
    667     bcm_ip6_t dip6;     /* Destination IPV6 address. */
    668     uint32 dst_port;    /* L4 destination port */
    669     uint32 src_port;    /* L4 source port */
    670     uint8 protocol;     /* IP protocol. */
    671 } bcm_regex_session_key_t;
    672 
    673 #define BCM_REGEX_SESSION_STATIC    0x0001     /* Will either convert an
    674                                                   existing dynamic session to
    675                                                   static or create a new static
    676                                                   session. If this flag is not
    677                                                   set, the session is assumed to
    678                                                   be dynamic and will only be
    679                                                   updated if it already exists. */
    680 
    681 /* Regex Configuration structure. */
    682 typedef struct bcm_regex_session_s {
    683     int flags;                  /* REGEX_SESSION_xxx flags */
    684     bcm_regex_policy_t policy;  /* The policy to apply to this flow. */
    685     uint32 inactivity_timeout;  /* Units are usec. */
    686     uint32 timestamp;           /* Output - session entry's timestamp. */
    687 } bcm_regex_session_t;
    688 
    689 /* Initialize regex session key structure. */
    690 extern void bcm_regex_session_key_t_init(
    691     bcm_regex_session_key_t *session_key);
    692 
    693 /* Initialize regex session structure. */
    694 extern void bcm_regex_session_t_init(
    695     bcm_regex_session_t *session);
    696 
    697 #ifndef BCM_HIDE_DISPATCHABLE
    698 
    699 /* 
    700  * Adds or updates a session entry. Flags param for future use, values
    701  * 0x1-0x8 reserved.
    702  */
    703 extern int bcm_regex_session_add(
    704     int unit, 
    705     int flags, 
    706     bcm_regex_session_key_t *key, 
    707     bcm_regex_session_t *session);
    708 
    709 /* Updates the policy ID in a session entry. */
    710 extern int bcm_regex_session_policy_update(
    711     int unit, 
    712     int flags, 
    713     int flow_index, 
    714     bcm_regex_policy_t policy);
    715 
    716 /* Deletes an entry from the regex session table. */
    717 extern int bcm_regex_session_delete(
    718     int unit, 
    719     bcm_regex_session_key_t *key);
    720 
    721 /* Returns the session data (if any). Flags param for future use. */
    722 extern int bcm_regex_session_get(
    723     int unit, 
    724     int flags, 
    725     bcm_regex_session_key_t *key, 
    726     bcm_regex_session_t *session);
    727 
    728 #endif /* BCM_HIDE_DISPATCHABLE */
    729 
    730 #define BCM_REGEX_SESSION_TRAVERSE_ALL  0x0001     /* If set, all sessions are
    731                                                       traversed.  Otherwise only
    732                                                       static sessions are
    733                                                       traversed. */
    734 
    735 /*  Prototype for regex session traverse callback. */
    736 typedef int (*bcm_regex_session_traverse_cb)(
    737     int unit, 
    738     bcm_regex_session_key_t *session_key, 
    739     bcm_regex_session_t *session_data, 
    740     void *user_data);
    741 
    742 #ifndef BCM_HIDE_DISPATCHABLE
    743 
    744 /* Traverse regex sessions. */
    745 extern int bcm_regex_session_traverse(
    746     int unit, 
    747     int flags, 
    748     bcm_regex_session_traverse_cb cb, 
    749     void *user_data);
    750 
    751 /* Deletes all the entries from the regex session table. */
    752 extern int bcm_regex_session_delete_all(
    753     int unit);
    754 
    755 #endif /* defined(INCLUDE_REGEX) */
    756 
    757 #endif /* BCM_HIDE_DISPATCHABLE */
    758 
    759 #endif /* __BCM_BREGEX_H__ */