1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 #ifndef NFP_MAIN_H
  10 #define NFP_MAIN_H
  11 
  12 #include <linux/ethtool.h>
  13 #include <linux/list.h>
  14 #include <linux/types.h>
  15 #include <linux/msi.h>
  16 #include <linux/mutex.h>
  17 #include <linux/pci.h>
  18 #include <linux/workqueue.h>
  19 #include <net/devlink.h>
  20 
  21 struct dentry;
  22 struct device;
  23 struct pci_dev;
  24 
  25 struct nfp_cpp;
  26 struct nfp_cpp_area;
  27 struct nfp_eth_table;
  28 struct nfp_hwinfo;
  29 struct nfp_mip;
  30 struct nfp_net;
  31 struct nfp_nsp_identify;
  32 struct nfp_port;
  33 struct nfp_rtsym;
  34 struct nfp_rtsym_table;
  35 struct nfp_shared_buf;
  36 
  37 
  38 
  39 
  40 
  41 
  42 
  43 struct nfp_dumpspec {
  44         u32 size;
  45         u8 data[0];
  46 };
  47 
  48 
  49 
  50 
  51 
  52 
  53 
  54 
  55 
  56 
  57 
  58 
  59 
  60 
  61 
  62 
  63 
  64 
  65 
  66 
  67 
  68 
  69 
  70 
  71 
  72 
  73 
  74 
  75 
  76 
  77 
  78 
  79 
  80 
  81 
  82 
  83 
  84 
  85 
  86 
  87 
  88 
  89 struct nfp_pf {
  90         struct pci_dev *pdev;
  91 
  92         struct nfp_cpp *cpp;
  93 
  94         struct nfp_app *app;
  95 
  96         struct nfp_cpp_area *data_vnic_bar;
  97         struct nfp_cpp_area *ctrl_vnic_bar;
  98         struct nfp_cpp_area *qc_area;
  99         struct nfp_cpp_area *mac_stats_bar;
 100         u8 __iomem *mac_stats_mem;
 101         struct nfp_cpp_area *vf_cfg_bar;
 102         u8 __iomem *vf_cfg_mem;
 103         struct nfp_cpp_area *vfcfg_tbl2_area;
 104         u8 __iomem *vfcfg_tbl2;
 105 
 106         const struct nfp_rtsym *mbox;
 107 
 108         struct msix_entry *irq_entries;
 109 
 110         unsigned int limit_vfs;
 111         unsigned int num_vfs;
 112 
 113         bool fw_loaded;
 114         bool unload_fw_on_remove;
 115 
 116         struct nfp_net *ctrl_vnic;
 117 
 118         const struct nfp_mip *mip;
 119         struct nfp_rtsym_table *rtbl;
 120         struct nfp_hwinfo *hwinfo;
 121         struct nfp_dumpspec *dumpspec;
 122         u32 dump_flag;
 123         u32 dump_len;
 124         struct nfp_eth_table *eth_tbl;
 125         struct nfp_nsp_identify *nspi;
 126 
 127         struct device *hwmon_dev;
 128 
 129         struct dentry *ddir;
 130 
 131         unsigned int max_data_vnics;
 132         unsigned int num_vnics;
 133 
 134         struct list_head vnics;
 135         struct list_head ports;
 136 
 137         struct workqueue_struct *wq;
 138         struct work_struct port_refresh_work;
 139 
 140         struct nfp_shared_buf *shared_bufs;
 141         unsigned int num_shared_bufs;
 142 
 143         struct mutex lock;
 144 };
 145 
 146 extern struct pci_driver nfp_netvf_pci_driver;
 147 
 148 extern const struct devlink_ops nfp_devlink_ops;
 149 
 150 int nfp_net_pci_probe(struct nfp_pf *pf);
 151 void nfp_net_pci_remove(struct nfp_pf *pf);
 152 
 153 int nfp_hwmon_register(struct nfp_pf *pf);
 154 void nfp_hwmon_unregister(struct nfp_pf *pf);
 155 
 156 void
 157 nfp_net_get_mac_addr(struct nfp_pf *pf, struct net_device *netdev,
 158                      struct nfp_port *port);
 159 
 160 bool nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb);
 161 
 162 int nfp_pf_rtsym_read_optional(struct nfp_pf *pf, const char *format,
 163                                unsigned int default_val);
 164 u8 __iomem *
 165 nfp_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt,
 166                  unsigned int min_size, struct nfp_cpp_area **area);
 167 int nfp_mbox_cmd(struct nfp_pf *pf, u32 cmd, void *in_data, u64 in_length,
 168                  void *out_data, u64 out_length);
 169 int nfp_flash_update_common(struct nfp_pf *pf, const char *path,
 170                             struct netlink_ext_ack *extack);
 171 
 172 enum nfp_dump_diag {
 173         NFP_DUMP_NSP_DIAG = 0,
 174 };
 175 
 176 struct nfp_dumpspec *
 177 nfp_net_dump_load_dumpspec(struct nfp_cpp *cpp, struct nfp_rtsym_table *rtbl);
 178 s64 nfp_net_dump_calculate_size(struct nfp_pf *pf, struct nfp_dumpspec *spec,
 179                                 u32 flag);
 180 int nfp_net_dump_populate_buffer(struct nfp_pf *pf, struct nfp_dumpspec *spec,
 181                                  struct ethtool_dump *dump_param, void *dest);
 182 
 183 int nfp_shared_buf_register(struct nfp_pf *pf);
 184 void nfp_shared_buf_unregister(struct nfp_pf *pf);
 185 int nfp_shared_buf_pool_get(struct nfp_pf *pf, unsigned int sb, u16 pool_index,
 186                             struct devlink_sb_pool_info *pool_info);
 187 int nfp_shared_buf_pool_set(struct nfp_pf *pf, unsigned int sb,
 188                             u16 pool_index, u32 size,
 189                             enum devlink_sb_threshold_type threshold_type);
 190 
 191 int nfp_devlink_params_register(struct nfp_pf *pf);
 192 void nfp_devlink_params_unregister(struct nfp_pf *pf);
 193 #endif