aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libiscsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/libiscsi.c')
-rw-r--r--drivers/scsi/libiscsi.c60
1 files changed, 53 insertions, 7 deletions
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 64b1dd827366..73c37c04ca66 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1764,8 +1764,39 @@ void iscsi_pool_free(struct iscsi_pool *q)
1764} 1764}
1765EXPORT_SYMBOL_GPL(iscsi_pool_free); 1765EXPORT_SYMBOL_GPL(iscsi_pool_free);
1766 1766
1767void iscsi_host_setup(struct Scsi_Host *shost, uint16_t qdepth) 1767/**
1768 * iscsi_host_add - add host to system
1769 * @shost: scsi host
1770 * @pdev: parent device
1771 *
1772 * This should be called by partial offload and software iscsi drivers
1773 * to add a host to the system.
1774 */
1775int iscsi_host_add(struct Scsi_Host *shost, struct device *pdev)
1776{
1777 return scsi_add_host(shost, pdev);
1778}
1779EXPORT_SYMBOL_GPL(iscsi_host_add);
1780
1781/**
1782 * iscsi_host_alloc - allocate a host and driver data
1783 * @sht: scsi host template
1784 * @dd_data_size: driver host data size
1785 * @qdepth: default device queue depth
1786 *
1787 * This should be called by partial offload and software iscsi drivers.
1788 * To access the driver specific memory use the iscsi_host_priv() macro.
1789 */
1790struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht,
1791 int dd_data_size, uint16_t qdepth)
1768{ 1792{
1793 struct Scsi_Host *shost;
1794
1795 shost = scsi_host_alloc(sht, sizeof(struct iscsi_host) + dd_data_size);
1796 if (!shost)
1797 return NULL;
1798 shost->transportt->eh_timed_out = iscsi_eh_cmd_timed_out;
1799
1769 if (qdepth > ISCSI_MAX_CMD_PER_LUN || qdepth < 1) { 1800 if (qdepth > ISCSI_MAX_CMD_PER_LUN || qdepth < 1) {
1770 if (qdepth != 0) 1801 if (qdepth != 0)
1771 printk(KERN_ERR "iscsi: invalid queue depth of %d. " 1802 printk(KERN_ERR "iscsi: invalid queue depth of %d. "
@@ -1773,22 +1804,37 @@ void iscsi_host_setup(struct Scsi_Host *shost, uint16_t qdepth)
1773 qdepth, ISCSI_MAX_CMD_PER_LUN); 1804 qdepth, ISCSI_MAX_CMD_PER_LUN);
1774 qdepth = ISCSI_DEF_CMD_PER_LUN; 1805 qdepth = ISCSI_DEF_CMD_PER_LUN;
1775 } 1806 }
1776
1777 shost->transportt->create_work_queue = 1;
1778 shost->transportt->eh_timed_out = iscsi_eh_cmd_timed_out;
1779 shost->cmd_per_lun = qdepth; 1807 shost->cmd_per_lun = qdepth;
1808 return shost;
1809}
1810EXPORT_SYMBOL_GPL(iscsi_host_alloc);
1811
1812/**
1813 * iscsi_host_remove - remove host and sessions
1814 * @shost: scsi host
1815 *
1816 * This will also remove any sessions attached to the host, but if userspace
1817 * is managing the session at the same time this will break. TODO: add
1818 * refcounting to the netlink iscsi interface so a rmmod or host hot unplug
1819 * does not remove the memory from under us.
1820 */
1821void iscsi_host_remove(struct Scsi_Host *shost)
1822{
1823 iscsi_host_for_each_session(shost, iscsi_session_teardown);
1824 scsi_remove_host(shost);
1780} 1825}
1781EXPORT_SYMBOL_GPL(iscsi_host_setup); 1826EXPORT_SYMBOL_GPL(iscsi_host_remove);
1782 1827
1783void iscsi_host_teardown(struct Scsi_Host *shost) 1828void iscsi_host_free(struct Scsi_Host *shost)
1784{ 1829{
1785 struct iscsi_host *ihost = shost_priv(shost); 1830 struct iscsi_host *ihost = shost_priv(shost);
1786 1831
1787 kfree(ihost->netdev); 1832 kfree(ihost->netdev);
1788 kfree(ihost->hwaddress); 1833 kfree(ihost->hwaddress);
1789 kfree(ihost->initiatorname); 1834 kfree(ihost->initiatorname);
1835 scsi_host_put(shost);
1790} 1836}
1791EXPORT_SYMBOL_GPL(iscsi_host_teardown); 1837EXPORT_SYMBOL_GPL(iscsi_host_free);
1792 1838
1793/** 1839/**
1794 * iscsi_session_setup - create iscsi cls session and host and session 1840 * iscsi_session_setup - create iscsi cls session and host and session