1 /* cxgb3i_init.c: Chelsio S3xx iSCSI driver.
3 * Copyright (c) 2008 Chelsio Communications, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation.
9 * Written by: Karen Xie (kxie@chelsio.com)
14 #define DRV_MODULE_NAME "cxgb3i"
15 #define DRV_MODULE_VERSION "1.0.1"
16 #define DRV_MODULE_RELDATE "Jan. 2009"
18 static char version[] =
19 "Chelsio S3xx iSCSI Driver " DRV_MODULE_NAME
20 " v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
22 MODULE_AUTHOR("Karen Xie <kxie@chelsio.com>");
23 MODULE_DESCRIPTION("Chelsio S3xx iSCSI Driver");
24 MODULE_LICENSE("GPL");
25 MODULE_VERSION(DRV_MODULE_VERSION);
27 static void open_s3_dev(struct t3cdev *);
28 static void close_s3_dev(struct t3cdev *);
29 static void s3_err_handler(struct t3cdev *tdev, u32 status, u32 error);
31 static cxgb3_cpl_handler_func cxgb3i_cpl_handlers[NUM_CPL_CMDS];
32 static struct cxgb3_client t3c_client = {
33 .name = "iscsi_cxgb3",
34 .handlers = cxgb3i_cpl_handlers,
36 .remove = close_s3_dev,
37 .err_handler = s3_err_handler,
41 * open_s3_dev - register with cxgb3 LLD
42 * @t3dev: cxgb3 adapter instance
44 static void open_s3_dev(struct t3cdev *t3dev)
46 static int vers_printed;
49 printk(KERN_INFO "%s", version);
53 cxgb3i_sdev_add(t3dev, &t3c_client);
54 cxgb3i_adapter_open(t3dev);
58 * close_s3_dev - de-register with cxgb3 LLD
59 * @t3dev: cxgb3 adapter instance
61 static void close_s3_dev(struct t3cdev *t3dev)
63 cxgb3i_adapter_close(t3dev);
64 cxgb3i_sdev_remove(t3dev);
67 static void s3_err_handler(struct t3cdev *tdev, u32 status, u32 error)
69 struct cxgb3i_adapter *snic = cxgb3i_adapter_find_by_tdev(tdev);
71 cxgb3i_log_info("snic 0x%p, tdev 0x%p, status 0x%x, err 0x%x.\n",
72 snic, tdev, status, error);
77 case OFFLOAD_STATUS_DOWN:
78 snic->flags |= CXGB3I_ADAPTER_FLAG_RESET;
80 case OFFLOAD_STATUS_UP:
81 snic->flags &= ~CXGB3I_ADAPTER_FLAG_RESET;
87 * cxgb3i_init_module - module init entry point
89 * initialize any driver wide global data structures and register itself
90 * with the cxgb3 module
92 static int __init cxgb3i_init_module(void)
96 err = cxgb3i_sdev_init(cxgb3i_cpl_handlers);
100 err = cxgb3i_iscsi_init();
104 err = cxgb3i_pdu_init();
108 cxgb3_register_client(&t3c_client);
114 * cxgb3i_exit_module - module cleanup/exit entry point
116 * go through the driver hba list and for each hba, release any resource held.
117 * and unregisters iscsi transport and the cxgb3 module
119 static void __exit cxgb3i_exit_module(void)
121 cxgb3_unregister_client(&t3c_client);
122 cxgb3i_pdu_cleanup();
123 cxgb3i_iscsi_cleanup();
124 cxgb3i_sdev_cleanup();
127 module_init(cxgb3i_init_module);
128 module_exit(cxgb3i_exit_module);