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