1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2020 Mellanox Technologies, Ltd
8 #include <rte_ethdev_driver.h>
9 #include <rte_interrupts.h>
11 #include <mlx5_glue.h>
12 #include <mlx5_devx_cmds.h>
13 #include <mlx5_common.h>
14 #include <mlx5_win_ext.h>
15 #include <mlx5_malloc.h>
19 * Get MAC address by querying netdevice.
22 * Pointer to Ethernet device.
24 * MAC address output buffer.
27 * 0 on success, a negative errno value otherwise and rte_errno is set.
30 mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN])
32 struct mlx5_priv *priv;
33 mlx5_context_st *context_obj;
39 priv = dev->data->dev_private;
40 context_obj = (mlx5_context_st *)priv->sh->ctx;
41 memcpy(mac, context_obj->mlx5_dev.eth_mac, RTE_ETHER_ADDR_LEN);
49 * Pointer to Ethernet device.
54 * 0 on success, a negative errno value otherwise and rte_errno is set.
57 mlx5_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
65 * Unregister callback handler safely. The handler may be active
66 * while we are trying to unregister it, in this case code -EAGAIN
67 * is returned by rte_intr_callback_unregister(). This routine checks
68 * the return code and tries to unregister handler again.
73 * pointer to callback routine
75 * opaque callback parameter
78 mlx5_intr_callback_unregister(const struct rte_intr_handle *handle,
79 rte_intr_callback_fn cb_fn, void *cb_arg)
87 * DPDK callback to get flow control status.
90 * Pointer to Ethernet device structure.
92 * Flow control output buffer.
95 * 0 on success, a negative errno value otherwise and rte_errno is set.
98 mlx5_dev_get_flow_ctrl(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
101 RTE_SET_USED(fc_conf);
106 * DPDK callback to modify flow control parameters.
109 * Pointer to Ethernet device structure.
111 * Flow control parameters.
114 * 0 on success, a negative errno value otherwise and rte_errno is set.
117 mlx5_dev_set_flow_ctrl(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
120 RTE_SET_USED(fc_conf);
125 * Query the number of statistics provided by ETHTOOL.
128 * Pointer to Ethernet device.
131 * Number of statistics on success, negative errno value otherwise and
135 mlx5_os_get_stats_n(struct rte_eth_dev *dev)
142 * Init the structures to read device counters.
145 * Pointer to Ethernet device.
148 mlx5_os_stats_init(struct rte_eth_dev *dev)
154 * Read device counters table.
157 * Pointer to Ethernet device.
159 * Counters table output buffer.
162 * 0 on success and stats is filled, negative errno value otherwise and
166 mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats)
174 * DPDK callback to retrieve physical link information.
177 * Pointer to Ethernet device structure.
178 * @param wait_to_complete
179 * Wait for request completion.
182 * 0 if link status was not updated, positive if it was, a negative errno
183 * value otherwise and rte_errno is set.
186 mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete)
188 RTE_SET_USED(wait_to_complete);
189 struct mlx5_priv *priv;
190 mlx5_context_st *context_obj;
191 struct rte_eth_link dev_link;
199 priv = dev->data->dev_private;
200 context_obj = (mlx5_context_st *)priv->sh->ctx;
201 dev_link.link_speed = context_obj->mlx5_dev.link_speed / (1024 * 1024);
202 dev_link.link_status =
203 (context_obj->mlx5_dev.link_state == 1 && !mlx5_is_removed(dev))
205 dev_link.link_duplex = 1;
206 if (dev->data->dev_link.link_speed != dev_link.link_speed ||
207 dev->data->dev_link.link_duplex != dev_link.link_duplex ||
208 dev->data->dev_link.link_autoneg != dev_link.link_autoneg ||
209 dev->data->dev_link.link_status != dev_link.link_status)
213 dev->data->dev_link = dev_link;
218 * DPDK callback to bring the link DOWN.
221 * Pointer to Ethernet device structure.
224 * 0 on success, a negative errno value otherwise
227 mlx5_set_link_down(struct rte_eth_dev *dev)
234 * DPDK callback to bring the link UP.
237 * Pointer to Ethernet device structure.
240 * 0 on success, a negative errno value otherwise
243 mlx5_set_link_up(struct rte_eth_dev *dev)
250 * DPDK callback to retrieve plug-in module EEPROM information (type and size).
253 * Pointer to Ethernet device structure.
254 * @param[out] modinfo
255 * Storage for plug-in module EEPROM information.
258 * 0 on success, a negative errno value otherwise and rte_errno is set.
261 mlx5_get_module_info(struct rte_eth_dev *dev,
262 struct rte_eth_dev_module_info *modinfo)
265 RTE_SET_USED(modinfo);
270 * DPDK callback to retrieve plug-in module EEPROM data.
273 * Pointer to Ethernet device structure.
275 * Storage for plug-in module EEPROM data.
278 * 0 on success, a negative errno value otherwise and rte_errno is set.
280 int mlx5_get_module_eeprom(struct rte_eth_dev *dev,
281 struct rte_dev_eeprom_info *info)