1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
2 /* Copyright (C) 2015-2018 Netronome Systems, Inc. */
6 * Author: Jason McMullan <jason.mcmullan@netronome.com>
12 #include <linux/ethtool.h>
13 #include <linux/list.h>
14 #include <linux/types.h>
15 #include <linux/msi.h>
16 #include <linux/mutex.h>
17 #include <linux/pci.h>
18 #include <linux/workqueue.h>
19 #include <net/devlink.h>
31 struct nfp_nsp_identify
;
34 struct nfp_rtsym_table
;
35 struct nfp_shared_buf
;
38 * struct nfp_dumpspec - NFP FW dump specification structure
39 * @size: Size of the data
40 * @data: Sequence of TLVs, each being an instruction to dump some data
49 * struct nfp_pf - NFP PF-specific device structure
50 * @pdev: Backpointer to PCI device
51 * @cpp: Pointer to the CPP handle
52 * @app: Pointer to the APP handle
53 * @data_vnic_bar: Pointer to the CPP area for the data vNICs' BARs
54 * @ctrl_vnic_bar: Pointer to the CPP area for the ctrl vNIC's BAR
55 * @qc_area: Pointer to the CPP area for the queues
56 * @mac_stats_bar: Pointer to the CPP area for the MAC stats
57 * @mac_stats_mem: Pointer to mapped MAC stats area
58 * @vf_cfg_bar: Pointer to the CPP area for the VF configuration BAR
59 * @vf_cfg_mem: Pointer to mapped VF configuration area
60 * @vfcfg_tbl2_area: Pointer to the CPP area for the VF config table
61 * @vfcfg_tbl2: Pointer to mapped VF config table
62 * @mbox: RTSym of per-PCI PF mailbox (under devlink lock)
63 * @irq_entries: Array of MSI-X entries for all vNICs
64 * @limit_vfs: Number of VFs supported by firmware (~0 for PCI limit)
65 * @num_vfs: Number of SR-IOV VFs enabled
66 * @fw_loaded: Is the firmware loaded?
67 * @ctrl_vnic: Pointer to the control vNIC if available
70 * @hwinfo: HWInfo table
71 * @dumpspec: Debug dump specification
72 * @dump_flag: Store dump flag between set_dump and get_dump_flag
73 * @dump_len: Store dump length between set_dump and get_dump_flag
74 * @eth_tbl: NSP ETH table
75 * @nspi: NSP identification info
76 * @hwmon_dev: pointer to hwmon device
77 * @ddir: Per-device debugfs directory
78 * @max_data_vnics: Number of data vNICs app firmware supports
79 * @num_vnics: Number of vNICs spawned
80 * @vnics: Linked list of vNIC structures (struct nfp_net)
81 * @ports: Linked list of port structures (struct nfp_port)
82 * @wq: Workqueue for running works which need to grab @lock
83 * @port_refresh_work: Work entry for taking netdevs out
84 * @shared_bufs: Array of shared buffer structures if FW has any SBs
85 * @num_shared_bufs: Number of elements in @shared_bufs
86 * @lock: Protects all fields which may change after probe
95 struct nfp_cpp_area
*data_vnic_bar
;
96 struct nfp_cpp_area
*ctrl_vnic_bar
;
97 struct nfp_cpp_area
*qc_area
;
98 struct nfp_cpp_area
*mac_stats_bar
;
99 u8 __iomem
*mac_stats_mem
;
100 struct nfp_cpp_area
*vf_cfg_bar
;
101 u8 __iomem
*vf_cfg_mem
;
102 struct nfp_cpp_area
*vfcfg_tbl2_area
;
103 u8 __iomem
*vfcfg_tbl2
;
105 const struct nfp_rtsym
*mbox
;
107 struct msix_entry
*irq_entries
;
109 unsigned int limit_vfs
;
110 unsigned int num_vfs
;
114 struct nfp_net
*ctrl_vnic
;
116 const struct nfp_mip
*mip
;
117 struct nfp_rtsym_table
*rtbl
;
118 struct nfp_hwinfo
*hwinfo
;
119 struct nfp_dumpspec
*dumpspec
;
122 struct nfp_eth_table
*eth_tbl
;
123 struct nfp_nsp_identify
*nspi
;
125 struct device
*hwmon_dev
;
129 unsigned int max_data_vnics
;
130 unsigned int num_vnics
;
132 struct list_head vnics
;
133 struct list_head ports
;
135 struct workqueue_struct
*wq
;
136 struct work_struct port_refresh_work
;
138 struct nfp_shared_buf
*shared_bufs
;
139 unsigned int num_shared_bufs
;
144 extern struct pci_driver nfp_netvf_pci_driver
;
146 extern const struct devlink_ops nfp_devlink_ops
;
148 int nfp_net_pci_probe(struct nfp_pf
*pf
);
149 void nfp_net_pci_remove(struct nfp_pf
*pf
);
151 int nfp_hwmon_register(struct nfp_pf
*pf
);
152 void nfp_hwmon_unregister(struct nfp_pf
*pf
);
155 nfp_net_get_mac_addr(struct nfp_pf
*pf
, struct net_device
*netdev
,
156 struct nfp_port
*port
);
158 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
);
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 int nfp_flash_update_common(struct nfp_pf
*pf
, const char *path
,
168 struct netlink_ext_ack
*extack
);
171 NFP_DUMP_NSP_DIAG
= 0,
174 struct nfp_dumpspec
*
175 nfp_net_dump_load_dumpspec(struct nfp_cpp
*cpp
, struct nfp_rtsym_table
*rtbl
);
176 s64
nfp_net_dump_calculate_size(struct nfp_pf
*pf
, struct nfp_dumpspec
*spec
,
178 int nfp_net_dump_populate_buffer(struct nfp_pf
*pf
, struct nfp_dumpspec
*spec
,
179 struct ethtool_dump
*dump_param
, void *dest
);
181 int nfp_shared_buf_register(struct nfp_pf
*pf
);
182 void nfp_shared_buf_unregister(struct nfp_pf
*pf
);
183 int nfp_shared_buf_pool_get(struct nfp_pf
*pf
, unsigned int sb
, u16 pool_index
,
184 struct devlink_sb_pool_info
*pool_info
);
185 int nfp_shared_buf_pool_set(struct nfp_pf
*pf
, unsigned int sb
,
186 u16 pool_index
, u32 size
,
187 enum devlink_sb_threshold_type threshold_type
);
188 #endif /* NFP_MAIN_H */