cxgb3i_init.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* cxgb3i_init.c: Chelsio S3xx iSCSI driver.
  2. *
  3. * Copyright (c) 2008 Chelsio Communications, Inc.
  4. *
  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.
  8. *
  9. * Written by: Karen Xie (kxie@chelsio.com)
  10. */
  11. #include "cxgb3i.h"
  12. #define DRV_MODULE_NAME "cxgb3i"
  13. #define DRV_MODULE_VERSION "1.0.0"
  14. #define DRV_MODULE_RELDATE "Jun. 1, 2008"
  15. static char version[] =
  16. "Chelsio S3xx iSCSI Driver " DRV_MODULE_NAME
  17. " v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
  18. MODULE_AUTHOR("Karen Xie <kxie@chelsio.com>");
  19. MODULE_DESCRIPTION("Chelsio S3xx iSCSI Driver");
  20. MODULE_LICENSE("GPL");
  21. MODULE_VERSION(DRV_MODULE_VERSION);
  22. static void open_s3_dev(struct t3cdev *);
  23. static void close_s3_dev(struct t3cdev *);
  24. static cxgb3_cpl_handler_func cxgb3i_cpl_handlers[NUM_CPL_CMDS];
  25. static struct cxgb3_client t3c_client = {
  26. .name = "iscsi_cxgb3",
  27. .handlers = cxgb3i_cpl_handlers,
  28. .add = open_s3_dev,
  29. .remove = close_s3_dev,
  30. };
  31. /**
  32. * open_s3_dev - register with cxgb3 LLD
  33. * @t3dev: cxgb3 adapter instance
  34. */
  35. static void open_s3_dev(struct t3cdev *t3dev)
  36. {
  37. static int vers_printed;
  38. if (!vers_printed) {
  39. printk(KERN_INFO "%s", version);
  40. vers_printed = 1;
  41. }
  42. cxgb3i_sdev_add(t3dev, &t3c_client);
  43. cxgb3i_adapter_add(t3dev);
  44. }
  45. /**
  46. * close_s3_dev - de-register with cxgb3 LLD
  47. * @t3dev: cxgb3 adapter instance
  48. */
  49. static void close_s3_dev(struct t3cdev *t3dev)
  50. {
  51. cxgb3i_adapter_remove(t3dev);
  52. cxgb3i_sdev_remove(t3dev);
  53. }
  54. /**
  55. * cxgb3i_init_module - module init entry point
  56. *
  57. * initialize any driver wide global data structures and register itself
  58. * with the cxgb3 module
  59. */
  60. static int __init cxgb3i_init_module(void)
  61. {
  62. int err;
  63. err = cxgb3i_sdev_init(cxgb3i_cpl_handlers);
  64. if (err < 0)
  65. return err;
  66. err = cxgb3i_iscsi_init();
  67. if (err < 0)
  68. return err;
  69. err = cxgb3i_pdu_init();
  70. if (err < 0)
  71. return err;
  72. cxgb3_register_client(&t3c_client);
  73. return 0;
  74. }
  75. /**
  76. * cxgb3i_exit_module - module cleanup/exit entry point
  77. *
  78. * go through the driver hba list and for each hba, release any resource held.
  79. * and unregisters iscsi transport and the cxgb3 module
  80. */
  81. static void __exit cxgb3i_exit_module(void)
  82. {
  83. cxgb3_unregister_client(&t3c_client);
  84. cxgb3i_pdu_cleanup();
  85. cxgb3i_iscsi_cleanup();
  86. cxgb3i_sdev_cleanup();
  87. }
  88. module_init(cxgb3i_init_module);
  89. module_exit(cxgb3i_exit_module);