/* * This file is part of the Chelsio FCoE driver for Linux. * * Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - 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. */ #define pr_fmt(fmt) … #include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h> #include <linux/pci.h> #include <linux/mm.h> #include <linux/notifier.h> #include <linux/kdebug.h> #include <linux/seq_file.h> #include <linux/debugfs.h> #include <linux/string.h> #include <linux/export.h> #include "csio_init.h" #include "csio_defs.h" #define CSIO_MIN_MEMPOOL_SZ … static struct dentry *csio_debugfs_root; static struct scsi_transport_template *csio_fcoe_transport; static struct scsi_transport_template *csio_fcoe_transport_vport; /* * debugfs support */ static ssize_t csio_mem_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { … } static const struct file_operations csio_mem_debugfs_fops = …; void csio_add_debugfs_mem(struct csio_hw *hw, const char *name, unsigned int idx, unsigned int size_mb) { … } static int csio_setup_debugfs(struct csio_hw *hw) { … } /* * csio_dfs_create - Creates and sets up per-hw debugfs. * */ static int csio_dfs_create(struct csio_hw *hw) { … } /* * csio_dfs_destroy - Destroys per-hw debugfs. */ static void csio_dfs_destroy(struct csio_hw *hw) { … } /* * csio_dfs_init - Debug filesystem initialization for the module. * */ static void csio_dfs_init(void) { … } /* * csio_dfs_exit - debugfs cleanup for the module. */ static void csio_dfs_exit(void) { … } /* * csio_pci_init - PCI initialization. * @pdev: PCI device. * @bars: Bitmask of bars to be requested. * * Initializes the PCI function by enabling MMIO, setting bus * mastership and setting DMA mask. */ static int csio_pci_init(struct pci_dev *pdev, int *bars) { … } /* * csio_pci_exit - PCI unitialization. * @pdev: PCI device. * @bars: Bars to be released. * */ static void csio_pci_exit(struct pci_dev *pdev, int *bars) { … } /* * csio_hw_init_workers - Initialize the HW module's worker threads. * @hw: HW module. * */ static void csio_hw_init_workers(struct csio_hw *hw) { … } static void csio_hw_exit_workers(struct csio_hw *hw) { … } static int csio_create_queues(struct csio_hw *hw) { … } /* * csio_config_queues - Configure the DMA queues. * @hw: HW module. * * Allocates memory for queues are registers them with FW. */ int csio_config_queues(struct csio_hw *hw) { … } static int csio_resource_alloc(struct csio_hw *hw) { … } static void csio_resource_free(struct csio_hw *hw) { … } /* * csio_hw_alloc - Allocate and initialize the HW module. * @pdev: PCI device. * * Allocates HW structure, DMA, memory resources, maps BARS to * host memory and initializes HW module. */ static struct csio_hw *csio_hw_alloc(struct pci_dev *pdev) { … } /* * csio_hw_free - Uninitialize and free the HW module. * @hw: The HW module * * Disable interrupts, uninit the HW module, free resources, free hw. */ static void csio_hw_free(struct csio_hw *hw) { … } /** * csio_shost_init - Create and initialize the lnode module. * @hw: The HW module. * @dev: The device associated with this invocation. * @probe: Called from probe context or not? * @pln: Parent lnode if any. * * Allocates lnode structure via scsi_host_alloc, initializes * shost, initializes lnode module and registers with SCSI ML * via scsi_host_add. This function is shared between physical and * virtual node ports. */ struct csio_lnode * csio_shost_init(struct csio_hw *hw, struct device *dev, bool probe, struct csio_lnode *pln) { … } /** * csio_shost_exit - De-instantiate the shost. * @ln: The lnode module corresponding to the shost. * */ void csio_shost_exit(struct csio_lnode *ln) { … } struct csio_lnode * csio_lnode_alloc(struct csio_hw *hw) { … } void csio_lnodes_block_request(struct csio_hw *hw) { … } void csio_lnodes_unblock_request(struct csio_hw *hw) { … } void csio_lnodes_block_by_port(struct csio_hw *hw, uint8_t portid) { … } void csio_lnodes_unblock_by_port(struct csio_hw *hw, uint8_t portid) { … } void csio_lnodes_exit(struct csio_hw *hw, bool npiv) { … } /* * csio_lnode_init_post: Set lnode attributes after starting HW. * @ln: lnode. * */ static void csio_lnode_init_post(struct csio_lnode *ln) { … } /* * csio_probe_one - Instantiate this function. * @pdev: PCI device * @id: Device ID * * This is the .probe() callback of the driver. This function: * - Initializes the PCI function by enabling MMIO, setting bus * mastership and setting DMA mask. * - Allocates HW structure, DMA, memory resources, maps BARS to * host memory and initializes HW module. * - Allocates lnode structure via scsi_host_alloc, initializes * shost, initialized lnode module and registers with SCSI ML * via scsi_host_add. * - Enables interrupts, and starts the chip by kicking off the * HW state machine. * - Once hardware is ready, initiated scan of the host via * scsi_scan_host. */ static int csio_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) { … } /* * csio_remove_one - Remove one instance of the driver at this PCI function. * @pdev: PCI device * * Used during hotplug operation. */ static void csio_remove_one(struct pci_dev *pdev) { … } /* * csio_pci_error_detected - PCI error was detected * @pdev: PCI device * */ static pci_ers_result_t csio_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) { … } /* * csio_pci_slot_reset - PCI slot has been reset. * @pdev: PCI device * */ static pci_ers_result_t csio_pci_slot_reset(struct pci_dev *pdev) { … } /* * csio_pci_resume - Resume normal operations * @pdev: PCI device * */ static void csio_pci_resume(struct pci_dev *pdev) { … } static struct pci_error_handlers csio_err_handler = …; /* * Macros needed to support the PCI Device ID Table ... */ #define CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN … /* Define for FCoE uses PF6 */ #define CH_PCI_DEVICE_ID_FUNCTION … #define CH_PCI_ID_TABLE_ENTRY(devid) … #define CH_PCI_DEVICE_ID_TABLE_DEFINE_END … #include "t4_pci_id_tbl.h" static struct pci_driver csio_pci_driver = …; /* * csio_init - Chelsio storage driver initialization function. * */ static int __init csio_init(void) { … } /* * csio_exit - Chelsio storage driver uninitialization . * * Function that gets called in the unload path. */ static void __exit csio_exit(void) { … } module_init(…) …; module_exit(csio_exit); MODULE_AUTHOR(…); MODULE_DESCRIPTION(…); MODULE_LICENSE(…) …; MODULE_DEVICE_TABLE(pci, csio_pci_tbl); MODULE_VERSION(…); MODULE_FIRMWARE(…); MODULE_FIRMWARE(…); MODULE_SOFTDEP(…) …;