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 MLX5_DOMAIN_BIT_NIC_RX (1 << 0) /**< NIC RX domain bit mask. */ 42 #define MLX5_DOMAIN_BIT_NIC_TX (1 << 1) /**< NIC TX domain bit mask. */ 43 #define 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 * 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 MLX5_EXTERNAL_RX_QUEUE_ID_MIN (UINT16_MAX - 1000 + 1) 70 71 /** 72 * Update mapping between rte_flow queue index (16 bits) and HW queue index (32 73 * bits) for RxQs which is created outside the PMD. 74 * 75 * @param[in] port_id 76 * The port identifier of the Ethernet device. 77 * @param[in] dpdk_idx 78 * Queue index in rte_flow. 79 * @param[in] hw_idx 80 * Queue index in hardware. 81 * 82 * @return 83 * 0 on success, a negative errno value otherwise and rte_errno is set. 84 * Possible values for rte_errno: 85 * - EEXIST - a mapping with the same rte_flow index already exists. 86 * - EINVAL - invalid rte_flow index, out of range. 87 * - ENODEV - there is no Ethernet device for this port id. 88 * - ENOTSUP - the port doesn't support external RxQ. 89 */ 90 __rte_experimental 91 int rte_pmd_mlx5_external_rx_queue_id_map(uint16_t port_id, uint16_t dpdk_idx, 92 uint32_t hw_idx); 93 94 /** 95 * Remove mapping between rte_flow queue index (16 bits) and HW queue index (32 96 * bits) for RxQs which is created outside the PMD. 97 * 98 * @param[in] port_id 99 * The port identifier of the Ethernet device. 100 * @param[in] dpdk_idx 101 * Queue index in rte_flow. 102 * 103 * @return 104 * 0 on success, a negative errno value otherwise and rte_errno is set. 105 * Possible values for rte_errno: 106 * - EINVAL - invalid index, out of range, still referenced or doesn't exist. 107 * - ENODEV - there is no Ethernet device for this port id. 108 * - ENOTSUP - the port doesn't support external RxQ. 109 */ 110 __rte_experimental 111 int rte_pmd_mlx5_external_rx_queue_id_unmap(uint16_t port_id, 112 uint16_t dpdk_idx); 113 114 /** 115 * The rate of the host port shaper will be updated directly at the next 116 * available descriptor threshold event to the rate that comes with this flag set; 117 * set rate 0 to disable this rate update. 118 * Unset this flag to update the rate of the host port shaper directly in 119 * the API call; use rate 0 to disable the current shaper. 120 */ 121 #define MLX5_HOST_SHAPER_FLAG_AVAIL_THRESH_TRIGGERED 0 122 123 /** 124 * Configure a HW shaper to limit Tx rate for a host port. 125 * The configuration will affect all the ethdev ports belonging to 126 * the same rte_device. 127 * 128 * @param[in] port_id 129 * The port identifier of the Ethernet device. 130 * @param[in] rate 131 * Unit is 100Mbps, setting the rate to 0 disables the shaper. 132 * @param[in] flags 133 * Host shaper flags. 134 * @return 135 * 0 : operation success. 136 * Otherwise: 137 * - ENOENT - no ibdev interface. 138 * - EBUSY - the register access unit is busy. 139 * - EIO - the register access command meets IO error. 140 */ 141 __rte_experimental 142 int rte_pmd_mlx5_host_shaper_config(int port_id, uint8_t rate, uint32_t flags); 143 144 /** 145 * Enable traffic for external SQ. 146 * 147 * @param[in] port_id 148 * The port identifier of the Ethernet device. 149 * @param[in] sq_num 150 * SQ HW number. 151 * 152 * @return 153 * 0 on success, a negative errno value otherwise and rte_errno is set. 154 * Possible values for rte_errno: 155 * - EINVAL - invalid sq_number or port type. 156 * - ENODEV - there is no Ethernet device for this port id. 157 */ 158 __rte_experimental 159 int rte_pmd_mlx5_external_sq_enable(uint16_t port_id, uint32_t sq_num); 160 161 #ifdef __cplusplus 162 } 163 #endif 164 165 #endif /* RTE_PMD_PRIVATE_MLX5_H_ */ 166