1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright 2020 Mellanox Technologies, Ltd 3 */ 4 #include <stdio.h> 5 6 #include <rte_errno.h> 7 #include <rte_ether.h> 8 #include <rte_ethdev_driver.h> 9 #include <rte_interrupts.h> 10 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> 16 #include <mlx5.h> 17 18 /** 19 * Get MAC address by querying netdevice. 20 * 21 * @param[in] dev 22 * Pointer to Ethernet device. 23 * @param[out] mac 24 * MAC address output buffer. 25 * 26 * @return 27 * 0 on success, a negative errno value otherwise and rte_errno is set. 28 */ 29 int 30 mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN]) 31 { 32 struct mlx5_priv *priv; 33 mlx5_context_st *context_obj; 34 35 if (!dev) { 36 rte_errno = EINVAL; 37 return -rte_errno; 38 } 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); 42 return 0; 43 } 44