7903673264c3b59d87f8eb600749bb7e2dabec83
[dpdk.git] / drivers / net / mlx5 / mlx5_nl.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2019 Mellanox Technologies, Ltd
3  */
4
5 #ifndef RTE_PMD_MLX5_NL_H_
6 #define RTE_PMD_MLX5_NL_H_
7
8 #include <linux/netlink.h>
9
10
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. */
18 };
19
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. */
28 };
29
30 /* VLAN netdev for VLAN workaround. */
31 struct mlx5_nl_vlan_dev {
32         uint32_t refcnt;
33         uint32_t ifindex; /**< Own interface index. */
34 };
35
36 /*
37  * Array of VLAN devices created on the base of VF
38  * used for workaround in virtual environments.
39  */
40 struct mlx5_nl_vlan_vmwa_context {
41         int nl_socket;
42         uint32_t nl_sn;
43         uint32_t vf_ifindex;
44         struct mlx5_nl_vlan_dev vlan_dev[4096];
45 };
46
47
48 int mlx5_nl_init(int protocol);
49 int mlx5_nl_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
50                          uint32_t index);
51 int mlx5_nl_mac_addr_remove(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
52                             uint32_t index);
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);
63
64 void mlx5_nl_vlan_vmwa_delete(struct mlx5_nl_vlan_vmwa_context *vmwa,
65                            uint32_t ifindex);
66 uint32_t mlx5_nl_vlan_vmwa_create(struct mlx5_nl_vlan_vmwa_context *vmwa,
67                                   uint32_t ifindex, uint16_t tag);
68
69 #endif /* RTE_PMD_MLX5_NL_H_ */