nfp_main.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. #include <net/devlink.h>
  47. struct dentry;
  48. struct device;
  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;
  59. struct nfp_rtsym_table;
  60. struct nfp_shared_buf;
  61. /**
  62. * struct nfp_dumpspec - NFP FW dump specification structure
  63. * @size: Size of the data
  64. * @data: Sequence of TLVs, each being an instruction to dump some data
  65. * from FW
  66. */
  67. struct nfp_dumpspec {
  68. u32 size;
  69. u8 data[0];
  70. };
  71. /**
  72. * struct nfp_pf - NFP PF-specific device structure
  73. * @pdev: Backpointer to PCI device
  74. * @cpp: Pointer to the CPP handle
  75. * @app: Pointer to the APP handle
  76. * @data_vnic_bar: Pointer to the CPP area for the data vNICs' BARs
  77. * @ctrl_vnic_bar: Pointer to the CPP area for the ctrl vNIC's BAR
  78. * @qc_area: Pointer to the CPP area for the queues
  79. * @mac_stats_bar: Pointer to the CPP area for the MAC stats
  80. * @mac_stats_mem: Pointer to mapped MAC stats area
  81. * @vf_cfg_bar: Pointer to the CPP area for the VF configuration BAR
  82. * @vf_cfg_mem: Pointer to mapped VF configuration area
  83. * @vfcfg_tbl2_area: Pointer to the CPP area for the VF config table
  84. * @vfcfg_tbl2: Pointer to mapped VF config table
  85. * @mbox: RTSym of per-PCI PF mailbox (under devlink lock)
  86. * @irq_entries: Array of MSI-X entries for all vNICs
  87. * @limit_vfs: Number of VFs supported by firmware (~0 for PCI limit)
  88. * @num_vfs: Number of SR-IOV VFs enabled
  89. * @fw_loaded: Is the firmware loaded?
  90. * @ctrl_vnic: Pointer to the control vNIC if available
  91. * @mip: MIP handle
  92. * @rtbl: RTsym table
  93. * @hwinfo: HWInfo table
  94. * @dumpspec: Debug dump specification
  95. * @dump_flag: Store dump flag between set_dump and get_dump_flag
  96. * @dump_len: Store dump length between set_dump and get_dump_flag
  97. * @eth_tbl: NSP ETH table
  98. * @nspi: NSP identification info
  99. * @hwmon_dev: pointer to hwmon device
  100. * @ddir: Per-device debugfs directory
  101. * @max_data_vnics: Number of data vNICs app firmware supports
  102. * @num_vnics: Number of vNICs spawned
  103. * @vnics: Linked list of vNIC structures (struct nfp_net)
  104. * @ports: Linked list of port structures (struct nfp_port)
  105. * @wq: Workqueue for running works which need to grab @lock
  106. * @port_refresh_work: Work entry for taking netdevs out
  107. * @shared_bufs: Array of shared buffer structures if FW has any SBs
  108. * @num_shared_bufs: Number of elements in @shared_bufs
  109. * @lock: Protects all fields which may change after probe
  110. */
  111. struct nfp_pf {
  112. struct pci_dev *pdev;
  113. struct nfp_cpp *cpp;
  114. struct nfp_app *app;
  115. struct nfp_cpp_area *data_vnic_bar;
  116. struct nfp_cpp_area *ctrl_vnic_bar;
  117. struct nfp_cpp_area *qc_area;
  118. struct nfp_cpp_area *mac_stats_bar;
  119. u8 __iomem *mac_stats_mem;
  120. struct nfp_cpp_area *vf_cfg_bar;
  121. u8 __iomem *vf_cfg_mem;
  122. struct nfp_cpp_area *vfcfg_tbl2_area;
  123. u8 __iomem *vfcfg_tbl2;
  124. const struct nfp_rtsym *mbox;
  125. struct msix_entry *irq_entries;
  126. unsigned int limit_vfs;
  127. unsigned int num_vfs;
  128. bool fw_loaded;
  129. struct nfp_net *ctrl_vnic;
  130. const struct nfp_mip *mip;
  131. struct nfp_rtsym_table *rtbl;
  132. struct nfp_hwinfo *hwinfo;
  133. struct nfp_dumpspec *dumpspec;
  134. u32 dump_flag;
  135. u32 dump_len;
  136. struct nfp_eth_table *eth_tbl;
  137. struct nfp_nsp_identify *nspi;
  138. struct device *hwmon_dev;
  139. struct dentry *ddir;
  140. unsigned int max_data_vnics;
  141. unsigned int num_vnics;
  142. struct list_head vnics;
  143. struct list_head ports;
  144. struct workqueue_struct *wq;
  145. struct work_struct port_refresh_work;
  146. struct nfp_shared_buf *shared_bufs;
  147. unsigned int num_shared_bufs;
  148. struct mutex lock;
  149. };
  150. extern struct pci_driver nfp_netvf_pci_driver;
  151. extern const struct devlink_ops nfp_devlink_ops;
  152. int nfp_net_pci_probe(struct nfp_pf *pf);
  153. void nfp_net_pci_remove(struct nfp_pf *pf);
  154. int nfp_hwmon_register(struct nfp_pf *pf);
  155. void nfp_hwmon_unregister(struct nfp_pf *pf);
  156. void
  157. nfp_net_get_mac_addr(struct nfp_pf *pf, struct net_device *netdev,
  158. struct nfp_port *port);
  159. bool nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb);
  160. int nfp_pf_rtsym_read_optional(struct nfp_pf *pf, const char *format,
  161. unsigned int default_val);
  162. u8 __iomem *
  163. nfp_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt,
  164. unsigned int min_size, struct nfp_cpp_area **area);
  165. int nfp_mbox_cmd(struct nfp_pf *pf, u32 cmd, void *in_data, u64 in_length,
  166. void *out_data, u64 out_length);
  167. enum nfp_dump_diag {
  168. NFP_DUMP_NSP_DIAG = 0,
  169. };
  170. struct nfp_dumpspec *
  171. nfp_net_dump_load_dumpspec(struct nfp_cpp *cpp, struct nfp_rtsym_table *rtbl);
  172. s64 nfp_net_dump_calculate_size(struct nfp_pf *pf, struct nfp_dumpspec *spec,
  173. u32 flag);
  174. int nfp_net_dump_populate_buffer(struct nfp_pf *pf, struct nfp_dumpspec *spec,
  175. struct ethtool_dump *dump_param, void *dest);
  176. int nfp_shared_buf_register(struct nfp_pf *pf);
  177. void nfp_shared_buf_unregister(struct nfp_pf *pf);
  178. int nfp_shared_buf_pool_get(struct nfp_pf *pf, unsigned int sb, u16 pool_index,
  179. struct devlink_sb_pool_info *pool_info);
  180. int nfp_shared_buf_pool_set(struct nfp_pf *pf, unsigned int sb,
  181. u16 pool_index, u32 size,
  182. enum devlink_sb_threshold_type threshold_type);
  183. #endif /* NFP_MAIN_H */