17b4f1e6bSMatan Azrad /* SPDX-License-Identifier: BSD-3-Clause 27b4f1e6bSMatan Azrad * Copyright 2019 Mellanox Technologies, Ltd 37b4f1e6bSMatan Azrad */ 47b4f1e6bSMatan Azrad 57b4f1e6bSMatan Azrad #ifndef RTE_PMD_MLX5_DEVX_CMDS_H_ 67b4f1e6bSMatan Azrad #define RTE_PMD_MLX5_DEVX_CMDS_H_ 77b4f1e6bSMatan Azrad 87b4f1e6bSMatan Azrad #include "mlx5_glue.h" 9*53ec4db0SMatan Azrad #include "mlx5_prm.h" 107b4f1e6bSMatan Azrad 117b4f1e6bSMatan Azrad 127b4f1e6bSMatan Azrad /* devX creation object */ 137b4f1e6bSMatan Azrad struct mlx5_devx_obj { 147b4f1e6bSMatan Azrad struct mlx5dv_devx_obj *obj; /* The DV object. */ 157b4f1e6bSMatan Azrad int id; /* The object ID. */ 167b4f1e6bSMatan Azrad }; 177b4f1e6bSMatan Azrad 18*53ec4db0SMatan Azrad /* UMR memory buffer used to define 1 entry in indirect mkey. */ 19*53ec4db0SMatan Azrad struct mlx5_klm { 20*53ec4db0SMatan Azrad uint32_t byte_count; 21*53ec4db0SMatan Azrad uint32_t mkey; 22*53ec4db0SMatan Azrad uint64_t address; 23*53ec4db0SMatan Azrad }; 24*53ec4db0SMatan Azrad 25*53ec4db0SMatan Azrad /* This is limitation of libibverbs: in length variable type is u16. */ 26*53ec4db0SMatan Azrad #define MLX5_DEVX_MAX_KLM_ENTRIES ((UINT16_MAX - \ 27*53ec4db0SMatan Azrad MLX5_ST_SZ_DW(create_mkey_in) * 4) / (MLX5_ST_SZ_DW(klm) * 4)) 28*53ec4db0SMatan Azrad 297b4f1e6bSMatan Azrad struct mlx5_devx_mkey_attr { 307b4f1e6bSMatan Azrad uint64_t addr; 317b4f1e6bSMatan Azrad uint64_t size; 327b4f1e6bSMatan Azrad uint32_t umem_id; 337b4f1e6bSMatan Azrad uint32_t pd; 34*53ec4db0SMatan Azrad uint32_t log_entity_size; 35*53ec4db0SMatan Azrad uint32_t pg_access:1; 36*53ec4db0SMatan Azrad struct mlx5_klm *klm_array; 37*53ec4db0SMatan Azrad int klm_num; 387b4f1e6bSMatan Azrad }; 397b4f1e6bSMatan Azrad 407b4f1e6bSMatan Azrad /* HCA qos attributes. */ 417b4f1e6bSMatan Azrad struct mlx5_hca_qos_attr { 427b4f1e6bSMatan Azrad uint32_t sup:1; /* Whether QOS is supported. */ 437b4f1e6bSMatan Azrad uint32_t srtcm_sup:1; /* Whether srTCM mode is supported. */ 447b4f1e6bSMatan Azrad uint32_t flow_meter_reg_share:1; 457b4f1e6bSMatan Azrad /* Whether reg_c share is supported. */ 467b4f1e6bSMatan Azrad uint8_t log_max_flow_meter; 477b4f1e6bSMatan Azrad /* Power of the maximum supported meters. */ 487b4f1e6bSMatan Azrad uint8_t flow_meter_reg_c_ids; 497b4f1e6bSMatan Azrad /* Bitmap of the reg_Cs available for flow meter to use. */ 507b4f1e6bSMatan Azrad 517b4f1e6bSMatan Azrad }; 527b4f1e6bSMatan Azrad 53ba1768c4SMatan Azrad struct mlx5_hca_vdpa_attr { 54ba1768c4SMatan Azrad uint8_t virtio_queue_type; 55ba1768c4SMatan Azrad uint32_t valid:1; 56ba1768c4SMatan Azrad uint32_t desc_tunnel_offload_type:1; 57ba1768c4SMatan Azrad uint32_t eth_frame_offload_type:1; 58ba1768c4SMatan Azrad uint32_t virtio_version_1_0:1; 59ba1768c4SMatan Azrad uint32_t tso_ipv4:1; 60ba1768c4SMatan Azrad uint32_t tso_ipv6:1; 61ba1768c4SMatan Azrad uint32_t tx_csum:1; 62ba1768c4SMatan Azrad uint32_t rx_csum:1; 63ba1768c4SMatan Azrad uint32_t event_mode:3; 64ba1768c4SMatan Azrad uint32_t log_doorbell_stride:5; 65ba1768c4SMatan Azrad uint32_t log_doorbell_bar_size:5; 66ba1768c4SMatan Azrad uint32_t max_num_virtio_queues; 67ba1768c4SMatan Azrad uint32_t umem_1_buffer_param_a; 68ba1768c4SMatan Azrad uint32_t umem_1_buffer_param_b; 69ba1768c4SMatan Azrad uint32_t umem_2_buffer_param_a; 70ba1768c4SMatan Azrad uint32_t umem_2_buffer_param_b; 71ba1768c4SMatan Azrad uint32_t umem_3_buffer_param_a; 72ba1768c4SMatan Azrad uint32_t umem_3_buffer_param_b; 73ba1768c4SMatan Azrad uint64_t doorbell_bar_offset; 74ba1768c4SMatan Azrad }; 75ba1768c4SMatan Azrad 767b4f1e6bSMatan Azrad /* HCA supports this number of time periods for LRO. */ 777b4f1e6bSMatan Azrad #define MLX5_LRO_NUM_SUPP_PERIODS 4 787b4f1e6bSMatan Azrad 797b4f1e6bSMatan Azrad /* HCA attributes. */ 807b4f1e6bSMatan Azrad struct mlx5_hca_attr { 817b4f1e6bSMatan Azrad uint32_t eswitch_manager:1; 827b4f1e6bSMatan Azrad uint32_t flow_counters_dump:1; 837b4f1e6bSMatan Azrad uint8_t flow_counter_bulk_alloc_bitmap; 847b4f1e6bSMatan Azrad uint32_t eth_net_offloads:1; 857b4f1e6bSMatan Azrad uint32_t eth_virt:1; 867b4f1e6bSMatan Azrad uint32_t wqe_vlan_insert:1; 877b4f1e6bSMatan Azrad uint32_t wqe_inline_mode:2; 887b4f1e6bSMatan Azrad uint32_t vport_inline_mode:3; 897b4f1e6bSMatan Azrad uint32_t tunnel_stateless_geneve_rx:1; 907b4f1e6bSMatan Azrad uint32_t geneve_max_opt_len:1; /* 0x0: 14DW, 0x1: 63DW */ 917b4f1e6bSMatan Azrad uint32_t tunnel_stateless_gtp:1; 927b4f1e6bSMatan Azrad uint32_t lro_cap:1; 937b4f1e6bSMatan Azrad uint32_t tunnel_lro_gre:1; 947b4f1e6bSMatan Azrad uint32_t tunnel_lro_vxlan:1; 957b4f1e6bSMatan Azrad uint32_t lro_max_msg_sz_mode:2; 967b4f1e6bSMatan Azrad uint32_t lro_timer_supported_periods[MLX5_LRO_NUM_SUPP_PERIODS]; 977b4f1e6bSMatan Azrad uint32_t flex_parser_protocols; 987b4f1e6bSMatan Azrad uint32_t hairpin:1; 997b4f1e6bSMatan Azrad uint32_t log_max_hairpin_queues:5; 1007b4f1e6bSMatan Azrad uint32_t log_max_hairpin_wq_data_sz:5; 1017b4f1e6bSMatan Azrad uint32_t log_max_hairpin_num_packets:5; 1027b4f1e6bSMatan Azrad uint32_t vhca_id:16; 1037b4f1e6bSMatan Azrad struct mlx5_hca_qos_attr qos; 104ba1768c4SMatan Azrad struct mlx5_hca_vdpa_attr vdpa; 1057b4f1e6bSMatan Azrad }; 1067b4f1e6bSMatan Azrad 1077b4f1e6bSMatan Azrad struct mlx5_devx_wq_attr { 1087b4f1e6bSMatan Azrad uint32_t wq_type:4; 1097b4f1e6bSMatan Azrad uint32_t wq_signature:1; 1107b4f1e6bSMatan Azrad uint32_t end_padding_mode:2; 1117b4f1e6bSMatan Azrad uint32_t cd_slave:1; 1127b4f1e6bSMatan Azrad uint32_t hds_skip_first_sge:1; 1137b4f1e6bSMatan Azrad uint32_t log2_hds_buf_size:3; 1147b4f1e6bSMatan Azrad uint32_t page_offset:5; 1157b4f1e6bSMatan Azrad uint32_t lwm:16; 1167b4f1e6bSMatan Azrad uint32_t pd:24; 1177b4f1e6bSMatan Azrad uint32_t uar_page:24; 1187b4f1e6bSMatan Azrad uint64_t dbr_addr; 1197b4f1e6bSMatan Azrad uint32_t hw_counter; 1207b4f1e6bSMatan Azrad uint32_t sw_counter; 1217b4f1e6bSMatan Azrad uint32_t log_wq_stride:4; 1227b4f1e6bSMatan Azrad uint32_t log_wq_pg_sz:5; 1237b4f1e6bSMatan Azrad uint32_t log_wq_sz:5; 1247b4f1e6bSMatan Azrad uint32_t dbr_umem_valid:1; 1257b4f1e6bSMatan Azrad uint32_t wq_umem_valid:1; 1267b4f1e6bSMatan Azrad uint32_t log_hairpin_num_packets:5; 1277b4f1e6bSMatan Azrad uint32_t log_hairpin_data_sz:5; 1287b4f1e6bSMatan Azrad uint32_t single_wqe_log_num_of_strides:4; 1297b4f1e6bSMatan Azrad uint32_t two_byte_shift_en:1; 1307b4f1e6bSMatan Azrad uint32_t single_stride_log_num_of_bytes:3; 1317b4f1e6bSMatan Azrad uint32_t dbr_umem_id; 1327b4f1e6bSMatan Azrad uint32_t wq_umem_id; 1337b4f1e6bSMatan Azrad uint64_t wq_umem_offset; 1347b4f1e6bSMatan Azrad }; 1357b4f1e6bSMatan Azrad 1367b4f1e6bSMatan Azrad /* Create RQ attributes structure, used by create RQ operation. */ 1377b4f1e6bSMatan Azrad struct mlx5_devx_create_rq_attr { 1387b4f1e6bSMatan Azrad uint32_t rlky:1; 1397b4f1e6bSMatan Azrad uint32_t delay_drop_en:1; 1407b4f1e6bSMatan Azrad uint32_t scatter_fcs:1; 1417b4f1e6bSMatan Azrad uint32_t vsd:1; 1427b4f1e6bSMatan Azrad uint32_t mem_rq_type:4; 1437b4f1e6bSMatan Azrad uint32_t state:4; 1447b4f1e6bSMatan Azrad uint32_t flush_in_error_en:1; 1457b4f1e6bSMatan Azrad uint32_t hairpin:1; 1467b4f1e6bSMatan Azrad uint32_t user_index:24; 1477b4f1e6bSMatan Azrad uint32_t cqn:24; 1487b4f1e6bSMatan Azrad uint32_t counter_set_id:8; 1497b4f1e6bSMatan Azrad uint32_t rmpn:24; 1507b4f1e6bSMatan Azrad struct mlx5_devx_wq_attr wq_attr; 1517b4f1e6bSMatan Azrad }; 1527b4f1e6bSMatan Azrad 1537b4f1e6bSMatan Azrad /* Modify RQ attributes structure, used by modify RQ operation. */ 1547b4f1e6bSMatan Azrad struct mlx5_devx_modify_rq_attr { 1557b4f1e6bSMatan Azrad uint32_t rqn:24; 1567b4f1e6bSMatan Azrad uint32_t rq_state:4; /* Current RQ state. */ 1577b4f1e6bSMatan Azrad uint32_t state:4; /* Required RQ state. */ 1587b4f1e6bSMatan Azrad uint32_t scatter_fcs:1; 1597b4f1e6bSMatan Azrad uint32_t vsd:1; 1607b4f1e6bSMatan Azrad uint32_t counter_set_id:8; 1617b4f1e6bSMatan Azrad uint32_t hairpin_peer_sq:24; 1627b4f1e6bSMatan Azrad uint32_t hairpin_peer_vhca:16; 1637b4f1e6bSMatan Azrad uint64_t modify_bitmask; 1647b4f1e6bSMatan Azrad uint32_t lwm:16; /* Contained WQ lwm. */ 1657b4f1e6bSMatan Azrad }; 1667b4f1e6bSMatan Azrad 1677b4f1e6bSMatan Azrad struct mlx5_rx_hash_field_select { 1687b4f1e6bSMatan Azrad uint32_t l3_prot_type:1; 1697b4f1e6bSMatan Azrad uint32_t l4_prot_type:1; 1707b4f1e6bSMatan Azrad uint32_t selected_fields:30; 1717b4f1e6bSMatan Azrad }; 1727b4f1e6bSMatan Azrad 1737b4f1e6bSMatan Azrad /* TIR attributes structure, used by TIR operations. */ 1747b4f1e6bSMatan Azrad struct mlx5_devx_tir_attr { 1757b4f1e6bSMatan Azrad uint32_t disp_type:4; 1767b4f1e6bSMatan Azrad uint32_t lro_timeout_period_usecs:16; 1777b4f1e6bSMatan Azrad uint32_t lro_enable_mask:4; 1787b4f1e6bSMatan Azrad uint32_t lro_max_msg_sz:8; 1797b4f1e6bSMatan Azrad uint32_t inline_rqn:24; 1807b4f1e6bSMatan Azrad uint32_t rx_hash_symmetric:1; 1817b4f1e6bSMatan Azrad uint32_t tunneled_offload_en:1; 1827b4f1e6bSMatan Azrad uint32_t indirect_table:24; 1837b4f1e6bSMatan Azrad uint32_t rx_hash_fn:4; 1847b4f1e6bSMatan Azrad uint32_t self_lb_block:2; 1857b4f1e6bSMatan Azrad uint32_t transport_domain:24; 1867b4f1e6bSMatan Azrad uint32_t rx_hash_toeplitz_key[10]; 1877b4f1e6bSMatan Azrad struct mlx5_rx_hash_field_select rx_hash_field_selector_outer; 1887b4f1e6bSMatan Azrad struct mlx5_rx_hash_field_select rx_hash_field_selector_inner; 1897b4f1e6bSMatan Azrad }; 1907b4f1e6bSMatan Azrad 1917b4f1e6bSMatan Azrad /* RQT attributes structure, used by RQT operations. */ 1927b4f1e6bSMatan Azrad struct mlx5_devx_rqt_attr { 1937b4f1e6bSMatan Azrad uint32_t rqt_max_size:16; 1947b4f1e6bSMatan Azrad uint32_t rqt_actual_size:16; 1957b4f1e6bSMatan Azrad uint32_t rq_list[]; 1967b4f1e6bSMatan Azrad }; 1977b4f1e6bSMatan Azrad 1987b4f1e6bSMatan Azrad /* TIS attributes structure. */ 1997b4f1e6bSMatan Azrad struct mlx5_devx_tis_attr { 2007b4f1e6bSMatan Azrad uint32_t strict_lag_tx_port_affinity:1; 2017b4f1e6bSMatan Azrad uint32_t tls_en:1; 2027b4f1e6bSMatan Azrad uint32_t lag_tx_port_affinity:4; 2037b4f1e6bSMatan Azrad uint32_t prio:4; 2047b4f1e6bSMatan Azrad uint32_t transport_domain:24; 2057b4f1e6bSMatan Azrad }; 2067b4f1e6bSMatan Azrad 2077b4f1e6bSMatan Azrad /* SQ attributes structure, used by SQ create operation. */ 2087b4f1e6bSMatan Azrad struct mlx5_devx_create_sq_attr { 2097b4f1e6bSMatan Azrad uint32_t rlky:1; 2107b4f1e6bSMatan Azrad uint32_t cd_master:1; 2117b4f1e6bSMatan Azrad uint32_t fre:1; 2127b4f1e6bSMatan Azrad uint32_t flush_in_error_en:1; 2137b4f1e6bSMatan Azrad uint32_t allow_multi_pkt_send_wqe:1; 2147b4f1e6bSMatan Azrad uint32_t min_wqe_inline_mode:3; 2157b4f1e6bSMatan Azrad uint32_t state:4; 2167b4f1e6bSMatan Azrad uint32_t reg_umr:1; 2177b4f1e6bSMatan Azrad uint32_t allow_swp:1; 2187b4f1e6bSMatan Azrad uint32_t hairpin:1; 2197b4f1e6bSMatan Azrad uint32_t user_index:24; 2207b4f1e6bSMatan Azrad uint32_t cqn:24; 2217b4f1e6bSMatan Azrad uint32_t packet_pacing_rate_limit_index:16; 2227b4f1e6bSMatan Azrad uint32_t tis_lst_sz:16; 2237b4f1e6bSMatan Azrad uint32_t tis_num:24; 2247b4f1e6bSMatan Azrad struct mlx5_devx_wq_attr wq_attr; 2257b4f1e6bSMatan Azrad }; 2267b4f1e6bSMatan Azrad 2277b4f1e6bSMatan Azrad /* SQ attributes structure, used by SQ modify operation. */ 2287b4f1e6bSMatan Azrad struct mlx5_devx_modify_sq_attr { 2297b4f1e6bSMatan Azrad uint32_t sq_state:4; 2307b4f1e6bSMatan Azrad uint32_t state:4; 2317b4f1e6bSMatan Azrad uint32_t hairpin_peer_rq:24; 2327b4f1e6bSMatan Azrad uint32_t hairpin_peer_vhca:16; 2337b4f1e6bSMatan Azrad }; 2347b4f1e6bSMatan Azrad 235*53ec4db0SMatan Azrad 2367b4f1e6bSMatan Azrad /* mlx5_devx_cmds.c */ 2377b4f1e6bSMatan Azrad 2387b4f1e6bSMatan Azrad struct mlx5_devx_obj *mlx5_devx_cmd_flow_counter_alloc(struct ibv_context *ctx, 2397b4f1e6bSMatan Azrad uint32_t bulk_sz); 2407b4f1e6bSMatan Azrad int mlx5_devx_cmd_destroy(struct mlx5_devx_obj *obj); 2417b4f1e6bSMatan Azrad int mlx5_devx_cmd_flow_counter_query(struct mlx5_devx_obj *dcs, 2427b4f1e6bSMatan Azrad int clear, uint32_t n_counters, 2437b4f1e6bSMatan Azrad uint64_t *pkts, uint64_t *bytes, 2447b4f1e6bSMatan Azrad uint32_t mkey, void *addr, 2457b4f1e6bSMatan Azrad struct mlx5dv_devx_cmd_comp *cmd_comp, 2467b4f1e6bSMatan Azrad uint64_t async_id); 2477b4f1e6bSMatan Azrad int mlx5_devx_cmd_query_hca_attr(struct ibv_context *ctx, 2487b4f1e6bSMatan Azrad struct mlx5_hca_attr *attr); 2497b4f1e6bSMatan Azrad struct mlx5_devx_obj *mlx5_devx_cmd_mkey_create(struct ibv_context *ctx, 2507b4f1e6bSMatan Azrad struct mlx5_devx_mkey_attr *attr); 2517b4f1e6bSMatan Azrad int mlx5_devx_get_out_command_status(void *out); 2527b4f1e6bSMatan Azrad int mlx5_devx_cmd_qp_query_tis_td(struct ibv_qp *qp, uint32_t tis_num, 2537b4f1e6bSMatan Azrad uint32_t *tis_td); 2547b4f1e6bSMatan Azrad struct mlx5_devx_obj *mlx5_devx_cmd_create_rq(struct ibv_context *ctx, 2557b4f1e6bSMatan Azrad struct mlx5_devx_create_rq_attr *rq_attr, 2567b4f1e6bSMatan Azrad int socket); 2577b4f1e6bSMatan Azrad int mlx5_devx_cmd_modify_rq(struct mlx5_devx_obj *rq, 2587b4f1e6bSMatan Azrad struct mlx5_devx_modify_rq_attr *rq_attr); 2597b4f1e6bSMatan Azrad struct mlx5_devx_obj *mlx5_devx_cmd_create_tir(struct ibv_context *ctx, 2607b4f1e6bSMatan Azrad struct mlx5_devx_tir_attr *tir_attr); 2617b4f1e6bSMatan Azrad struct mlx5_devx_obj *mlx5_devx_cmd_create_rqt(struct ibv_context *ctx, 2627b4f1e6bSMatan Azrad struct mlx5_devx_rqt_attr *rqt_attr); 2637b4f1e6bSMatan Azrad struct mlx5_devx_obj *mlx5_devx_cmd_create_sq(struct ibv_context *ctx, 2647b4f1e6bSMatan Azrad struct mlx5_devx_create_sq_attr *sq_attr); 2657b4f1e6bSMatan Azrad int mlx5_devx_cmd_modify_sq(struct mlx5_devx_obj *sq, 2667b4f1e6bSMatan Azrad struct mlx5_devx_modify_sq_attr *sq_attr); 2677b4f1e6bSMatan Azrad struct mlx5_devx_obj *mlx5_devx_cmd_create_tis(struct ibv_context *ctx, 2687b4f1e6bSMatan Azrad struct mlx5_devx_tis_attr *tis_attr); 2697b4f1e6bSMatan Azrad struct mlx5_devx_obj *mlx5_devx_cmd_create_td(struct ibv_context *ctx); 2707b4f1e6bSMatan Azrad int mlx5_devx_cmd_flow_dump(void *fdb_domain, void *rx_domain, void *tx_domain, 2717b4f1e6bSMatan Azrad FILE *file); 2727b4f1e6bSMatan Azrad #endif /* RTE_PMD_MLX5_DEVX_CMDS_H_ */ 273