mirror of
https://github.com/AetherDroid/android_kernel_samsung_on5xelte.git
synced 2025-09-08 01:08:03 -04:00
Fixed MTP to work with TWRP
This commit is contained in:
commit
f6dfaef42e
50820 changed files with 20846062 additions and 0 deletions
161
drivers/scsi/bnx2i/57xx_iscsi_constants.h
Normal file
161
drivers/scsi/bnx2i/57xx_iscsi_constants.h
Normal file
|
@ -0,0 +1,161 @@
|
|||
/* 57xx_iscsi_constants.h: QLogic NetXtreme II iSCSI HSI
|
||||
*
|
||||
* Copyright (c) 2006 - 2013 Broadcom Corporation
|
||||
* Copyright (c) 2014, QLogic Corporation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
* Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
|
||||
* Previously Maintained by: Eddie Wai (eddie.wai@broadcom.com)
|
||||
* Maintained by: QLogic-Storage-Upstream@qlogic.com
|
||||
*/
|
||||
#ifndef __57XX_ISCSI_CONSTANTS_H_
|
||||
#define __57XX_ISCSI_CONSTANTS_H_
|
||||
|
||||
/**
|
||||
* This file defines HSI constants for the iSCSI flows
|
||||
*/
|
||||
|
||||
/* iSCSI request op codes */
|
||||
#define ISCSI_OPCODE_CLEANUP_REQUEST (7)
|
||||
|
||||
/* iSCSI response/messages op codes */
|
||||
#define ISCSI_OPCODE_CLEANUP_RESPONSE (0x27)
|
||||
#define ISCSI_OPCODE_NOPOUT_LOCAL_COMPLETION (0)
|
||||
|
||||
/* iSCSI task types */
|
||||
#define ISCSI_TASK_TYPE_READ (0)
|
||||
#define ISCSI_TASK_TYPE_WRITE (1)
|
||||
#define ISCSI_TASK_TYPE_MPATH (2)
|
||||
|
||||
/* initial CQ sequence numbers */
|
||||
#define ISCSI_INITIAL_SN (1)
|
||||
|
||||
/* KWQ (kernel work queue) layer codes */
|
||||
#define ISCSI_KWQE_LAYER_CODE (6)
|
||||
|
||||
/* KWQ (kernel work queue) request op codes */
|
||||
#define ISCSI_KWQE_OPCODE_OFFLOAD_CONN1 (0)
|
||||
#define ISCSI_KWQE_OPCODE_OFFLOAD_CONN2 (1)
|
||||
#define ISCSI_KWQE_OPCODE_UPDATE_CONN (2)
|
||||
#define ISCSI_KWQE_OPCODE_DESTROY_CONN (3)
|
||||
#define ISCSI_KWQE_OPCODE_INIT1 (4)
|
||||
#define ISCSI_KWQE_OPCODE_INIT2 (5)
|
||||
|
||||
/* KCQ (kernel completion queue) response op codes */
|
||||
#define ISCSI_KCQE_OPCODE_OFFLOAD_CONN (0x10)
|
||||
#define ISCSI_KCQE_OPCODE_UPDATE_CONN (0x12)
|
||||
#define ISCSI_KCQE_OPCODE_DESTROY_CONN (0x13)
|
||||
#define ISCSI_KCQE_OPCODE_INIT (0x14)
|
||||
#define ISCSI_KCQE_OPCODE_FW_CLEAN_TASK (0x15)
|
||||
#define ISCSI_KCQE_OPCODE_TCP_RESET (0x16)
|
||||
#define ISCSI_KCQE_OPCODE_TCP_SYN (0x17)
|
||||
#define ISCSI_KCQE_OPCODE_TCP_FIN (0X18)
|
||||
#define ISCSI_KCQE_OPCODE_TCP_ERROR (0x19)
|
||||
#define ISCSI_KCQE_OPCODE_CQ_EVENT_NOTIFICATION (0x20)
|
||||
#define ISCSI_KCQE_OPCODE_ISCSI_ERROR (0x21)
|
||||
|
||||
/* KCQ (kernel completion queue) completion status */
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_SUCCESS (0x0)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_INVALID_OPCODE (0x1)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_CTX_ALLOC_FAILURE (0x2)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_CTX_FREE_FAILURE (0x3)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_NIC_ERROR (0x4)
|
||||
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_HDR_DIG_ERR (0x5)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_DATA_DIG_ERR (0x6)
|
||||
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_UNEXPECTED_OPCODE (0xa)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_OPCODE (0xb)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_AHS_LEN (0xc)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_ITT (0xd)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_STATSN (0xe)
|
||||
|
||||
/* Response */
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_EXP_DATASN (0xf)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_PEND_R2T (0x10)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_DATA_SEG_LEN_IS_ZERO (0x2c)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_DATA_SEG_LEN_TOO_BIG (0x2d)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_O_U_0 (0x11)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_O_U_1 (0x12)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_O_U_2 (0x13)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_O_U_3 (0x14)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_O_U_4 (0x15)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_O_U_5 (0x16)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_O_U_6 (0x17)
|
||||
|
||||
/* Data-In */
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_REMAIN_RCV_LEN (0x18)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_MAX_RCV_PDU_LEN (0x19)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_F_BIT_ZERO (0x1a)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_TTT_NOT_RSRV (0x1b)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_DATASN (0x1c)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_REMAIN_BURST_LEN (0x1d)
|
||||
|
||||
/* R2T */
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_BUFFER_OFF (0x1f)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_LUN (0x20)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_R2TSN (0x21)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_DESIRED_DATA_TRNS_LEN_0 (0x22)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_DESIRED_DATA_TRNS_LEN_1 (0x23)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_PEND_R2T_EXCEED (0x24)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_TTT_IS_RSRV (0x25)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_MAX_BURST_LEN (0x26)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_DATA_SEG_LEN_NOT_ZERO (0x27)
|
||||
|
||||
/* TMF */
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_REJECT_PDU_LEN (0x28)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_ASYNC_PDU_LEN (0x29)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_NOPIN_PDU_LEN (0x2a)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PROTOCOL_ERR_PEND_R2T_IN_CLEANUP (0x2b)
|
||||
|
||||
/* IP/TCP processing errors: */
|
||||
#define ISCI_KCQE_COMPLETION_STATUS_TCP_ERROR_IP_FRAGMENT (0x40)
|
||||
#define ISCI_KCQE_COMPLETION_STATUS_TCP_ERROR_IP_OPTIONS (0x41)
|
||||
#define ISCI_KCQE_COMPLETION_STATUS_TCP_ERROR_URGENT_FLAG (0x42)
|
||||
#define ISCI_KCQE_COMPLETION_STATUS_TCP_ERROR_MAX_RTRANS (0x43)
|
||||
|
||||
/* iSCSI licensing errors */
|
||||
/* general iSCSI license not installed */
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_ISCSI_NOT_SUPPORTED (0x50)
|
||||
/* additional LOM specific iSCSI license not installed */
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_LOM_ISCSI_NOT_ENABLED (0x51)
|
||||
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_CID_BUSY (0x80)
|
||||
#define ISCSI_KCQE_COMPLETION_STATUS_PARITY_ERR (0x81)
|
||||
|
||||
/* SQ/RQ/CQ DB structure sizes */
|
||||
#define ISCSI_SQ_DB_SIZE (16)
|
||||
#define ISCSI_RQ_DB_SIZE (64)
|
||||
#define ISCSI_CQ_DB_SIZE (80)
|
||||
|
||||
#define ISCSI_SQN_TO_NOTIFY_NOT_VALID 0xFFFF
|
||||
|
||||
/* Page size codes (for flags field in connection offload request) */
|
||||
#define ISCSI_PAGE_SIZE_256 (0)
|
||||
#define ISCSI_PAGE_SIZE_512 (1)
|
||||
#define ISCSI_PAGE_SIZE_1K (2)
|
||||
#define ISCSI_PAGE_SIZE_2K (3)
|
||||
#define ISCSI_PAGE_SIZE_4K (4)
|
||||
#define ISCSI_PAGE_SIZE_8K (5)
|
||||
#define ISCSI_PAGE_SIZE_16K (6)
|
||||
#define ISCSI_PAGE_SIZE_32K (7)
|
||||
#define ISCSI_PAGE_SIZE_64K (8)
|
||||
#define ISCSI_PAGE_SIZE_128K (9)
|
||||
#define ISCSI_PAGE_SIZE_256K (10)
|
||||
#define ISCSI_PAGE_SIZE_512K (11)
|
||||
#define ISCSI_PAGE_SIZE_1M (12)
|
||||
#define ISCSI_PAGE_SIZE_2M (13)
|
||||
#define ISCSI_PAGE_SIZE_4M (14)
|
||||
#define ISCSI_PAGE_SIZE_8M (15)
|
||||
|
||||
/* Iscsi PDU related defines */
|
||||
#define ISCSI_HEADER_SIZE (48)
|
||||
#define ISCSI_DIGEST_SHIFT (2)
|
||||
#define ISCSI_DIGEST_SIZE (4)
|
||||
|
||||
#define B577XX_ISCSI_CONNECTION_TYPE 3
|
||||
|
||||
#endif /*__57XX_ISCSI_CONSTANTS_H_ */
|
1526
drivers/scsi/bnx2i/57xx_iscsi_hsi.h
Normal file
1526
drivers/scsi/bnx2i/57xx_iscsi_hsi.h
Normal file
File diff suppressed because it is too large
Load diff
13
drivers/scsi/bnx2i/Kconfig
Normal file
13
drivers/scsi/bnx2i/Kconfig
Normal file
|
@ -0,0 +1,13 @@
|
|||
config SCSI_BNX2_ISCSI
|
||||
tristate "QLogic NetXtreme II iSCSI support"
|
||||
depends on NET
|
||||
depends on PCI
|
||||
depends on (IPV6 || IPV6=n)
|
||||
select SCSI_ISCSI_ATTRS
|
||||
select NETDEVICES
|
||||
select ETHERNET
|
||||
select NET_VENDOR_BROADCOM
|
||||
select CNIC
|
||||
---help---
|
||||
This driver supports iSCSI offload for the QLogic NetXtreme II
|
||||
devices.
|
3
drivers/scsi/bnx2i/Makefile
Normal file
3
drivers/scsi/bnx2i/Makefile
Normal file
|
@ -0,0 +1,3 @@
|
|||
bnx2i-y := bnx2i_init.o bnx2i_hwi.o bnx2i_iscsi.o bnx2i_sysfs.o
|
||||
|
||||
obj-$(CONFIG_SCSI_BNX2_ISCSI) += bnx2i.o
|
882
drivers/scsi/bnx2i/bnx2i.h
Normal file
882
drivers/scsi/bnx2i/bnx2i.h
Normal file
|
@ -0,0 +1,882 @@
|
|||
/* bnx2i.h: QLogic NetXtreme II iSCSI driver.
|
||||
*
|
||||
* Copyright (c) 2006 - 2013 Broadcom Corporation
|
||||
* Copyright (c) 2007, 2008 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (c) 2007, 2008 Mike Christie
|
||||
* Copyright (c) 2014, QLogic Corporation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
* Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
|
||||
* Previously Maintained by: Eddie Wai (eddie.wai@broadcom.com)
|
||||
* Maintained by: QLogic-Storage-Upstream@qlogic.com
|
||||
*/
|
||||
|
||||
#ifndef _BNX2I_H_
|
||||
#define _BNX2I_H_
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
|
||||
#include <linux/errno.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/in.h>
|
||||
#include <linux/kfifo.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/completion.h>
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/cpu.h>
|
||||
|
||||
#include <scsi/scsi_cmnd.h>
|
||||
#include <scsi/scsi_device.h>
|
||||
#include <scsi/scsi_eh.h>
|
||||
#include <scsi/scsi_host.h>
|
||||
#include <scsi/scsi.h>
|
||||
#include <scsi/iscsi_proto.h>
|
||||
#include <scsi/libiscsi.h>
|
||||
#include <scsi/scsi_transport_iscsi.h>
|
||||
|
||||
#include "../../net/ethernet/broadcom/cnic_if.h"
|
||||
#include "57xx_iscsi_hsi.h"
|
||||
#include "57xx_iscsi_constants.h"
|
||||
|
||||
#include "../../net/ethernet/broadcom/bnx2x/bnx2x_mfw_req.h"
|
||||
|
||||
#define BNX2_ISCSI_DRIVER_NAME "bnx2i"
|
||||
|
||||
#define BNX2I_MAX_ADAPTERS 8
|
||||
|
||||
#define ISCSI_MAX_CONNS_PER_HBA 128
|
||||
#define ISCSI_MAX_SESS_PER_HBA ISCSI_MAX_CONNS_PER_HBA
|
||||
#define ISCSI_MAX_CMDS_PER_SESS 128
|
||||
|
||||
/* Total active commands across all connections supported by devices */
|
||||
#define ISCSI_MAX_CMDS_PER_HBA_5708 (28 * (ISCSI_MAX_CMDS_PER_SESS - 1))
|
||||
#define ISCSI_MAX_CMDS_PER_HBA_5709 (128 * (ISCSI_MAX_CMDS_PER_SESS - 1))
|
||||
#define ISCSI_MAX_CMDS_PER_HBA_57710 (256 * (ISCSI_MAX_CMDS_PER_SESS - 1))
|
||||
|
||||
#define ISCSI_MAX_BDS_PER_CMD 32
|
||||
|
||||
#define MAX_PAGES_PER_CTRL_STRUCT_POOL 8
|
||||
#define BNX2I_RESERVED_SLOW_PATH_CMD_SLOTS 4
|
||||
|
||||
#define BNX2X_DB_SHIFT 3
|
||||
|
||||
/* 5706/08 hardware has limit on maximum buffer size per BD it can handle */
|
||||
#define MAX_BD_LENGTH 65535
|
||||
#define BD_SPLIT_SIZE 32768
|
||||
|
||||
/* min, max & default values for SQ/RQ/CQ size, configurable via' modparam */
|
||||
#define BNX2I_SQ_WQES_MIN 16
|
||||
#define BNX2I_570X_SQ_WQES_MAX 128
|
||||
#define BNX2I_5770X_SQ_WQES_MAX 512
|
||||
#define BNX2I_570X_SQ_WQES_DEFAULT 128
|
||||
#define BNX2I_5770X_SQ_WQES_DEFAULT 128
|
||||
|
||||
#define BNX2I_570X_CQ_WQES_MAX 128
|
||||
#define BNX2I_5770X_CQ_WQES_MAX 512
|
||||
|
||||
#define BNX2I_RQ_WQES_MIN 16
|
||||
#define BNX2I_RQ_WQES_MAX 32
|
||||
#define BNX2I_RQ_WQES_DEFAULT 16
|
||||
|
||||
/* CCELLs per conn */
|
||||
#define BNX2I_CCELLS_MIN 16
|
||||
#define BNX2I_CCELLS_MAX 96
|
||||
#define BNX2I_CCELLS_DEFAULT 64
|
||||
|
||||
#define ITT_INVALID_SIGNATURE 0xFFFF
|
||||
|
||||
#define ISCSI_CMD_CLEANUP_TIMEOUT 100
|
||||
|
||||
#define BNX2I_CONN_CTX_BUF_SIZE 16384
|
||||
|
||||
#define BNX2I_SQ_WQE_SIZE 64
|
||||
#define BNX2I_RQ_WQE_SIZE 256
|
||||
#define BNX2I_CQE_SIZE 64
|
||||
|
||||
#define MB_KERNEL_CTX_SHIFT 8
|
||||
#define MB_KERNEL_CTX_SIZE (1 << MB_KERNEL_CTX_SHIFT)
|
||||
|
||||
#define CTX_SHIFT 7
|
||||
#define GET_CID_NUM(cid_addr) ((cid_addr) >> CTX_SHIFT)
|
||||
|
||||
#define CTX_OFFSET 0x10000
|
||||
#define MAX_CID_CNT 0x4000
|
||||
|
||||
#define BNX2I_570X_PAGE_SIZE_DEFAULT 4096
|
||||
|
||||
/* 5709 context registers */
|
||||
#define BNX2_MQ_CONFIG2 0x00003d00
|
||||
#define BNX2_MQ_CONFIG2_CONT_SZ (0x7L<<4)
|
||||
#define BNX2_MQ_CONFIG2_FIRST_L4L5 (0x1fL<<8)
|
||||
|
||||
/* 57710's BAR2 is mapped to doorbell registers */
|
||||
#define BNX2X_DOORBELL_PCI_BAR 2
|
||||
#define BNX2X_MAX_CQS 8
|
||||
|
||||
#define CNIC_ARM_CQE 1
|
||||
#define CNIC_ARM_CQE_FP 2
|
||||
#define CNIC_DISARM_CQE 0
|
||||
|
||||
#define REG_RD(__hba, offset) \
|
||||
readl(__hba->regview + offset)
|
||||
#define REG_WR(__hba, offset, val) \
|
||||
writel(val, __hba->regview + offset)
|
||||
|
||||
#ifdef CONFIG_32BIT
|
||||
#define GET_STATS_64(__hba, dst, field) \
|
||||
do { \
|
||||
spin_lock_bh(&__hba->stat_lock); \
|
||||
dst->field##_lo = __hba->stats.field##_lo; \
|
||||
dst->field##_hi = __hba->stats.field##_hi; \
|
||||
spin_unlock_bh(&__hba->stat_lock); \
|
||||
} while (0)
|
||||
|
||||
#define ADD_STATS_64(__hba, field, len) \
|
||||
do { \
|
||||
if (spin_trylock(&__hba->stat_lock)) { \
|
||||
if (__hba->stats.field##_lo + len < \
|
||||
__hba->stats.field##_lo) \
|
||||
__hba->stats.field##_hi++; \
|
||||
__hba->stats.field##_lo += len; \
|
||||
spin_unlock(&__hba->stat_lock); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
#define GET_STATS_64(__hba, dst, field) \
|
||||
do { \
|
||||
u64 val, *out; \
|
||||
\
|
||||
val = __hba->bnx2i_stats.field; \
|
||||
out = (u64 *)&__hba->stats.field##_lo; \
|
||||
*out = cpu_to_le64(val); \
|
||||
out = (u64 *)&dst->field##_lo; \
|
||||
*out = cpu_to_le64(val); \
|
||||
} while (0)
|
||||
|
||||
#define ADD_STATS_64(__hba, field, len) \
|
||||
do { \
|
||||
__hba->bnx2i_stats.field += len; \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* struct generic_pdu_resc - login pdu resource structure
|
||||
*
|
||||
* @req_buf: driver buffer used to stage payload associated with
|
||||
* the login request
|
||||
* @req_dma_addr: dma address for iscsi login request payload buffer
|
||||
* @req_buf_size: actual login request payload length
|
||||
* @req_wr_ptr: pointer into login request buffer when next data is
|
||||
* to be written
|
||||
* @resp_hdr: iscsi header where iscsi login response header is to
|
||||
* be recreated
|
||||
* @resp_buf: buffer to stage login response payload
|
||||
* @resp_dma_addr: login response payload buffer dma address
|
||||
* @resp_buf_size: login response paylod length
|
||||
* @resp_wr_ptr: pointer into login response buffer when next data is
|
||||
* to be written
|
||||
* @req_bd_tbl: iscsi login request payload BD table
|
||||
* @req_bd_dma: login request BD table dma address
|
||||
* @resp_bd_tbl: iscsi login response payload BD table
|
||||
* @resp_bd_dma: login request BD table dma address
|
||||
*
|
||||
* following structure defines buffer info for generic pdus such as iSCSI Login,
|
||||
* Logout and NOP
|
||||
*/
|
||||
struct generic_pdu_resc {
|
||||
char *req_buf;
|
||||
dma_addr_t req_dma_addr;
|
||||
u32 req_buf_size;
|
||||
char *req_wr_ptr;
|
||||
struct iscsi_hdr resp_hdr;
|
||||
char *resp_buf;
|
||||
dma_addr_t resp_dma_addr;
|
||||
u32 resp_buf_size;
|
||||
char *resp_wr_ptr;
|
||||
char *req_bd_tbl;
|
||||
dma_addr_t req_bd_dma;
|
||||
char *resp_bd_tbl;
|
||||
dma_addr_t resp_bd_dma;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* struct bd_resc_page - tracks DMA'able memory allocated for BD tables
|
||||
*
|
||||
* @link: list head to link elements
|
||||
* @max_ptrs: maximun pointers that can be stored in this page
|
||||
* @num_valid: number of pointer valid in this page
|
||||
* @page: base addess for page pointer array
|
||||
*
|
||||
* structure to track DMA'able memory allocated for command BD tables
|
||||
*/
|
||||
struct bd_resc_page {
|
||||
struct list_head link;
|
||||
u32 max_ptrs;
|
||||
u32 num_valid;
|
||||
void *page[1];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* struct io_bdt - I/O buffer destricptor table
|
||||
*
|
||||
* @bd_tbl: BD table's virtual address
|
||||
* @bd_tbl_dma: BD table's dma address
|
||||
* @bd_valid: num valid BD entries
|
||||
*
|
||||
* IO BD table
|
||||
*/
|
||||
struct io_bdt {
|
||||
struct iscsi_bd *bd_tbl;
|
||||
dma_addr_t bd_tbl_dma;
|
||||
u16 bd_valid;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* bnx2i_cmd - iscsi command structure
|
||||
*
|
||||
* @hdr: iSCSI header
|
||||
* @conn: iscsi_conn pointer
|
||||
* @scsi_cmd: SCSI-ML task pointer corresponding to this iscsi cmd
|
||||
* @sg: SG list
|
||||
* @io_tbl: buffer descriptor (BD) table
|
||||
* @bd_tbl_dma: buffer descriptor (BD) table's dma address
|
||||
* @req: bnx2i specific command request struct
|
||||
*/
|
||||
struct bnx2i_cmd {
|
||||
struct iscsi_hdr hdr;
|
||||
struct bnx2i_conn *conn;
|
||||
struct scsi_cmnd *scsi_cmd;
|
||||
struct scatterlist *sg;
|
||||
struct io_bdt io_tbl;
|
||||
dma_addr_t bd_tbl_dma;
|
||||
struct bnx2i_cmd_request req;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* struct bnx2i_conn - iscsi connection structure
|
||||
*
|
||||
* @cls_conn: pointer to iscsi cls conn
|
||||
* @hba: adapter structure pointer
|
||||
* @iscsi_conn_cid: iscsi conn id
|
||||
* @fw_cid: firmware iscsi context id
|
||||
* @ep: endpoint structure pointer
|
||||
* @gen_pdu: login/nopout/logout pdu resources
|
||||
* @violation_notified: bit mask used to track iscsi error/warning messages
|
||||
* already printed out
|
||||
* @work_cnt: keeps track of the number of outstanding work
|
||||
*
|
||||
* iSCSI connection structure
|
||||
*/
|
||||
struct bnx2i_conn {
|
||||
struct iscsi_cls_conn *cls_conn;
|
||||
struct bnx2i_hba *hba;
|
||||
struct completion cmd_cleanup_cmpl;
|
||||
|
||||
u32 iscsi_conn_cid;
|
||||
#define BNX2I_CID_RESERVED 0x5AFF
|
||||
u32 fw_cid;
|
||||
|
||||
struct timer_list poll_timer;
|
||||
/*
|
||||
* Queue Pair (QP) related structure elements.
|
||||
*/
|
||||
struct bnx2i_endpoint *ep;
|
||||
|
||||
/*
|
||||
* Buffer for login negotiation process
|
||||
*/
|
||||
struct generic_pdu_resc gen_pdu;
|
||||
u64 violation_notified;
|
||||
|
||||
atomic_t work_cnt;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* struct iscsi_cid_queue - Per adapter iscsi cid queue
|
||||
*
|
||||
* @cid_que_base: queue base memory
|
||||
* @cid_que: queue memory pointer
|
||||
* @cid_q_prod_idx: produce index
|
||||
* @cid_q_cons_idx: consumer index
|
||||
* @cid_q_max_idx: max index. used to detect wrap around condition
|
||||
* @cid_free_cnt: queue size
|
||||
* @conn_cid_tbl: iscsi cid to conn structure mapping table
|
||||
*
|
||||
* Per adapter iSCSI CID Queue
|
||||
*/
|
||||
struct iscsi_cid_queue {
|
||||
void *cid_que_base;
|
||||
u32 *cid_que;
|
||||
u32 cid_q_prod_idx;
|
||||
u32 cid_q_cons_idx;
|
||||
u32 cid_q_max_idx;
|
||||
u32 cid_free_cnt;
|
||||
struct bnx2i_conn **conn_cid_tbl;
|
||||
};
|
||||
|
||||
|
||||
struct bnx2i_stats_info {
|
||||
u64 rx_pdus;
|
||||
u64 rx_bytes;
|
||||
u64 tx_pdus;
|
||||
u64 tx_bytes;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* struct bnx2i_hba - bnx2i adapter structure
|
||||
*
|
||||
* @link: list head to link elements
|
||||
* @cnic: pointer to cnic device
|
||||
* @pcidev: pointer to pci dev
|
||||
* @netdev: pointer to netdev structure
|
||||
* @regview: mapped PCI register space
|
||||
* @age: age, incremented by every recovery
|
||||
* @cnic_dev_type: cnic device type, 5706/5708/5709/57710
|
||||
* @mail_queue_access: mailbox queue access mode, applicable to 5709 only
|
||||
* @reg_with_cnic: indicates whether the device is register with CNIC
|
||||
* @adapter_state: adapter state, UP, GOING_DOWN, LINK_DOWN
|
||||
* @mtu_supported: Ethernet MTU supported
|
||||
* @shost: scsi host pointer
|
||||
* @max_sqes: SQ size
|
||||
* @max_rqes: RQ size
|
||||
* @max_cqes: CQ size
|
||||
* @num_ccell: number of command cells per connection
|
||||
* @ofld_conns_active: active connection list
|
||||
* @eh_wait: wait queue for the endpoint to shutdown
|
||||
* @max_active_conns: max offload connections supported by this device
|
||||
* @cid_que: iscsi cid queue
|
||||
* @ep_rdwr_lock: read / write lock to synchronize various ep lists
|
||||
* @ep_ofld_list: connection list for pending offload completion
|
||||
* @ep_active_list: connection list for active offload endpoints
|
||||
* @ep_destroy_list: connection list for pending offload completion
|
||||
* @mp_bd_tbl: BD table to be used with middle path requests
|
||||
* @mp_bd_dma: DMA address of 'mp_bd_tbl' memory buffer
|
||||
* @dummy_buffer: Dummy buffer to be used with zero length scsicmd reqs
|
||||
* @dummy_buf_dma: DMA address of 'dummy_buffer' memory buffer
|
||||
* @lock: lock to synchonize access to hba structure
|
||||
* @hba_shutdown_tmo: Timeout value to shutdown each connection
|
||||
* @conn_teardown_tmo: Timeout value to tear down each connection
|
||||
* @conn_ctx_destroy_tmo: Timeout value to destroy context of each connection
|
||||
* @pci_did: PCI device ID
|
||||
* @pci_vid: PCI vendor ID
|
||||
* @pci_sdid: PCI subsystem device ID
|
||||
* @pci_svid: PCI subsystem vendor ID
|
||||
* @pci_func: PCI function number in system pci tree
|
||||
* @pci_devno: PCI device number in system pci tree
|
||||
* @num_wqe_sent: statistic counter, total wqe's sent
|
||||
* @num_cqe_rcvd: statistic counter, total cqe's received
|
||||
* @num_intr_claimed: statistic counter, total interrupts claimed
|
||||
* @link_changed_count: statistic counter, num of link change notifications
|
||||
* received
|
||||
* @ipaddr_changed_count: statistic counter, num times IP address changed while
|
||||
* at least one connection is offloaded
|
||||
* @num_sess_opened: statistic counter, total num sessions opened
|
||||
* @num_conn_opened: statistic counter, total num conns opened on this hba
|
||||
* @ctx_ccell_tasks: captures number of ccells and tasks supported by
|
||||
* currently offloaded connection, used to decode
|
||||
* context memory
|
||||
* @stat_lock: spin lock used by the statistic collector (32 bit)
|
||||
* @stats: local iSCSI statistic collection place holder
|
||||
*
|
||||
* Adapter Data Structure
|
||||
*/
|
||||
struct bnx2i_hba {
|
||||
struct list_head link;
|
||||
struct cnic_dev *cnic;
|
||||
struct pci_dev *pcidev;
|
||||
struct net_device *netdev;
|
||||
void __iomem *regview;
|
||||
resource_size_t reg_base;
|
||||
|
||||
u32 age;
|
||||
unsigned long cnic_dev_type;
|
||||
#define BNX2I_NX2_DEV_5706 0x0
|
||||
#define BNX2I_NX2_DEV_5708 0x1
|
||||
#define BNX2I_NX2_DEV_5709 0x2
|
||||
#define BNX2I_NX2_DEV_57710 0x3
|
||||
u32 mail_queue_access;
|
||||
#define BNX2I_MQ_KERNEL_MODE 0x0
|
||||
#define BNX2I_MQ_KERNEL_BYPASS_MODE 0x1
|
||||
#define BNX2I_MQ_BIN_MODE 0x2
|
||||
unsigned long reg_with_cnic;
|
||||
#define BNX2I_CNIC_REGISTERED 1
|
||||
|
||||
unsigned long adapter_state;
|
||||
#define ADAPTER_STATE_UP 0
|
||||
#define ADAPTER_STATE_GOING_DOWN 1
|
||||
#define ADAPTER_STATE_LINK_DOWN 2
|
||||
#define ADAPTER_STATE_INIT_FAILED 31
|
||||
unsigned int mtu_supported;
|
||||
#define BNX2I_MAX_MTU_SUPPORTED 9000
|
||||
|
||||
struct Scsi_Host *shost;
|
||||
|
||||
u32 max_sqes;
|
||||
u32 max_rqes;
|
||||
u32 max_cqes;
|
||||
u32 num_ccell;
|
||||
|
||||
int ofld_conns_active;
|
||||
wait_queue_head_t eh_wait;
|
||||
|
||||
int max_active_conns;
|
||||
struct iscsi_cid_queue cid_que;
|
||||
|
||||
rwlock_t ep_rdwr_lock;
|
||||
struct list_head ep_ofld_list;
|
||||
struct list_head ep_active_list;
|
||||
struct list_head ep_destroy_list;
|
||||
|
||||
/*
|
||||
* BD table to be used with MP (Middle Path requests.
|
||||
*/
|
||||
char *mp_bd_tbl;
|
||||
dma_addr_t mp_bd_dma;
|
||||
char *dummy_buffer;
|
||||
dma_addr_t dummy_buf_dma;
|
||||
|
||||
spinlock_t lock; /* protects hba structure access */
|
||||
struct mutex net_dev_lock;/* sync net device access */
|
||||
|
||||
int hba_shutdown_tmo;
|
||||
int conn_teardown_tmo;
|
||||
int conn_ctx_destroy_tmo;
|
||||
/*
|
||||
* PCI related info.
|
||||
*/
|
||||
u16 pci_did;
|
||||
u16 pci_vid;
|
||||
u16 pci_sdid;
|
||||
u16 pci_svid;
|
||||
u16 pci_func;
|
||||
u16 pci_devno;
|
||||
|
||||
/*
|
||||
* Following are a bunch of statistics useful during development
|
||||
* and later stage for score boarding.
|
||||
*/
|
||||
u32 num_wqe_sent;
|
||||
u32 num_cqe_rcvd;
|
||||
u32 num_intr_claimed;
|
||||
u32 link_changed_count;
|
||||
u32 ipaddr_changed_count;
|
||||
u32 num_sess_opened;
|
||||
u32 num_conn_opened;
|
||||
unsigned int ctx_ccell_tasks;
|
||||
|
||||
#ifdef CONFIG_32BIT
|
||||
spinlock_t stat_lock;
|
||||
#endif
|
||||
struct bnx2i_stats_info bnx2i_stats;
|
||||
struct iscsi_stats_info stats;
|
||||
};
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* QP [ SQ / RQ / CQ ] info.
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* SQ/RQ/CQ generic structure definition
|
||||
*/
|
||||
struct sqe {
|
||||
u8 sqe_byte[BNX2I_SQ_WQE_SIZE];
|
||||
};
|
||||
|
||||
struct rqe {
|
||||
u8 rqe_byte[BNX2I_RQ_WQE_SIZE];
|
||||
};
|
||||
|
||||
struct cqe {
|
||||
u8 cqe_byte[BNX2I_CQE_SIZE];
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
#if defined(__LITTLE_ENDIAN)
|
||||
CNIC_EVENT_COAL_INDEX = 0x0,
|
||||
CNIC_SEND_DOORBELL = 0x4,
|
||||
CNIC_EVENT_CQ_ARM = 0x7,
|
||||
CNIC_RECV_DOORBELL = 0x8
|
||||
#elif defined(__BIG_ENDIAN)
|
||||
CNIC_EVENT_COAL_INDEX = 0x2,
|
||||
CNIC_SEND_DOORBELL = 0x6,
|
||||
CNIC_EVENT_CQ_ARM = 0x4,
|
||||
CNIC_RECV_DOORBELL = 0xa
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* CQ DB
|
||||
*/
|
||||
struct bnx2x_iscsi_cq_pend_cmpl {
|
||||
/* CQ producer, updated by Ustorm */
|
||||
u16 ustrom_prod;
|
||||
/* CQ pending completion counter */
|
||||
u16 pend_cntr;
|
||||
};
|
||||
|
||||
|
||||
struct bnx2i_5771x_cq_db {
|
||||
struct bnx2x_iscsi_cq_pend_cmpl qp_pend_cmpl[BNX2X_MAX_CQS];
|
||||
/* CQ pending completion ITT array */
|
||||
u16 itt[BNX2X_MAX_CQS];
|
||||
/* Cstorm CQ sequence to notify array, updated by driver */;
|
||||
u16 sqn[BNX2X_MAX_CQS];
|
||||
u32 reserved[4] /* 16 byte allignment */;
|
||||
};
|
||||
|
||||
|
||||
struct bnx2i_5771x_sq_rq_db {
|
||||
u16 prod_idx;
|
||||
u8 reserved0[62]; /* Pad structure size to 64 bytes */
|
||||
};
|
||||
|
||||
|
||||
struct bnx2i_5771x_dbell_hdr {
|
||||
u8 header;
|
||||
/* 1 for rx doorbell, 0 for tx doorbell */
|
||||
#define B577XX_DOORBELL_HDR_RX (0x1<<0)
|
||||
#define B577XX_DOORBELL_HDR_RX_SHIFT 0
|
||||
/* 0 for normal doorbell, 1 for advertise wnd doorbell */
|
||||
#define B577XX_DOORBELL_HDR_DB_TYPE (0x1<<1)
|
||||
#define B577XX_DOORBELL_HDR_DB_TYPE_SHIFT 1
|
||||
/* rdma tx only: DPM transaction size specifier (64/128/256/512B) */
|
||||
#define B577XX_DOORBELL_HDR_DPM_SIZE (0x3<<2)
|
||||
#define B577XX_DOORBELL_HDR_DPM_SIZE_SHIFT 2
|
||||
/* connection type */
|
||||
#define B577XX_DOORBELL_HDR_CONN_TYPE (0xF<<4)
|
||||
#define B577XX_DOORBELL_HDR_CONN_TYPE_SHIFT 4
|
||||
};
|
||||
|
||||
struct bnx2i_5771x_dbell {
|
||||
struct bnx2i_5771x_dbell_hdr dbell;
|
||||
u8 pad[3];
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* struct qp_info - QP (share queue region) atrributes structure
|
||||
*
|
||||
* @ctx_base: ioremapped pci register base to access doorbell register
|
||||
* pertaining to this offloaded connection
|
||||
* @sq_virt: virtual address of send queue (SQ) region
|
||||
* @sq_phys: DMA address of SQ memory region
|
||||
* @sq_mem_size: SQ size
|
||||
* @sq_prod_qe: SQ producer entry pointer
|
||||
* @sq_cons_qe: SQ consumer entry pointer
|
||||
* @sq_first_qe: virtual address of first entry in SQ
|
||||
* @sq_last_qe: virtual address of last entry in SQ
|
||||
* @sq_prod_idx: SQ producer index
|
||||
* @sq_cons_idx: SQ consumer index
|
||||
* @sqe_left: number sq entry left
|
||||
* @sq_pgtbl_virt: page table describing buffer consituting SQ region
|
||||
* @sq_pgtbl_phys: dma address of 'sq_pgtbl_virt'
|
||||
* @sq_pgtbl_size: SQ page table size
|
||||
* @cq_virt: virtual address of completion queue (CQ) region
|
||||
* @cq_phys: DMA address of RQ memory region
|
||||
* @cq_mem_size: CQ size
|
||||
* @cq_prod_qe: CQ producer entry pointer
|
||||
* @cq_cons_qe: CQ consumer entry pointer
|
||||
* @cq_first_qe: virtual address of first entry in CQ
|
||||
* @cq_last_qe: virtual address of last entry in CQ
|
||||
* @cq_prod_idx: CQ producer index
|
||||
* @cq_cons_idx: CQ consumer index
|
||||
* @cqe_left: number cq entry left
|
||||
* @cqe_size: size of each CQ entry
|
||||
* @cqe_exp_seq_sn: next expected CQE sequence number
|
||||
* @cq_pgtbl_virt: page table describing buffer consituting CQ region
|
||||
* @cq_pgtbl_phys: dma address of 'cq_pgtbl_virt'
|
||||
* @cq_pgtbl_size: CQ page table size
|
||||
* @rq_virt: virtual address of receive queue (RQ) region
|
||||
* @rq_phys: DMA address of RQ memory region
|
||||
* @rq_mem_size: RQ size
|
||||
* @rq_prod_qe: RQ producer entry pointer
|
||||
* @rq_cons_qe: RQ consumer entry pointer
|
||||
* @rq_first_qe: virtual address of first entry in RQ
|
||||
* @rq_last_qe: virtual address of last entry in RQ
|
||||
* @rq_prod_idx: RQ producer index
|
||||
* @rq_cons_idx: RQ consumer index
|
||||
* @rqe_left: number rq entry left
|
||||
* @rq_pgtbl_virt: page table describing buffer consituting RQ region
|
||||
* @rq_pgtbl_phys: dma address of 'rq_pgtbl_virt'
|
||||
* @rq_pgtbl_size: RQ page table size
|
||||
*
|
||||
* queue pair (QP) is a per connection shared data structure which is used
|
||||
* to send work requests (SQ), receive completion notifications (CQ)
|
||||
* and receive asynchoronous / scsi sense info (RQ). 'qp_info' structure
|
||||
* below holds queue memory, consumer/producer indexes and page table
|
||||
* information
|
||||
*/
|
||||
struct qp_info {
|
||||
void __iomem *ctx_base;
|
||||
#define DPM_TRIGER_TYPE 0x40
|
||||
|
||||
#define BNX2I_570x_QUE_DB_SIZE 0
|
||||
#define BNX2I_5771x_QUE_DB_SIZE 16
|
||||
struct sqe *sq_virt;
|
||||
dma_addr_t sq_phys;
|
||||
u32 sq_mem_size;
|
||||
|
||||
struct sqe *sq_prod_qe;
|
||||
struct sqe *sq_cons_qe;
|
||||
struct sqe *sq_first_qe;
|
||||
struct sqe *sq_last_qe;
|
||||
u16 sq_prod_idx;
|
||||
u16 sq_cons_idx;
|
||||
u32 sqe_left;
|
||||
|
||||
void *sq_pgtbl_virt;
|
||||
dma_addr_t sq_pgtbl_phys;
|
||||
u32 sq_pgtbl_size; /* set to PAGE_SIZE for 5708 & 5709 */
|
||||
|
||||
struct cqe *cq_virt;
|
||||
dma_addr_t cq_phys;
|
||||
u32 cq_mem_size;
|
||||
|
||||
struct cqe *cq_prod_qe;
|
||||
struct cqe *cq_cons_qe;
|
||||
struct cqe *cq_first_qe;
|
||||
struct cqe *cq_last_qe;
|
||||
u16 cq_prod_idx;
|
||||
u16 cq_cons_idx;
|
||||
u32 cqe_left;
|
||||
u32 cqe_size;
|
||||
u32 cqe_exp_seq_sn;
|
||||
|
||||
void *cq_pgtbl_virt;
|
||||
dma_addr_t cq_pgtbl_phys;
|
||||
u32 cq_pgtbl_size; /* set to PAGE_SIZE for 5708 & 5709 */
|
||||
|
||||
struct rqe *rq_virt;
|
||||
dma_addr_t rq_phys;
|
||||
u32 rq_mem_size;
|
||||
|
||||
struct rqe *rq_prod_qe;
|
||||
struct rqe *rq_cons_qe;
|
||||
struct rqe *rq_first_qe;
|
||||
struct rqe *rq_last_qe;
|
||||
u16 rq_prod_idx;
|
||||
u16 rq_cons_idx;
|
||||
u32 rqe_left;
|
||||
|
||||
void *rq_pgtbl_virt;
|
||||
dma_addr_t rq_pgtbl_phys;
|
||||
u32 rq_pgtbl_size; /* set to PAGE_SIZE for 5708 & 5709 */
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* CID handles
|
||||
*/
|
||||
struct ep_handles {
|
||||
u32 fw_cid;
|
||||
u32 drv_iscsi_cid;
|
||||
u16 pg_cid;
|
||||
u16 rsvd;
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
EP_STATE_IDLE = 0x0,
|
||||
EP_STATE_PG_OFLD_START = 0x1,
|
||||
EP_STATE_PG_OFLD_COMPL = 0x2,
|
||||
EP_STATE_OFLD_START = 0x4,
|
||||
EP_STATE_OFLD_COMPL = 0x8,
|
||||
EP_STATE_CONNECT_START = 0x10,
|
||||
EP_STATE_CONNECT_COMPL = 0x20,
|
||||
EP_STATE_ULP_UPDATE_START = 0x40,
|
||||
EP_STATE_ULP_UPDATE_COMPL = 0x80,
|
||||
EP_STATE_DISCONN_START = 0x100,
|
||||
EP_STATE_DISCONN_COMPL = 0x200,
|
||||
EP_STATE_CLEANUP_START = 0x400,
|
||||
EP_STATE_CLEANUP_CMPL = 0x800,
|
||||
EP_STATE_TCP_FIN_RCVD = 0x1000,
|
||||
EP_STATE_TCP_RST_RCVD = 0x2000,
|
||||
EP_STATE_LOGOUT_SENT = 0x4000,
|
||||
EP_STATE_LOGOUT_RESP_RCVD = 0x8000,
|
||||
EP_STATE_PG_OFLD_FAILED = 0x1000000,
|
||||
EP_STATE_ULP_UPDATE_FAILED = 0x2000000,
|
||||
EP_STATE_CLEANUP_FAILED = 0x4000000,
|
||||
EP_STATE_OFLD_FAILED = 0x8000000,
|
||||
EP_STATE_CONNECT_FAILED = 0x10000000,
|
||||
EP_STATE_DISCONN_TIMEDOUT = 0x20000000,
|
||||
EP_STATE_OFLD_FAILED_CID_BUSY = 0x80000000,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct bnx2i_endpoint - representation of tcp connection in NX2 world
|
||||
*
|
||||
* @link: list head to link elements
|
||||
* @hba: adapter to which this connection belongs
|
||||
* @conn: iscsi connection this EP is linked to
|
||||
* @cls_ep: associated iSCSI endpoint pointer
|
||||
* @cm_sk: cnic sock struct
|
||||
* @hba_age: age to detect if 'iscsid' issues ep_disconnect()
|
||||
* after HBA reset is completed by bnx2i/cnic/bnx2
|
||||
* modules
|
||||
* @state: tracks offload connection state machine
|
||||
* @timestamp: tracks the start time when the ep begins to connect
|
||||
* @num_active_cmds: tracks the number of outstanding commands for this ep
|
||||
* @ec_shift: the amount of shift as part of the event coal calc
|
||||
* @qp: QP information
|
||||
* @ids: contains chip allocated *context id* & driver assigned
|
||||
* *iscsi cid*
|
||||
* @ofld_timer: offload timer to detect timeout
|
||||
* @ofld_wait: wait queue
|
||||
*
|
||||
* Endpoint Structure - equivalent of tcp socket structure
|
||||
*/
|
||||
struct bnx2i_endpoint {
|
||||
struct list_head link;
|
||||
struct bnx2i_hba *hba;
|
||||
struct bnx2i_conn *conn;
|
||||
struct iscsi_endpoint *cls_ep;
|
||||
struct cnic_sock *cm_sk;
|
||||
u32 hba_age;
|
||||
u32 state;
|
||||
unsigned long timestamp;
|
||||
atomic_t num_active_cmds;
|
||||
u32 ec_shift;
|
||||
|
||||
struct qp_info qp;
|
||||
struct ep_handles ids;
|
||||
#define ep_iscsi_cid ids.drv_iscsi_cid
|
||||
#define ep_cid ids.fw_cid
|
||||
#define ep_pg_cid ids.pg_cid
|
||||
struct timer_list ofld_timer;
|
||||
wait_queue_head_t ofld_wait;
|
||||
};
|
||||
|
||||
|
||||
struct bnx2i_work {
|
||||
struct list_head list;
|
||||
struct iscsi_session *session;
|
||||
struct bnx2i_conn *bnx2i_conn;
|
||||
struct cqe cqe;
|
||||
};
|
||||
|
||||
struct bnx2i_percpu_s {
|
||||
struct task_struct *iothread;
|
||||
struct list_head work_list;
|
||||
spinlock_t p_work_lock;
|
||||
};
|
||||
|
||||
|
||||
/* Global variables */
|
||||
extern unsigned int error_mask1, error_mask2;
|
||||
extern u64 iscsi_error_mask;
|
||||
extern unsigned int en_tcp_dack;
|
||||
extern unsigned int event_coal_div;
|
||||
extern unsigned int event_coal_min;
|
||||
|
||||
extern struct scsi_transport_template *bnx2i_scsi_xport_template;
|
||||
extern struct iscsi_transport bnx2i_iscsi_transport;
|
||||
extern struct cnic_ulp_ops bnx2i_cnic_cb;
|
||||
|
||||
extern unsigned int sq_size;
|
||||
extern unsigned int rq_size;
|
||||
|
||||
extern struct device_attribute *bnx2i_dev_attributes[];
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Function Prototypes
|
||||
*/
|
||||
extern void bnx2i_identify_device(struct bnx2i_hba *hba, struct cnic_dev *dev);
|
||||
|
||||
extern void bnx2i_ulp_init(struct cnic_dev *dev);
|
||||
extern void bnx2i_ulp_exit(struct cnic_dev *dev);
|
||||
extern void bnx2i_start(void *handle);
|
||||
extern void bnx2i_stop(void *handle);
|
||||
extern int bnx2i_get_stats(void *handle);
|
||||
|
||||
extern struct bnx2i_hba *get_adapter_list_head(void);
|
||||
|
||||
struct bnx2i_conn *bnx2i_get_conn_from_id(struct bnx2i_hba *hba,
|
||||
u16 iscsi_cid);
|
||||
|
||||
int bnx2i_alloc_ep_pool(void);
|
||||
void bnx2i_release_ep_pool(void);
|
||||
struct bnx2i_endpoint *bnx2i_ep_ofld_list_next(struct bnx2i_hba *hba);
|
||||
struct bnx2i_endpoint *bnx2i_ep_destroy_list_next(struct bnx2i_hba *hba);
|
||||
|
||||
struct bnx2i_hba *bnx2i_find_hba_for_cnic(struct cnic_dev *cnic);
|
||||
|
||||
struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic);
|
||||
void bnx2i_free_hba(struct bnx2i_hba *hba);
|
||||
|
||||
void bnx2i_get_rq_buf(struct bnx2i_conn *conn, char *ptr, int len);
|
||||
void bnx2i_put_rq_buf(struct bnx2i_conn *conn, int count);
|
||||
|
||||
void bnx2i_iscsi_unmap_sg_list(struct bnx2i_cmd *cmd);
|
||||
|
||||
void bnx2i_drop_session(struct iscsi_cls_session *session);
|
||||
|
||||
extern int bnx2i_send_fw_iscsi_init_msg(struct bnx2i_hba *hba);
|
||||
extern int bnx2i_send_iscsi_login(struct bnx2i_conn *conn,
|
||||
struct iscsi_task *mtask);
|
||||
extern int bnx2i_send_iscsi_tmf(struct bnx2i_conn *conn,
|
||||
struct iscsi_task *mtask);
|
||||
extern int bnx2i_send_iscsi_text(struct bnx2i_conn *conn,
|
||||
struct iscsi_task *mtask);
|
||||
extern int bnx2i_send_iscsi_scsicmd(struct bnx2i_conn *conn,
|
||||
struct bnx2i_cmd *cmnd);
|
||||
extern int bnx2i_send_iscsi_nopout(struct bnx2i_conn *conn,
|
||||
struct iscsi_task *mtask,
|
||||
char *datap, int data_len, int unsol);
|
||||
extern int bnx2i_send_iscsi_logout(struct bnx2i_conn *conn,
|
||||
struct iscsi_task *mtask);
|
||||
extern void bnx2i_send_cmd_cleanup_req(struct bnx2i_hba *hba,
|
||||
struct bnx2i_cmd *cmd);
|
||||
extern int bnx2i_send_conn_ofld_req(struct bnx2i_hba *hba,
|
||||
struct bnx2i_endpoint *ep);
|
||||
extern void bnx2i_update_iscsi_conn(struct iscsi_conn *conn);
|
||||
extern int bnx2i_send_conn_destroy(struct bnx2i_hba *hba,
|
||||
struct bnx2i_endpoint *ep);
|
||||
|
||||
extern int bnx2i_alloc_qp_resc(struct bnx2i_hba *hba,
|
||||
struct bnx2i_endpoint *ep);
|
||||
extern void bnx2i_free_qp_resc(struct bnx2i_hba *hba,
|
||||
struct bnx2i_endpoint *ep);
|
||||
extern void bnx2i_ep_ofld_timer(unsigned long data);
|
||||
extern struct bnx2i_endpoint *bnx2i_find_ep_in_ofld_list(
|
||||
struct bnx2i_hba *hba, u32 iscsi_cid);
|
||||
extern struct bnx2i_endpoint *bnx2i_find_ep_in_destroy_list(
|
||||
struct bnx2i_hba *hba, u32 iscsi_cid);
|
||||
|
||||
extern int bnx2i_map_ep_dbell_regs(struct bnx2i_endpoint *ep);
|
||||
extern int bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action);
|
||||
|
||||
extern int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep);
|
||||
|
||||
/* Debug related function prototypes */
|
||||
extern void bnx2i_print_pend_cmd_queue(struct bnx2i_conn *conn);
|
||||
extern void bnx2i_print_active_cmd_queue(struct bnx2i_conn *conn);
|
||||
extern void bnx2i_print_xmit_pdu_queue(struct bnx2i_conn *conn);
|
||||
extern void bnx2i_print_recv_state(struct bnx2i_conn *conn);
|
||||
|
||||
extern int bnx2i_percpu_io_thread(void *arg);
|
||||
extern int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session,
|
||||
struct bnx2i_conn *bnx2i_conn,
|
||||
struct cqe *cqe);
|
||||
#endif
|
2771
drivers/scsi/bnx2i/bnx2i_hwi.c
Normal file
2771
drivers/scsi/bnx2i/bnx2i_hwi.c
Normal file
File diff suppressed because it is too large
Load diff
604
drivers/scsi/bnx2i/bnx2i_init.c
Normal file
604
drivers/scsi/bnx2i/bnx2i_init.c
Normal file
|
@ -0,0 +1,604 @@
|
|||
/* bnx2i.c: QLogic NetXtreme II iSCSI driver.
|
||||
*
|
||||
* Copyright (c) 2006 - 2013 Broadcom Corporation
|
||||
* Copyright (c) 2007, 2008 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (c) 2007, 2008 Mike Christie
|
||||
* Copyright (c) 2014, QLogic Corporation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
* Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
|
||||
* Previously Maintained by: Eddie Wai (eddie.wai@broadcom.com)
|
||||
* Maintained by: QLogic-Storage-Upstream@qlogic.com
|
||||
*/
|
||||
|
||||
#include "bnx2i.h"
|
||||
|
||||
static struct list_head adapter_list = LIST_HEAD_INIT(adapter_list);
|
||||
static u32 adapter_count;
|
||||
|
||||
#define DRV_MODULE_NAME "bnx2i"
|
||||
#define DRV_MODULE_VERSION "2.7.10.1"
|
||||
#define DRV_MODULE_RELDATE "Jul 16, 2014"
|
||||
|
||||
static char version[] =
|
||||
"QLogic NetXtreme II iSCSI Driver " DRV_MODULE_NAME \
|
||||
" v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
|
||||
|
||||
|
||||
MODULE_AUTHOR("Anil Veerabhadrappa <anilgv@broadcom.com> and "
|
||||
"Eddie Wai <eddie.wai@broadcom.com>");
|
||||
|
||||
MODULE_DESCRIPTION("QLogic NetXtreme II BCM5706/5708/5709/57710/57711/57712"
|
||||
"/57800/57810/57840 iSCSI Driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(DRV_MODULE_VERSION);
|
||||
|
||||
static DEFINE_MUTEX(bnx2i_dev_lock);
|
||||
|
||||
unsigned int event_coal_min = 24;
|
||||
module_param(event_coal_min, int, 0664);
|
||||
MODULE_PARM_DESC(event_coal_min, "Event Coalescing Minimum Commands");
|
||||
|
||||
unsigned int event_coal_div = 2;
|
||||
module_param(event_coal_div, int, 0664);
|
||||
MODULE_PARM_DESC(event_coal_div, "Event Coalescing Divide Factor");
|
||||
|
||||
unsigned int en_tcp_dack = 1;
|
||||
module_param(en_tcp_dack, int, 0664);
|
||||
MODULE_PARM_DESC(en_tcp_dack, "Enable TCP Delayed ACK");
|
||||
|
||||
unsigned int error_mask1 = 0x00;
|
||||
module_param(error_mask1, uint, 0664);
|
||||
MODULE_PARM_DESC(error_mask1, "Config FW iSCSI Error Mask #1");
|
||||
|
||||
unsigned int error_mask2 = 0x00;
|
||||
module_param(error_mask2, uint, 0664);
|
||||
MODULE_PARM_DESC(error_mask2, "Config FW iSCSI Error Mask #2");
|
||||
|
||||
unsigned int sq_size;
|
||||
module_param(sq_size, int, 0664);
|
||||
MODULE_PARM_DESC(sq_size, "Configure SQ size");
|
||||
|
||||
unsigned int rq_size = BNX2I_RQ_WQES_DEFAULT;
|
||||
module_param(rq_size, int, 0664);
|
||||
MODULE_PARM_DESC(rq_size, "Configure RQ size");
|
||||
|
||||
u64 iscsi_error_mask = 0x00;
|
||||
|
||||
DEFINE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu);
|
||||
|
||||
static int bnx2i_cpu_callback(struct notifier_block *nfb,
|
||||
unsigned long action, void *hcpu);
|
||||
/* notification function for CPU hotplug events */
|
||||
static struct notifier_block bnx2i_cpu_notifier = {
|
||||
.notifier_call = bnx2i_cpu_callback,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* bnx2i_identify_device - identifies NetXtreme II device type
|
||||
* @hba: Adapter structure pointer
|
||||
* @cnic: Corresponding cnic device
|
||||
*
|
||||
* This function identifies the NX2 device type and sets appropriate
|
||||
* queue mailbox register access method, 5709 requires driver to
|
||||
* access MBOX regs using *bin* mode
|
||||
*/
|
||||
void bnx2i_identify_device(struct bnx2i_hba *hba, struct cnic_dev *dev)
|
||||
{
|
||||
hba->cnic_dev_type = 0;
|
||||
if (test_bit(CNIC_F_BNX2_CLASS, &dev->flags)) {
|
||||
if (hba->pci_did == PCI_DEVICE_ID_NX2_5706 ||
|
||||
hba->pci_did == PCI_DEVICE_ID_NX2_5706S) {
|
||||
set_bit(BNX2I_NX2_DEV_5706, &hba->cnic_dev_type);
|
||||
} else if (hba->pci_did == PCI_DEVICE_ID_NX2_5708 ||
|
||||
hba->pci_did == PCI_DEVICE_ID_NX2_5708S) {
|
||||
set_bit(BNX2I_NX2_DEV_5708, &hba->cnic_dev_type);
|
||||
} else if (hba->pci_did == PCI_DEVICE_ID_NX2_5709 ||
|
||||
hba->pci_did == PCI_DEVICE_ID_NX2_5709S) {
|
||||
set_bit(BNX2I_NX2_DEV_5709, &hba->cnic_dev_type);
|
||||
hba->mail_queue_access = BNX2I_MQ_BIN_MODE;
|
||||
}
|
||||
} else if (test_bit(CNIC_F_BNX2X_CLASS, &dev->flags)) {
|
||||
set_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type);
|
||||
} else {
|
||||
printk(KERN_ALERT "bnx2i: unknown device, 0x%x\n",
|
||||
hba->pci_did);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get_adapter_list_head - returns head of adapter list
|
||||
*/
|
||||
struct bnx2i_hba *get_adapter_list_head(void)
|
||||
{
|
||||
struct bnx2i_hba *hba = NULL;
|
||||
struct bnx2i_hba *tmp_hba;
|
||||
|
||||
if (!adapter_count)
|
||||
goto hba_not_found;
|
||||
|
||||
mutex_lock(&bnx2i_dev_lock);
|
||||
list_for_each_entry(tmp_hba, &adapter_list, link) {
|
||||
if (tmp_hba->cnic && tmp_hba->cnic->cm_select_dev) {
|
||||
hba = tmp_hba;
|
||||
break;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&bnx2i_dev_lock);
|
||||
hba_not_found:
|
||||
return hba;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bnx2i_find_hba_for_cnic - maps cnic device instance to bnx2i adapter instance
|
||||
* @cnic: pointer to cnic device instance
|
||||
*
|
||||
*/
|
||||
struct bnx2i_hba *bnx2i_find_hba_for_cnic(struct cnic_dev *cnic)
|
||||
{
|
||||
struct bnx2i_hba *hba, *temp;
|
||||
|
||||
mutex_lock(&bnx2i_dev_lock);
|
||||
list_for_each_entry_safe(hba, temp, &adapter_list, link) {
|
||||
if (hba->cnic == cnic) {
|
||||
mutex_unlock(&bnx2i_dev_lock);
|
||||
return hba;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&bnx2i_dev_lock);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bnx2i_start - cnic callback to initialize & start adapter instance
|
||||
* @handle: transparent handle pointing to adapter structure
|
||||
*
|
||||
* This function maps adapter structure to pcidev structure and initiates
|
||||
* firmware handshake to enable/initialize on chip iscsi components
|
||||
* This bnx2i - cnic interface api callback is issued after following
|
||||
* 2 conditions are met -
|
||||
* a) underlying network interface is up (marked by event 'NETDEV_UP'
|
||||
* from netdev
|
||||
* b) bnx2i adapter instance is registered
|
||||
*/
|
||||
void bnx2i_start(void *handle)
|
||||
{
|
||||
#define BNX2I_INIT_POLL_TIME (1000 / HZ)
|
||||
struct bnx2i_hba *hba = handle;
|
||||
int i = HZ;
|
||||
|
||||
/* On some bnx2x devices, it is possible that iSCSI is no
|
||||
* longer supported after firmware is downloaded. In that
|
||||
* case, the iscsi_init_msg will return failure.
|
||||
*/
|
||||
|
||||
bnx2i_send_fw_iscsi_init_msg(hba);
|
||||
while (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state) &&
|
||||
!test_bit(ADAPTER_STATE_INIT_FAILED, &hba->adapter_state) && i--)
|
||||
msleep(BNX2I_INIT_POLL_TIME);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bnx2i_chip_cleanup - local routine to handle chip cleanup
|
||||
* @hba: Adapter instance to register
|
||||
*
|
||||
* Driver checks if adapter still has any active connections before
|
||||
* executing the cleanup process
|
||||
*/
|
||||
static void bnx2i_chip_cleanup(struct bnx2i_hba *hba)
|
||||
{
|
||||
struct bnx2i_endpoint *bnx2i_ep;
|
||||
struct list_head *pos, *tmp;
|
||||
|
||||
if (hba->ofld_conns_active) {
|
||||
/* Stage to force the disconnection
|
||||
* This is the case where the daemon is either slow or
|
||||
* not present
|
||||
*/
|
||||
printk(KERN_ALERT "bnx2i: (%s) chip cleanup for %d active "
|
||||
"connections\n", hba->netdev->name,
|
||||
hba->ofld_conns_active);
|
||||
mutex_lock(&hba->net_dev_lock);
|
||||
list_for_each_safe(pos, tmp, &hba->ep_active_list) {
|
||||
bnx2i_ep = list_entry(pos, struct bnx2i_endpoint, link);
|
||||
/* Clean up the chip only */
|
||||
bnx2i_hw_ep_disconnect(bnx2i_ep);
|
||||
bnx2i_ep->cm_sk = NULL;
|
||||
}
|
||||
mutex_unlock(&hba->net_dev_lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bnx2i_stop - cnic callback to shutdown adapter instance
|
||||
* @handle: transparent handle pointing to adapter structure
|
||||
*
|
||||
* driver checks if adapter is already in shutdown mode, if not start
|
||||
* the shutdown process
|
||||
*/
|
||||
void bnx2i_stop(void *handle)
|
||||
{
|
||||
struct bnx2i_hba *hba = handle;
|
||||
int conns_active;
|
||||
int wait_delay = 1 * HZ;
|
||||
|
||||
/* check if cleanup happened in GOING_DOWN context */
|
||||
if (!test_and_set_bit(ADAPTER_STATE_GOING_DOWN,
|
||||
&hba->adapter_state)) {
|
||||
iscsi_host_for_each_session(hba->shost,
|
||||
bnx2i_drop_session);
|
||||
wait_delay = hba->hba_shutdown_tmo;
|
||||
}
|
||||
/* Wait for inflight offload connection tasks to complete before
|
||||
* proceeding. Forcefully terminate all connection recovery in
|
||||
* progress at the earliest, either in bind(), send_pdu(LOGIN),
|
||||
* or conn_start()
|
||||
*/
|
||||
wait_event_interruptible_timeout(hba->eh_wait,
|
||||
(list_empty(&hba->ep_ofld_list) &&
|
||||
list_empty(&hba->ep_destroy_list)),
|
||||
2 * HZ);
|
||||
/* Wait for all endpoints to be torn down, Chip will be reset once
|
||||
* control returns to network driver. So it is required to cleanup and
|
||||
* release all connection resources before returning from this routine.
|
||||
*/
|
||||
while (hba->ofld_conns_active) {
|
||||
conns_active = hba->ofld_conns_active;
|
||||
wait_event_interruptible_timeout(hba->eh_wait,
|
||||
(hba->ofld_conns_active != conns_active),
|
||||
wait_delay);
|
||||
if (hba->ofld_conns_active == conns_active)
|
||||
break;
|
||||
}
|
||||
bnx2i_chip_cleanup(hba);
|
||||
|
||||
/* This flag should be cleared last so that ep_disconnect() gracefully
|
||||
* cleans up connection context
|
||||
*/
|
||||
clear_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state);
|
||||
clear_bit(ADAPTER_STATE_UP, &hba->adapter_state);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bnx2i_init_one - initialize an adapter instance and allocate memory resources
|
||||
* @hba: bnx2i adapter instance
|
||||
* @cnic: cnic device handle
|
||||
*
|
||||
* Global resource lock is held during critical sections below. This routine is
|
||||
* called from either cnic_register_driver() or device hot plug context and
|
||||
* and does majority of device specific initialization
|
||||
*/
|
||||
static int bnx2i_init_one(struct bnx2i_hba *hba, struct cnic_dev *cnic)
|
||||
{
|
||||
int rc;
|
||||
|
||||
mutex_lock(&bnx2i_dev_lock);
|
||||
if (!cnic->max_iscsi_conn) {
|
||||
printk(KERN_ALERT "bnx2i: dev %s does not support "
|
||||
"iSCSI\n", hba->netdev->name);
|
||||
rc = -EOPNOTSUPP;
|
||||
goto out;
|
||||
}
|
||||
|
||||
hba->cnic = cnic;
|
||||
rc = cnic->register_device(cnic, CNIC_ULP_ISCSI, hba);
|
||||
if (!rc) {
|
||||
hba->age++;
|
||||
set_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic);
|
||||
list_add_tail(&hba->link, &adapter_list);
|
||||
adapter_count++;
|
||||
} else if (rc == -EBUSY) /* duplicate registration */
|
||||
printk(KERN_ALERT "bnx2i, duplicate registration"
|
||||
"hba=%p, cnic=%p\n", hba, cnic);
|
||||
else if (rc == -EAGAIN)
|
||||
printk(KERN_ERR "bnx2i, driver not registered\n");
|
||||
else if (rc == -EINVAL)
|
||||
printk(KERN_ERR "bnx2i, invalid type %d\n", CNIC_ULP_ISCSI);
|
||||
else
|
||||
printk(KERN_ERR "bnx2i dev reg, unknown error, %d\n", rc);
|
||||
|
||||
out:
|
||||
mutex_unlock(&bnx2i_dev_lock);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bnx2i_ulp_init - initialize an adapter instance
|
||||
* @dev: cnic device handle
|
||||
*
|
||||
* Called from cnic_register_driver() context to initialize all enumerated
|
||||
* cnic devices. This routine allocate adapter structure and other
|
||||
* device specific resources.
|
||||
*/
|
||||
void bnx2i_ulp_init(struct cnic_dev *dev)
|
||||
{
|
||||
struct bnx2i_hba *hba;
|
||||
|
||||
/* Allocate a HBA structure for this device */
|
||||
hba = bnx2i_alloc_hba(dev);
|
||||
if (!hba) {
|
||||
printk(KERN_ERR "bnx2i init: hba initialization failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get PCI related information and update hba struct members */
|
||||
clear_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic);
|
||||
if (bnx2i_init_one(hba, dev)) {
|
||||
printk(KERN_ERR "bnx2i - hba %p init failed\n", hba);
|
||||
bnx2i_free_hba(hba);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bnx2i_ulp_exit - shuts down adapter instance and frees all resources
|
||||
* @dev: cnic device handle
|
||||
*
|
||||
*/
|
||||
void bnx2i_ulp_exit(struct cnic_dev *dev)
|
||||
{
|
||||
struct bnx2i_hba *hba;
|
||||
|
||||
hba = bnx2i_find_hba_for_cnic(dev);
|
||||
if (!hba) {
|
||||
printk(KERN_INFO "bnx2i_ulp_exit: hba not "
|
||||
"found, dev 0x%p\n", dev);
|
||||
return;
|
||||
}
|
||||
mutex_lock(&bnx2i_dev_lock);
|
||||
list_del_init(&hba->link);
|
||||
adapter_count--;
|
||||
|
||||
if (test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic)) {
|
||||
hba->cnic->unregister_device(hba->cnic, CNIC_ULP_ISCSI);
|
||||
clear_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic);
|
||||
}
|
||||
mutex_unlock(&bnx2i_dev_lock);
|
||||
|
||||
bnx2i_free_hba(hba);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bnx2i_get_stats - Retrieve various statistic from iSCSI offload
|
||||
* @handle: bnx2i_hba
|
||||
*
|
||||
* function callback exported via bnx2i - cnic driver interface to
|
||||
* retrieve various iSCSI offload related statistics.
|
||||
*/
|
||||
int bnx2i_get_stats(void *handle)
|
||||
{
|
||||
struct bnx2i_hba *hba = handle;
|
||||
struct iscsi_stats_info *stats;
|
||||
|
||||
if (!hba)
|
||||
return -EINVAL;
|
||||
|
||||
stats = (struct iscsi_stats_info *)hba->cnic->stats_addr;
|
||||
|
||||
if (!stats)
|
||||
return -ENOMEM;
|
||||
|
||||
strlcpy(stats->version, DRV_MODULE_VERSION, sizeof(stats->version));
|
||||
memcpy(stats->mac_add1 + 2, hba->cnic->mac_addr, ETH_ALEN);
|
||||
|
||||
stats->max_frame_size = hba->netdev->mtu;
|
||||
stats->txq_size = hba->max_sqes;
|
||||
stats->rxq_size = hba->max_cqes;
|
||||
|
||||
stats->txq_avg_depth = 0;
|
||||
stats->rxq_avg_depth = 0;
|
||||
|
||||
GET_STATS_64(hba, stats, rx_pdus);
|
||||
GET_STATS_64(hba, stats, rx_bytes);
|
||||
|
||||
GET_STATS_64(hba, stats, tx_pdus);
|
||||
GET_STATS_64(hba, stats, tx_bytes);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bnx2i_percpu_thread_create - Create a receive thread for an
|
||||
* online CPU
|
||||
*
|
||||
* @cpu: cpu index for the online cpu
|
||||
*/
|
||||
static void bnx2i_percpu_thread_create(unsigned int cpu)
|
||||
{
|
||||
struct bnx2i_percpu_s *p;
|
||||
struct task_struct *thread;
|
||||
|
||||
p = &per_cpu(bnx2i_percpu, cpu);
|
||||
|
||||
thread = kthread_create_on_node(bnx2i_percpu_io_thread, (void *)p,
|
||||
cpu_to_node(cpu),
|
||||
"bnx2i_thread/%d", cpu);
|
||||
/* bind thread to the cpu */
|
||||
if (likely(!IS_ERR(thread))) {
|
||||
kthread_bind(thread, cpu);
|
||||
p->iothread = thread;
|
||||
wake_up_process(thread);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void bnx2i_percpu_thread_destroy(unsigned int cpu)
|
||||
{
|
||||
struct bnx2i_percpu_s *p;
|
||||
struct task_struct *thread;
|
||||
struct bnx2i_work *work, *tmp;
|
||||
|
||||
/* Prevent any new work from being queued for this CPU */
|
||||
p = &per_cpu(bnx2i_percpu, cpu);
|
||||
spin_lock_bh(&p->p_work_lock);
|
||||
thread = p->iothread;
|
||||
p->iothread = NULL;
|
||||
|
||||
/* Free all work in the list */
|
||||
list_for_each_entry_safe(work, tmp, &p->work_list, list) {
|
||||
list_del_init(&work->list);
|
||||
bnx2i_process_scsi_cmd_resp(work->session,
|
||||
work->bnx2i_conn, &work->cqe);
|
||||
kfree(work);
|
||||
}
|
||||
|
||||
spin_unlock_bh(&p->p_work_lock);
|
||||
if (thread)
|
||||
kthread_stop(thread);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bnx2i_cpu_callback - Handler for CPU hotplug events
|
||||
*
|
||||
* @nfb: The callback data block
|
||||
* @action: The event triggering the callback
|
||||
* @hcpu: The index of the CPU that the event is for
|
||||
*
|
||||
* This creates or destroys per-CPU data for iSCSI
|
||||
*
|
||||
* Returns NOTIFY_OK always.
|
||||
*/
|
||||
static int bnx2i_cpu_callback(struct notifier_block *nfb,
|
||||
unsigned long action, void *hcpu)
|
||||
{
|
||||
unsigned cpu = (unsigned long)hcpu;
|
||||
|
||||
switch (action) {
|
||||
case CPU_ONLINE:
|
||||
case CPU_ONLINE_FROZEN:
|
||||
printk(KERN_INFO "bnx2i: CPU %x online: Create Rx thread\n",
|
||||
cpu);
|
||||
bnx2i_percpu_thread_create(cpu);
|
||||
break;
|
||||
case CPU_DEAD:
|
||||
case CPU_DEAD_FROZEN:
|
||||
printk(KERN_INFO "CPU %x offline: Remove Rx thread\n", cpu);
|
||||
bnx2i_percpu_thread_destroy(cpu);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NOTIFY_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bnx2i_mod_init - module init entry point
|
||||
*
|
||||
* initialize any driver wide global data structures such as endpoint pool,
|
||||
* tcp port manager/queue, sysfs. finally driver will register itself
|
||||
* with the cnic module
|
||||
*/
|
||||
static int __init bnx2i_mod_init(void)
|
||||
{
|
||||
int err;
|
||||
unsigned cpu = 0;
|
||||
struct bnx2i_percpu_s *p;
|
||||
|
||||
printk(KERN_INFO "%s", version);
|
||||
|
||||
if (sq_size && !is_power_of_2(sq_size))
|
||||
sq_size = roundup_pow_of_two(sq_size);
|
||||
|
||||
mutex_init(&bnx2i_dev_lock);
|
||||
|
||||
bnx2i_scsi_xport_template =
|
||||
iscsi_register_transport(&bnx2i_iscsi_transport);
|
||||
if (!bnx2i_scsi_xport_template) {
|
||||
printk(KERN_ERR "Could not register bnx2i transport.\n");
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
err = cnic_register_driver(CNIC_ULP_ISCSI, &bnx2i_cnic_cb);
|
||||
if (err) {
|
||||
printk(KERN_ERR "Could not register bnx2i cnic driver.\n");
|
||||
goto unreg_xport;
|
||||
}
|
||||
|
||||
/* Create percpu kernel threads to handle iSCSI I/O completions */
|
||||
for_each_possible_cpu(cpu) {
|
||||
p = &per_cpu(bnx2i_percpu, cpu);
|
||||
INIT_LIST_HEAD(&p->work_list);
|
||||
spin_lock_init(&p->p_work_lock);
|
||||
p->iothread = NULL;
|
||||
}
|
||||
|
||||
cpu_notifier_register_begin();
|
||||
|
||||
for_each_online_cpu(cpu)
|
||||
bnx2i_percpu_thread_create(cpu);
|
||||
|
||||
/* Initialize per CPU interrupt thread */
|
||||
__register_hotcpu_notifier(&bnx2i_cpu_notifier);
|
||||
|
||||
cpu_notifier_register_done();
|
||||
|
||||
return 0;
|
||||
|
||||
unreg_xport:
|
||||
iscsi_unregister_transport(&bnx2i_iscsi_transport);
|
||||
out:
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bnx2i_mod_exit - module cleanup/exit entry point
|
||||
*
|
||||
* Global resource lock and host adapter lock is held during critical sections
|
||||
* in this function. Driver will browse through the adapter list, cleans-up
|
||||
* each instance, unregisters iscsi transport name and finally driver will
|
||||
* unregister itself with the cnic module
|
||||
*/
|
||||
static void __exit bnx2i_mod_exit(void)
|
||||
{
|
||||
struct bnx2i_hba *hba;
|
||||
unsigned cpu = 0;
|
||||
|
||||
mutex_lock(&bnx2i_dev_lock);
|
||||
while (!list_empty(&adapter_list)) {
|
||||
hba = list_entry(adapter_list.next, struct bnx2i_hba, link);
|
||||
list_del(&hba->link);
|
||||
adapter_count--;
|
||||
|
||||
if (test_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic)) {
|
||||
bnx2i_chip_cleanup(hba);
|
||||
hba->cnic->unregister_device(hba->cnic, CNIC_ULP_ISCSI);
|
||||
clear_bit(BNX2I_CNIC_REGISTERED, &hba->reg_with_cnic);
|
||||
}
|
||||
|
||||
bnx2i_free_hba(hba);
|
||||
}
|
||||
mutex_unlock(&bnx2i_dev_lock);
|
||||
|
||||
cpu_notifier_register_begin();
|
||||
|
||||
for_each_online_cpu(cpu)
|
||||
bnx2i_percpu_thread_destroy(cpu);
|
||||
|
||||
__unregister_hotcpu_notifier(&bnx2i_cpu_notifier);
|
||||
|
||||
cpu_notifier_register_done();
|
||||
|
||||
iscsi_unregister_transport(&bnx2i_iscsi_transport);
|
||||
cnic_unregister_driver(CNIC_ULP_ISCSI);
|
||||
}
|
||||
|
||||
module_init(bnx2i_mod_init);
|
||||
module_exit(bnx2i_mod_exit);
|
2304
drivers/scsi/bnx2i/bnx2i_iscsi.c
Normal file
2304
drivers/scsi/bnx2i/bnx2i_iscsi.c
Normal file
File diff suppressed because it is too large
Load diff
145
drivers/scsi/bnx2i/bnx2i_sysfs.c
Normal file
145
drivers/scsi/bnx2i/bnx2i_sysfs.c
Normal file
|
@ -0,0 +1,145 @@
|
|||
/* bnx2i_sysfs.c: QLogic NetXtreme II iSCSI driver.
|
||||
*
|
||||
* Copyright (c) 2004 - 2013 Broadcom Corporation
|
||||
* Copyright (c) 2014, QLogic Corporation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
* Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
|
||||
* Previously Maintained by: Eddie Wai (eddie.wai@broadcom.com)
|
||||
* Maintained by: QLogic-Storage-Upstream@qlogic.com
|
||||
*/
|
||||
|
||||
#include "bnx2i.h"
|
||||
|
||||
/**
|
||||
* bnx2i_dev_to_hba - maps dev pointer to adapter struct
|
||||
* @dev: device pointer
|
||||
*
|
||||
* Map device to hba structure
|
||||
*/
|
||||
static inline struct bnx2i_hba *bnx2i_dev_to_hba(struct device *dev)
|
||||
{
|
||||
struct Scsi_Host *shost = class_to_shost(dev);
|
||||
return iscsi_host_priv(shost);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bnx2i_show_sq_info - return(s currently configured send queue (SQ) size
|
||||
* @dev: device pointer
|
||||
* @buf: buffer to return current SQ size parameter
|
||||
*
|
||||
* Returns current SQ size parameter, this paramater determines the number
|
||||
* outstanding iSCSI commands supported on a connection
|
||||
*/
|
||||
static ssize_t bnx2i_show_sq_info(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
|
||||
|
||||
return sprintf(buf, "0x%x\n", hba->max_sqes);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bnx2i_set_sq_info - update send queue (SQ) size parameter
|
||||
* @dev: device pointer
|
||||
* @buf: buffer to return current SQ size parameter
|
||||
* @count: parameter buffer size
|
||||
*
|
||||
* Interface for user to change shared queue size allocated for each conn
|
||||
* Must be within SQ limits and a power of 2. For the latter this is needed
|
||||
* because of how libiscsi preallocates tasks.
|
||||
*/
|
||||
static ssize_t bnx2i_set_sq_info(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
|
||||
u32 val;
|
||||
int max_sq_size;
|
||||
|
||||
if (hba->ofld_conns_active)
|
||||
goto skip_config;
|
||||
|
||||
if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type))
|
||||
max_sq_size = BNX2I_5770X_SQ_WQES_MAX;
|
||||
else
|
||||
max_sq_size = BNX2I_570X_SQ_WQES_MAX;
|
||||
|
||||
if (sscanf(buf, " 0x%x ", &val) > 0) {
|
||||
if ((val >= BNX2I_SQ_WQES_MIN) && (val <= max_sq_size) &&
|
||||
(is_power_of_2(val)))
|
||||
hba->max_sqes = val;
|
||||
}
|
||||
|
||||
return count;
|
||||
|
||||
skip_config:
|
||||
printk(KERN_ERR "bnx2i: device busy, cannot change SQ size\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bnx2i_show_ccell_info - returns command cell (HQ) size
|
||||
* @dev: device pointer
|
||||
* @buf: buffer to return current SQ size parameter
|
||||
*
|
||||
* returns per-connection TCP history queue size parameter
|
||||
*/
|
||||
static ssize_t bnx2i_show_ccell_info(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
|
||||
|
||||
return sprintf(buf, "0x%x\n", hba->num_ccell);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bnx2i_get_link_state - set command cell (HQ) size
|
||||
* @dev: device pointer
|
||||
* @buf: buffer to return current SQ size parameter
|
||||
* @count: parameter buffer size
|
||||
*
|
||||
* updates per-connection TCP history queue size parameter
|
||||
*/
|
||||
static ssize_t bnx2i_set_ccell_info(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
u32 val;
|
||||
struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
|
||||
|
||||
if (hba->ofld_conns_active)
|
||||
goto skip_config;
|
||||
|
||||
if (sscanf(buf, " 0x%x ", &val) > 0) {
|
||||
if ((val >= BNX2I_CCELLS_MIN) &&
|
||||
(val <= BNX2I_CCELLS_MAX)) {
|
||||
hba->num_ccell = val;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
|
||||
skip_config:
|
||||
printk(KERN_ERR "bnx2i: device busy, cannot change CCELL size\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static DEVICE_ATTR(sq_size, S_IRUGO | S_IWUSR,
|
||||
bnx2i_show_sq_info, bnx2i_set_sq_info);
|
||||
static DEVICE_ATTR(num_ccell, S_IRUGO | S_IWUSR,
|
||||
bnx2i_show_ccell_info, bnx2i_set_ccell_info);
|
||||
|
||||
struct device_attribute *bnx2i_dev_attributes[] = {
|
||||
&dev_attr_sq_size,
|
||||
&dev_attr_num_ccell,
|
||||
NULL
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue