2 * Copyright (C) 2015-2017 Netronome Systems, Inc.
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.
9 * The BSD 2-Clause License:
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
15 * 1. Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
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.
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
36 * Author: Jason McMullan <jason.mcmullan@netronome.com>
42 #include <linux/list.h>
43 #include <linux/types.h>
44 #include <linux/msi.h>
45 #include <linux/mutex.h>
46 #include <linux/pci.h>
47 #include <linux/workqueue.h>
60 struct nfp_nsp_identify;
62 struct nfp_rtsym_table;
65 * struct nfp_pf - NFP PF-specific device structure
66 * @pdev: Backpointer to PCI device
67 * @cpp: Pointer to the CPP handle
68 * @app: Pointer to the APP handle
69 * @data_vnic_bar: Pointer to the CPP area for the data vNICs' BARs
70 * @ctrl_vnic_bar: Pointer to the CPP area for the ctrl vNIC's BAR
71 * @qc_area: Pointer to the CPP area for the queues
72 * @mac_stats_bar: Pointer to the CPP area for the MAC stats
73 * @mac_stats_mem: Pointer to mapped MAC stats area
74 * @vf_cfg_bar: Pointer to the CPP area for the VF configuration BAR
75 * @vf_cfg_mem: Pointer to mapped VF configuration area
76 * @vfcfg_tbl2_area: Pointer to the CPP area for the VF config table
77 * @vfcfg_tbl2: Pointer to mapped VF config table
78 * @irq_entries: Array of MSI-X entries for all vNICs
79 * @limit_vfs: Number of VFs supported by firmware (~0 for PCI limit)
80 * @num_vfs: Number of SR-IOV VFs enabled
81 * @fw_loaded: Is the firmware loaded?
82 * @ctrl_vnic: Pointer to the control vNIC if available
85 * @hwinfo: HWInfo table
86 * @eth_tbl: NSP ETH table
87 * @nspi: NSP identification info
88 * @hwmon_dev: pointer to hwmon device
89 * @ddir: Per-device debugfs directory
90 * @max_data_vnics: Number of data vNICs app firmware supports
91 * @num_vnics: Number of vNICs spawned
92 * @vnics: Linked list of vNIC structures (struct nfp_net)
93 * @ports: Linked list of port structures (struct nfp_port)
94 * @wq: Workqueue for running works which need to grab @lock
95 * @port_refresh_work: Work entry for taking netdevs out
96 * @lock: Protects all fields which may change after probe
105 struct nfp_cpp_area *data_vnic_bar;
106 struct nfp_cpp_area *ctrl_vnic_bar;
107 struct nfp_cpp_area *qc_area;
108 struct nfp_cpp_area *mac_stats_bar;
109 u8 __iomem *mac_stats_mem;
110 struct nfp_cpp_area *vf_cfg_bar;
111 u8 __iomem *vf_cfg_mem;
112 struct nfp_cpp_area *vfcfg_tbl2_area;
113 u8 __iomem *vfcfg_tbl2;
115 struct msix_entry *irq_entries;
117 unsigned int limit_vfs;
118 unsigned int num_vfs;
122 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_eth_table *eth_tbl;
128 struct nfp_nsp_identify *nspi;
130 struct device *hwmon_dev;
134 unsigned int max_data_vnics;
135 unsigned int num_vnics;
137 struct list_head vnics;
138 struct list_head ports;
140 struct workqueue_struct *wq;
141 struct work_struct port_refresh_work;
146 extern struct pci_driver nfp_netvf_pci_driver;
148 extern const struct devlink_ops nfp_devlink_ops;
150 int nfp_net_pci_probe(struct nfp_pf *pf);
151 void nfp_net_pci_remove(struct nfp_pf *pf);
153 int nfp_hwmon_register(struct nfp_pf *pf);
154 void nfp_hwmon_unregister(struct nfp_pf *pf);
156 void nfp_net_get_mac_addr(struct nfp_pf *pf, struct nfp_port *port);
158 bool nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb);
160 #endif /* NFP_MAIN_H */