/* bnx2i.c: QLogic NetXtreme II iSCSI driver. * * Copyright (c) 2006 - 2013 Broadcom Corporation * Copyright (c) 2007, 2008 Red Hat, Inc. All rights reserved. * Copyright (c) 2007, 2008 Mike Christie * Copyright (c) 2014, QLogic Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation. * * Written by: Anil Veerabhadrappa ([email protected]) * Previously Maintained by: Eddie Wai ([email protected]) * Maintained by: [email protected] */ #include "bnx2i.h" static struct list_head adapter_list = …; static u32 adapter_count; #define DRV_MODULE_NAME … #define DRV_MODULE_VERSION … #define DRV_MODULE_RELDATE … static char version[] = …; MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …; MODULE_VERSION(…); static DEFINE_MUTEX(bnx2i_dev_lock); unsigned int event_coal_min = …; module_param(event_coal_min, int, 0664); MODULE_PARM_DESC(…) …; unsigned int event_coal_div = …; module_param(event_coal_div, int, 0664); MODULE_PARM_DESC(…) …; unsigned int en_tcp_dack = …; module_param(en_tcp_dack, int, 0664); MODULE_PARM_DESC(…) …; unsigned int error_mask1 = …; module_param(error_mask1, uint, 0664); MODULE_PARM_DESC(…) …; unsigned int error_mask2 = …; module_param(error_mask2, uint, 0664); MODULE_PARM_DESC(…) …; unsigned int sq_size; module_param(sq_size, int, 0664); MODULE_PARM_DESC(…) …; unsigned int rq_size = …; module_param(rq_size, int, 0664); MODULE_PARM_DESC(…) …; u64 iscsi_error_mask = …; DEFINE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu); /** * bnx2i_identify_device - identifies NetXtreme II device type * @hba: Adapter structure pointer * @dev: Corresponding cnic device * * This function identifies the NX2 device type and sets appropriate * queue mailbox register access method, 5709 requires driver to * access MBOX regs using *bin* mode */ void bnx2i_identify_device(struct bnx2i_hba *hba, struct cnic_dev *dev) { … } /** * get_adapter_list_head - returns head of adapter list */ struct bnx2i_hba *get_adapter_list_head(void) { … } /** * bnx2i_find_hba_for_cnic - maps cnic device instance to bnx2i adapter instance * @cnic: pointer to cnic device instance * */ struct bnx2i_hba *bnx2i_find_hba_for_cnic(struct cnic_dev *cnic) { … } /** * bnx2i_start - cnic callback to initialize & start adapter instance * @handle: transparent handle pointing to adapter structure * * This function maps adapter structure to pcidev structure and initiates * firmware handshake to enable/initialize on chip iscsi components * This bnx2i - cnic interface api callback is issued after following * 2 conditions are met - * a) underlying network interface is up (marked by event 'NETDEV_UP' * from netdev * b) bnx2i adapter instance is registered */ void bnx2i_start(void *handle) { … } /** * bnx2i_chip_cleanup - local routine to handle chip cleanup * @hba: Adapter instance to register * * Driver checks if adapter still has any active connections before * executing the cleanup process */ static void bnx2i_chip_cleanup(struct bnx2i_hba *hba) { … } /** * bnx2i_stop - cnic callback to shutdown adapter instance * @handle: transparent handle pointing to adapter structure * * driver checks if adapter is already in shutdown mode, if not start * the shutdown process */ void bnx2i_stop(void *handle) { … } /** * bnx2i_init_one - initialize an adapter instance and allocate memory resources * @hba: bnx2i adapter instance * @cnic: cnic device handle * * Global resource lock is held during critical sections below. This routine is * called from either cnic_register_driver() or device hot plug context and * and does majority of device specific initialization */ static int bnx2i_init_one(struct bnx2i_hba *hba, struct cnic_dev *cnic) { … } /** * bnx2i_ulp_init - initialize an adapter instance * @dev: cnic device handle * * Called from cnic_register_driver() context to initialize all enumerated * cnic devices. This routine allocate adapter structure and other * device specific resources. */ void bnx2i_ulp_init(struct cnic_dev *dev) { … } /** * bnx2i_ulp_exit - shuts down adapter instance and frees all resources * @dev: cnic device handle * */ void bnx2i_ulp_exit(struct cnic_dev *dev) { … } /** * bnx2i_get_stats - Retrieve various statistic from iSCSI offload * @handle: bnx2i_hba * * function callback exported via bnx2i - cnic driver interface to * retrieve various iSCSI offload related statistics. */ int bnx2i_get_stats(void *handle) { … } /** * bnx2i_cpu_online - Create a receive thread for an online CPU * * @cpu: cpu index for the online cpu */ static int bnx2i_cpu_online(unsigned int cpu) { … } static int bnx2i_cpu_offline(unsigned int cpu) { … } static enum cpuhp_state bnx2i_online_state; /** * bnx2i_mod_init - module init entry point * * initialize any driver wide global data structures such as endpoint pool, * tcp port manager/queue, sysfs. finally driver will register itself * with the cnic module */ static int __init bnx2i_mod_init(void) { … } /** * bnx2i_mod_exit - module cleanup/exit entry point * * Global resource lock and host adapter lock is held during critical sections * in this function. Driver will browse through the adapter list, cleans-up * each instance, unregisters iscsi transport name and finally driver will * unregister itself with the cnic module */ static void __exit bnx2i_mod_exit(void) { … } module_init(…) …; module_exit(bnx2i_mod_exit);