cxgb3i.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * cxgb3i.h: Chelsio S3xx iSCSI driver.
  3. *
  4. * Copyright (c) 2008 Chelsio Communications, Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation.
  9. *
  10. * Written by: Karen Xie (kxie@chelsio.com)
  11. */
  12. #ifndef __CXGB3I_H__
  13. #define __CXGB3I_H__
  14. #include <linux/module.h>
  15. #include <linux/moduleparam.h>
  16. #include <linux/errno.h>
  17. #include <linux/types.h>
  18. #include <linux/list.h>
  19. #include <linux/netdevice.h>
  20. #include <linux/scatterlist.h>
  21. #include <scsi/libiscsi_tcp.h>
  22. /* from cxgb3 LLD */
  23. #include "common.h"
  24. #include "t3_cpl.h"
  25. #include "t3cdev.h"
  26. #include "cxgb3_ctl_defs.h"
  27. #include "cxgb3_offload.h"
  28. #include "firmware_exports.h"
  29. #include "cxgb3i_offload.h"
  30. #include "cxgb3i_ddp.h"
  31. #define CXGB3I_SCSI_QDEPTH_DFLT 128
  32. #define CXGB3I_MAX_TARGET CXGB3I_MAX_CONN
  33. #define CXGB3I_MAX_LUN 512
  34. #define ISCSI_PDU_NONPAYLOAD_MAX \
  35. (sizeof(struct iscsi_hdr) + ISCSI_MAX_AHS_SIZE + 2*ISCSI_DIGEST_SIZE)
  36. struct cxgb3i_adapter;
  37. struct cxgb3i_hba;
  38. struct cxgb3i_endpoint;
  39. /**
  40. * struct cxgb3i_hba - cxgb3i iscsi structure (per port)
  41. *
  42. * @snic: cxgb3i adapter containing this port
  43. * @ndev: pointer to netdev structure
  44. * @shost: pointer to scsi host structure
  45. */
  46. struct cxgb3i_hba {
  47. struct cxgb3i_adapter *snic;
  48. struct net_device *ndev;
  49. struct Scsi_Host *shost;
  50. };
  51. /**
  52. * struct cxgb3i_adapter - cxgb3i adapter structure (per pci)
  53. *
  54. * @listhead: list head to link elements
  55. * @lock: lock for this structure
  56. * @tdev: pointer to t3cdev used by cxgb3 driver
  57. * @pdev: pointer to pci dev
  58. * @hba_cnt: # of hbas (the same as # of ports)
  59. * @hba: all the hbas on this adapter
  60. * @tx_max_size: max. tx packet size supported
  61. * @rx_max_size: max. rx packet size supported
  62. * @tag_format: ddp tag format settings
  63. */
  64. struct cxgb3i_adapter {
  65. struct list_head list_head;
  66. spinlock_t lock;
  67. struct t3cdev *tdev;
  68. struct pci_dev *pdev;
  69. unsigned char hba_cnt;
  70. struct cxgb3i_hba *hba[MAX_NPORTS];
  71. unsigned int tx_max_size;
  72. unsigned int rx_max_size;
  73. struct cxgb3i_tag_format tag_format;
  74. };
  75. /**
  76. * struct cxgb3i_conn - cxgb3i iscsi connection
  77. *
  78. * @listhead: list head to link elements
  79. * @cep: pointer to iscsi_endpoint structure
  80. * @conn: pointer to iscsi_conn structure
  81. * @hba: pointer to the hba this conn. is going through
  82. * @task_idx_bits: # of bits needed for session->cmds_max
  83. */
  84. struct cxgb3i_conn {
  85. struct list_head list_head;
  86. struct cxgb3i_endpoint *cep;
  87. struct iscsi_conn *conn;
  88. struct cxgb3i_hba *hba;
  89. unsigned int task_idx_bits;
  90. };
  91. /**
  92. * struct cxgb3i_endpoint - iscsi tcp endpoint
  93. *
  94. * @c3cn: the h/w tcp connection representation
  95. * @hba: pointer to the hba this conn. is going through
  96. * @cconn: pointer to the associated cxgb3i iscsi connection
  97. */
  98. struct cxgb3i_endpoint {
  99. struct s3_conn *c3cn;
  100. struct cxgb3i_hba *hba;
  101. struct cxgb3i_conn *cconn;
  102. };
  103. int cxgb3i_iscsi_init(void);
  104. void cxgb3i_iscsi_cleanup(void);
  105. struct cxgb3i_adapter *cxgb3i_adapter_add(struct t3cdev *);
  106. void cxgb3i_adapter_remove(struct t3cdev *);
  107. int cxgb3i_adapter_ulp_init(struct cxgb3i_adapter *);
  108. void cxgb3i_adapter_ulp_cleanup(struct cxgb3i_adapter *);
  109. struct cxgb3i_hba *cxgb3i_hba_find_by_netdev(struct net_device *);
  110. struct cxgb3i_hba *cxgb3i_hba_host_add(struct cxgb3i_adapter *,
  111. struct net_device *);
  112. void cxgb3i_hba_host_remove(struct cxgb3i_hba *);
  113. int cxgb3i_pdu_init(void);
  114. void cxgb3i_pdu_cleanup(void);
  115. void cxgb3i_conn_cleanup_task(struct iscsi_task *);
  116. int cxgb3i_conn_alloc_pdu(struct iscsi_task *, u8);
  117. int cxgb3i_conn_init_pdu(struct iscsi_task *, unsigned int, unsigned int);
  118. int cxgb3i_conn_xmit_pdu(struct iscsi_task *);
  119. void cxgb3i_release_itt(struct iscsi_task *task, itt_t hdr_itt);
  120. int cxgb3i_reserve_itt(struct iscsi_task *task, itt_t *hdr_itt);
  121. #endif