nfp_main.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * Copyright (C) 2015-2017 Netronome Systems, Inc.
  3. *
  4. * This software is dual licensed under the GNU General License Version 2,
  5. * June 1991 as shown in the file COPYING in the top-level directory of this
  6. * source tree or the BSD 2-Clause License provided below. You have the
  7. * option to license this software under the complete terms of either license.
  8. *
  9. * The BSD 2-Clause License:
  10. *
  11. * Redistribution and use in source and binary forms, with or
  12. * without modification, are permitted provided that the following
  13. * conditions are met:
  14. *
  15. * 1. Redistributions of source code must retain the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer.
  18. *
  19. * 2. Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials
  22. * provided with the distribution.
  23. *
  24. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31. * SOFTWARE.
  32. */
  33. /*
  34. * nfp_main.h
  35. * Author: Jason McMullan <jason.mcmullan@netronome.com>
  36. */
  37. #ifndef NFP_MAIN_H
  38. #define NFP_MAIN_H
  39. #include <linux/ethtool.h>
  40. #include <linux/list.h>
  41. #include <linux/types.h>
  42. #include <linux/msi.h>
  43. #include <linux/mutex.h>
  44. #include <linux/pci.h>
  45. #include <linux/workqueue.h>
  46. struct dentry;
  47. struct device;
  48. struct devlink_ops;
  49. struct pci_dev;
  50. struct nfp_cpp;
  51. struct nfp_cpp_area;
  52. struct nfp_eth_table;
  53. struct nfp_hwinfo;
  54. struct nfp_mip;
  55. struct nfp_net;
  56. struct nfp_nsp_identify;
  57. struct nfp_port;
  58. struct nfp_rtsym_table;
  59. /**
  60. * struct nfp_dumpspec - NFP FW dump specification structure
  61. * @size: Size of the data
  62. * @data: Sequence of TLVs, each being an instruction to dump some data
  63. * from FW
  64. */
  65. struct nfp_dumpspec {
  66. u32 size;
  67. u8 data[0];
  68. };
  69. /**
  70. * struct nfp_pf - NFP PF-specific device structure
  71. * @pdev: Backpointer to PCI device
  72. * @cpp: Pointer to the CPP handle
  73. * @app: Pointer to the APP handle
  74. * @data_vnic_bar: Pointer to the CPP area for the data vNICs' BARs
  75. * @ctrl_vnic_bar: Pointer to the CPP area for the ctrl vNIC's BAR
  76. * @qc_area: Pointer to the CPP area for the queues
  77. * @mac_stats_bar: Pointer to the CPP area for the MAC stats
  78. * @mac_stats_mem: Pointer to mapped MAC stats area
  79. * @vf_cfg_bar: Pointer to the CPP area for the VF configuration BAR
  80. * @vf_cfg_mem: Pointer to mapped VF configuration area
  81. * @vfcfg_tbl2_area: Pointer to the CPP area for the VF config table
  82. * @vfcfg_tbl2: Pointer to mapped VF config table
  83. * @irq_entries: Array of MSI-X entries for all vNICs
  84. * @limit_vfs: Number of VFs supported by firmware (~0 for PCI limit)
  85. * @num_vfs: Number of SR-IOV VFs enabled
  86. * @fw_loaded: Is the firmware loaded?
  87. * @ctrl_vnic: Pointer to the control vNIC if available
  88. * @mip: MIP handle
  89. * @rtbl: RTsym table
  90. * @hwinfo: HWInfo table
  91. * @dumpspec: Debug dump specification
  92. * @dump_flag: Store dump flag between set_dump and get_dump_flag
  93. * @dump_len: Store dump length between set_dump and get_dump_flag
  94. * @eth_tbl: NSP ETH table
  95. * @nspi: NSP identification info
  96. * @hwmon_dev: pointer to hwmon device
  97. * @ddir: Per-device debugfs directory
  98. * @max_data_vnics: Number of data vNICs app firmware supports
  99. * @num_vnics: Number of vNICs spawned
  100. * @vnics: Linked list of vNIC structures (struct nfp_net)
  101. * @ports: Linked list of port structures (struct nfp_port)
  102. * @wq: Workqueue for running works which need to grab @lock
  103. * @port_refresh_work: Work entry for taking netdevs out
  104. * @lock: Protects all fields which may change after probe
  105. */
  106. struct nfp_pf {
  107. struct pci_dev *pdev;
  108. struct nfp_cpp *cpp;
  109. struct nfp_app *app;
  110. struct nfp_cpp_area *data_vnic_bar;
  111. struct nfp_cpp_area *ctrl_vnic_bar;
  112. struct nfp_cpp_area *qc_area;
  113. struct nfp_cpp_area *mac_stats_bar;
  114. u8 __iomem *mac_stats_mem;
  115. struct nfp_cpp_area *vf_cfg_bar;
  116. u8 __iomem *vf_cfg_mem;
  117. struct nfp_cpp_area *vfcfg_tbl2_area;
  118. u8 __iomem *vfcfg_tbl2;
  119. struct msix_entry *irq_entries;
  120. unsigned int limit_vfs;
  121. unsigned int num_vfs;
  122. bool fw_loaded;
  123. struct nfp_net *ctrl_vnic;
  124. const struct nfp_mip *mip;
  125. struct nfp_rtsym_table *rtbl;
  126. struct nfp_hwinfo *hwinfo;
  127. struct nfp_dumpspec *dumpspec;
  128. u32 dump_flag;
  129. u32 dump_len;
  130. struct nfp_eth_table *eth_tbl;
  131. struct nfp_nsp_identify *nspi;
  132. struct device *hwmon_dev;
  133. struct dentry *ddir;
  134. unsigned int max_data_vnics;
  135. unsigned int num_vnics;
  136. struct list_head vnics;
  137. struct list_head ports;
  138. struct workqueue_struct *wq;
  139. struct work_struct port_refresh_work;
  140. struct mutex lock;
  141. };
  142. extern struct pci_driver nfp_netvf_pci_driver;
  143. extern const struct devlink_ops nfp_devlink_ops;
  144. int nfp_net_pci_probe(struct nfp_pf *pf);
  145. void nfp_net_pci_remove(struct nfp_pf *pf);
  146. int nfp_hwmon_register(struct nfp_pf *pf);
  147. void nfp_hwmon_unregister(struct nfp_pf *pf);
  148. void
  149. nfp_net_get_mac_addr(struct nfp_pf *pf, struct net_device *netdev,
  150. struct nfp_port *port);
  151. bool nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb);
  152. enum nfp_dump_diag {
  153. NFP_DUMP_NSP_DIAG = 0,
  154. };
  155. struct nfp_dumpspec *
  156. nfp_net_dump_load_dumpspec(struct nfp_cpp *cpp, struct nfp_rtsym_table *rtbl);
  157. s64 nfp_net_dump_calculate_size(struct nfp_pf *pf, struct nfp_dumpspec *spec,
  158. u32 flag);
  159. int nfp_net_dump_populate_buffer(struct nfp_pf *pf, struct nfp_dumpspec *spec,
  160. struct ethtool_dump *dump_param, void *dest);
  161. #endif /* NFP_MAIN_H */