Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
0002 /* Copyright (C) 2015-2018 Netronome Systems, Inc. */
0003 
0004 /*
0005  * nfp_main.h
0006  * Author: Jason McMullan <jason.mcmullan@netronome.com>
0007  */
0008 
0009 #ifndef NFP_MAIN_H
0010 #define NFP_MAIN_H
0011 
0012 #include <linux/ethtool.h>
0013 #include <linux/list.h>
0014 #include <linux/types.h>
0015 #include <linux/msi.h>
0016 #include <linux/pci.h>
0017 #include <linux/workqueue.h>
0018 #include <net/devlink.h>
0019 
0020 struct dentry;
0021 struct device;
0022 struct pci_dev;
0023 
0024 struct nfp_cpp;
0025 struct nfp_cpp_area;
0026 struct nfp_eth_table;
0027 struct nfp_hwinfo;
0028 struct nfp_mip;
0029 struct nfp_net;
0030 struct nfp_nsp_identify;
0031 struct nfp_port;
0032 struct nfp_rtsym;
0033 struct nfp_rtsym_table;
0034 struct nfp_shared_buf;
0035 
0036 /**
0037  * struct nfp_dumpspec - NFP FW dump specification structure
0038  * @size:   Size of the data
0039  * @data:   Sequence of TLVs, each being an instruction to dump some data
0040  *      from FW
0041  */
0042 struct nfp_dumpspec {
0043     u32 size;
0044     u8 data[];
0045 };
0046 
0047 /**
0048  * struct nfp_pf - NFP PF-specific device structure
0049  * @pdev:       Backpointer to PCI device
0050  * @dev_info:       NFP ASIC params
0051  * @cpp:        Pointer to the CPP handle
0052  * @app:        Pointer to the APP handle
0053  * @data_vnic_bar:  Pointer to the CPP area for the data vNICs' BARs
0054  * @ctrl_vnic_bar:  Pointer to the CPP area for the ctrl vNIC's BAR
0055  * @qc_area:        Pointer to the CPP area for the queues
0056  * @mac_stats_bar:  Pointer to the CPP area for the MAC stats
0057  * @mac_stats_mem:  Pointer to mapped MAC stats area
0058  * @vf_cfg_bar:     Pointer to the CPP area for the VF configuration BAR
0059  * @vf_cfg_mem:     Pointer to mapped VF configuration area
0060  * @vfcfg_tbl2_area:    Pointer to the CPP area for the VF config table
0061  * @vfcfg_tbl2:     Pointer to mapped VF config table
0062  * @mbox:       RTSym of per-PCI PF mailbox (under devlink lock)
0063  * @irq_entries:    Array of MSI-X entries for all vNICs
0064  * @limit_vfs:      Number of VFs supported by firmware (~0 for PCI limit)
0065  * @num_vfs:        Number of SR-IOV VFs enabled
0066  * @fw_loaded:      Is the firmware loaded?
0067  * @unload_fw_on_remove:Do we need to unload firmware on driver removal?
0068  * @ctrl_vnic:      Pointer to the control vNIC if available
0069  * @mip:        MIP handle
0070  * @rtbl:       RTsym table
0071  * @hwinfo:     HWInfo table
0072  * @dumpspec:       Debug dump specification
0073  * @dump_flag:      Store dump flag between set_dump and get_dump_flag
0074  * @dump_len:       Store dump length between set_dump and get_dump_flag
0075  * @eth_tbl:        NSP ETH table
0076  * @nspi:       NSP identification info
0077  * @hwmon_dev:      pointer to hwmon device
0078  * @ddir:       Per-device debugfs directory
0079  * @max_data_vnics: Number of data vNICs app firmware supports
0080  * @num_vnics:      Number of vNICs spawned
0081  * @vnics:      Linked list of vNIC structures (struct nfp_net)
0082  * @ports:      Linked list of port structures (struct nfp_port)
0083  * @wq:         Workqueue for running works which need to grab @lock
0084  * @port_refresh_work:  Work entry for taking netdevs out
0085  * @shared_bufs:    Array of shared buffer structures if FW has any SBs
0086  * @num_shared_bufs:    Number of elements in @shared_bufs
0087  *
0088  * Fields which may change after proble are protected by devlink instance lock.
0089  */
0090 struct nfp_pf {
0091     struct pci_dev *pdev;
0092     const struct nfp_dev_info *dev_info;
0093 
0094     struct nfp_cpp *cpp;
0095 
0096     struct nfp_app *app;
0097 
0098     struct nfp_cpp_area *data_vnic_bar;
0099     struct nfp_cpp_area *ctrl_vnic_bar;
0100     struct nfp_cpp_area *qc_area;
0101     struct nfp_cpp_area *mac_stats_bar;
0102     u8 __iomem *mac_stats_mem;
0103     struct nfp_cpp_area *vf_cfg_bar;
0104     u8 __iomem *vf_cfg_mem;
0105     struct nfp_cpp_area *vfcfg_tbl2_area;
0106     u8 __iomem *vfcfg_tbl2;
0107 
0108     const struct nfp_rtsym *mbox;
0109 
0110     struct msix_entry *irq_entries;
0111 
0112     unsigned int limit_vfs;
0113     unsigned int num_vfs;
0114 
0115     bool fw_loaded;
0116     bool unload_fw_on_remove;
0117 
0118     struct nfp_net *ctrl_vnic;
0119 
0120     const struct nfp_mip *mip;
0121     struct nfp_rtsym_table *rtbl;
0122     struct nfp_hwinfo *hwinfo;
0123     struct nfp_dumpspec *dumpspec;
0124     u32 dump_flag;
0125     u32 dump_len;
0126     struct nfp_eth_table *eth_tbl;
0127     struct nfp_nsp_identify *nspi;
0128 
0129     struct device *hwmon_dev;
0130 
0131     struct dentry *ddir;
0132 
0133     unsigned int max_data_vnics;
0134     unsigned int num_vnics;
0135 
0136     struct list_head vnics;
0137     struct list_head ports;
0138 
0139     struct workqueue_struct *wq;
0140     struct work_struct port_refresh_work;
0141 
0142     struct nfp_shared_buf *shared_bufs;
0143     unsigned int num_shared_bufs;
0144 };
0145 
0146 extern struct pci_driver nfp_netvf_pci_driver;
0147 
0148 extern const struct devlink_ops nfp_devlink_ops;
0149 
0150 int nfp_net_pci_probe(struct nfp_pf *pf);
0151 void nfp_net_pci_remove(struct nfp_pf *pf);
0152 
0153 int nfp_hwmon_register(struct nfp_pf *pf);
0154 void nfp_hwmon_unregister(struct nfp_pf *pf);
0155 
0156 void
0157 nfp_net_get_mac_addr(struct nfp_pf *pf, struct net_device *netdev,
0158              struct nfp_port *port);
0159 
0160 bool nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb);
0161 
0162 int nfp_pf_rtsym_read_optional(struct nfp_pf *pf, const char *format,
0163                    unsigned int default_val);
0164 u8 __iomem *
0165 nfp_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt,
0166          unsigned int min_size, struct nfp_cpp_area **area);
0167 int nfp_mbox_cmd(struct nfp_pf *pf, u32 cmd, void *in_data, u64 in_length,
0168          void *out_data, u64 out_length);
0169 int nfp_flash_update_common(struct nfp_pf *pf, const struct firmware *fw,
0170                 struct netlink_ext_ack *extack);
0171 
0172 enum nfp_dump_diag {
0173     NFP_DUMP_NSP_DIAG = 0,
0174 };
0175 
0176 struct nfp_dumpspec *
0177 nfp_net_dump_load_dumpspec(struct nfp_cpp *cpp, struct nfp_rtsym_table *rtbl);
0178 s64 nfp_net_dump_calculate_size(struct nfp_pf *pf, struct nfp_dumpspec *spec,
0179                 u32 flag);
0180 int nfp_net_dump_populate_buffer(struct nfp_pf *pf, struct nfp_dumpspec *spec,
0181                  struct ethtool_dump *dump_param, void *dest);
0182 
0183 int nfp_shared_buf_register(struct nfp_pf *pf);
0184 void nfp_shared_buf_unregister(struct nfp_pf *pf);
0185 int nfp_shared_buf_pool_get(struct nfp_pf *pf, unsigned int sb, u16 pool_index,
0186                 struct devlink_sb_pool_info *pool_info);
0187 int nfp_shared_buf_pool_set(struct nfp_pf *pf, unsigned int sb,
0188                 u16 pool_index, u32 size,
0189                 enum devlink_sb_threshold_type threshold_type);
0190 
0191 int nfp_devlink_params_register(struct nfp_pf *pf);
0192 void nfp_devlink_params_unregister(struct nfp_pf *pf);
0193 #endif /* NFP_MAIN_H */