1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2020 Mellanox Technologies, Ltd
11 #include <rte_windows.h>
13 #include <mlx5_glue.h>
14 #include <mlx5_devx_cmds.h>
15 #include <mlx5_common.h>
16 #include <mlx5_common_mp.h>
17 #include <mlx5_common_mr.h>
18 #include <mlx5_malloc.h>
20 #include "mlx5_defs.h"
22 #include "mlx5_common_os.h"
23 #include "mlx5_utils.h"
24 #include "mlx5_rxtx.h"
25 #include "mlx5_autoconf.h"
27 #include "mlx5_flow.h"
30 * Get mlx5 device attributes.
33 * Pointer to device context.
36 * Pointer to mlx5 device attributes.
39 * 0 on success, non zero error number otherwise
42 mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *device_attr)
44 struct mlx5_context *mlx5_ctx;
45 struct mlx5_hca_attr hca_attr;
52 mlx5_ctx = (struct mlx5_context *)ctx;
53 memset(device_attr, 0, sizeof(*device_attr));
54 err = mlx5_devx_cmd_query_hca_attr(mlx5_ctx, &hca_attr);
56 DRV_LOG(ERR, "Failed to get device hca_cap");
59 device_attr->max_cq = 1 << hca_attr.log_max_cq;
60 device_attr->max_qp = 1 << hca_attr.log_max_qp;
61 device_attr->max_qp_wr = 1 << hca_attr.log_max_qp_sz;
62 device_attr->max_cqe = 1 << hca_attr.log_max_cq_sz;
63 device_attr->max_mr = 1 << hca_attr.log_max_mrw_sz;
64 device_attr->max_pd = 1 << hca_attr.log_max_pd;
65 device_attr->max_srq = 1 << hca_attr.log_max_srq;
66 device_attr->max_srq_wr = 1 << hca_attr.log_max_srq_sz;
67 if (hca_attr.rss_ind_tbl_cap) {
68 device_attr->max_rwq_indirection_table_size =
69 1 << hca_attr.rss_ind_tbl_cap;
71 pv_iseg = mlx5_glue->query_hca_iseg(mlx5_ctx, &cb_iseg);
72 if (pv_iseg == NULL) {
73 DRV_LOG(ERR, "Failed to get device hca_iseg");
77 snprintf(device_attr->fw_ver, 64, "%x.%x.%04x",
78 MLX5_GET(initial_seg, pv_iseg, fw_rev_major),
79 MLX5_GET(initial_seg, pv_iseg, fw_rev_minor),
80 MLX5_GET(initial_seg, pv_iseg, fw_rev_subminor));
86 * Set the completion channel file descriptor interrupt as non-blocking.
87 * Currently it has no support under Windows.
90 * Pointer to RQ channel object, which includes the channel fd
93 * The file descriptor (representing the intetrrupt) used in this channel.
96 * 0 on successfully setting the fd to non-blocking, non-zero otherwise.
99 mlx5_os_set_nonblock_channel_fd(int fd)
102 DRV_LOG(WARNING, "%s: is not supported", __func__);
107 * This function should share events between multiple ports of single IB
108 * device. Currently it has no support under Windows.
111 * Pointer to mlx5_dev_ctx_shared object.
114 mlx5_os_dev_shared_handler_install(struct mlx5_dev_ctx_shared *sh)
117 DRV_LOG(WARNING, "%s: is not supported", __func__);
121 * This function should share events between multiple ports of single IB
122 * device. Currently it has no support under Windows.
125 * Pointer to mlx5_dev_ctx_shared object.
128 mlx5_os_dev_shared_handler_uninstall(struct mlx5_dev_ctx_shared *sh)
131 DRV_LOG(WARNING, "%s: is not supported", __func__);
135 * Read statistics by a named counter.
138 * Pointer to the private device data structure.
139 * @param[in] ctr_name
140 * Pointer to the name of the statistic counter to read
142 * Pointer to read statistic value.
144 * 0 on success and stat is valud, 1 if failed to read the value
149 mlx5_os_read_dev_stat(struct mlx5_priv *priv, const char *ctr_name,
153 RTE_SET_USED(ctr_name);
155 DRV_LOG(WARNING, "%s: is not supported", __func__);
160 * Flush device MAC addresses
161 * Currently it has no support under Windows.
164 * Pointer to Ethernet device structure.
168 mlx5_os_mac_addr_flush(struct rte_eth_dev *dev)
171 DRV_LOG(WARNING, "%s: is not supported", __func__);
175 * Remove a MAC address from device
176 * Currently it has no support under Windows.
179 * Pointer to Ethernet device structure.
184 mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
188 DRV_LOG(WARNING, "%s: is not supported", __func__);
192 * Adds a MAC address to the device
193 * Currently it has no support under Windows.
196 * Pointer to Ethernet device structure.
198 * MAC address to register.
203 * 0 on success, a negative errno value otherwise
206 mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
210 struct rte_ether_addr lmac;
212 if (mlx5_get_mac(dev, &lmac.addr_bytes)) {
214 "port %u cannot get MAC address, is mlx5_en"
215 " loaded? (errno: %s)",
216 dev->data->port_id, strerror(rte_errno));
219 if (!rte_is_same_ether_addr(&lmac, mac)) {
221 "adding new mac address to device is unsupported");
228 * Modify a VF MAC address
229 * Currently it has no support under Windows.
232 * Pointer to device private data.
234 * MAC address to modify into.
236 * Net device interface index
241 * 0 on success, a negative errno value otherwise
244 mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv,
245 unsigned int iface_idx,
246 struct rte_ether_addr *mac_addr,
253 DRV_LOG(WARNING, "%s: is not supported", __func__);
258 * Set device promiscuous mode
259 * Currently it has no support under Windows.
262 * Pointer to Ethernet device structure.
264 * 0 - promiscuous is disabled, otherwise - enabled
267 * 0 on success, a negative error value otherwise
270 mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable)
274 DRV_LOG(WARNING, "%s: is not supported", __func__);
279 * Set device allmulti mode
282 * Pointer to Ethernet device structure.
284 * 0 - all multicase is disabled, otherwise - enabled
287 * 0 on success, a negative error value otherwise
290 mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable)
294 DRV_LOG(WARNING, "%s: is not supported", __func__);
298 const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = {0};
300 const struct eth_dev_ops mlx5_os_dev_ops = {
301 .dev_configure = mlx5_dev_configure,
302 .dev_start = mlx5_dev_start,
303 .dev_stop = mlx5_dev_stop,
304 .dev_close = mlx5_dev_close,
305 .mtu_set = mlx5_dev_set_mtu,
306 .link_update = mlx5_link_update,
307 .stats_get = mlx5_stats_get,
308 .stats_reset = mlx5_stats_reset,
309 .dev_infos_get = mlx5_dev_infos_get,
310 .dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get,
311 .promiscuous_enable = mlx5_promiscuous_enable,
312 .promiscuous_disable = mlx5_promiscuous_disable,
313 .allmulticast_enable = mlx5_allmulticast_enable,
314 .allmulticast_disable = mlx5_allmulticast_disable,
315 .xstats_get = mlx5_xstats_get,
316 .xstats_reset = mlx5_xstats_reset,
317 .xstats_get_names = mlx5_xstats_get_names,
318 .fw_version_get = mlx5_fw_version_get,
319 .read_clock = mlx5_read_clock,
320 .vlan_filter_set = mlx5_vlan_filter_set,
321 .rx_queue_setup = mlx5_rx_queue_setup,
322 .rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup,
323 .tx_queue_setup = mlx5_tx_queue_setup,
324 .tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
325 .rx_queue_release = mlx5_rx_queue_release,
326 .tx_queue_release = mlx5_tx_queue_release,
327 .flow_ctrl_get = mlx5_dev_get_flow_ctrl,
328 .flow_ctrl_set = mlx5_dev_set_flow_ctrl,
329 .mac_addr_remove = mlx5_mac_addr_remove,
330 .mac_addr_add = mlx5_mac_addr_add,
331 .mac_addr_set = mlx5_mac_addr_set,
332 .set_mc_addr_list = mlx5_set_mc_addr_list,
333 .vlan_strip_queue_set = mlx5_vlan_strip_queue_set,
334 .vlan_offload_set = mlx5_vlan_offload_set,
335 .reta_update = mlx5_dev_rss_reta_update,
336 .reta_query = mlx5_dev_rss_reta_query,
337 .rss_hash_update = mlx5_rss_hash_update,
338 .rss_hash_conf_get = mlx5_rss_hash_conf_get,
339 .filter_ctrl = mlx5_dev_filter_ctrl,
340 .rxq_info_get = mlx5_rxq_info_get,
341 .txq_info_get = mlx5_txq_info_get,
342 .rx_burst_mode_get = mlx5_rx_burst_mode_get,
343 .tx_burst_mode_get = mlx5_tx_burst_mode_get,
344 .rx_queue_intr_enable = mlx5_rx_intr_enable,
345 .rx_queue_intr_disable = mlx5_rx_intr_disable,
346 .is_removed = mlx5_is_removed,
347 .udp_tunnel_port_add = mlx5_udp_tunnel_port_add,
348 .get_module_info = mlx5_get_module_info,
349 .get_module_eeprom = mlx5_get_module_eeprom,
350 .hairpin_cap_get = mlx5_hairpin_cap_get,
351 .mtr_ops_get = mlx5_flow_meter_ops_get,
354 /* Available operations from secondary process. */
355 const struct eth_dev_ops mlx5_os_dev_sec_ops = {0};
357 /* Available operations in flow isolated mode. */
358 const struct eth_dev_ops mlx5_os_dev_ops_isolate = {
359 .dev_configure = mlx5_dev_configure,
360 .dev_start = mlx5_dev_start,
361 .dev_stop = mlx5_dev_stop,
362 .dev_close = mlx5_dev_close,
363 .mtu_set = mlx5_dev_set_mtu,
364 .link_update = mlx5_link_update,
365 .stats_get = mlx5_stats_get,
366 .stats_reset = mlx5_stats_reset,
367 .dev_infos_get = mlx5_dev_infos_get,
368 .dev_set_link_down = mlx5_set_link_down,
369 .dev_set_link_up = mlx5_set_link_up,
370 .promiscuous_enable = mlx5_promiscuous_enable,
371 .promiscuous_disable = mlx5_promiscuous_disable,
372 .allmulticast_enable = mlx5_allmulticast_enable,
373 .allmulticast_disable = mlx5_allmulticast_disable,
374 .xstats_get = mlx5_xstats_get,
375 .xstats_reset = mlx5_xstats_reset,
376 .xstats_get_names = mlx5_xstats_get_names,
377 .fw_version_get = mlx5_fw_version_get,
378 .dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get,
379 .vlan_filter_set = mlx5_vlan_filter_set,
380 .rx_queue_setup = mlx5_rx_queue_setup,
381 .rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup,
382 .tx_queue_setup = mlx5_tx_queue_setup,
383 .tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
384 .rx_queue_release = mlx5_rx_queue_release,
385 .tx_queue_release = mlx5_tx_queue_release,
386 .flow_ctrl_get = mlx5_dev_get_flow_ctrl,
387 .flow_ctrl_set = mlx5_dev_set_flow_ctrl,
388 .mac_addr_remove = mlx5_mac_addr_remove,
389 .mac_addr_add = mlx5_mac_addr_add,
390 .mac_addr_set = mlx5_mac_addr_set,
391 .set_mc_addr_list = mlx5_set_mc_addr_list,
392 .vlan_strip_queue_set = mlx5_vlan_strip_queue_set,
393 .vlan_offload_set = mlx5_vlan_offload_set,
394 .filter_ctrl = mlx5_dev_filter_ctrl,
395 .rxq_info_get = mlx5_rxq_info_get,
396 .txq_info_get = mlx5_txq_info_get,
397 .rx_burst_mode_get = mlx5_rx_burst_mode_get,
398 .tx_burst_mode_get = mlx5_tx_burst_mode_get,
399 .rx_queue_intr_enable = mlx5_rx_intr_enable,
400 .rx_queue_intr_disable = mlx5_rx_intr_disable,
401 .is_removed = mlx5_is_removed,
402 .get_module_info = mlx5_get_module_info,
403 .get_module_eeprom = mlx5_get_module_eeprom,
404 .hairpin_cap_get = mlx5_hairpin_cap_get,
405 .mtr_ops_get = mlx5_flow_meter_ops_get,