1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright 2020 Mellanox Technologies, Ltd 3 */ 4 5 #ifndef RTE_PMD_PRIVATE_MLX5_H_ 6 #define RTE_PMD_PRIVATE_MLX5_H_ 7 8 #include <rte_compat.h> 9 10 /** 11 * @file 12 * MLX5 public header. 13 * 14 * This interface provides the ability to support private PMD 15 * dynamic flags. 16 */ 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 #define RTE_PMD_MLX5_FINE_GRANULARITY_INLINE "mlx5_fine_granularity_inline" 23 24 /** 25 * Returns the dynamic flags name, that are supported. 26 * 27 * @param[out] names 28 * Array that is used to return the supported dynamic flags names. 29 * @param[in] n 30 * The number of elements in the names array. 31 * 32 * @return 33 * The number of dynamic flags that were copied if not negative. 34 * Otherwise: 35 * - ENOMEM - not enough entries in the array 36 * - EINVAL - invalid array entry 37 */ 38 __rte_experimental 39 int rte_pmd_mlx5_get_dyn_flag_names(char *names[], unsigned int n); 40 41 #define RTE_PMD_MLX5_DOMAIN_BIT_NIC_RX (1 << 0) /**< NIC RX domain bit mask. */ 42 #define RTE_PMD_MLX5_DOMAIN_BIT_NIC_TX (1 << 1) /**< NIC TX domain bit mask. */ 43 #define RTE_PMD_MLX5_DOMAIN_BIT_FDB (1 << 2) /**< FDB (TX + RX) domain bit mask. */ 44 45 /** 46 * Synchronize the flows to make them take effort on hardware. 47 * It only supports DR flows now. For DV and Verbs flows, there is no need to 48 * call this function, and a success will return directly in case of Verbs. 49 * 50 * @param[in] port_id 51 * The port identifier of the Ethernet device. 52 * @param[in] domains 53 * Refer to "/usr/include/infiniband/mlx5dv.h". 54 * Bitmask of domains in which the synchronization will be done. 55 * RTE_PMD_MLX5_DOMAIN_BIT_* macros are used to specify the domains. 56 * An ADD or OR operation could be used to synchronize flows in more than 57 * one domain per call. 58 * 59 * @return 60 * - (0) if successful. 61 * - Negative value if an error. 62 */ 63 __rte_experimental 64 int rte_pmd_mlx5_sync_flow(uint16_t port_id, uint32_t domains); 65 66 /** 67 * External Rx queue rte_flow index minimal value. 68 */ 69 #define RTE_PMD_MLX5_EXTERNAL_RX_QUEUE_ID_MIN (UINT16_MAX - 1000 + 1) 70 71 /** 72 * Tag level to set the linear hash index. 73 */ 74 #define RTE_PMD_MLX5_LINEAR_HASH_TAG_INDEX 255 75 76 /** 77 * Update mapping between rte_flow queue index (16 bits) and HW queue index (32 78 * bits) for RxQs which is created outside the PMD. 79 * 80 * @param[in] port_id 81 * The port identifier of the Ethernet device. 82 * @param[in] dpdk_idx 83 * Queue index in rte_flow. 84 * @param[in] hw_idx 85 * Queue index in hardware. 86 * 87 * @return 88 * 0 on success, a negative errno value otherwise and rte_errno is set. 89 * Possible values for rte_errno: 90 * - EEXIST - a mapping with the same rte_flow index already exists. 91 * - EINVAL - invalid rte_flow index, out of range. 92 * - ENODEV - there is no Ethernet device for this port id. 93 * - ENOTSUP - the port doesn't support external RxQ. 94 */ 95 __rte_experimental 96 int rte_pmd_mlx5_external_rx_queue_id_map(uint16_t port_id, uint16_t dpdk_idx, 97 uint32_t hw_idx); 98 99 /** 100 * Remove mapping between rte_flow queue index (16 bits) and HW queue index (32 101 * bits) for RxQs which is created outside the PMD. 102 * 103 * @param[in] port_id 104 * The port identifier of the Ethernet device. 105 * @param[in] dpdk_idx 106 * Queue index in rte_flow. 107 * 108 * @return 109 * 0 on success, a negative errno value otherwise and rte_errno is set. 110 * Possible values for rte_errno: 111 * - EINVAL - invalid index, out of range, still referenced or doesn't exist. 112 * - ENODEV - there is no Ethernet device for this port id. 113 * - ENOTSUP - the port doesn't support external RxQ. 114 */ 115 __rte_experimental 116 int rte_pmd_mlx5_external_rx_queue_id_unmap(uint16_t port_id, 117 uint16_t dpdk_idx); 118 119 /** 120 * The rate of the host port shaper will be updated directly at the next 121 * available descriptor threshold event to the rate that comes with this flag set; 122 * set rate 0 to disable this rate update. 123 * Unset this flag to update the rate of the host port shaper directly in 124 * the API call; use rate 0 to disable the current shaper. 125 */ 126 #define RTE_PMD_MLX5_HOST_SHAPER_FLAG_AVAIL_THRESH_TRIGGERED 0 127 128 /** 129 * Configure a HW shaper to limit Tx rate for a host port. 130 * The configuration will affect all the ethdev ports belonging to 131 * the same rte_device. 132 * 133 * @param[in] port_id 134 * The port identifier of the Ethernet device. 135 * @param[in] rate 136 * Unit is 100Mbps, setting the rate to 0 disables the shaper. 137 * @param[in] flags 138 * Host shaper flags (see RTE_PMD_MLX5_HOST_SHAPER_FLAG_*). 139 * @return 140 * 0 : operation success. 141 * Otherwise: 142 * - ENOENT - no ibdev interface. 143 * - EBUSY - the register access unit is busy. 144 * - EIO - the register access command meets IO error. 145 */ 146 __rte_experimental 147 int rte_pmd_mlx5_host_shaper_config(int port_id, uint8_t rate, uint32_t flags); 148 149 /** 150 * Enable traffic for external SQ. 151 * 152 * @param[in] port_id 153 * The port identifier of the Ethernet device. 154 * @param[in] sq_num 155 * SQ HW number. 156 * 157 * @return 158 * 0 on success, a negative errno value otherwise and rte_errno is set. 159 * Possible values for rte_errno: 160 * - EINVAL - invalid sq_number or port type. 161 * - ENODEV - there is no Ethernet device for this port id. 162 */ 163 __rte_experimental 164 int rte_pmd_mlx5_external_sq_enable(uint16_t port_id, uint32_t sq_num); 165 166 /* MLX5 flow engine mode definition for live migration. */ 167 enum rte_pmd_mlx5_flow_engine_mode { 168 RTE_PMD_MLX5_FLOW_ENGINE_MODE_ACTIVE, /* active means high priority, effective in HW. */ 169 RTE_PMD_MLX5_FLOW_ENGINE_MODE_STANDBY, /* standby mode with lower priority flow rules. */ 170 }; 171 172 /** 173 * When set on the flow engine of a standby process, ingress flow rules will be effective 174 * in active and standby processes, so the ingress traffic may be duplicated. 175 */ 176 #define RTE_PMD_MLX5_FLOW_ENGINE_FLAG_STANDBY_DUP_INGRESS RTE_BIT32(0) 177 178 /** 179 * @warning 180 * @b EXPERIMENTAL: this API may change without prior notice 181 * 182 * Set the flow engine mode of the process to active or standby, 183 * affecting network traffic handling. 184 * 185 * If one device does not support this operation or fails, 186 * the whole operation is failed and rolled back. 187 * 188 * It is forbidden to have multiple flow engines with the same mode 189 * unless only one of them is configured to handle the traffic. 190 * 191 * The application's flow engine is active by default. 192 * The configuration from the active flow engine is effective immediately 193 * while the configuration from the standby flow engine is queued by hardware. 194 * When configuring the device from a standby flow engine, 195 * it has no effect except for below situations: 196 * - traffic not handled by the active flow engine configuration 197 * - no active flow engine 198 * 199 * When flow engine of a process is changed from a standby to an active mode, 200 * all preceding configurations that are queued by hardware 201 * should become effective immediately. 202 * Before mode transition, all the traffic handling configurations 203 * set by the active flow engine should be flushed first. 204 * 205 * In summary, the operations are expected to happen in this order 206 * in "old" and "new" applications: 207 * device: already configured by the old application 208 * new: start as active 209 * new: probe the same device 210 * new: set as standby 211 * new: configure the device 212 * device: has configurations from old and new applications 213 * old: clear its device configuration 214 * device: has only 1 configuration from new application 215 * new: set as active 216 * device: downtime for connecting all to the new application 217 * old: shutdown 218 * 219 * @param mode 220 * The desired mode (see rte_pmd_mlx5_flow_engine_mode). 221 * @param flags 222 * Mode specific flags (see RTE_PMD_MLX5_FLOW_ENGINE_FLAG_*). 223 * @return 224 * Positive value on success, -rte_errno value on error: 225 * - (> 0) Number of switched devices. 226 * - (-EINVAL) if error happen and rollback internally. 227 * - (-EPERM) if operation failed and can't recover. 228 */ 229 __rte_experimental 230 int rte_pmd_mlx5_flow_engine_set_mode(enum rte_pmd_mlx5_flow_engine_mode mode, uint32_t flags); 231 232 /** 233 * User configuration structure using to create parser for single GENEVE TLV option. 234 */ 235 struct rte_pmd_mlx5_geneve_tlv { 236 /** 237 * The class of the GENEVE TLV option. 238 * Relevant only when 'match_on_class_mode' is 1. 239 */ 240 rte_be16_t option_class; 241 /** 242 * The type of the GENEVE TLV option. 243 * This field is the identifier of the option. 244 */ 245 uint8_t option_type; 246 /** 247 * The length of the GENEVE TLV option data excluding the option header 248 * in DW granularity. 249 */ 250 uint8_t option_len; 251 /** 252 * Indicator about class field role in this option: 253 * 0 - class is ignored. 254 * 1 - class is fixed (the class defines the option along with the type). 255 * 2 - class matching per flow. 256 */ 257 uint8_t match_on_class_mode; 258 /** 259 * The offset of the first sample in DW granularity. 260 * This offset is relative to first of option data. 261 * The 'match_data_mask' corresponds to option data since this offset. 262 */ 263 uint8_t offset; 264 /** 265 * The number of DW to sample. 266 * This field describes the length of 'match_data_mask' in DW 267 * granularity. 268 */ 269 uint8_t sample_len; 270 /** 271 * Array of DWs which each bit marks if this bit should be sampled. 272 * Each nonzero DW consumes one DW from maximum 7 DW in total. 273 */ 274 rte_be32_t *match_data_mask; 275 }; 276 277 /** 278 * Creates GENEVE TLV parser for the selected port. 279 * This function must be called before first use of GENEVE option. 280 * 281 * This API is port oriented, but the configuration is done once for all ports 282 * under the same physical device. Each port should call this API before using 283 * GENEVE OPT item, but it must use the same options in the same order inside 284 * the list. 285 * 286 * Each physical device has 7 DWs for GENEVE TLV options. Each nonzero element 287 * in 'match_data_mask' array consumes one DW, and choosing matchable mode for 288 * class consumes additional one. 289 * Calling this API for second port under same physical device doesn't consume 290 * more DW, it uses same configuration. 291 * 292 * @param[in] port_id 293 * The port identifier of the Ethernet device. 294 * @param[in] tlv_list 295 * A list of GENEVE TLV options to create parser for them. 296 * @param[in] nb_options 297 * The number of options in TLV list. 298 * 299 * @return 300 * A pointer to TLV handle on success, NULL otherwise and rte_errno is set. 301 * Possible values for rte_errno: 302 * - ENOMEM - not enough memory to create GENEVE TLV parser. 303 * - EEXIST - this port already has GENEVE TLV parser or another port under 304 * same physical device has already prepared a different parser. 305 * - EINVAL - invalid GENEVE TLV requested. 306 * - ENODEV - there is no Ethernet device for this port id. 307 * - ENOTSUP - the port doesn't support GENEVE TLV parsing. 308 */ 309 __rte_experimental 310 void * 311 rte_pmd_mlx5_create_geneve_tlv_parser(uint16_t port_id, 312 const struct rte_pmd_mlx5_geneve_tlv tlv_list[], 313 uint8_t nb_options); 314 315 /** 316 * Destroy GENEVE TLV parser for the selected port. 317 * This function must be called after last use of GENEVE option and before port 318 * closing. 319 * 320 * @param[in] handle 321 * Handle for the GENEVE TLV parser object to be destroyed. 322 * 323 * @return 324 * 0 on success, a negative errno value otherwise and rte_errno is set. 325 * Possible values for rte_errno: 326 * - EINVAL - invalid handle. 327 * - ENOENT - there is no valid GENEVE TLV parser in this handle. 328 * - EBUSY - one of options is in used by template table. 329 */ 330 __rte_experimental 331 int 332 rte_pmd_mlx5_destroy_geneve_tlv_parser(void *handle); 333 334 #ifdef __cplusplus 335 } 336 #endif 337 338 #endif /* RTE_PMD_PRIVATE_MLX5_H_ */ 339