linux/drivers/net/ethernet/huawei/hinic/hinic_sriov.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0-only */
   2/* Huawei HiNIC PCI Express Linux driver
   3 * Copyright(c) 2017 Huawei Technologies Co., Ltd
   4 */
   5
   6#ifndef HINIC_SRIOV_H
   7#define HINIC_SRIOV_H
   8
   9#include "hinic_hw_dev.h"
  10
  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)
  13
  14enum hinic_sriov_state {
  15        HINIC_SRIOV_DISABLE,
  16        HINIC_SRIOV_ENABLE,
  17        HINIC_FUNC_REMOVE,
  18};
  19
  20enum {
  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 */
  24};
  25
  26struct hinic_sriov_info {
  27        struct pci_dev *pdev;
  28        struct hinic_hwdev *hwdev;
  29        bool sriov_enabled;
  30        unsigned int num_vfs;
  31        unsigned long state;
  32};
  33
  34struct vf_data_storage {
  35        u8 vf_mac_addr[ETH_ALEN];
  36        bool registered;
  37        bool pf_set_mac;
  38        u16 pf_vlan;
  39        u8 pf_qos;
  40        u32 max_rate;
  41        u32 min_rate;
  42
  43        bool link_forced;
  44        bool link_up;           /* only valid if VF link is forced */
  45        bool spoofchk;
  46        bool trust;
  47};
  48
  49struct hinic_register_vf {
  50        u8      status;
  51        u8      version;
  52        u8      rsvd0[6];
  53};
  54
  55struct hinic_port_mac_update {
  56        u8      status;
  57        u8      version;
  58        u8      rsvd0[6];
  59
  60        u16     func_id;
  61        u16     vlan_id;
  62        u16     rsvd1;
  63        u8      old_mac[ETH_ALEN];
  64        u16     rsvd2;
  65        u8      new_mac[ETH_ALEN];
  66};
  67
  68struct hinic_vf_vlan_config {
  69        u8 status;
  70        u8 version;
  71        u8 rsvd0[6];
  72
  73        u16 func_id;
  74        u16 vlan_id;
  75        u8  qos;
  76        u8  rsvd1[7];
  77};
  78
  79int hinic_ndo_set_vf_mac(struct net_device *netdev, int vf, u8 *mac);
  80
  81int hinic_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos,
  82                          __be16 vlan_proto);
  83
  84int hinic_ndo_get_vf_config(struct net_device *netdev,
  85                            int vf, struct ifla_vf_info *ivi);
  86
  87int hinic_ndo_set_vf_trust(struct net_device *netdev, int vf, bool setting);
  88
  89int hinic_ndo_set_vf_bw(struct net_device *netdev,
  90                        int vf, int min_tx_rate, int max_tx_rate);
  91
  92int hinic_ndo_set_vf_spoofchk(struct net_device *netdev, int vf, bool setting);
  93
  94int hinic_ndo_set_vf_link_state(struct net_device *netdev, int vf_id, int link);
  95
  96void hinic_notify_all_vfs_link_changed(struct hinic_hwdev *hwdev,
  97                                       u8 link_status);
  98
  99int hinic_pci_sriov_disable(struct pci_dev *dev);
 100
 101int hinic_pci_sriov_enable(struct pci_dev *dev, int num_vfs);
 102
 103int hinic_vf_func_init(struct hinic_hwdev *hwdev);
 104
 105void hinic_vf_func_free(struct hinic_hwdev *hwdev);
 106
 107int hinic_pci_sriov_configure(struct pci_dev *dev, int num_vfs);
 108
 109#endif
 110