1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Huawei HiNIC PCI Express Linux driver
3 * Copyright(c) 2017 Huawei Technologies Co., Ltd
9 #include "hinic_hw_dev.h"
11 #define OS_VF_ID_TO_HW(os_vf_id) ((os_vf_id) + 1)
12 #define HW_VF_ID_TO_OS(hw_vf_id) ((hw_vf_id) - 1)
14 enum hinic_sriov_state
{
21 HINIC_IFLA_VF_LINK_STATE_AUTO
, /* link state of the uplink */
22 HINIC_IFLA_VF_LINK_STATE_ENABLE
, /* link always up */
23 HINIC_IFLA_VF_LINK_STATE_DISABLE
, /* link always down */
26 struct hinic_sriov_info
{
28 struct hinic_hwdev
*hwdev
;
34 struct vf_data_storage
{
35 u8 vf_mac_addr
[ETH_ALEN
];
44 bool link_up
; /* only valid if VF link is forced */
49 struct hinic_register_vf
{
55 struct hinic_port_mac_update
{
68 struct hinic_vf_vlan_config
{
79 int hinic_ndo_set_vf_mac(struct net_device
*netdev
, int vf
, u8
*mac
);
81 int hinic_ndo_set_vf_vlan(struct net_device
*netdev
, int vf
, u16 vlan
, u8 qos
,
84 int hinic_ndo_get_vf_config(struct net_device
*netdev
,
85 int vf
, struct ifla_vf_info
*ivi
);
87 int hinic_ndo_set_vf_trust(struct net_device
*netdev
, int vf
, bool setting
);
89 int hinic_ndo_set_vf_bw(struct net_device
*netdev
,
90 int vf
, int min_tx_rate
, int max_tx_rate
);
92 int hinic_ndo_set_vf_spoofchk(struct net_device
*netdev
, int vf
, bool setting
);
94 int hinic_ndo_set_vf_link_state(struct net_device
*netdev
, int vf_id
, int link
);
96 void hinic_notify_all_vfs_link_changed(struct hinic_hwdev
*hwdev
,
99 int hinic_pci_sriov_disable(struct pci_dev
*dev
);
101 int hinic_pci_sriov_enable(struct pci_dev
*dev
, int num_vfs
);
103 int hinic_vf_func_init(struct hinic_hwdev
*hwdev
);
105 void hinic_vf_func_free(struct hinic_hwdev
*hwdev
);
107 int hinic_pci_sriov_configure(struct pci_dev
*dev
, int num_vfs
);