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 <scsi/libiscsi_tcp.h>
29 #include "cxgb3_ctl_defs.h"
30 #include "cxgb3_offload.h"
31 #include "firmware_exports.h"
33 #include "cxgb3i_offload.h"
34 #include "cxgb3i_ddp.h"
36 #define CXGB3I_SCSI_QDEPTH_DFLT 128
37 #define CXGB3I_MAX_TARGET CXGB3I_MAX_CONN
38 #define CXGB3I_MAX_LUN 512
39 #define ISCSI_PDU_NONPAYLOAD_MAX \
40 (sizeof(struct iscsi_hdr) + ISCSI_MAX_AHS_SIZE + 2*ISCSI_DIGEST_SIZE)
42 struct cxgb3i_adapter;
44 struct cxgb3i_endpoint;
47 * struct cxgb3i_hba - cxgb3i iscsi structure (per port)
49 * @snic: cxgb3i adapter containing this port
50 * @ndev: pointer to netdev structure
51 * @shost: pointer to scsi host structure
54 struct cxgb3i_adapter *snic;
55 struct net_device *ndev;
56 struct Scsi_Host *shost;
60 * struct cxgb3i_adapter - cxgb3i adapter structure (per pci)
62 * @listhead: list head to link elements
63 * @lock: lock for this structure
64 * @tdev: pointer to t3cdev used by cxgb3 driver
65 * @pdev: pointer to pci dev
66 * @hba_cnt: # of hbas (the same as # of ports)
67 * @hba: all the hbas on this adapter
68 * @tx_max_size: max. tx packet size supported
69 * @rx_max_size: max. rx packet size supported
70 * @tag_format: ddp tag format settings
72 struct cxgb3i_adapter {
73 struct list_head list_head;
77 unsigned char hba_cnt;
78 struct cxgb3i_hba *hba[MAX_NPORTS];
80 unsigned int tx_max_size;
81 unsigned int rx_max_size;
83 struct cxgb3i_tag_format tag_format;
87 * struct cxgb3i_conn - cxgb3i iscsi connection
89 * @listhead: list head to link elements
90 * @cep: pointer to iscsi_endpoint structure
91 * @conn: pointer to iscsi_conn structure
92 * @hba: pointer to the hba this conn. is going through
93 * @task_idx_bits: # of bits needed for session->cmds_max
96 struct list_head list_head;
97 struct cxgb3i_endpoint *cep;
98 struct iscsi_conn *conn;
99 struct cxgb3i_hba *hba;
100 unsigned int task_idx_bits;
104 * struct cxgb3i_endpoint - iscsi tcp endpoint
106 * @c3cn: the h/w tcp connection representation
107 * @hba: pointer to the hba this conn. is going through
108 * @cconn: pointer to the associated cxgb3i iscsi connection
110 struct cxgb3i_endpoint {
111 struct s3_conn *c3cn;
112 struct cxgb3i_hba *hba;
113 struct cxgb3i_conn *cconn;
116 int cxgb3i_iscsi_init(void);
117 void cxgb3i_iscsi_cleanup(void);
119 struct cxgb3i_adapter *cxgb3i_adapter_add(struct t3cdev *);
120 void cxgb3i_adapter_remove(struct t3cdev *);
121 int cxgb3i_adapter_ulp_init(struct cxgb3i_adapter *);
122 void cxgb3i_adapter_ulp_cleanup(struct cxgb3i_adapter *);
124 struct cxgb3i_hba *cxgb3i_hba_find_by_netdev(struct net_device *);
125 struct cxgb3i_hba *cxgb3i_hba_host_add(struct cxgb3i_adapter *,
126 struct net_device *);
127 void cxgb3i_hba_host_remove(struct cxgb3i_hba *);
129 int cxgb3i_pdu_init(void);
130 void cxgb3i_pdu_cleanup(void);
131 void cxgb3i_conn_cleanup_task(struct iscsi_task *);
132 int cxgb3i_conn_alloc_pdu(struct iscsi_task *, u8);
133 int cxgb3i_conn_init_pdu(struct iscsi_task *, unsigned int, unsigned int);
134 int cxgb3i_conn_xmit_pdu(struct iscsi_task *);
136 void cxgb3i_release_itt(struct iscsi_task *task, itt_t hdr_itt);
137 int cxgb3i_reserve_itt(struct iscsi_task *task, itt_t *hdr_itt);