1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2019 Mellanox Technologies, Ltd
5 #ifndef RTE_PMD_MLX5_NL_H_
6 #define RTE_PMD_MLX5_NL_H_
8 #include <linux/netlink.h>
11 /* Recognized Infiniband device physical port name types. */
12 enum mlx5_nl_phys_port_name_type {
13 MLX5_PHYS_PORT_NAME_TYPE_NOTSET = 0, /* Not set. */
14 MLX5_PHYS_PORT_NAME_TYPE_LEGACY, /* before kernel ver < 5.0 */
15 MLX5_PHYS_PORT_NAME_TYPE_UPLINK, /* p0, kernel ver >= 5.0 */
16 MLX5_PHYS_PORT_NAME_TYPE_PFVF, /* pf0vf0, kernel ver >= 5.0 */
17 MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN, /* Unrecognized. */
20 /** Switch information returned by mlx5_nl_switch_info(). */
21 struct mlx5_switch_info {
22 uint32_t master:1; /**< Master device. */
23 uint32_t representor:1; /**< Representor device. */
24 enum mlx5_nl_phys_port_name_type name_type; /** < Port name type. */
25 int32_t pf_num; /**< PF number (valid for pfxvfx format only). */
26 int32_t port_name; /**< Representor port name. */
27 uint64_t switch_id; /**< Switch identifier. */
30 /* VLAN netdev for VLAN workaround. */
31 struct mlx5_nl_vlan_dev {
33 uint32_t ifindex; /**< Own interface index. */
37 * Array of VLAN devices created on the base of VF
38 * used for workaround in virtual environments.
40 struct mlx5_nl_vlan_vmwa_context {
44 struct mlx5_nl_vlan_dev vlan_dev[4096];
48 int mlx5_nl_init(int protocol);
49 int mlx5_nl_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
51 int mlx5_nl_mac_addr_remove(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
53 void mlx5_nl_mac_addr_sync(struct rte_eth_dev *dev);
54 void mlx5_nl_mac_addr_flush(struct rte_eth_dev *dev);
55 int mlx5_nl_promisc(struct rte_eth_dev *dev, int enable);
56 int mlx5_nl_allmulti(struct rte_eth_dev *dev, int enable);
57 unsigned int mlx5_nl_portnum(int nl, const char *name);
58 unsigned int mlx5_nl_ifindex(int nl, const char *name, uint32_t pindex);
59 int mlx5_nl_vf_mac_addr_modify(struct rte_eth_dev *dev,
60 struct rte_ether_addr *mac, int vf_index);
61 int mlx5_nl_switch_info(int nl, unsigned int ifindex,
62 struct mlx5_switch_info *info);
64 void mlx5_nl_vlan_vmwa_delete(struct mlx5_nl_vlan_vmwa_context *vmwa,
66 uint32_t mlx5_nl_vlan_vmwa_create(struct mlx5_nl_vlan_vmwa_context *vmwa,
67 uint32_t ifindex, uint16_t tag);
69 #endif /* RTE_PMD_MLX5_NL_H_ */