| 1 | /* |
| 2 | * Copyright (c) 2015-2018, Intel Corporation |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are met: |
| 6 | * |
| 7 | * * Redistributions of source code must retain the above copyright notice, |
| 8 | * this list of conditions and the following disclaimer. |
| 9 | * * Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * * Neither the name of Intel Corporation nor the names of its contributors |
| 13 | * may be used to endorse or promote products derived from this software |
| 14 | * without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 26 | * POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
| 28 | |
| 29 | /** \file |
| 30 | * \brief Rose data structures to do with role programs. |
| 31 | */ |
| 32 | |
| 33 | #ifndef ROSE_ROSE_PROGRAM_H |
| 34 | #define ROSE_ROSE_PROGRAM_H |
| 35 | |
| 36 | #include "som/som_operation.h" |
| 37 | #include "rose_internal.h" |
| 38 | #include "ue2common.h" |
| 39 | #include "util/simd_types.h" |
| 40 | |
| 41 | /** \brief Minimum alignment for each instruction in memory. */ |
| 42 | #define ROSE_INSTR_MIN_ALIGN 8U |
| 43 | |
| 44 | /** \brief Role program instruction opcodes. */ |
| 45 | enum RoseInstructionCode { |
| 46 | ROSE_INSTR_END, //!< End of program. |
| 47 | ROSE_INSTR_ANCHORED_DELAY, //!< Delay until after anchored matcher. |
| 48 | ROSE_INSTR_CHECK_LIT_EARLY, //!< Skip matches before floating min offset. |
| 49 | ROSE_INSTR_CHECK_GROUPS, //!< Check that literal groups are on. |
| 50 | ROSE_INSTR_CHECK_ONLY_EOD, //!< Role matches only at EOD. |
| 51 | ROSE_INSTR_CHECK_BOUNDS, //!< Bounds on distance from offset 0. |
| 52 | ROSE_INSTR_CHECK_NOT_HANDLED, //!< Test & set role in "handled". |
| 53 | ROSE_INSTR_CHECK_SINGLE_LOOKAROUND, //!< Single lookaround check. |
| 54 | ROSE_INSTR_CHECK_LOOKAROUND, //!< Lookaround check. |
| 55 | ROSE_INSTR_CHECK_MASK, //!< 8-bytes mask check. |
| 56 | ROSE_INSTR_CHECK_MASK_32, //!< 32-bytes and/cmp/neg mask check. |
| 57 | ROSE_INSTR_CHECK_BYTE, //!< Single Byte check. |
| 58 | ROSE_INSTR_CHECK_SHUFTI_16x8, //!< Check 16-byte data by 8-bucket shufti. |
| 59 | ROSE_INSTR_CHECK_SHUFTI_32x8, //!< Check 32-byte data by 8-bucket shufti. |
| 60 | ROSE_INSTR_CHECK_SHUFTI_16x16, //!< Check 16-byte data by 16-bucket shufti. |
| 61 | ROSE_INSTR_CHECK_SHUFTI_32x16, //!< Check 32-byte data by 16-bucket shufti. |
| 62 | ROSE_INSTR_CHECK_INFIX, //!< Infix engine must be in accept state. |
| 63 | ROSE_INSTR_CHECK_PREFIX, //!< Prefix engine must be in accept state. |
| 64 | ROSE_INSTR_PUSH_DELAYED, //!< Push delayed literal matches. |
| 65 | ROSE_INSTR_DUMMY_NOP, //!< NOP. Should not exist in build programs. |
| 66 | ROSE_INSTR_CATCH_UP, //!< Catch up engines, anchored matches. |
| 67 | ROSE_INSTR_CATCH_UP_MPV, //!< Catch up the MPV. |
| 68 | ROSE_INSTR_SOM_ADJUST, //!< Set SOM from a distance to EOM. |
| 69 | ROSE_INSTR_SOM_LEFTFIX, //!< Acquire SOM from a leftfix engine. |
| 70 | ROSE_INSTR_SOM_FROM_REPORT, //!< Acquire SOM from a som_operation. |
| 71 | ROSE_INSTR_SOM_ZERO, //!< Set SOM to zero. |
| 72 | ROSE_INSTR_TRIGGER_INFIX, //!< Trigger an infix engine. |
| 73 | ROSE_INSTR_TRIGGER_SUFFIX, //!< Trigger a suffix engine. |
| 74 | ROSE_INSTR_DEDUPE, //!< Run deduplication for report. |
| 75 | ROSE_INSTR_DEDUPE_SOM, //!< Run deduplication for SOM report. |
| 76 | ROSE_INSTR_REPORT_CHAIN, //!< Fire a chained report (MPV). |
| 77 | ROSE_INSTR_REPORT_SOM_INT, //!< Manipulate SOM only. |
| 78 | ROSE_INSTR_REPORT_SOM_AWARE, //!< Manipulate SOM from SOM-aware source. |
| 79 | |
| 80 | /** \brief Fire a report. */ |
| 81 | ROSE_INSTR_REPORT, |
| 82 | |
| 83 | /** \brief Fire an exhaustible report. */ |
| 84 | ROSE_INSTR_REPORT_EXHAUST, |
| 85 | |
| 86 | /** \brief Fire a SOM report. */ |
| 87 | ROSE_INSTR_REPORT_SOM, |
| 88 | |
| 89 | /** \brief Fire an exhaustible SOM report. */ |
| 90 | ROSE_INSTR_REPORT_SOM_EXHAUST, |
| 91 | |
| 92 | /** \brief Super-instruction combining DEDUPE and REPORT. */ |
| 93 | ROSE_INSTR_DEDUPE_AND_REPORT, |
| 94 | |
| 95 | /** |
| 96 | * \brief Fire a report and stop program execution. This is a |
| 97 | * specialisation intended for short, frequently-executed programs. |
| 98 | */ |
| 99 | ROSE_INSTR_FINAL_REPORT, |
| 100 | |
| 101 | ROSE_INSTR_CHECK_EXHAUSTED, //!< Check if an ekey has already been set. |
| 102 | ROSE_INSTR_CHECK_MIN_LENGTH, //!< Check (EOM - SOM) against min length. |
| 103 | ROSE_INSTR_SET_STATE, //!< Switch a state index on. |
| 104 | ROSE_INSTR_SET_GROUPS, //!< Set some literal group bits. |
| 105 | ROSE_INSTR_SQUASH_GROUPS, //!< Conditionally turn off some groups. |
| 106 | ROSE_INSTR_CHECK_STATE, //!< Test a single bit in the state multibit. |
| 107 | ROSE_INSTR_SPARSE_ITER_BEGIN, //!< Begin running a sparse iter over states. |
| 108 | ROSE_INSTR_SPARSE_ITER_NEXT, //!< Continue running sparse iter over states. |
| 109 | ROSE_INSTR_SPARSE_ITER_ANY, //!< Test for any bit in the sparse iterator. |
| 110 | |
| 111 | /** \brief Check outfixes and suffixes for EOD and fire reports if so. */ |
| 112 | ROSE_INSTR_ENGINES_EOD, |
| 113 | |
| 114 | /** \brief Catch up and check active suffixes for EOD and fire reports if |
| 115 | * so. */ |
| 116 | ROSE_INSTR_SUFFIXES_EOD, |
| 117 | |
| 118 | /** \brief Run the EOD-anchored HWLM literal matcher. */ |
| 119 | ROSE_INSTR_MATCHER_EOD, |
| 120 | |
| 121 | /** |
| 122 | * \brief Confirm a case-sensitive literal at the current offset. In |
| 123 | * streaming mode, this makes use of the long literal table. |
| 124 | */ |
| 125 | ROSE_INSTR_CHECK_LONG_LIT, |
| 126 | |
| 127 | /** |
| 128 | * \brief Confirm a case-insensitive literal at the current offset. In |
| 129 | * streaming mode, this makes use of the long literal table. |
| 130 | */ |
| 131 | ROSE_INSTR_CHECK_LONG_LIT_NOCASE, |
| 132 | |
| 133 | /** |
| 134 | * \brief Confirm a case-sensitive "medium length" literal at the current |
| 135 | * offset. In streaming mode, this will check history if needed. |
| 136 | */ |
| 137 | ROSE_INSTR_CHECK_MED_LIT, |
| 138 | |
| 139 | /** |
| 140 | * \brief Confirm a case-insensitive "medium length" literal at the current |
| 141 | * offset. In streaming mode, this will check history if needed. |
| 142 | */ |
| 143 | ROSE_INSTR_CHECK_MED_LIT_NOCASE, |
| 144 | |
| 145 | /** |
| 146 | * \brief Clear the "work done" flag used by the SQUASH_GROUPS instruction. |
| 147 | */ |
| 148 | ROSE_INSTR_CLEAR_WORK_DONE, |
| 149 | |
| 150 | /** \brief Check lookaround if it has multiple paths. */ |
| 151 | ROSE_INSTR_MULTIPATH_LOOKAROUND, |
| 152 | |
| 153 | /** |
| 154 | * \brief Use shufti to check lookaround with multiple paths. The total |
| 155 | * length of the paths is 16 bytes at most and shufti has 8 buckets. |
| 156 | * All paths can be at most 16 bytes long. |
| 157 | */ |
| 158 | ROSE_INSTR_CHECK_MULTIPATH_SHUFTI_16x8, |
| 159 | |
| 160 | /** |
| 161 | * \brief Use shufti to check lookaround with multiple paths. The total |
| 162 | * length of the paths is 32 bytes at most and shufti has 8 buckets. |
| 163 | * All paths can be at most 16 bytes long. |
| 164 | */ |
| 165 | ROSE_INSTR_CHECK_MULTIPATH_SHUFTI_32x8, |
| 166 | |
| 167 | /** |
| 168 | * \brief Use shufti to check lookaround with multiple paths. The total |
| 169 | * length of the paths is 32 bytes at most and shufti has 16 buckets. |
| 170 | * All paths can be at most 16 bytes long. |
| 171 | */ |
| 172 | ROSE_INSTR_CHECK_MULTIPATH_SHUFTI_32x16, |
| 173 | |
| 174 | /** |
| 175 | * \brief Use shufti to check multiple paths lookaround. The total |
| 176 | * length of the paths is 64 bytes at most and shufti has 8 buckets. |
| 177 | * All paths can be at most 16 bytes long. |
| 178 | */ |
| 179 | ROSE_INSTR_CHECK_MULTIPATH_SHUFTI_64, |
| 180 | |
| 181 | /** |
| 182 | * \brief Jump to the program of included literal. |
| 183 | */ |
| 184 | ROSE_INSTR_INCLUDED_JUMP, |
| 185 | |
| 186 | /** |
| 187 | * \brief Set matching status of a sub-expression. |
| 188 | */ |
| 189 | ROSE_INSTR_SET_LOGICAL, |
| 190 | |
| 191 | /** |
| 192 | * \brief Set combination status pending checking. |
| 193 | */ |
| 194 | ROSE_INSTR_SET_COMBINATION, |
| 195 | |
| 196 | /** |
| 197 | * \brief Check if compliant with any logical constraints. |
| 198 | */ |
| 199 | ROSE_INSTR_FLUSH_COMBINATION, |
| 200 | |
| 201 | /** \brief Mark as exhausted instead of report while quiet. */ |
| 202 | ROSE_INSTR_SET_EXHAUST, |
| 203 | |
| 204 | LAST_ROSE_INSTRUCTION = ROSE_INSTR_SET_EXHAUST //!< Sentinel. |
| 205 | }; |
| 206 | |
| 207 | struct ROSE_STRUCT_END { |
| 208 | u8 code; //!< From enum RoseInstructionCode. |
| 209 | }; |
| 210 | |
| 211 | struct ROSE_STRUCT_ANCHORED_DELAY { |
| 212 | u8 code; //!< From enum RoseInstructionCode. |
| 213 | rose_group groups; //!< Bitmask. |
| 214 | u32 anch_id; //!< Program to restart after the delay. |
| 215 | u32 done_jump; //!< Jump forward this many bytes if we have to delay. |
| 216 | }; |
| 217 | |
| 218 | struct ROSE_STRUCT_CHECK_LIT_EARLY { |
| 219 | u8 code; //!< From enum RoseInstructionCode. |
| 220 | u32 min_offset; //!< Minimum offset for this literal. |
| 221 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 222 | }; |
| 223 | |
| 224 | /** Note: check failure will halt program. */ |
| 225 | struct ROSE_STRUCT_CHECK_GROUPS { |
| 226 | u8 code; //!< From enum RoseInstructionCode. |
| 227 | rose_group groups; //!< Bitmask. |
| 228 | }; |
| 229 | |
| 230 | struct ROSE_STRUCT_CHECK_ONLY_EOD { |
| 231 | u8 code; //!< From enum RoseInstructionCode. |
| 232 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 233 | }; |
| 234 | |
| 235 | struct ROSE_STRUCT_CHECK_BOUNDS { |
| 236 | u8 code; //!< From enum RoseInstructionCode. |
| 237 | u64a min_bound; //!< Min distance from zero. |
| 238 | u64a max_bound; //!< Max distance from zero. |
| 239 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 240 | }; |
| 241 | |
| 242 | struct ROSE_STRUCT_CHECK_NOT_HANDLED { |
| 243 | u8 code; //!< From enum RoseInstructionCode. |
| 244 | u32 key; //!< Key in the "handled_roles" fatbit in scratch. |
| 245 | u32 fail_jump; //!< Jump forward this many bytes if we have seen key before. |
| 246 | }; |
| 247 | |
| 248 | struct ROSE_STRUCT_CHECK_SINGLE_LOOKAROUND { |
| 249 | u8 code; //!< From enum RoseInstructionCode. |
| 250 | s8 offset; //!< The offset of the byte to examine. |
| 251 | u32 reach_index; //!< Index for lookaround reach bitvectors. |
| 252 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 253 | }; |
| 254 | |
| 255 | struct ROSE_STRUCT_CHECK_LOOKAROUND { |
| 256 | u8 code; //!< From enum RoseInstructionCode. |
| 257 | u32 look_index; //!< Offset in bytecode of lookaround offset list. |
| 258 | u32 reach_index; //!< Offset in bytecode of lookaround reach bitvectors. |
| 259 | u32 count; //!< The count of lookaround entries in one instruction. |
| 260 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 261 | }; |
| 262 | |
| 263 | struct ROSE_STRUCT_CHECK_MASK { |
| 264 | u8 code; //!< From enum roseInstructionCode. |
| 265 | u64a and_mask; //!< 8-byte and mask. |
| 266 | u64a cmp_mask; //!< 8-byte cmp mask. |
| 267 | u64a neg_mask; //!< 8-byte negation mask. |
| 268 | s32 offset; //!< Relative offset of the first byte. |
| 269 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 270 | }; |
| 271 | |
| 272 | struct ROSE_STRUCT_CHECK_MASK_32 { |
| 273 | u8 code; //!< From enum RoseInstructionCode. |
| 274 | u8 and_mask[32]; //!< 32-byte and mask. |
| 275 | u8 cmp_mask[32]; //!< 32-byte cmp mask. |
| 276 | u32 neg_mask; //!< negation mask with 32 bits. |
| 277 | s32 offset; //!< Relative offset of the first byte. |
| 278 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 279 | }; |
| 280 | |
| 281 | struct ROSE_STRUCT_CHECK_BYTE { |
| 282 | u8 code; //!< From enum RoseInstructionCode. |
| 283 | u8 and_mask; //!< 8-bits and mask. |
| 284 | u8 cmp_mask; //!< 8-bits cmp mask. |
| 285 | u8 negation; //!< Flag about negation. |
| 286 | s32 offset; //!< The relative offset. |
| 287 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 288 | }; |
| 289 | |
| 290 | // Since m128 and m256 could be missaligned in the bytecode, |
| 291 | // we'll use u8[16] and u8[32] instead in all rose_check_shufti structures. |
| 292 | struct ROSE_STRUCT_CHECK_SHUFTI_16x8 { |
| 293 | u8 code; //!< From enum RoseInstructionCode. |
| 294 | u8 nib_mask[32]; //!< High 16 and low 16 bits nibble mask in shufti. |
| 295 | u8 bucket_select_mask[16]; //!< Mask for bucket assigning. |
| 296 | u32 neg_mask; //!< Negation mask in low 16 bits. |
| 297 | s32 offset; //!< Relative offset of the first byte. |
| 298 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 299 | }; |
| 300 | |
| 301 | struct ROSE_STRUCT_CHECK_SHUFTI_32x8 { |
| 302 | u8 code; //!< From enum RoseInstructionCode. |
| 303 | u8 hi_mask[16]; //!< High nibble mask in shufti. |
| 304 | u8 lo_mask[16]; //!< Low nibble mask in shufti. |
| 305 | u8 bucket_select_mask[32]; //!< Mask for bucket assigning. |
| 306 | u32 neg_mask; //!< 32 bits negation mask. |
| 307 | s32 offset; //!< Relative offset of the first byte. |
| 308 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 309 | }; |
| 310 | |
| 311 | struct ROSE_STRUCT_CHECK_SHUFTI_16x16 { |
| 312 | u8 code; //!< From enum RoseInstructionCode. |
| 313 | u8 hi_mask[32]; //!< High nibble mask in shufti. |
| 314 | u8 lo_mask[32]; //!< Low nibble mask in shufti. |
| 315 | u8 bucket_select_mask[32]; //!< Mask for bucket assigning. |
| 316 | u32 neg_mask; //!< Negation mask in low 16 bits. |
| 317 | s32 offset; //!< Relative offset of the first byte. |
| 318 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 319 | }; |
| 320 | |
| 321 | struct ROSE_STRUCT_CHECK_SHUFTI_32x16 { |
| 322 | u8 code; //!< From enum RoseInstructionCode. |
| 323 | u8 hi_mask[32]; //!< High nibble mask in shufti. |
| 324 | u8 lo_mask[32]; //!< Low nibble mask in shufti. |
| 325 | u8 bucket_select_mask_hi[32]; //!< Bucket mask for high 8 buckets. |
| 326 | u8 bucket_select_mask_lo[32]; //!< Bucket mask for low 8 buckets. |
| 327 | u32 neg_mask; //!< 32 bits negation mask. |
| 328 | s32 offset; //!< Relative offset of the first byte. |
| 329 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 330 | }; |
| 331 | |
| 332 | struct ROSE_STRUCT_CHECK_INFIX { |
| 333 | u8 code; //!< From enum RoseInstructionCode. |
| 334 | u32 queue; //!< Queue of leftfix to check. |
| 335 | u32 lag; //!< Lag of leftfix for this case. |
| 336 | ReportID report; //!< ReportID of leftfix to check. |
| 337 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 338 | }; |
| 339 | |
| 340 | struct ROSE_STRUCT_CHECK_PREFIX { |
| 341 | u8 code; //!< From enum RoseInstructionCode. |
| 342 | u32 queue; //!< Queue of leftfix to check. |
| 343 | u32 lag; //!< Lag of leftfix for this case. |
| 344 | ReportID report; //!< ReportID of leftfix to check. |
| 345 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 346 | }; |
| 347 | |
| 348 | struct ROSE_STRUCT_PUSH_DELAYED { |
| 349 | u8 code; //!< From enum RoseInstructionCode. |
| 350 | u8 delay; // Number of bytes to delay. |
| 351 | u32 index; // Delay literal index (relative to first delay lit). |
| 352 | }; |
| 353 | |
| 354 | struct ROSE_STRUCT_DUMMY_NOP { |
| 355 | u8 code; //!< From enum RoseInstructionCode. |
| 356 | }; |
| 357 | |
| 358 | struct ROSE_STRUCT_CATCH_UP { |
| 359 | u8 code; //!< From enum RoseInstructionCode. |
| 360 | }; |
| 361 | |
| 362 | struct ROSE_STRUCT_CATCH_UP_MPV { |
| 363 | u8 code; //!< From enum RoseInstructionCode. |
| 364 | }; |
| 365 | |
| 366 | struct ROSE_STRUCT_SOM_ADJUST { |
| 367 | u8 code; //!< From enum RoseInstructionCode. |
| 368 | u32 distance; //!< Distance to EOM. |
| 369 | }; |
| 370 | |
| 371 | struct ROSE_STRUCT_SOM_LEFTFIX { |
| 372 | u8 code; //!< From enum RoseInstructionCode. |
| 373 | u32 queue; //!< Queue index of leftfix providing SOM. |
| 374 | u32 lag; //!< Lag of leftfix for this case. |
| 375 | }; |
| 376 | |
| 377 | struct ROSE_STRUCT_SOM_FROM_REPORT { |
| 378 | u8 code; //!< From enum RoseInstructionCode. |
| 379 | struct som_operation som; |
| 380 | }; |
| 381 | |
| 382 | struct ROSE_STRUCT_SOM_ZERO { |
| 383 | u8 code; //!< From enum RoseInstructionCode. |
| 384 | }; |
| 385 | |
| 386 | struct ROSE_STRUCT_TRIGGER_INFIX { |
| 387 | u8 code; //!< From enum RoseInstructionCode. |
| 388 | u8 cancel; //!< Cancels previous top event. |
| 389 | u32 queue; //!< Queue index of infix. |
| 390 | u32 event; //!< Queue event, from MQE_*. |
| 391 | }; |
| 392 | |
| 393 | struct ROSE_STRUCT_TRIGGER_SUFFIX { |
| 394 | u8 code; //!< From enum RoseInstructionCode. |
| 395 | u32 queue; //!< Queue index of suffix. |
| 396 | u32 event; //!< Queue event, from MQE_*. |
| 397 | }; |
| 398 | |
| 399 | struct ROSE_STRUCT_DEDUPE { |
| 400 | u8 code; //!< From enum RoseInstructionCode. |
| 401 | u8 quash_som; //!< Force SOM to zero for this report. |
| 402 | u32 dkey; //!< Dedupe key. |
| 403 | s32 offset_adjust; //!< Offset adjustment to apply to end offset. |
| 404 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 405 | }; |
| 406 | |
| 407 | struct ROSE_STRUCT_DEDUPE_SOM { |
| 408 | u8 code; //!< From enum RoseInstructionCode. |
| 409 | u8 quash_som; //!< Force SOM to zero for this report. |
| 410 | u32 dkey; //!< Dedupe key. |
| 411 | s32 offset_adjust; //!< Offset adjustment to apply to end offset. |
| 412 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 413 | }; |
| 414 | |
| 415 | struct ROSE_STRUCT_REPORT_CHAIN { |
| 416 | u8 code; //!< From enum RoseInstructionCode. |
| 417 | u32 event; //!< Queue event, from MQE_*. Must be a top. |
| 418 | |
| 419 | /** |
| 420 | * \brief Number of bytes behind us that we are allowed to squash |
| 421 | * identical top events on the queue. |
| 422 | */ |
| 423 | u64a top_squash_distance; |
| 424 | }; |
| 425 | |
| 426 | struct ROSE_STRUCT_REPORT_SOM_INT { |
| 427 | u8 code; //!< From enum RoseInstructionCode. |
| 428 | struct som_operation som; |
| 429 | }; |
| 430 | |
| 431 | struct ROSE_STRUCT_REPORT_SOM_AWARE { |
| 432 | u8 code; //!< From enum RoseInstructionCode. |
| 433 | struct som_operation som; |
| 434 | }; |
| 435 | |
| 436 | struct ROSE_STRUCT_REPORT { |
| 437 | u8 code; //!< From enum RoseInstructionCode. |
| 438 | ReportID onmatch; //!< Report ID to deliver to user. |
| 439 | s32 offset_adjust; //!< Offset adjustment to apply to end offset. |
| 440 | }; |
| 441 | |
| 442 | struct ROSE_STRUCT_REPORT_EXHAUST { |
| 443 | u8 code; //!< From enum RoseInstructionCode. |
| 444 | ReportID onmatch; //!< Report ID to deliver to user. |
| 445 | s32 offset_adjust; //!< Offset adjustment to apply to end offset. |
| 446 | u32 ekey; //!< Exhaustion key. |
| 447 | }; |
| 448 | |
| 449 | struct ROSE_STRUCT_REPORT_SOM { |
| 450 | u8 code; //!< From enum RoseInstructionCode. |
| 451 | ReportID onmatch; //!< Report ID to deliver to user. |
| 452 | s32 offset_adjust; //!< Offset adjustment to apply to end offset. |
| 453 | }; |
| 454 | |
| 455 | struct ROSE_STRUCT_REPORT_SOM_EXHAUST { |
| 456 | u8 code; //!< From enum RoseInstructionCode. |
| 457 | ReportID onmatch; //!< Report ID to deliver to user. |
| 458 | s32 offset_adjust; //!< Offset adjustment to apply to end offset. |
| 459 | u32 ekey; //!< Exhaustion key. |
| 460 | }; |
| 461 | |
| 462 | struct ROSE_STRUCT_DEDUPE_AND_REPORT { |
| 463 | u8 code; //!< From enum RoseInstructionCode. |
| 464 | u8 quash_som; //!< Force SOM to zero for this report. |
| 465 | u32 dkey; //!< Dedupe key. |
| 466 | ReportID onmatch; //!< Report ID to deliver to user. |
| 467 | s32 offset_adjust; //!< Offset adjustment to apply to end offset. |
| 468 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 469 | }; |
| 470 | |
| 471 | struct ROSE_STRUCT_FINAL_REPORT { |
| 472 | u8 code; //!< From enum RoseInstructionCode. |
| 473 | ReportID onmatch; //!< Report ID to deliver to user. |
| 474 | s32 offset_adjust; //!< Offset adjustment to apply to end offset. |
| 475 | }; |
| 476 | |
| 477 | struct ROSE_STRUCT_CHECK_EXHAUSTED { |
| 478 | u8 code; //!< From enum RoseInstructionCode. |
| 479 | u32 ekey; //!< Exhaustion key to check. |
| 480 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 481 | }; |
| 482 | |
| 483 | struct ROSE_STRUCT_CHECK_MIN_LENGTH { |
| 484 | u8 code; //!< From enum RoseInstructionCode. |
| 485 | s32 end_adj; //!< Offset adjustment to add to EOM first. |
| 486 | u64a min_length; //!< Minimum distance from SOM to EOM. |
| 487 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 488 | }; |
| 489 | |
| 490 | struct ROSE_STRUCT_SET_STATE { |
| 491 | u8 code; //!< From enum RoseInstructionCode. |
| 492 | u32 index; //!< State index in multibit. |
| 493 | }; |
| 494 | |
| 495 | struct ROSE_STRUCT_SET_GROUPS { |
| 496 | u8 code; //!< From enum RoseInstructionCode. |
| 497 | rose_group groups; //!< Bitmask to OR into groups. |
| 498 | }; |
| 499 | |
| 500 | struct ROSE_STRUCT_SQUASH_GROUPS { |
| 501 | u8 code; //!< From enum RoseInstructionCode. |
| 502 | rose_group groups; //!< Bitmask to AND into groups. |
| 503 | }; |
| 504 | |
| 505 | struct ROSE_STRUCT_CHECK_STATE { |
| 506 | u8 code; //!< From enum RoseInstructionCode. |
| 507 | u32 index; //!< State index in the role multibit. |
| 508 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 509 | }; |
| 510 | |
| 511 | /** |
| 512 | * Note that the offsets in the jump table are always relative to the start of |
| 513 | * the program, not the current instruction. |
| 514 | */ |
| 515 | struct ROSE_STRUCT_SPARSE_ITER_BEGIN { |
| 516 | u8 code; //!< From enum RoseInstructionCode. |
| 517 | u32 iter_offset; //!< Offset of mmbit_sparse_iter structure. |
| 518 | u32 jump_table; //!< Offset of jump table indexed by sparse iterator. |
| 519 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 520 | }; |
| 521 | |
| 522 | /** |
| 523 | * Note that the offsets in the jump table are always relative to the start of |
| 524 | * the program, not the current instruction. |
| 525 | */ |
| 526 | struct ROSE_STRUCT_SPARSE_ITER_NEXT { |
| 527 | u8 code; //!< From enum RoseInstructionCode. |
| 528 | u32 iter_offset; //!< Offset of mmbit_sparse_iter structure. |
| 529 | u32 jump_table; //!< Offset of jump table indexed by sparse iterator. |
| 530 | u32 state; // Current state index. |
| 531 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 532 | }; |
| 533 | |
| 534 | struct ROSE_STRUCT_SPARSE_ITER_ANY { |
| 535 | u8 code; //!< From enum RoseInstructionCode. |
| 536 | u32 iter_offset; //!< Offset of mmbit_sparse_iter structure. |
| 537 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 538 | }; |
| 539 | |
| 540 | struct ROSE_STRUCT_ENGINES_EOD { |
| 541 | u8 code; //!< From enum RoseInstructionCode. |
| 542 | u32 iter_offset; //!< Offset of mmbit_sparse_iter structure. |
| 543 | }; |
| 544 | |
| 545 | struct ROSE_STRUCT_SUFFIXES_EOD { |
| 546 | u8 code; //!< From enum RoseInstructionCode. |
| 547 | }; |
| 548 | |
| 549 | struct ROSE_STRUCT_MATCHER_EOD { |
| 550 | u8 code; //!< From enum RoseInstructionCode. |
| 551 | }; |
| 552 | |
| 553 | struct ROSE_STRUCT_CHECK_LONG_LIT { |
| 554 | u8 code; //!< From enum RoseInstructionCode. |
| 555 | u32 lit_offset; //!< Offset of literal string. |
| 556 | u32 lit_length; //!< Length of literal string. |
| 557 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 558 | }; |
| 559 | |
| 560 | struct ROSE_STRUCT_CHECK_LONG_LIT_NOCASE { |
| 561 | u8 code; //!< From enum RoseInstructionCode. |
| 562 | u32 lit_offset; //!< Offset of literal string. |
| 563 | u32 lit_length; //!< Length of literal string. |
| 564 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 565 | }; |
| 566 | |
| 567 | struct ROSE_STRUCT_CHECK_MED_LIT { |
| 568 | u8 code; //!< From enum RoseInstructionCode. |
| 569 | u32 lit_offset; //!< Offset of literal string. |
| 570 | u32 lit_length; //!< Length of literal string. |
| 571 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 572 | }; |
| 573 | |
| 574 | struct ROSE_STRUCT_CHECK_MED_LIT_NOCASE { |
| 575 | u8 code; //!< From enum RoseInstructionCode. |
| 576 | u32 lit_offset; //!< Offset of literal string. |
| 577 | u32 lit_length; //!< Length of literal string. |
| 578 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 579 | }; |
| 580 | |
| 581 | struct ROSE_STRUCT_CLEAR_WORK_DONE { |
| 582 | u8 code; //!< From enum RoseInstructionCode. |
| 583 | }; |
| 584 | |
| 585 | struct ROSE_STRUCT_MULTIPATH_LOOKAROUND { |
| 586 | u8 code; //!< From enum RoseInstructionCode. |
| 587 | u32 look_index; //!< Offset in bytecode of lookaround offset list. |
| 588 | u32 reach_index; //!< Offset in bytecode of lookaround reach bitvectors. |
| 589 | u32 count; //!< The lookaround byte numbers for each path. |
| 590 | s32 last_start; //!< The latest start offset among 8 paths. |
| 591 | u8 start_mask[MULTIPATH_MAX_LEN]; /*!< Used to initialize path if left-most |
| 592 | * data is missed. */ |
| 593 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 594 | }; |
| 595 | |
| 596 | struct ROSE_STRUCT_CHECK_MULTIPATH_SHUFTI_16x8 { |
| 597 | u8 code; //!< From enum RoseInstructionCode. |
| 598 | u8 nib_mask[2 * sizeof(m128)]; //!< High and low nibble mask in shufti. |
| 599 | u8 bucket_select_mask[sizeof(m128)]; //!< Mask for bucket assigning. |
| 600 | u8 data_select_mask[sizeof(m128)]; //!< Shuffle mask for data ordering. |
| 601 | u32 hi_bits_mask; //!< High-bits used in multi-path validation. |
| 602 | u32 lo_bits_mask; //!< Low-bits used in multi-path validation. |
| 603 | u32 neg_mask; //!< 64 bits negation mask. |
| 604 | s32 base_offset; //!< Relative offset of the first byte. |
| 605 | s32 last_start; //!< The latest start offset among 8 paths. |
| 606 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 607 | }; |
| 608 | |
| 609 | struct ROSE_STRUCT_CHECK_MULTIPATH_SHUFTI_32x8 { |
| 610 | u8 code; //!< From enum RoseInstructionCode. |
| 611 | u8 hi_mask[sizeof(m128)]; //!< High nibble mask in shufti. |
| 612 | u8 lo_mask[sizeof(m128)]; //!< Low nibble mask in shufti. |
| 613 | u8 bucket_select_mask[sizeof(m256)]; //!< Mask for bucket assigning. |
| 614 | u8 data_select_mask[sizeof(m256)]; //!< Shuffle mask for data ordering. |
| 615 | u32 hi_bits_mask; //!< High-bits used in multi-path validation. |
| 616 | u32 lo_bits_mask; //!< Low-bits used in multi-path validation. |
| 617 | u32 neg_mask; //!< 64 bits negation mask. |
| 618 | s32 base_offset; //!< Relative offset of the first byte. |
| 619 | s32 last_start; //!< The latest start offset among 8 paths. |
| 620 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 621 | }; |
| 622 | |
| 623 | struct ROSE_STRUCT_CHECK_MULTIPATH_SHUFTI_32x16 { |
| 624 | u8 code; //!< From enum RoseInstructionCode. |
| 625 | u8 hi_mask[sizeof(m256)]; //!< High nibble mask in shufti. |
| 626 | u8 lo_mask[sizeof(m256)]; //!< Low nibble mask in shufti. |
| 627 | u8 bucket_select_mask_hi[sizeof(m256)]; //!< Mask for bucket assigning. |
| 628 | u8 bucket_select_mask_lo[sizeof(m256)]; //!< Mask for bucket assigning. |
| 629 | u8 data_select_mask[sizeof(m256)]; //!< Shuffle mask for data ordering. |
| 630 | u32 hi_bits_mask; //!< High-bits used in multi-path validation. |
| 631 | u32 lo_bits_mask; //!< Low-bits used in multi-path validation. |
| 632 | u32 neg_mask; //!< 64 bits negation mask. |
| 633 | s32 base_offset; //!< Relative offset of the first byte. |
| 634 | s32 last_start; //!< The latest start offset among 8 paths. |
| 635 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 636 | }; |
| 637 | |
| 638 | struct ROSE_STRUCT_CHECK_MULTIPATH_SHUFTI_64 { |
| 639 | u8 code; //!< From enum RoseInstructionCode. |
| 640 | u8 hi_mask[sizeof(m128)]; //!< High nibble mask in shufti. |
| 641 | u8 lo_mask[sizeof(m128)]; //!< Low nibble mask in shufti. |
| 642 | u8 bucket_select_mask[2 * sizeof(m256)]; //!< Mask for bucket assigning. |
| 643 | u8 data_select_mask[2 * sizeof(m256)]; //!< Shuffle mask for data ordering. |
| 644 | u64a hi_bits_mask; //!< High-bits used in multi-path validation. |
| 645 | u64a lo_bits_mask; //!< Low-bits used in multi-path validation. |
| 646 | u64a neg_mask; //!< 64 bits negation mask. |
| 647 | s32 base_offset; //!< Relative offset of the first byte. |
| 648 | s32 last_start; //!< The latest start offset among 8 paths. |
| 649 | u32 fail_jump; //!< Jump forward this many bytes on failure. |
| 650 | }; |
| 651 | |
| 652 | struct ROSE_STRUCT_INCLUDED_JUMP { |
| 653 | u8 code; //!< From enum RoseInstructionCode. |
| 654 | u8 squash; //!< FDR confirm squash mask for included literal. |
| 655 | u32 child_offset; //!< Program offset of included literal. |
| 656 | }; |
| 657 | |
| 658 | struct ROSE_STRUCT_SET_LOGICAL { |
| 659 | u8 code; //!< From enum RoseInstructionCode. |
| 660 | u32 lkey; //!< Logical key to set. |
| 661 | s32 offset_adjust; //!< offsetAdjust from struct Report triggers the flush. |
| 662 | }; |
| 663 | |
| 664 | struct ROSE_STRUCT_SET_COMBINATION { |
| 665 | u8 code; //!< From enum RoseInstructionCode. |
| 666 | u32 ckey; //!< Combination key to set. |
| 667 | }; |
| 668 | |
| 669 | struct ROSE_STRUCT_FLUSH_COMBINATION { |
| 670 | u8 code; //!< From enum RoseInstructionCode. |
| 671 | }; |
| 672 | |
| 673 | struct ROSE_STRUCT_SET_EXHAUST { |
| 674 | u8 code; //!< From enum RoseInstructionCode. |
| 675 | u32 ekey; //!< Exhaustion key. |
| 676 | }; |
| 677 | #endif // ROSE_ROSE_PROGRAM_H |
| 678 | |