18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* Huawei HiNIC PCI Express Linux driver 38c2ecf20Sopenharmony_ci * Copyright(c) 2017 Huawei Technologies Co., Ltd 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef HINIC_SRIOV_H 78c2ecf20Sopenharmony_ci#define HINIC_SRIOV_H 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include "hinic_hw_dev.h" 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#define OS_VF_ID_TO_HW(os_vf_id) ((os_vf_id) + 1) 128c2ecf20Sopenharmony_ci#define HW_VF_ID_TO_OS(hw_vf_id) ((hw_vf_id) - 1) 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_cienum hinic_sriov_state { 158c2ecf20Sopenharmony_ci HINIC_SRIOV_DISABLE, 168c2ecf20Sopenharmony_ci HINIC_SRIOV_ENABLE, 178c2ecf20Sopenharmony_ci HINIC_FUNC_REMOVE, 188c2ecf20Sopenharmony_ci}; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_cienum { 218c2ecf20Sopenharmony_ci HINIC_IFLA_VF_LINK_STATE_AUTO, /* link state of the uplink */ 228c2ecf20Sopenharmony_ci HINIC_IFLA_VF_LINK_STATE_ENABLE, /* link always up */ 238c2ecf20Sopenharmony_ci HINIC_IFLA_VF_LINK_STATE_DISABLE, /* link always down */ 248c2ecf20Sopenharmony_ci}; 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cistruct hinic_sriov_info { 278c2ecf20Sopenharmony_ci struct pci_dev *pdev; 288c2ecf20Sopenharmony_ci struct hinic_hwdev *hwdev; 298c2ecf20Sopenharmony_ci bool sriov_enabled; 308c2ecf20Sopenharmony_ci unsigned int num_vfs; 318c2ecf20Sopenharmony_ci unsigned long state; 328c2ecf20Sopenharmony_ci}; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistruct vf_data_storage { 358c2ecf20Sopenharmony_ci u8 vf_mac_addr[ETH_ALEN]; 368c2ecf20Sopenharmony_ci bool registered; 378c2ecf20Sopenharmony_ci bool pf_set_mac; 388c2ecf20Sopenharmony_ci u16 pf_vlan; 398c2ecf20Sopenharmony_ci u8 pf_qos; 408c2ecf20Sopenharmony_ci u32 max_rate; 418c2ecf20Sopenharmony_ci u32 min_rate; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci bool link_forced; 448c2ecf20Sopenharmony_ci bool link_up; /* only valid if VF link is forced */ 458c2ecf20Sopenharmony_ci bool spoofchk; 468c2ecf20Sopenharmony_ci bool trust; 478c2ecf20Sopenharmony_ci}; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_cistruct hinic_register_vf { 508c2ecf20Sopenharmony_ci u8 status; 518c2ecf20Sopenharmony_ci u8 version; 528c2ecf20Sopenharmony_ci u8 rsvd0[6]; 538c2ecf20Sopenharmony_ci}; 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_cistruct hinic_port_mac_update { 568c2ecf20Sopenharmony_ci u8 status; 578c2ecf20Sopenharmony_ci u8 version; 588c2ecf20Sopenharmony_ci u8 rsvd0[6]; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci u16 func_id; 618c2ecf20Sopenharmony_ci u16 vlan_id; 628c2ecf20Sopenharmony_ci u16 rsvd1; 638c2ecf20Sopenharmony_ci u8 old_mac[ETH_ALEN]; 648c2ecf20Sopenharmony_ci u16 rsvd2; 658c2ecf20Sopenharmony_ci u8 new_mac[ETH_ALEN]; 668c2ecf20Sopenharmony_ci}; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_cistruct hinic_vf_vlan_config { 698c2ecf20Sopenharmony_ci u8 status; 708c2ecf20Sopenharmony_ci u8 version; 718c2ecf20Sopenharmony_ci u8 rsvd0[6]; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci u16 func_id; 748c2ecf20Sopenharmony_ci u16 vlan_id; 758c2ecf20Sopenharmony_ci u8 qos; 768c2ecf20Sopenharmony_ci u8 rsvd1[7]; 778c2ecf20Sopenharmony_ci}; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ciint hinic_ndo_set_vf_mac(struct net_device *netdev, int vf, u8 *mac); 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ciint hinic_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos, 828c2ecf20Sopenharmony_ci __be16 vlan_proto); 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ciint hinic_ndo_get_vf_config(struct net_device *netdev, 858c2ecf20Sopenharmony_ci int vf, struct ifla_vf_info *ivi); 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ciint hinic_ndo_set_vf_trust(struct net_device *netdev, int vf, bool setting); 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ciint hinic_ndo_set_vf_bw(struct net_device *netdev, 908c2ecf20Sopenharmony_ci int vf, int min_tx_rate, int max_tx_rate); 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ciint hinic_ndo_set_vf_spoofchk(struct net_device *netdev, int vf, bool setting); 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ciint hinic_ndo_set_vf_link_state(struct net_device *netdev, int vf_id, int link); 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_civoid hinic_notify_all_vfs_link_changed(struct hinic_hwdev *hwdev, 978c2ecf20Sopenharmony_ci u8 link_status); 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ciint hinic_pci_sriov_disable(struct pci_dev *dev); 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ciint hinic_pci_sriov_enable(struct pci_dev *dev, int num_vfs); 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ciint hinic_vf_func_init(struct hinic_hwdev *hwdev); 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_civoid hinic_vf_func_free(struct hinic_hwdev *hwdev); 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ciint hinic_pci_sriov_configure(struct pci_dev *dev, int num_vfs); 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci#endif 110