1b34d8163SFrancis Kelly /* SPDX-License-Identifier: BSD-3-Clause 2b34d8163SFrancis Kelly * Copyright 2020 Mellanox Technologies, Ltd 3b34d8163SFrancis Kelly */ 4b34d8163SFrancis Kelly 5b34d8163SFrancis Kelly #ifndef RTE_PMD_MLX5_REGEX_RXP_H_ 6b34d8163SFrancis Kelly #define RTE_PMD_MLX5_REGEX_RXP_H_ 7b34d8163SFrancis Kelly 802179f82SFrancis Kelly #define MLX5_RXP_BF2_IDENTIFIER 0x0 9ab746801SGerry Gribbon #define MLX5_RXP_BF3_IDENTIFIER 0x1 10b34d8163SFrancis Kelly #define MLX5_RXP_MAX_JOB_LENGTH 16384 11b34d8163SFrancis Kelly #define MLX5_RXP_MAX_SUBSETS 4095 12b34d8163SFrancis Kelly #define MLX5_RXP_CSR_NUM_ENTRIES 31 13ab746801SGerry Gribbon #define MLX5_RXP_BF2_ROF_VERSION_STRING 0x07055254 14ab746801SGerry Gribbon #define MLX5_RXP_BF3_ROF_VERSION_STRING 0x00065254 15ab746801SGerry Gribbon #define MLX5_RXP_BF4_ROF_VERSION_STRING 0x00075254 16b34d8163SFrancis Kelly 17b34d8163SFrancis Kelly #define MLX5_RXP_CTRL_TYPE_MASK 7 18b34d8163SFrancis Kelly #define MLX5_RXP_CTRL_TYPE_JOB_DESCRIPTOR 0 19b34d8163SFrancis Kelly #define MLX5_RXP_CTRL_TYPE_RESPONSE_DESCRIPTOR 1 20b34d8163SFrancis Kelly #define MLX5_RXP_CTRL_TYPE_MEMORY_WRITE 4 21b34d8163SFrancis Kelly #define MLX5_RXP_CSR_CTRL_DISABLE_L2C (1 << 7) 22b34d8163SFrancis Kelly 23b34d8163SFrancis Kelly #define MLX5_RXP_CTRL_JOB_DESC_SOF 0x0010 24b34d8163SFrancis Kelly #define MLX5_RXP_CTRL_JOB_DESC_EOF 0x0020 25b34d8163SFrancis Kelly #define MLX5_RXP_CTRL_JOB_DESC_HPM_ENABLE 0x0100 26b34d8163SFrancis Kelly #define MLX5_RXP_CTRL_JOB_DESC_ANYMATCH_ENABLE 0x0200 27b34d8163SFrancis Kelly #define MLX5_RXP_CTRL_JOB_DESC_FLAGS (MLX5_RXP_CTRL_JOB_DESC_SOF | \ 28b34d8163SFrancis Kelly MLX5_RXP_CTRL_JOB_DESC_EOF | \ 29b34d8163SFrancis Kelly MLX5_RXP_CTRL_JOB_DESC_HPM_ENABLE | \ 30b34d8163SFrancis Kelly MLX5_RXP_CTRL_JOB_DESC_ANYMATCH_ENABLE) 31b34d8163SFrancis Kelly 32b34d8163SFrancis Kelly #define MLX5_RXP_CTRL_VALID 0x8000 33b34d8163SFrancis Kelly 34b34d8163SFrancis Kelly #define MLX5_RXP_RESP_STATUS_MAX_PRI_THREADS (1 << 3) 35b34d8163SFrancis Kelly #define MLX5_RXP_RESP_STATUS_MAX_SEC_THREADS (1 << 4) 36b34d8163SFrancis Kelly #define MLX5_RXP_RESP_STATUS_MAX_LATENCY (1 << 5) 37b34d8163SFrancis Kelly #define MLX5_RXP_RESP_STATUS_MAX_MATCH (1 << 6) 38b34d8163SFrancis Kelly #define MLX5_RXP_RESP_STATUS_MAX_PREFIX (1 << 7) 39b34d8163SFrancis Kelly #define MLX5_RXP_RESP_STATUS_HPM (1 << 8) 40b34d8163SFrancis Kelly #define MLX5_RXP_RESP_STATUS_ANYMATCH (1 << 9) 41b34d8163SFrancis Kelly #define MLX5_RXP_RESP_STATUS_PMI_SOJ (1 << 13) 42b34d8163SFrancis Kelly #define MLX5_RXP_RESP_STATUS_PMI_EOJ (1 << 14) 43b34d8163SFrancis Kelly 44b34d8163SFrancis Kelly /* This describes the header the RXP expects for any search data. */ 45*e7750639SAndre Muezerie struct __rte_packed_begin mlx5_rxp_job_desc { 46b34d8163SFrancis Kelly uint32_t job_id; 47b34d8163SFrancis Kelly uint16_t ctrl; 48b34d8163SFrancis Kelly uint16_t len; 49b34d8163SFrancis Kelly uint16_t subset[4]; 50*e7750639SAndre Muezerie } __rte_packed_end; 51b34d8163SFrancis Kelly 52*e7750639SAndre Muezerie struct __rte_packed_begin mlx5_rxp_response_desc { 53b34d8163SFrancis Kelly uint32_t job_id; 54b34d8163SFrancis Kelly uint16_t status; 55b34d8163SFrancis Kelly uint8_t detected_match_count; 56b34d8163SFrancis Kelly uint8_t match_count; 57b34d8163SFrancis Kelly uint16_t primary_thread_count; 58b34d8163SFrancis Kelly uint16_t instruction_count; 59b34d8163SFrancis Kelly uint16_t latency_count; 60b34d8163SFrancis Kelly uint16_t pmi_min_byte_ptr; 61*e7750639SAndre Muezerie } __rte_packed_end; 62b34d8163SFrancis Kelly 63*e7750639SAndre Muezerie struct __rte_packed_begin mlx5_rxp_match_tuple { 64b34d8163SFrancis Kelly uint32_t rule_id; 65b34d8163SFrancis Kelly uint16_t start_ptr; 66b34d8163SFrancis Kelly uint16_t length; 67*e7750639SAndre Muezerie } __rte_packed_end; 68b34d8163SFrancis Kelly 69b34d8163SFrancis Kelly struct mlx5_rxp_response { 70b34d8163SFrancis Kelly struct mlx5_rxp_response_desc header; 71013b4c52SBruce Richardson struct mlx5_rxp_match_tuple matches[]; 72b34d8163SFrancis Kelly }; 73b34d8163SFrancis Kelly 74b34d8163SFrancis Kelly #define MLX5_RXP_MAX_MATCHES 254 75b34d8163SFrancis Kelly 76b34d8163SFrancis Kelly #define MLX5_RXP_CTL_RULES_PGM 1 77b34d8163SFrancis Kelly #define MLX5_RXP_CTL_RULES_PGM_INCR 2 78b34d8163SFrancis Kelly 79b34d8163SFrancis Kelly #define MLX5_RXP_ROF_ENTRY_INST 0 80b34d8163SFrancis Kelly #define MLX5_RXP_ROF_ENTRY_EQ 1 81b34d8163SFrancis Kelly #define MLX5_RXP_ROF_ENTRY_GTE 2 82b34d8163SFrancis Kelly #define MLX5_RXP_ROF_ENTRY_LTE 3 83b34d8163SFrancis Kelly #define MLX5_RXP_ROF_ENTRY_CHECKSUM 4 84b34d8163SFrancis Kelly #define MLX5_RXP_ROF_ENTRY_CHECKSUM_EX_EM 5 85b34d8163SFrancis Kelly #define MLX5_RXP_ROF_ENTRY_IM 6 86b34d8163SFrancis Kelly #define MLX5_RXP_ROF_ENTRY_EM 7 87b34d8163SFrancis Kelly #define MLX5_RXP_ROF_ENTRY_TYPE_MAX 7 88b34d8163SFrancis Kelly 89b34d8163SFrancis Kelly #define MLX5_RXP_INST_OFFSET 3 90b34d8163SFrancis Kelly #define MLX5_RXP_INST_BLOCK_SIZE 8 91b34d8163SFrancis Kelly #define MLX5_MAX_SIZE_RES_DES (sizeof(struct mlx5_rxp_response_desc)) 92b34d8163SFrancis Kelly #define MLX5_MAX_DB_SIZE (1u << 27u) 93b34d8163SFrancis Kelly #define MLX5_MAX_SIZE_MATCH_RESP (254 * sizeof(struct mlx5_rxp_match_tuple)) 94b34d8163SFrancis Kelly #define MLX5_RXP_SQ_NOT_BUSY false 95b34d8163SFrancis Kelly #define MLX5_RXP_SQ_BUSY true 96b34d8163SFrancis Kelly 97b34d8163SFrancis Kelly 98b34d8163SFrancis Kelly struct mlx5_rxp_ctl_hdr { 99b34d8163SFrancis Kelly uint16_t cmd; 100b34d8163SFrancis Kelly uint32_t len; 101b34d8163SFrancis Kelly }; 102b34d8163SFrancis Kelly 103b34d8163SFrancis Kelly struct mlx5_rxp_rof_entry { 104b34d8163SFrancis Kelly uint8_t type; 105b34d8163SFrancis Kelly uint32_t addr; 106b34d8163SFrancis Kelly uint64_t value; 107b34d8163SFrancis Kelly }; 108b34d8163SFrancis Kelly 109b34d8163SFrancis Kelly struct mlx5_rxp_rof { 110b34d8163SFrancis Kelly uint32_t rof_version; 111b34d8163SFrancis Kelly char *timestamp; 112b34d8163SFrancis Kelly char *rxp_compiler_version; 113b34d8163SFrancis Kelly uint32_t rof_revision; 114b34d8163SFrancis Kelly uint32_t number_of_entries; 115b34d8163SFrancis Kelly struct mlx5_rxp_rof_entry *rof_entries; 116b34d8163SFrancis Kelly }; 117b34d8163SFrancis Kelly 118*e7750639SAndre Muezerie struct __rte_packed_begin mlx5_rxp_ctl_rules_pgm { 119b34d8163SFrancis Kelly struct mlx5_rxp_ctl_hdr hdr; 120b34d8163SFrancis Kelly uint32_t count; 121013b4c52SBruce Richardson struct mlx5_rxp_rof_entry rules[]; 122*e7750639SAndre Muezerie } __rte_packed_end; 123b34d8163SFrancis Kelly 124b34d8163SFrancis Kelly /* RXP programming mode setting. */ 125b34d8163SFrancis Kelly enum mlx5_rxp_program_mode { 126b34d8163SFrancis Kelly MLX5_RXP_MODE_NOT_DEFINED = 0, 127b34d8163SFrancis Kelly MLX5_RXP_SHARED_PROG_MODE, 128b34d8163SFrancis Kelly MLX5_RXP_PRIVATE_PROG_MODE, 129b34d8163SFrancis Kelly }; 130b34d8163SFrancis Kelly 131b34d8163SFrancis Kelly #define MLX5_RXP_POLL_CSR_FOR_VALUE_TIMEOUT 3000 /* Poll timeout in ms. */ 132b34d8163SFrancis Kelly #define MLX5_RXP_INITIALIZATION_TIMEOUT 60000 /* Initialize timeout in ms. */ 133b34d8163SFrancis Kelly #define MLX5_RXP_MAX_ENGINES 2u /* Number of RXP engines. */ 134b34d8163SFrancis Kelly #define MLX5_RXP_EM_COUNT 1u /* Extra External Memories to use. */ 135b34d8163SFrancis Kelly #define MLX5_RXP_DB_NOT_ASSIGNED 0xFF 136b34d8163SFrancis Kelly 1379fa82d28SAdy Agbarih struct mlx5_regex_mkey { 138b34d8163SFrancis Kelly struct mlx5dv_devx_umem *umem; 1399fa82d28SAdy Agbarih struct mlx5_devx_obj *mkey; 140b34d8163SFrancis Kelly uint64_t offset; 141b34d8163SFrancis Kelly }; 142b34d8163SFrancis Kelly 143b34d8163SFrancis Kelly #endif /* RTE_PMD_MLX5_REGEX_RXP_H_ */ 144