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 #include <rte_ether.h> 11 12 #include "mlx5_common.h" 13 14 typedef void (mlx5_nl_event_cb)(struct nlmsghdr *hdr, void *user_data); 15 16 /* VLAN netdev for VLAN workaround. */ 17 struct mlx5_nl_vlan_dev { 18 uint32_t refcnt; 19 uint32_t ifindex; /**< Own interface index. */ 20 }; 21 22 /* 23 * Array of VLAN devices created on the base of VF 24 * used for workaround in virtual environments. 25 */ 26 struct mlx5_nl_vlan_vmwa_context { 27 int nl_socket; 28 uint32_t vf_ifindex; 29 rte_spinlock_t sl; 30 struct mlx5_nl_vlan_dev vlan_dev[4096]; 31 }; 32 33 __rte_internal 34 int mlx5_nl_init(int protocol, int groups); 35 __rte_internal 36 int mlx5_nl_mac_addr_add(int nlsk_fd, unsigned int iface_idx, uint64_t *mac_own, 37 struct rte_ether_addr *mac, uint32_t index); 38 __rte_internal 39 int mlx5_nl_mac_addr_remove(int nlsk_fd, unsigned int iface_idx, 40 uint64_t *mac_own, struct rte_ether_addr *mac, 41 uint32_t index); 42 __rte_internal 43 void mlx5_nl_mac_addr_sync(int nlsk_fd, unsigned int iface_idx, 44 struct rte_ether_addr *mac_addrs, int n); 45 __rte_internal 46 void mlx5_nl_mac_addr_flush(int nlsk_fd, unsigned int iface_idx, 47 struct rte_ether_addr *mac_addrs, int n, 48 uint64_t *mac_own); 49 __rte_internal 50 int mlx5_nl_promisc(int nlsk_fd, unsigned int iface_idx, int enable); 51 __rte_internal 52 int mlx5_nl_allmulti(int nlsk_fd, unsigned int iface_idx, int enable); 53 __rte_internal 54 unsigned int mlx5_nl_portnum(int nl, const char *name); 55 __rte_internal 56 unsigned int mlx5_nl_ifindex(int nl, const char *name, uint32_t pindex); 57 __rte_internal 58 int mlx5_nl_port_state(int nl, const char *name, uint32_t pindex); 59 __rte_internal 60 int mlx5_nl_vf_mac_addr_modify(int nlsk_fd, unsigned int iface_idx, 61 struct rte_ether_addr *mac, int vf_index); 62 __rte_internal 63 int mlx5_nl_switch_info(int nl, unsigned int ifindex, 64 struct mlx5_switch_info *info); 65 66 __rte_internal 67 void mlx5_nl_vlan_vmwa_delete(struct mlx5_nl_vlan_vmwa_context *vmwa, 68 uint32_t ifindex); 69 __rte_internal 70 uint32_t mlx5_nl_vlan_vmwa_create(struct mlx5_nl_vlan_vmwa_context *vmwa, 71 uint32_t ifindex, uint16_t tag); 72 73 int mlx5_nl_devlink_family_id_get(int nlsk_fd); 74 int mlx5_nl_enable_roce_get(int nlsk_fd, int family_id, const char *pci_addr, 75 int *enable); 76 int mlx5_nl_enable_roce_set(int nlsk_fd, int family_id, const char *pci_addr, 77 int enable); 78 79 __rte_internal 80 int mlx5_nl_read_events(int nlsk_fd, mlx5_nl_event_cb *cb, void *cb_arg); 81 __rte_internal 82 int mlx5_nl_parse_link_status_update(struct nlmsghdr *hdr, uint32_t *ifindex); 83 84 #endif /* RTE_PMD_MLX5_NL_H_ */ 85