[S390] Remove error checking from copy_oldmem_page()
[linux/fpc-iii.git] / drivers / scsi / bnx2i / bnx2i.h
blob0bd70e80efe46bee67fdd211ec00d2359db1f45b
1 /* bnx2i.h: Broadcom NetXtreme II iSCSI driver.
3 * Copyright (c) 2006 - 2011 Broadcom Corporation
4 * Copyright (c) 2007, 2008 Red Hat, Inc. All rights reserved.
5 * Copyright (c) 2007, 2008 Mike Christie
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation.
11 * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
12 * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
15 #ifndef _BNX2I_H_
16 #define _BNX2I_H_
18 #include <linux/module.h>
19 #include <linux/moduleparam.h>
21 #include <linux/errno.h>
22 #include <linux/pci.h>
23 #include <linux/spinlock.h>
24 #include <linux/interrupt.h>
25 #include <linux/delay.h>
26 #include <linux/sched.h>
27 #include <linux/in.h>
28 #include <linux/kfifo.h>
29 #include <linux/netdevice.h>
30 #include <linux/completion.h>
31 #include <linux/kthread.h>
32 #include <linux/cpu.h>
34 #include <scsi/scsi_cmnd.h>
35 #include <scsi/scsi_device.h>
36 #include <scsi/scsi_eh.h>
37 #include <scsi/scsi_host.h>
38 #include <scsi/scsi.h>
39 #include <scsi/iscsi_proto.h>
40 #include <scsi/libiscsi.h>
41 #include <scsi/scsi_transport_iscsi.h>
43 #include "../../net/ethernet/broadcom/cnic_if.h"
44 #include "57xx_iscsi_hsi.h"
45 #include "57xx_iscsi_constants.h"
47 #define BNX2_ISCSI_DRIVER_NAME "bnx2i"
49 #define BNX2I_MAX_ADAPTERS 8
51 #define ISCSI_MAX_CONNS_PER_HBA 128
52 #define ISCSI_MAX_SESS_PER_HBA ISCSI_MAX_CONNS_PER_HBA
53 #define ISCSI_MAX_CMDS_PER_SESS 128
55 /* Total active commands across all connections supported by devices */
56 #define ISCSI_MAX_CMDS_PER_HBA_5708 (28 * (ISCSI_MAX_CMDS_PER_SESS - 1))
57 #define ISCSI_MAX_CMDS_PER_HBA_5709 (128 * (ISCSI_MAX_CMDS_PER_SESS - 1))
58 #define ISCSI_MAX_CMDS_PER_HBA_57710 (256 * (ISCSI_MAX_CMDS_PER_SESS - 1))
60 #define ISCSI_MAX_BDS_PER_CMD 32
62 #define MAX_PAGES_PER_CTRL_STRUCT_POOL 8
63 #define BNX2I_RESERVED_SLOW_PATH_CMD_SLOTS 4
65 #define BNX2I_5771X_DBELL_PAGE_SIZE 128
67 /* 5706/08 hardware has limit on maximum buffer size per BD it can handle */
68 #define MAX_BD_LENGTH 65535
69 #define BD_SPLIT_SIZE 32768
71 /* min, max & default values for SQ/RQ/CQ size, configurable via' modparam */
72 #define BNX2I_SQ_WQES_MIN 16
73 #define BNX2I_570X_SQ_WQES_MAX 128
74 #define BNX2I_5770X_SQ_WQES_MAX 512
75 #define BNX2I_570X_SQ_WQES_DEFAULT 128
76 #define BNX2I_5770X_SQ_WQES_DEFAULT 128
78 #define BNX2I_570X_CQ_WQES_MAX 128
79 #define BNX2I_5770X_CQ_WQES_MAX 512
81 #define BNX2I_RQ_WQES_MIN 16
82 #define BNX2I_RQ_WQES_MAX 32
83 #define BNX2I_RQ_WQES_DEFAULT 16
85 /* CCELLs per conn */
86 #define BNX2I_CCELLS_MIN 16
87 #define BNX2I_CCELLS_MAX 96
88 #define BNX2I_CCELLS_DEFAULT 64
90 #define ITT_INVALID_SIGNATURE 0xFFFF
92 #define ISCSI_CMD_CLEANUP_TIMEOUT 100
94 #define BNX2I_CONN_CTX_BUF_SIZE 16384
96 #define BNX2I_SQ_WQE_SIZE 64
97 #define BNX2I_RQ_WQE_SIZE 256
98 #define BNX2I_CQE_SIZE 64
100 #define MB_KERNEL_CTX_SHIFT 8
101 #define MB_KERNEL_CTX_SIZE (1 << MB_KERNEL_CTX_SHIFT)
103 #define CTX_SHIFT 7
104 #define GET_CID_NUM(cid_addr) ((cid_addr) >> CTX_SHIFT)
106 #define CTX_OFFSET 0x10000
107 #define MAX_CID_CNT 0x4000
109 #define BNX2I_570X_PAGE_SIZE_DEFAULT 4096
111 /* 5709 context registers */
112 #define BNX2_MQ_CONFIG2 0x00003d00
113 #define BNX2_MQ_CONFIG2_CONT_SZ (0x7L<<4)
114 #define BNX2_MQ_CONFIG2_FIRST_L4L5 (0x1fL<<8)
116 /* 57710's BAR2 is mapped to doorbell registers */
117 #define BNX2X_DOORBELL_PCI_BAR 2
118 #define BNX2X_MAX_CQS 8
120 #define CNIC_ARM_CQE 1
121 #define CNIC_ARM_CQE_FP 2
122 #define CNIC_DISARM_CQE 0
124 #define REG_RD(__hba, offset) \
125 readl(__hba->regview + offset)
126 #define REG_WR(__hba, offset, val) \
127 writel(val, __hba->regview + offset)
131 * struct generic_pdu_resc - login pdu resource structure
133 * @req_buf: driver buffer used to stage payload associated with
134 * the login request
135 * @req_dma_addr: dma address for iscsi login request payload buffer
136 * @req_buf_size: actual login request payload length
137 * @req_wr_ptr: pointer into login request buffer when next data is
138 * to be written
139 * @resp_hdr: iscsi header where iscsi login response header is to
140 * be recreated
141 * @resp_buf: buffer to stage login response payload
142 * @resp_dma_addr: login response payload buffer dma address
143 * @resp_buf_size: login response paylod length
144 * @resp_wr_ptr: pointer into login response buffer when next data is
145 * to be written
146 * @req_bd_tbl: iscsi login request payload BD table
147 * @req_bd_dma: login request BD table dma address
148 * @resp_bd_tbl: iscsi login response payload BD table
149 * @resp_bd_dma: login request BD table dma address
151 * following structure defines buffer info for generic pdus such as iSCSI Login,
152 * Logout and NOP
154 struct generic_pdu_resc {
155 char *req_buf;
156 dma_addr_t req_dma_addr;
157 u32 req_buf_size;
158 char *req_wr_ptr;
159 struct iscsi_hdr resp_hdr;
160 char *resp_buf;
161 dma_addr_t resp_dma_addr;
162 u32 resp_buf_size;
163 char *resp_wr_ptr;
164 char *req_bd_tbl;
165 dma_addr_t req_bd_dma;
166 char *resp_bd_tbl;
167 dma_addr_t resp_bd_dma;
172 * struct bd_resc_page - tracks DMA'able memory allocated for BD tables
174 * @link: list head to link elements
175 * @max_ptrs: maximun pointers that can be stored in this page
176 * @num_valid: number of pointer valid in this page
177 * @page: base addess for page pointer array
179 * structure to track DMA'able memory allocated for command BD tables
181 struct bd_resc_page {
182 struct list_head link;
183 u32 max_ptrs;
184 u32 num_valid;
185 void *page[1];
190 * struct io_bdt - I/O buffer destricptor table
192 * @bd_tbl: BD table's virtual address
193 * @bd_tbl_dma: BD table's dma address
194 * @bd_valid: num valid BD entries
196 * IO BD table
198 struct io_bdt {
199 struct iscsi_bd *bd_tbl;
200 dma_addr_t bd_tbl_dma;
201 u16 bd_valid;
206 * bnx2i_cmd - iscsi command structure
208 * @hdr: iSCSI header
209 * @conn: iscsi_conn pointer
210 * @scsi_cmd: SCSI-ML task pointer corresponding to this iscsi cmd
211 * @sg: SG list
212 * @io_tbl: buffer descriptor (BD) table
213 * @bd_tbl_dma: buffer descriptor (BD) table's dma address
214 * @req: bnx2i specific command request struct
216 struct bnx2i_cmd {
217 struct iscsi_hdr hdr;
218 struct bnx2i_conn *conn;
219 struct scsi_cmnd *scsi_cmd;
220 struct scatterlist *sg;
221 struct io_bdt io_tbl;
222 dma_addr_t bd_tbl_dma;
223 struct bnx2i_cmd_request req;
228 * struct bnx2i_conn - iscsi connection structure
230 * @cls_conn: pointer to iscsi cls conn
231 * @hba: adapter structure pointer
232 * @iscsi_conn_cid: iscsi conn id
233 * @fw_cid: firmware iscsi context id
234 * @ep: endpoint structure pointer
235 * @gen_pdu: login/nopout/logout pdu resources
236 * @violation_notified: bit mask used to track iscsi error/warning messages
237 * already printed out
238 * @work_cnt: keeps track of the number of outstanding work
240 * iSCSI connection structure
242 struct bnx2i_conn {
243 struct iscsi_cls_conn *cls_conn;
244 struct bnx2i_hba *hba;
245 struct completion cmd_cleanup_cmpl;
247 u32 iscsi_conn_cid;
248 #define BNX2I_CID_RESERVED 0x5AFF
249 u32 fw_cid;
251 struct timer_list poll_timer;
253 * Queue Pair (QP) related structure elements.
255 struct bnx2i_endpoint *ep;
258 * Buffer for login negotiation process
260 struct generic_pdu_resc gen_pdu;
261 u64 violation_notified;
263 atomic_t work_cnt;
269 * struct iscsi_cid_queue - Per adapter iscsi cid queue
271 * @cid_que_base: queue base memory
272 * @cid_que: queue memory pointer
273 * @cid_q_prod_idx: produce index
274 * @cid_q_cons_idx: consumer index
275 * @cid_q_max_idx: max index. used to detect wrap around condition
276 * @cid_free_cnt: queue size
277 * @conn_cid_tbl: iscsi cid to conn structure mapping table
279 * Per adapter iSCSI CID Queue
281 struct iscsi_cid_queue {
282 void *cid_que_base;
283 u32 *cid_que;
284 u32 cid_q_prod_idx;
285 u32 cid_q_cons_idx;
286 u32 cid_q_max_idx;
287 u32 cid_free_cnt;
288 struct bnx2i_conn **conn_cid_tbl;
292 * struct bnx2i_hba - bnx2i adapter structure
294 * @link: list head to link elements
295 * @cnic: pointer to cnic device
296 * @pcidev: pointer to pci dev
297 * @netdev: pointer to netdev structure
298 * @regview: mapped PCI register space
299 * @age: age, incremented by every recovery
300 * @cnic_dev_type: cnic device type, 5706/5708/5709/57710
301 * @mail_queue_access: mailbox queue access mode, applicable to 5709 only
302 * @reg_with_cnic: indicates whether the device is register with CNIC
303 * @adapter_state: adapter state, UP, GOING_DOWN, LINK_DOWN
304 * @mtu_supported: Ethernet MTU supported
305 * @shost: scsi host pointer
306 * @max_sqes: SQ size
307 * @max_rqes: RQ size
308 * @max_cqes: CQ size
309 * @num_ccell: number of command cells per connection
310 * @ofld_conns_active: active connection list
311 * @eh_wait: wait queue for the endpoint to shutdown
312 * @max_active_conns: max offload connections supported by this device
313 * @cid_que: iscsi cid queue
314 * @ep_rdwr_lock: read / write lock to synchronize various ep lists
315 * @ep_ofld_list: connection list for pending offload completion
316 * @ep_active_list: connection list for active offload endpoints
317 * @ep_destroy_list: connection list for pending offload completion
318 * @mp_bd_tbl: BD table to be used with middle path requests
319 * @mp_bd_dma: DMA address of 'mp_bd_tbl' memory buffer
320 * @dummy_buffer: Dummy buffer to be used with zero length scsicmd reqs
321 * @dummy_buf_dma: DMA address of 'dummy_buffer' memory buffer
322 * @lock: lock to synchonize access to hba structure
323 * @hba_shutdown_tmo: Timeout value to shutdown each connection
324 * @conn_teardown_tmo: Timeout value to tear down each connection
325 * @conn_ctx_destroy_tmo: Timeout value to destroy context of each connection
326 * @pci_did: PCI device ID
327 * @pci_vid: PCI vendor ID
328 * @pci_sdid: PCI subsystem device ID
329 * @pci_svid: PCI subsystem vendor ID
330 * @pci_func: PCI function number in system pci tree
331 * @pci_devno: PCI device number in system pci tree
332 * @num_wqe_sent: statistic counter, total wqe's sent
333 * @num_cqe_rcvd: statistic counter, total cqe's received
334 * @num_intr_claimed: statistic counter, total interrupts claimed
335 * @link_changed_count: statistic counter, num of link change notifications
336 * received
337 * @ipaddr_changed_count: statistic counter, num times IP address changed while
338 * at least one connection is offloaded
339 * @num_sess_opened: statistic counter, total num sessions opened
340 * @num_conn_opened: statistic counter, total num conns opened on this hba
341 * @ctx_ccell_tasks: captures number of ccells and tasks supported by
342 * currently offloaded connection, used to decode
343 * context memory
345 * Adapter Data Structure
347 struct bnx2i_hba {
348 struct list_head link;
349 struct cnic_dev *cnic;
350 struct pci_dev *pcidev;
351 struct net_device *netdev;
352 void __iomem *regview;
354 u32 age;
355 unsigned long cnic_dev_type;
356 #define BNX2I_NX2_DEV_5706 0x0
357 #define BNX2I_NX2_DEV_5708 0x1
358 #define BNX2I_NX2_DEV_5709 0x2
359 #define BNX2I_NX2_DEV_57710 0x3
360 u32 mail_queue_access;
361 #define BNX2I_MQ_KERNEL_MODE 0x0
362 #define BNX2I_MQ_KERNEL_BYPASS_MODE 0x1
363 #define BNX2I_MQ_BIN_MODE 0x2
364 unsigned long reg_with_cnic;
365 #define BNX2I_CNIC_REGISTERED 1
367 unsigned long adapter_state;
368 #define ADAPTER_STATE_UP 0
369 #define ADAPTER_STATE_GOING_DOWN 1
370 #define ADAPTER_STATE_LINK_DOWN 2
371 #define ADAPTER_STATE_INIT_FAILED 31
372 unsigned int mtu_supported;
373 #define BNX2I_MAX_MTU_SUPPORTED 9000
375 struct Scsi_Host *shost;
377 u32 max_sqes;
378 u32 max_rqes;
379 u32 max_cqes;
380 u32 num_ccell;
382 int ofld_conns_active;
383 wait_queue_head_t eh_wait;
385 int max_active_conns;
386 struct iscsi_cid_queue cid_que;
388 rwlock_t ep_rdwr_lock;
389 struct list_head ep_ofld_list;
390 struct list_head ep_active_list;
391 struct list_head ep_destroy_list;
394 * BD table to be used with MP (Middle Path requests.
396 char *mp_bd_tbl;
397 dma_addr_t mp_bd_dma;
398 char *dummy_buffer;
399 dma_addr_t dummy_buf_dma;
401 spinlock_t lock; /* protects hba structure access */
402 struct mutex net_dev_lock;/* sync net device access */
404 int hba_shutdown_tmo;
405 int conn_teardown_tmo;
406 int conn_ctx_destroy_tmo;
408 * PCI related info.
410 u16 pci_did;
411 u16 pci_vid;
412 u16 pci_sdid;
413 u16 pci_svid;
414 u16 pci_func;
415 u16 pci_devno;
418 * Following are a bunch of statistics useful during development
419 * and later stage for score boarding.
421 u32 num_wqe_sent;
422 u32 num_cqe_rcvd;
423 u32 num_intr_claimed;
424 u32 link_changed_count;
425 u32 ipaddr_changed_count;
426 u32 num_sess_opened;
427 u32 num_conn_opened;
428 unsigned int ctx_ccell_tasks;
432 /*******************************************************************************
433 * QP [ SQ / RQ / CQ ] info.
434 ******************************************************************************/
437 * SQ/RQ/CQ generic structure definition
439 struct sqe {
440 u8 sqe_byte[BNX2I_SQ_WQE_SIZE];
443 struct rqe {
444 u8 rqe_byte[BNX2I_RQ_WQE_SIZE];
447 struct cqe {
448 u8 cqe_byte[BNX2I_CQE_SIZE];
452 enum {
453 #if defined(__LITTLE_ENDIAN)
454 CNIC_EVENT_COAL_INDEX = 0x0,
455 CNIC_SEND_DOORBELL = 0x4,
456 CNIC_EVENT_CQ_ARM = 0x7,
457 CNIC_RECV_DOORBELL = 0x8
458 #elif defined(__BIG_ENDIAN)
459 CNIC_EVENT_COAL_INDEX = 0x2,
460 CNIC_SEND_DOORBELL = 0x6,
461 CNIC_EVENT_CQ_ARM = 0x4,
462 CNIC_RECV_DOORBELL = 0xa
463 #endif
468 * CQ DB
470 struct bnx2x_iscsi_cq_pend_cmpl {
471 /* CQ producer, updated by Ustorm */
472 u16 ustrom_prod;
473 /* CQ pending completion counter */
474 u16 pend_cntr;
478 struct bnx2i_5771x_cq_db {
479 struct bnx2x_iscsi_cq_pend_cmpl qp_pend_cmpl[BNX2X_MAX_CQS];
480 /* CQ pending completion ITT array */
481 u16 itt[BNX2X_MAX_CQS];
482 /* Cstorm CQ sequence to notify array, updated by driver */;
483 u16 sqn[BNX2X_MAX_CQS];
484 u32 reserved[4] /* 16 byte allignment */;
488 struct bnx2i_5771x_sq_rq_db {
489 u16 prod_idx;
490 u8 reserved0[62]; /* Pad structure size to 64 bytes */
494 struct bnx2i_5771x_dbell_hdr {
495 u8 header;
496 /* 1 for rx doorbell, 0 for tx doorbell */
497 #define B577XX_DOORBELL_HDR_RX (0x1<<0)
498 #define B577XX_DOORBELL_HDR_RX_SHIFT 0
499 /* 0 for normal doorbell, 1 for advertise wnd doorbell */
500 #define B577XX_DOORBELL_HDR_DB_TYPE (0x1<<1)
501 #define B577XX_DOORBELL_HDR_DB_TYPE_SHIFT 1
502 /* rdma tx only: DPM transaction size specifier (64/128/256/512B) */
503 #define B577XX_DOORBELL_HDR_DPM_SIZE (0x3<<2)
504 #define B577XX_DOORBELL_HDR_DPM_SIZE_SHIFT 2
505 /* connection type */
506 #define B577XX_DOORBELL_HDR_CONN_TYPE (0xF<<4)
507 #define B577XX_DOORBELL_HDR_CONN_TYPE_SHIFT 4
510 struct bnx2i_5771x_dbell {
511 struct bnx2i_5771x_dbell_hdr dbell;
512 u8 pad[3];
517 * struct qp_info - QP (share queue region) atrributes structure
519 * @ctx_base: ioremapped pci register base to access doorbell register
520 * pertaining to this offloaded connection
521 * @sq_virt: virtual address of send queue (SQ) region
522 * @sq_phys: DMA address of SQ memory region
523 * @sq_mem_size: SQ size
524 * @sq_prod_qe: SQ producer entry pointer
525 * @sq_cons_qe: SQ consumer entry pointer
526 * @sq_first_qe: virtaul address of first entry in SQ
527 * @sq_last_qe: virtaul address of last entry in SQ
528 * @sq_prod_idx: SQ producer index
529 * @sq_cons_idx: SQ consumer index
530 * @sqe_left: number sq entry left
531 * @sq_pgtbl_virt: page table describing buffer consituting SQ region
532 * @sq_pgtbl_phys: dma address of 'sq_pgtbl_virt'
533 * @sq_pgtbl_size: SQ page table size
534 * @cq_virt: virtual address of completion queue (CQ) region
535 * @cq_phys: DMA address of RQ memory region
536 * @cq_mem_size: CQ size
537 * @cq_prod_qe: CQ producer entry pointer
538 * @cq_cons_qe: CQ consumer entry pointer
539 * @cq_first_qe: virtaul address of first entry in CQ
540 * @cq_last_qe: virtaul address of last entry in CQ
541 * @cq_prod_idx: CQ producer index
542 * @cq_cons_idx: CQ consumer index
543 * @cqe_left: number cq entry left
544 * @cqe_size: size of each CQ entry
545 * @cqe_exp_seq_sn: next expected CQE sequence number
546 * @cq_pgtbl_virt: page table describing buffer consituting CQ region
547 * @cq_pgtbl_phys: dma address of 'cq_pgtbl_virt'
548 * @cq_pgtbl_size: CQ page table size
549 * @rq_virt: virtual address of receive queue (RQ) region
550 * @rq_phys: DMA address of RQ memory region
551 * @rq_mem_size: RQ size
552 * @rq_prod_qe: RQ producer entry pointer
553 * @rq_cons_qe: RQ consumer entry pointer
554 * @rq_first_qe: virtaul address of first entry in RQ
555 * @rq_last_qe: virtaul address of last entry in RQ
556 * @rq_prod_idx: RQ producer index
557 * @rq_cons_idx: RQ consumer index
558 * @rqe_left: number rq entry left
559 * @rq_pgtbl_virt: page table describing buffer consituting RQ region
560 * @rq_pgtbl_phys: dma address of 'rq_pgtbl_virt'
561 * @rq_pgtbl_size: RQ page table size
563 * queue pair (QP) is a per connection shared data structure which is used
564 * to send work requests (SQ), receive completion notifications (CQ)
565 * and receive asynchoronous / scsi sense info (RQ). 'qp_info' structure
566 * below holds queue memory, consumer/producer indexes and page table
567 * information
569 struct qp_info {
570 void __iomem *ctx_base;
571 #define DPM_TRIGER_TYPE 0x40
573 #define BNX2I_570x_QUE_DB_SIZE 0
574 #define BNX2I_5771x_QUE_DB_SIZE 16
575 struct sqe *sq_virt;
576 dma_addr_t sq_phys;
577 u32 sq_mem_size;
579 struct sqe *sq_prod_qe;
580 struct sqe *sq_cons_qe;
581 struct sqe *sq_first_qe;
582 struct sqe *sq_last_qe;
583 u16 sq_prod_idx;
584 u16 sq_cons_idx;
585 u32 sqe_left;
587 void *sq_pgtbl_virt;
588 dma_addr_t sq_pgtbl_phys;
589 u32 sq_pgtbl_size; /* set to PAGE_SIZE for 5708 & 5709 */
591 struct cqe *cq_virt;
592 dma_addr_t cq_phys;
593 u32 cq_mem_size;
595 struct cqe *cq_prod_qe;
596 struct cqe *cq_cons_qe;
597 struct cqe *cq_first_qe;
598 struct cqe *cq_last_qe;
599 u16 cq_prod_idx;
600 u16 cq_cons_idx;
601 u32 cqe_left;
602 u32 cqe_size;
603 u32 cqe_exp_seq_sn;
605 void *cq_pgtbl_virt;
606 dma_addr_t cq_pgtbl_phys;
607 u32 cq_pgtbl_size; /* set to PAGE_SIZE for 5708 & 5709 */
609 struct rqe *rq_virt;
610 dma_addr_t rq_phys;
611 u32 rq_mem_size;
613 struct rqe *rq_prod_qe;
614 struct rqe *rq_cons_qe;
615 struct rqe *rq_first_qe;
616 struct rqe *rq_last_qe;
617 u16 rq_prod_idx;
618 u16 rq_cons_idx;
619 u32 rqe_left;
621 void *rq_pgtbl_virt;
622 dma_addr_t rq_pgtbl_phys;
623 u32 rq_pgtbl_size; /* set to PAGE_SIZE for 5708 & 5709 */
629 * CID handles
631 struct ep_handles {
632 u32 fw_cid;
633 u32 drv_iscsi_cid;
634 u16 pg_cid;
635 u16 rsvd;
639 enum {
640 EP_STATE_IDLE = 0x0,
641 EP_STATE_PG_OFLD_START = 0x1,
642 EP_STATE_PG_OFLD_COMPL = 0x2,
643 EP_STATE_OFLD_START = 0x4,
644 EP_STATE_OFLD_COMPL = 0x8,
645 EP_STATE_CONNECT_START = 0x10,
646 EP_STATE_CONNECT_COMPL = 0x20,
647 EP_STATE_ULP_UPDATE_START = 0x40,
648 EP_STATE_ULP_UPDATE_COMPL = 0x80,
649 EP_STATE_DISCONN_START = 0x100,
650 EP_STATE_DISCONN_COMPL = 0x200,
651 EP_STATE_CLEANUP_START = 0x400,
652 EP_STATE_CLEANUP_CMPL = 0x800,
653 EP_STATE_TCP_FIN_RCVD = 0x1000,
654 EP_STATE_TCP_RST_RCVD = 0x2000,
655 EP_STATE_LOGOUT_SENT = 0x4000,
656 EP_STATE_LOGOUT_RESP_RCVD = 0x8000,
657 EP_STATE_PG_OFLD_FAILED = 0x1000000,
658 EP_STATE_ULP_UPDATE_FAILED = 0x2000000,
659 EP_STATE_CLEANUP_FAILED = 0x4000000,
660 EP_STATE_OFLD_FAILED = 0x8000000,
661 EP_STATE_CONNECT_FAILED = 0x10000000,
662 EP_STATE_DISCONN_TIMEDOUT = 0x20000000,
663 EP_STATE_OFLD_FAILED_CID_BUSY = 0x80000000,
667 * struct bnx2i_endpoint - representation of tcp connection in NX2 world
669 * @link: list head to link elements
670 * @hba: adapter to which this connection belongs
671 * @conn: iscsi connection this EP is linked to
672 * @cls_ep: associated iSCSI endpoint pointer
673 * @cm_sk: cnic sock struct
674 * @hba_age: age to detect if 'iscsid' issues ep_disconnect()
675 * after HBA reset is completed by bnx2i/cnic/bnx2
676 * modules
677 * @state: tracks offload connection state machine
678 * @timestamp: tracks the start time when the ep begins to connect
679 * @num_active_cmds: tracks the number of outstanding commands for this ep
680 * @ec_shift: the amount of shift as part of the event coal calc
681 * @qp: QP information
682 * @ids: contains chip allocated *context id* & driver assigned
683 * *iscsi cid*
684 * @ofld_timer: offload timer to detect timeout
685 * @ofld_wait: wait queue
687 * Endpoint Structure - equivalent of tcp socket structure
689 struct bnx2i_endpoint {
690 struct list_head link;
691 struct bnx2i_hba *hba;
692 struct bnx2i_conn *conn;
693 struct iscsi_endpoint *cls_ep;
694 struct cnic_sock *cm_sk;
695 u32 hba_age;
696 u32 state;
697 unsigned long timestamp;
698 atomic_t num_active_cmds;
699 u32 ec_shift;
701 struct qp_info qp;
702 struct ep_handles ids;
703 #define ep_iscsi_cid ids.drv_iscsi_cid
704 #define ep_cid ids.fw_cid
705 #define ep_pg_cid ids.pg_cid
706 struct timer_list ofld_timer;
707 wait_queue_head_t ofld_wait;
711 struct bnx2i_work {
712 struct list_head list;
713 struct iscsi_session *session;
714 struct bnx2i_conn *bnx2i_conn;
715 struct cqe cqe;
718 struct bnx2i_percpu_s {
719 struct task_struct *iothread;
720 struct list_head work_list;
721 spinlock_t p_work_lock;
725 /* Global variables */
726 extern unsigned int error_mask1, error_mask2;
727 extern u64 iscsi_error_mask;
728 extern unsigned int en_tcp_dack;
729 extern unsigned int event_coal_div;
730 extern unsigned int event_coal_min;
732 extern struct scsi_transport_template *bnx2i_scsi_xport_template;
733 extern struct iscsi_transport bnx2i_iscsi_transport;
734 extern struct cnic_ulp_ops bnx2i_cnic_cb;
736 extern unsigned int sq_size;
737 extern unsigned int rq_size;
739 extern struct device_attribute *bnx2i_dev_attributes[];
744 * Function Prototypes
746 extern void bnx2i_identify_device(struct bnx2i_hba *hba);
748 extern void bnx2i_ulp_init(struct cnic_dev *dev);
749 extern void bnx2i_ulp_exit(struct cnic_dev *dev);
750 extern void bnx2i_start(void *handle);
751 extern void bnx2i_stop(void *handle);
752 extern struct bnx2i_hba *get_adapter_list_head(void);
754 struct bnx2i_conn *bnx2i_get_conn_from_id(struct bnx2i_hba *hba,
755 u16 iscsi_cid);
757 int bnx2i_alloc_ep_pool(void);
758 void bnx2i_release_ep_pool(void);
759 struct bnx2i_endpoint *bnx2i_ep_ofld_list_next(struct bnx2i_hba *hba);
760 struct bnx2i_endpoint *bnx2i_ep_destroy_list_next(struct bnx2i_hba *hba);
762 struct bnx2i_hba *bnx2i_find_hba_for_cnic(struct cnic_dev *cnic);
764 struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic);
765 void bnx2i_free_hba(struct bnx2i_hba *hba);
767 void bnx2i_get_rq_buf(struct bnx2i_conn *conn, char *ptr, int len);
768 void bnx2i_put_rq_buf(struct bnx2i_conn *conn, int count);
770 void bnx2i_iscsi_unmap_sg_list(struct bnx2i_cmd *cmd);
772 void bnx2i_drop_session(struct iscsi_cls_session *session);
774 extern int bnx2i_send_fw_iscsi_init_msg(struct bnx2i_hba *hba);
775 extern int bnx2i_send_iscsi_login(struct bnx2i_conn *conn,
776 struct iscsi_task *mtask);
777 extern int bnx2i_send_iscsi_tmf(struct bnx2i_conn *conn,
778 struct iscsi_task *mtask);
779 extern int bnx2i_send_iscsi_text(struct bnx2i_conn *conn,
780 struct iscsi_task *mtask);
781 extern int bnx2i_send_iscsi_scsicmd(struct bnx2i_conn *conn,
782 struct bnx2i_cmd *cmnd);
783 extern int bnx2i_send_iscsi_nopout(struct bnx2i_conn *conn,
784 struct iscsi_task *mtask,
785 char *datap, int data_len, int unsol);
786 extern int bnx2i_send_iscsi_logout(struct bnx2i_conn *conn,
787 struct iscsi_task *mtask);
788 extern void bnx2i_send_cmd_cleanup_req(struct bnx2i_hba *hba,
789 struct bnx2i_cmd *cmd);
790 extern int bnx2i_send_conn_ofld_req(struct bnx2i_hba *hba,
791 struct bnx2i_endpoint *ep);
792 extern void bnx2i_update_iscsi_conn(struct iscsi_conn *conn);
793 extern int bnx2i_send_conn_destroy(struct bnx2i_hba *hba,
794 struct bnx2i_endpoint *ep);
796 extern int bnx2i_alloc_qp_resc(struct bnx2i_hba *hba,
797 struct bnx2i_endpoint *ep);
798 extern void bnx2i_free_qp_resc(struct bnx2i_hba *hba,
799 struct bnx2i_endpoint *ep);
800 extern void bnx2i_ep_ofld_timer(unsigned long data);
801 extern struct bnx2i_endpoint *bnx2i_find_ep_in_ofld_list(
802 struct bnx2i_hba *hba, u32 iscsi_cid);
803 extern struct bnx2i_endpoint *bnx2i_find_ep_in_destroy_list(
804 struct bnx2i_hba *hba, u32 iscsi_cid);
806 extern int bnx2i_map_ep_dbell_regs(struct bnx2i_endpoint *ep);
807 extern int bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action);
809 extern int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep);
811 /* Debug related function prototypes */
812 extern void bnx2i_print_pend_cmd_queue(struct bnx2i_conn *conn);
813 extern void bnx2i_print_active_cmd_queue(struct bnx2i_conn *conn);
814 extern void bnx2i_print_xmit_pdu_queue(struct bnx2i_conn *conn);
815 extern void bnx2i_print_recv_state(struct bnx2i_conn *conn);
817 extern int bnx2i_percpu_io_thread(void *arg);
818 extern int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session,
819 struct bnx2i_conn *bnx2i_conn,
820 struct cqe *cqe);
821 #endif