nfp_main.h 3.9 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

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

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

struct nfp_cpp;
struct nfp_cpp_area;
struct nfp_eth_table;
J
Jakub Kicinski 已提交
57
struct nfp_net;
D
David Brunecz 已提交
58
struct nfp_nsp_identify;
J
Jakub Kicinski 已提交
59 60 61 62 63

/**
 * struct nfp_pf - NFP PF-specific device structure
 * @pdev:		Backpointer to PCI device
 * @cpp:		Pointer to the CPP handle
64
 * @app:		Pointer to the APP handle
J
Jakub Kicinski 已提交
65
 * @data_vnic_bar:	Pointer to the CPP area for the data vNICs' BARs
J
Jakub Kicinski 已提交
66 67
 * @tx_area:		Pointer to the CPP area for the TX queues
 * @rx_area:		Pointer to the CPP area for the FL/RX queues
J
Jakub Kicinski 已提交
68
 * @irq_entries:	Array of MSI-X entries for all vNICs
69
 * @limit_vfs:		Number of VFs supported by firmware (~0 for PCI limit)
J
Jakub Kicinski 已提交
70 71 72
 * @num_vfs:		Number of SR-IOV VFs enabled
 * @fw_loaded:		Is the firmware loaded?
 * @eth_tbl:		NSP ETH table
D
David Brunecz 已提交
73 74
 * @nspi:		NSP identification info
 * @hwmon_dev:		pointer to hwmon device
J
Jakub Kicinski 已提交
75
 * @ddir:		Per-device debugfs directory
J
Jakub Kicinski 已提交
76 77 78
 * @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)
79
 * @ports:		Linked list of port structures (struct nfp_port)
J
Jakub Kicinski 已提交
80
 * @port_refresh_work:	Work entry for taking netdevs out
J
Jakub Kicinski 已提交
81
 * @lock:		Protects all fields which may change after probe
J
Jakub Kicinski 已提交
82 83 84 85 86 87
 */
struct nfp_pf {
	struct pci_dev *pdev;

	struct nfp_cpp *cpp;

88 89
	struct nfp_app *app;

J
Jakub Kicinski 已提交
90
	struct nfp_cpp_area *data_vnic_bar;
J
Jakub Kicinski 已提交
91 92 93 94 95
	struct nfp_cpp_area *tx_area;
	struct nfp_cpp_area *rx_area;

	struct msix_entry *irq_entries;

96
	unsigned int limit_vfs;
J
Jakub Kicinski 已提交
97 98 99 100 101
	unsigned int num_vfs;

	bool fw_loaded;

	struct nfp_eth_table *eth_tbl;
D
David Brunecz 已提交
102 103 104
	struct nfp_nsp_identify *nspi;

	struct device *hwmon_dev;
J
Jakub Kicinski 已提交
105 106 107

	struct dentry *ddir;

J
Jakub Kicinski 已提交
108 109
	unsigned int max_data_vnics;
	unsigned int num_vnics;
110

J
Jakub Kicinski 已提交
111
	struct list_head vnics;
112
	struct list_head ports;
J
Jakub Kicinski 已提交
113
	struct work_struct port_refresh_work;
J
Jakub Kicinski 已提交
114
	struct mutex lock;
J
Jakub Kicinski 已提交
115 116
};

117 118
extern struct pci_driver nfp_netvf_pci_driver;

S
Simon Horman 已提交
119 120
extern const struct devlink_ops nfp_devlink_ops;

J
Jakub Kicinski 已提交
121 122 123
int nfp_net_pci_probe(struct nfp_pf *pf);
void nfp_net_pci_remove(struct nfp_pf *pf);

D
David Brunecz 已提交
124 125 126
int nfp_hwmon_register(struct nfp_pf *pf);
void nfp_hwmon_unregister(struct nfp_pf *pf);

J
Jakub Kicinski 已提交
127 128 129 130 131
struct nfp_eth_table_port *
nfp_net_find_port(struct nfp_eth_table *eth_tbl, unsigned int id);
void
nfp_net_get_mac_addr(struct nfp_net *nn, struct nfp_cpp *cpp, unsigned int id);

132
#endif /* NFP_MAIN_H */