1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright 2020 Mellanox Technologies, Ltd 3 */ 4 5 #include <stddef.h> 6 #include <errno.h> 7 #include <stdbool.h> 8 #include <string.h> 9 #include <stdint.h> 10 #include <sys/queue.h> 11 12 #include <rte_malloc.h> 13 #include <rte_common.h> 14 #include <rte_eal_paging.h> 15 16 #include <mlx5_glue.h> 17 #include <mlx5_devx_cmds.h> 18 #include <mlx5_common_devx.h> 19 #include <mlx5_malloc.h> 20 21 #include "mlx5.h" 22 #include "mlx5_common_os.h" 23 #include "mlx5_tx.h" 24 #include "mlx5_rx.h" 25 #include "mlx5_utils.h" 26 #include "mlx5_devx.h" 27 #include "mlx5_flow.h" 28 #include "mlx5_flow_os.h" 29 30 /** 31 * Modify RQ vlan stripping offload 32 * 33 * @param rxq 34 * Rx queue. 35 * @param on 36 * Enable/disable VLAN stripping. 37 * 38 * @return 39 * 0 on success, non-0 otherwise 40 */ 41 static int 42 mlx5_rxq_obj_modify_rq_vlan_strip(struct mlx5_rxq_priv *rxq, int on) 43 { 44 struct mlx5_devx_modify_rq_attr rq_attr; 45 46 memset(&rq_attr, 0, sizeof(rq_attr)); 47 rq_attr.rq_state = MLX5_RQC_STATE_RDY; 48 rq_attr.state = MLX5_RQC_STATE_RDY; 49 rq_attr.vsd = (on ? 0 : 1); 50 rq_attr.modify_bitmask = MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_VSD; 51 return mlx5_devx_cmd_modify_rq(rxq->devx_rq.rq, &rq_attr); 52 } 53 54 /** 55 * Modify RQ using DevX API. 56 * 57 * @param rxq 58 * DevX rx queue. 59 * @param type 60 * Type of change queue state. 61 * 62 * @return 63 * 0 on success, a negative errno value otherwise and rte_errno is set. 64 */ 65 int 66 mlx5_devx_modify_rq(struct mlx5_rxq_priv *rxq, uint8_t type) 67 { 68 struct mlx5_devx_modify_rq_attr rq_attr; 69 70 memset(&rq_attr, 0, sizeof(rq_attr)); 71 switch (type) { 72 case MLX5_RXQ_MOD_ERR2RST: 73 rq_attr.rq_state = MLX5_RQC_STATE_ERR; 74 rq_attr.state = MLX5_RQC_STATE_RST; 75 break; 76 case MLX5_RXQ_MOD_RST2RDY: 77 rq_attr.rq_state = MLX5_RQC_STATE_RST; 78 rq_attr.state = MLX5_RQC_STATE_RDY; 79 if (rxq->lwm) { 80 rq_attr.modify_bitmask |= 81 MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_WQ_LWM; 82 rq_attr.lwm = rxq->lwm; 83 } 84 break; 85 case MLX5_RXQ_MOD_RDY2ERR: 86 rq_attr.rq_state = MLX5_RQC_STATE_RDY; 87 rq_attr.state = MLX5_RQC_STATE_ERR; 88 break; 89 case MLX5_RXQ_MOD_RDY2RST: 90 rq_attr.rq_state = MLX5_RQC_STATE_RDY; 91 rq_attr.state = MLX5_RQC_STATE_RST; 92 break; 93 case MLX5_RXQ_MOD_RDY2RDY: 94 rq_attr.rq_state = MLX5_RQC_STATE_RDY; 95 rq_attr.state = MLX5_RQC_STATE_RDY; 96 rq_attr.modify_bitmask |= MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_WQ_LWM; 97 rq_attr.lwm = rxq->lwm; 98 break; 99 default: 100 break; 101 } 102 if (rxq->ctrl->is_hairpin) 103 return mlx5_devx_cmd_modify_rq(rxq->ctrl->obj->rq, &rq_attr); 104 return mlx5_devx_cmd_modify_rq(rxq->devx_rq.rq, &rq_attr); 105 } 106 107 /** 108 * Modify SQ using DevX API. 109 * 110 * @param txq_obj 111 * DevX Tx queue object. 112 * @param type 113 * Type of change queue state. 114 * @param dev_port 115 * Unnecessary. 116 * 117 * @return 118 * 0 on success, a negative errno value otherwise and rte_errno is set. 119 */ 120 int 121 mlx5_txq_devx_modify(struct mlx5_txq_obj *obj, enum mlx5_txq_modify_type type, 122 uint8_t dev_port) 123 { 124 struct mlx5_devx_modify_sq_attr msq_attr = { 0 }; 125 int ret; 126 127 if (type != MLX5_TXQ_MOD_RST2RDY) { 128 /* Change queue state to reset. */ 129 if (type == MLX5_TXQ_MOD_ERR2RDY) 130 msq_attr.sq_state = MLX5_SQC_STATE_ERR; 131 else 132 msq_attr.sq_state = MLX5_SQC_STATE_RDY; 133 msq_attr.state = MLX5_SQC_STATE_RST; 134 ret = mlx5_devx_cmd_modify_sq(obj->sq_obj.sq, &msq_attr); 135 if (ret) { 136 DRV_LOG(ERR, "Cannot change the Tx SQ state to RESET" 137 " %s", strerror(errno)); 138 rte_errno = errno; 139 return ret; 140 } 141 } 142 if (type != MLX5_TXQ_MOD_RDY2RST) { 143 /* Change queue state to ready. */ 144 msq_attr.sq_state = MLX5_SQC_STATE_RST; 145 msq_attr.state = MLX5_SQC_STATE_RDY; 146 ret = mlx5_devx_cmd_modify_sq(obj->sq_obj.sq, &msq_attr); 147 if (ret) { 148 DRV_LOG(ERR, "Cannot change the Tx SQ state to READY" 149 " %s", strerror(errno)); 150 rte_errno = errno; 151 return ret; 152 } 153 } 154 /* 155 * The dev_port variable is relevant only in Verbs API, and there is a 156 * pointer that points to this function and a parallel function in verbs 157 * intermittently, so they should have the same parameters. 158 */ 159 (void)dev_port; 160 return 0; 161 } 162 163 /** 164 * Release an Rx DevX queue object. 165 * 166 * @param rxq 167 * DevX Rx queue. 168 */ 169 static void 170 mlx5_rxq_devx_obj_release(struct mlx5_rxq_priv *rxq) 171 { 172 struct mlx5_rxq_obj *rxq_obj = rxq->ctrl->obj; 173 174 if (rxq_obj == NULL) 175 return; 176 if (rxq_obj->rxq_ctrl->is_hairpin) { 177 if (rxq_obj->rq == NULL) 178 return; 179 mlx5_devx_modify_rq(rxq, MLX5_RXQ_MOD_RDY2RST); 180 claim_zero(mlx5_devx_cmd_destroy(rxq_obj->rq)); 181 } else { 182 if (rxq->devx_rq.rq == NULL) 183 return; 184 mlx5_devx_rq_destroy(&rxq->devx_rq); 185 if (rxq->devx_rq.rmp != NULL && rxq->devx_rq.rmp->ref_cnt > 0) 186 return; 187 mlx5_devx_cq_destroy(&rxq_obj->cq_obj); 188 memset(&rxq_obj->cq_obj, 0, sizeof(rxq_obj->cq_obj)); 189 if (rxq_obj->devx_channel) { 190 mlx5_os_devx_destroy_event_channel 191 (rxq_obj->devx_channel); 192 rxq_obj->devx_channel = NULL; 193 } 194 } 195 rxq->ctrl->started = false; 196 } 197 198 /** 199 * Get event for an Rx DevX queue object. 200 * 201 * @param rxq_obj 202 * DevX Rx queue object. 203 * 204 * @return 205 * 0 on success, a negative errno value otherwise and rte_errno is set. 206 */ 207 static int 208 mlx5_rx_devx_get_event(struct mlx5_rxq_obj *rxq_obj) 209 { 210 #ifdef HAVE_IBV_DEVX_EVENT 211 union { 212 struct mlx5dv_devx_async_event_hdr event_resp; 213 uint8_t buf[sizeof(struct mlx5dv_devx_async_event_hdr) + 128]; 214 } out; 215 int ret = mlx5_glue->devx_get_event(rxq_obj->devx_channel, 216 &out.event_resp, 217 sizeof(out.buf)); 218 219 if (ret < 0) { 220 rte_errno = errno; 221 return -rte_errno; 222 } 223 if (out.event_resp.cookie != (uint64_t)(uintptr_t)rxq_obj->cq_obj.cq) { 224 rte_errno = EINVAL; 225 return -rte_errno; 226 } 227 return 0; 228 #else 229 (void)rxq_obj; 230 rte_errno = ENOTSUP; 231 return -rte_errno; 232 #endif /* HAVE_IBV_DEVX_EVENT */ 233 } 234 235 /** 236 * Get LWM event for shared context, return the correct port/rxq for this event. 237 * 238 * @param priv 239 * Mlx5_priv object. 240 * @param rxq_idx [out] 241 * Which rxq gets this event. 242 * @param port_id [out] 243 * Which port gets this event. 244 * 245 * @return 246 * 0 on success, a negative errno value otherwise and rte_errno is set. 247 */ 248 static int 249 mlx5_rx_devx_get_event_lwm(struct mlx5_priv *priv, int *rxq_idx, int *port_id) 250 { 251 #ifdef HAVE_IBV_DEVX_EVENT 252 union { 253 struct mlx5dv_devx_async_event_hdr event_resp; 254 uint8_t buf[sizeof(struct mlx5dv_devx_async_event_hdr) + 128]; 255 } out; 256 int ret; 257 258 memset(&out, 0, sizeof(out)); 259 ret = mlx5_glue->devx_get_event(priv->sh->devx_channel_lwm, 260 &out.event_resp, 261 sizeof(out.buf)); 262 if (ret < 0) { 263 rte_errno = errno; 264 DRV_LOG(WARNING, "%s err\n", __func__); 265 return -rte_errno; 266 } 267 *port_id = (((uint32_t)out.event_resp.cookie) >> 268 LWM_COOKIE_PORTID_OFFSET) & LWM_COOKIE_PORTID_MASK; 269 *rxq_idx = (((uint32_t)out.event_resp.cookie) >> 270 LWM_COOKIE_RXQID_OFFSET) & LWM_COOKIE_RXQID_MASK; 271 return 0; 272 #else 273 (void)priv; 274 (void)rxq_idx; 275 (void)port_id; 276 rte_errno = ENOTSUP; 277 return -rte_errno; 278 #endif /* HAVE_IBV_DEVX_EVENT */ 279 } 280 281 /** 282 * Create a RQ object using DevX. 283 * 284 * @param rxq 285 * Pointer to Rx queue. 286 * 287 * @return 288 * 0 on success, a negative errno value otherwise and rte_errno is set. 289 */ 290 static int 291 mlx5_rxq_create_devx_rq_resources(struct mlx5_rxq_priv *rxq) 292 { 293 struct mlx5_priv *priv = rxq->priv; 294 struct mlx5_common_device *cdev = priv->sh->cdev; 295 struct mlx5_rxq_ctrl *rxq_ctrl = rxq->ctrl; 296 struct mlx5_rxq_data *rxq_data = &rxq->ctrl->rxq; 297 struct mlx5_devx_create_rq_attr rq_attr = { 0 }; 298 uint16_t log_desc_n = rxq_data->elts_n - rxq_data->sges_n; 299 uint32_t wqe_size, log_wqe_size; 300 301 /* Fill RQ attributes. */ 302 rq_attr.mem_rq_type = MLX5_RQC_MEM_RQ_TYPE_MEMORY_RQ_INLINE; 303 rq_attr.flush_in_error_en = 1; 304 rq_attr.vsd = (rxq_data->vlan_strip) ? 0 : 1; 305 rq_attr.cqn = rxq_ctrl->obj->cq_obj.cq->id; 306 rq_attr.scatter_fcs = (rxq_data->crc_present) ? 1 : 0; 307 rq_attr.ts_format = 308 mlx5_ts_format_conv(cdev->config.hca_attr.rq_ts_format); 309 /* Fill WQ attributes for this RQ. */ 310 if (mlx5_rxq_mprq_enabled(rxq_data)) { 311 rq_attr.wq_attr.wq_type = MLX5_WQ_TYPE_CYCLIC_STRIDING_RQ; 312 /* 313 * Number of strides in each WQE: 314 * 512*2^single_wqe_log_num_of_strides. 315 */ 316 rq_attr.wq_attr.single_wqe_log_num_of_strides = 317 rxq_data->log_strd_num - 318 MLX5_MIN_SINGLE_WQE_LOG_NUM_STRIDES; 319 /* Stride size = (2^single_stride_log_num_of_bytes)*64B. */ 320 rq_attr.wq_attr.single_stride_log_num_of_bytes = 321 rxq_data->log_strd_sz - 322 MLX5_MIN_SINGLE_STRIDE_LOG_NUM_BYTES; 323 wqe_size = sizeof(struct mlx5_wqe_mprq); 324 } else { 325 rq_attr.wq_attr.wq_type = MLX5_WQ_TYPE_CYCLIC; 326 wqe_size = sizeof(struct mlx5_wqe_data_seg); 327 } 328 log_wqe_size = log2above(wqe_size) + rxq_data->sges_n; 329 wqe_size = 1 << log_wqe_size; /* round up power of two.*/ 330 rq_attr.wq_attr.log_wq_stride = log_wqe_size; 331 rq_attr.wq_attr.log_wq_sz = log_desc_n; 332 rq_attr.wq_attr.end_padding_mode = priv->config.hw_padding ? 333 MLX5_WQ_END_PAD_MODE_ALIGN : 334 MLX5_WQ_END_PAD_MODE_NONE; 335 rq_attr.wq_attr.pd = cdev->pdn; 336 rq_attr.counter_set_id = priv->counter_set_id; 337 rq_attr.delay_drop_en = rxq_data->delay_drop; 338 rq_attr.user_index = rte_cpu_to_be_16(priv->dev_data->port_id); 339 if (rxq_data->shared) /* Create RMP based RQ. */ 340 rxq->devx_rq.rmp = &rxq_ctrl->obj->devx_rmp; 341 /* Create RQ using DevX API. */ 342 return mlx5_devx_rq_create(cdev->ctx, &rxq->devx_rq, wqe_size, 343 log_desc_n, &rq_attr, rxq_ctrl->socket); 344 } 345 346 /** 347 * Create a DevX CQ object for an Rx queue. 348 * 349 * @param rxq 350 * Pointer to Rx queue. 351 * 352 * @return 353 * 0 on success, a negative errno value otherwise and rte_errno is set. 354 */ 355 static int 356 mlx5_rxq_create_devx_cq_resources(struct mlx5_rxq_priv *rxq) 357 { 358 struct mlx5_devx_cq *cq_obj = 0; 359 struct mlx5_devx_cq_attr cq_attr = { 0 }; 360 struct mlx5_priv *priv = rxq->priv; 361 struct mlx5_dev_ctx_shared *sh = priv->sh; 362 uint16_t port_id = priv->dev_data->port_id; 363 struct mlx5_rxq_ctrl *rxq_ctrl = rxq->ctrl; 364 struct mlx5_rxq_data *rxq_data = &rxq_ctrl->rxq; 365 unsigned int cqe_n = mlx5_rxq_cqe_num(rxq_data); 366 uint32_t log_cqe_n; 367 uint16_t event_nums[1] = { 0 }; 368 int ret = 0; 369 370 if (rxq_ctrl->started) 371 return 0; 372 if (priv->config.cqe_comp && !rxq_data->hw_timestamp && 373 !rxq_data->lro) { 374 cq_attr.cqe_comp_en = 1u; 375 cq_attr.cqe_comp_layout = priv->config.enh_cqe_comp; 376 rxq_data->cqe_comp_layout = cq_attr.cqe_comp_layout; 377 rxq_data->mcqe_format = priv->config.cqe_comp_fmt; 378 rxq_data->byte_mask = UINT32_MAX; 379 switch (priv->config.cqe_comp_fmt) { 380 case MLX5_CQE_RESP_FORMAT_HASH: 381 /* fallthrough */ 382 case MLX5_CQE_RESP_FORMAT_CSUM: 383 /* 384 * Select CSUM miniCQE format only for non-vectorized 385 * MPRQ Rx burst, use HASH miniCQE format for others. 386 */ 387 if (mlx5_rxq_check_vec_support(rxq_data) < 0 && 388 mlx5_rxq_mprq_enabled(rxq_data)) 389 cq_attr.mini_cqe_res_format = 390 MLX5_CQE_RESP_FORMAT_CSUM_STRIDX; 391 else 392 cq_attr.mini_cqe_res_format = 393 MLX5_CQE_RESP_FORMAT_HASH; 394 rxq_data->mcqe_format = cq_attr.mini_cqe_res_format; 395 break; 396 case MLX5_CQE_RESP_FORMAT_FTAG_STRIDX: 397 rxq_data->byte_mask = MLX5_LEN_WITH_MARK_MASK; 398 /* fallthrough */ 399 case MLX5_CQE_RESP_FORMAT_CSUM_STRIDX: 400 cq_attr.mini_cqe_res_format = priv->config.cqe_comp_fmt; 401 break; 402 case MLX5_CQE_RESP_FORMAT_L34H_STRIDX: 403 cq_attr.mini_cqe_res_format = 0; 404 cq_attr.mini_cqe_res_format_ext = 1; 405 break; 406 } 407 DRV_LOG(DEBUG, 408 "Port %u Rx CQE compression is enabled, format %d.", 409 port_id, priv->config.cqe_comp_fmt); 410 /* 411 * For vectorized Rx, it must not be doubled in order to 412 * make cq_ci and rq_ci aligned. 413 */ 414 if (mlx5_rxq_check_vec_support(rxq_data) < 0) 415 cqe_n *= 2; 416 } else if (priv->config.cqe_comp && rxq_data->hw_timestamp) { 417 DRV_LOG(DEBUG, 418 "Port %u Rx CQE compression is disabled for HW timestamp.", 419 port_id); 420 } else if (priv->config.cqe_comp && rxq_data->lro) { 421 DRV_LOG(DEBUG, 422 "Port %u Rx CQE compression is disabled for LRO.", 423 port_id); 424 } 425 cq_attr.uar_page_id = mlx5_os_get_devx_uar_page_id(sh->rx_uar.obj); 426 log_cqe_n = log2above(cqe_n); 427 /* Create CQ using DevX API. */ 428 ret = mlx5_devx_cq_create(sh->cdev->ctx, &rxq_ctrl->obj->cq_obj, 429 log_cqe_n, &cq_attr, sh->numa_node); 430 if (ret) 431 return ret; 432 cq_obj = &rxq_ctrl->obj->cq_obj; 433 rxq_data->cqes = (volatile struct mlx5_cqe (*)[]) 434 (uintptr_t)cq_obj->cqes; 435 rxq_data->cq_db = cq_obj->db_rec; 436 rxq_data->uar_data = sh->rx_uar.cq_db; 437 rxq_data->cqe_n = log_cqe_n; 438 rxq_data->cqn = cq_obj->cq->id; 439 rxq_data->cq_ci = 0; 440 if (rxq_ctrl->obj->devx_channel) { 441 ret = mlx5_os_devx_subscribe_devx_event 442 (rxq_ctrl->obj->devx_channel, 443 cq_obj->cq->obj, 444 sizeof(event_nums), 445 event_nums, 446 (uint64_t)(uintptr_t)cq_obj->cq); 447 if (ret) { 448 DRV_LOG(ERR, "Fail to subscribe CQ to event channel."); 449 ret = errno; 450 mlx5_devx_cq_destroy(cq_obj); 451 memset(cq_obj, 0, sizeof(*cq_obj)); 452 rte_errno = ret; 453 return -ret; 454 } 455 } 456 return 0; 457 } 458 459 /** 460 * Create the Rx hairpin queue object. 461 * 462 * @param rxq 463 * Pointer to Rx queue. 464 * 465 * @return 466 * 0 on success, a negative errno value otherwise and rte_errno is set. 467 */ 468 static int 469 mlx5_rxq_obj_hairpin_new(struct mlx5_rxq_priv *rxq) 470 { 471 uint16_t idx = rxq->idx; 472 struct mlx5_priv *priv = rxq->priv; 473 struct mlx5_hca_attr *hca_attr __rte_unused = &priv->sh->cdev->config.hca_attr; 474 struct mlx5_rxq_ctrl *rxq_ctrl = rxq->ctrl; 475 struct mlx5_devx_create_rq_attr unlocked_attr = { 0 }; 476 struct mlx5_devx_create_rq_attr locked_attr = { 0 }; 477 struct mlx5_rxq_obj *tmpl = rxq_ctrl->obj; 478 uint32_t max_wq_data; 479 480 MLX5_ASSERT(rxq != NULL && rxq->ctrl != NULL && tmpl != NULL); 481 tmpl->rxq_ctrl = rxq_ctrl; 482 unlocked_attr.hairpin = 1; 483 max_wq_data = 484 priv->sh->cdev->config.hca_attr.log_max_hairpin_wq_data_sz; 485 /* Jumbo frames > 9KB should be supported, and more packets. */ 486 if (priv->config.log_hp_size != (uint32_t)MLX5_ARG_UNSET) { 487 if (priv->config.log_hp_size > max_wq_data) { 488 DRV_LOG(ERR, "Total data size %u power of 2 is " 489 "too large for hairpin.", 490 priv->config.log_hp_size); 491 rte_errno = ERANGE; 492 return -rte_errno; 493 } 494 unlocked_attr.wq_attr.log_hairpin_data_sz = priv->config.log_hp_size; 495 } else { 496 unlocked_attr.wq_attr.log_hairpin_data_sz = 497 (max_wq_data < MLX5_HAIRPIN_JUMBO_LOG_SIZE) ? 498 max_wq_data : MLX5_HAIRPIN_JUMBO_LOG_SIZE; 499 } 500 /* Set the packets number to the maximum value for performance. */ 501 unlocked_attr.wq_attr.log_hairpin_num_packets = 502 unlocked_attr.wq_attr.log_hairpin_data_sz - 503 MLX5_HAIRPIN_QUEUE_STRIDE; 504 unlocked_attr.counter_set_id = priv->counter_set_id; 505 rxq_ctrl->rxq.delay_drop = priv->config.hp_delay_drop; 506 unlocked_attr.delay_drop_en = priv->config.hp_delay_drop; 507 unlocked_attr.hairpin_data_buffer_type = 508 MLX5_RQC_HAIRPIN_DATA_BUFFER_TYPE_UNLOCKED_INTERNAL_BUFFER; 509 if (rxq->hairpin_conf.use_locked_device_memory) { 510 /* 511 * It is assumed that configuration is verified against capabilities 512 * during queue setup. 513 */ 514 MLX5_ASSERT(hca_attr->hairpin_data_buffer_locked); 515 rte_memcpy(&locked_attr, &unlocked_attr, sizeof(locked_attr)); 516 locked_attr.hairpin_data_buffer_type = 517 MLX5_RQC_HAIRPIN_DATA_BUFFER_TYPE_LOCKED_INTERNAL_BUFFER; 518 tmpl->rq = mlx5_devx_cmd_create_rq(priv->sh->cdev->ctx, &locked_attr, 519 rxq_ctrl->socket); 520 if (!tmpl->rq && rxq->hairpin_conf.force_memory) { 521 DRV_LOG(ERR, "Port %u Rx hairpin queue %u can't create RQ object" 522 " with locked memory buffer", 523 priv->dev_data->port_id, idx); 524 return -rte_errno; 525 } else if (!tmpl->rq && !rxq->hairpin_conf.force_memory) { 526 DRV_LOG(WARNING, "Port %u Rx hairpin queue %u can't create RQ object" 527 " with locked memory buffer. Falling back to unlocked" 528 " device memory.", 529 priv->dev_data->port_id, idx); 530 rte_errno = 0; 531 goto create_rq_unlocked; 532 } 533 goto create_rq_set_state; 534 } 535 536 create_rq_unlocked: 537 tmpl->rq = mlx5_devx_cmd_create_rq(priv->sh->cdev->ctx, &unlocked_attr, 538 rxq_ctrl->socket); 539 if (!tmpl->rq) { 540 DRV_LOG(ERR, 541 "Port %u Rx hairpin queue %u can't create rq object.", 542 priv->dev_data->port_id, idx); 543 rte_errno = errno; 544 return -rte_errno; 545 } 546 create_rq_set_state: 547 priv->dev_data->rx_queue_state[idx] = RTE_ETH_QUEUE_STATE_HAIRPIN; 548 return 0; 549 } 550 551 /** 552 * Create the Rx queue DevX object. 553 * 554 * @param rxq 555 * Pointer to Rx queue. 556 * 557 * @return 558 * 0 on success, a negative errno value otherwise and rte_errno is set. 559 */ 560 static int 561 mlx5_rxq_devx_obj_new(struct mlx5_rxq_priv *rxq) 562 { 563 struct mlx5_priv *priv = rxq->priv; 564 struct mlx5_rxq_ctrl *rxq_ctrl = rxq->ctrl; 565 struct mlx5_rxq_data *rxq_data = &rxq_ctrl->rxq; 566 struct mlx5_rxq_obj *tmpl = rxq_ctrl->obj; 567 int ret = 0; 568 569 MLX5_ASSERT(rxq_data); 570 MLX5_ASSERT(tmpl); 571 if (rxq_ctrl->is_hairpin) 572 return mlx5_rxq_obj_hairpin_new(rxq); 573 tmpl->rxq_ctrl = rxq_ctrl; 574 if (rxq_ctrl->irq && !rxq_ctrl->started) { 575 int devx_ev_flag = 576 MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA; 577 578 tmpl->devx_channel = mlx5_os_devx_create_event_channel 579 (priv->sh->cdev->ctx, 580 devx_ev_flag); 581 if (!tmpl->devx_channel) { 582 rte_errno = errno; 583 DRV_LOG(ERR, "Failed to create event channel %d.", 584 rte_errno); 585 goto error; 586 } 587 tmpl->fd = mlx5_os_get_devx_channel_fd(tmpl->devx_channel); 588 } 589 /* Create CQ using DevX API. */ 590 ret = mlx5_rxq_create_devx_cq_resources(rxq); 591 if (ret) { 592 DRV_LOG(ERR, "Failed to create CQ."); 593 goto error; 594 } 595 rxq_data->delay_drop = priv->config.std_delay_drop; 596 /* Create RQ using DevX API. */ 597 ret = mlx5_rxq_create_devx_rq_resources(rxq); 598 if (ret) { 599 DRV_LOG(ERR, "Port %u Rx queue %u RQ creation failure.", 600 priv->dev_data->port_id, rxq->idx); 601 rte_errno = ENOMEM; 602 goto error; 603 } 604 /* Change queue state to ready. */ 605 ret = mlx5_devx_modify_rq(rxq, MLX5_RXQ_MOD_RST2RDY); 606 if (ret) 607 goto error; 608 if (!rxq_data->shared) { 609 rxq_data->wqes = (void *)(uintptr_t)rxq->devx_rq.wq.umem_buf; 610 rxq_data->rq_db = (uint32_t *)(uintptr_t)rxq->devx_rq.wq.db_rec; 611 } else if (!rxq_ctrl->started) { 612 rxq_data->wqes = (void *)(uintptr_t)tmpl->devx_rmp.wq.umem_buf; 613 rxq_data->rq_db = 614 (uint32_t *)(uintptr_t)tmpl->devx_rmp.wq.db_rec; 615 } 616 if (!rxq_ctrl->started) { 617 mlx5_rxq_initialize(rxq_data); 618 rxq_ctrl->wqn = rxq->devx_rq.rq->id; 619 } 620 priv->dev_data->rx_queue_state[rxq->idx] = RTE_ETH_QUEUE_STATE_STARTED; 621 return 0; 622 error: 623 ret = rte_errno; /* Save rte_errno before cleanup. */ 624 mlx5_rxq_devx_obj_release(rxq); 625 rte_errno = ret; /* Restore rte_errno. */ 626 return -rte_errno; 627 } 628 629 /** 630 * Prepare RQT attribute structure for DevX RQT API. 631 * 632 * @param dev 633 * Pointer to Ethernet device. 634 * @param log_n 635 * Log of number of queues in the array. 636 * @param queues 637 * List of RX queue indices or NULL, in which case 638 * the attribute will be filled by drop queue ID. 639 * @param queues_n 640 * Size of @p queues array or 0 if it is NULL. 641 * @param ind_tbl 642 * DevX indirection table object. 643 * 644 * @return 645 * The RQT attr object initialized, NULL otherwise and rte_errno is set. 646 */ 647 static struct mlx5_devx_rqt_attr * 648 mlx5_devx_ind_table_create_rqt_attr(struct rte_eth_dev *dev, 649 const unsigned int log_n, 650 const uint16_t *queues, 651 const uint32_t queues_n) 652 { 653 struct mlx5_priv *priv = dev->data->dev_private; 654 struct mlx5_devx_rqt_attr *rqt_attr = NULL; 655 const unsigned int rqt_n = 1 << log_n; 656 unsigned int i, j; 657 658 rqt_attr = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*rqt_attr) + 659 rqt_n * sizeof(uint32_t), 0, SOCKET_ID_ANY); 660 if (!rqt_attr) { 661 DRV_LOG(ERR, "Port %u cannot allocate RQT resources.", 662 dev->data->port_id); 663 rte_errno = ENOMEM; 664 return NULL; 665 } 666 rqt_attr->rqt_max_size = priv->sh->dev_cap.ind_table_max_size; 667 rqt_attr->rqt_actual_size = rqt_n; 668 if (queues == NULL) { 669 for (i = 0; i < rqt_n; i++) 670 rqt_attr->rq_list[i] = 671 priv->drop_queue.rxq->devx_rq.rq->id; 672 return rqt_attr; 673 } 674 for (i = 0; i != queues_n; ++i) { 675 if (mlx5_is_external_rxq(dev, queues[i])) { 676 struct mlx5_external_rxq *ext_rxq = 677 mlx5_ext_rxq_get(dev, queues[i]); 678 679 rqt_attr->rq_list[i] = ext_rxq->hw_id; 680 } else { 681 struct mlx5_rxq_priv *rxq = 682 mlx5_rxq_get(dev, queues[i]); 683 684 MLX5_ASSERT(rxq != NULL); 685 if (rxq->ctrl->is_hairpin) 686 rqt_attr->rq_list[i] = rxq->ctrl->obj->rq->id; 687 else 688 rqt_attr->rq_list[i] = rxq->devx_rq.rq->id; 689 } 690 } 691 MLX5_ASSERT(i > 0); 692 for (j = 0; i != rqt_n; ++j, ++i) 693 rqt_attr->rq_list[i] = rqt_attr->rq_list[j]; 694 return rqt_attr; 695 } 696 697 /** 698 * Create RQT using DevX API as a filed of indirection table. 699 * 700 * @param dev 701 * Pointer to Ethernet device. 702 * @param log_n 703 * Log of number of queues in the array. 704 * @param ind_tbl 705 * DevX indirection table object. 706 * 707 * @return 708 * 0 on success, a negative errno value otherwise and rte_errno is set. 709 */ 710 static int 711 mlx5_devx_ind_table_new(struct rte_eth_dev *dev, const unsigned int log_n, 712 struct mlx5_ind_table_obj *ind_tbl) 713 { 714 struct mlx5_priv *priv = dev->data->dev_private; 715 struct mlx5_devx_rqt_attr *rqt_attr = NULL; 716 const uint16_t *queues = dev->data->dev_started ? ind_tbl->queues : 717 NULL; 718 719 MLX5_ASSERT(ind_tbl); 720 rqt_attr = mlx5_devx_ind_table_create_rqt_attr(dev, log_n, queues, 721 ind_tbl->queues_n); 722 if (!rqt_attr) 723 return -rte_errno; 724 ind_tbl->rqt = mlx5_devx_cmd_create_rqt(priv->sh->cdev->ctx, rqt_attr); 725 mlx5_free(rqt_attr); 726 if (!ind_tbl->rqt) { 727 DRV_LOG(ERR, "Port %u cannot create DevX RQT.", 728 dev->data->port_id); 729 rte_errno = errno; 730 return -rte_errno; 731 } 732 return 0; 733 } 734 735 /** 736 * Modify RQT using DevX API as a filed of indirection table. 737 * 738 * @param dev 739 * Pointer to Ethernet device. 740 * @param log_n 741 * Log of number of queues in the array. 742 * @param ind_tbl 743 * DevX indirection table object. 744 * 745 * @return 746 * 0 on success, a negative errno value otherwise and rte_errno is set. 747 */ 748 static int 749 mlx5_devx_ind_table_modify(struct rte_eth_dev *dev, const unsigned int log_n, 750 const uint16_t *queues, const uint32_t queues_n, 751 struct mlx5_ind_table_obj *ind_tbl) 752 { 753 int ret = 0; 754 struct mlx5_devx_rqt_attr *rqt_attr = NULL; 755 756 MLX5_ASSERT(ind_tbl); 757 rqt_attr = mlx5_devx_ind_table_create_rqt_attr(dev, log_n, 758 queues, 759 queues_n); 760 if (!rqt_attr) 761 return -rte_errno; 762 ret = mlx5_devx_cmd_modify_rqt(ind_tbl->rqt, rqt_attr); 763 mlx5_free(rqt_attr); 764 if (ret) 765 DRV_LOG(ERR, "Port %u cannot modify DevX RQT.", 766 dev->data->port_id); 767 return ret; 768 } 769 770 /** 771 * Destroy the DevX RQT object. 772 * 773 * @param ind_table 774 * Indirection table to release. 775 */ 776 static void 777 mlx5_devx_ind_table_destroy(struct mlx5_ind_table_obj *ind_tbl) 778 { 779 claim_zero(mlx5_devx_cmd_destroy(ind_tbl->rqt)); 780 } 781 782 /** 783 * Set TIR attribute struct with relevant input values. 784 * 785 * @param[in] dev 786 * Pointer to Ethernet device. 787 * @param[in] rss_key 788 * RSS key for the Rx hash queue. 789 * @param[in] hash_fields 790 * Verbs protocol hash field to make the RSS on. 791 * @param[in] ind_tbl 792 * Indirection table for TIR. If table queues array is NULL, 793 * a TIR for drop queue is assumed. 794 * @param[in] tunnel 795 * Tunnel type. 796 * @param[out] tir_attr 797 * Parameters structure for TIR creation/modification. 798 * 799 * @return 800 * The Verbs/DevX object initialised index, 0 otherwise and rte_errno is set. 801 */ 802 static void 803 mlx5_devx_tir_attr_set(struct rte_eth_dev *dev, const uint8_t *rss_key, 804 uint64_t hash_fields, 805 const struct mlx5_ind_table_obj *ind_tbl, 806 int tunnel, struct mlx5_devx_tir_attr *tir_attr) 807 { 808 struct mlx5_priv *priv = dev->data->dev_private; 809 bool is_hairpin; 810 bool lro = false; 811 uint32_t i; 812 813 /* NULL queues designate drop queue. */ 814 if (ind_tbl->queues == NULL) { 815 is_hairpin = priv->drop_queue.rxq->ctrl->is_hairpin; 816 } else if (mlx5_is_external_rxq(dev, ind_tbl->queues[0])) { 817 /* External RxQ supports neither Hairpin nor LRO. */ 818 is_hairpin = false; 819 } else { 820 is_hairpin = mlx5_rxq_is_hairpin(dev, ind_tbl->queues[0]); 821 lro = true; 822 /* Enable TIR LRO only if all the queues were configured for. */ 823 for (i = 0; i < ind_tbl->queues_n; ++i) { 824 struct mlx5_rxq_data *rxq_i = 825 mlx5_rxq_data_get(dev, ind_tbl->queues[i]); 826 827 if (rxq_i != NULL && !rxq_i->lro) { 828 lro = false; 829 break; 830 } 831 } 832 } 833 memset(tir_attr, 0, sizeof(*tir_attr)); 834 tir_attr->disp_type = MLX5_TIRC_DISP_TYPE_INDIRECT; 835 tir_attr->rx_hash_fn = MLX5_RX_HASH_FN_TOEPLITZ; 836 tir_attr->tunneled_offload_en = !!tunnel; 837 /* If needed, translate hash_fields bitmap to PRM format. */ 838 if (hash_fields) { 839 struct mlx5_rx_hash_field_select *rx_hash_field_select = 840 #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT 841 hash_fields & IBV_RX_HASH_INNER ? 842 &tir_attr->rx_hash_field_selector_inner : 843 #endif 844 &tir_attr->rx_hash_field_selector_outer; 845 /* 1 bit: 0: IPv4, 1: IPv6. */ 846 rx_hash_field_select->l3_prot_type = 847 !!(hash_fields & MLX5_IPV6_IBV_RX_HASH); 848 /* 1 bit: 0: TCP, 1: UDP. */ 849 rx_hash_field_select->l4_prot_type = 850 !!(hash_fields & MLX5_UDP_IBV_RX_HASH); 851 /* Bitmask which sets which fields to use in RX Hash. */ 852 rx_hash_field_select->selected_fields = 853 ((!!(hash_fields & MLX5_L3_SRC_IBV_RX_HASH)) << 854 MLX5_RX_HASH_FIELD_SELECT_SELECTED_FIELDS_SRC_IP) | 855 (!!(hash_fields & MLX5_L3_DST_IBV_RX_HASH)) << 856 MLX5_RX_HASH_FIELD_SELECT_SELECTED_FIELDS_DST_IP | 857 (!!(hash_fields & MLX5_L4_SRC_IBV_RX_HASH)) << 858 MLX5_RX_HASH_FIELD_SELECT_SELECTED_FIELDS_L4_SPORT | 859 (!!(hash_fields & MLX5_L4_DST_IBV_RX_HASH)) << 860 MLX5_RX_HASH_FIELD_SELECT_SELECTED_FIELDS_L4_DPORT | 861 (!!(hash_fields & IBV_RX_HASH_IPSEC_SPI)) << 862 MLX5_RX_HASH_FIELD_SELECT_SELECTED_FIELDS_IPSEC_SPI; 863 } 864 if (is_hairpin) 865 tir_attr->transport_domain = priv->sh->td->id; 866 else 867 tir_attr->transport_domain = priv->sh->tdn; 868 memcpy(tir_attr->rx_hash_toeplitz_key, rss_key, MLX5_RSS_HASH_KEY_LEN); 869 tir_attr->indirect_table = ind_tbl->rqt->id; 870 if (dev->data->dev_conf.lpbk_mode) 871 tir_attr->self_lb_block = MLX5_TIRC_SELF_LB_BLOCK_BLOCK_UNICAST; 872 if (lro) { 873 MLX5_ASSERT(priv->sh->config.lro_allowed); 874 tir_attr->lro_timeout_period_usecs = priv->config.lro_timeout; 875 tir_attr->lro_max_msg_sz = 876 priv->max_lro_msg_size / MLX5_LRO_SEG_CHUNK_SIZE; 877 tir_attr->lro_enable_mask = 878 MLX5_TIRC_LRO_ENABLE_MASK_IPV4_LRO | 879 MLX5_TIRC_LRO_ENABLE_MASK_IPV6_LRO; 880 } 881 } 882 883 /** 884 * Create an Rx Hash queue. 885 * 886 * @param dev 887 * Pointer to Ethernet device. 888 * @param hrxq 889 * Pointer to Rx Hash queue. 890 * @param tunnel 891 * Tunnel type. 892 * 893 * @return 894 * 0 on success, a negative errno value otherwise and rte_errno is set. 895 */ 896 static int 897 mlx5_devx_hrxq_new(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq, 898 int tunnel __rte_unused) 899 { 900 struct mlx5_priv *priv = dev->data->dev_private; 901 struct mlx5_devx_tir_attr tir_attr = {0}; 902 int err; 903 904 mlx5_devx_tir_attr_set(dev, hrxq->rss_key, hrxq->hash_fields, 905 hrxq->ind_table, tunnel, &tir_attr); 906 hrxq->tir = mlx5_devx_cmd_create_tir(priv->sh->cdev->ctx, &tir_attr); 907 if (!hrxq->tir) { 908 DRV_LOG(ERR, "Port %u cannot create DevX TIR.", 909 dev->data->port_id); 910 rte_errno = errno; 911 goto error; 912 } 913 #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H) 914 #ifdef HAVE_MLX5_HWS_SUPPORT 915 if (hrxq->hws_flags) { 916 hrxq->action = mlx5dr_action_create_dest_tir 917 (priv->dr_ctx, 918 (struct mlx5dr_devx_obj *)hrxq->tir, hrxq->hws_flags, true); 919 if (!hrxq->action) 920 goto error; 921 return 0; 922 } 923 #endif 924 if (mlx5_flow_os_create_flow_action_dest_devx_tir(hrxq->tir, 925 &hrxq->action)) { 926 rte_errno = errno; 927 goto error; 928 } 929 #endif 930 return 0; 931 error: 932 err = rte_errno; /* Save rte_errno before cleanup. */ 933 if (hrxq->tir) 934 claim_zero(mlx5_devx_cmd_destroy(hrxq->tir)); 935 rte_errno = err; /* Restore rte_errno. */ 936 return -rte_errno; 937 } 938 939 /** 940 * Destroy a DevX TIR object. 941 * 942 * @param hrxq 943 * Hash Rx queue to release its tir. 944 */ 945 static void 946 mlx5_devx_tir_destroy(struct mlx5_hrxq *hrxq) 947 { 948 claim_zero(mlx5_devx_cmd_destroy(hrxq->tir)); 949 } 950 951 /** 952 * Modify an Rx Hash queue configuration. 953 * 954 * @param dev 955 * Pointer to Ethernet device. 956 * @param hrxq 957 * Hash Rx queue to modify. 958 * @param rss_key 959 * RSS key for the Rx hash queue. 960 * @param hash_fields 961 * Verbs protocol hash field to make the RSS on. 962 * @param[in] ind_tbl 963 * Indirection table for TIR. 964 * 965 * @return 966 * 0 on success, a negative errno value otherwise and rte_errno is set. 967 */ 968 static int 969 mlx5_devx_hrxq_modify(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq, 970 const uint8_t *rss_key, 971 uint64_t hash_fields, 972 const struct mlx5_ind_table_obj *ind_tbl) 973 { 974 struct mlx5_devx_modify_tir_attr modify_tir = {0}; 975 976 /* 977 * untested for modification fields: 978 * - rx_hash_symmetric not set in hrxq_new(), 979 * - rx_hash_fn set hard-coded in hrxq_new(), 980 * - lro_xxx not set after rxq setup 981 */ 982 if (ind_tbl != hrxq->ind_table) 983 modify_tir.modify_bitmask |= 984 MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_INDIRECT_TABLE; 985 if (hash_fields != hrxq->hash_fields || 986 memcmp(hrxq->rss_key, rss_key, MLX5_RSS_HASH_KEY_LEN)) 987 modify_tir.modify_bitmask |= 988 MLX5_MODIFY_TIR_IN_MODIFY_BITMASK_HASH; 989 mlx5_devx_tir_attr_set(dev, rss_key, hash_fields, ind_tbl, 990 0, /* N/A - tunnel modification unsupported */ 991 &modify_tir.tir); 992 modify_tir.tirn = hrxq->tir->id; 993 if (mlx5_devx_cmd_modify_tir(hrxq->tir, &modify_tir)) { 994 DRV_LOG(ERR, "port %u cannot modify DevX TIR", 995 dev->data->port_id); 996 rte_errno = errno; 997 return -rte_errno; 998 } 999 return 0; 1000 } 1001 1002 /** 1003 * Create a DevX drop Rx queue. 1004 * 1005 * @param dev 1006 * Pointer to Ethernet device. 1007 * 1008 * @return 1009 * 0 on success, a negative errno value otherwise and rte_errno is set. 1010 */ 1011 static int 1012 mlx5_rxq_devx_obj_drop_create(struct rte_eth_dev *dev) 1013 { 1014 struct mlx5_priv *priv = dev->data->dev_private; 1015 int socket_id = dev->device->numa_node; 1016 struct mlx5_rxq_priv *rxq; 1017 struct mlx5_rxq_ctrl *rxq_ctrl = NULL; 1018 struct mlx5_rxq_obj *rxq_obj = NULL; 1019 int ret; 1020 1021 /* 1022 * Initialize dummy control structures. 1023 * They are required to hold pointers for cleanup 1024 * and are only accessible via drop queue DevX objects. 1025 */ 1026 rxq = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*rxq), 0, socket_id); 1027 if (rxq == NULL) { 1028 DRV_LOG(ERR, "Port %u could not allocate drop queue private", 1029 dev->data->port_id); 1030 rte_errno = ENOMEM; 1031 goto error; 1032 } 1033 rxq_ctrl = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*rxq_ctrl), 1034 0, socket_id); 1035 if (rxq_ctrl == NULL) { 1036 DRV_LOG(ERR, "Port %u could not allocate drop queue control", 1037 dev->data->port_id); 1038 rte_errno = ENOMEM; 1039 goto error; 1040 } 1041 rxq_obj = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*rxq_obj), 0, socket_id); 1042 if (rxq_obj == NULL) { 1043 DRV_LOG(ERR, "Port %u could not allocate drop queue object", 1044 dev->data->port_id); 1045 rte_errno = ENOMEM; 1046 goto error; 1047 } 1048 /* set the CPU socket ID where the rxq_ctrl was allocated */ 1049 rxq_ctrl->socket = socket_id; 1050 rxq_obj->rxq_ctrl = rxq_ctrl; 1051 rxq_ctrl->is_hairpin = false; 1052 rxq_ctrl->sh = priv->sh; 1053 rxq_ctrl->obj = rxq_obj; 1054 rxq->ctrl = rxq_ctrl; 1055 rxq->priv = priv; 1056 LIST_INSERT_HEAD(&rxq_ctrl->owners, rxq, owner_entry); 1057 /* Create CQ using DevX API. */ 1058 ret = mlx5_rxq_create_devx_cq_resources(rxq); 1059 if (ret != 0) { 1060 DRV_LOG(ERR, "Port %u drop queue CQ creation failed.", 1061 dev->data->port_id); 1062 goto error; 1063 } 1064 rxq_ctrl->rxq.delay_drop = 0; 1065 /* Create RQ using DevX API. */ 1066 ret = mlx5_rxq_create_devx_rq_resources(rxq); 1067 if (ret != 0) { 1068 DRV_LOG(ERR, "Port %u drop queue RQ creation failed.", 1069 dev->data->port_id); 1070 rte_errno = ENOMEM; 1071 goto error; 1072 } 1073 /* Change queue state to ready. */ 1074 ret = mlx5_devx_modify_rq(rxq, MLX5_RXQ_MOD_RST2RDY); 1075 if (ret != 0) 1076 goto error; 1077 /* Initialize drop queue. */ 1078 priv->drop_queue.rxq = rxq; 1079 return 0; 1080 error: 1081 ret = rte_errno; /* Save rte_errno before cleanup. */ 1082 if (rxq != NULL && rxq->devx_rq.rq != NULL) 1083 mlx5_devx_rq_destroy(&rxq->devx_rq); 1084 if (rxq_obj != NULL) { 1085 if (rxq_obj->cq_obj.cq != NULL) 1086 mlx5_devx_cq_destroy(&rxq_obj->cq_obj); 1087 if (rxq_obj->devx_channel) 1088 mlx5_os_devx_destroy_event_channel 1089 (rxq_obj->devx_channel); 1090 mlx5_free(rxq_obj); 1091 } 1092 if (rxq_ctrl != NULL) 1093 mlx5_free(rxq_ctrl); 1094 if (rxq != NULL) 1095 mlx5_free(rxq); 1096 rte_errno = ret; /* Restore rte_errno. */ 1097 return -rte_errno; 1098 } 1099 1100 /** 1101 * Release drop Rx queue resources. 1102 * 1103 * @param dev 1104 * Pointer to Ethernet device. 1105 */ 1106 static void 1107 mlx5_rxq_devx_obj_drop_release(struct rte_eth_dev *dev) 1108 { 1109 struct mlx5_priv *priv = dev->data->dev_private; 1110 struct mlx5_rxq_priv *rxq = priv->drop_queue.rxq; 1111 struct mlx5_rxq_ctrl *rxq_ctrl = rxq->ctrl; 1112 1113 mlx5_rxq_devx_obj_release(rxq); 1114 mlx5_free(rxq_ctrl->obj); 1115 mlx5_free(rxq_ctrl); 1116 mlx5_free(rxq); 1117 priv->drop_queue.rxq = NULL; 1118 } 1119 1120 /** 1121 * Release a drop hash Rx queue. 1122 * 1123 * @param dev 1124 * Pointer to Ethernet device. 1125 */ 1126 static void 1127 mlx5_devx_drop_action_destroy(struct rte_eth_dev *dev) 1128 { 1129 struct mlx5_priv *priv = dev->data->dev_private; 1130 struct mlx5_hrxq *hrxq = priv->drop_queue.hrxq; 1131 1132 if (hrxq->tir != NULL) 1133 mlx5_devx_tir_destroy(hrxq); 1134 if (hrxq->ind_table->ind_table != NULL) 1135 mlx5_devx_ind_table_destroy(hrxq->ind_table); 1136 if (priv->drop_queue.rxq->devx_rq.rq != NULL) 1137 mlx5_rxq_devx_obj_drop_release(dev); 1138 } 1139 1140 /** 1141 * Create a DevX drop action for Rx Hash queue. 1142 * 1143 * @param dev 1144 * Pointer to Ethernet device. 1145 * 1146 * @return 1147 * 0 on success, a negative errno value otherwise and rte_errno is set. 1148 */ 1149 static int 1150 mlx5_devx_drop_action_create(struct rte_eth_dev *dev) 1151 { 1152 struct mlx5_priv *priv = dev->data->dev_private; 1153 struct mlx5_hrxq *hrxq = priv->drop_queue.hrxq; 1154 int ret; 1155 1156 ret = mlx5_rxq_devx_obj_drop_create(dev); 1157 if (ret != 0) { 1158 DRV_LOG(ERR, "Cannot create drop RX queue"); 1159 return ret; 1160 } 1161 if (priv->sh->config.dv_flow_en == 2) 1162 return 0; 1163 /* hrxq->ind_table queues are NULL, drop RX queue ID will be used */ 1164 ret = mlx5_devx_ind_table_new(dev, 0, hrxq->ind_table); 1165 if (ret != 0) { 1166 DRV_LOG(ERR, "Cannot create drop hash RX queue indirection table"); 1167 goto error; 1168 } 1169 ret = mlx5_devx_hrxq_new(dev, hrxq, /* tunnel */ false); 1170 if (ret != 0) { 1171 DRV_LOG(ERR, "Cannot create drop hash RX queue"); 1172 goto error; 1173 } 1174 return 0; 1175 error: 1176 mlx5_devx_drop_action_destroy(dev); 1177 return ret; 1178 } 1179 1180 /** 1181 * Select TXQ TIS number. 1182 * 1183 * @param dev 1184 * Pointer to Ethernet device. 1185 * @param queue_idx 1186 * Queue index in DPDK Tx queue array. 1187 * 1188 * @return 1189 * > 0 on success, a negative errno value otherwise. 1190 */ 1191 static uint32_t 1192 mlx5_get_txq_tis_num(struct rte_eth_dev *dev, uint16_t queue_idx) 1193 { 1194 struct mlx5_priv *priv = dev->data->dev_private; 1195 struct mlx5_txq_data *txq_data = (*priv->txqs)[queue_idx]; 1196 int tis_idx = 0; 1197 1198 if (priv->sh->bond.n_port) { 1199 if (txq_data->tx_aggr_affinity) { 1200 tis_idx = txq_data->tx_aggr_affinity; 1201 } else if (priv->sh->lag.affinity_mode == MLX5_LAG_MODE_TIS) { 1202 tis_idx = (priv->lag_affinity_idx + queue_idx) % 1203 priv->sh->bond.n_port + 1; 1204 DRV_LOG(INFO, "port %d txq %d gets affinity %d and maps to PF %d.", 1205 dev->data->port_id, queue_idx, tis_idx, 1206 priv->sh->lag.tx_remap_affinity[tis_idx - 1]); 1207 } 1208 } 1209 MLX5_ASSERT(priv->sh->tis[tis_idx]); 1210 return priv->sh->tis[tis_idx]->id; 1211 } 1212 1213 /** 1214 * Create the Tx hairpin queue object. 1215 * 1216 * @param dev 1217 * Pointer to Ethernet device. 1218 * @param idx 1219 * Queue index in DPDK Tx queue array. 1220 * 1221 * @return 1222 * 0 on success, a negative errno value otherwise and rte_errno is set. 1223 */ 1224 static int 1225 mlx5_txq_obj_hairpin_new(struct rte_eth_dev *dev, uint16_t idx) 1226 { 1227 struct mlx5_priv *priv = dev->data->dev_private; 1228 struct mlx5_hca_attr *hca_attr = &priv->sh->cdev->config.hca_attr; 1229 struct mlx5_txq_data *txq_data = (*priv->txqs)[idx]; 1230 struct mlx5_txq_ctrl *txq_ctrl = 1231 container_of(txq_data, struct mlx5_txq_ctrl, txq); 1232 struct mlx5_devx_create_sq_attr dev_mem_attr = { 0 }; 1233 struct mlx5_devx_create_sq_attr host_mem_attr = { 0 }; 1234 struct mlx5_txq_obj *tmpl = txq_ctrl->obj; 1235 void *umem_buf = NULL; 1236 void *umem_obj = NULL; 1237 uint32_t max_wq_data; 1238 1239 MLX5_ASSERT(txq_data); 1240 MLX5_ASSERT(tmpl); 1241 tmpl->txq_ctrl = txq_ctrl; 1242 dev_mem_attr.hairpin = 1; 1243 dev_mem_attr.tis_lst_sz = 1; 1244 dev_mem_attr.tis_num = mlx5_get_txq_tis_num(dev, idx); 1245 max_wq_data = 1246 priv->sh->cdev->config.hca_attr.log_max_hairpin_wq_data_sz; 1247 /* Jumbo frames > 9KB should be supported, and more packets. */ 1248 if (priv->config.log_hp_size != (uint32_t)MLX5_ARG_UNSET) { 1249 if (priv->config.log_hp_size > max_wq_data) { 1250 DRV_LOG(ERR, "Total data size %u power of 2 is " 1251 "too large for hairpin.", 1252 priv->config.log_hp_size); 1253 rte_errno = ERANGE; 1254 return -rte_errno; 1255 } 1256 dev_mem_attr.wq_attr.log_hairpin_data_sz = priv->config.log_hp_size; 1257 } else { 1258 dev_mem_attr.wq_attr.log_hairpin_data_sz = 1259 (max_wq_data < MLX5_HAIRPIN_JUMBO_LOG_SIZE) ? 1260 max_wq_data : MLX5_HAIRPIN_JUMBO_LOG_SIZE; 1261 } 1262 /* Set the packets number to the maximum value for performance. */ 1263 dev_mem_attr.wq_attr.log_hairpin_num_packets = 1264 dev_mem_attr.wq_attr.log_hairpin_data_sz - 1265 MLX5_HAIRPIN_QUEUE_STRIDE; 1266 dev_mem_attr.hairpin_wq_buffer_type = MLX5_SQC_HAIRPIN_WQ_BUFFER_TYPE_INTERNAL_BUFFER; 1267 if (txq_ctrl->hairpin_conf.use_rte_memory) { 1268 uint32_t umem_size; 1269 uint32_t umem_dbrec; 1270 size_t alignment = MLX5_WQE_BUF_ALIGNMENT; 1271 1272 if (alignment == (size_t)-1) { 1273 DRV_LOG(ERR, "Failed to get WQE buf alignment."); 1274 rte_errno = ENOMEM; 1275 return -rte_errno; 1276 } 1277 /* 1278 * It is assumed that configuration is verified against capabilities 1279 * during queue setup. 1280 */ 1281 MLX5_ASSERT(hca_attr->hairpin_sq_wq_in_host_mem); 1282 MLX5_ASSERT(hca_attr->hairpin_sq_wqe_bb_size > 0); 1283 rte_memcpy(&host_mem_attr, &dev_mem_attr, sizeof(host_mem_attr)); 1284 umem_size = MLX5_WQE_SIZE * 1285 RTE_BIT32(host_mem_attr.wq_attr.log_hairpin_num_packets); 1286 umem_dbrec = RTE_ALIGN(umem_size, MLX5_DBR_SIZE); 1287 umem_size += MLX5_DBR_SIZE; 1288 umem_buf = mlx5_malloc(MLX5_MEM_RTE | MLX5_MEM_ZERO, umem_size, 1289 alignment, priv->sh->numa_node); 1290 if (umem_buf == NULL && txq_ctrl->hairpin_conf.force_memory) { 1291 DRV_LOG(ERR, "Failed to allocate memory for hairpin TX queue"); 1292 rte_errno = ENOMEM; 1293 return -rte_errno; 1294 } else if (umem_buf == NULL && !txq_ctrl->hairpin_conf.force_memory) { 1295 DRV_LOG(WARNING, "Failed to allocate memory for hairpin TX queue." 1296 " Falling back to TX queue located on the device."); 1297 goto create_sq_on_device; 1298 } 1299 umem_obj = mlx5_os_umem_reg(priv->sh->cdev->ctx, 1300 (void *)(uintptr_t)umem_buf, 1301 umem_size, 1302 IBV_ACCESS_LOCAL_WRITE); 1303 if (umem_obj == NULL && txq_ctrl->hairpin_conf.force_memory) { 1304 DRV_LOG(ERR, "Failed to register UMEM for hairpin TX queue"); 1305 mlx5_free(umem_buf); 1306 return -rte_errno; 1307 } else if (umem_obj == NULL && !txq_ctrl->hairpin_conf.force_memory) { 1308 DRV_LOG(WARNING, "Failed to register UMEM for hairpin TX queue." 1309 " Falling back to TX queue located on the device."); 1310 rte_errno = 0; 1311 mlx5_free(umem_buf); 1312 goto create_sq_on_device; 1313 } 1314 host_mem_attr.wq_attr.wq_type = MLX5_WQ_TYPE_CYCLIC; 1315 host_mem_attr.wq_attr.wq_umem_valid = 1; 1316 host_mem_attr.wq_attr.wq_umem_id = mlx5_os_get_umem_id(umem_obj); 1317 host_mem_attr.wq_attr.wq_umem_offset = 0; 1318 host_mem_attr.wq_attr.dbr_umem_valid = 1; 1319 host_mem_attr.wq_attr.dbr_umem_id = host_mem_attr.wq_attr.wq_umem_id; 1320 host_mem_attr.wq_attr.dbr_addr = umem_dbrec; 1321 host_mem_attr.wq_attr.log_wq_stride = rte_log2_u32(MLX5_WQE_SIZE); 1322 host_mem_attr.wq_attr.log_wq_sz = 1323 host_mem_attr.wq_attr.log_hairpin_num_packets * 1324 hca_attr->hairpin_sq_wqe_bb_size; 1325 host_mem_attr.wq_attr.log_wq_pg_sz = MLX5_LOG_PAGE_SIZE; 1326 host_mem_attr.hairpin_wq_buffer_type = MLX5_SQC_HAIRPIN_WQ_BUFFER_TYPE_HOST_MEMORY; 1327 tmpl->sq = mlx5_devx_cmd_create_sq(priv->sh->cdev->ctx, &host_mem_attr); 1328 if (!tmpl->sq && txq_ctrl->hairpin_conf.force_memory) { 1329 DRV_LOG(ERR, 1330 "Port %u tx hairpin queue %u can't create SQ object.", 1331 dev->data->port_id, idx); 1332 claim_zero(mlx5_os_umem_dereg(umem_obj)); 1333 mlx5_free(umem_buf); 1334 return -rte_errno; 1335 } else if (!tmpl->sq && !txq_ctrl->hairpin_conf.force_memory) { 1336 DRV_LOG(WARNING, 1337 "Port %u tx hairpin queue %u failed to allocate SQ object" 1338 " using host memory. Falling back to TX queue located" 1339 " on the device", 1340 dev->data->port_id, idx); 1341 rte_errno = 0; 1342 claim_zero(mlx5_os_umem_dereg(umem_obj)); 1343 mlx5_free(umem_buf); 1344 goto create_sq_on_device; 1345 } 1346 tmpl->umem_buf_wq_buffer = umem_buf; 1347 tmpl->umem_obj_wq_buffer = umem_obj; 1348 return 0; 1349 } 1350 1351 create_sq_on_device: 1352 tmpl->sq = mlx5_devx_cmd_create_sq(priv->sh->cdev->ctx, &dev_mem_attr); 1353 if (!tmpl->sq) { 1354 DRV_LOG(ERR, 1355 "Port %u tx hairpin queue %u can't create SQ object.", 1356 dev->data->port_id, idx); 1357 rte_errno = errno; 1358 return -rte_errno; 1359 } 1360 return 0; 1361 } 1362 1363 #if defined(HAVE_MLX5DV_DEVX_UAR_OFFSET) || !defined(HAVE_INFINIBAND_VERBS_H) 1364 /** 1365 * Destroy the Tx queue DevX object. 1366 * 1367 * @param txq_obj 1368 * Txq object to destroy. 1369 */ 1370 static void 1371 mlx5_txq_release_devx_resources(struct mlx5_txq_obj *txq_obj) 1372 { 1373 mlx5_devx_sq_destroy(&txq_obj->sq_obj); 1374 memset(&txq_obj->sq_obj, 0, sizeof(txq_obj->sq_obj)); 1375 mlx5_devx_cq_destroy(&txq_obj->cq_obj); 1376 memset(&txq_obj->cq_obj, 0, sizeof(txq_obj->cq_obj)); 1377 } 1378 1379 /** 1380 * Create a SQ object and its resources using DevX. 1381 * 1382 * @param dev 1383 * Pointer to Ethernet device. 1384 * @param idx 1385 * Queue index in DPDK Tx queue array. 1386 * @param[in] log_desc_n 1387 * Log of number of descriptors in queue. 1388 * 1389 * @return 1390 * 0 on success, a negative errno value otherwise and rte_errno is set. 1391 */ 1392 static int 1393 mlx5_txq_create_devx_sq_resources(struct rte_eth_dev *dev, uint16_t idx, 1394 uint16_t log_desc_n) 1395 { 1396 struct mlx5_priv *priv = dev->data->dev_private; 1397 struct mlx5_common_device *cdev = priv->sh->cdev; 1398 struct mlx5_uar *uar = &priv->sh->tx_uar; 1399 struct mlx5_txq_data *txq_data = (*priv->txqs)[idx]; 1400 struct mlx5_txq_ctrl *txq_ctrl = 1401 container_of(txq_data, struct mlx5_txq_ctrl, txq); 1402 struct mlx5_txq_obj *txq_obj = txq_ctrl->obj; 1403 struct mlx5_devx_create_sq_attr sq_attr = { 1404 .flush_in_error_en = 1, 1405 .allow_multi_pkt_send_wqe = !!priv->config.mps, 1406 .min_wqe_inline_mode = cdev->config.hca_attr.vport_inline_mode, 1407 .allow_swp = !!priv->sh->dev_cap.swp, 1408 .cqn = txq_obj->cq_obj.cq->id, 1409 .tis_lst_sz = 1, 1410 .wq_attr = (struct mlx5_devx_wq_attr){ 1411 .pd = cdev->pdn, 1412 .uar_page = mlx5_os_get_devx_uar_page_id(uar->obj), 1413 }, 1414 .ts_format = 1415 mlx5_ts_format_conv(cdev->config.hca_attr.sq_ts_format), 1416 .tis_num = mlx5_get_txq_tis_num(dev, idx), 1417 }; 1418 1419 /* Create Send Queue object with DevX. */ 1420 return mlx5_devx_sq_create(cdev->ctx, &txq_obj->sq_obj, 1421 log_desc_n, &sq_attr, priv->sh->numa_node); 1422 } 1423 #endif 1424 1425 /** 1426 * Create the Tx queue DevX object. 1427 * 1428 * @param dev 1429 * Pointer to Ethernet device. 1430 * @param idx 1431 * Queue index in DPDK Tx queue array. 1432 * 1433 * @return 1434 * 0 on success, a negative errno value otherwise and rte_errno is set. 1435 */ 1436 int 1437 mlx5_txq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx) 1438 { 1439 struct mlx5_priv *priv = dev->data->dev_private; 1440 struct mlx5_txq_data *txq_data = (*priv->txqs)[idx]; 1441 struct mlx5_txq_ctrl *txq_ctrl = 1442 container_of(txq_data, struct mlx5_txq_ctrl, txq); 1443 1444 if (txq_ctrl->is_hairpin) 1445 return mlx5_txq_obj_hairpin_new(dev, idx); 1446 #if !defined(HAVE_MLX5DV_DEVX_UAR_OFFSET) && defined(HAVE_INFINIBAND_VERBS_H) 1447 DRV_LOG(ERR, "Port %u Tx queue %u cannot create with DevX, no UAR.", 1448 dev->data->port_id, idx); 1449 rte_errno = ENOMEM; 1450 return -rte_errno; 1451 #else 1452 struct mlx5_proc_priv *ppriv = MLX5_PROC_PRIV(PORT_ID(priv)); 1453 struct mlx5_dev_ctx_shared *sh = priv->sh; 1454 struct mlx5_txq_obj *txq_obj = txq_ctrl->obj; 1455 struct mlx5_devx_cq_attr cq_attr = { 1456 .uar_page_id = mlx5_os_get_devx_uar_page_id(sh->tx_uar.obj), 1457 }; 1458 uint32_t cqe_n, log_desc_n; 1459 uint32_t wqe_n, wqe_size; 1460 int ret = 0; 1461 1462 MLX5_ASSERT(txq_data); 1463 MLX5_ASSERT(txq_obj); 1464 MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY); 1465 MLX5_ASSERT(ppriv); 1466 txq_obj->txq_ctrl = txq_ctrl; 1467 txq_obj->dev = dev; 1468 cqe_n = (1UL << txq_data->elts_n) / MLX5_TX_COMP_THRESH + 1469 1 + MLX5_TX_COMP_THRESH_INLINE_DIV; 1470 log_desc_n = log2above(cqe_n); 1471 cqe_n = 1UL << log_desc_n; 1472 if (cqe_n > UINT16_MAX) { 1473 DRV_LOG(ERR, "Port %u Tx queue %u requests to many CQEs %u.", 1474 dev->data->port_id, txq_data->idx, cqe_n); 1475 rte_errno = EINVAL; 1476 return 0; 1477 } 1478 /* Create completion queue object with DevX. */ 1479 ret = mlx5_devx_cq_create(sh->cdev->ctx, &txq_obj->cq_obj, log_desc_n, 1480 &cq_attr, priv->sh->numa_node); 1481 if (ret) { 1482 DRV_LOG(ERR, "Port %u Tx queue %u CQ creation failure.", 1483 dev->data->port_id, idx); 1484 goto error; 1485 } 1486 txq_data->cqe_n = log_desc_n; 1487 txq_data->cqe_s = cqe_n; 1488 txq_data->cqe_m = txq_data->cqe_s - 1; 1489 txq_data->cqes = txq_obj->cq_obj.cqes; 1490 txq_data->cq_ci = 0; 1491 txq_data->cq_pi = 0; 1492 txq_data->cq_db = txq_obj->cq_obj.db_rec; 1493 *txq_data->cq_db = 0; 1494 /* 1495 * Adjust the amount of WQEs depending on inline settings. 1496 * The number of descriptors should be enough to handle 1497 * the specified number of packets. If queue is being created 1498 * with Verbs the rdma-core does queue size adjustment 1499 * internally in the mlx5_calc_sq_size(), we do the same 1500 * for the queue being created with DevX at this point. 1501 */ 1502 wqe_size = txq_data->tso_en ? 1503 RTE_ALIGN(txq_ctrl->max_tso_header, MLX5_WSEG_SIZE) : 0; 1504 wqe_size += sizeof(struct mlx5_wqe_cseg) + 1505 sizeof(struct mlx5_wqe_eseg) + 1506 sizeof(struct mlx5_wqe_dseg); 1507 if (txq_data->inlen_send) 1508 wqe_size = RTE_MAX(wqe_size, sizeof(struct mlx5_wqe_cseg) + 1509 sizeof(struct mlx5_wqe_eseg) + 1510 RTE_ALIGN(txq_data->inlen_send + 1511 sizeof(uint32_t), 1512 MLX5_WSEG_SIZE)); 1513 wqe_size = RTE_ALIGN(wqe_size, MLX5_WQE_SIZE) / MLX5_WQE_SIZE; 1514 /* Create Send Queue object with DevX. */ 1515 wqe_n = RTE_MIN((1UL << txq_data->elts_n) * wqe_size, 1516 (uint32_t)priv->sh->dev_cap.max_qp_wr); 1517 log_desc_n = log2above(wqe_n); 1518 ret = mlx5_txq_create_devx_sq_resources(dev, idx, log_desc_n); 1519 if (ret) { 1520 DRV_LOG(ERR, "Port %u Tx queue %u SQ creation failure.", 1521 dev->data->port_id, idx); 1522 rte_errno = errno; 1523 goto error; 1524 } 1525 /* Create the Work Queue. */ 1526 txq_data->wqe_n = log_desc_n; 1527 txq_data->wqe_s = 1 << txq_data->wqe_n; 1528 txq_data->wqe_m = txq_data->wqe_s - 1; 1529 txq_data->wqes = (struct mlx5_wqe *)(uintptr_t)txq_obj->sq_obj.wqes; 1530 txq_data->wqes_end = txq_data->wqes + txq_data->wqe_s; 1531 txq_data->wqe_ci = 0; 1532 txq_data->wqe_pi = 0; 1533 txq_data->wqe_comp = 0; 1534 txq_data->wqe_thres = txq_data->wqe_s / MLX5_TX_COMP_THRESH_INLINE_DIV; 1535 txq_data->qp_db = &txq_obj->sq_obj.db_rec[MLX5_SND_DBR]; 1536 *txq_data->qp_db = 0; 1537 txq_data->qp_num_8s = txq_obj->sq_obj.sq->id << 8; 1538 txq_data->db_heu = sh->cdev->config.dbnc == MLX5_SQ_DB_HEURISTIC; 1539 txq_data->db_nc = sh->tx_uar.dbnc; 1540 txq_data->wait_on_time = !!(!sh->config.tx_pp && 1541 sh->cdev->config.hca_attr.wait_on_time); 1542 /* Change Send Queue state to Ready-to-Send. */ 1543 ret = mlx5_txq_devx_modify(txq_obj, MLX5_TXQ_MOD_RST2RDY, 0); 1544 if (ret) { 1545 rte_errno = errno; 1546 DRV_LOG(ERR, 1547 "Port %u Tx queue %u SQ state to SQC_STATE_RDY failed.", 1548 dev->data->port_id, idx); 1549 goto error; 1550 } 1551 #ifdef HAVE_IBV_FLOW_DV_SUPPORT 1552 /* 1553 * If using DevX need to query and store TIS transport domain value. 1554 * This is done once per port. 1555 * Will use this value on Rx, when creating matching TIR. 1556 */ 1557 if (!priv->sh->tdn) 1558 priv->sh->tdn = priv->sh->td->id; 1559 #endif 1560 txq_ctrl->uar_mmap_offset = 1561 mlx5_os_get_devx_uar_mmap_offset(sh->tx_uar.obj); 1562 ppriv->uar_table[txq_data->idx] = sh->tx_uar.bf_db; 1563 dev->data->tx_queue_state[idx] = RTE_ETH_QUEUE_STATE_STARTED; 1564 return 0; 1565 error: 1566 ret = rte_errno; /* Save rte_errno before cleanup. */ 1567 mlx5_txq_release_devx_resources(txq_obj); 1568 rte_errno = ret; /* Restore rte_errno. */ 1569 return -rte_errno; 1570 #endif 1571 } 1572 1573 /** 1574 * Release an Tx DevX queue object. 1575 * 1576 * @param txq_obj 1577 * DevX Tx queue object. 1578 */ 1579 void 1580 mlx5_txq_devx_obj_release(struct mlx5_txq_obj *txq_obj) 1581 { 1582 MLX5_ASSERT(txq_obj); 1583 if (txq_obj->txq_ctrl->is_hairpin) { 1584 if (txq_obj->sq) { 1585 claim_zero(mlx5_devx_cmd_destroy(txq_obj->sq)); 1586 txq_obj->sq = NULL; 1587 } 1588 if (txq_obj->tis) 1589 claim_zero(mlx5_devx_cmd_destroy(txq_obj->tis)); 1590 if (txq_obj->umem_obj_wq_buffer) { 1591 claim_zero(mlx5_os_umem_dereg(txq_obj->umem_obj_wq_buffer)); 1592 txq_obj->umem_obj_wq_buffer = NULL; 1593 } 1594 if (txq_obj->umem_buf_wq_buffer) { 1595 mlx5_free(txq_obj->umem_buf_wq_buffer); 1596 txq_obj->umem_buf_wq_buffer = NULL; 1597 } 1598 #if defined(HAVE_MLX5DV_DEVX_UAR_OFFSET) || !defined(HAVE_INFINIBAND_VERBS_H) 1599 } else { 1600 mlx5_txq_release_devx_resources(txq_obj); 1601 #endif 1602 } 1603 } 1604 1605 struct mlx5_obj_ops devx_obj_ops = { 1606 .rxq_obj_modify_vlan_strip = mlx5_rxq_obj_modify_rq_vlan_strip, 1607 .rxq_obj_new = mlx5_rxq_devx_obj_new, 1608 .rxq_event_get = mlx5_rx_devx_get_event, 1609 .rxq_obj_modify = mlx5_devx_modify_rq, 1610 .rxq_obj_release = mlx5_rxq_devx_obj_release, 1611 .rxq_event_get_lwm = mlx5_rx_devx_get_event_lwm, 1612 .ind_table_new = mlx5_devx_ind_table_new, 1613 .ind_table_modify = mlx5_devx_ind_table_modify, 1614 .ind_table_destroy = mlx5_devx_ind_table_destroy, 1615 .hrxq_new = mlx5_devx_hrxq_new, 1616 .hrxq_destroy = mlx5_devx_tir_destroy, 1617 .hrxq_modify = mlx5_devx_hrxq_modify, 1618 .drop_action_create = mlx5_devx_drop_action_create, 1619 .drop_action_destroy = mlx5_devx_drop_action_destroy, 1620 .txq_obj_new = mlx5_txq_devx_obj_new, 1621 .txq_obj_modify = mlx5_txq_devx_modify, 1622 .txq_obj_release = mlx5_txq_devx_obj_release, 1623 .lb_dummy_queue_create = NULL, 1624 .lb_dummy_queue_release = NULL, 1625 }; 1626