872 lines · c
1/* bnx2i.h: QLogic NetXtreme II iSCSI driver.2 *3 * Copyright (c) 2006 - 2013 Broadcom Corporation4 * Copyright (c) 2007, 2008 Red Hat, Inc. All rights reserved.5 * Copyright (c) 2007, 2008 Mike Christie6 * Copyright (c) 2014, QLogic Corporation7 *8 * This program is free software; you can redistribute it and/or modify9 * it under the terms of the GNU General Public License as published by10 * the Free Software Foundation.11 *12 * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)13 * Previously Maintained by: Eddie Wai (eddie.wai@broadcom.com)14 * Maintained by: QLogic-Storage-Upstream@qlogic.com15 */16 17#ifndef _BNX2I_H_18#define _BNX2I_H_19 20#include <linux/module.h>21#include <linux/moduleparam.h>22 23#include <linux/errno.h>24#include <linux/pci.h>25#include <linux/spinlock.h>26#include <linux/interrupt.h>27#include <linux/delay.h>28#include <linux/sched/signal.h>29#include <linux/in.h>30#include <linux/kfifo.h>31#include <linux/netdevice.h>32#include <linux/completion.h>33#include <linux/kthread.h>34#include <linux/cpu.h>35 36#include <scsi/scsi_cmnd.h>37#include <scsi/scsi_device.h>38#include <scsi/scsi_eh.h>39#include <scsi/scsi_host.h>40#include <scsi/scsi.h>41#include <scsi/iscsi_proto.h>42#include <scsi/libiscsi.h>43#include <scsi/scsi_transport_iscsi.h>44 45#include "../../net/ethernet/broadcom/cnic_if.h"46#include "57xx_iscsi_hsi.h"47#include "57xx_iscsi_constants.h"48 49#include "../../net/ethernet/broadcom/bnx2x/bnx2x_mfw_req.h"50 51#define BNX2_ISCSI_DRIVER_NAME "bnx2i"52 53#define BNX2I_MAX_ADAPTERS 854 55#define ISCSI_MAX_CONNS_PER_HBA 12856#define ISCSI_MAX_SESS_PER_HBA ISCSI_MAX_CONNS_PER_HBA57#define ISCSI_MAX_CMDS_PER_SESS 12858 59/* Total active commands across all connections supported by devices */60#define ISCSI_MAX_CMDS_PER_HBA_5708 (28 * (ISCSI_MAX_CMDS_PER_SESS - 1))61#define ISCSI_MAX_CMDS_PER_HBA_5709 (128 * (ISCSI_MAX_CMDS_PER_SESS - 1))62#define ISCSI_MAX_CMDS_PER_HBA_57710 (256 * (ISCSI_MAX_CMDS_PER_SESS - 1))63 64#define ISCSI_MAX_BDS_PER_CMD 3265 66#define MAX_PAGES_PER_CTRL_STRUCT_POOL 867#define BNX2I_RESERVED_SLOW_PATH_CMD_SLOTS 468 69#define BNX2X_DB_SHIFT 370 71/* 5706/08 hardware has limit on maximum buffer size per BD it can handle */72#define MAX_BD_LENGTH 6553573#define BD_SPLIT_SIZE 3276874 75/* min, max & default values for SQ/RQ/CQ size, configurable via' modparam */76#define BNX2I_SQ_WQES_MIN 1677#define BNX2I_570X_SQ_WQES_MAX 12878#define BNX2I_5770X_SQ_WQES_MAX 51279#define BNX2I_570X_SQ_WQES_DEFAULT 12880#define BNX2I_5770X_SQ_WQES_DEFAULT 12881 82#define BNX2I_570X_CQ_WQES_MAX 12883#define BNX2I_5770X_CQ_WQES_MAX 51284 85#define BNX2I_RQ_WQES_MIN 1686#define BNX2I_RQ_WQES_MAX 3287#define BNX2I_RQ_WQES_DEFAULT 1688 89/* CCELLs per conn */90#define BNX2I_CCELLS_MIN 1691#define BNX2I_CCELLS_MAX 9692#define BNX2I_CCELLS_DEFAULT 6493 94#define ITT_INVALID_SIGNATURE 0xFFFF95 96#define ISCSI_CMD_CLEANUP_TIMEOUT 10097 98#define BNX2I_CONN_CTX_BUF_SIZE 1638499 100#define BNX2I_SQ_WQE_SIZE 64101#define BNX2I_RQ_WQE_SIZE 256102#define BNX2I_CQE_SIZE 64103 104#define MB_KERNEL_CTX_SHIFT 8105#define MB_KERNEL_CTX_SIZE (1 << MB_KERNEL_CTX_SHIFT)106 107#define CTX_SHIFT 7108#define GET_CID_NUM(cid_addr) ((cid_addr) >> CTX_SHIFT)109 110#define CTX_OFFSET 0x10000111#define MAX_CID_CNT 0x4000112 113#define BNX2I_570X_PAGE_SIZE_DEFAULT 4096114 115/* 5709 context registers */116#define BNX2_MQ_CONFIG2 0x00003d00117#define BNX2_MQ_CONFIG2_CONT_SZ (0x7L<<4)118#define BNX2_MQ_CONFIG2_FIRST_L4L5 (0x1fL<<8)119 120/* 57710's BAR2 is mapped to doorbell registers */121#define BNX2X_DOORBELL_PCI_BAR 2122#define BNX2X_MAX_CQS 8123 124#define CNIC_ARM_CQE 1125#define CNIC_ARM_CQE_FP 2126#define CNIC_DISARM_CQE 0127 128#define REG_RD(__hba, offset) \129 readl(__hba->regview + offset)130#define REG_WR(__hba, offset, val) \131 writel(val, __hba->regview + offset)132 133#ifdef CONFIG_32BIT134#define GET_STATS_64(__hba, dst, field) \135 do { \136 spin_lock_bh(&__hba->stat_lock); \137 dst->field##_lo = __hba->stats.field##_lo; \138 dst->field##_hi = __hba->stats.field##_hi; \139 spin_unlock_bh(&__hba->stat_lock); \140 } while (0)141 142#define ADD_STATS_64(__hba, field, len) \143 do { \144 if (spin_trylock(&__hba->stat_lock)) { \145 if (__hba->stats.field##_lo + len < \146 __hba->stats.field##_lo) \147 __hba->stats.field##_hi++; \148 __hba->stats.field##_lo += len; \149 spin_unlock(&__hba->stat_lock); \150 } \151 } while (0)152 153#else154#define GET_STATS_64(__hba, dst, field) \155 do { \156 u64 val, *out; \157 \158 val = __hba->bnx2i_stats.field; \159 out = (u64 *)&__hba->stats.field##_lo; \160 *out = cpu_to_le64(val); \161 out = (u64 *)&dst->field##_lo; \162 *out = cpu_to_le64(val); \163 } while (0)164 165#define ADD_STATS_64(__hba, field, len) \166 do { \167 __hba->bnx2i_stats.field += len; \168 } while (0)169#endif170 171/**172 * struct generic_pdu_resc - login pdu resource structure173 *174 * @req_buf: driver buffer used to stage payload associated with175 * the login request176 * @req_dma_addr: dma address for iscsi login request payload buffer177 * @req_buf_size: actual login request payload length178 * @req_wr_ptr: pointer into login request buffer when next data is179 * to be written180 * @resp_hdr: iscsi header where iscsi login response header is to181 * be recreated182 * @resp_buf: buffer to stage login response payload183 * @resp_dma_addr: login response payload buffer dma address184 * @resp_buf_size: login response paylod length185 * @resp_wr_ptr: pointer into login response buffer when next data is186 * to be written187 * @req_bd_tbl: iscsi login request payload BD table188 * @req_bd_dma: login request BD table dma address189 * @resp_bd_tbl: iscsi login response payload BD table190 * @resp_bd_dma: login request BD table dma address191 *192 * following structure defines buffer info for generic pdus such as iSCSI Login,193 * Logout and NOP194 */195struct generic_pdu_resc {196 char *req_buf;197 dma_addr_t req_dma_addr;198 u32 req_buf_size;199 char *req_wr_ptr;200 struct iscsi_hdr resp_hdr;201 char *resp_buf;202 dma_addr_t resp_dma_addr;203 u32 resp_buf_size;204 char *resp_wr_ptr;205 char *req_bd_tbl;206 dma_addr_t req_bd_dma;207 char *resp_bd_tbl;208 dma_addr_t resp_bd_dma;209};210 211 212/**213 * struct bd_resc_page - tracks DMA'able memory allocated for BD tables214 *215 * @link: list head to link elements216 * @max_ptrs: maximun pointers that can be stored in this page217 * @num_valid: number of pointer valid in this page218 * @page: base addess for page pointer array219 *220 * structure to track DMA'able memory allocated for command BD tables221 */222struct bd_resc_page {223 struct list_head link;224 u32 max_ptrs;225 u32 num_valid;226 void *page[1];227};228 229 230/**231 * struct io_bdt - I/O buffer destricptor table232 *233 * @bd_tbl: BD table's virtual address234 * @bd_tbl_dma: BD table's dma address235 * @bd_valid: num valid BD entries236 *237 * IO BD table238 */239struct io_bdt {240 struct iscsi_bd *bd_tbl;241 dma_addr_t bd_tbl_dma;242 u16 bd_valid;243};244 245 246/**247 * bnx2i_cmd - iscsi command structure248 *249 * @hdr: iSCSI header250 * @conn: iscsi_conn pointer251 * @scsi_cmd: SCSI-ML task pointer corresponding to this iscsi cmd252 * @sg: SG list253 * @io_tbl: buffer descriptor (BD) table254 * @bd_tbl_dma: buffer descriptor (BD) table's dma address255 * @req: bnx2i specific command request struct256 */257struct bnx2i_cmd {258 struct iscsi_hdr hdr;259 struct bnx2i_conn *conn;260 struct scsi_cmnd *scsi_cmd;261 struct scatterlist *sg;262 struct io_bdt io_tbl;263 dma_addr_t bd_tbl_dma;264 struct bnx2i_cmd_request req;265};266 267 268/**269 * struct bnx2i_conn - iscsi connection structure270 *271 * @cls_conn: pointer to iscsi cls conn272 * @hba: adapter structure pointer273 * @iscsi_conn_cid: iscsi conn id274 * @fw_cid: firmware iscsi context id275 * @ep: endpoint structure pointer276 * @gen_pdu: login/nopout/logout pdu resources277 * @violation_notified: bit mask used to track iscsi error/warning messages278 * already printed out279 * @work_cnt: keeps track of the number of outstanding work280 *281 * iSCSI connection structure282 */283struct bnx2i_conn {284 struct iscsi_cls_conn *cls_conn;285 struct bnx2i_hba *hba;286 struct completion cmd_cleanup_cmpl;287 288 u32 iscsi_conn_cid;289#define BNX2I_CID_RESERVED 0x5AFF290 u32 fw_cid;291 292 struct timer_list poll_timer;293 /*294 * Queue Pair (QP) related structure elements.295 */296 struct bnx2i_endpoint *ep;297 298 /*299 * Buffer for login negotiation process300 */301 struct generic_pdu_resc gen_pdu;302 u64 violation_notified;303 304 atomic_t work_cnt;305};306 307 308 309/**310 * struct iscsi_cid_queue - Per adapter iscsi cid queue311 *312 * @cid_que_base: queue base memory313 * @cid_que: queue memory pointer314 * @cid_q_prod_idx: produce index315 * @cid_q_cons_idx: consumer index316 * @cid_q_max_idx: max index. used to detect wrap around condition317 * @cid_free_cnt: queue size318 * @conn_cid_tbl: iscsi cid to conn structure mapping table319 *320 * Per adapter iSCSI CID Queue321 */322struct iscsi_cid_queue {323 void *cid_que_base;324 u32 *cid_que;325 u32 cid_q_prod_idx;326 u32 cid_q_cons_idx;327 u32 cid_q_max_idx;328 u32 cid_free_cnt;329 struct bnx2i_conn **conn_cid_tbl;330};331 332 333struct bnx2i_stats_info {334 u64 rx_pdus;335 u64 rx_bytes;336 u64 tx_pdus;337 u64 tx_bytes;338};339 340 341/**342 * struct bnx2i_hba - bnx2i adapter structure343 *344 * @link: list head to link elements345 * @cnic: pointer to cnic device346 * @pcidev: pointer to pci dev347 * @netdev: pointer to netdev structure348 * @regview: mapped PCI register space349 * @age: age, incremented by every recovery350 * @cnic_dev_type: cnic device type, 5706/5708/5709/57710351 * @mail_queue_access: mailbox queue access mode, applicable to 5709 only352 * @reg_with_cnic: indicates whether the device is register with CNIC353 * @adapter_state: adapter state, UP, GOING_DOWN, LINK_DOWN354 * @mtu_supported: Ethernet MTU supported355 * @shost: scsi host pointer356 * @max_sqes: SQ size357 * @max_rqes: RQ size358 * @max_cqes: CQ size359 * @num_ccell: number of command cells per connection360 * @ofld_conns_active: active connection list361 * @eh_wait: wait queue for the endpoint to shutdown362 * @max_active_conns: max offload connections supported by this device363 * @cid_que: iscsi cid queue364 * @ep_rdwr_lock: read / write lock to synchronize various ep lists365 * @ep_ofld_list: connection list for pending offload completion366 * @ep_active_list: connection list for active offload endpoints367 * @ep_destroy_list: connection list for pending offload completion368 * @mp_bd_tbl: BD table to be used with middle path requests369 * @mp_bd_dma: DMA address of 'mp_bd_tbl' memory buffer370 * @dummy_buffer: Dummy buffer to be used with zero length scsicmd reqs371 * @dummy_buf_dma: DMA address of 'dummy_buffer' memory buffer372 * @lock: lock to synchonize access to hba structure373 * @hba_shutdown_tmo: Timeout value to shutdown each connection374 * @conn_teardown_tmo: Timeout value to tear down each connection375 * @conn_ctx_destroy_tmo: Timeout value to destroy context of each connection376 * @pci_did: PCI device ID377 * @pci_vid: PCI vendor ID378 * @pci_sdid: PCI subsystem device ID379 * @pci_svid: PCI subsystem vendor ID380 * @pci_func: PCI function number in system pci tree381 * @pci_devno: PCI device number in system pci tree382 * @num_wqe_sent: statistic counter, total wqe's sent383 * @num_cqe_rcvd: statistic counter, total cqe's received384 * @num_intr_claimed: statistic counter, total interrupts claimed385 * @link_changed_count: statistic counter, num of link change notifications386 * received387 * @ipaddr_changed_count: statistic counter, num times IP address changed while388 * at least one connection is offloaded389 * @num_sess_opened: statistic counter, total num sessions opened390 * @num_conn_opened: statistic counter, total num conns opened on this hba391 * @ctx_ccell_tasks: captures number of ccells and tasks supported by392 * currently offloaded connection, used to decode393 * context memory394 * @stat_lock: spin lock used by the statistic collector (32 bit)395 * @stats: local iSCSI statistic collection place holder396 *397 * Adapter Data Structure398 */399struct bnx2i_hba {400 struct list_head link;401 struct cnic_dev *cnic;402 struct pci_dev *pcidev;403 struct net_device *netdev;404 void __iomem *regview;405 resource_size_t reg_base;406 407 u32 age;408 unsigned long cnic_dev_type;409 #define BNX2I_NX2_DEV_5706 0x0410 #define BNX2I_NX2_DEV_5708 0x1411 #define BNX2I_NX2_DEV_5709 0x2412 #define BNX2I_NX2_DEV_57710 0x3413 u32 mail_queue_access;414 #define BNX2I_MQ_KERNEL_MODE 0x0415 #define BNX2I_MQ_KERNEL_BYPASS_MODE 0x1416 #define BNX2I_MQ_BIN_MODE 0x2417 unsigned long reg_with_cnic;418 #define BNX2I_CNIC_REGISTERED 1419 420 unsigned long adapter_state;421 #define ADAPTER_STATE_UP 0422 #define ADAPTER_STATE_GOING_DOWN 1423 #define ADAPTER_STATE_LINK_DOWN 2424 #define ADAPTER_STATE_INIT_FAILED 31425 unsigned int mtu_supported;426 #define BNX2I_MAX_MTU_SUPPORTED 9000427 428 struct Scsi_Host *shost;429 430 u32 max_sqes;431 u32 max_rqes;432 u32 max_cqes;433 u32 num_ccell;434 435 int ofld_conns_active;436 wait_queue_head_t eh_wait;437 438 int max_active_conns;439 struct iscsi_cid_queue cid_que;440 441 rwlock_t ep_rdwr_lock;442 struct list_head ep_ofld_list;443 struct list_head ep_active_list;444 struct list_head ep_destroy_list;445 446 /*447 * BD table to be used with MP (Middle Path requests.448 */449 char *mp_bd_tbl;450 dma_addr_t mp_bd_dma;451 char *dummy_buffer;452 dma_addr_t dummy_buf_dma;453 454 spinlock_t lock; /* protects hba structure access */455 struct mutex net_dev_lock;/* sync net device access */456 457 int hba_shutdown_tmo;458 int conn_teardown_tmo;459 int conn_ctx_destroy_tmo;460 /*461 * PCI related info.462 */463 u16 pci_did;464 u16 pci_vid;465 u16 pci_sdid;466 u16 pci_svid;467 u16 pci_func;468 u16 pci_devno;469 470 /*471 * Following are a bunch of statistics useful during development472 * and later stage for score boarding.473 */474 u32 num_wqe_sent;475 u32 num_cqe_rcvd;476 u32 num_intr_claimed;477 u32 link_changed_count;478 u32 ipaddr_changed_count;479 u32 num_sess_opened;480 u32 num_conn_opened;481 unsigned int ctx_ccell_tasks;482 483#ifdef CONFIG_32BIT484 spinlock_t stat_lock;485#endif486 struct bnx2i_stats_info bnx2i_stats;487 struct iscsi_stats_info stats;488};489 490 491/*******************************************************************************492 * QP [ SQ / RQ / CQ ] info.493 ******************************************************************************/494 495/*496 * SQ/RQ/CQ generic structure definition497 */498struct sqe {499 u8 sqe_byte[BNX2I_SQ_WQE_SIZE];500};501 502struct rqe {503 u8 rqe_byte[BNX2I_RQ_WQE_SIZE];504};505 506struct cqe {507 u8 cqe_byte[BNX2I_CQE_SIZE];508};509 510 511enum {512#if defined(__LITTLE_ENDIAN)513 CNIC_EVENT_COAL_INDEX = 0x0,514 CNIC_SEND_DOORBELL = 0x4,515 CNIC_EVENT_CQ_ARM = 0x7,516 CNIC_RECV_DOORBELL = 0x8517#elif defined(__BIG_ENDIAN)518 CNIC_EVENT_COAL_INDEX = 0x2,519 CNIC_SEND_DOORBELL = 0x6,520 CNIC_EVENT_CQ_ARM = 0x4,521 CNIC_RECV_DOORBELL = 0xa522#endif523};524 525 526/*527 * CQ DB528 */529struct bnx2x_iscsi_cq_pend_cmpl {530 /* CQ producer, updated by Ustorm */531 u16 ustrom_prod;532 /* CQ pending completion counter */533 u16 pend_cntr;534};535 536 537struct bnx2i_5771x_cq_db {538 struct bnx2x_iscsi_cq_pend_cmpl qp_pend_cmpl[BNX2X_MAX_CQS];539 /* CQ pending completion ITT array */540 u16 itt[BNX2X_MAX_CQS];541 /* Cstorm CQ sequence to notify array, updated by driver */;542 u16 sqn[BNX2X_MAX_CQS];543 u32 reserved[4] /* 16 byte allignment */;544};545 546 547struct bnx2i_5771x_sq_rq_db {548 u16 prod_idx;549 u8 reserved0[62]; /* Pad structure size to 64 bytes */550};551 552 553struct bnx2i_5771x_dbell_hdr {554 u8 header;555 /* 1 for rx doorbell, 0 for tx doorbell */556#define B577XX_DOORBELL_HDR_RX (0x1<<0)557#define B577XX_DOORBELL_HDR_RX_SHIFT 0558 /* 0 for normal doorbell, 1 for advertise wnd doorbell */559#define B577XX_DOORBELL_HDR_DB_TYPE (0x1<<1)560#define B577XX_DOORBELL_HDR_DB_TYPE_SHIFT 1561 /* rdma tx only: DPM transaction size specifier (64/128/256/512B) */562#define B577XX_DOORBELL_HDR_DPM_SIZE (0x3<<2)563#define B577XX_DOORBELL_HDR_DPM_SIZE_SHIFT 2564 /* connection type */565#define B577XX_DOORBELL_HDR_CONN_TYPE (0xF<<4)566#define B577XX_DOORBELL_HDR_CONN_TYPE_SHIFT 4567};568 569struct bnx2i_5771x_dbell {570 struct bnx2i_5771x_dbell_hdr dbell;571 u8 pad[3];572 573};574 575/**576 * struct qp_info - QP (share queue region) atrributes structure577 *578 * @ctx_base: ioremapped pci register base to access doorbell register579 * pertaining to this offloaded connection580 * @sq_virt: virtual address of send queue (SQ) region581 * @sq_phys: DMA address of SQ memory region582 * @sq_mem_size: SQ size583 * @sq_prod_qe: SQ producer entry pointer584 * @sq_cons_qe: SQ consumer entry pointer585 * @sq_first_qe: virtual address of first entry in SQ586 * @sq_last_qe: virtual address of last entry in SQ587 * @sq_prod_idx: SQ producer index588 * @sq_cons_idx: SQ consumer index589 * @sqe_left: number sq entry left590 * @sq_pgtbl_virt: page table describing buffer consituting SQ region591 * @sq_pgtbl_phys: dma address of 'sq_pgtbl_virt'592 * @sq_pgtbl_size: SQ page table size593 * @cq_virt: virtual address of completion queue (CQ) region594 * @cq_phys: DMA address of RQ memory region595 * @cq_mem_size: CQ size596 * @cq_prod_qe: CQ producer entry pointer597 * @cq_cons_qe: CQ consumer entry pointer598 * @cq_first_qe: virtual address of first entry in CQ599 * @cq_last_qe: virtual address of last entry in CQ600 * @cq_prod_idx: CQ producer index601 * @cq_cons_idx: CQ consumer index602 * @cqe_left: number cq entry left603 * @cqe_size: size of each CQ entry604 * @cqe_exp_seq_sn: next expected CQE sequence number605 * @cq_pgtbl_virt: page table describing buffer consituting CQ region606 * @cq_pgtbl_phys: dma address of 'cq_pgtbl_virt'607 * @cq_pgtbl_size: CQ page table size608 * @rq_virt: virtual address of receive queue (RQ) region609 * @rq_phys: DMA address of RQ memory region610 * @rq_mem_size: RQ size611 * @rq_prod_qe: RQ producer entry pointer612 * @rq_cons_qe: RQ consumer entry pointer613 * @rq_first_qe: virtual address of first entry in RQ614 * @rq_last_qe: virtual address of last entry in RQ615 * @rq_prod_idx: RQ producer index616 * @rq_cons_idx: RQ consumer index617 * @rqe_left: number rq entry left618 * @rq_pgtbl_virt: page table describing buffer consituting RQ region619 * @rq_pgtbl_phys: dma address of 'rq_pgtbl_virt'620 * @rq_pgtbl_size: RQ page table size621 *622 * queue pair (QP) is a per connection shared data structure which is used623 * to send work requests (SQ), receive completion notifications (CQ)624 * and receive asynchoronous / scsi sense info (RQ). 'qp_info' structure625 * below holds queue memory, consumer/producer indexes and page table626 * information627 */628struct qp_info {629 void __iomem *ctx_base;630#define DPM_TRIGER_TYPE 0x40631 632#define BNX2I_570x_QUE_DB_SIZE 0633#define BNX2I_5771x_QUE_DB_SIZE 16634 struct sqe *sq_virt;635 dma_addr_t sq_phys;636 u32 sq_mem_size;637 638 struct sqe *sq_prod_qe;639 struct sqe *sq_cons_qe;640 struct sqe *sq_first_qe;641 struct sqe *sq_last_qe;642 u16 sq_prod_idx;643 u16 sq_cons_idx;644 u32 sqe_left;645 646 void *sq_pgtbl_virt;647 dma_addr_t sq_pgtbl_phys;648 u32 sq_pgtbl_size; /* set to PAGE_SIZE for 5708 & 5709 */649 650 struct cqe *cq_virt;651 dma_addr_t cq_phys;652 u32 cq_mem_size;653 654 struct cqe *cq_prod_qe;655 struct cqe *cq_cons_qe;656 struct cqe *cq_first_qe;657 struct cqe *cq_last_qe;658 u16 cq_prod_idx;659 u16 cq_cons_idx;660 u32 cqe_left;661 u32 cqe_size;662 u32 cqe_exp_seq_sn;663 664 void *cq_pgtbl_virt;665 dma_addr_t cq_pgtbl_phys;666 u32 cq_pgtbl_size; /* set to PAGE_SIZE for 5708 & 5709 */667 668 struct rqe *rq_virt;669 dma_addr_t rq_phys;670 u32 rq_mem_size;671 672 struct rqe *rq_prod_qe;673 struct rqe *rq_cons_qe;674 struct rqe *rq_first_qe;675 struct rqe *rq_last_qe;676 u16 rq_prod_idx;677 u16 rq_cons_idx;678 u32 rqe_left;679 680 void *rq_pgtbl_virt;681 dma_addr_t rq_pgtbl_phys;682 u32 rq_pgtbl_size; /* set to PAGE_SIZE for 5708 & 5709 */683};684 685 686 687/*688 * CID handles689 */690struct ep_handles {691 u32 fw_cid;692 u32 drv_iscsi_cid;693 u16 pg_cid;694 u16 rsvd;695};696 697 698enum {699 EP_STATE_IDLE = 0x0,700 EP_STATE_PG_OFLD_START = 0x1,701 EP_STATE_PG_OFLD_COMPL = 0x2,702 EP_STATE_OFLD_START = 0x4,703 EP_STATE_OFLD_COMPL = 0x8,704 EP_STATE_CONNECT_START = 0x10,705 EP_STATE_CONNECT_COMPL = 0x20,706 EP_STATE_ULP_UPDATE_START = 0x40,707 EP_STATE_ULP_UPDATE_COMPL = 0x80,708 EP_STATE_DISCONN_START = 0x100,709 EP_STATE_DISCONN_COMPL = 0x200,710 EP_STATE_CLEANUP_START = 0x400,711 EP_STATE_CLEANUP_CMPL = 0x800,712 EP_STATE_TCP_FIN_RCVD = 0x1000,713 EP_STATE_TCP_RST_RCVD = 0x2000,714 EP_STATE_LOGOUT_SENT = 0x4000,715 EP_STATE_LOGOUT_RESP_RCVD = 0x8000,716 EP_STATE_PG_OFLD_FAILED = 0x1000000,717 EP_STATE_ULP_UPDATE_FAILED = 0x2000000,718 EP_STATE_CLEANUP_FAILED = 0x4000000,719 EP_STATE_OFLD_FAILED = 0x8000000,720 EP_STATE_CONNECT_FAILED = 0x10000000,721 EP_STATE_DISCONN_TIMEDOUT = 0x20000000,722 EP_STATE_OFLD_FAILED_CID_BUSY = 0x80000000,723};724 725/**726 * struct bnx2i_endpoint - representation of tcp connection in NX2 world727 *728 * @link: list head to link elements729 * @hba: adapter to which this connection belongs730 * @conn: iscsi connection this EP is linked to731 * @cls_ep: associated iSCSI endpoint pointer732 * @cm_sk: cnic sock struct733 * @hba_age: age to detect if 'iscsid' issues ep_disconnect()734 * after HBA reset is completed by bnx2i/cnic/bnx2735 * modules736 * @state: tracks offload connection state machine737 * @timestamp: tracks the start time when the ep begins to connect738 * @num_active_cmds: tracks the number of outstanding commands for this ep739 * @ec_shift: the amount of shift as part of the event coal calc740 * @qp: QP information741 * @ids: contains chip allocated *context id* & driver assigned742 * *iscsi cid*743 * @ofld_timer: offload timer to detect timeout744 * @ofld_wait: wait queue745 *746 * Endpoint Structure - equivalent of tcp socket structure747 */748struct bnx2i_endpoint {749 struct list_head link;750 struct bnx2i_hba *hba;751 struct bnx2i_conn *conn;752 struct iscsi_endpoint *cls_ep;753 struct cnic_sock *cm_sk;754 u32 hba_age;755 u32 state;756 unsigned long timestamp;757 atomic_t num_active_cmds;758 u32 ec_shift;759 760 struct qp_info qp;761 struct ep_handles ids;762 #define ep_iscsi_cid ids.drv_iscsi_cid763 #define ep_cid ids.fw_cid764 #define ep_pg_cid ids.pg_cid765 struct timer_list ofld_timer;766 wait_queue_head_t ofld_wait;767};768 769 770struct bnx2i_work {771 struct list_head list;772 struct iscsi_session *session;773 struct bnx2i_conn *bnx2i_conn;774 struct cqe cqe;775};776 777struct bnx2i_percpu_s {778 struct task_struct *iothread;779 struct list_head work_list;780 spinlock_t p_work_lock;781};782 783 784/* Global variables */785extern unsigned int error_mask1, error_mask2;786extern u64 iscsi_error_mask;787extern unsigned int en_tcp_dack;788extern unsigned int event_coal_div;789extern unsigned int event_coal_min;790 791extern struct scsi_transport_template *bnx2i_scsi_xport_template;792extern struct iscsi_transport bnx2i_iscsi_transport;793extern struct cnic_ulp_ops bnx2i_cnic_cb;794 795extern unsigned int sq_size;796extern unsigned int rq_size;797 798extern const struct attribute_group *bnx2i_dev_groups[];799 800 801 802/*803 * Function Prototypes804 */805extern void bnx2i_identify_device(struct bnx2i_hba *hba, struct cnic_dev *dev);806 807extern void bnx2i_ulp_init(struct cnic_dev *dev);808extern void bnx2i_ulp_exit(struct cnic_dev *dev);809extern void bnx2i_start(void *handle);810extern void bnx2i_stop(void *handle);811extern int bnx2i_get_stats(void *handle);812 813extern struct bnx2i_hba *get_adapter_list_head(void);814 815struct bnx2i_conn *bnx2i_get_conn_from_id(struct bnx2i_hba *hba,816 u16 iscsi_cid);817 818struct bnx2i_hba *bnx2i_find_hba_for_cnic(struct cnic_dev *cnic);819 820struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic);821void bnx2i_free_hba(struct bnx2i_hba *hba);822 823void bnx2i_get_rq_buf(struct bnx2i_conn *conn, char *ptr, int len);824void bnx2i_put_rq_buf(struct bnx2i_conn *conn, int count);825 826void bnx2i_iscsi_unmap_sg_list(struct bnx2i_cmd *cmd);827 828void bnx2i_drop_session(struct iscsi_cls_session *session);829 830extern int bnx2i_send_fw_iscsi_init_msg(struct bnx2i_hba *hba);831extern int bnx2i_send_iscsi_login(struct bnx2i_conn *conn,832 struct iscsi_task *mtask);833extern int bnx2i_send_iscsi_tmf(struct bnx2i_conn *conn,834 struct iscsi_task *mtask);835extern int bnx2i_send_iscsi_text(struct bnx2i_conn *conn,836 struct iscsi_task *mtask);837extern int bnx2i_send_iscsi_scsicmd(struct bnx2i_conn *conn,838 struct bnx2i_cmd *cmnd);839extern int bnx2i_send_iscsi_nopout(struct bnx2i_conn *conn,840 struct iscsi_task *mtask,841 char *datap, int data_len, int unsol);842extern int bnx2i_send_iscsi_logout(struct bnx2i_conn *conn,843 struct iscsi_task *mtask);844extern void bnx2i_send_cmd_cleanup_req(struct bnx2i_hba *hba,845 struct bnx2i_cmd *cmd);846extern int bnx2i_send_conn_ofld_req(struct bnx2i_hba *hba,847 struct bnx2i_endpoint *ep);848extern void bnx2i_update_iscsi_conn(struct iscsi_conn *conn);849extern int bnx2i_send_conn_destroy(struct bnx2i_hba *hba,850 struct bnx2i_endpoint *ep);851 852extern int bnx2i_alloc_qp_resc(struct bnx2i_hba *hba,853 struct bnx2i_endpoint *ep);854extern void bnx2i_free_qp_resc(struct bnx2i_hba *hba,855 struct bnx2i_endpoint *ep);856extern void bnx2i_ep_ofld_timer(struct timer_list *t);857extern struct bnx2i_endpoint *bnx2i_find_ep_in_ofld_list(858 struct bnx2i_hba *hba, u32 iscsi_cid);859extern struct bnx2i_endpoint *bnx2i_find_ep_in_destroy_list(860 struct bnx2i_hba *hba, u32 iscsi_cid);861 862extern int bnx2i_map_ep_dbell_regs(struct bnx2i_endpoint *ep);863extern int bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action);864 865extern int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep);866 867extern int bnx2i_percpu_io_thread(void *arg);868extern int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session,869 struct bnx2i_conn *bnx2i_conn,870 struct cqe *cqe);871#endif872