xref: /openbmc/linux/drivers/scsi/cxgbi/libcxgbi.h (revision 0c874100)
1 /*
2  * libcxgbi.h: Chelsio common library for T3/T4 iSCSI driver.
3  *
4  * Copyright (c) 2010-2015 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  * Written by: Rakesh Ranjan (rranjan@chelsio.com)
12  */
13 
14 #ifndef	__LIBCXGBI_H__
15 #define	__LIBCXGBI_H__
16 
17 #include <linux/kernel.h>
18 #include <linux/errno.h>
19 #include <linux/types.h>
20 #include <linux/debugfs.h>
21 #include <linux/list.h>
22 #include <linux/netdevice.h>
23 #include <linux/if_vlan.h>
24 #include <linux/scatterlist.h>
25 #include <linux/skbuff.h>
26 #include <linux/vmalloc.h>
27 #include <linux/version.h>
28 #include <scsi/scsi_device.h>
29 #include <scsi/libiscsi_tcp.h>
30 
31 #include <libcxgb_ppm.h>
32 
33 enum cxgbi_dbg_flag {
34 	CXGBI_DBG_ISCSI,
35 	CXGBI_DBG_DDP,
36 	CXGBI_DBG_TOE,
37 	CXGBI_DBG_SOCK,
38 
39 	CXGBI_DBG_PDU_TX,
40 	CXGBI_DBG_PDU_RX,
41 	CXGBI_DBG_DEV,
42 };
43 
44 #define log_debug(level, fmt, ...)	\
45 	do {	\
46 		if (dbg_level & (level)) \
47 			pr_info(fmt, ##__VA_ARGS__); \
48 	} while (0)
49 
50 #define pr_info_ipaddr(fmt_trail,					\
51 			addr1, addr2, args_trail...)			\
52 do {									\
53 	if (!((1 << CXGBI_DBG_SOCK) & dbg_level))			\
54 		break;							\
55 	pr_info("%pISpc - %pISpc, " fmt_trail,				\
56 		addr1, addr2, args_trail);				\
57 } while (0)
58 
59 /* max. connections per adapter */
60 #define CXGBI_MAX_CONN		16384
61 
62 /* always allocate rooms for AHS */
63 #define SKB_TX_ISCSI_PDU_HEADER_MAX	\
64 	(sizeof(struct iscsi_hdr) + ISCSI_MAX_AHS_SIZE)
65 
66 #define	ISCSI_PDU_NONPAYLOAD_LEN	312 /* bhs(48) + ahs(256) + digest(8)*/
67 
68 /*
69  * align pdu size to multiple of 512 for better performance
70  */
71 #define cxgbi_align_pdu_size(n) do { n = (n) & (~511); } while (0)
72 
73 #define ULP2_MODE_ISCSI		2
74 
75 #define ULP2_MAX_PKT_SIZE	16224
76 #define ULP2_MAX_PDU_PAYLOAD	\
77 	(ULP2_MAX_PKT_SIZE - ISCSI_PDU_NONPAYLOAD_LEN)
78 
79 /*
80  * For iscsi connections HW may inserts digest bytes into the pdu. Those digest
81  * bytes are not sent by the host but are part of the TCP payload and therefore
82  * consume TCP sequence space.
83  */
84 static const unsigned int ulp2_extra_len[] = { 0, 4, 4, 8 };
85 static inline unsigned int cxgbi_ulp_extra_len(int submode)
86 {
87 	return ulp2_extra_len[submode & 3];
88 }
89 
90 #define CPL_RX_DDP_STATUS_DDP_SHIFT	16 /* ddp'able */
91 #define CPL_RX_DDP_STATUS_PAD_SHIFT	19 /* pad error */
92 #define CPL_RX_DDP_STATUS_HCRC_SHIFT	20 /* hcrc error */
93 #define CPL_RX_DDP_STATUS_DCRC_SHIFT	21 /* dcrc error */
94 
95 /*
96  * sge_opaque_hdr -
97  * Opaque version of structure the SGE stores at skb->head of TX_DATA packets
98  * and for which we must reserve space.
99  */
100 struct sge_opaque_hdr {
101 	void *dev;
102 	dma_addr_t addr[MAX_SKB_FRAGS + 1];
103 };
104 
105 struct cxgbi_sock {
106 	struct cxgbi_device *cdev;
107 
108 	int tid;
109 	int atid;
110 	unsigned long flags;
111 	unsigned int mtu;
112 	unsigned short rss_qid;
113 	unsigned short txq_idx;
114 	unsigned short advmss;
115 	unsigned int tx_chan;
116 	unsigned int rx_chan;
117 	unsigned int mss_idx;
118 	unsigned int smac_idx;
119 	unsigned char port_id;
120 	int wr_max_cred;
121 	int wr_cred;
122 	int wr_una_cred;
123 #ifdef CONFIG_CHELSIO_T4_DCB
124 	u8 dcb_priority;
125 #endif
126 	unsigned char hcrc_len;
127 	unsigned char dcrc_len;
128 
129 	void *l2t;
130 	struct sk_buff *wr_pending_head;
131 	struct sk_buff *wr_pending_tail;
132 	struct sk_buff *cpl_close;
133 	struct sk_buff *cpl_abort_req;
134 	struct sk_buff *cpl_abort_rpl;
135 	struct sk_buff *skb_ulp_lhdr;
136 	spinlock_t lock;
137 	struct kref refcnt;
138 	unsigned int state;
139 	unsigned int csk_family;
140 	union {
141 		struct sockaddr_in saddr;
142 		struct sockaddr_in6 saddr6;
143 	};
144 	union {
145 		struct sockaddr_in daddr;
146 		struct sockaddr_in6 daddr6;
147 	};
148 	struct dst_entry *dst;
149 	struct sk_buff_head receive_queue;
150 	struct sk_buff_head write_queue;
151 	struct timer_list retry_timer;
152 	int err;
153 	rwlock_t callback_lock;
154 	void *user_data;
155 
156 	u32 rcv_nxt;
157 	u32 copied_seq;
158 	u32 rcv_wup;
159 	u32 snd_nxt;
160 	u32 snd_una;
161 	u32 write_seq;
162 	u32 snd_win;
163 	u32 rcv_win;
164 };
165 
166 /*
167  * connection states
168  */
169 enum cxgbi_sock_states{
170 	CTP_CLOSED,
171 	CTP_CONNECTING,
172 	CTP_ACTIVE_OPEN,
173 	CTP_ESTABLISHED,
174 	CTP_ACTIVE_CLOSE,
175 	CTP_PASSIVE_CLOSE,
176 	CTP_CLOSE_WAIT_1,
177 	CTP_CLOSE_WAIT_2,
178 	CTP_ABORTING,
179 };
180 
181 /*
182  * Connection flags -- many to track some close related events.
183  */
184 enum cxgbi_sock_flags {
185 	CTPF_ABORT_RPL_RCVD,	/*received one ABORT_RPL_RSS message */
186 	CTPF_ABORT_REQ_RCVD,	/*received one ABORT_REQ_RSS message */
187 	CTPF_ABORT_RPL_PENDING,	/* expecting an abort reply */
188 	CTPF_TX_DATA_SENT,	/* already sent a TX_DATA WR */
189 	CTPF_ACTIVE_CLOSE_NEEDED,/* need to be closed */
190 	CTPF_HAS_ATID,		/* reserved atid */
191 	CTPF_HAS_TID,		/* reserved hw tid */
192 	CTPF_OFFLOAD_DOWN,	/* offload function off */
193 	CTPF_LOGOUT_RSP_RCVD,   /* received logout response */
194 };
195 
196 struct cxgbi_skb_rx_cb {
197 	__u32 ddigest;
198 	__u32 pdulen;
199 };
200 
201 struct cxgbi_skb_tx_cb {
202 	void *handle;
203 	void *arp_err_handler;
204 	struct sk_buff *wr_next;
205 };
206 
207 enum cxgbi_skcb_flags {
208 	SKCBF_TX_NEED_HDR,	/* packet needs a header */
209 	SKCBF_TX_MEM_WRITE,     /* memory write */
210 	SKCBF_TX_FLAG_COMPL,    /* wr completion flag */
211 	SKCBF_RX_COALESCED,	/* received whole pdu */
212 	SKCBF_RX_HDR,		/* received pdu header */
213 	SKCBF_RX_DATA,		/* received pdu payload */
214 	SKCBF_RX_STATUS,	/* received ddp status */
215 	SKCBF_RX_ISCSI_COMPL,   /* received iscsi completion */
216 	SKCBF_RX_DATA_DDPD,	/* pdu payload ddp'd */
217 	SKCBF_RX_HCRC_ERR,	/* header digest error */
218 	SKCBF_RX_DCRC_ERR,	/* data digest error */
219 	SKCBF_RX_PAD_ERR,	/* padding byte error */
220 };
221 
222 struct cxgbi_skb_cb {
223 	union {
224 		struct cxgbi_skb_rx_cb rx;
225 		struct cxgbi_skb_tx_cb tx;
226 	};
227 	unsigned char ulp_mode;
228 	unsigned long flags;
229 	unsigned int seq;
230 };
231 
232 #define CXGBI_SKB_CB(skb)	((struct cxgbi_skb_cb *)&((skb)->cb[0]))
233 #define cxgbi_skcb_flags(skb)		(CXGBI_SKB_CB(skb)->flags)
234 #define cxgbi_skcb_ulp_mode(skb)	(CXGBI_SKB_CB(skb)->ulp_mode)
235 #define cxgbi_skcb_tcp_seq(skb)		(CXGBI_SKB_CB(skb)->seq)
236 #define cxgbi_skcb_rx_ddigest(skb)	(CXGBI_SKB_CB(skb)->rx.ddigest)
237 #define cxgbi_skcb_rx_pdulen(skb)	(CXGBI_SKB_CB(skb)->rx.pdulen)
238 #define cxgbi_skcb_tx_wr_next(skb)	(CXGBI_SKB_CB(skb)->tx.wr_next)
239 
240 static inline void cxgbi_skcb_set_flag(struct sk_buff *skb,
241 					enum cxgbi_skcb_flags flag)
242 {
243 	__set_bit(flag, &(cxgbi_skcb_flags(skb)));
244 }
245 
246 static inline void cxgbi_skcb_clear_flag(struct sk_buff *skb,
247 					enum cxgbi_skcb_flags flag)
248 {
249 	__clear_bit(flag, &(cxgbi_skcb_flags(skb)));
250 }
251 
252 static inline int cxgbi_skcb_test_flag(const struct sk_buff *skb,
253 				       enum cxgbi_skcb_flags flag)
254 {
255 	return test_bit(flag, &(cxgbi_skcb_flags(skb)));
256 }
257 
258 static inline void cxgbi_sock_set_flag(struct cxgbi_sock *csk,
259 					enum cxgbi_sock_flags flag)
260 {
261 	__set_bit(flag, &csk->flags);
262 	log_debug(1 << CXGBI_DBG_SOCK,
263 		"csk 0x%p,%u,0x%lx, bit %d.\n",
264 		csk, csk->state, csk->flags, flag);
265 }
266 
267 static inline void cxgbi_sock_clear_flag(struct cxgbi_sock *csk,
268 					enum cxgbi_sock_flags flag)
269 {
270 	__clear_bit(flag, &csk->flags);
271 	log_debug(1 << CXGBI_DBG_SOCK,
272 		"csk 0x%p,%u,0x%lx, bit %d.\n",
273 		csk, csk->state, csk->flags, flag);
274 }
275 
276 static inline int cxgbi_sock_flag(struct cxgbi_sock *csk,
277 				enum cxgbi_sock_flags flag)
278 {
279 	if (csk == NULL)
280 		return 0;
281 	return test_bit(flag, &csk->flags);
282 }
283 
284 static inline void cxgbi_sock_set_state(struct cxgbi_sock *csk, int state)
285 {
286 	log_debug(1 << CXGBI_DBG_SOCK,
287 		"csk 0x%p,%u,0x%lx, state -> %u.\n",
288 		csk, csk->state, csk->flags, state);
289 	csk->state = state;
290 }
291 
292 static inline void cxgbi_sock_free(struct kref *kref)
293 {
294 	struct cxgbi_sock *csk = container_of(kref,
295 						struct cxgbi_sock,
296 						refcnt);
297 	if (csk) {
298 		log_debug(1 << CXGBI_DBG_SOCK,
299 			"free csk 0x%p, state %u, flags 0x%lx\n",
300 			csk, csk->state, csk->flags);
301 		kfree(csk);
302 	}
303 }
304 
305 static inline void __cxgbi_sock_put(const char *fn, struct cxgbi_sock *csk)
306 {
307 	log_debug(1 << CXGBI_DBG_SOCK,
308 		"%s, put csk 0x%p, ref %u-1.\n",
309 		fn, csk, kref_read(&csk->refcnt));
310 	kref_put(&csk->refcnt, cxgbi_sock_free);
311 }
312 #define cxgbi_sock_put(csk)	__cxgbi_sock_put(__func__, csk)
313 
314 static inline void __cxgbi_sock_get(const char *fn, struct cxgbi_sock *csk)
315 {
316 	log_debug(1 << CXGBI_DBG_SOCK,
317 		"%s, get csk 0x%p, ref %u+1.\n",
318 		fn, csk, kref_read(&csk->refcnt));
319 	kref_get(&csk->refcnt);
320 }
321 #define cxgbi_sock_get(csk)	__cxgbi_sock_get(__func__, csk)
322 
323 static inline int cxgbi_sock_is_closing(struct cxgbi_sock *csk)
324 {
325 	return csk->state >= CTP_ACTIVE_CLOSE;
326 }
327 
328 static inline int cxgbi_sock_is_established(struct cxgbi_sock *csk)
329 {
330 	return csk->state == CTP_ESTABLISHED;
331 }
332 
333 static inline void cxgbi_sock_purge_write_queue(struct cxgbi_sock *csk)
334 {
335 	struct sk_buff *skb;
336 
337 	while ((skb = __skb_dequeue(&csk->write_queue)))
338 		__kfree_skb(skb);
339 }
340 
341 static inline unsigned int cxgbi_sock_compute_wscale(unsigned int win)
342 {
343 	unsigned int wscale = 0;
344 
345 	while (wscale < 14 && (65535 << wscale) < win)
346 		wscale++;
347 	return wscale;
348 }
349 
350 static inline struct sk_buff *alloc_wr(int wrlen, int dlen, gfp_t gfp)
351 {
352 	struct sk_buff *skb = alloc_skb(wrlen + dlen, gfp);
353 
354 	if (skb) {
355 		__skb_put(skb, wrlen);
356 		memset(skb->head, 0, wrlen + dlen);
357 	} else
358 		pr_info("alloc cpl wr skb %u+%u, OOM.\n", wrlen, dlen);
359 	return skb;
360 }
361 
362 
363 /*
364  * The number of WRs needed for an skb depends on the number of fragments
365  * in the skb and whether it has any payload in its main body.  This maps the
366  * length of the gather list represented by an skb into the # of necessary WRs.
367  * The extra two fragments are for iscsi bhs and payload padding.
368  */
369 #define SKB_WR_LIST_SIZE	 (MAX_SKB_FRAGS + 2)
370 
371 static inline void cxgbi_sock_reset_wr_list(struct cxgbi_sock *csk)
372 {
373 	csk->wr_pending_head = csk->wr_pending_tail = NULL;
374 }
375 
376 static inline void cxgbi_sock_enqueue_wr(struct cxgbi_sock *csk,
377 					  struct sk_buff *skb)
378 {
379 	cxgbi_skcb_tx_wr_next(skb) = NULL;
380 	/*
381 	 * We want to take an extra reference since both us and the driver
382 	 * need to free the packet before it's really freed.
383 	 */
384 	skb_get(skb);
385 
386 	if (!csk->wr_pending_head)
387 		csk->wr_pending_head = skb;
388 	else
389 		cxgbi_skcb_tx_wr_next(csk->wr_pending_tail) = skb;
390 	csk->wr_pending_tail = skb;
391 }
392 
393 static inline int cxgbi_sock_count_pending_wrs(const struct cxgbi_sock *csk)
394 {
395 	int n = 0;
396 	const struct sk_buff *skb = csk->wr_pending_head;
397 
398 	while (skb) {
399 		n += skb->csum;
400 		skb = cxgbi_skcb_tx_wr_next(skb);
401 	}
402 	return n;
403 }
404 
405 static inline struct sk_buff *cxgbi_sock_peek_wr(const struct cxgbi_sock *csk)
406 {
407 	return csk->wr_pending_head;
408 }
409 
410 static inline struct sk_buff *cxgbi_sock_dequeue_wr(struct cxgbi_sock *csk)
411 {
412 	struct sk_buff *skb = csk->wr_pending_head;
413 
414 	if (likely(skb)) {
415 		csk->wr_pending_head = cxgbi_skcb_tx_wr_next(skb);
416 		cxgbi_skcb_tx_wr_next(skb) = NULL;
417 	}
418 	return skb;
419 }
420 
421 void cxgbi_sock_check_wr_invariants(const struct cxgbi_sock *);
422 void cxgbi_sock_purge_wr_queue(struct cxgbi_sock *);
423 void cxgbi_sock_skb_entail(struct cxgbi_sock *, struct sk_buff *);
424 void cxgbi_sock_fail_act_open(struct cxgbi_sock *, int);
425 void cxgbi_sock_act_open_req_arp_failure(void *, struct sk_buff *);
426 void cxgbi_sock_closed(struct cxgbi_sock *);
427 void cxgbi_sock_established(struct cxgbi_sock *, unsigned int, unsigned int);
428 void cxgbi_sock_rcv_abort_rpl(struct cxgbi_sock *);
429 void cxgbi_sock_rcv_peer_close(struct cxgbi_sock *);
430 void cxgbi_sock_rcv_close_conn_rpl(struct cxgbi_sock *, u32);
431 void cxgbi_sock_rcv_wr_ack(struct cxgbi_sock *, unsigned int, unsigned int,
432 				int);
433 unsigned int cxgbi_sock_select_mss(struct cxgbi_sock *, unsigned int);
434 void cxgbi_sock_free_cpl_skbs(struct cxgbi_sock *);
435 
436 struct cxgbi_hba {
437 	struct net_device *ndev;
438 	struct net_device *vdev;	/* vlan dev */
439 	struct Scsi_Host *shost;
440 	struct cxgbi_device *cdev;
441 	__be32 ipv4addr;
442 	unsigned char port_id;
443 };
444 
445 struct cxgbi_ports_map {
446 	unsigned int max_connect;
447 	unsigned int used;
448 	unsigned short sport_base;
449 	spinlock_t lock;
450 	unsigned int next;
451 	struct cxgbi_sock **port_csk;
452 };
453 
454 #define CXGBI_FLAG_DEV_T3		0x1
455 #define CXGBI_FLAG_DEV_T4		0x2
456 #define CXGBI_FLAG_ADAPTER_RESET	0x4
457 #define CXGBI_FLAG_IPV4_SET		0x10
458 #define CXGBI_FLAG_USE_PPOD_OFLDQ       0x40
459 #define CXGBI_FLAG_DDP_OFF		0x100
460 
461 struct cxgbi_device {
462 	struct list_head list_head;
463 	struct list_head rcu_node;
464 	unsigned int flags;
465 	struct net_device **ports;
466 	void *lldev;
467 	struct cxgbi_hba **hbas;
468 	const unsigned short *mtus;
469 	unsigned char nmtus;
470 	unsigned char nports;
471 	struct pci_dev *pdev;
472 	struct dentry *debugfs_root;
473 	struct iscsi_transport *itp;
474 	struct module *owner;
475 
476 	unsigned int pfvf;
477 	unsigned int rx_credit_thres;
478 	unsigned int skb_tx_rsvd;
479 	unsigned int skb_rx_extra;	/* for msg coalesced mode */
480 	unsigned int tx_max_size;
481 	unsigned int rx_max_size;
482 	unsigned int rxq_idx_cntr;
483 	struct cxgbi_ports_map pmap;
484 
485 	void (*dev_ddp_cleanup)(struct cxgbi_device *);
486 	struct cxgbi_ppm* (*cdev2ppm)(struct cxgbi_device *);
487 	int (*csk_ddp_set_map)(struct cxgbi_ppm *, struct cxgbi_sock *,
488 			       struct cxgbi_task_tag_info *);
489 	void (*csk_ddp_clear_map)(struct cxgbi_device *cdev,
490 				  struct cxgbi_ppm *,
491 				  struct cxgbi_task_tag_info *);
492 	int (*csk_ddp_setup_digest)(struct cxgbi_sock *,
493 				unsigned int, int, int, int);
494 	int (*csk_ddp_setup_pgidx)(struct cxgbi_sock *,
495 				unsigned int, int, bool);
496 
497 	void (*csk_release_offload_resources)(struct cxgbi_sock *);
498 	int (*csk_rx_pdu_ready)(struct cxgbi_sock *, struct sk_buff *);
499 	u32 (*csk_send_rx_credits)(struct cxgbi_sock *, u32);
500 	int (*csk_push_tx_frames)(struct cxgbi_sock *, int);
501 	void (*csk_send_abort_req)(struct cxgbi_sock *);
502 	void (*csk_send_close_req)(struct cxgbi_sock *);
503 	int (*csk_alloc_cpls)(struct cxgbi_sock *);
504 	int (*csk_init_act_open)(struct cxgbi_sock *);
505 
506 	void *dd_data;
507 };
508 #define cxgbi_cdev_priv(cdev)	((cdev)->dd_data)
509 
510 struct cxgbi_conn {
511 	struct cxgbi_endpoint *cep;
512 	struct iscsi_conn *iconn;
513 	struct cxgbi_hba *chba;
514 	u32 task_idx_bits;
515 	unsigned int ddp_full;
516 	unsigned int ddp_tag_full;
517 };
518 
519 struct cxgbi_endpoint {
520 	struct cxgbi_conn *cconn;
521 	struct cxgbi_hba *chba;
522 	struct cxgbi_sock *csk;
523 };
524 
525 #define MAX_PDU_FRAGS	((ULP2_MAX_PDU_PAYLOAD + 512 - 1) / 512)
526 struct cxgbi_task_data {
527 	unsigned short nr_frags;
528 	struct page_frag frags[MAX_PDU_FRAGS];
529 	struct sk_buff *skb;
530 	unsigned int dlen;
531 	unsigned int offset;
532 	unsigned int count;
533 	unsigned int sgoffset;
534 	struct cxgbi_task_tag_info ttinfo;
535 };
536 #define iscsi_task_cxgbi_data(task) \
537 	((task)->dd_data + sizeof(struct iscsi_tcp_task))
538 
539 static inline void *cxgbi_alloc_big_mem(unsigned int size,
540 					gfp_t gfp)
541 {
542 	void *p = kzalloc(size, gfp | __GFP_NOWARN);
543 
544 	if (!p)
545 		p = vzalloc(size);
546 
547 	return p;
548 }
549 
550 static inline void cxgbi_free_big_mem(void *addr)
551 {
552 	kvfree(addr);
553 }
554 
555 static inline void cxgbi_set_iscsi_ipv4(struct cxgbi_hba *chba, __be32 ipaddr)
556 {
557 	if (chba->cdev->flags & CXGBI_FLAG_IPV4_SET)
558 		chba->ipv4addr = ipaddr;
559 	else
560 		pr_info("set iscsi ipv4 NOT supported, using %s ipv4.\n",
561 			chba->ndev->name);
562 }
563 
564 struct cxgbi_device *cxgbi_device_register(unsigned int, unsigned int);
565 void cxgbi_device_unregister(struct cxgbi_device *);
566 void cxgbi_device_unregister_all(unsigned int flag);
567 struct cxgbi_device *cxgbi_device_find_by_lldev(void *);
568 struct cxgbi_device *cxgbi_device_find_by_netdev(struct net_device *, int *);
569 struct cxgbi_device *cxgbi_device_find_by_netdev_rcu(struct net_device *,
570 						     int *);
571 int cxgbi_hbas_add(struct cxgbi_device *, u64, unsigned int,
572 			struct scsi_host_template *,
573 			struct scsi_transport_template *);
574 void cxgbi_hbas_remove(struct cxgbi_device *);
575 
576 int cxgbi_device_portmap_create(struct cxgbi_device *cdev, unsigned int base,
577 			unsigned int max_conn);
578 void cxgbi_device_portmap_cleanup(struct cxgbi_device *cdev);
579 
580 void cxgbi_conn_tx_open(struct cxgbi_sock *);
581 void cxgbi_conn_pdu_ready(struct cxgbi_sock *);
582 int cxgbi_conn_alloc_pdu(struct iscsi_task *, u8);
583 int cxgbi_conn_init_pdu(struct iscsi_task *, unsigned int , unsigned int);
584 int cxgbi_conn_xmit_pdu(struct iscsi_task *);
585 
586 void cxgbi_cleanup_task(struct iscsi_task *task);
587 
588 umode_t cxgbi_attr_is_visible(int param_type, int param);
589 void cxgbi_get_conn_stats(struct iscsi_cls_conn *, struct iscsi_stats *);
590 int cxgbi_set_conn_param(struct iscsi_cls_conn *,
591 			enum iscsi_param, char *, int);
592 int cxgbi_get_ep_param(struct iscsi_endpoint *ep, enum iscsi_param, char *);
593 struct iscsi_cls_conn *cxgbi_create_conn(struct iscsi_cls_session *, u32);
594 int cxgbi_bind_conn(struct iscsi_cls_session *,
595 			struct iscsi_cls_conn *, u64, int);
596 void cxgbi_destroy_session(struct iscsi_cls_session *);
597 struct iscsi_cls_session *cxgbi_create_session(struct iscsi_endpoint *,
598 			u16, u16, u32);
599 int cxgbi_set_host_param(struct Scsi_Host *,
600 			enum iscsi_host_param, char *, int);
601 int cxgbi_get_host_param(struct Scsi_Host *, enum iscsi_host_param, char *);
602 struct iscsi_endpoint *cxgbi_ep_connect(struct Scsi_Host *,
603 			struct sockaddr *, int);
604 int cxgbi_ep_poll(struct iscsi_endpoint *, int);
605 void cxgbi_ep_disconnect(struct iscsi_endpoint *);
606 
607 int cxgbi_iscsi_init(struct iscsi_transport *,
608 			struct scsi_transport_template **);
609 void cxgbi_iscsi_cleanup(struct iscsi_transport *,
610 			struct scsi_transport_template **);
611 void cxgbi_parse_pdu_itt(struct iscsi_conn *, itt_t, int *, int *);
612 int cxgbi_ddp_init(struct cxgbi_device *, unsigned int, unsigned int,
613 			unsigned int, unsigned int);
614 int cxgbi_ddp_cleanup(struct cxgbi_device *);
615 void cxgbi_ddp_page_size_factor(int *);
616 void cxgbi_ddp_set_one_ppod(struct cxgbi_pagepod *,
617 			    struct cxgbi_task_tag_info *,
618 			    struct scatterlist **sg_pp, unsigned int *sg_off);
619 void cxgbi_ddp_ppm_setup(void **ppm_pp, struct cxgbi_device *,
620 			 struct cxgbi_tag_format *, unsigned int ppmax,
621 			 unsigned int llimit, unsigned int start,
622 			 unsigned int rsvd_factor);
623 #endif	/*__LIBCXGBI_H__*/
624