#include <linux/switchtec.h>
#include <linux/switchtec_ioctl.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/uaccess.h>
#include <linux/poll.h>
#include <linux/wait.h>
#include <linux/io-64-nonatomic-lo-hi.h>
#include <linux/nospec.h>
MODULE_DESCRIPTION(…) …;
MODULE_VERSION(…) …;
MODULE_LICENSE(…) …;
MODULE_AUTHOR(…) …;
static int max_devices = …;
module_param(max_devices, int, 0644);
MODULE_PARM_DESC(…) …;
static bool use_dma_mrpc = …;
module_param(use_dma_mrpc, bool, 0644);
MODULE_PARM_DESC(…) …;
static int nirqs = …;
module_param(nirqs, int, 0644);
MODULE_PARM_DESC(…) …;
static dev_t switchtec_devt;
static DEFINE_IDA(switchtec_minor_ida);
const struct class switchtec_class = …;
EXPORT_SYMBOL_GPL(…);
enum mrpc_state { … };
struct switchtec_user { … };
static int is_firmware_running(struct switchtec_dev *stdev)
{ … }
static struct switchtec_user *stuser_create(struct switchtec_dev *stdev)
{ … }
static void stuser_free(struct kref *kref)
{ … }
static void stuser_put(struct switchtec_user *stuser)
{ … }
static void stuser_set_state(struct switchtec_user *stuser,
enum mrpc_state state)
{ … }
static void mrpc_complete_cmd(struct switchtec_dev *stdev);
static void flush_wc_buf(struct switchtec_dev *stdev)
{ … }
static void mrpc_cmd_submit(struct switchtec_dev *stdev)
{ … }
static int mrpc_queue_cmd(struct switchtec_user *stuser)
{ … }
static void mrpc_cleanup_cmd(struct switchtec_dev *stdev)
{ … }
static void mrpc_complete_cmd(struct switchtec_dev *stdev)
{ … }
static void mrpc_event_work(struct work_struct *work)
{ … }
static void mrpc_error_complete_cmd(struct switchtec_dev *stdev)
{ … }
static void mrpc_timeout_work(struct work_struct *work)
{ … }
static ssize_t device_version_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(device_version);
static ssize_t fw_version_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(fw_version);
static ssize_t io_string_show(char *buf, void __iomem *attr, size_t len)
{ … }
#define DEVICE_ATTR_SYS_INFO_STR(field) …
DEVICE_ATTR_SYS_INFO_STR(…);
DEVICE_ATTR_SYS_INFO_STR(…);
DEVICE_ATTR_SYS_INFO_STR(…);
static ssize_t component_vendor_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(component_vendor);
static ssize_t component_id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(component_id);
static ssize_t component_revision_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(component_revision);
static ssize_t partition_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(partition);
static ssize_t partition_count_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(partition_count);
static struct attribute *switchtec_device_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static int switchtec_dev_open(struct inode *inode, struct file *filp)
{ … }
static int switchtec_dev_release(struct inode *inode, struct file *filp)
{ … }
static int lock_mutex_and_test_alive(struct switchtec_dev *stdev)
{ … }
static ssize_t switchtec_dev_write(struct file *filp, const char __user *data,
size_t size, loff_t *off)
{ … }
static ssize_t switchtec_dev_read(struct file *filp, char __user *data,
size_t size, loff_t *off)
{ … }
static __poll_t switchtec_dev_poll(struct file *filp, poll_table *wait)
{ … }
static int ioctl_flash_info(struct switchtec_dev *stdev,
struct switchtec_ioctl_flash_info __user *uinfo)
{ … }
static void set_fw_info_part(struct switchtec_ioctl_flash_part_info *info,
struct partition_info __iomem *pi)
{ … }
static int flash_part_info_gen3(struct switchtec_dev *stdev,
struct switchtec_ioctl_flash_part_info *info)
{ … }
static int flash_part_info_gen4(struct switchtec_dev *stdev,
struct switchtec_ioctl_flash_part_info *info)
{ … }
static int ioctl_flash_part_info(struct switchtec_dev *stdev,
struct switchtec_ioctl_flash_part_info __user *uinfo)
{ … }
static int ioctl_event_summary(struct switchtec_dev *stdev,
struct switchtec_user *stuser,
struct switchtec_ioctl_event_summary __user *usum,
size_t size)
{ … }
static u32 __iomem *global_ev_reg(struct switchtec_dev *stdev,
size_t offset, int index)
{ … }
static u32 __iomem *part_ev_reg(struct switchtec_dev *stdev,
size_t offset, int index)
{ … }
static u32 __iomem *pff_ev_reg(struct switchtec_dev *stdev,
size_t offset, int index)
{ … }
#define EV_GLB(i, r) …
#define EV_PAR(i, r) …
#define EV_PFF(i, r) …
static const struct event_reg { … } event_regs[] = …;
static u32 __iomem *event_hdr_addr(struct switchtec_dev *stdev,
int event_id, int index)
{ … }
static int event_ctl(struct switchtec_dev *stdev,
struct switchtec_ioctl_event_ctl *ctl)
{ … }
static int ioctl_event_ctl(struct switchtec_dev *stdev,
struct switchtec_ioctl_event_ctl __user *uctl)
{ … }
static int ioctl_pff_to_port(struct switchtec_dev *stdev,
struct switchtec_ioctl_pff_port __user *up)
{ … }
static int ioctl_port_to_pff(struct switchtec_dev *stdev,
struct switchtec_ioctl_pff_port __user *up)
{ … }
static long switchtec_dev_ioctl(struct file *filp, unsigned int cmd,
unsigned long arg)
{ … }
static const struct file_operations switchtec_fops = …;
static void link_event_work(struct work_struct *work)
{ … }
static void check_link_state_events(struct switchtec_dev *stdev)
{ … }
static void enable_link_state_events(struct switchtec_dev *stdev)
{ … }
static void enable_dma_mrpc(struct switchtec_dev *stdev)
{ … }
static void stdev_release(struct device *dev)
{ … }
static void stdev_kill(struct switchtec_dev *stdev)
{ … }
static struct switchtec_dev *stdev_create(struct pci_dev *pdev)
{ … }
static int mask_event(struct switchtec_dev *stdev, int eid, int idx)
{ … }
static int mask_all_events(struct switchtec_dev *stdev, int eid)
{ … }
static irqreturn_t switchtec_event_isr(int irq, void *dev)
{ … }
static irqreturn_t switchtec_dma_mrpc_isr(int irq, void *dev)
{ … }
static int switchtec_init_isr(struct switchtec_dev *stdev)
{ … }
static void init_pff(struct switchtec_dev *stdev)
{ … }
static int switchtec_init_pci(struct switchtec_dev *stdev,
struct pci_dev *pdev)
{ … }
static void switchtec_exit_pci(struct switchtec_dev *stdev)
{ … }
static int switchtec_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *id)
{ … }
static void switchtec_pci_remove(struct pci_dev *pdev)
{ … }
#define SWITCHTEC_PCI_DEVICE(device_id, gen) …
static const struct pci_device_id switchtec_pci_tbl[] = …;
MODULE_DEVICE_TABLE(pci, switchtec_pci_tbl);
static struct pci_driver switchtec_pci_driver = …;
static int __init switchtec_init(void)
{ … }
module_init(…) …;
static void __exit switchtec_exit(void)
{ … }
module_exit(switchtec_exit);