cxgb3i.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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 <linux/skbuff.h>
  22. #include <scsi/libiscsi_tcp.h>
  23. /* from cxgb3 LLD */
  24. #include "common.h"
  25. #include "t3_cpl.h"
  26. #include "t3cdev.h"
  27. #include "cxgb3_ctl_defs.h"
  28. #include "cxgb3_offload.h"
  29. #include "firmware_exports.h"
  30. #include "cxgb3i_offload.h"
  31. #include "cxgb3i_ddp.h"
  32. #define CXGB3I_SCSI_HOST_QDEPTH 1024
  33. #define CXGB3I_MAX_TARGET CXGB3I_MAX_CONN
  34. #define CXGB3I_MAX_LUN 512
  35. #define ISCSI_PDU_NONPAYLOAD_MAX \
  36. (sizeof(struct iscsi_hdr) + ISCSI_MAX_AHS_SIZE + 2*ISCSI_DIGEST_SIZE)
  37. struct cxgb3i_adapter;
  38. struct cxgb3i_hba;
  39. struct cxgb3i_endpoint;
  40. /**
  41. * struct cxgb3i_hba - cxgb3i iscsi structure (per port)
  42. *
  43. * @snic: cxgb3i adapter containing this port
  44. * @ndev: pointer to netdev structure
  45. * @shost: pointer to scsi host structure
  46. */
  47. struct cxgb3i_hba {
  48. struct cxgb3i_adapter *snic;
  49. struct net_device *ndev;
  50. struct Scsi_Host *shost;
  51. };
  52. /**
  53. * struct cxgb3i_adapter - cxgb3i adapter structure (per pci)
  54. *
  55. * @listhead: list head to link elements
  56. * @lock: lock for this structure
  57. * @tdev: pointer to t3cdev used by cxgb3 driver
  58. * @pdev: pointer to pci dev
  59. * @hba_cnt: # of hbas (the same as # of ports)
  60. * @hba: all the hbas on this adapter
  61. * @flags: bit flag for adapter event/status
  62. * @tx_max_size: max. tx packet size supported
  63. * @rx_max_size: max. rx packet size supported
  64. * @tag_format: ddp tag format settings
  65. */
  66. #define CXGB3I_ADAPTER_FLAG_RESET 0x1
  67. struct cxgb3i_adapter {
  68. struct list_head list_head;
  69. spinlock_t lock;
  70. struct t3cdev *tdev;
  71. struct pci_dev *pdev;
  72. unsigned char hba_cnt;
  73. struct cxgb3i_hba *hba[MAX_NPORTS];
  74. unsigned int flags;
  75. unsigned int tx_max_size;
  76. unsigned int rx_max_size;
  77. struct cxgb3i_tag_format tag_format;
  78. };
  79. /**
  80. * struct cxgb3i_conn - cxgb3i iscsi connection
  81. *
  82. * @listhead: list head to link elements
  83. * @cep: pointer to iscsi_endpoint structure
  84. * @conn: pointer to iscsi_conn structure
  85. * @hba: pointer to the hba this conn. is going through
  86. * @task_idx_bits: # of bits needed for session->cmds_max
  87. */
  88. struct cxgb3i_conn {
  89. struct list_head list_head;
  90. struct cxgb3i_endpoint *cep;
  91. struct iscsi_conn *conn;
  92. struct cxgb3i_hba *hba;
  93. unsigned int task_idx_bits;
  94. };
  95. /**
  96. * struct cxgb3i_endpoint - iscsi tcp endpoint
  97. *
  98. * @c3cn: the h/w tcp connection representation
  99. * @hba: pointer to the hba this conn. is going through
  100. * @cconn: pointer to the associated cxgb3i iscsi connection
  101. */
  102. struct cxgb3i_endpoint {
  103. struct s3_conn *c3cn;
  104. struct cxgb3i_hba *hba;
  105. struct cxgb3i_conn *cconn;
  106. };
  107. /**
  108. * struct cxgb3i_task_data - private iscsi task data
  109. *
  110. * @nr_frags: # of coalesced page frags (from scsi sgl)
  111. * @frags: coalesced page frags (from scsi sgl)
  112. * @skb: tx pdu skb
  113. * @offset: data offset for the next pdu
  114. * @count: max. possible pdu payload
  115. * @sgoffset: offset to the first sg entry for a given offset
  116. */
  117. #define MAX_PDU_FRAGS ((ULP2_MAX_PDU_PAYLOAD + 512 - 1) / 512)
  118. struct cxgb3i_task_data {
  119. unsigned short nr_frags;
  120. skb_frag_t frags[MAX_PDU_FRAGS];
  121. struct sk_buff *skb;
  122. unsigned int offset;
  123. unsigned int count;
  124. unsigned int sgoffset;
  125. };
  126. int cxgb3i_iscsi_init(void);
  127. void cxgb3i_iscsi_cleanup(void);
  128. struct cxgb3i_adapter *cxgb3i_adapter_find_by_tdev(struct t3cdev *);
  129. void cxgb3i_adapter_open(struct t3cdev *);
  130. void cxgb3i_adapter_close(struct t3cdev *);
  131. struct cxgb3i_hba *cxgb3i_hba_host_add(struct cxgb3i_adapter *,
  132. struct net_device *);
  133. void cxgb3i_hba_host_remove(struct cxgb3i_hba *);
  134. int cxgb3i_pdu_init(void);
  135. void cxgb3i_pdu_cleanup(void);
  136. void cxgb3i_conn_cleanup_task(struct iscsi_task *);
  137. int cxgb3i_conn_alloc_pdu(struct iscsi_task *, u8);
  138. int cxgb3i_conn_init_pdu(struct iscsi_task *, unsigned int, unsigned int);
  139. int cxgb3i_conn_xmit_pdu(struct iscsi_task *);
  140. void cxgb3i_release_itt(struct iscsi_task *task, itt_t hdr_itt);
  141. int cxgb3i_reserve_itt(struct iscsi_task *task, itt_t *hdr_itt);
  142. #endif