2 * cxgb3i.h: Chelsio S3xx iSCSI driver.
4 * Copyright (c) 2008 Chelsio Communications, Inc.
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.
10 * Written by: Karen Xie (kxie@chelsio.com)
16 #include <linux/module.h>
17 #include <linux/moduleparam.h>
18 #include <linux/errno.h>
19 #include <linux/types.h>
20 #include <linux/list.h>
21 #include <linux/netdevice.h>
22 #include <linux/scatterlist.h>
23 #include <linux/skbuff.h>
24 #include <scsi/libiscsi_tcp.h>
30 #include "cxgb3_ctl_defs.h"
31 #include "cxgb3_offload.h"
32 #include "firmware_exports.h"
34 #include "cxgb3i_offload.h"
35 #include "cxgb3i_ddp.h"
37 #define CXGB3I_SCSI_HOST_QDEPTH 1024
38 #define CXGB3I_MAX_TARGET CXGB3I_MAX_CONN
39 #define CXGB3I_MAX_LUN 512
40 #define ISCSI_PDU_NONPAYLOAD_MAX \
41 (sizeof(struct iscsi_hdr) + ISCSI_MAX_AHS_SIZE + 2*ISCSI_DIGEST_SIZE)
43 struct cxgb3i_adapter
;
45 struct cxgb3i_endpoint
;
48 * struct cxgb3i_hba - cxgb3i iscsi structure (per port)
50 * @snic: cxgb3i adapter containing this port
51 * @ndev: pointer to netdev structure
52 * @shost: pointer to scsi host structure
55 struct cxgb3i_adapter
*snic
;
56 struct net_device
*ndev
;
57 struct Scsi_Host
*shost
;
61 * struct cxgb3i_adapter - cxgb3i adapter structure (per pci)
63 * @listhead: list head to link elements
64 * @lock: lock for this structure
65 * @tdev: pointer to t3cdev used by cxgb3 driver
66 * @pdev: pointer to pci dev
67 * @hba_cnt: # of hbas (the same as # of ports)
68 * @hba: all the hbas on this adapter
69 * @flags: bit flag for adapter event/status
70 * @tx_max_size: max. tx packet size supported
71 * @rx_max_size: max. rx packet size supported
72 * @tag_format: ddp tag format settings
74 #define CXGB3I_ADAPTER_FLAG_RESET 0x1
75 struct cxgb3i_adapter
{
76 struct list_head list_head
;
80 unsigned char hba_cnt
;
81 struct cxgb3i_hba
*hba
[MAX_NPORTS
];
84 unsigned int tx_max_size
;
85 unsigned int rx_max_size
;
87 struct cxgb3i_tag_format tag_format
;
91 * struct cxgb3i_conn - cxgb3i iscsi connection
93 * @listhead: list head to link elements
94 * @cep: pointer to iscsi_endpoint structure
95 * @conn: pointer to iscsi_conn structure
96 * @hba: pointer to the hba this conn. is going through
97 * @task_idx_bits: # of bits needed for session->cmds_max
100 struct list_head list_head
;
101 struct cxgb3i_endpoint
*cep
;
102 struct iscsi_conn
*conn
;
103 struct cxgb3i_hba
*hba
;
104 unsigned int task_idx_bits
;
108 * struct cxgb3i_endpoint - iscsi tcp endpoint
110 * @c3cn: the h/w tcp connection representation
111 * @hba: pointer to the hba this conn. is going through
112 * @cconn: pointer to the associated cxgb3i iscsi connection
114 struct cxgb3i_endpoint
{
115 struct s3_conn
*c3cn
;
116 struct cxgb3i_hba
*hba
;
117 struct cxgb3i_conn
*cconn
;
121 * struct cxgb3i_task_data - private iscsi task data
123 * @nr_frags: # of coalesced page frags (from scsi sgl)
124 * @frags: coalesced page frags (from scsi sgl)
126 * @offset: data offset for the next pdu
127 * @count: max. possible pdu payload
128 * @sgoffset: offset to the first sg entry for a given offset
130 #define MAX_PDU_FRAGS ((ULP2_MAX_PDU_PAYLOAD + 512 - 1) / 512)
131 struct cxgb3i_task_data
{
132 unsigned short nr_frags
;
133 skb_frag_t frags
[MAX_PDU_FRAGS
];
137 unsigned int sgoffset
;
140 int cxgb3i_iscsi_init(void);
141 void cxgb3i_iscsi_cleanup(void);
143 struct cxgb3i_adapter
*cxgb3i_adapter_find_by_tdev(struct t3cdev
*);
144 void cxgb3i_adapter_open(struct t3cdev
*);
145 void cxgb3i_adapter_close(struct t3cdev
*);
147 struct cxgb3i_hba
*cxgb3i_hba_host_add(struct cxgb3i_adapter
*,
148 struct net_device
*);
149 void cxgb3i_hba_host_remove(struct cxgb3i_hba
*);
151 int cxgb3i_pdu_init(void);
152 void cxgb3i_pdu_cleanup(void);
153 void cxgb3i_conn_cleanup_task(struct iscsi_task
*);
154 int cxgb3i_conn_alloc_pdu(struct iscsi_task
*, u8
);
155 int cxgb3i_conn_init_pdu(struct iscsi_task
*, unsigned int, unsigned int);
156 int cxgb3i_conn_xmit_pdu(struct iscsi_task
*);
158 void cxgb3i_release_itt(struct iscsi_task
*task
, itt_t hdr_itt
);
159 int cxgb3i_reserve_itt(struct iscsi_task
*task
, itt_t
*hdr_itt
);