/* 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 (anilgv@broadcom.com) * Previously Maintained by: Eddie Wai (eddie.wai@broadcom.com) * Maintained by: QLogic-Storage-Upstream@qlogic.com
*/
/** * 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)
{ #define BNX2I_INIT_POLL_TIME (1000 / HZ) struct bnx2i_hba *hba = handle; int i = HZ;
/* On some bnx2x devices, it is possible that iSCSI is no * longer supported after firmware is downloaded. In that * case, the iscsi_init_msg will return failure.
*/
/** * 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
*/ staticvoid bnx2i_chip_cleanup(struct bnx2i_hba *hba)
{ struct bnx2i_endpoint *bnx2i_ep; struct list_head *pos, *tmp;
if (hba->ofld_conns_active) { /* Stage to force the disconnection * This is the case where the daemon is either slow or * not present
*/
printk(KERN_ALERT "bnx2i: (%s) chip cleanup for %d active " "connections\n", hba->netdev->name,
hba->ofld_conns_active);
mutex_lock(&hba->net_dev_lock);
list_for_each_safe(pos, tmp, &hba->ep_active_list) {
bnx2i_ep = list_entry(pos, struct bnx2i_endpoint, link); /* Clean up the chip only */
bnx2i_hw_ep_disconnect(bnx2i_ep);
bnx2i_ep->cm_sk = NULL;
}
mutex_unlock(&hba->net_dev_lock);
}
}
/** * 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)
{ struct bnx2i_hba *hba = handle; int conns_active; int wait_delay = 1 * HZ;
/* check if cleanup happened in GOING_DOWN context */ if (!test_and_set_bit(ADAPTER_STATE_GOING_DOWN,
&hba->adapter_state)) {
iscsi_host_for_each_session(hba->shost,
bnx2i_drop_session);
wait_delay = hba->hba_shutdown_tmo;
} /* Wait for inflight offload connection tasks to complete before * proceeding. Forcefully terminate all connection recovery in * progress at the earliest, either in bind(), send_pdu(LOGIN), * or conn_start()
*/
wait_event_interruptible_timeout(hba->eh_wait,
(list_empty(&hba->ep_ofld_list) &&
list_empty(&hba->ep_destroy_list)),
2 * HZ); /* Wait for all endpoints to be torn down, Chip will be reset once * control returns to network driver. So it is required to cleanup and * release all connection resources before returning from this routine.
*/ while (hba->ofld_conns_active) {
conns_active = hba->ofld_conns_active;
wait_event_interruptible_timeout(hba->eh_wait,
(hba->ofld_conns_active != conns_active),
wait_delay); if (hba->ofld_conns_active == conns_active) break;
}
bnx2i_chip_cleanup(hba);
/* This flag should be cleared last so that ep_disconnect() gracefully * cleans up connection context
*/
clear_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state);
clear_bit(ADAPTER_STATE_UP, &hba->adapter_state);
}
/** * 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
*/ staticint bnx2i_init_one(struct bnx2i_hba *hba, struct cnic_dev *cnic)
{ int rc;
mutex_lock(&bnx2i_dev_lock); if (!cnic->max_iscsi_conn) {
printk(KERN_ALERT "bnx2i: dev %s does not support " "iSCSI\n", hba->netdev->name);
rc = -EOPNOTSUPP; goto out;
}
/** * 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)
{ struct bnx2i_hba *hba;
/* Allocate a HBA structure for this device */
hba = bnx2i_alloc_hba(dev); if (!hba) {
printk(KERN_ERR "bnx2i init: hba initialization failed\n"); return;
}
/* Get PCI related information and update hba struct members */
clear_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic); if (bnx2i_init_one(hba, dev)) {
printk(KERN_ERR "bnx2i - hba %p init failed\n", hba);
bnx2i_free_hba(hba);
}
}
/** * bnx2i_ulp_exit - shuts down adapter instance and frees all resources * @dev: cnic device handle *
*/ void bnx2i_ulp_exit(struct cnic_dev *dev)
{ struct bnx2i_hba *hba;
hba = bnx2i_find_hba_for_cnic(dev); if (!hba) {
printk(KERN_INFO "bnx2i_ulp_exit: hba not " "found, dev 0x%p\n", dev); return;
}
mutex_lock(&bnx2i_dev_lock);
list_del_init(&hba->link);
adapter_count--;
if (test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic)) {
hba->cnic->unregister_device(hba->cnic, CNIC_ULP_ISCSI);
clear_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic);
}
mutex_unlock(&bnx2i_dev_lock);
bnx2i_free_hba(hba);
}
/** * 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)
{ struct bnx2i_hba *hba = handle; struct iscsi_stats_info *stats;
/** * bnx2i_cpu_online - Create a receive thread for an online CPU * * @cpu: cpu index for the online cpu
*/ staticint bnx2i_cpu_online(unsignedint cpu)
{ struct bnx2i_percpu_s *p; struct task_struct *thread;
/* Prevent any new work from being queued for this CPU */
p = &per_cpu(bnx2i_percpu, cpu);
spin_lock_bh(&p->p_work_lock);
thread = p->iothread;
p->iothread = NULL;
/* Free all work in the list */
list_for_each_entry_safe(work, tmp, &p->work_list, list) {
list_del_init(&work->list);
bnx2i_process_scsi_cmd_resp(work->session,
work->bnx2i_conn, &work->cqe);
kfree(work);
}
spin_unlock_bh(&p->p_work_lock); if (thread)
kthread_stop(thread); return 0;
}
staticenum 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
*/ staticint __init bnx2i_mod_init(void)
{ int err; unsigned cpu = 0; struct bnx2i_percpu_s *p;
printk(KERN_INFO "%s", version);
if (sq_size && !is_power_of_2(sq_size))
sq_size = roundup_pow_of_two(sq_size);
bnx2i_scsi_xport_template =
iscsi_register_transport(&bnx2i_iscsi_transport); if (!bnx2i_scsi_xport_template) {
printk(KERN_ERR "Could not register bnx2i transport.\n");
err = -ENOMEM; goto out;
}
err = cnic_register_driver(CNIC_ULP_ISCSI, &bnx2i_cnic_cb); if (err) {
printk(KERN_ERR "Could not register bnx2i cnic driver.\n"); goto unreg_xport;
}
/** * 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
*/ staticvoid __exit bnx2i_mod_exit(void)
{ struct bnx2i_hba *hba;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.