nfp_main.h 6.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
/*
 * Copyright (C) 2015-2017 Netronome Systems, Inc.
 *
 * This software is dual licensed under the GNU General License Version 2,
 * June 1991 as shown in the file COPYING in the top-level directory of this
 * source tree or the BSD 2-Clause License provided below.  You have the
 * option to license this software under the complete terms of either license.
 *
 * The BSD 2-Clause License:
 *
 *     Redistribution and use in source and binary forms, with or
 *     without modification, are permitted provided that the following
 *     conditions are met:
 *
 *      1. Redistributions of source code must retain the above
 *         copyright notice, this list of conditions and the following
 *         disclaimer.
 *
 *      2. Redistributions in binary form must reproduce the above
 *         copyright notice, this list of conditions and the following
 *         disclaimer in the documentation and/or other materials
 *         provided with the distribution.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/*
 * nfp_main.h
 * Author: Jason McMullan <jason.mcmullan@netronome.com>
 */

#ifndef NFP_MAIN_H
#define NFP_MAIN_H

C
Carl Heymann 已提交
42
#include <linux/ethtool.h>
J
Jakub Kicinski 已提交
43
#include <linux/list.h>
44 45
#include <linux/types.h>
#include <linux/msi.h>
46
#include <linux/mutex.h>
47
#include <linux/pci.h>
J
Jakub Kicinski 已提交
48
#include <linux/workqueue.h>
49

J
Jakub Kicinski 已提交
50
struct dentry;
D
David Brunecz 已提交
51
struct device;
S
Simon Horman 已提交
52
struct devlink_ops;
J
Jakub Kicinski 已提交
53 54 55 56 57
struct pci_dev;

struct nfp_cpp;
struct nfp_cpp_area;
struct nfp_eth_table;
58
struct nfp_hwinfo;
J
Jakub Kicinski 已提交
59
struct nfp_mip;
J
Jakub Kicinski 已提交
60
struct nfp_net;
D
David Brunecz 已提交
61
struct nfp_nsp_identify;
62
struct nfp_port;
63
struct nfp_rtsym;
64
struct nfp_rtsym_table;
J
Jakub Kicinski 已提交
65

C
Carl Heymann 已提交
66 67 68 69 70 71 72 73 74 75 76
/**
 * struct nfp_dumpspec - NFP FW dump specification structure
 * @size:	Size of the data
 * @data:	Sequence of TLVs, each being an instruction to dump some data
 *		from FW
 */
struct nfp_dumpspec {
	u32 size;
	u8 data[0];
};

J
Jakub Kicinski 已提交
77 78 79 80
/**
 * struct nfp_pf - NFP PF-specific device structure
 * @pdev:		Backpointer to PCI device
 * @cpp:		Pointer to the CPP handle
81
 * @app:		Pointer to the APP handle
J
Jakub Kicinski 已提交
82
 * @data_vnic_bar:	Pointer to the CPP area for the data vNICs' BARs
83
 * @ctrl_vnic_bar:	Pointer to the CPP area for the ctrl vNIC's BAR
84
 * @qc_area:		Pointer to the CPP area for the queues
85 86 87 88
 * @mac_stats_bar:	Pointer to the CPP area for the MAC stats
 * @mac_stats_mem:	Pointer to mapped MAC stats area
 * @vf_cfg_bar:		Pointer to the CPP area for the VF configuration BAR
 * @vf_cfg_mem:		Pointer to mapped VF configuration area
89 90
 * @vfcfg_tbl2_area:	Pointer to the CPP area for the VF config table
 * @vfcfg_tbl2:		Pointer to mapped VF config table
91
 * @mbox:		RTSym of per-PCI PF mailbox (under devlink lock)
J
Jakub Kicinski 已提交
92
 * @irq_entries:	Array of MSI-X entries for all vNICs
93
 * @limit_vfs:		Number of VFs supported by firmware (~0 for PCI limit)
J
Jakub Kicinski 已提交
94 95
 * @num_vfs:		Number of SR-IOV VFs enabled
 * @fw_loaded:		Is the firmware loaded?
96
 * @ctrl_vnic:		Pointer to the control vNIC if available
J
Jakub Kicinski 已提交
97
 * @mip:		MIP handle
98
 * @rtbl:		RTsym table
99
 * @hwinfo:		HWInfo table
C
Carl Heymann 已提交
100 101 102
 * @dumpspec:		Debug dump specification
 * @dump_flag:		Store dump flag between set_dump and get_dump_flag
 * @dump_len:		Store dump length between set_dump and get_dump_flag
J
Jakub Kicinski 已提交
103
 * @eth_tbl:		NSP ETH table
D
David Brunecz 已提交
104 105
 * @nspi:		NSP identification info
 * @hwmon_dev:		pointer to hwmon device
J
Jakub Kicinski 已提交
106
 * @ddir:		Per-device debugfs directory
J
Jakub Kicinski 已提交
107 108 109
 * @max_data_vnics:	Number of data vNICs app firmware supports
 * @num_vnics:		Number of vNICs spawned
 * @vnics:		Linked list of vNIC structures (struct nfp_net)
110
 * @ports:		Linked list of port structures (struct nfp_port)
111
 * @wq:			Workqueue for running works which need to grab @lock
J
Jakub Kicinski 已提交
112
 * @port_refresh_work:	Work entry for taking netdevs out
J
Jakub Kicinski 已提交
113
 * @lock:		Protects all fields which may change after probe
J
Jakub Kicinski 已提交
114 115 116 117 118 119
 */
struct nfp_pf {
	struct pci_dev *pdev;

	struct nfp_cpp *cpp;

120 121
	struct nfp_app *app;

J
Jakub Kicinski 已提交
122
	struct nfp_cpp_area *data_vnic_bar;
123
	struct nfp_cpp_area *ctrl_vnic_bar;
124
	struct nfp_cpp_area *qc_area;
125 126 127 128
	struct nfp_cpp_area *mac_stats_bar;
	u8 __iomem *mac_stats_mem;
	struct nfp_cpp_area *vf_cfg_bar;
	u8 __iomem *vf_cfg_mem;
129 130
	struct nfp_cpp_area *vfcfg_tbl2_area;
	u8 __iomem *vfcfg_tbl2;
J
Jakub Kicinski 已提交
131

132 133
	const struct nfp_rtsym *mbox;

J
Jakub Kicinski 已提交
134 135
	struct msix_entry *irq_entries;

136
	unsigned int limit_vfs;
J
Jakub Kicinski 已提交
137 138 139 140
	unsigned int num_vfs;

	bool fw_loaded;

141 142
	struct nfp_net *ctrl_vnic;

J
Jakub Kicinski 已提交
143
	const struct nfp_mip *mip;
144
	struct nfp_rtsym_table *rtbl;
145
	struct nfp_hwinfo *hwinfo;
C
Carl Heymann 已提交
146 147 148
	struct nfp_dumpspec *dumpspec;
	u32 dump_flag;
	u32 dump_len;
J
Jakub Kicinski 已提交
149
	struct nfp_eth_table *eth_tbl;
D
David Brunecz 已提交
150 151 152
	struct nfp_nsp_identify *nspi;

	struct device *hwmon_dev;
J
Jakub Kicinski 已提交
153 154 155

	struct dentry *ddir;

J
Jakub Kicinski 已提交
156 157
	unsigned int max_data_vnics;
	unsigned int num_vnics;
158

J
Jakub Kicinski 已提交
159
	struct list_head vnics;
160
	struct list_head ports;
161 162

	struct workqueue_struct *wq;
J
Jakub Kicinski 已提交
163
	struct work_struct port_refresh_work;
164

J
Jakub Kicinski 已提交
165
	struct mutex lock;
J
Jakub Kicinski 已提交
166 167
};

168 169
extern struct pci_driver nfp_netvf_pci_driver;

S
Simon Horman 已提交
170 171
extern const struct devlink_ops nfp_devlink_ops;

J
Jakub Kicinski 已提交
172 173 174
int nfp_net_pci_probe(struct nfp_pf *pf);
void nfp_net_pci_remove(struct nfp_pf *pf);

D
David Brunecz 已提交
175 176 177
int nfp_hwmon_register(struct nfp_pf *pf);
void nfp_hwmon_unregister(struct nfp_pf *pf);

178 179 180
void
nfp_net_get_mac_addr(struct nfp_pf *pf, struct net_device *netdev,
		     struct nfp_port *port);
J
Jakub Kicinski 已提交
181

182 183
bool nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb);

184 185 186 187 188
int nfp_pf_rtsym_read_optional(struct nfp_pf *pf, const char *format,
			       unsigned int default_val);
u8 __iomem *
nfp_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt,
		 unsigned int min_size, struct nfp_cpp_area **area);
189 190
int nfp_mbox_cmd(struct nfp_pf *pf, u32 cmd, void *in_data, u64 in_length,
		 void *out_data, u64 out_length);
191

C
Carl Heymann 已提交
192 193 194 195 196 197 198 199 200 201 202
enum nfp_dump_diag {
	NFP_DUMP_NSP_DIAG = 0,
};

struct nfp_dumpspec *
nfp_net_dump_load_dumpspec(struct nfp_cpp *cpp, struct nfp_rtsym_table *rtbl);
s64 nfp_net_dump_calculate_size(struct nfp_pf *pf, struct nfp_dumpspec *spec,
				u32 flag);
int nfp_net_dump_populate_buffer(struct nfp_pf *pf, struct nfp_dumpspec *spec,
				 struct ethtool_dump *dump_param, void *dest);

203
#endif /* NFP_MAIN_H */