Merge branch 'docs-next' of git://git.lwn.net/linux-2.6
[sfrench/cifs-2.6.git] / drivers / scsi / cxgb3i / cxgb3i.h
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
13 #ifndef __CXGB3I_H__
14 #define __CXGB3I_H__
15
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>
24
25 /* from cxgb3 LLD */
26 #include "common.h"
27 #include "t3_cpl.h"
28 #include "t3cdev.h"
29 #include "cxgb3_ctl_defs.h"
30 #include "cxgb3_offload.h"
31 #include "firmware_exports.h"
32
33 #include "cxgb3i_offload.h"
34 #include "cxgb3i_ddp.h"
35
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)
41
42 struct cxgb3i_adapter;
43 struct cxgb3i_hba;
44 struct cxgb3i_endpoint;
45
46 /**
47  * struct cxgb3i_hba - cxgb3i iscsi structure (per port)
48  *
49  * @snic:       cxgb3i adapter containing this port
50  * @ndev:       pointer to netdev structure
51  * @shost:      pointer to scsi host structure
52  */
53 struct cxgb3i_hba {
54         struct cxgb3i_adapter *snic;
55         struct net_device *ndev;
56         struct Scsi_Host *shost;
57 };
58
59 /**
60  * struct cxgb3i_adapter - cxgb3i adapter structure (per pci)
61  *
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
71  */
72 struct cxgb3i_adapter {
73         struct list_head list_head;
74         spinlock_t lock;
75         struct t3cdev *tdev;
76         struct pci_dev *pdev;
77         unsigned char hba_cnt;
78         struct cxgb3i_hba *hba[MAX_NPORTS];
79
80         unsigned int tx_max_size;
81         unsigned int rx_max_size;
82
83         struct cxgb3i_tag_format tag_format;
84 };
85
86 /**
87  * struct cxgb3i_conn - cxgb3i iscsi connection
88  *
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
94  */
95 struct cxgb3i_conn {
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;
101 };
102
103 /**
104  * struct cxgb3i_endpoint - iscsi tcp endpoint
105  *
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
109  */
110 struct cxgb3i_endpoint {
111         struct s3_conn *c3cn;
112         struct cxgb3i_hba *hba;
113         struct cxgb3i_conn *cconn;
114 };
115
116 int cxgb3i_iscsi_init(void);
117 void cxgb3i_iscsi_cleanup(void);
118
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 *);
123
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 *);
128
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 *);
135
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);
138
139 #endif