Bug

[В начало]

Ошибка # 105

Показать/спрятать трассу ошибок
Error trace
Function bodies
Blocks
  • Others...
    Function bodies without model function calls
    Initialization function calls
    Initialization function bodies
    Entry point
    Entry point body
    Function calls
    Skipped function calls
    Formal parameter names
    Declarations
    Assumes
    Assume conditions
    Returns
    Return values
    DEG initialization
    DEG function calls
    Model function calls
    Model function bodies
    Model asserts
    Model state changes
    Model function function calls
    Model function function bodies
    Model returns
    Model others
    Identation
    Line numbers
    Expand signs
-entry_point
{
7269 ldv_s_beiscsi_pci_driver_pci_driver = 0;
7171 LDV_IN_INTERRUPT = 1;
7180 +ldv_initialize()
7260 ldv_handler_precall() { /* Function call is skipped due to function is undefined */}
7261 +beiscsi_module_init()
7261 assume(!(tmp != 0));
7275 goto ldv_53267;
7275 tmp___1 = nondet_int() { /* Function call is skipped due to function is undefined */}
7275 assume(tmp___1 != 0);
7278 goto ldv_53266;
7276 ldv_53266:;
7279 tmp___0 = nondet_int() { /* Function call is skipped due to function is undefined */}
7279 switch (tmp___0)
7280 assume(!(tmp___0 == 0));
7372 assume(!(tmp___0 == 1));
7463 assume(!(tmp___0 == 2));
7554 assume(!(tmp___0 == 3));
7645 assume(!(tmp___0 == 4));
7736 assume(!(tmp___0 == 5));
7827 assume(tmp___0 == 6);
7909 ldv_handler_precall() { /* Function call is skipped due to function is undefined */}
7910 -beiscsi_task_xmit(var_group4)
{
5062 struct beiscsi_io_task *__CPAchecker_TMP_0 = (struct beiscsi_io_task *)(task->dd_data);
5062 io_task = __CPAchecker_TMP_0;
5063 sc = task->sc;
5064 phba = (struct beiscsi_hba *)0;
5067 writedir = 0U;
5067 xferlen = 0U;
5069 struct beiscsi_conn *__CPAchecker_TMP_1 = (struct beiscsi_conn *)(task->conn->dd_data);
5069 phba = __CPAchecker_TMP_1->phba;
5071 assume(((unsigned long)sc) == ((unsigned long)((struct scsi_cmnd *)0)));
5072 -beiscsi_mtask(task)
{
4959 struct beiscsi_io_task *__CPAchecker_TMP_0 = (struct beiscsi_io_task *)(task->dd_data);
4959 io_task = __CPAchecker_TMP_0;
4960 conn = task->conn;
4961 struct beiscsi_conn *__CPAchecker_TMP_1 = (struct beiscsi_conn *)(conn->dd_data);
4961 beiscsi_conn = __CPAchecker_TMP_1;
4962 phba = beiscsi_conn->phba;
4963 pwrb = (struct iscsi_wrb *)0;
4964 doorbell = 0U;
4966 pwrb_typeoffset = 0U;
4968 cid = beiscsi_conn->beiscsi_conn_cid;
4969 pwrb = io_task->pwrb_handle->pwrb;
4970 memset((void *)pwrb, 0, 64UL) { /* Function call is skipped due to function is undefined */}
4972 assume(!((phba->generation) == 3U));
4972 assume(!((phba->generation) == 2U));
4985 +__fswab32(task->cmdsn)
4985 +amap_mask(32U)
4985 +amap_set((void *)pwrb, 7U, tmp___6, 0U, tmp___5)
4987 +amap_mask(8U)
4987 u32 __CPAchecker_TMP_4 = (u32 )(io_task->pwrb_handle->wrb_index);
4987 +amap_set((void *)pwrb, 1U, tmp___7, 8U, __CPAchecker_TMP_4)
4989 +amap_mask(16U)
4989 +amap_set((void *)pwrb, 2U, tmp___8, 0U, io_task->psgl_handle->sgl_index)
4991 +amap_mask(25U)
4991 +amap_set((void *)pwrb, 0U, tmp___9, 0U, task->data_count)
4993 +amap_mask(8U)
4993 u32 __CPAchecker_TMP_5 = (u32 )(io_task->pwrb_handle->nxt_wrb_index);
4993 +amap_set((void *)pwrb, 1U, tmp___10, 0U, __CPAchecker_TMP_5)
4995 pwrb_typeoffset = 27U;
4999 int __CPAchecker_TMP_6 = (int)(task->hdr->opcode);
4999 switch (__CPAchecker_TMP_6 & 63)
5000 assume((__CPAchecker_TMP_6 & 63) == 3);
5001 +amap_mask(32U)
5001 +amap_set((void *)pwrb, 6U, tmp___11, 0U, 1U)
5002 (pwrb->dw)[0] = ((pwrb->dw)[0]) | ((u32 )(11 << ((int)pwrb_typeoffset)));
5003 -hwi_write_buffer(pwrb, task)
{
2498 struct beiscsi_io_task *__CPAchecker_TMP_0 = (struct beiscsi_io_task *)(task->dd_data);
2498 io_task = __CPAchecker_TMP_0;
2499 beiscsi_conn = io_task->conn;
2500 phba = beiscsi_conn->phba;
2501 dsp_value = 0U;
2503 io_task->bhs_len = 322U;
2504 +amap_mask(32U)
2504 +amap_set((void *)pwrb, 5U, tmp, 0U, io_task->bhs_pa.u.a32.address_lo)
2506 +amap_mask(32U)
2506 +amap_set((void *)pwrb, 4U, tmp___0, 0U, io_task->bhs_pa.u.a32.address_hi)
2509 unsigned long __CPAchecker_TMP_1 = (unsigned long)(task->data);
2509 assume(__CPAchecker_TMP_1 != ((unsigned long)((char *)0)));
2512 dsp_value = (task->data_count) != 0U;
2514 assume(!((phba->generation) == 3U));
2514 assume((phba->generation) == 2U);
2515 +amap_mask(1U)
2515 +amap_set((void *)pwrb, 0U, tmp___1, 24U, (u32 )dsp_value)
2522 assume(((unsigned int)dsp_value) != 0U);
2523 void *__CPAchecker_TMP_2 = (void *)(task->data);
2523 size_t __CPAchecker_TMP_3 = (size_t )(task->data_count);
2523 -pci_map_single(phba->pcidev, __CPAchecker_TMP_2, __CPAchecker_TMP_3, 1)
{
32 assume(((unsigned long)hwdev) != ((unsigned long)((struct pci_dev *)0)));
32 __CPAchecker_TMP_0 = &(hwdev->dev);
32 -ldv_dma_map_single_attrs_5(__CPAchecker_TMP_0, ptr, size, (enum dma_data_direction )direction, (struct dma_attrs *)0)
{
13 -ldv_dma_map_single_attrs(dev, ptr, size, dir, attrs)
{
58 tmp = ldv_undef_ptr() { /* Function call is skipped due to function is undefined */}
58 nonedetermined = (dma_addr_t )tmp;
61 assume(!(LDV_DMA_MAP_CALLS != 0));
63 LDV_DMA_MAP_CALLS = LDV_DMA_MAP_CALLS + 1;
65 return nonedetermined;;
}
13 return tmp;;
}
32 return tmp;;
}
2527 io_task->mtask_data_count = task->data_count;
2531 +amap_mask(32U)
2531 unsigned int __CPAchecker_TMP_4 = (unsigned int)(io_task->mtask_addr);
2531 +amap_set((void *)pwrb, 9U, tmp___3, 0U, __CPAchecker_TMP_4)
2533 +amap_mask(32U)
2533 +amap_set((void *)pwrb, 8U, tmp___4, 0U, (unsigned int)((io_task->mtask_addr) >> 32ULL))
2535 +amap_mask(17U)
2535 +amap_set((void *)pwrb, 11U, tmp___5, 0U, task->data_count)
2538 +amap_mask(1U)
2538 +amap_set((void *)pwrb, 10U, tmp___6, 31U, 1U)
2544 psgl = io_task->psgl_handle->pfrag;
2546 +amap_mask(17U)
2546 u32 __CPAchecker_TMP_5 = (u32 )(io_task->bhs_len);
2546 +amap_set((void *)psgl, 3U, tmp___8, 0U, __CPAchecker_TMP_5)
2548 +amap_mask(32U)
2548 +amap_set((void *)psgl, 0U, tmp___9, 0U, io_task->bhs_pa.u.a32.address_hi)
2550 +amap_mask(32U)
2550 +amap_set((void *)psgl, 1U, tmp___10, 0U, io_task->bhs_pa.u.a32.address_lo)
2552 unsigned long __CPAchecker_TMP_6 = (unsigned long)(task->data);
2552 assume(__CPAchecker_TMP_6 != ((unsigned long)((char *)0)));
2553 psgl = psgl + 1;
2554 +amap_mask(32U)
2554 +amap_set((void *)psgl, 0U, tmp___11, 0U, 0U)
2555 +amap_mask(32U)
2555 +amap_set((void *)psgl, 1U, tmp___12, 0U, 0U)
2556 +amap_mask(17U)
2556 +amap_set((void *)psgl, 3U, tmp___13, 0U, 0U)
2557 +amap_mask(22U)
2557 +amap_set((void *)psgl, 2U, tmp___14, 0U, 0U)
2558 +amap_mask(9U)
2558 +amap_set((void *)psgl, 2U, tmp___15, 22U, 0U)
2559 +amap_mask(1U)
2559 +amap_set((void *)psgl, 2U, tmp___16, 31U, 0U)
2561 psgl = psgl + 1;
2562 unsigned long __CPAchecker_TMP_7 = (unsigned long)(task->data);
2562 assume(__CPAchecker_TMP_7 != ((unsigned long)((char *)0)));
2563 +amap_mask(32U)
2563 unsigned int __CPAchecker_TMP_8 = (unsigned int)(io_task->mtask_addr);
2563 +amap_set((void *)psgl, 1U, tmp___17, 0U, __CPAchecker_TMP_8)
2565 +amap_mask(32U)
2565 +amap_set((void *)psgl, 0U, tmp___18, 0U, (unsigned int)((io_task->mtask_addr) >> 32ULL))
2568 +amap_mask(17U)
2568 +amap_set((void *)psgl, 3U, tmp___19, 0U, 262U)
2570 +amap_mask(1U)
2570 +amap_set((void *)psgl, 2U, tmp___20, 31U, 1U)
2571 return ;;
}
5004 goto ldv_52987;
5045 ldv_52987:;
5047 assume(!((phba->generation) == 3U));
5047 assume(!((phba->generation) == 2U));
5047 +amap_mask(5U)
5047 +amap_get((void *)pwrb, 0U, tmp___18, 27U)
5047 io_task->wrb_type = (uint8_t )tmp___19;
5051 doorbell = (cid & 65535U) | doorbell;
5052 int __CPAchecker_TMP_8 = (int)(io_task->pwrb_handle->wrb_index);
5052 doorbell = ((unsigned int)((__CPAchecker_TMP_8 & 255) << 16)) | doorbell;
5054 doorbell = doorbell | 16777216U;
5055 void *__CPAchecker_TMP_9 = (void *)(phba->db_va);
5055 unsigned long __CPAchecker_TMP_10 = (unsigned long)(beiscsi_conn->doorbell_offset);
5055 iowrite32(doorbell, __CPAchecker_TMP_9 + __CPAchecker_TMP_10) { /* Function call is skipped due to function is undefined */}
5057 return 0;;
}
5072 return tmp;;
}
7917 goto ldv_53247;
8833 ldv_53247:;
8834 ldv_53267:;
7275 tmp___1 = nondet_int() { /* Function call is skipped due to function is undefined */}
7275 assume(tmp___1 != 0);
7278 goto ldv_53266;
7276 ldv_53266:;
7279 tmp___0 = nondet_int() { /* Function call is skipped due to function is undefined */}
7279 switch (tmp___0)
7280 assume(!(tmp___0 == 0));
7372 assume(!(tmp___0 == 1));
7463 assume(!(tmp___0 == 2));
7554 assume(!(tmp___0 == 3));
7645 assume(!(tmp___0 == 4));
7736 assume(!(tmp___0 == 5));
7827 assume(tmp___0 == 6);
7909 ldv_handler_precall() { /* Function call is skipped due to function is undefined */}
7910 -beiscsi_task_xmit(var_group4)
{
5062 struct beiscsi_io_task *__CPAchecker_TMP_0 = (struct beiscsi_io_task *)(task->dd_data);
5062 io_task = __CPAchecker_TMP_0;
5063 sc = task->sc;
5064 phba = (struct beiscsi_hba *)0;
5067 writedir = 0U;
5067 xferlen = 0U;
5069 struct beiscsi_conn *__CPAchecker_TMP_1 = (struct beiscsi_conn *)(task->conn->dd_data);
5069 phba = __CPAchecker_TMP_1->phba;
5071 assume(((unsigned long)sc) == ((unsigned long)((struct scsi_cmnd *)0)));
5072 -beiscsi_mtask(task)
{
4959 struct beiscsi_io_task *__CPAchecker_TMP_0 = (struct beiscsi_io_task *)(task->dd_data);
4959 io_task = __CPAchecker_TMP_0;
4960 conn = task->conn;
4961 struct beiscsi_conn *__CPAchecker_TMP_1 = (struct beiscsi_conn *)(conn->dd_data);
4961 beiscsi_conn = __CPAchecker_TMP_1;
4962 phba = beiscsi_conn->phba;
4963 pwrb = (struct iscsi_wrb *)0;
4964 doorbell = 0U;
4966 pwrb_typeoffset = 0U;
4968 cid = beiscsi_conn->beiscsi_conn_cid;
4969 pwrb = io_task->pwrb_handle->pwrb;
4970 memset((void *)pwrb, 0, 64UL) { /* Function call is skipped due to function is undefined */}
4972 assume(!((phba->generation) == 3U));
4972 assume(!((phba->generation) == 2U));
4985 +__fswab32(task->cmdsn)
4985 +amap_mask(32U)
4985 +amap_set((void *)pwrb, 7U, tmp___6, 0U, tmp___5)
4987 +amap_mask(8U)
4987 u32 __CPAchecker_TMP_4 = (u32 )(io_task->pwrb_handle->wrb_index);
4987 +amap_set((void *)pwrb, 1U, tmp___7, 8U, __CPAchecker_TMP_4)
4989 +amap_mask(16U)
4989 +amap_set((void *)pwrb, 2U, tmp___8, 0U, io_task->psgl_handle->sgl_index)
4991 +amap_mask(25U)
4991 +amap_set((void *)pwrb, 0U, tmp___9, 0U, task->data_count)
4993 +amap_mask(8U)
4993 u32 __CPAchecker_TMP_5 = (u32 )(io_task->pwrb_handle->nxt_wrb_index);
4993 +amap_set((void *)pwrb, 1U, tmp___10, 0U, __CPAchecker_TMP_5)
4995 pwrb_typeoffset = 27U;
4999 int __CPAchecker_TMP_6 = (int)(task->hdr->opcode);
4999 switch (__CPAchecker_TMP_6 & 63)
5000 assume(!((__CPAchecker_TMP_6 & 63) == 3));
5005 assume(!((__CPAchecker_TMP_6 & 63) == 0));
5025 assume(!((__CPAchecker_TMP_6 & 63) == 4));
5029 assume(!((__CPAchecker_TMP_6 & 63) == 2));
5033 assume((__CPAchecker_TMP_6 & 63) == 6);
5034 (pwrb->dw)[0] = ((pwrb->dw)[0]) | ((u32 )(2 << ((int)pwrb_typeoffset)));
5035 -hwi_write_buffer(pwrb, task)
{
2498 struct beiscsi_io_task *__CPAchecker_TMP_0 = (struct beiscsi_io_task *)(task->dd_data);
2498 io_task = __CPAchecker_TMP_0;
2499 beiscsi_conn = io_task->conn;
2500 phba = beiscsi_conn->phba;
2501 dsp_value = 0U;
2503 io_task->bhs_len = 322U;
2504 +amap_mask(32U)
2504 +amap_set((void *)pwrb, 5U, tmp, 0U, io_task->bhs_pa.u.a32.address_lo)
2506 +amap_mask(32U)
2506 +amap_set((void *)pwrb, 4U, tmp___0, 0U, io_task->bhs_pa.u.a32.address_hi)
2509 unsigned long __CPAchecker_TMP_1 = (unsigned long)(task->data);
2509 assume(__CPAchecker_TMP_1 != ((unsigned long)((char *)0)));
2512 dsp_value = (task->data_count) != 0U;
2514 assume(!((phba->generation) == 3U));
2514 assume(!((phba->generation) == 2U));
2518 +amap_mask(1U)
2518 +amap_set((void *)pwrb, 11U, tmp___2, 28U, (u32 )dsp_value)
2522 assume(((unsigned int)dsp_value) != 0U);
2523 void *__CPAchecker_TMP_2 = (void *)(task->data);
2523 size_t __CPAchecker_TMP_3 = (size_t )(task->data_count);
2523 -pci_map_single(phba->pcidev, __CPAchecker_TMP_2, __CPAchecker_TMP_3, 1)
{
32 assume(((unsigned long)hwdev) != ((unsigned long)((struct pci_dev *)0)));
32 __CPAchecker_TMP_0 = &(hwdev->dev);
32 -ldv_dma_map_single_attrs_5(__CPAchecker_TMP_0, ptr, size, (enum dma_data_direction )direction, (struct dma_attrs *)0)
{
13 -ldv_dma_map_single_attrs(dev, ptr, size, dir, attrs)
{
58 tmp = ldv_undef_ptr() { /* Function call is skipped due to function is undefined */}
58 nonedetermined = (dma_addr_t )tmp;
61 assume(LDV_DMA_MAP_CALLS != 0);
61 +ldv_error()
}
}
}
}
}
}
}
Source code
1 2 /** 3 * Copyright (C) 2005 - 2013 Emulex 4 * All rights reserved. 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License version 2 8 * as published by the Free Software Foundation. The full GNU General 9 * Public License is included in this distribution in the file called COPYING. 10 * 11 * Written by: Jayamohan Kallickal (jayamohan.kallickal@emulex.com) 12 * 13 * Contact Information: 14 * linux-drivers@emulex.com 15 * 16 * Emulex 17 * 3333 Susan Street 18 * Costa Mesa, CA 92626 19 */ 20 21 #include <linux/reboot.h> 22 #include <linux/delay.h> 23 #include <linux/slab.h> 24 #include <linux/interrupt.h> 25 #include <linux/blkdev.h> 26 #include <linux/pci.h> 27 #include <linux/string.h> 28 #include <linux/kernel.h> 29 #include <linux/semaphore.h> 30 #include <linux/iscsi_boot_sysfs.h> 31 #include <linux/module.h> 32 #include <linux/bsg-lib.h> 33 34 #include <scsi/libiscsi.h> 35 #include <scsi/scsi_bsg_iscsi.h> 36 #include <scsi/scsi_netlink.h> 37 #include <scsi/scsi_transport_iscsi.h> 38 #include <scsi/scsi_transport.h> 39 #include <scsi/scsi_cmnd.h> 40 #include <scsi/scsi_device.h> 41 #include <scsi/scsi_host.h> 42 #include <scsi/scsi.h> 43 #include "be_main.h" 44 #include "be_iscsi.h" 45 #include "be_mgmt.h" 46 #include "be_cmds.h" 47 48 static unsigned int be_iopoll_budget = 10; 49 static unsigned int be_max_phys_size = 64; 50 static unsigned int enable_msix = 1; 51 52 MODULE_DEVICE_TABLE(pci, beiscsi_pci_id_table); 53 MODULE_DESCRIPTION(DRV_DESC " " BUILD_STR); 54 MODULE_VERSION(BUILD_STR); 55 MODULE_AUTHOR("Emulex Corporation"); 56 MODULE_LICENSE("GPL"); 57 module_param(be_iopoll_budget, int, 0); 58 module_param(enable_msix, int, 0); 59 module_param(be_max_phys_size, uint, S_IRUGO); 60 MODULE_PARM_DESC(be_max_phys_size, 61 "Maximum Size (In Kilobytes) of physically contiguous " 62 "memory that can be allocated. Range is 16 - 128"); 63 64 #define beiscsi_disp_param(_name)\ 65 ssize_t \ 66 beiscsi_##_name##_disp(struct device *dev,\ 67 struct device_attribute *attrib, char *buf) \ 68 { \ 69 struct Scsi_Host *shost = class_to_shost(dev);\ 70 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 71 uint32_t param_val = 0; \ 72 param_val = phba->attr_##_name;\ 73 return snprintf(buf, PAGE_SIZE, "%d\n",\ 74 phba->attr_##_name);\ 75 } 76 77 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 78 int \ 79 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 80 {\ 81 if (val >= _minval && val <= _maxval) {\ 82 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 83 "BA_%d : beiscsi_"#_name" updated "\ 84 "from 0x%x ==> 0x%x\n",\ 85 phba->attr_##_name, val); \ 86 phba->attr_##_name = val;\ 87 return 0;\ 88 } \ 89 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 90 "BA_%d beiscsi_"#_name" attribute "\ 91 "cannot be updated to 0x%x, "\ 92 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 93 return -EINVAL;\ 94 } 95 96 #define beiscsi_store_param(_name) \ 97 ssize_t \ 98 beiscsi_##_name##_store(struct device *dev,\ 99 struct device_attribute *attr, const char *buf,\ 100 size_t count) \ 101 { \ 102 struct Scsi_Host *shost = class_to_shost(dev);\ 103 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 104 uint32_t param_val = 0;\ 105 if (!isdigit(buf[0]))\ 106 return -EINVAL;\ 107 if (sscanf(buf, "%i", &param_val) != 1)\ 108 return -EINVAL;\ 109 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 110 return strlen(buf);\ 111 else \ 112 return -EINVAL;\ 113 } 114 115 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 116 int \ 117 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 118 { \ 119 if (val >= _minval && val <= _maxval) {\ 120 phba->attr_##_name = val;\ 121 return 0;\ 122 } \ 123 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 124 "BA_%d beiscsi_"#_name" attribute " \ 125 "cannot be updated to 0x%x, "\ 126 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 127 phba->attr_##_name = _defval;\ 128 return -EINVAL;\ 129 } 130 131 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 132 static uint beiscsi_##_name = _defval;\ 133 module_param(beiscsi_##_name, uint, S_IRUGO);\ 134 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 135 beiscsi_disp_param(_name)\ 136 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 137 beiscsi_store_param(_name)\ 138 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 139 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 140 beiscsi_##_name##_disp, beiscsi_##_name##_store) 141 142 /* 143 * When new log level added update the 144 * the MAX allowed value for log_enable 145 */ 146 BEISCSI_RW_ATTR(log_enable, 0x00, 147 0xFF, 0x00, "Enable logging Bit Mask\n" 148 "\t\t\t\tInitialization Events : 0x01\n" 149 "\t\t\t\tMailbox Events : 0x02\n" 150 "\t\t\t\tMiscellaneous Events : 0x04\n" 151 "\t\t\t\tError Handling : 0x08\n" 152 "\t\t\t\tIO Path Events : 0x10\n" 153 "\t\t\t\tConfiguration Path : 0x20\n" 154 "\t\t\t\tiSCSI Protocol : 0x40\n"); 155 156 DEVICE_ATTR(beiscsi_drvr_ver, S_IRUGO, beiscsi_drvr_ver_disp, NULL); 157 DEVICE_ATTR(beiscsi_adapter_family, S_IRUGO, beiscsi_adap_family_disp, NULL); 158 DEVICE_ATTR(beiscsi_fw_ver, S_IRUGO, beiscsi_fw_ver_disp, NULL); 159 DEVICE_ATTR(beiscsi_phys_port, S_IRUGO, beiscsi_phys_port_disp, NULL); 160 DEVICE_ATTR(beiscsi_active_session_count, S_IRUGO, 161 beiscsi_active_session_disp, NULL); 162 DEVICE_ATTR(beiscsi_free_session_count, S_IRUGO, 163 beiscsi_free_session_disp, NULL); 164 struct device_attribute *beiscsi_attrs[] = { 165 &dev_attr_beiscsi_log_enable, 166 &dev_attr_beiscsi_drvr_ver, 167 &dev_attr_beiscsi_adapter_family, 168 &dev_attr_beiscsi_fw_ver, 169 &dev_attr_beiscsi_active_session_count, 170 &dev_attr_beiscsi_free_session_count, 171 &dev_attr_beiscsi_phys_port, 172 NULL, 173 }; 174 175 static char const *cqe_desc[] = { 176 "RESERVED_DESC", 177 "SOL_CMD_COMPLETE", 178 "SOL_CMD_KILLED_DATA_DIGEST_ERR", 179 "CXN_KILLED_PDU_SIZE_EXCEEDS_DSL", 180 "CXN_KILLED_BURST_LEN_MISMATCH", 181 "CXN_KILLED_AHS_RCVD", 182 "CXN_KILLED_HDR_DIGEST_ERR", 183 "CXN_KILLED_UNKNOWN_HDR", 184 "CXN_KILLED_STALE_ITT_TTT_RCVD", 185 "CXN_KILLED_INVALID_ITT_TTT_RCVD", 186 "CXN_KILLED_RST_RCVD", 187 "CXN_KILLED_TIMED_OUT", 188 "CXN_KILLED_RST_SENT", 189 "CXN_KILLED_FIN_RCVD", 190 "CXN_KILLED_BAD_UNSOL_PDU_RCVD", 191 "CXN_KILLED_BAD_WRB_INDEX_ERROR", 192 "CXN_KILLED_OVER_RUN_RESIDUAL", 193 "CXN_KILLED_UNDER_RUN_RESIDUAL", 194 "CMD_KILLED_INVALID_STATSN_RCVD", 195 "CMD_KILLED_INVALID_R2T_RCVD", 196 "CMD_CXN_KILLED_LUN_INVALID", 197 "CMD_CXN_KILLED_ICD_INVALID", 198 "CMD_CXN_KILLED_ITT_INVALID", 199 "CMD_CXN_KILLED_SEQ_OUTOFORDER", 200 "CMD_CXN_KILLED_INVALID_DATASN_RCVD", 201 "CXN_INVALIDATE_NOTIFY", 202 "CXN_INVALIDATE_INDEX_NOTIFY", 203 "CMD_INVALIDATED_NOTIFY", 204 "UNSOL_HDR_NOTIFY", 205 "UNSOL_DATA_NOTIFY", 206 "UNSOL_DATA_DIGEST_ERROR_NOTIFY", 207 "DRIVERMSG_NOTIFY", 208 "CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN", 209 "SOL_CMD_KILLED_DIF_ERR", 210 "CXN_KILLED_SYN_RCVD", 211 "CXN_KILLED_IMM_DATA_RCVD" 212 }; 213 214 static int beiscsi_slave_configure(struct scsi_device *sdev) 215 { 216 blk_queue_max_segment_size(sdev->request_queue, 65536); 217 return 0; 218 } 219 220 static int beiscsi_eh_abort(struct scsi_cmnd *sc) 221 { 222 struct iscsi_cls_session *cls_session; 223 struct iscsi_task *aborted_task = (struct iscsi_task *)sc->SCp.ptr; 224 struct beiscsi_io_task *aborted_io_task; 225 struct iscsi_conn *conn; 226 struct beiscsi_conn *beiscsi_conn; 227 struct beiscsi_hba *phba; 228 struct iscsi_session *session; 229 struct invalidate_command_table *inv_tbl; 230 struct be_dma_mem nonemb_cmd; 231 unsigned int cid, tag, num_invalidate; 232 233 cls_session = starget_to_session(scsi_target(sc->device)); 234 session = cls_session->dd_data; 235 236 spin_lock_bh(&session->lock); 237 if (!aborted_task || !aborted_task->sc) { 238 /* we raced */ 239 spin_unlock_bh(&session->lock); 240 return SUCCESS; 241 } 242 243 aborted_io_task = aborted_task->dd_data; 244 if (!aborted_io_task->scsi_cmnd) { 245 /* raced or invalid command */ 246 spin_unlock_bh(&session->lock); 247 return SUCCESS; 248 } 249 spin_unlock_bh(&session->lock); 250 /* Invalidate WRB Posted for this Task */ 251 AMAP_SET_BITS(struct amap_iscsi_wrb, invld, 252 aborted_io_task->pwrb_handle->pwrb, 253 1); 254 255 conn = aborted_task->conn; 256 beiscsi_conn = conn->dd_data; 257 phba = beiscsi_conn->phba; 258 259 /* invalidate iocb */ 260 cid = beiscsi_conn->beiscsi_conn_cid; 261 inv_tbl = phba->inv_tbl; 262 memset(inv_tbl, 0x0, sizeof(*inv_tbl)); 263 inv_tbl->cid = cid; 264 inv_tbl->icd = aborted_io_task->psgl_handle->sgl_index; 265 num_invalidate = 1; 266 nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev, 267 sizeof(struct invalidate_commands_params_in), 268 &nonemb_cmd.dma); 269 if (nonemb_cmd.va == NULL) { 270 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH, 271 "BM_%d : Failed to allocate memory for" 272 "mgmt_invalidate_icds\n"); 273 return FAILED; 274 } 275 nonemb_cmd.size = sizeof(struct invalidate_commands_params_in); 276 277 tag = mgmt_invalidate_icds(phba, inv_tbl, num_invalidate, 278 cid, &nonemb_cmd); 279 if (!tag) { 280 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_EH, 281 "BM_%d : mgmt_invalidate_icds could not be" 282 "submitted\n"); 283 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, 284 nonemb_cmd.va, nonemb_cmd.dma); 285 286 return FAILED; 287 } 288 289 beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd.va); 290 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, 291 nonemb_cmd.va, nonemb_cmd.dma); 292 return iscsi_eh_abort(sc); 293 } 294 295 static int beiscsi_eh_device_reset(struct scsi_cmnd *sc) 296 { 297 struct iscsi_task *abrt_task; 298 struct beiscsi_io_task *abrt_io_task; 299 struct iscsi_conn *conn; 300 struct beiscsi_conn *beiscsi_conn; 301 struct beiscsi_hba *phba; 302 struct iscsi_session *session; 303 struct iscsi_cls_session *cls_session; 304 struct invalidate_command_table *inv_tbl; 305 struct be_dma_mem nonemb_cmd; 306 unsigned int cid, tag, i, num_invalidate; 307 308 /* invalidate iocbs */ 309 cls_session = starget_to_session(scsi_target(sc->device)); 310 session = cls_session->dd_data; 311 spin_lock_bh(&session->lock); 312 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN) { 313 spin_unlock_bh(&session->lock); 314 return FAILED; 315 } 316 conn = session->leadconn; 317 beiscsi_conn = conn->dd_data; 318 phba = beiscsi_conn->phba; 319 cid = beiscsi_conn->beiscsi_conn_cid; 320 inv_tbl = phba->inv_tbl; 321 memset(inv_tbl, 0x0, sizeof(*inv_tbl) * BE2_CMDS_PER_CXN); 322 num_invalidate = 0; 323 for (i = 0; i < conn->session->cmds_max; i++) { 324 abrt_task = conn->session->cmds[i]; 325 abrt_io_task = abrt_task->dd_data; 326 if (!abrt_task->sc || abrt_task->state == ISCSI_TASK_FREE) 327 continue; 328 329 if (sc->device->lun != abrt_task->sc->device->lun) 330 continue; 331 332 /* Invalidate WRB Posted for this Task */ 333 AMAP_SET_BITS(struct amap_iscsi_wrb, invld, 334 abrt_io_task->pwrb_handle->pwrb, 335 1); 336 337 inv_tbl->cid = cid; 338 inv_tbl->icd = abrt_io_task->psgl_handle->sgl_index; 339 num_invalidate++; 340 inv_tbl++; 341 } 342 spin_unlock_bh(&session->lock); 343 inv_tbl = phba->inv_tbl; 344 345 nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev, 346 sizeof(struct invalidate_commands_params_in), 347 &nonemb_cmd.dma); 348 if (nonemb_cmd.va == NULL) { 349 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH, 350 "BM_%d : Failed to allocate memory for" 351 "mgmt_invalidate_icds\n"); 352 return FAILED; 353 } 354 nonemb_cmd.size = sizeof(struct invalidate_commands_params_in); 355 memset(nonemb_cmd.va, 0, nonemb_cmd.size); 356 tag = mgmt_invalidate_icds(phba, inv_tbl, num_invalidate, 357 cid, &nonemb_cmd); 358 if (!tag) { 359 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_EH, 360 "BM_%d : mgmt_invalidate_icds could not be" 361 " submitted\n"); 362 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, 363 nonemb_cmd.va, nonemb_cmd.dma); 364 return FAILED; 365 } 366 367 beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd.va); 368 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, 369 nonemb_cmd.va, nonemb_cmd.dma); 370 return iscsi_eh_device_reset(sc); 371 } 372 373 static ssize_t beiscsi_show_boot_tgt_info(void *data, int type, char *buf) 374 { 375 struct beiscsi_hba *phba = data; 376 struct mgmt_session_info *boot_sess = &phba->boot_sess; 377 struct mgmt_conn_info *boot_conn = &boot_sess->conn_list[0]; 378 char *str = buf; 379 int rc; 380 381 switch (type) { 382 case ISCSI_BOOT_TGT_NAME: 383 rc = sprintf(buf, "%.*s\n", 384 (int)strlen(boot_sess->target_name), 385 (char *)&boot_sess->target_name); 386 break; 387 case ISCSI_BOOT_TGT_IP_ADDR: 388 if (boot_conn->dest_ipaddr.ip_type == 0x1) 389 rc = sprintf(buf, "%pI4\n", 390 (char *)&boot_conn->dest_ipaddr.addr); 391 else 392 rc = sprintf(str, "%pI6\n", 393 (char *)&boot_conn->dest_ipaddr.addr); 394 break; 395 case ISCSI_BOOT_TGT_PORT: 396 rc = sprintf(str, "%d\n", boot_conn->dest_port); 397 break; 398 399 case ISCSI_BOOT_TGT_CHAP_NAME: 400 rc = sprintf(str, "%.*s\n", 401 boot_conn->negotiated_login_options.auth_data.chap. 402 target_chap_name_length, 403 (char *)&boot_conn->negotiated_login_options. 404 auth_data.chap.target_chap_name); 405 break; 406 case ISCSI_BOOT_TGT_CHAP_SECRET: 407 rc = sprintf(str, "%.*s\n", 408 boot_conn->negotiated_login_options.auth_data.chap. 409 target_secret_length, 410 (char *)&boot_conn->negotiated_login_options. 411 auth_data.chap.target_secret); 412 break; 413 case ISCSI_BOOT_TGT_REV_CHAP_NAME: 414 rc = sprintf(str, "%.*s\n", 415 boot_conn->negotiated_login_options.auth_data.chap. 416 intr_chap_name_length, 417 (char *)&boot_conn->negotiated_login_options. 418 auth_data.chap.intr_chap_name); 419 break; 420 case ISCSI_BOOT_TGT_REV_CHAP_SECRET: 421 rc = sprintf(str, "%.*s\n", 422 boot_conn->negotiated_login_options.auth_data.chap. 423 intr_secret_length, 424 (char *)&boot_conn->negotiated_login_options. 425 auth_data.chap.intr_secret); 426 break; 427 case ISCSI_BOOT_TGT_FLAGS: 428 rc = sprintf(str, "2\n"); 429 break; 430 case ISCSI_BOOT_TGT_NIC_ASSOC: 431 rc = sprintf(str, "0\n"); 432 break; 433 default: 434 rc = -ENOSYS; 435 break; 436 } 437 return rc; 438 } 439 440 static ssize_t beiscsi_show_boot_ini_info(void *data, int type, char *buf) 441 { 442 struct beiscsi_hba *phba = data; 443 char *str = buf; 444 int rc; 445 446 switch (type) { 447 case ISCSI_BOOT_INI_INITIATOR_NAME: 448 rc = sprintf(str, "%s\n", phba->boot_sess.initiator_iscsiname); 449 break; 450 default: 451 rc = -ENOSYS; 452 break; 453 } 454 return rc; 455 } 456 457 static ssize_t beiscsi_show_boot_eth_info(void *data, int type, char *buf) 458 { 459 struct beiscsi_hba *phba = data; 460 char *str = buf; 461 int rc; 462 463 switch (type) { 464 case ISCSI_BOOT_ETH_FLAGS: 465 rc = sprintf(str, "2\n"); 466 break; 467 case ISCSI_BOOT_ETH_INDEX: 468 rc = sprintf(str, "0\n"); 469 break; 470 case ISCSI_BOOT_ETH_MAC: 471 rc = beiscsi_get_macaddr(str, phba); 472 break; 473 default: 474 rc = -ENOSYS; 475 break; 476 } 477 return rc; 478 } 479 480 481 static umode_t beiscsi_tgt_get_attr_visibility(void *data, int type) 482 { 483 umode_t rc; 484 485 switch (type) { 486 case ISCSI_BOOT_TGT_NAME: 487 case ISCSI_BOOT_TGT_IP_ADDR: 488 case ISCSI_BOOT_TGT_PORT: 489 case ISCSI_BOOT_TGT_CHAP_NAME: 490 case ISCSI_BOOT_TGT_CHAP_SECRET: 491 case ISCSI_BOOT_TGT_REV_CHAP_NAME: 492 case ISCSI_BOOT_TGT_REV_CHAP_SECRET: 493 case ISCSI_BOOT_TGT_NIC_ASSOC: 494 case ISCSI_BOOT_TGT_FLAGS: 495 rc = S_IRUGO; 496 break; 497 default: 498 rc = 0; 499 break; 500 } 501 return rc; 502 } 503 504 static umode_t beiscsi_ini_get_attr_visibility(void *data, int type) 505 { 506 umode_t rc; 507 508 switch (type) { 509 case ISCSI_BOOT_INI_INITIATOR_NAME: 510 rc = S_IRUGO; 511 break; 512 default: 513 rc = 0; 514 break; 515 } 516 return rc; 517 } 518 519 520 static umode_t beiscsi_eth_get_attr_visibility(void *data, int type) 521 { 522 umode_t rc; 523 524 switch (type) { 525 case ISCSI_BOOT_ETH_FLAGS: 526 case ISCSI_BOOT_ETH_MAC: 527 case ISCSI_BOOT_ETH_INDEX: 528 rc = S_IRUGO; 529 break; 530 default: 531 rc = 0; 532 break; 533 } 534 return rc; 535 } 536 537 /*------------------- PCI Driver operations and data ----------------- */ 538 static DEFINE_PCI_DEVICE_TABLE(beiscsi_pci_id_table) = { 539 { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID1) }, 540 { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID2) }, 541 { PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID1) }, 542 { PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID2) }, 543 { PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID3) }, 544 { PCI_DEVICE(ELX_VENDOR_ID, OC_SKH_ID1) }, 545 { 0 } 546 }; 547 MODULE_DEVICE_TABLE(pci, beiscsi_pci_id_table); 548 549 550 static struct scsi_host_template beiscsi_sht = { 551 .module = THIS_MODULE, 552 .name = "Emulex 10Gbe open-iscsi Initiator Driver", 553 .proc_name = DRV_NAME, 554 .queuecommand = iscsi_queuecommand, 555 .change_queue_depth = iscsi_change_queue_depth, 556 .slave_configure = beiscsi_slave_configure, 557 .target_alloc = iscsi_target_alloc, 558 .eh_abort_handler = beiscsi_eh_abort, 559 .eh_device_reset_handler = beiscsi_eh_device_reset, 560 .eh_target_reset_handler = iscsi_eh_session_reset, 561 .shost_attrs = beiscsi_attrs, 562 .sg_tablesize = BEISCSI_SGLIST_ELEMENTS, 563 .can_queue = BE2_IO_DEPTH, 564 .this_id = -1, 565 .max_sectors = BEISCSI_MAX_SECTORS, 566 .cmd_per_lun = BEISCSI_CMD_PER_LUN, 567 .use_clustering = ENABLE_CLUSTERING, 568 .vendor_id = SCSI_NL_VID_TYPE_PCI | BE_VENDOR_ID, 569 570 }; 571 572 static struct scsi_transport_template *beiscsi_scsi_transport; 573 574 static struct beiscsi_hba *beiscsi_hba_alloc(struct pci_dev *pcidev) 575 { 576 struct beiscsi_hba *phba; 577 struct Scsi_Host *shost; 578 579 shost = iscsi_host_alloc(&beiscsi_sht, sizeof(*phba), 0); 580 if (!shost) { 581 dev_err(&pcidev->dev, 582 "beiscsi_hba_alloc - iscsi_host_alloc failed\n"); 583 return NULL; 584 } 585 shost->dma_boundary = pcidev->dma_mask; 586 shost->max_id = BE2_MAX_SESSIONS; 587 shost->max_channel = 0; 588 shost->max_cmd_len = BEISCSI_MAX_CMD_LEN; 589 shost->max_lun = BEISCSI_NUM_MAX_LUN; 590 shost->transportt = beiscsi_scsi_transport; 591 phba = iscsi_host_priv(shost); 592 memset(phba, 0, sizeof(*phba)); 593 phba->shost = shost; 594 phba->pcidev = pci_dev_get(pcidev); 595 pci_set_drvdata(pcidev, phba); 596 phba->interface_handle = 0xFFFFFFFF; 597 598 if (iscsi_host_add(shost, &phba->pcidev->dev)) 599 goto free_devices; 600 601 return phba; 602 603 free_devices: 604 pci_dev_put(phba->pcidev); 605 iscsi_host_free(phba->shost); 606 return NULL; 607 } 608 609 static void beiscsi_unmap_pci_function(struct beiscsi_hba *phba) 610 { 611 if (phba->csr_va) { 612 iounmap(phba->csr_va); 613 phba->csr_va = NULL; 614 } 615 if (phba->db_va) { 616 iounmap(phba->db_va); 617 phba->db_va = NULL; 618 } 619 if (phba->pci_va) { 620 iounmap(phba->pci_va); 621 phba->pci_va = NULL; 622 } 623 } 624 625 static int beiscsi_map_pci_bars(struct beiscsi_hba *phba, 626 struct pci_dev *pcidev) 627 { 628 u8 __iomem *addr; 629 int pcicfg_reg; 630 631 addr = ioremap_nocache(pci_resource_start(pcidev, 2), 632 pci_resource_len(pcidev, 2)); 633 if (addr == NULL) 634 return -ENOMEM; 635 phba->ctrl.csr = addr; 636 phba->csr_va = addr; 637 phba->csr_pa.u.a64.address = pci_resource_start(pcidev, 2); 638 639 addr = ioremap_nocache(pci_resource_start(pcidev, 4), 128 * 1024); 640 if (addr == NULL) 641 goto pci_map_err; 642 phba->ctrl.db = addr; 643 phba->db_va = addr; 644 phba->db_pa.u.a64.address = pci_resource_start(pcidev, 4); 645 646 if (phba->generation == BE_GEN2) 647 pcicfg_reg = 1; 648 else 649 pcicfg_reg = 0; 650 651 addr = ioremap_nocache(pci_resource_start(pcidev, pcicfg_reg), 652 pci_resource_len(pcidev, pcicfg_reg)); 653 654 if (addr == NULL) 655 goto pci_map_err; 656 phba->ctrl.pcicfg = addr; 657 phba->pci_va = addr; 658 phba->pci_pa.u.a64.address = pci_resource_start(pcidev, pcicfg_reg); 659 return 0; 660 661 pci_map_err: 662 beiscsi_unmap_pci_function(phba); 663 return -ENOMEM; 664 } 665 666 static int beiscsi_enable_pci(struct pci_dev *pcidev) 667 { 668 int ret; 669 670 ret = pci_enable_device(pcidev); 671 if (ret) { 672 dev_err(&pcidev->dev, 673 "beiscsi_enable_pci - enable device failed\n"); 674 return ret; 675 } 676 677 pci_set_master(pcidev); 678 if (pci_set_consistent_dma_mask(pcidev, DMA_BIT_MASK(64))) { 679 ret = pci_set_consistent_dma_mask(pcidev, DMA_BIT_MASK(32)); 680 if (ret) { 681 dev_err(&pcidev->dev, "Could not set PCI DMA Mask\n"); 682 pci_disable_device(pcidev); 683 return ret; 684 } 685 } 686 return 0; 687 } 688 689 static int be_ctrl_init(struct beiscsi_hba *phba, struct pci_dev *pdev) 690 { 691 struct be_ctrl_info *ctrl = &phba->ctrl; 692 struct be_dma_mem *mbox_mem_alloc = &ctrl->mbox_mem_alloced; 693 struct be_dma_mem *mbox_mem_align = &ctrl->mbox_mem; 694 int status = 0; 695 696 ctrl->pdev = pdev; 697 status = beiscsi_map_pci_bars(phba, pdev); 698 if (status) 699 return status; 700 mbox_mem_alloc->size = sizeof(struct be_mcc_mailbox) + 16; 701 mbox_mem_alloc->va = pci_alloc_consistent(pdev, 702 mbox_mem_alloc->size, 703 &mbox_mem_alloc->dma); 704 if (!mbox_mem_alloc->va) { 705 beiscsi_unmap_pci_function(phba); 706 return -ENOMEM; 707 } 708 709 mbox_mem_align->size = sizeof(struct be_mcc_mailbox); 710 mbox_mem_align->va = PTR_ALIGN(mbox_mem_alloc->va, 16); 711 mbox_mem_align->dma = PTR_ALIGN(mbox_mem_alloc->dma, 16); 712 memset(mbox_mem_align->va, 0, sizeof(struct be_mcc_mailbox)); 713 spin_lock_init(&ctrl->mbox_lock); 714 spin_lock_init(&phba->ctrl.mcc_lock); 715 spin_lock_init(&phba->ctrl.mcc_cq_lock); 716 717 return status; 718 } 719 720 /** 721 * beiscsi_get_params()- Set the config paramters 722 * @phba: ptr device priv structure 723 **/ 724 static void beiscsi_get_params(struct beiscsi_hba *phba) 725 { 726 uint32_t total_cid_count = 0; 727 uint32_t total_icd_count = 0; 728 uint8_t ulp_num = 0; 729 730 total_cid_count = BEISCSI_GET_CID_COUNT(phba, BEISCSI_ULP0) + 731 BEISCSI_GET_CID_COUNT(phba, BEISCSI_ULP1); 732 733 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) { 734 uint32_t align_mask = 0; 735 uint32_t icd_post_per_page = 0; 736 uint32_t icd_count_unavailable = 0; 737 uint32_t icd_start = 0, icd_count = 0; 738 uint32_t icd_start_align = 0, icd_count_align = 0; 739 740 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { 741 icd_start = phba->fw_config.iscsi_icd_start[ulp_num]; 742 icd_count = phba->fw_config.iscsi_icd_count[ulp_num]; 743 744 /* Get ICD count that can be posted on each page */ 745 icd_post_per_page = (PAGE_SIZE / (BE2_SGE * 746 sizeof(struct iscsi_sge))); 747 align_mask = (icd_post_per_page - 1); 748 749 /* Check if icd_start is aligned ICD per page posting */ 750 if (icd_start % icd_post_per_page) { 751 icd_start_align = ((icd_start + 752 icd_post_per_page) & 753 ~(align_mask)); 754 phba->fw_config. 755 iscsi_icd_start[ulp_num] = 756 icd_start_align; 757 } 758 759 icd_count_align = (icd_count & ~align_mask); 760 761 /* ICD discarded in the process of alignment */ 762 if (icd_start_align) 763 icd_count_unavailable = ((icd_start_align - 764 icd_start) + 765 (icd_count - 766 icd_count_align)); 767 768 /* Updated ICD count available */ 769 phba->fw_config.iscsi_icd_count[ulp_num] = (icd_count - 770 icd_count_unavailable); 771 772 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 773 "BM_%d : Aligned ICD values\n" 774 "\t ICD Start : %d\n" 775 "\t ICD Count : %d\n" 776 "\t ICD Discarded : %d\n", 777 phba->fw_config. 778 iscsi_icd_start[ulp_num], 779 phba->fw_config. 780 iscsi_icd_count[ulp_num], 781 icd_count_unavailable); 782 break; 783 } 784 } 785 786 total_icd_count = phba->fw_config.iscsi_icd_count[ulp_num]; 787 phba->params.ios_per_ctrl = (total_icd_count - 788 (total_cid_count + 789 BE2_TMFS + BE2_NOPOUT_REQ)); 790 phba->params.cxns_per_ctrl = total_cid_count; 791 phba->params.asyncpdus_per_ctrl = total_cid_count; 792 phba->params.icds_per_ctrl = total_icd_count; 793 phba->params.num_sge_per_io = BE2_SGE; 794 phba->params.defpdu_hdr_sz = BE2_DEFPDU_HDR_SZ; 795 phba->params.defpdu_data_sz = BE2_DEFPDU_DATA_SZ; 796 phba->params.eq_timer = 64; 797 phba->params.num_eq_entries = 1024; 798 phba->params.num_cq_entries = 1024; 799 phba->params.wrbs_per_cxn = 256; 800 } 801 802 static void hwi_ring_eq_db(struct beiscsi_hba *phba, 803 unsigned int id, unsigned int clr_interrupt, 804 unsigned int num_processed, 805 unsigned char rearm, unsigned char event) 806 { 807 u32 val = 0; 808 val |= id & DB_EQ_RING_ID_MASK; 809 if (rearm) 810 val |= 1 << DB_EQ_REARM_SHIFT; 811 if (clr_interrupt) 812 val |= 1 << DB_EQ_CLR_SHIFT; 813 if (event) 814 val |= 1 << DB_EQ_EVNT_SHIFT; 815 val |= num_processed << DB_EQ_NUM_POPPED_SHIFT; 816 iowrite32(val, phba->db_va + DB_EQ_OFFSET); 817 } 818 819 /** 820 * be_isr_mcc - The isr routine of the driver. 821 * @irq: Not used 822 * @dev_id: Pointer to host adapter structure 823 */ 824 static irqreturn_t be_isr_mcc(int irq, void *dev_id) 825 { 826 struct beiscsi_hba *phba; 827 struct be_eq_entry *eqe = NULL; 828 struct be_queue_info *eq; 829 struct be_queue_info *mcc; 830 unsigned int num_eq_processed; 831 struct be_eq_obj *pbe_eq; 832 unsigned long flags; 833 834 pbe_eq = dev_id; 835 eq = &pbe_eq->q; 836 phba = pbe_eq->phba; 837 mcc = &phba->ctrl.mcc_obj.cq; 838 eqe = queue_tail_node(eq); 839 840 num_eq_processed = 0; 841 842 while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32] 843 & EQE_VALID_MASK) { 844 if (((eqe->dw[offsetof(struct amap_eq_entry, 845 resource_id) / 32] & 846 EQE_RESID_MASK) >> 16) == mcc->id) { 847 spin_lock_irqsave(&phba->isr_lock, flags); 848 pbe_eq->todo_mcc_cq = true; 849 spin_unlock_irqrestore(&phba->isr_lock, flags); 850 } 851 AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0); 852 queue_tail_inc(eq); 853 eqe = queue_tail_node(eq); 854 num_eq_processed++; 855 } 856 if (pbe_eq->todo_mcc_cq) 857 queue_work(phba->wq, &pbe_eq->work_cqs); 858 if (num_eq_processed) 859 hwi_ring_eq_db(phba, eq->id, 1, num_eq_processed, 1, 1); 860 861 return IRQ_HANDLED; 862 } 863 864 /** 865 * be_isr_msix - The isr routine of the driver. 866 * @irq: Not used 867 * @dev_id: Pointer to host adapter structure 868 */ 869 static irqreturn_t be_isr_msix(int irq, void *dev_id) 870 { 871 struct beiscsi_hba *phba; 872 struct be_eq_entry *eqe = NULL; 873 struct be_queue_info *eq; 874 struct be_queue_info *cq; 875 unsigned int num_eq_processed; 876 struct be_eq_obj *pbe_eq; 877 unsigned long flags; 878 879 pbe_eq = dev_id; 880 eq = &pbe_eq->q; 881 cq = pbe_eq->cq; 882 eqe = queue_tail_node(eq); 883 884 phba = pbe_eq->phba; 885 num_eq_processed = 0; 886 if (blk_iopoll_enabled) { 887 while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32] 888 & EQE_VALID_MASK) { 889 if (!blk_iopoll_sched_prep(&pbe_eq->iopoll)) 890 blk_iopoll_sched(&pbe_eq->iopoll); 891 892 AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0); 893 queue_tail_inc(eq); 894 eqe = queue_tail_node(eq); 895 num_eq_processed++; 896 } 897 } else { 898 while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32] 899 & EQE_VALID_MASK) { 900 spin_lock_irqsave(&phba->isr_lock, flags); 901 pbe_eq->todo_cq = true; 902 spin_unlock_irqrestore(&phba->isr_lock, flags); 903 AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0); 904 queue_tail_inc(eq); 905 eqe = queue_tail_node(eq); 906 num_eq_processed++; 907 } 908 909 if (pbe_eq->todo_cq) 910 queue_work(phba->wq, &pbe_eq->work_cqs); 911 } 912 913 if (num_eq_processed) 914 hwi_ring_eq_db(phba, eq->id, 1, num_eq_processed, 0, 1); 915 916 return IRQ_HANDLED; 917 } 918 919 /** 920 * be_isr - The isr routine of the driver. 921 * @irq: Not used 922 * @dev_id: Pointer to host adapter structure 923 */ 924 static irqreturn_t be_isr(int irq, void *dev_id) 925 { 926 struct beiscsi_hba *phba; 927 struct hwi_controller *phwi_ctrlr; 928 struct hwi_context_memory *phwi_context; 929 struct be_eq_entry *eqe = NULL; 930 struct be_queue_info *eq; 931 struct be_queue_info *cq; 932 struct be_queue_info *mcc; 933 unsigned long flags, index; 934 unsigned int num_mcceq_processed, num_ioeq_processed; 935 struct be_ctrl_info *ctrl; 936 struct be_eq_obj *pbe_eq; 937 int isr; 938 939 phba = dev_id; 940 ctrl = &phba->ctrl; 941 isr = ioread32(ctrl->csr + CEV_ISR0_OFFSET + 942 (PCI_FUNC(ctrl->pdev->devfn) * CEV_ISR_SIZE)); 943 if (!isr) 944 return IRQ_NONE; 945 946 phwi_ctrlr = phba->phwi_ctrlr; 947 phwi_context = phwi_ctrlr->phwi_ctxt; 948 pbe_eq = &phwi_context->be_eq[0]; 949 950 eq = &phwi_context->be_eq[0].q; 951 mcc = &phba->ctrl.mcc_obj.cq; 952 index = 0; 953 eqe = queue_tail_node(eq); 954 955 num_ioeq_processed = 0; 956 num_mcceq_processed = 0; 957 if (blk_iopoll_enabled) { 958 while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32] 959 & EQE_VALID_MASK) { 960 if (((eqe->dw[offsetof(struct amap_eq_entry, 961 resource_id) / 32] & 962 EQE_RESID_MASK) >> 16) == mcc->id) { 963 spin_lock_irqsave(&phba->isr_lock, flags); 964 pbe_eq->todo_mcc_cq = true; 965 spin_unlock_irqrestore(&phba->isr_lock, flags); 966 num_mcceq_processed++; 967 } else { 968 if (!blk_iopoll_sched_prep(&pbe_eq->iopoll)) 969 blk_iopoll_sched(&pbe_eq->iopoll); 970 num_ioeq_processed++; 971 } 972 AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0); 973 queue_tail_inc(eq); 974 eqe = queue_tail_node(eq); 975 } 976 if (num_ioeq_processed || num_mcceq_processed) { 977 if (pbe_eq->todo_mcc_cq) 978 queue_work(phba->wq, &pbe_eq->work_cqs); 979 980 if ((num_mcceq_processed) && (!num_ioeq_processed)) 981 hwi_ring_eq_db(phba, eq->id, 0, 982 (num_ioeq_processed + 983 num_mcceq_processed) , 1, 1); 984 else 985 hwi_ring_eq_db(phba, eq->id, 0, 986 (num_ioeq_processed + 987 num_mcceq_processed), 0, 1); 988 989 return IRQ_HANDLED; 990 } else 991 return IRQ_NONE; 992 } else { 993 cq = &phwi_context->be_cq[0]; 994 while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32] 995 & EQE_VALID_MASK) { 996 997 if (((eqe->dw[offsetof(struct amap_eq_entry, 998 resource_id) / 32] & 999 EQE_RESID_MASK) >> 16) != cq->id) { 1000 spin_lock_irqsave(&phba->isr_lock, flags); 1001 pbe_eq->todo_mcc_cq = true; 1002 spin_unlock_irqrestore(&phba->isr_lock, flags); 1003 } else { 1004 spin_lock_irqsave(&phba->isr_lock, flags); 1005 pbe_eq->todo_cq = true; 1006 spin_unlock_irqrestore(&phba->isr_lock, flags); 1007 } 1008 AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0); 1009 queue_tail_inc(eq); 1010 eqe = queue_tail_node(eq); 1011 num_ioeq_processed++; 1012 } 1013 if (pbe_eq->todo_cq || pbe_eq->todo_mcc_cq) 1014 queue_work(phba->wq, &pbe_eq->work_cqs); 1015 1016 if (num_ioeq_processed) { 1017 hwi_ring_eq_db(phba, eq->id, 0, 1018 num_ioeq_processed, 1, 1); 1019 return IRQ_HANDLED; 1020 } else 1021 return IRQ_NONE; 1022 } 1023 } 1024 1025 static int beiscsi_init_irqs(struct beiscsi_hba *phba) 1026 { 1027 struct pci_dev *pcidev = phba->pcidev; 1028 struct hwi_controller *phwi_ctrlr; 1029 struct hwi_context_memory *phwi_context; 1030 int ret, msix_vec, i, j; 1031 1032 phwi_ctrlr = phba->phwi_ctrlr; 1033 phwi_context = phwi_ctrlr->phwi_ctxt; 1034 1035 if (phba->msix_enabled) { 1036 for (i = 0; i < phba->num_cpus; i++) { 1037 phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME, 1038 GFP_KERNEL); 1039 if (!phba->msi_name[i]) { 1040 ret = -ENOMEM; 1041 goto free_msix_irqs; 1042 } 1043 1044 sprintf(phba->msi_name[i], "beiscsi_%02x_%02x", 1045 phba->shost->host_no, i); 1046 msix_vec = phba->msix_entries[i].vector; 1047 ret = request_irq(msix_vec, be_isr_msix, 0, 1048 phba->msi_name[i], 1049 &phwi_context->be_eq[i]); 1050 if (ret) { 1051 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 1052 "BM_%d : beiscsi_init_irqs-Failed to" 1053 "register msix for i = %d\n", 1054 i); 1055 kfree(phba->msi_name[i]); 1056 goto free_msix_irqs; 1057 } 1058 } 1059 phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME, GFP_KERNEL); 1060 if (!phba->msi_name[i]) { 1061 ret = -ENOMEM; 1062 goto free_msix_irqs; 1063 } 1064 sprintf(phba->msi_name[i], "beiscsi_mcc_%02x", 1065 phba->shost->host_no); 1066 msix_vec = phba->msix_entries[i].vector; 1067 ret = request_irq(msix_vec, be_isr_mcc, 0, phba->msi_name[i], 1068 &phwi_context->be_eq[i]); 1069 if (ret) { 1070 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT , 1071 "BM_%d : beiscsi_init_irqs-" 1072 "Failed to register beiscsi_msix_mcc\n"); 1073 kfree(phba->msi_name[i]); 1074 goto free_msix_irqs; 1075 } 1076 1077 } else { 1078 ret = request_irq(pcidev->irq, be_isr, IRQF_SHARED, 1079 "beiscsi", phba); 1080 if (ret) { 1081 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 1082 "BM_%d : beiscsi_init_irqs-" 1083 "Failed to register irq\\n"); 1084 return ret; 1085 } 1086 } 1087 return 0; 1088 free_msix_irqs: 1089 for (j = i - 1; j >= 0; j--) { 1090 kfree(phba->msi_name[j]); 1091 msix_vec = phba->msix_entries[j].vector; 1092 free_irq(msix_vec, &phwi_context->be_eq[j]); 1093 } 1094 return ret; 1095 } 1096 1097 static void hwi_ring_cq_db(struct beiscsi_hba *phba, 1098 unsigned int id, unsigned int num_processed, 1099 unsigned char rearm, unsigned char event) 1100 { 1101 u32 val = 0; 1102 val |= id & DB_CQ_RING_ID_MASK; 1103 if (rearm) 1104 val |= 1 << DB_CQ_REARM_SHIFT; 1105 val |= num_processed << DB_CQ_NUM_POPPED_SHIFT; 1106 iowrite32(val, phba->db_va + DB_CQ_OFFSET); 1107 } 1108 1109 static unsigned int 1110 beiscsi_process_async_pdu(struct beiscsi_conn *beiscsi_conn, 1111 struct beiscsi_hba *phba, 1112 struct pdu_base *ppdu, 1113 unsigned long pdu_len, 1114 void *pbuffer, unsigned long buf_len) 1115 { 1116 struct iscsi_conn *conn = beiscsi_conn->conn; 1117 struct iscsi_session *session = conn->session; 1118 struct iscsi_task *task; 1119 struct beiscsi_io_task *io_task; 1120 struct iscsi_hdr *login_hdr; 1121 1122 switch (ppdu->dw[offsetof(struct amap_pdu_base, opcode) / 32] & 1123 PDUBASE_OPCODE_MASK) { 1124 case ISCSI_OP_NOOP_IN: 1125 pbuffer = NULL; 1126 buf_len = 0; 1127 break; 1128 case ISCSI_OP_ASYNC_EVENT: 1129 break; 1130 case ISCSI_OP_REJECT: 1131 WARN_ON(!pbuffer); 1132 WARN_ON(!(buf_len == 48)); 1133 beiscsi_log(phba, KERN_ERR, 1134 BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO, 1135 "BM_%d : In ISCSI_OP_REJECT\n"); 1136 break; 1137 case ISCSI_OP_LOGIN_RSP: 1138 case ISCSI_OP_TEXT_RSP: 1139 task = conn->login_task; 1140 io_task = task->dd_data; 1141 login_hdr = (struct iscsi_hdr *)ppdu; 1142 login_hdr->itt = io_task->libiscsi_itt; 1143 break; 1144 default: 1145 beiscsi_log(phba, KERN_WARNING, 1146 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, 1147 "BM_%d : Unrecognized opcode 0x%x in async msg\n", 1148 (ppdu-> 1149 dw[offsetof(struct amap_pdu_base, opcode) / 32] 1150 & PDUBASE_OPCODE_MASK)); 1151 return 1; 1152 } 1153 1154 spin_lock_bh(&session->lock); 1155 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)ppdu, pbuffer, buf_len); 1156 spin_unlock_bh(&session->lock); 1157 return 0; 1158 } 1159 1160 static struct sgl_handle *alloc_io_sgl_handle(struct beiscsi_hba *phba) 1161 { 1162 struct sgl_handle *psgl_handle; 1163 1164 if (phba->io_sgl_hndl_avbl) { 1165 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO, 1166 "BM_%d : In alloc_io_sgl_handle," 1167 " io_sgl_alloc_index=%d\n", 1168 phba->io_sgl_alloc_index); 1169 1170 psgl_handle = phba->io_sgl_hndl_base[phba-> 1171 io_sgl_alloc_index]; 1172 phba->io_sgl_hndl_base[phba->io_sgl_alloc_index] = NULL; 1173 phba->io_sgl_hndl_avbl--; 1174 if (phba->io_sgl_alloc_index == (phba->params. 1175 ios_per_ctrl - 1)) 1176 phba->io_sgl_alloc_index = 0; 1177 else 1178 phba->io_sgl_alloc_index++; 1179 } else 1180 psgl_handle = NULL; 1181 return psgl_handle; 1182 } 1183 1184 static void 1185 free_io_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle) 1186 { 1187 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO, 1188 "BM_%d : In free_,io_sgl_free_index=%d\n", 1189 phba->io_sgl_free_index); 1190 1191 if (phba->io_sgl_hndl_base[phba->io_sgl_free_index]) { 1192 /* 1193 * this can happen if clean_task is called on a task that 1194 * failed in xmit_task or alloc_pdu. 1195 */ 1196 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO, 1197 "BM_%d : Double Free in IO SGL io_sgl_free_index=%d," 1198 "value there=%p\n", phba->io_sgl_free_index, 1199 phba->io_sgl_hndl_base 1200 [phba->io_sgl_free_index]); 1201 return; 1202 } 1203 phba->io_sgl_hndl_base[phba->io_sgl_free_index] = psgl_handle; 1204 phba->io_sgl_hndl_avbl++; 1205 if (phba->io_sgl_free_index == (phba->params.ios_per_ctrl - 1)) 1206 phba->io_sgl_free_index = 0; 1207 else 1208 phba->io_sgl_free_index++; 1209 } 1210 1211 /** 1212 * alloc_wrb_handle - To allocate a wrb handle 1213 * @phba: The hba pointer 1214 * @cid: The cid to use for allocation 1215 * 1216 * This happens under session_lock until submission to chip 1217 */ 1218 struct wrb_handle *alloc_wrb_handle(struct beiscsi_hba *phba, unsigned int cid) 1219 { 1220 struct hwi_wrb_context *pwrb_context; 1221 struct hwi_controller *phwi_ctrlr; 1222 struct wrb_handle *pwrb_handle, *pwrb_handle_tmp; 1223 uint16_t cri_index = BE_GET_CRI_FROM_CID(cid); 1224 1225 phwi_ctrlr = phba->phwi_ctrlr; 1226 pwrb_context = &phwi_ctrlr->wrb_context[cri_index]; 1227 if (pwrb_context->wrb_handles_available >= 2) { 1228 pwrb_handle = pwrb_context->pwrb_handle_base[ 1229 pwrb_context->alloc_index]; 1230 pwrb_context->wrb_handles_available--; 1231 if (pwrb_context->alloc_index == 1232 (phba->params.wrbs_per_cxn - 1)) 1233 pwrb_context->alloc_index = 0; 1234 else 1235 pwrb_context->alloc_index++; 1236 pwrb_handle_tmp = pwrb_context->pwrb_handle_base[ 1237 pwrb_context->alloc_index]; 1238 pwrb_handle->nxt_wrb_index = pwrb_handle_tmp->wrb_index; 1239 } else 1240 pwrb_handle = NULL; 1241 return pwrb_handle; 1242 } 1243 1244 /** 1245 * free_wrb_handle - To free the wrb handle back to pool 1246 * @phba: The hba pointer 1247 * @pwrb_context: The context to free from 1248 * @pwrb_handle: The wrb_handle to free 1249 * 1250 * This happens under session_lock until submission to chip 1251 */ 1252 static void 1253 free_wrb_handle(struct beiscsi_hba *phba, struct hwi_wrb_context *pwrb_context, 1254 struct wrb_handle *pwrb_handle) 1255 { 1256 pwrb_context->pwrb_handle_base[pwrb_context->free_index] = pwrb_handle; 1257 pwrb_context->wrb_handles_available++; 1258 if (pwrb_context->free_index == (phba->params.wrbs_per_cxn - 1)) 1259 pwrb_context->free_index = 0; 1260 else 1261 pwrb_context->free_index++; 1262 1263 beiscsi_log(phba, KERN_INFO, 1264 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, 1265 "BM_%d : FREE WRB: pwrb_handle=%p free_index=0x%x" 1266 "wrb_handles_available=%d\n", 1267 pwrb_handle, pwrb_context->free_index, 1268 pwrb_context->wrb_handles_available); 1269 } 1270 1271 static struct sgl_handle *alloc_mgmt_sgl_handle(struct beiscsi_hba *phba) 1272 { 1273 struct sgl_handle *psgl_handle; 1274 1275 if (phba->eh_sgl_hndl_avbl) { 1276 psgl_handle = phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index]; 1277 phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index] = NULL; 1278 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, 1279 "BM_%d : mgmt_sgl_alloc_index=%d=0x%x\n", 1280 phba->eh_sgl_alloc_index, 1281 phba->eh_sgl_alloc_index); 1282 1283 phba->eh_sgl_hndl_avbl--; 1284 if (phba->eh_sgl_alloc_index == 1285 (phba->params.icds_per_ctrl - phba->params.ios_per_ctrl - 1286 1)) 1287 phba->eh_sgl_alloc_index = 0; 1288 else 1289 phba->eh_sgl_alloc_index++; 1290 } else 1291 psgl_handle = NULL; 1292 return psgl_handle; 1293 } 1294 1295 void 1296 free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle) 1297 { 1298 1299 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, 1300 "BM_%d : In free_mgmt_sgl_handle," 1301 "eh_sgl_free_index=%d\n", 1302 phba->eh_sgl_free_index); 1303 1304 if (phba->eh_sgl_hndl_base[phba->eh_sgl_free_index]) { 1305 /* 1306 * this can happen if clean_task is called on a task that 1307 * failed in xmit_task or alloc_pdu. 1308 */ 1309 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, 1310 "BM_%d : Double Free in eh SGL ," 1311 "eh_sgl_free_index=%d\n", 1312 phba->eh_sgl_free_index); 1313 return; 1314 } 1315 phba->eh_sgl_hndl_base[phba->eh_sgl_free_index] = psgl_handle; 1316 phba->eh_sgl_hndl_avbl++; 1317 if (phba->eh_sgl_free_index == 1318 (phba->params.icds_per_ctrl - phba->params.ios_per_ctrl - 1)) 1319 phba->eh_sgl_free_index = 0; 1320 else 1321 phba->eh_sgl_free_index++; 1322 } 1323 1324 static void 1325 be_complete_io(struct beiscsi_conn *beiscsi_conn, 1326 struct iscsi_task *task, 1327 struct common_sol_cqe *csol_cqe) 1328 { 1329 struct beiscsi_io_task *io_task = task->dd_data; 1330 struct be_status_bhs *sts_bhs = 1331 (struct be_status_bhs *)io_task->cmd_bhs; 1332 struct iscsi_conn *conn = beiscsi_conn->conn; 1333 unsigned char *sense; 1334 u32 resid = 0, exp_cmdsn, max_cmdsn; 1335 u8 rsp, status, flags; 1336 1337 exp_cmdsn = csol_cqe->exp_cmdsn; 1338 max_cmdsn = (csol_cqe->exp_cmdsn + 1339 csol_cqe->cmd_wnd - 1); 1340 rsp = csol_cqe->i_resp; 1341 status = csol_cqe->i_sts; 1342 flags = csol_cqe->i_flags; 1343 resid = csol_cqe->res_cnt; 1344 1345 if (!task->sc) { 1346 if (io_task->scsi_cmnd) 1347 scsi_dma_unmap(io_task->scsi_cmnd); 1348 1349 return; 1350 } 1351 task->sc->result = (DID_OK << 16) | status; 1352 if (rsp != ISCSI_STATUS_CMD_COMPLETED) { 1353 task->sc->result = DID_ERROR << 16; 1354 goto unmap; 1355 } 1356 1357 /* bidi not initially supported */ 1358 if (flags & (ISCSI_FLAG_CMD_UNDERFLOW | ISCSI_FLAG_CMD_OVERFLOW)) { 1359 if (!status && (flags & ISCSI_FLAG_CMD_OVERFLOW)) 1360 task->sc->result = DID_ERROR << 16; 1361 1362 if (flags & ISCSI_FLAG_CMD_UNDERFLOW) { 1363 scsi_set_resid(task->sc, resid); 1364 if (!status && (scsi_bufflen(task->sc) - resid < 1365 task->sc->underflow)) 1366 task->sc->result = DID_ERROR << 16; 1367 } 1368 } 1369 1370 if (status == SAM_STAT_CHECK_CONDITION) { 1371 u16 sense_len; 1372 unsigned short *slen = (unsigned short *)sts_bhs->sense_info; 1373 1374 sense = sts_bhs->sense_info + sizeof(unsigned short); 1375 sense_len = be16_to_cpu(*slen); 1376 memcpy(task->sc->sense_buffer, sense, 1377 min_t(u16, sense_len, SCSI_SENSE_BUFFERSIZE)); 1378 } 1379 1380 if (io_task->cmd_bhs->iscsi_hdr.flags & ISCSI_FLAG_CMD_READ) 1381 conn->rxdata_octets += resid; 1382 unmap: 1383 scsi_dma_unmap(io_task->scsi_cmnd); 1384 iscsi_complete_scsi_task(task, exp_cmdsn, max_cmdsn); 1385 } 1386 1387 static void 1388 be_complete_logout(struct beiscsi_conn *beiscsi_conn, 1389 struct iscsi_task *task, 1390 struct common_sol_cqe *csol_cqe) 1391 { 1392 struct iscsi_logout_rsp *hdr; 1393 struct beiscsi_io_task *io_task = task->dd_data; 1394 struct iscsi_conn *conn = beiscsi_conn->conn; 1395 1396 hdr = (struct iscsi_logout_rsp *)task->hdr; 1397 hdr->opcode = ISCSI_OP_LOGOUT_RSP; 1398 hdr->t2wait = 5; 1399 hdr->t2retain = 0; 1400 hdr->flags = csol_cqe->i_flags; 1401 hdr->response = csol_cqe->i_resp; 1402 hdr->exp_cmdsn = cpu_to_be32(csol_cqe->exp_cmdsn); 1403 hdr->max_cmdsn = cpu_to_be32(csol_cqe->exp_cmdsn + 1404 csol_cqe->cmd_wnd - 1); 1405 1406 hdr->dlength[0] = 0; 1407 hdr->dlength[1] = 0; 1408 hdr->dlength[2] = 0; 1409 hdr->hlength = 0; 1410 hdr->itt = io_task->libiscsi_itt; 1411 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0); 1412 } 1413 1414 static void 1415 be_complete_tmf(struct beiscsi_conn *beiscsi_conn, 1416 struct iscsi_task *task, 1417 struct common_sol_cqe *csol_cqe) 1418 { 1419 struct iscsi_tm_rsp *hdr; 1420 struct iscsi_conn *conn = beiscsi_conn->conn; 1421 struct beiscsi_io_task *io_task = task->dd_data; 1422 1423 hdr = (struct iscsi_tm_rsp *)task->hdr; 1424 hdr->opcode = ISCSI_OP_SCSI_TMFUNC_RSP; 1425 hdr->flags = csol_cqe->i_flags; 1426 hdr->response = csol_cqe->i_resp; 1427 hdr->exp_cmdsn = cpu_to_be32(csol_cqe->exp_cmdsn); 1428 hdr->max_cmdsn = cpu_to_be32(csol_cqe->exp_cmdsn + 1429 csol_cqe->cmd_wnd - 1); 1430 1431 hdr->itt = io_task->libiscsi_itt; 1432 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0); 1433 } 1434 1435 static void 1436 hwi_complete_drvr_msgs(struct beiscsi_conn *beiscsi_conn, 1437 struct beiscsi_hba *phba, struct sol_cqe *psol) 1438 { 1439 struct hwi_wrb_context *pwrb_context; 1440 struct wrb_handle *pwrb_handle = NULL; 1441 struct hwi_controller *phwi_ctrlr; 1442 struct iscsi_task *task; 1443 struct beiscsi_io_task *io_task; 1444 uint16_t wrb_index, cid, cri_index; 1445 1446 phwi_ctrlr = phba->phwi_ctrlr; 1447 if (is_chip_be2_be3r(phba)) { 1448 wrb_index = AMAP_GET_BITS(struct amap_it_dmsg_cqe, 1449 wrb_idx, psol); 1450 cid = AMAP_GET_BITS(struct amap_it_dmsg_cqe, 1451 cid, psol); 1452 } else { 1453 wrb_index = AMAP_GET_BITS(struct amap_it_dmsg_cqe_v2, 1454 wrb_idx, psol); 1455 cid = AMAP_GET_BITS(struct amap_it_dmsg_cqe_v2, 1456 cid, psol); 1457 } 1458 1459 cri_index = BE_GET_CRI_FROM_CID(cid); 1460 pwrb_context = &phwi_ctrlr->wrb_context[cri_index]; 1461 pwrb_handle = pwrb_context->pwrb_handle_basestd[wrb_index]; 1462 task = pwrb_handle->pio_handle; 1463 1464 io_task = task->dd_data; 1465 memset(io_task->pwrb_handle->pwrb, 0, sizeof(struct iscsi_wrb)); 1466 iscsi_put_task(task); 1467 } 1468 1469 static void 1470 be_complete_nopin_resp(struct beiscsi_conn *beiscsi_conn, 1471 struct iscsi_task *task, 1472 struct common_sol_cqe *csol_cqe) 1473 { 1474 struct iscsi_nopin *hdr; 1475 struct iscsi_conn *conn = beiscsi_conn->conn; 1476 struct beiscsi_io_task *io_task = task->dd_data; 1477 1478 hdr = (struct iscsi_nopin *)task->hdr; 1479 hdr->flags = csol_cqe->i_flags; 1480 hdr->exp_cmdsn = cpu_to_be32(csol_cqe->exp_cmdsn); 1481 hdr->max_cmdsn = cpu_to_be32(csol_cqe->exp_cmdsn + 1482 csol_cqe->cmd_wnd - 1); 1483 1484 hdr->opcode = ISCSI_OP_NOOP_IN; 1485 hdr->itt = io_task->libiscsi_itt; 1486 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0); 1487 } 1488 1489 static void adapter_get_sol_cqe(struct beiscsi_hba *phba, 1490 struct sol_cqe *psol, 1491 struct common_sol_cqe *csol_cqe) 1492 { 1493 if (is_chip_be2_be3r(phba)) { 1494 csol_cqe->exp_cmdsn = AMAP_GET_BITS(struct amap_sol_cqe, 1495 i_exp_cmd_sn, psol); 1496 csol_cqe->res_cnt = AMAP_GET_BITS(struct amap_sol_cqe, 1497 i_res_cnt, psol); 1498 csol_cqe->cmd_wnd = AMAP_GET_BITS(struct amap_sol_cqe, 1499 i_cmd_wnd, psol); 1500 csol_cqe->wrb_index = AMAP_GET_BITS(struct amap_sol_cqe, 1501 wrb_index, psol); 1502 csol_cqe->cid = AMAP_GET_BITS(struct amap_sol_cqe, 1503 cid, psol); 1504 csol_cqe->hw_sts = AMAP_GET_BITS(struct amap_sol_cqe, 1505 hw_sts, psol); 1506 csol_cqe->i_resp = AMAP_GET_BITS(struct amap_sol_cqe, 1507 i_resp, psol); 1508 csol_cqe->i_sts = AMAP_GET_BITS(struct amap_sol_cqe, 1509 i_sts, psol); 1510 csol_cqe->i_flags = AMAP_GET_BITS(struct amap_sol_cqe, 1511 i_flags, psol); 1512 } else { 1513 csol_cqe->exp_cmdsn = AMAP_GET_BITS(struct amap_sol_cqe_v2, 1514 i_exp_cmd_sn, psol); 1515 csol_cqe->res_cnt = AMAP_GET_BITS(struct amap_sol_cqe_v2, 1516 i_res_cnt, psol); 1517 csol_cqe->wrb_index = AMAP_GET_BITS(struct amap_sol_cqe_v2, 1518 wrb_index, psol); 1519 csol_cqe->cid = AMAP_GET_BITS(struct amap_sol_cqe_v2, 1520 cid, psol); 1521 csol_cqe->hw_sts = AMAP_GET_BITS(struct amap_sol_cqe_v2, 1522 hw_sts, psol); 1523 csol_cqe->cmd_wnd = AMAP_GET_BITS(struct amap_sol_cqe_v2, 1524 i_cmd_wnd, psol); 1525 if (AMAP_GET_BITS(struct amap_sol_cqe_v2, 1526 cmd_cmpl, psol)) 1527 csol_cqe->i_sts = AMAP_GET_BITS(struct amap_sol_cqe_v2, 1528 i_sts, psol); 1529 else 1530 csol_cqe->i_resp = AMAP_GET_BITS(struct amap_sol_cqe_v2, 1531 i_sts, psol); 1532 if (AMAP_GET_BITS(struct amap_sol_cqe_v2, 1533 u, psol)) 1534 csol_cqe->i_flags = ISCSI_FLAG_CMD_UNDERFLOW; 1535 1536 if (AMAP_GET_BITS(struct amap_sol_cqe_v2, 1537 o, psol)) 1538 csol_cqe->i_flags |= ISCSI_FLAG_CMD_OVERFLOW; 1539 } 1540 } 1541 1542 1543 static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn, 1544 struct beiscsi_hba *phba, struct sol_cqe *psol) 1545 { 1546 struct hwi_wrb_context *pwrb_context; 1547 struct wrb_handle *pwrb_handle; 1548 struct iscsi_wrb *pwrb = NULL; 1549 struct hwi_controller *phwi_ctrlr; 1550 struct iscsi_task *task; 1551 unsigned int type; 1552 struct iscsi_conn *conn = beiscsi_conn->conn; 1553 struct iscsi_session *session = conn->session; 1554 struct common_sol_cqe csol_cqe = {0}; 1555 uint16_t cri_index = 0; 1556 1557 phwi_ctrlr = phba->phwi_ctrlr; 1558 1559 /* Copy the elements to a common structure */ 1560 adapter_get_sol_cqe(phba, psol, &csol_cqe); 1561 1562 cri_index = BE_GET_CRI_FROM_CID(csol_cqe.cid); 1563 pwrb_context = &phwi_ctrlr->wrb_context[cri_index]; 1564 1565 pwrb_handle = pwrb_context->pwrb_handle_basestd[ 1566 csol_cqe.wrb_index]; 1567 1568 task = pwrb_handle->pio_handle; 1569 pwrb = pwrb_handle->pwrb; 1570 type = ((struct beiscsi_io_task *)task->dd_data)->wrb_type; 1571 1572 spin_lock_bh(&session->lock); 1573 switch (type) { 1574 case HWH_TYPE_IO: 1575 case HWH_TYPE_IO_RD: 1576 if ((task->hdr->opcode & ISCSI_OPCODE_MASK) == 1577 ISCSI_OP_NOOP_OUT) 1578 be_complete_nopin_resp(beiscsi_conn, task, &csol_cqe); 1579 else 1580 be_complete_io(beiscsi_conn, task, &csol_cqe); 1581 break; 1582 1583 case HWH_TYPE_LOGOUT: 1584 if ((task->hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGOUT) 1585 be_complete_logout(beiscsi_conn, task, &csol_cqe); 1586 else 1587 be_complete_tmf(beiscsi_conn, task, &csol_cqe); 1588 break; 1589 1590 case HWH_TYPE_LOGIN: 1591 beiscsi_log(phba, KERN_ERR, 1592 BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO, 1593 "BM_%d :\t\t No HWH_TYPE_LOGIN Expected in" 1594 " hwi_complete_cmd- Solicited path\n"); 1595 break; 1596 1597 case HWH_TYPE_NOP: 1598 be_complete_nopin_resp(beiscsi_conn, task, &csol_cqe); 1599 break; 1600 1601 default: 1602 beiscsi_log(phba, KERN_WARNING, 1603 BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO, 1604 "BM_%d : In hwi_complete_cmd, unknown type = %d" 1605 "wrb_index 0x%x CID 0x%x\n", type, 1606 csol_cqe.wrb_index, 1607 csol_cqe.cid); 1608 break; 1609 } 1610 1611 spin_unlock_bh(&session->lock); 1612 } 1613 1614 static struct list_head *hwi_get_async_busy_list(struct hwi_async_pdu_context 1615 *pasync_ctx, unsigned int is_header, 1616 unsigned int host_write_ptr) 1617 { 1618 if (is_header) 1619 return &pasync_ctx->async_entry[host_write_ptr]. 1620 header_busy_list; 1621 else 1622 return &pasync_ctx->async_entry[host_write_ptr].data_busy_list; 1623 } 1624 1625 static struct async_pdu_handle * 1626 hwi_get_async_handle(struct beiscsi_hba *phba, 1627 struct beiscsi_conn *beiscsi_conn, 1628 struct hwi_async_pdu_context *pasync_ctx, 1629 struct i_t_dpdu_cqe *pdpdu_cqe, unsigned int *pcq_index) 1630 { 1631 struct be_bus_address phys_addr; 1632 struct list_head *pbusy_list; 1633 struct async_pdu_handle *pasync_handle = NULL; 1634 unsigned char is_header = 0; 1635 unsigned int index, dpl; 1636 1637 if (is_chip_be2_be3r(phba)) { 1638 dpl = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe, 1639 dpl, pdpdu_cqe); 1640 index = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe, 1641 index, pdpdu_cqe); 1642 } else { 1643 dpl = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe_v2, 1644 dpl, pdpdu_cqe); 1645 index = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe_v2, 1646 index, pdpdu_cqe); 1647 } 1648 1649 phys_addr.u.a32.address_lo = 1650 (pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe, 1651 db_addr_lo) / 32] - dpl); 1652 phys_addr.u.a32.address_hi = 1653 pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe, 1654 db_addr_hi) / 32]; 1655 1656 phys_addr.u.a64.address = 1657 *((unsigned long long *)(&phys_addr.u.a64.address)); 1658 1659 switch (pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe, code) / 32] 1660 & PDUCQE_CODE_MASK) { 1661 case UNSOL_HDR_NOTIFY: 1662 is_header = 1; 1663 1664 pbusy_list = hwi_get_async_busy_list(pasync_ctx, 1665 is_header, index); 1666 break; 1667 case UNSOL_DATA_NOTIFY: 1668 pbusy_list = hwi_get_async_busy_list(pasync_ctx, 1669 is_header, index); 1670 break; 1671 default: 1672 pbusy_list = NULL; 1673 beiscsi_log(phba, KERN_WARNING, 1674 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, 1675 "BM_%d : Unexpected code=%d\n", 1676 pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe, 1677 code) / 32] & PDUCQE_CODE_MASK); 1678 return NULL; 1679 } 1680 1681 WARN_ON(list_empty(pbusy_list)); 1682 list_for_each_entry(pasync_handle, pbusy_list, link) { 1683 if (pasync_handle->pa.u.a64.address == phys_addr.u.a64.address) 1684 break; 1685 } 1686 1687 WARN_ON(!pasync_handle); 1688 1689 pasync_handle->cri = BE_GET_ASYNC_CRI_FROM_CID( 1690 beiscsi_conn->beiscsi_conn_cid); 1691 pasync_handle->is_header = is_header; 1692 pasync_handle->buffer_len = dpl; 1693 *pcq_index = index; 1694 1695 return pasync_handle; 1696 } 1697 1698 static unsigned int 1699 hwi_update_async_writables(struct beiscsi_hba *phba, 1700 struct hwi_async_pdu_context *pasync_ctx, 1701 unsigned int is_header, unsigned int cq_index) 1702 { 1703 struct list_head *pbusy_list; 1704 struct async_pdu_handle *pasync_handle; 1705 unsigned int num_entries, writables = 0; 1706 unsigned int *pep_read_ptr, *pwritables; 1707 1708 num_entries = pasync_ctx->num_entries; 1709 if (is_header) { 1710 pep_read_ptr = &pasync_ctx->async_header.ep_read_ptr; 1711 pwritables = &pasync_ctx->async_header.writables; 1712 } else { 1713 pep_read_ptr = &pasync_ctx->async_data.ep_read_ptr; 1714 pwritables = &pasync_ctx->async_data.writables; 1715 } 1716 1717 while ((*pep_read_ptr) != cq_index) { 1718 (*pep_read_ptr)++; 1719 *pep_read_ptr = (*pep_read_ptr) % num_entries; 1720 1721 pbusy_list = hwi_get_async_busy_list(pasync_ctx, is_header, 1722 *pep_read_ptr); 1723 if (writables == 0) 1724 WARN_ON(list_empty(pbusy_list)); 1725 1726 if (!list_empty(pbusy_list)) { 1727 pasync_handle = list_entry(pbusy_list->next, 1728 struct async_pdu_handle, 1729 link); 1730 WARN_ON(!pasync_handle); 1731 pasync_handle->consumed = 1; 1732 } 1733 1734 writables++; 1735 } 1736 1737 if (!writables) { 1738 beiscsi_log(phba, KERN_ERR, 1739 BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO, 1740 "BM_%d : Duplicate notification received - index 0x%x!!\n", 1741 cq_index); 1742 WARN_ON(1); 1743 } 1744 1745 *pwritables = *pwritables + writables; 1746 return 0; 1747 } 1748 1749 static void hwi_free_async_msg(struct beiscsi_hba *phba, 1750 struct hwi_async_pdu_context *pasync_ctx, 1751 unsigned int cri) 1752 { 1753 struct async_pdu_handle *pasync_handle, *tmp_handle; 1754 struct list_head *plist; 1755 1756 plist = &pasync_ctx->async_entry[cri].wait_queue.list; 1757 list_for_each_entry_safe(pasync_handle, tmp_handle, plist, link) { 1758 list_del(&pasync_handle->link); 1759 1760 if (pasync_handle->is_header) { 1761 list_add_tail(&pasync_handle->link, 1762 &pasync_ctx->async_header.free_list); 1763 pasync_ctx->async_header.free_entries++; 1764 } else { 1765 list_add_tail(&pasync_handle->link, 1766 &pasync_ctx->async_data.free_list); 1767 pasync_ctx->async_data.free_entries++; 1768 } 1769 } 1770 1771 INIT_LIST_HEAD(&pasync_ctx->async_entry[cri].wait_queue.list); 1772 pasync_ctx->async_entry[cri].wait_queue.hdr_received = 0; 1773 pasync_ctx->async_entry[cri].wait_queue.bytes_received = 0; 1774 } 1775 1776 static struct phys_addr * 1777 hwi_get_ring_address(struct hwi_async_pdu_context *pasync_ctx, 1778 unsigned int is_header, unsigned int host_write_ptr) 1779 { 1780 struct phys_addr *pasync_sge = NULL; 1781 1782 if (is_header) 1783 pasync_sge = pasync_ctx->async_header.ring_base; 1784 else 1785 pasync_sge = pasync_ctx->async_data.ring_base; 1786 1787 return pasync_sge + host_write_ptr; 1788 } 1789 1790 static void hwi_post_async_buffers(struct beiscsi_hba *phba, 1791 unsigned int is_header, uint8_t ulp_num) 1792 { 1793 struct hwi_controller *phwi_ctrlr; 1794 struct hwi_async_pdu_context *pasync_ctx; 1795 struct async_pdu_handle *pasync_handle; 1796 struct list_head *pfree_link, *pbusy_list; 1797 struct phys_addr *pasync_sge; 1798 unsigned int ring_id, num_entries; 1799 unsigned int host_write_num, doorbell_offset; 1800 unsigned int writables; 1801 unsigned int i = 0; 1802 u32 doorbell = 0; 1803 1804 phwi_ctrlr = phba->phwi_ctrlr; 1805 pasync_ctx = HWI_GET_ASYNC_PDU_CTX(phwi_ctrlr, ulp_num); 1806 num_entries = pasync_ctx->num_entries; 1807 1808 if (is_header) { 1809 writables = min(pasync_ctx->async_header.writables, 1810 pasync_ctx->async_header.free_entries); 1811 pfree_link = pasync_ctx->async_header.free_list.next; 1812 host_write_num = pasync_ctx->async_header.host_write_ptr; 1813 ring_id = phwi_ctrlr->default_pdu_hdr[ulp_num].id; 1814 doorbell_offset = phwi_ctrlr->default_pdu_hdr[ulp_num]. 1815 doorbell_offset; 1816 } else { 1817 writables = min(pasync_ctx->async_data.writables, 1818 pasync_ctx->async_data.free_entries); 1819 pfree_link = pasync_ctx->async_data.free_list.next; 1820 host_write_num = pasync_ctx->async_data.host_write_ptr; 1821 ring_id = phwi_ctrlr->default_pdu_data[ulp_num].id; 1822 doorbell_offset = phwi_ctrlr->default_pdu_data[ulp_num]. 1823 doorbell_offset; 1824 } 1825 1826 writables = (writables / 8) * 8; 1827 if (writables) { 1828 for (i = 0; i < writables; i++) { 1829 pbusy_list = 1830 hwi_get_async_busy_list(pasync_ctx, is_header, 1831 host_write_num); 1832 pasync_handle = 1833 list_entry(pfree_link, struct async_pdu_handle, 1834 link); 1835 WARN_ON(!pasync_handle); 1836 pasync_handle->consumed = 0; 1837 1838 pfree_link = pfree_link->next; 1839 1840 pasync_sge = hwi_get_ring_address(pasync_ctx, 1841 is_header, host_write_num); 1842 1843 pasync_sge->hi = pasync_handle->pa.u.a32.address_lo; 1844 pasync_sge->lo = pasync_handle->pa.u.a32.address_hi; 1845 1846 list_move(&pasync_handle->link, pbusy_list); 1847 1848 host_write_num++; 1849 host_write_num = host_write_num % num_entries; 1850 } 1851 1852 if (is_header) { 1853 pasync_ctx->async_header.host_write_ptr = 1854 host_write_num; 1855 pasync_ctx->async_header.free_entries -= writables; 1856 pasync_ctx->async_header.writables -= writables; 1857 pasync_ctx->async_header.busy_entries += writables; 1858 } else { 1859 pasync_ctx->async_data.host_write_ptr = host_write_num; 1860 pasync_ctx->async_data.free_entries -= writables; 1861 pasync_ctx->async_data.writables -= writables; 1862 pasync_ctx->async_data.busy_entries += writables; 1863 } 1864 1865 doorbell |= ring_id & DB_DEF_PDU_RING_ID_MASK; 1866 doorbell |= 1 << DB_DEF_PDU_REARM_SHIFT; 1867 doorbell |= 0 << DB_DEF_PDU_EVENT_SHIFT; 1868 doorbell |= (writables & DB_DEF_PDU_CQPROC_MASK) 1869 << DB_DEF_PDU_CQPROC_SHIFT; 1870 1871 iowrite32(doorbell, phba->db_va + doorbell_offset); 1872 } 1873 } 1874 1875 static void hwi_flush_default_pdu_buffer(struct beiscsi_hba *phba, 1876 struct beiscsi_conn *beiscsi_conn, 1877 struct i_t_dpdu_cqe *pdpdu_cqe) 1878 { 1879 struct hwi_controller *phwi_ctrlr; 1880 struct hwi_async_pdu_context *pasync_ctx; 1881 struct async_pdu_handle *pasync_handle = NULL; 1882 unsigned int cq_index = -1; 1883 uint16_t cri_index = BE_GET_CRI_FROM_CID( 1884 beiscsi_conn->beiscsi_conn_cid); 1885 1886 phwi_ctrlr = phba->phwi_ctrlr; 1887 pasync_ctx = HWI_GET_ASYNC_PDU_CTX(phwi_ctrlr, 1888 BEISCSI_GET_ULP_FROM_CRI(phwi_ctrlr, 1889 cri_index)); 1890 1891 pasync_handle = hwi_get_async_handle(phba, beiscsi_conn, pasync_ctx, 1892 pdpdu_cqe, &cq_index); 1893 BUG_ON(pasync_handle->is_header != 0); 1894 if (pasync_handle->consumed == 0) 1895 hwi_update_async_writables(phba, pasync_ctx, 1896 pasync_handle->is_header, cq_index); 1897 1898 hwi_free_async_msg(phba, pasync_ctx, pasync_handle->cri); 1899 hwi_post_async_buffers(phba, pasync_handle->is_header, 1900 BEISCSI_GET_ULP_FROM_CRI(phwi_ctrlr, 1901 cri_index)); 1902 } 1903 1904 static unsigned int 1905 hwi_fwd_async_msg(struct beiscsi_conn *beiscsi_conn, 1906 struct beiscsi_hba *phba, 1907 struct hwi_async_pdu_context *pasync_ctx, unsigned short cri) 1908 { 1909 struct list_head *plist; 1910 struct async_pdu_handle *pasync_handle; 1911 void *phdr = NULL; 1912 unsigned int hdr_len = 0, buf_len = 0; 1913 unsigned int status, index = 0, offset = 0; 1914 void *pfirst_buffer = NULL; 1915 unsigned int num_buf = 0; 1916 1917 plist = &pasync_ctx->async_entry[cri].wait_queue.list; 1918 1919 list_for_each_entry(pasync_handle, plist, link) { 1920 if (index == 0) { 1921 phdr = pasync_handle->pbuffer; 1922 hdr_len = pasync_handle->buffer_len; 1923 } else { 1924 buf_len = pasync_handle->buffer_len; 1925 if (!num_buf) { 1926 pfirst_buffer = pasync_handle->pbuffer; 1927 num_buf++; 1928 } 1929 memcpy(pfirst_buffer + offset, 1930 pasync_handle->pbuffer, buf_len); 1931 offset += buf_len; 1932 } 1933 index++; 1934 } 1935 1936 status = beiscsi_process_async_pdu(beiscsi_conn, phba, 1937 phdr, hdr_len, pfirst_buffer, 1938 offset); 1939 1940 hwi_free_async_msg(phba, pasync_ctx, cri); 1941 return 0; 1942 } 1943 1944 static unsigned int 1945 hwi_gather_async_pdu(struct beiscsi_conn *beiscsi_conn, 1946 struct beiscsi_hba *phba, 1947 struct async_pdu_handle *pasync_handle) 1948 { 1949 struct hwi_async_pdu_context *pasync_ctx; 1950 struct hwi_controller *phwi_ctrlr; 1951 unsigned int bytes_needed = 0, status = 0; 1952 unsigned short cri = pasync_handle->cri; 1953 struct pdu_base *ppdu; 1954 1955 phwi_ctrlr = phba->phwi_ctrlr; 1956 pasync_ctx = HWI_GET_ASYNC_PDU_CTX(phwi_ctrlr, 1957 BEISCSI_GET_ULP_FROM_CRI(phwi_ctrlr, 1958 BE_GET_CRI_FROM_CID(beiscsi_conn-> 1959 beiscsi_conn_cid))); 1960 1961 list_del(&pasync_handle->link); 1962 if (pasync_handle->is_header) { 1963 pasync_ctx->async_header.busy_entries--; 1964 if (pasync_ctx->async_entry[cri].wait_queue.hdr_received) { 1965 hwi_free_async_msg(phba, pasync_ctx, cri); 1966 BUG(); 1967 } 1968 1969 pasync_ctx->async_entry[cri].wait_queue.bytes_received = 0; 1970 pasync_ctx->async_entry[cri].wait_queue.hdr_received = 1; 1971 pasync_ctx->async_entry[cri].wait_queue.hdr_len = 1972 (unsigned short)pasync_handle->buffer_len; 1973 list_add_tail(&pasync_handle->link, 1974 &pasync_ctx->async_entry[cri].wait_queue.list); 1975 1976 ppdu = pasync_handle->pbuffer; 1977 bytes_needed = ((((ppdu->dw[offsetof(struct amap_pdu_base, 1978 data_len_hi) / 32] & PDUBASE_DATALENHI_MASK) << 8) & 1979 0xFFFF0000) | ((be16_to_cpu((ppdu-> 1980 dw[offsetof(struct amap_pdu_base, data_len_lo) / 32] 1981 & PDUBASE_DATALENLO_MASK) >> 16)) & 0x0000FFFF)); 1982 1983 if (status == 0) { 1984 pasync_ctx->async_entry[cri].wait_queue.bytes_needed = 1985 bytes_needed; 1986 1987 if (bytes_needed == 0) 1988 status = hwi_fwd_async_msg(beiscsi_conn, phba, 1989 pasync_ctx, cri); 1990 } 1991 } else { 1992 pasync_ctx->async_data.busy_entries--; 1993 if (pasync_ctx->async_entry[cri].wait_queue.hdr_received) { 1994 list_add_tail(&pasync_handle->link, 1995 &pasync_ctx->async_entry[cri].wait_queue. 1996 list); 1997 pasync_ctx->async_entry[cri].wait_queue. 1998 bytes_received += 1999 (unsigned short)pasync_handle->buffer_len; 2000 2001 if (pasync_ctx->async_entry[cri].wait_queue. 2002 bytes_received >= 2003 pasync_ctx->async_entry[cri].wait_queue. 2004 bytes_needed) 2005 status = hwi_fwd_async_msg(beiscsi_conn, phba, 2006 pasync_ctx, cri); 2007 } 2008 } 2009 return status; 2010 } 2011 2012 static void hwi_process_default_pdu_ring(struct beiscsi_conn *beiscsi_conn, 2013 struct beiscsi_hba *phba, 2014 struct i_t_dpdu_cqe *pdpdu_cqe) 2015 { 2016 struct hwi_controller *phwi_ctrlr; 2017 struct hwi_async_pdu_context *pasync_ctx; 2018 struct async_pdu_handle *pasync_handle = NULL; 2019 unsigned int cq_index = -1; 2020 uint16_t cri_index = BE_GET_CRI_FROM_CID( 2021 beiscsi_conn->beiscsi_conn_cid); 2022 2023 phwi_ctrlr = phba->phwi_ctrlr; 2024 pasync_ctx = HWI_GET_ASYNC_PDU_CTX(phwi_ctrlr, 2025 BEISCSI_GET_ULP_FROM_CRI(phwi_ctrlr, 2026 cri_index)); 2027 2028 pasync_handle = hwi_get_async_handle(phba, beiscsi_conn, pasync_ctx, 2029 pdpdu_cqe, &cq_index); 2030 2031 if (pasync_handle->consumed == 0) 2032 hwi_update_async_writables(phba, pasync_ctx, 2033 pasync_handle->is_header, cq_index); 2034 2035 hwi_gather_async_pdu(beiscsi_conn, phba, pasync_handle); 2036 hwi_post_async_buffers(phba, pasync_handle->is_header, 2037 BEISCSI_GET_ULP_FROM_CRI( 2038 phwi_ctrlr, cri_index)); 2039 } 2040 2041 static void beiscsi_process_mcc_isr(struct beiscsi_hba *phba) 2042 { 2043 struct be_queue_info *mcc_cq; 2044 struct be_mcc_compl *mcc_compl; 2045 unsigned int num_processed = 0; 2046 2047 mcc_cq = &phba->ctrl.mcc_obj.cq; 2048 mcc_compl = queue_tail_node(mcc_cq); 2049 mcc_compl->flags = le32_to_cpu(mcc_compl->flags); 2050 while (mcc_compl->flags & CQE_FLAGS_VALID_MASK) { 2051 2052 if (num_processed >= 32) { 2053 hwi_ring_cq_db(phba, mcc_cq->id, 2054 num_processed, 0, 0); 2055 num_processed = 0; 2056 } 2057 if (mcc_compl->flags & CQE_FLAGS_ASYNC_MASK) { 2058 /* Interpret flags as an async trailer */ 2059 if (is_link_state_evt(mcc_compl->flags)) 2060 /* Interpret compl as a async link evt */ 2061 beiscsi_async_link_state_process(phba, 2062 (struct be_async_event_link_state *) mcc_compl); 2063 else 2064 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_MBOX, 2065 "BM_%d : Unsupported Async Event, flags" 2066 " = 0x%08x\n", 2067 mcc_compl->flags); 2068 } else if (mcc_compl->flags & CQE_FLAGS_COMPLETED_MASK) { 2069 be_mcc_compl_process_isr(&phba->ctrl, mcc_compl); 2070 atomic_dec(&phba->ctrl.mcc_obj.q.used); 2071 } 2072 2073 mcc_compl->flags = 0; 2074 queue_tail_inc(mcc_cq); 2075 mcc_compl = queue_tail_node(mcc_cq); 2076 mcc_compl->flags = le32_to_cpu(mcc_compl->flags); 2077 num_processed++; 2078 } 2079 2080 if (num_processed > 0) 2081 hwi_ring_cq_db(phba, mcc_cq->id, num_processed, 1, 0); 2082 2083 } 2084 2085 /** 2086 * beiscsi_process_cq()- Process the Completion Queue 2087 * @pbe_eq: Event Q on which the Completion has come 2088 * 2089 * return 2090 * Number of Completion Entries processed. 2091 **/ 2092 static unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq) 2093 { 2094 struct be_queue_info *cq; 2095 struct sol_cqe *sol; 2096 struct dmsg_cqe *dmsg; 2097 unsigned int num_processed = 0; 2098 unsigned int tot_nump = 0; 2099 unsigned short code = 0, cid = 0; 2100 uint16_t cri_index = 0; 2101 struct beiscsi_conn *beiscsi_conn; 2102 struct beiscsi_endpoint *beiscsi_ep; 2103 struct iscsi_endpoint *ep; 2104 struct beiscsi_hba *phba; 2105 2106 cq = pbe_eq->cq; 2107 sol = queue_tail_node(cq); 2108 phba = pbe_eq->phba; 2109 2110 while (sol->dw[offsetof(struct amap_sol_cqe, valid) / 32] & 2111 CQE_VALID_MASK) { 2112 be_dws_le_to_cpu(sol, sizeof(struct sol_cqe)); 2113 2114 code = (sol->dw[offsetof(struct amap_sol_cqe, code) / 2115 32] & CQE_CODE_MASK); 2116 2117 /* Get the CID */ 2118 if (is_chip_be2_be3r(phba)) { 2119 cid = AMAP_GET_BITS(struct amap_sol_cqe, cid, sol); 2120 } else { 2121 if ((code == DRIVERMSG_NOTIFY) || 2122 (code == UNSOL_HDR_NOTIFY) || 2123 (code == UNSOL_DATA_NOTIFY)) 2124 cid = AMAP_GET_BITS( 2125 struct amap_i_t_dpdu_cqe_v2, 2126 cid, sol); 2127 else 2128 cid = AMAP_GET_BITS(struct amap_sol_cqe_v2, 2129 cid, sol); 2130 } 2131 2132 cri_index = BE_GET_CRI_FROM_CID(cid); 2133 ep = phba->ep_array[cri_index]; 2134 beiscsi_ep = ep->dd_data; 2135 beiscsi_conn = beiscsi_ep->conn; 2136 2137 if (num_processed >= 32) { 2138 hwi_ring_cq_db(phba, cq->id, 2139 num_processed, 0, 0); 2140 tot_nump += num_processed; 2141 num_processed = 0; 2142 } 2143 2144 switch (code) { 2145 case SOL_CMD_COMPLETE: 2146 hwi_complete_cmd(beiscsi_conn, phba, sol); 2147 break; 2148 case DRIVERMSG_NOTIFY: 2149 beiscsi_log(phba, KERN_INFO, 2150 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, 2151 "BM_%d : Received %s[%d] on CID : %d\n", 2152 cqe_desc[code], code, cid); 2153 2154 dmsg = (struct dmsg_cqe *)sol; 2155 hwi_complete_drvr_msgs(beiscsi_conn, phba, sol); 2156 break; 2157 case UNSOL_HDR_NOTIFY: 2158 beiscsi_log(phba, KERN_INFO, 2159 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, 2160 "BM_%d : Received %s[%d] on CID : %d\n", 2161 cqe_desc[code], code, cid); 2162 2163 spin_lock_bh(&phba->async_pdu_lock); 2164 hwi_process_default_pdu_ring(beiscsi_conn, phba, 2165 (struct i_t_dpdu_cqe *)sol); 2166 spin_unlock_bh(&phba->async_pdu_lock); 2167 break; 2168 case UNSOL_DATA_NOTIFY: 2169 beiscsi_log(phba, KERN_INFO, 2170 BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO, 2171 "BM_%d : Received %s[%d] on CID : %d\n", 2172 cqe_desc[code], code, cid); 2173 2174 spin_lock_bh(&phba->async_pdu_lock); 2175 hwi_process_default_pdu_ring(beiscsi_conn, phba, 2176 (struct i_t_dpdu_cqe *)sol); 2177 spin_unlock_bh(&phba->async_pdu_lock); 2178 break; 2179 case CXN_INVALIDATE_INDEX_NOTIFY: 2180 case CMD_INVALIDATED_NOTIFY: 2181 case CXN_INVALIDATE_NOTIFY: 2182 beiscsi_log(phba, KERN_ERR, 2183 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, 2184 "BM_%d : Ignoring %s[%d] on CID : %d\n", 2185 cqe_desc[code], code, cid); 2186 break; 2187 case SOL_CMD_KILLED_DATA_DIGEST_ERR: 2188 case CMD_KILLED_INVALID_STATSN_RCVD: 2189 case CMD_KILLED_INVALID_R2T_RCVD: 2190 case CMD_CXN_KILLED_LUN_INVALID: 2191 case CMD_CXN_KILLED_ICD_INVALID: 2192 case CMD_CXN_KILLED_ITT_INVALID: 2193 case CMD_CXN_KILLED_SEQ_OUTOFORDER: 2194 case CMD_CXN_KILLED_INVALID_DATASN_RCVD: 2195 beiscsi_log(phba, KERN_ERR, 2196 BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO, 2197 "BM_%d : Cmd Notification %s[%d] on CID : %d\n", 2198 cqe_desc[code], code, cid); 2199 break; 2200 case UNSOL_DATA_DIGEST_ERROR_NOTIFY: 2201 beiscsi_log(phba, KERN_ERR, 2202 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, 2203 "BM_%d : Dropping %s[%d] on DPDU ring on CID : %d\n", 2204 cqe_desc[code], code, cid); 2205 spin_lock_bh(&phba->async_pdu_lock); 2206 hwi_flush_default_pdu_buffer(phba, beiscsi_conn, 2207 (struct i_t_dpdu_cqe *) sol); 2208 spin_unlock_bh(&phba->async_pdu_lock); 2209 break; 2210 case CXN_KILLED_PDU_SIZE_EXCEEDS_DSL: 2211 case CXN_KILLED_BURST_LEN_MISMATCH: 2212 case CXN_KILLED_AHS_RCVD: 2213 case CXN_KILLED_HDR_DIGEST_ERR: 2214 case CXN_KILLED_UNKNOWN_HDR: 2215 case CXN_KILLED_STALE_ITT_TTT_RCVD: 2216 case CXN_KILLED_INVALID_ITT_TTT_RCVD: 2217 case CXN_KILLED_TIMED_OUT: 2218 case CXN_KILLED_FIN_RCVD: 2219 case CXN_KILLED_RST_SENT: 2220 case CXN_KILLED_RST_RCVD: 2221 case CXN_KILLED_BAD_UNSOL_PDU_RCVD: 2222 case CXN_KILLED_BAD_WRB_INDEX_ERROR: 2223 case CXN_KILLED_OVER_RUN_RESIDUAL: 2224 case CXN_KILLED_UNDER_RUN_RESIDUAL: 2225 case CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN: 2226 beiscsi_log(phba, KERN_ERR, 2227 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, 2228 "BM_%d : Event %s[%d] received on CID : %d\n", 2229 cqe_desc[code], code, cid); 2230 if (beiscsi_conn) 2231 iscsi_conn_failure(beiscsi_conn->conn, 2232 ISCSI_ERR_CONN_FAILED); 2233 break; 2234 default: 2235 beiscsi_log(phba, KERN_ERR, 2236 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, 2237 "BM_%d : Invalid CQE Event Received Code : %d" 2238 "CID 0x%x...\n", 2239 code, cid); 2240 break; 2241 } 2242 2243 AMAP_SET_BITS(struct amap_sol_cqe, valid, sol, 0); 2244 queue_tail_inc(cq); 2245 sol = queue_tail_node(cq); 2246 num_processed++; 2247 } 2248 2249 if (num_processed > 0) { 2250 tot_nump += num_processed; 2251 hwi_ring_cq_db(phba, cq->id, num_processed, 1, 0); 2252 } 2253 return tot_nump; 2254 } 2255 2256 void beiscsi_process_all_cqs(struct work_struct *work) 2257 { 2258 unsigned long flags; 2259 struct hwi_controller *phwi_ctrlr; 2260 struct hwi_context_memory *phwi_context; 2261 struct beiscsi_hba *phba; 2262 struct be_eq_obj *pbe_eq = 2263 container_of(work, struct be_eq_obj, work_cqs); 2264 2265 phba = pbe_eq->phba; 2266 phwi_ctrlr = phba->phwi_ctrlr; 2267 phwi_context = phwi_ctrlr->phwi_ctxt; 2268 2269 if (pbe_eq->todo_mcc_cq) { 2270 spin_lock_irqsave(&phba->isr_lock, flags); 2271 pbe_eq->todo_mcc_cq = false; 2272 spin_unlock_irqrestore(&phba->isr_lock, flags); 2273 beiscsi_process_mcc_isr(phba); 2274 } 2275 2276 if (pbe_eq->todo_cq) { 2277 spin_lock_irqsave(&phba->isr_lock, flags); 2278 pbe_eq->todo_cq = false; 2279 spin_unlock_irqrestore(&phba->isr_lock, flags); 2280 beiscsi_process_cq(pbe_eq); 2281 } 2282 2283 /* rearm EQ for further interrupts */ 2284 hwi_ring_eq_db(phba, pbe_eq->q.id, 0, 0, 1, 1); 2285 } 2286 2287 static int be_iopoll(struct blk_iopoll *iop, int budget) 2288 { 2289 unsigned int ret; 2290 struct beiscsi_hba *phba; 2291 struct be_eq_obj *pbe_eq; 2292 2293 pbe_eq = container_of(iop, struct be_eq_obj, iopoll); 2294 ret = beiscsi_process_cq(pbe_eq); 2295 if (ret < budget) { 2296 phba = pbe_eq->phba; 2297 blk_iopoll_complete(iop); 2298 beiscsi_log(phba, KERN_INFO, 2299 BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO, 2300 "BM_%d : rearm pbe_eq->q.id =%d\n", 2301 pbe_eq->q.id); 2302 hwi_ring_eq_db(phba, pbe_eq->q.id, 0, 0, 1, 1); 2303 } 2304 return ret; 2305 } 2306 2307 static void 2308 hwi_write_sgl_v2(struct iscsi_wrb *pwrb, struct scatterlist *sg, 2309 unsigned int num_sg, struct beiscsi_io_task *io_task) 2310 { 2311 struct iscsi_sge *psgl; 2312 unsigned int sg_len, index; 2313 unsigned int sge_len = 0; 2314 unsigned long long addr; 2315 struct scatterlist *l_sg; 2316 unsigned int offset; 2317 2318 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, iscsi_bhs_addr_lo, pwrb, 2319 io_task->bhs_pa.u.a32.address_lo); 2320 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, iscsi_bhs_addr_hi, pwrb, 2321 io_task->bhs_pa.u.a32.address_hi); 2322 2323 l_sg = sg; 2324 for (index = 0; (index < num_sg) && (index < 2); index++, 2325 sg = sg_next(sg)) { 2326 if (index == 0) { 2327 sg_len = sg_dma_len(sg); 2328 addr = (u64) sg_dma_address(sg); 2329 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, 2330 sge0_addr_lo, pwrb, 2331 lower_32_bits(addr)); 2332 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, 2333 sge0_addr_hi, pwrb, 2334 upper_32_bits(addr)); 2335 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, 2336 sge0_len, pwrb, 2337 sg_len); 2338 sge_len = sg_len; 2339 } else { 2340 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge1_r2t_offset, 2341 pwrb, sge_len); 2342 sg_len = sg_dma_len(sg); 2343 addr = (u64) sg_dma_address(sg); 2344 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, 2345 sge1_addr_lo, pwrb, 2346 lower_32_bits(addr)); 2347 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, 2348 sge1_addr_hi, pwrb, 2349 upper_32_bits(addr)); 2350 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, 2351 sge1_len, pwrb, 2352 sg_len); 2353 } 2354 } 2355 psgl = (struct iscsi_sge *)io_task->psgl_handle->pfrag; 2356 memset(psgl, 0, sizeof(*psgl) * BE2_SGE); 2357 2358 AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, io_task->bhs_len - 2); 2359 2360 AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl, 2361 io_task->bhs_pa.u.a32.address_hi); 2362 AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl, 2363 io_task->bhs_pa.u.a32.address_lo); 2364 2365 if (num_sg == 1) { 2366 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge0_last, pwrb, 2367 1); 2368 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge1_last, pwrb, 2369 0); 2370 } else if (num_sg == 2) { 2371 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge0_last, pwrb, 2372 0); 2373 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge1_last, pwrb, 2374 1); 2375 } else { 2376 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge0_last, pwrb, 2377 0); 2378 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge1_last, pwrb, 2379 0); 2380 } 2381 2382 sg = l_sg; 2383 psgl++; 2384 psgl++; 2385 offset = 0; 2386 for (index = 0; index < num_sg; index++, sg = sg_next(sg), psgl++) { 2387 sg_len = sg_dma_len(sg); 2388 addr = (u64) sg_dma_address(sg); 2389 AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl, 2390 lower_32_bits(addr)); 2391 AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl, 2392 upper_32_bits(addr)); 2393 AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, sg_len); 2394 AMAP_SET_BITS(struct amap_iscsi_sge, sge_offset, psgl, offset); 2395 AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 0); 2396 offset += sg_len; 2397 } 2398 psgl--; 2399 AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 1); 2400 } 2401 2402 static void 2403 hwi_write_sgl(struct iscsi_wrb *pwrb, struct scatterlist *sg, 2404 unsigned int num_sg, struct beiscsi_io_task *io_task) 2405 { 2406 struct iscsi_sge *psgl; 2407 unsigned int sg_len, index; 2408 unsigned int sge_len = 0; 2409 unsigned long long addr; 2410 struct scatterlist *l_sg; 2411 unsigned int offset; 2412 2413 AMAP_SET_BITS(struct amap_iscsi_wrb, iscsi_bhs_addr_lo, pwrb, 2414 io_task->bhs_pa.u.a32.address_lo); 2415 AMAP_SET_BITS(struct amap_iscsi_wrb, iscsi_bhs_addr_hi, pwrb, 2416 io_task->bhs_pa.u.a32.address_hi); 2417 2418 l_sg = sg; 2419 for (index = 0; (index < num_sg) && (index < 2); index++, 2420 sg = sg_next(sg)) { 2421 if (index == 0) { 2422 sg_len = sg_dma_len(sg); 2423 addr = (u64) sg_dma_address(sg); 2424 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_lo, pwrb, 2425 ((u32)(addr & 0xFFFFFFFF))); 2426 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_hi, pwrb, 2427 ((u32)(addr >> 32))); 2428 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_len, pwrb, 2429 sg_len); 2430 sge_len = sg_len; 2431 } else { 2432 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_r2t_offset, 2433 pwrb, sge_len); 2434 sg_len = sg_dma_len(sg); 2435 addr = (u64) sg_dma_address(sg); 2436 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_addr_lo, pwrb, 2437 ((u32)(addr & 0xFFFFFFFF))); 2438 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_addr_hi, pwrb, 2439 ((u32)(addr >> 32))); 2440 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_len, pwrb, 2441 sg_len); 2442 } 2443 } 2444 psgl = (struct iscsi_sge *)io_task->psgl_handle->pfrag; 2445 memset(psgl, 0, sizeof(*psgl) * BE2_SGE); 2446 2447 AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, io_task->bhs_len - 2); 2448 2449 AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl, 2450 io_task->bhs_pa.u.a32.address_hi); 2451 AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl, 2452 io_task->bhs_pa.u.a32.address_lo); 2453 2454 if (num_sg == 1) { 2455 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_last, pwrb, 2456 1); 2457 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_last, pwrb, 2458 0); 2459 } else if (num_sg == 2) { 2460 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_last, pwrb, 2461 0); 2462 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_last, pwrb, 2463 1); 2464 } else { 2465 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_last, pwrb, 2466 0); 2467 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_last, pwrb, 2468 0); 2469 } 2470 sg = l_sg; 2471 psgl++; 2472 psgl++; 2473 offset = 0; 2474 for (index = 0; index < num_sg; index++, sg = sg_next(sg), psgl++) { 2475 sg_len = sg_dma_len(sg); 2476 addr = (u64) sg_dma_address(sg); 2477 AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl, 2478 (addr & 0xFFFFFFFF)); 2479 AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl, 2480 (addr >> 32)); 2481 AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, sg_len); 2482 AMAP_SET_BITS(struct amap_iscsi_sge, sge_offset, psgl, offset); 2483 AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 0); 2484 offset += sg_len; 2485 } 2486 psgl--; 2487 AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 1); 2488 } 2489 2490 /** 2491 * hwi_write_buffer()- Populate the WRB with task info 2492 * @pwrb: ptr to the WRB entry 2493 * @task: iscsi task which is to be executed 2494 **/ 2495 static void hwi_write_buffer(struct iscsi_wrb *pwrb, struct iscsi_task *task) 2496 { 2497 struct iscsi_sge *psgl; 2498 struct beiscsi_io_task *io_task = task->dd_data; 2499 struct beiscsi_conn *beiscsi_conn = io_task->conn; 2500 struct beiscsi_hba *phba = beiscsi_conn->phba; 2501 uint8_t dsp_value = 0; 2502 2503 io_task->bhs_len = sizeof(struct be_nonio_bhs) - 2; 2504 AMAP_SET_BITS(struct amap_iscsi_wrb, iscsi_bhs_addr_lo, pwrb, 2505 io_task->bhs_pa.u.a32.address_lo); 2506 AMAP_SET_BITS(struct amap_iscsi_wrb, iscsi_bhs_addr_hi, pwrb, 2507 io_task->bhs_pa.u.a32.address_hi); 2508 2509 if (task->data) { 2510 2511 /* Check for the data_count */ 2512 dsp_value = (task->data_count) ? 1 : 0; 2513 2514 if (is_chip_be2_be3r(phba)) 2515 AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, 2516 pwrb, dsp_value); 2517 else 2518 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, dsp, 2519 pwrb, dsp_value); 2520 2521 /* Map addr only if there is data_count */ 2522 if (dsp_value) { 2523 io_task->mtask_addr = pci_map_single(phba->pcidev, 2524 task->data, 2525 task->data_count, 2526 PCI_DMA_TODEVICE); 2527 io_task->mtask_data_count = task->data_count; 2528 } else 2529 io_task->mtask_addr = 0; 2530 2531 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_lo, pwrb, 2532 lower_32_bits(io_task->mtask_addr)); 2533 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_hi, pwrb, 2534 upper_32_bits(io_task->mtask_addr)); 2535 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_len, pwrb, 2536 task->data_count); 2537 2538 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_last, pwrb, 1); 2539 } else { 2540 AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 0); 2541 io_task->mtask_addr = 0; 2542 } 2543 2544 psgl = (struct iscsi_sge *)io_task->psgl_handle->pfrag; 2545 2546 AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, io_task->bhs_len); 2547 2548 AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl, 2549 io_task->bhs_pa.u.a32.address_hi); 2550 AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl, 2551 io_task->bhs_pa.u.a32.address_lo); 2552 if (task->data) { 2553 psgl++; 2554 AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl, 0); 2555 AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl, 0); 2556 AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, 0); 2557 AMAP_SET_BITS(struct amap_iscsi_sge, sge_offset, psgl, 0); 2558 AMAP_SET_BITS(struct amap_iscsi_sge, rsvd0, psgl, 0); 2559 AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 0); 2560 2561 psgl++; 2562 if (task->data) { 2563 AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl, 2564 lower_32_bits(io_task->mtask_addr)); 2565 AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl, 2566 upper_32_bits(io_task->mtask_addr)); 2567 } 2568 AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, 0x106); 2569 } 2570 AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 1); 2571 } 2572 2573 /** 2574 * beiscsi_find_mem_req()- Find mem needed 2575 * @phba: ptr to HBA struct 2576 **/ 2577 static void beiscsi_find_mem_req(struct beiscsi_hba *phba) 2578 { 2579 uint8_t mem_descr_index, ulp_num; 2580 unsigned int num_cq_pages, num_async_pdu_buf_pages; 2581 unsigned int num_async_pdu_data_pages, wrb_sz_per_cxn; 2582 unsigned int num_async_pdu_buf_sgl_pages, num_async_pdu_data_sgl_pages; 2583 2584 num_cq_pages = PAGES_REQUIRED(phba->params.num_cq_entries * \ 2585 sizeof(struct sol_cqe)); 2586 2587 phba->params.hwi_ws_sz = sizeof(struct hwi_controller); 2588 2589 phba->mem_req[ISCSI_MEM_GLOBAL_HEADER] = 2 * 2590 BE_ISCSI_PDU_HEADER_SIZE; 2591 phba->mem_req[HWI_MEM_ADDN_CONTEXT] = 2592 sizeof(struct hwi_context_memory); 2593 2594 2595 phba->mem_req[HWI_MEM_WRB] = sizeof(struct iscsi_wrb) 2596 * (phba->params.wrbs_per_cxn) 2597 * phba->params.cxns_per_ctrl; 2598 wrb_sz_per_cxn = sizeof(struct wrb_handle) * 2599 (phba->params.wrbs_per_cxn); 2600 phba->mem_req[HWI_MEM_WRBH] = roundup_pow_of_two((wrb_sz_per_cxn) * 2601 phba->params.cxns_per_ctrl); 2602 2603 phba->mem_req[HWI_MEM_SGLH] = sizeof(struct sgl_handle) * 2604 phba->params.icds_per_ctrl; 2605 phba->mem_req[HWI_MEM_SGE] = sizeof(struct iscsi_sge) * 2606 phba->params.num_sge_per_io * phba->params.icds_per_ctrl; 2607 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) { 2608 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { 2609 2610 num_async_pdu_buf_sgl_pages = 2611 PAGES_REQUIRED(BEISCSI_GET_CID_COUNT( 2612 phba, ulp_num) * 2613 sizeof(struct phys_addr)); 2614 2615 num_async_pdu_buf_pages = 2616 PAGES_REQUIRED(BEISCSI_GET_CID_COUNT( 2617 phba, ulp_num) * 2618 phba->params.defpdu_hdr_sz); 2619 2620 num_async_pdu_data_pages = 2621 PAGES_REQUIRED(BEISCSI_GET_CID_COUNT( 2622 phba, ulp_num) * 2623 phba->params.defpdu_data_sz); 2624 2625 num_async_pdu_data_sgl_pages = 2626 PAGES_REQUIRED(BEISCSI_GET_CID_COUNT( 2627 phba, ulp_num) * 2628 sizeof(struct phys_addr)); 2629 2630 mem_descr_index = (HWI_MEM_TEMPLATE_HDR_ULP0 + 2631 (ulp_num * MEM_DESCR_OFFSET)); 2632 phba->mem_req[mem_descr_index] = 2633 BEISCSI_GET_CID_COUNT(phba, ulp_num) * 2634 BEISCSI_TEMPLATE_HDR_PER_CXN_SIZE; 2635 2636 mem_descr_index = (HWI_MEM_ASYNC_HEADER_BUF_ULP0 + 2637 (ulp_num * MEM_DESCR_OFFSET)); 2638 phba->mem_req[mem_descr_index] = 2639 num_async_pdu_buf_pages * 2640 PAGE_SIZE; 2641 2642 mem_descr_index = (HWI_MEM_ASYNC_DATA_BUF_ULP0 + 2643 (ulp_num * MEM_DESCR_OFFSET)); 2644 phba->mem_req[mem_descr_index] = 2645 num_async_pdu_data_pages * 2646 PAGE_SIZE; 2647 2648 mem_descr_index = (HWI_MEM_ASYNC_HEADER_RING_ULP0 + 2649 (ulp_num * MEM_DESCR_OFFSET)); 2650 phba->mem_req[mem_descr_index] = 2651 num_async_pdu_buf_sgl_pages * 2652 PAGE_SIZE; 2653 2654 mem_descr_index = (HWI_MEM_ASYNC_DATA_RING_ULP0 + 2655 (ulp_num * MEM_DESCR_OFFSET)); 2656 phba->mem_req[mem_descr_index] = 2657 num_async_pdu_data_sgl_pages * 2658 PAGE_SIZE; 2659 2660 mem_descr_index = (HWI_MEM_ASYNC_HEADER_HANDLE_ULP0 + 2661 (ulp_num * MEM_DESCR_OFFSET)); 2662 phba->mem_req[mem_descr_index] = 2663 BEISCSI_GET_CID_COUNT(phba, ulp_num) * 2664 sizeof(struct async_pdu_handle); 2665 2666 mem_descr_index = (HWI_MEM_ASYNC_DATA_HANDLE_ULP0 + 2667 (ulp_num * MEM_DESCR_OFFSET)); 2668 phba->mem_req[mem_descr_index] = 2669 BEISCSI_GET_CID_COUNT(phba, ulp_num) * 2670 sizeof(struct async_pdu_handle); 2671 2672 mem_descr_index = (HWI_MEM_ASYNC_PDU_CONTEXT_ULP0 + 2673 (ulp_num * MEM_DESCR_OFFSET)); 2674 phba->mem_req[mem_descr_index] = 2675 sizeof(struct hwi_async_pdu_context) + 2676 (BEISCSI_GET_CID_COUNT(phba, ulp_num) * 2677 sizeof(struct hwi_async_entry)); 2678 } 2679 } 2680 } 2681 2682 static int beiscsi_alloc_mem(struct beiscsi_hba *phba) 2683 { 2684 dma_addr_t bus_add; 2685 struct hwi_controller *phwi_ctrlr; 2686 struct be_mem_descriptor *mem_descr; 2687 struct mem_array *mem_arr, *mem_arr_orig; 2688 unsigned int i, j, alloc_size, curr_alloc_size; 2689 2690 phba->phwi_ctrlr = kzalloc(phba->params.hwi_ws_sz, GFP_KERNEL); 2691 if (!phba->phwi_ctrlr) 2692 return -ENOMEM; 2693 2694 /* Allocate memory for wrb_context */ 2695 phwi_ctrlr = phba->phwi_ctrlr; 2696 phwi_ctrlr->wrb_context = kzalloc(sizeof(struct hwi_wrb_context) * 2697 phba->params.cxns_per_ctrl, 2698 GFP_KERNEL); 2699 if (!phwi_ctrlr->wrb_context) 2700 return -ENOMEM; 2701 2702 phba->init_mem = kcalloc(SE_MEM_MAX, sizeof(*mem_descr), 2703 GFP_KERNEL); 2704 if (!phba->init_mem) { 2705 kfree(phwi_ctrlr->wrb_context); 2706 kfree(phba->phwi_ctrlr); 2707 return -ENOMEM; 2708 } 2709 2710 mem_arr_orig = kmalloc(sizeof(*mem_arr_orig) * BEISCSI_MAX_FRAGS_INIT, 2711 GFP_KERNEL); 2712 if (!mem_arr_orig) { 2713 kfree(phba->init_mem); 2714 kfree(phwi_ctrlr->wrb_context); 2715 kfree(phba->phwi_ctrlr); 2716 return -ENOMEM; 2717 } 2718 2719 mem_descr = phba->init_mem; 2720 for (i = 0; i < SE_MEM_MAX; i++) { 2721 if (!phba->mem_req[i]) { 2722 mem_descr->mem_array = NULL; 2723 mem_descr++; 2724 continue; 2725 } 2726 2727 j = 0; 2728 mem_arr = mem_arr_orig; 2729 alloc_size = phba->mem_req[i]; 2730 memset(mem_arr, 0, sizeof(struct mem_array) * 2731 BEISCSI_MAX_FRAGS_INIT); 2732 curr_alloc_size = min(be_max_phys_size * 1024, alloc_size); 2733 do { 2734 mem_arr->virtual_address = pci_alloc_consistent( 2735 phba->pcidev, 2736 curr_alloc_size, 2737 &bus_add); 2738 if (!mem_arr->virtual_address) { 2739 if (curr_alloc_size <= BE_MIN_MEM_SIZE) 2740 goto free_mem; 2741 if (curr_alloc_size - 2742 rounddown_pow_of_two(curr_alloc_size)) 2743 curr_alloc_size = rounddown_pow_of_two 2744 (curr_alloc_size); 2745 else 2746 curr_alloc_size = curr_alloc_size / 2; 2747 } else { 2748 mem_arr->bus_address.u. 2749 a64.address = (__u64) bus_add; 2750 mem_arr->size = curr_alloc_size; 2751 alloc_size -= curr_alloc_size; 2752 curr_alloc_size = min(be_max_phys_size * 2753 1024, alloc_size); 2754 j++; 2755 mem_arr++; 2756 } 2757 } while (alloc_size); 2758 mem_descr->num_elements = j; 2759 mem_descr->size_in_bytes = phba->mem_req[i]; 2760 mem_descr->mem_array = kmalloc(sizeof(*mem_arr) * j, 2761 GFP_KERNEL); 2762 if (!mem_descr->mem_array) 2763 goto free_mem; 2764 2765 memcpy(mem_descr->mem_array, mem_arr_orig, 2766 sizeof(struct mem_array) * j); 2767 mem_descr++; 2768 } 2769 kfree(mem_arr_orig); 2770 return 0; 2771 free_mem: 2772 mem_descr->num_elements = j; 2773 while ((i) || (j)) { 2774 for (j = mem_descr->num_elements; j > 0; j--) { 2775 pci_free_consistent(phba->pcidev, 2776 mem_descr->mem_array[j - 1].size, 2777 mem_descr->mem_array[j - 1]. 2778 virtual_address, 2779 (unsigned long)mem_descr-> 2780 mem_array[j - 1]. 2781 bus_address.u.a64.address); 2782 } 2783 if (i) { 2784 i--; 2785 kfree(mem_descr->mem_array); 2786 mem_descr--; 2787 } 2788 } 2789 kfree(mem_arr_orig); 2790 kfree(phba->init_mem); 2791 kfree(phba->phwi_ctrlr->wrb_context); 2792 kfree(phba->phwi_ctrlr); 2793 return -ENOMEM; 2794 } 2795 2796 static int beiscsi_get_memory(struct beiscsi_hba *phba) 2797 { 2798 beiscsi_find_mem_req(phba); 2799 return beiscsi_alloc_mem(phba); 2800 } 2801 2802 static void iscsi_init_global_templates(struct beiscsi_hba *phba) 2803 { 2804 struct pdu_data_out *pdata_out; 2805 struct pdu_nop_out *pnop_out; 2806 struct be_mem_descriptor *mem_descr; 2807 2808 mem_descr = phba->init_mem; 2809 mem_descr += ISCSI_MEM_GLOBAL_HEADER; 2810 pdata_out = 2811 (struct pdu_data_out *)mem_descr->mem_array[0].virtual_address; 2812 memset(pdata_out, 0, BE_ISCSI_PDU_HEADER_SIZE); 2813 2814 AMAP_SET_BITS(struct amap_pdu_data_out, opcode, pdata_out, 2815 IIOC_SCSI_DATA); 2816 2817 pnop_out = 2818 (struct pdu_nop_out *)((unsigned char *)mem_descr->mem_array[0]. 2819 virtual_address + BE_ISCSI_PDU_HEADER_SIZE); 2820 2821 memset(pnop_out, 0, BE_ISCSI_PDU_HEADER_SIZE); 2822 AMAP_SET_BITS(struct amap_pdu_nop_out, ttt, pnop_out, 0xFFFFFFFF); 2823 AMAP_SET_BITS(struct amap_pdu_nop_out, f_bit, pnop_out, 1); 2824 AMAP_SET_BITS(struct amap_pdu_nop_out, i_bit, pnop_out, 0); 2825 } 2826 2827 static int beiscsi_init_wrb_handle(struct beiscsi_hba *phba) 2828 { 2829 struct be_mem_descriptor *mem_descr_wrbh, *mem_descr_wrb; 2830 struct hwi_context_memory *phwi_ctxt; 2831 struct wrb_handle *pwrb_handle = NULL; 2832 struct hwi_controller *phwi_ctrlr; 2833 struct hwi_wrb_context *pwrb_context; 2834 struct iscsi_wrb *pwrb = NULL; 2835 unsigned int num_cxn_wrbh = 0; 2836 unsigned int num_cxn_wrb = 0, j, idx = 0, index; 2837 2838 mem_descr_wrbh = phba->init_mem; 2839 mem_descr_wrbh += HWI_MEM_WRBH; 2840 2841 mem_descr_wrb = phba->init_mem; 2842 mem_descr_wrb += HWI_MEM_WRB; 2843 phwi_ctrlr = phba->phwi_ctrlr; 2844 2845 /* Allocate memory for WRBQ */ 2846 phwi_ctxt = phwi_ctrlr->phwi_ctxt; 2847 phwi_ctxt->be_wrbq = kzalloc(sizeof(struct be_queue_info) * 2848 phba->params.cxns_per_ctrl, 2849 GFP_KERNEL); 2850 if (!phwi_ctxt->be_wrbq) { 2851 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 2852 "BM_%d : WRBQ Mem Alloc Failed\n"); 2853 return -ENOMEM; 2854 } 2855 2856 for (index = 0; index < phba->params.cxns_per_ctrl; index++) { 2857 pwrb_context = &phwi_ctrlr->wrb_context[index]; 2858 pwrb_context->pwrb_handle_base = 2859 kzalloc(sizeof(struct wrb_handle *) * 2860 phba->params.wrbs_per_cxn, GFP_KERNEL); 2861 if (!pwrb_context->pwrb_handle_base) { 2862 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 2863 "BM_%d : Mem Alloc Failed. Failing to load\n"); 2864 goto init_wrb_hndl_failed; 2865 } 2866 pwrb_context->pwrb_handle_basestd = 2867 kzalloc(sizeof(struct wrb_handle *) * 2868 phba->params.wrbs_per_cxn, GFP_KERNEL); 2869 if (!pwrb_context->pwrb_handle_basestd) { 2870 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 2871 "BM_%d : Mem Alloc Failed. Failing to load\n"); 2872 goto init_wrb_hndl_failed; 2873 } 2874 if (!num_cxn_wrbh) { 2875 pwrb_handle = 2876 mem_descr_wrbh->mem_array[idx].virtual_address; 2877 num_cxn_wrbh = ((mem_descr_wrbh->mem_array[idx].size) / 2878 ((sizeof(struct wrb_handle)) * 2879 phba->params.wrbs_per_cxn)); 2880 idx++; 2881 } 2882 pwrb_context->alloc_index = 0; 2883 pwrb_context->wrb_handles_available = 0; 2884 pwrb_context->free_index = 0; 2885 2886 if (num_cxn_wrbh) { 2887 for (j = 0; j < phba->params.wrbs_per_cxn; j++) { 2888 pwrb_context->pwrb_handle_base[j] = pwrb_handle; 2889 pwrb_context->pwrb_handle_basestd[j] = 2890 pwrb_handle; 2891 pwrb_context->wrb_handles_available++; 2892 pwrb_handle->wrb_index = j; 2893 pwrb_handle++; 2894 } 2895 num_cxn_wrbh--; 2896 } 2897 } 2898 idx = 0; 2899 for (index = 0; index < phba->params.cxns_per_ctrl; index++) { 2900 pwrb_context = &phwi_ctrlr->wrb_context[index]; 2901 if (!num_cxn_wrb) { 2902 pwrb = mem_descr_wrb->mem_array[idx].virtual_address; 2903 num_cxn_wrb = (mem_descr_wrb->mem_array[idx].size) / 2904 ((sizeof(struct iscsi_wrb) * 2905 phba->params.wrbs_per_cxn)); 2906 idx++; 2907 } 2908 2909 if (num_cxn_wrb) { 2910 for (j = 0; j < phba->params.wrbs_per_cxn; j++) { 2911 pwrb_handle = pwrb_context->pwrb_handle_base[j]; 2912 pwrb_handle->pwrb = pwrb; 2913 pwrb++; 2914 } 2915 num_cxn_wrb--; 2916 } 2917 } 2918 return 0; 2919 init_wrb_hndl_failed: 2920 for (j = index; j > 0; j--) { 2921 pwrb_context = &phwi_ctrlr->wrb_context[j]; 2922 kfree(pwrb_context->pwrb_handle_base); 2923 kfree(pwrb_context->pwrb_handle_basestd); 2924 } 2925 return -ENOMEM; 2926 } 2927 2928 static int hwi_init_async_pdu_ctx(struct beiscsi_hba *phba) 2929 { 2930 uint8_t ulp_num; 2931 struct hwi_controller *phwi_ctrlr; 2932 struct hba_parameters *p = &phba->params; 2933 struct hwi_async_pdu_context *pasync_ctx; 2934 struct async_pdu_handle *pasync_header_h, *pasync_data_h; 2935 unsigned int index, idx, num_per_mem, num_async_data; 2936 struct be_mem_descriptor *mem_descr; 2937 2938 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) { 2939 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { 2940 2941 mem_descr = (struct be_mem_descriptor *)phba->init_mem; 2942 mem_descr += (HWI_MEM_ASYNC_PDU_CONTEXT_ULP0 + 2943 (ulp_num * MEM_DESCR_OFFSET)); 2944 2945 phwi_ctrlr = phba->phwi_ctrlr; 2946 phwi_ctrlr->phwi_ctxt->pasync_ctx[ulp_num] = 2947 (struct hwi_async_pdu_context *) 2948 mem_descr->mem_array[0].virtual_address; 2949 2950 pasync_ctx = phwi_ctrlr->phwi_ctxt->pasync_ctx[ulp_num]; 2951 memset(pasync_ctx, 0, sizeof(*pasync_ctx)); 2952 2953 pasync_ctx->async_entry = 2954 (struct hwi_async_entry *) 2955 ((long unsigned int)pasync_ctx + 2956 sizeof(struct hwi_async_pdu_context)); 2957 2958 pasync_ctx->num_entries = BEISCSI_GET_CID_COUNT(phba, 2959 ulp_num); 2960 pasync_ctx->buffer_size = p->defpdu_hdr_sz; 2961 2962 mem_descr = (struct be_mem_descriptor *)phba->init_mem; 2963 mem_descr += HWI_MEM_ASYNC_HEADER_BUF_ULP0 + 2964 (ulp_num * MEM_DESCR_OFFSET); 2965 if (mem_descr->mem_array[0].virtual_address) { 2966 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 2967 "BM_%d : hwi_init_async_pdu_ctx" 2968 " HWI_MEM_ASYNC_HEADER_BUF_ULP%d va=%p\n", 2969 ulp_num, 2970 mem_descr->mem_array[0]. 2971 virtual_address); 2972 } else 2973 beiscsi_log(phba, KERN_WARNING, 2974 BEISCSI_LOG_INIT, 2975 "BM_%d : No Virtual address for ULP : %d\n", 2976 ulp_num); 2977 2978 pasync_ctx->async_header.va_base = 2979 mem_descr->mem_array[0].virtual_address; 2980 2981 pasync_ctx->async_header.pa_base.u.a64.address = 2982 mem_descr->mem_array[0]. 2983 bus_address.u.a64.address; 2984 2985 mem_descr = (struct be_mem_descriptor *)phba->init_mem; 2986 mem_descr += HWI_MEM_ASYNC_HEADER_RING_ULP0 + 2987 (ulp_num * MEM_DESCR_OFFSET); 2988 if (mem_descr->mem_array[0].virtual_address) { 2989 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 2990 "BM_%d : hwi_init_async_pdu_ctx" 2991 " HWI_MEM_ASYNC_HEADER_RING_ULP%d va=%p\n", 2992 ulp_num, 2993 mem_descr->mem_array[0]. 2994 virtual_address); 2995 } else 2996 beiscsi_log(phba, KERN_WARNING, 2997 BEISCSI_LOG_INIT, 2998 "BM_%d : No Virtual address for ULP : %d\n", 2999 ulp_num); 3000 3001 pasync_ctx->async_header.ring_base = 3002 mem_descr->mem_array[0].virtual_address; 3003 3004 mem_descr = (struct be_mem_descriptor *)phba->init_mem; 3005 mem_descr += HWI_MEM_ASYNC_HEADER_HANDLE_ULP0 + 3006 (ulp_num * MEM_DESCR_OFFSET); 3007 if (mem_descr->mem_array[0].virtual_address) { 3008 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 3009 "BM_%d : hwi_init_async_pdu_ctx" 3010 " HWI_MEM_ASYNC_HEADER_HANDLE_ULP%d va=%p\n", 3011 ulp_num, 3012 mem_descr->mem_array[0]. 3013 virtual_address); 3014 } else 3015 beiscsi_log(phba, KERN_WARNING, 3016 BEISCSI_LOG_INIT, 3017 "BM_%d : No Virtual address for ULP : %d\n", 3018 ulp_num); 3019 3020 pasync_ctx->async_header.handle_base = 3021 mem_descr->mem_array[0].virtual_address; 3022 pasync_ctx->async_header.writables = 0; 3023 INIT_LIST_HEAD(&pasync_ctx->async_header.free_list); 3024 3025 mem_descr = (struct be_mem_descriptor *)phba->init_mem; 3026 mem_descr += HWI_MEM_ASYNC_DATA_RING_ULP0 + 3027 (ulp_num * MEM_DESCR_OFFSET); 3028 if (mem_descr->mem_array[0].virtual_address) { 3029 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 3030 "BM_%d : hwi_init_async_pdu_ctx" 3031 " HWI_MEM_ASYNC_DATA_RING_ULP%d va=%p\n", 3032 ulp_num, 3033 mem_descr->mem_array[0]. 3034 virtual_address); 3035 } else 3036 beiscsi_log(phba, KERN_WARNING, 3037 BEISCSI_LOG_INIT, 3038 "BM_%d : No Virtual address for ULP : %d\n", 3039 ulp_num); 3040 3041 pasync_ctx->async_data.ring_base = 3042 mem_descr->mem_array[0].virtual_address; 3043 3044 mem_descr = (struct be_mem_descriptor *)phba->init_mem; 3045 mem_descr += HWI_MEM_ASYNC_DATA_HANDLE_ULP0 + 3046 (ulp_num * MEM_DESCR_OFFSET); 3047 if (!mem_descr->mem_array[0].virtual_address) 3048 beiscsi_log(phba, KERN_WARNING, 3049 BEISCSI_LOG_INIT, 3050 "BM_%d : No Virtual address for ULP : %d\n", 3051 ulp_num); 3052 3053 pasync_ctx->async_data.handle_base = 3054 mem_descr->mem_array[0].virtual_address; 3055 pasync_ctx->async_data.writables = 0; 3056 INIT_LIST_HEAD(&pasync_ctx->async_data.free_list); 3057 3058 pasync_header_h = 3059 (struct async_pdu_handle *) 3060 pasync_ctx->async_header.handle_base; 3061 pasync_data_h = 3062 (struct async_pdu_handle *) 3063 pasync_ctx->async_data.handle_base; 3064 3065 mem_descr = (struct be_mem_descriptor *)phba->init_mem; 3066 mem_descr += HWI_MEM_ASYNC_DATA_BUF_ULP0 + 3067 (ulp_num * MEM_DESCR_OFFSET); 3068 if (mem_descr->mem_array[0].virtual_address) { 3069 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 3070 "BM_%d : hwi_init_async_pdu_ctx" 3071 " HWI_MEM_ASYNC_DATA_BUF_ULP%d va=%p\n", 3072 ulp_num, 3073 mem_descr->mem_array[0]. 3074 virtual_address); 3075 } else 3076 beiscsi_log(phba, KERN_WARNING, 3077 BEISCSI_LOG_INIT, 3078 "BM_%d : No Virtual address for ULP : %d\n", 3079 ulp_num); 3080 3081 idx = 0; 3082 pasync_ctx->async_data.va_base = 3083 mem_descr->mem_array[idx].virtual_address; 3084 pasync_ctx->async_data.pa_base.u.a64.address = 3085 mem_descr->mem_array[idx]. 3086 bus_address.u.a64.address; 3087 3088 num_async_data = ((mem_descr->mem_array[idx].size) / 3089 phba->params.defpdu_data_sz); 3090 num_per_mem = 0; 3091 3092 for (index = 0; index < BEISCSI_GET_CID_COUNT 3093 (phba, ulp_num); index++) { 3094 pasync_header_h->cri = -1; 3095 pasync_header_h->index = (char)index; 3096 INIT_LIST_HEAD(&pasync_header_h->link); 3097 pasync_header_h->pbuffer = 3098 (void *)((unsigned long) 3099 (pasync_ctx-> 3100 async_header.va_base) + 3101 (p->defpdu_hdr_sz * index)); 3102 3103 pasync_header_h->pa.u.a64.address = 3104 pasync_ctx->async_header.pa_base.u.a64. 3105 address + (p->defpdu_hdr_sz * index); 3106 3107 list_add_tail(&pasync_header_h->link, 3108 &pasync_ctx->async_header. 3109 free_list); 3110 pasync_header_h++; 3111 pasync_ctx->async_header.free_entries++; 3112 pasync_ctx->async_header.writables++; 3113 3114 INIT_LIST_HEAD(&pasync_ctx->async_entry[index]. 3115 wait_queue.list); 3116 INIT_LIST_HEAD(&pasync_ctx->async_entry[index]. 3117 header_busy_list); 3118 pasync_data_h->cri = -1; 3119 pasync_data_h->index = (char)index; 3120 INIT_LIST_HEAD(&pasync_data_h->link); 3121 3122 if (!num_async_data) { 3123 num_per_mem = 0; 3124 idx++; 3125 pasync_ctx->async_data.va_base = 3126 mem_descr->mem_array[idx]. 3127 virtual_address; 3128 pasync_ctx->async_data.pa_base.u. 3129 a64.address = 3130 mem_descr->mem_array[idx]. 3131 bus_address.u.a64.address; 3132 num_async_data = 3133 ((mem_descr->mem_array[idx]. 3134 size) / 3135 phba->params.defpdu_data_sz); 3136 } 3137 pasync_data_h->pbuffer = 3138 (void *)((unsigned long) 3139 (pasync_ctx->async_data.va_base) + 3140 (p->defpdu_data_sz * num_per_mem)); 3141 3142 pasync_data_h->pa.u.a64.address = 3143 pasync_ctx->async_data.pa_base.u.a64. 3144 address + (p->defpdu_data_sz * 3145 num_per_mem); 3146 num_per_mem++; 3147 num_async_data--; 3148 3149 list_add_tail(&pasync_data_h->link, 3150 &pasync_ctx->async_data. 3151 free_list); 3152 pasync_data_h++; 3153 pasync_ctx->async_data.free_entries++; 3154 pasync_ctx->async_data.writables++; 3155 3156 INIT_LIST_HEAD(&pasync_ctx->async_entry[index]. 3157 data_busy_list); 3158 } 3159 3160 pasync_ctx->async_header.host_write_ptr = 0; 3161 pasync_ctx->async_header.ep_read_ptr = -1; 3162 pasync_ctx->async_data.host_write_ptr = 0; 3163 pasync_ctx->async_data.ep_read_ptr = -1; 3164 } 3165 } 3166 3167 return 0; 3168 } 3169 3170 static int 3171 be_sgl_create_contiguous(void *virtual_address, 3172 u64 physical_address, u32 length, 3173 struct be_dma_mem *sgl) 3174 { 3175 WARN_ON(!virtual_address); 3176 WARN_ON(!physical_address); 3177 WARN_ON(!length > 0); 3178 WARN_ON(!sgl); 3179 3180 sgl->va = virtual_address; 3181 sgl->dma = (unsigned long)physical_address; 3182 sgl->size = length; 3183 3184 return 0; 3185 } 3186 3187 static void be_sgl_destroy_contiguous(struct be_dma_mem *sgl) 3188 { 3189 memset(sgl, 0, sizeof(*sgl)); 3190 } 3191 3192 static void 3193 hwi_build_be_sgl_arr(struct beiscsi_hba *phba, 3194 struct mem_array *pmem, struct be_dma_mem *sgl) 3195 { 3196 if (sgl->va) 3197 be_sgl_destroy_contiguous(sgl); 3198 3199 be_sgl_create_contiguous(pmem->virtual_address, 3200 pmem->bus_address.u.a64.address, 3201 pmem->size, sgl); 3202 } 3203 3204 static void 3205 hwi_build_be_sgl_by_offset(struct beiscsi_hba *phba, 3206 struct mem_array *pmem, struct be_dma_mem *sgl) 3207 { 3208 if (sgl->va) 3209 be_sgl_destroy_contiguous(sgl); 3210 3211 be_sgl_create_contiguous((unsigned char *)pmem->virtual_address, 3212 pmem->bus_address.u.a64.address, 3213 pmem->size, sgl); 3214 } 3215 3216 static int be_fill_queue(struct be_queue_info *q, 3217 u16 len, u16 entry_size, void *vaddress) 3218 { 3219 struct be_dma_mem *mem = &q->dma_mem; 3220 3221 memset(q, 0, sizeof(*q)); 3222 q->len = len; 3223 q->entry_size = entry_size; 3224 mem->size = len * entry_size; 3225 mem->va = vaddress; 3226 if (!mem->va) 3227 return -ENOMEM; 3228 memset(mem->va, 0, mem->size); 3229 return 0; 3230 } 3231 3232 static int beiscsi_create_eqs(struct beiscsi_hba *phba, 3233 struct hwi_context_memory *phwi_context) 3234 { 3235 unsigned int i, num_eq_pages; 3236 int ret = 0, eq_for_mcc; 3237 struct be_queue_info *eq; 3238 struct be_dma_mem *mem; 3239 void *eq_vaddress; 3240 dma_addr_t paddr; 3241 3242 num_eq_pages = PAGES_REQUIRED(phba->params.num_eq_entries * \ 3243 sizeof(struct be_eq_entry)); 3244 3245 if (phba->msix_enabled) 3246 eq_for_mcc = 1; 3247 else 3248 eq_for_mcc = 0; 3249 for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) { 3250 eq = &phwi_context->be_eq[i].q; 3251 mem = &eq->dma_mem; 3252 phwi_context->be_eq[i].phba = phba; 3253 eq_vaddress = pci_alloc_consistent(phba->pcidev, 3254 num_eq_pages * PAGE_SIZE, 3255 &paddr); 3256 if (!eq_vaddress) 3257 goto create_eq_error; 3258 3259 mem->va = eq_vaddress; 3260 ret = be_fill_queue(eq, phba->params.num_eq_entries, 3261 sizeof(struct be_eq_entry), eq_vaddress); 3262 if (ret) { 3263 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3264 "BM_%d : be_fill_queue Failed for EQ\n"); 3265 goto create_eq_error; 3266 } 3267 3268 mem->dma = paddr; 3269 ret = beiscsi_cmd_eq_create(&phba->ctrl, eq, 3270 phwi_context->cur_eqd); 3271 if (ret) { 3272 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3273 "BM_%d : beiscsi_cmd_eq_create" 3274 "Failed for EQ\n"); 3275 goto create_eq_error; 3276 } 3277 3278 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 3279 "BM_%d : eqid = %d\n", 3280 phwi_context->be_eq[i].q.id); 3281 } 3282 return 0; 3283 create_eq_error: 3284 for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) { 3285 eq = &phwi_context->be_eq[i].q; 3286 mem = &eq->dma_mem; 3287 if (mem->va) 3288 pci_free_consistent(phba->pcidev, num_eq_pages 3289 * PAGE_SIZE, 3290 mem->va, mem->dma); 3291 } 3292 return ret; 3293 } 3294 3295 static int beiscsi_create_cqs(struct beiscsi_hba *phba, 3296 struct hwi_context_memory *phwi_context) 3297 { 3298 unsigned int i, num_cq_pages; 3299 int ret = 0; 3300 struct be_queue_info *cq, *eq; 3301 struct be_dma_mem *mem; 3302 struct be_eq_obj *pbe_eq; 3303 void *cq_vaddress; 3304 dma_addr_t paddr; 3305 3306 num_cq_pages = PAGES_REQUIRED(phba->params.num_cq_entries * \ 3307 sizeof(struct sol_cqe)); 3308 3309 for (i = 0; i < phba->num_cpus; i++) { 3310 cq = &phwi_context->be_cq[i]; 3311 eq = &phwi_context->be_eq[i].q; 3312 pbe_eq = &phwi_context->be_eq[i]; 3313 pbe_eq->cq = cq; 3314 pbe_eq->phba = phba; 3315 mem = &cq->dma_mem; 3316 cq_vaddress = pci_alloc_consistent(phba->pcidev, 3317 num_cq_pages * PAGE_SIZE, 3318 &paddr); 3319 if (!cq_vaddress) 3320 goto create_cq_error; 3321 ret = be_fill_queue(cq, phba->params.num_cq_entries, 3322 sizeof(struct sol_cqe), cq_vaddress); 3323 if (ret) { 3324 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3325 "BM_%d : be_fill_queue Failed " 3326 "for ISCSI CQ\n"); 3327 goto create_cq_error; 3328 } 3329 3330 mem->dma = paddr; 3331 ret = beiscsi_cmd_cq_create(&phba->ctrl, cq, eq, false, 3332 false, 0); 3333 if (ret) { 3334 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3335 "BM_%d : beiscsi_cmd_eq_create" 3336 "Failed for ISCSI CQ\n"); 3337 goto create_cq_error; 3338 } 3339 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 3340 "BM_%d : iscsi cq_id is %d for eq_id %d\n" 3341 "iSCSI CQ CREATED\n", cq->id, eq->id); 3342 } 3343 return 0; 3344 3345 create_cq_error: 3346 for (i = 0; i < phba->num_cpus; i++) { 3347 cq = &phwi_context->be_cq[i]; 3348 mem = &cq->dma_mem; 3349 if (mem->va) 3350 pci_free_consistent(phba->pcidev, num_cq_pages 3351 * PAGE_SIZE, 3352 mem->va, mem->dma); 3353 } 3354 return ret; 3355 3356 } 3357 3358 static int 3359 beiscsi_create_def_hdr(struct beiscsi_hba *phba, 3360 struct hwi_context_memory *phwi_context, 3361 struct hwi_controller *phwi_ctrlr, 3362 unsigned int def_pdu_ring_sz, uint8_t ulp_num) 3363 { 3364 unsigned int idx; 3365 int ret; 3366 struct be_queue_info *dq, *cq; 3367 struct be_dma_mem *mem; 3368 struct be_mem_descriptor *mem_descr; 3369 void *dq_vaddress; 3370 3371 idx = 0; 3372 dq = &phwi_context->be_def_hdrq[ulp_num]; 3373 cq = &phwi_context->be_cq[0]; 3374 mem = &dq->dma_mem; 3375 mem_descr = phba->init_mem; 3376 mem_descr += HWI_MEM_ASYNC_HEADER_RING_ULP0 + 3377 (ulp_num * MEM_DESCR_OFFSET); 3378 dq_vaddress = mem_descr->mem_array[idx].virtual_address; 3379 ret = be_fill_queue(dq, mem_descr->mem_array[0].size / 3380 sizeof(struct phys_addr), 3381 sizeof(struct phys_addr), dq_vaddress); 3382 if (ret) { 3383 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3384 "BM_%d : be_fill_queue Failed for DEF PDU HDR on ULP : %d\n", 3385 ulp_num); 3386 3387 return ret; 3388 } 3389 mem->dma = (unsigned long)mem_descr->mem_array[idx]. 3390 bus_address.u.a64.address; 3391 ret = be_cmd_create_default_pdu_queue(&phba->ctrl, cq, dq, 3392 def_pdu_ring_sz, 3393 phba->params.defpdu_hdr_sz, 3394 BEISCSI_DEFQ_HDR, ulp_num); 3395 if (ret) { 3396 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3397 "BM_%d : be_cmd_create_default_pdu_queue Failed DEFHDR on ULP : %d\n", 3398 ulp_num); 3399 3400 return ret; 3401 } 3402 3403 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 3404 "BM_%d : iscsi hdr def pdu id for ULP : %d is %d\n", 3405 ulp_num, 3406 phwi_context->be_def_hdrq[ulp_num].id); 3407 hwi_post_async_buffers(phba, BEISCSI_DEFQ_HDR, ulp_num); 3408 return 0; 3409 } 3410 3411 static int 3412 beiscsi_create_def_data(struct beiscsi_hba *phba, 3413 struct hwi_context_memory *phwi_context, 3414 struct hwi_controller *phwi_ctrlr, 3415 unsigned int def_pdu_ring_sz, uint8_t ulp_num) 3416 { 3417 unsigned int idx; 3418 int ret; 3419 struct be_queue_info *dataq, *cq; 3420 struct be_dma_mem *mem; 3421 struct be_mem_descriptor *mem_descr; 3422 void *dq_vaddress; 3423 3424 idx = 0; 3425 dataq = &phwi_context->be_def_dataq[ulp_num]; 3426 cq = &phwi_context->be_cq[0]; 3427 mem = &dataq->dma_mem; 3428 mem_descr = phba->init_mem; 3429 mem_descr += HWI_MEM_ASYNC_DATA_RING_ULP0 + 3430 (ulp_num * MEM_DESCR_OFFSET); 3431 dq_vaddress = mem_descr->mem_array[idx].virtual_address; 3432 ret = be_fill_queue(dataq, mem_descr->mem_array[0].size / 3433 sizeof(struct phys_addr), 3434 sizeof(struct phys_addr), dq_vaddress); 3435 if (ret) { 3436 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3437 "BM_%d : be_fill_queue Failed for DEF PDU " 3438 "DATA on ULP : %d\n", 3439 ulp_num); 3440 3441 return ret; 3442 } 3443 mem->dma = (unsigned long)mem_descr->mem_array[idx]. 3444 bus_address.u.a64.address; 3445 ret = be_cmd_create_default_pdu_queue(&phba->ctrl, cq, dataq, 3446 def_pdu_ring_sz, 3447 phba->params.defpdu_data_sz, 3448 BEISCSI_DEFQ_DATA, ulp_num); 3449 if (ret) { 3450 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3451 "BM_%d be_cmd_create_default_pdu_queue" 3452 " Failed for DEF PDU DATA on ULP : %d\n", 3453 ulp_num); 3454 return ret; 3455 } 3456 3457 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 3458 "BM_%d : iscsi def data id on ULP : %d is %d\n", 3459 ulp_num, 3460 phwi_context->be_def_dataq[ulp_num].id); 3461 3462 hwi_post_async_buffers(phba, BEISCSI_DEFQ_DATA, ulp_num); 3463 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 3464 "BM_%d : DEFAULT PDU DATA RING CREATED" 3465 "on ULP : %d\n", ulp_num); 3466 3467 return 0; 3468 } 3469 3470 3471 static int 3472 beiscsi_post_template_hdr(struct beiscsi_hba *phba) 3473 { 3474 struct be_mem_descriptor *mem_descr; 3475 struct mem_array *pm_arr; 3476 struct be_dma_mem sgl; 3477 int status, ulp_num; 3478 3479 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) { 3480 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { 3481 mem_descr = (struct be_mem_descriptor *)phba->init_mem; 3482 mem_descr += HWI_MEM_TEMPLATE_HDR_ULP0 + 3483 (ulp_num * MEM_DESCR_OFFSET); 3484 pm_arr = mem_descr->mem_array; 3485 3486 hwi_build_be_sgl_arr(phba, pm_arr, &sgl); 3487 status = be_cmd_iscsi_post_template_hdr( 3488 &phba->ctrl, &sgl); 3489 3490 if (status != 0) { 3491 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3492 "BM_%d : Post Template HDR Failed for" 3493 "ULP_%d\n", ulp_num); 3494 return status; 3495 } 3496 3497 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 3498 "BM_%d : Template HDR Pages Posted for" 3499 "ULP_%d\n", ulp_num); 3500 } 3501 } 3502 return 0; 3503 } 3504 3505 static int 3506 beiscsi_post_pages(struct beiscsi_hba *phba) 3507 { 3508 struct be_mem_descriptor *mem_descr; 3509 struct mem_array *pm_arr; 3510 unsigned int page_offset, i; 3511 struct be_dma_mem sgl; 3512 int status, ulp_num = 0; 3513 3514 mem_descr = phba->init_mem; 3515 mem_descr += HWI_MEM_SGE; 3516 pm_arr = mem_descr->mem_array; 3517 3518 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) 3519 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) 3520 break; 3521 3522 page_offset = (sizeof(struct iscsi_sge) * phba->params.num_sge_per_io * 3523 phba->fw_config.iscsi_icd_start[ulp_num]) / PAGE_SIZE; 3524 for (i = 0; i < mem_descr->num_elements; i++) { 3525 hwi_build_be_sgl_arr(phba, pm_arr, &sgl); 3526 status = be_cmd_iscsi_post_sgl_pages(&phba->ctrl, &sgl, 3527 page_offset, 3528 (pm_arr->size / PAGE_SIZE)); 3529 page_offset += pm_arr->size / PAGE_SIZE; 3530 if (status != 0) { 3531 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3532 "BM_%d : post sgl failed.\n"); 3533 return status; 3534 } 3535 pm_arr++; 3536 } 3537 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 3538 "BM_%d : POSTED PAGES\n"); 3539 return 0; 3540 } 3541 3542 static void be_queue_free(struct beiscsi_hba *phba, struct be_queue_info *q) 3543 { 3544 struct be_dma_mem *mem = &q->dma_mem; 3545 if (mem->va) { 3546 pci_free_consistent(phba->pcidev, mem->size, 3547 mem->va, mem->dma); 3548 mem->va = NULL; 3549 } 3550 } 3551 3552 static int be_queue_alloc(struct beiscsi_hba *phba, struct be_queue_info *q, 3553 u16 len, u16 entry_size) 3554 { 3555 struct be_dma_mem *mem = &q->dma_mem; 3556 3557 memset(q, 0, sizeof(*q)); 3558 q->len = len; 3559 q->entry_size = entry_size; 3560 mem->size = len * entry_size; 3561 mem->va = pci_alloc_consistent(phba->pcidev, mem->size, &mem->dma); 3562 if (!mem->va) 3563 return -ENOMEM; 3564 memset(mem->va, 0, mem->size); 3565 return 0; 3566 } 3567 3568 static int 3569 beiscsi_create_wrb_rings(struct beiscsi_hba *phba, 3570 struct hwi_context_memory *phwi_context, 3571 struct hwi_controller *phwi_ctrlr) 3572 { 3573 unsigned int wrb_mem_index, offset, size, num_wrb_rings; 3574 u64 pa_addr_lo; 3575 unsigned int idx, num, i, ulp_num; 3576 struct mem_array *pwrb_arr; 3577 void *wrb_vaddr; 3578 struct be_dma_mem sgl; 3579 struct be_mem_descriptor *mem_descr; 3580 struct hwi_wrb_context *pwrb_context; 3581 int status; 3582 uint8_t ulp_count = 0, ulp_base_num = 0; 3583 uint16_t cid_count_ulp[BEISCSI_ULP_COUNT] = { 0 }; 3584 3585 idx = 0; 3586 mem_descr = phba->init_mem; 3587 mem_descr += HWI_MEM_WRB; 3588 pwrb_arr = kmalloc(sizeof(*pwrb_arr) * phba->params.cxns_per_ctrl, 3589 GFP_KERNEL); 3590 if (!pwrb_arr) { 3591 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3592 "BM_%d : Memory alloc failed in create wrb ring.\n"); 3593 return -ENOMEM; 3594 } 3595 wrb_vaddr = mem_descr->mem_array[idx].virtual_address; 3596 pa_addr_lo = mem_descr->mem_array[idx].bus_address.u.a64.address; 3597 num_wrb_rings = mem_descr->mem_array[idx].size / 3598 (phba->params.wrbs_per_cxn * sizeof(struct iscsi_wrb)); 3599 3600 for (num = 0; num < phba->params.cxns_per_ctrl; num++) { 3601 if (num_wrb_rings) { 3602 pwrb_arr[num].virtual_address = wrb_vaddr; 3603 pwrb_arr[num].bus_address.u.a64.address = pa_addr_lo; 3604 pwrb_arr[num].size = phba->params.wrbs_per_cxn * 3605 sizeof(struct iscsi_wrb); 3606 wrb_vaddr += pwrb_arr[num].size; 3607 pa_addr_lo += pwrb_arr[num].size; 3608 num_wrb_rings--; 3609 } else { 3610 idx++; 3611 wrb_vaddr = mem_descr->mem_array[idx].virtual_address; 3612 pa_addr_lo = mem_descr->mem_array[idx].\ 3613 bus_address.u.a64.address; 3614 num_wrb_rings = mem_descr->mem_array[idx].size / 3615 (phba->params.wrbs_per_cxn * 3616 sizeof(struct iscsi_wrb)); 3617 pwrb_arr[num].virtual_address = wrb_vaddr; 3618 pwrb_arr[num].bus_address.u.a64.address\ 3619 = pa_addr_lo; 3620 pwrb_arr[num].size = phba->params.wrbs_per_cxn * 3621 sizeof(struct iscsi_wrb); 3622 wrb_vaddr += pwrb_arr[num].size; 3623 pa_addr_lo += pwrb_arr[num].size; 3624 num_wrb_rings--; 3625 } 3626 } 3627 3628 /* Get the ULP Count */ 3629 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) 3630 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { 3631 ulp_count++; 3632 ulp_base_num = ulp_num; 3633 cid_count_ulp[ulp_num] = 3634 BEISCSI_GET_CID_COUNT(phba, ulp_num); 3635 } 3636 3637 for (i = 0; i < phba->params.cxns_per_ctrl; i++) { 3638 wrb_mem_index = 0; 3639 offset = 0; 3640 size = 0; 3641 3642 if (ulp_count > 1) { 3643 ulp_base_num = (ulp_base_num + 1) % BEISCSI_ULP_COUNT; 3644 3645 if (!cid_count_ulp[ulp_base_num]) 3646 ulp_base_num = (ulp_base_num + 1) % 3647 BEISCSI_ULP_COUNT; 3648 3649 cid_count_ulp[ulp_base_num]--; 3650 } 3651 3652 3653 hwi_build_be_sgl_by_offset(phba, &pwrb_arr[i], &sgl); 3654 status = be_cmd_wrbq_create(&phba->ctrl, &sgl, 3655 &phwi_context->be_wrbq[i], 3656 &phwi_ctrlr->wrb_context[i], 3657 ulp_base_num); 3658 if (status != 0) { 3659 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3660 "BM_%d : wrbq create failed."); 3661 kfree(pwrb_arr); 3662 return status; 3663 } 3664 pwrb_context = &phwi_ctrlr->wrb_context[i]; 3665 BE_SET_CID_TO_CRI(i, pwrb_context->cid); 3666 } 3667 kfree(pwrb_arr); 3668 return 0; 3669 } 3670 3671 static void free_wrb_handles(struct beiscsi_hba *phba) 3672 { 3673 unsigned int index; 3674 struct hwi_controller *phwi_ctrlr; 3675 struct hwi_wrb_context *pwrb_context; 3676 3677 phwi_ctrlr = phba->phwi_ctrlr; 3678 for (index = 0; index < phba->params.cxns_per_ctrl; index++) { 3679 pwrb_context = &phwi_ctrlr->wrb_context[index]; 3680 kfree(pwrb_context->pwrb_handle_base); 3681 kfree(pwrb_context->pwrb_handle_basestd); 3682 } 3683 } 3684 3685 static void be_mcc_queues_destroy(struct beiscsi_hba *phba) 3686 { 3687 struct be_queue_info *q; 3688 struct be_ctrl_info *ctrl = &phba->ctrl; 3689 3690 q = &phba->ctrl.mcc_obj.q; 3691 if (q->created) 3692 beiscsi_cmd_q_destroy(ctrl, q, QTYPE_MCCQ); 3693 be_queue_free(phba, q); 3694 3695 q = &phba->ctrl.mcc_obj.cq; 3696 if (q->created) 3697 beiscsi_cmd_q_destroy(ctrl, q, QTYPE_CQ); 3698 be_queue_free(phba, q); 3699 } 3700 3701 static void hwi_cleanup(struct beiscsi_hba *phba) 3702 { 3703 struct be_queue_info *q; 3704 struct be_ctrl_info *ctrl = &phba->ctrl; 3705 struct hwi_controller *phwi_ctrlr; 3706 struct hwi_context_memory *phwi_context; 3707 struct hwi_async_pdu_context *pasync_ctx; 3708 int i, eq_num, ulp_num; 3709 3710 phwi_ctrlr = phba->phwi_ctrlr; 3711 phwi_context = phwi_ctrlr->phwi_ctxt; 3712 3713 be_cmd_iscsi_remove_template_hdr(ctrl); 3714 3715 for (i = 0; i < phba->params.cxns_per_ctrl; i++) { 3716 q = &phwi_context->be_wrbq[i]; 3717 if (q->created) 3718 beiscsi_cmd_q_destroy(ctrl, q, QTYPE_WRBQ); 3719 } 3720 kfree(phwi_context->be_wrbq); 3721 free_wrb_handles(phba); 3722 3723 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) { 3724 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { 3725 3726 q = &phwi_context->be_def_hdrq[ulp_num]; 3727 if (q->created) 3728 beiscsi_cmd_q_destroy(ctrl, q, QTYPE_DPDUQ); 3729 3730 q = &phwi_context->be_def_dataq[ulp_num]; 3731 if (q->created) 3732 beiscsi_cmd_q_destroy(ctrl, q, QTYPE_DPDUQ); 3733 3734 pasync_ctx = phwi_ctrlr->phwi_ctxt->pasync_ctx[ulp_num]; 3735 } 3736 } 3737 3738 beiscsi_cmd_q_destroy(ctrl, NULL, QTYPE_SGL); 3739 3740 for (i = 0; i < (phba->num_cpus); i++) { 3741 q = &phwi_context->be_cq[i]; 3742 if (q->created) 3743 beiscsi_cmd_q_destroy(ctrl, q, QTYPE_CQ); 3744 } 3745 if (phba->msix_enabled) 3746 eq_num = 1; 3747 else 3748 eq_num = 0; 3749 for (i = 0; i < (phba->num_cpus + eq_num); i++) { 3750 q = &phwi_context->be_eq[i].q; 3751 if (q->created) 3752 beiscsi_cmd_q_destroy(ctrl, q, QTYPE_EQ); 3753 } 3754 be_mcc_queues_destroy(phba); 3755 be_cmd_fw_uninit(ctrl); 3756 } 3757 3758 static int be_mcc_queues_create(struct beiscsi_hba *phba, 3759 struct hwi_context_memory *phwi_context) 3760 { 3761 struct be_queue_info *q, *cq; 3762 struct be_ctrl_info *ctrl = &phba->ctrl; 3763 3764 /* Alloc MCC compl queue */ 3765 cq = &phba->ctrl.mcc_obj.cq; 3766 if (be_queue_alloc(phba, cq, MCC_CQ_LEN, 3767 sizeof(struct be_mcc_compl))) 3768 goto err; 3769 /* Ask BE to create MCC compl queue; */ 3770 if (phba->msix_enabled) { 3771 if (beiscsi_cmd_cq_create(ctrl, cq, &phwi_context->be_eq 3772 [phba->num_cpus].q, false, true, 0)) 3773 goto mcc_cq_free; 3774 } else { 3775 if (beiscsi_cmd_cq_create(ctrl, cq, &phwi_context->be_eq[0].q, 3776 false, true, 0)) 3777 goto mcc_cq_free; 3778 } 3779 3780 /* Alloc MCC queue */ 3781 q = &phba->ctrl.mcc_obj.q; 3782 if (be_queue_alloc(phba, q, MCC_Q_LEN, sizeof(struct be_mcc_wrb))) 3783 goto mcc_cq_destroy; 3784 3785 /* Ask BE to create MCC queue */ 3786 if (beiscsi_cmd_mccq_create(phba, q, cq)) 3787 goto mcc_q_free; 3788 3789 return 0; 3790 3791 mcc_q_free: 3792 be_queue_free(phba, q); 3793 mcc_cq_destroy: 3794 beiscsi_cmd_q_destroy(ctrl, cq, QTYPE_CQ); 3795 mcc_cq_free: 3796 be_queue_free(phba, cq); 3797 err: 3798 return -ENOMEM; 3799 } 3800 3801 /** 3802 * find_num_cpus()- Get the CPU online count 3803 * @phba: ptr to priv structure 3804 * 3805 * CPU count is used for creating EQ. 3806 **/ 3807 static void find_num_cpus(struct beiscsi_hba *phba) 3808 { 3809 int num_cpus = 0; 3810 3811 num_cpus = num_online_cpus(); 3812 3813 switch (phba->generation) { 3814 case BE_GEN2: 3815 case BE_GEN3: 3816 phba->num_cpus = (num_cpus > BEISCSI_MAX_NUM_CPUS) ? 3817 BEISCSI_MAX_NUM_CPUS : num_cpus; 3818 break; 3819 case BE_GEN4: 3820 /* 3821 * If eqid_count == 1 fall back to 3822 * INTX mechanism 3823 **/ 3824 if (phba->fw_config.eqid_count == 1) { 3825 enable_msix = 0; 3826 phba->num_cpus = 1; 3827 return; 3828 } 3829 3830 phba->num_cpus = 3831 (num_cpus > (phba->fw_config.eqid_count - 1)) ? 3832 (phba->fw_config.eqid_count - 1) : num_cpus; 3833 break; 3834 default: 3835 phba->num_cpus = 1; 3836 } 3837 } 3838 3839 static int hwi_init_port(struct beiscsi_hba *phba) 3840 { 3841 struct hwi_controller *phwi_ctrlr; 3842 struct hwi_context_memory *phwi_context; 3843 unsigned int def_pdu_ring_sz; 3844 struct be_ctrl_info *ctrl = &phba->ctrl; 3845 int status, ulp_num; 3846 3847 phwi_ctrlr = phba->phwi_ctrlr; 3848 phwi_context = phwi_ctrlr->phwi_ctxt; 3849 phwi_context->max_eqd = 0; 3850 phwi_context->min_eqd = 0; 3851 phwi_context->cur_eqd = 64; 3852 be_cmd_fw_initialize(&phba->ctrl); 3853 3854 status = beiscsi_create_eqs(phba, phwi_context); 3855 if (status != 0) { 3856 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3857 "BM_%d : EQ not created\n"); 3858 goto error; 3859 } 3860 3861 status = be_mcc_queues_create(phba, phwi_context); 3862 if (status != 0) 3863 goto error; 3864 3865 status = mgmt_check_supported_fw(ctrl, phba); 3866 if (status != 0) { 3867 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3868 "BM_%d : Unsupported fw version\n"); 3869 goto error; 3870 } 3871 3872 status = beiscsi_create_cqs(phba, phwi_context); 3873 if (status != 0) { 3874 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3875 "BM_%d : CQ not created\n"); 3876 goto error; 3877 } 3878 3879 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) { 3880 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { 3881 3882 def_pdu_ring_sz = 3883 BEISCSI_GET_CID_COUNT(phba, ulp_num) * 3884 sizeof(struct phys_addr); 3885 3886 status = beiscsi_create_def_hdr(phba, phwi_context, 3887 phwi_ctrlr, 3888 def_pdu_ring_sz, 3889 ulp_num); 3890 if (status != 0) { 3891 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3892 "BM_%d : Default Header not created for ULP : %d\n", 3893 ulp_num); 3894 goto error; 3895 } 3896 3897 status = beiscsi_create_def_data(phba, phwi_context, 3898 phwi_ctrlr, 3899 def_pdu_ring_sz, 3900 ulp_num); 3901 if (status != 0) { 3902 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3903 "BM_%d : Default Data not created for ULP : %d\n", 3904 ulp_num); 3905 goto error; 3906 } 3907 } 3908 } 3909 3910 status = beiscsi_post_pages(phba); 3911 if (status != 0) { 3912 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3913 "BM_%d : Post SGL Pages Failed\n"); 3914 goto error; 3915 } 3916 3917 status = beiscsi_post_template_hdr(phba); 3918 if (status != 0) { 3919 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3920 "BM_%d : Template HDR Posting for CXN Failed\n"); 3921 } 3922 3923 status = beiscsi_create_wrb_rings(phba, phwi_context, phwi_ctrlr); 3924 if (status != 0) { 3925 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3926 "BM_%d : WRB Rings not created\n"); 3927 goto error; 3928 } 3929 3930 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) { 3931 uint16_t async_arr_idx = 0; 3932 3933 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { 3934 uint16_t cri = 0; 3935 struct hwi_async_pdu_context *pasync_ctx; 3936 3937 pasync_ctx = HWI_GET_ASYNC_PDU_CTX( 3938 phwi_ctrlr, ulp_num); 3939 for (cri = 0; cri < 3940 phba->params.cxns_per_ctrl; cri++) { 3941 if (ulp_num == BEISCSI_GET_ULP_FROM_CRI 3942 (phwi_ctrlr, cri)) 3943 pasync_ctx->cid_to_async_cri_map[ 3944 phwi_ctrlr->wrb_context[cri].cid] = 3945 async_arr_idx++; 3946 } 3947 } 3948 } 3949 3950 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 3951 "BM_%d : hwi_init_port success\n"); 3952 return 0; 3953 3954 error: 3955 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3956 "BM_%d : hwi_init_port failed"); 3957 hwi_cleanup(phba); 3958 return status; 3959 } 3960 3961 static int hwi_init_controller(struct beiscsi_hba *phba) 3962 { 3963 struct hwi_controller *phwi_ctrlr; 3964 3965 phwi_ctrlr = phba->phwi_ctrlr; 3966 if (1 == phba->init_mem[HWI_MEM_ADDN_CONTEXT].num_elements) { 3967 phwi_ctrlr->phwi_ctxt = (struct hwi_context_memory *)phba-> 3968 init_mem[HWI_MEM_ADDN_CONTEXT].mem_array[0].virtual_address; 3969 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 3970 "BM_%d : phwi_ctrlr->phwi_ctxt=%p\n", 3971 phwi_ctrlr->phwi_ctxt); 3972 } else { 3973 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3974 "BM_%d : HWI_MEM_ADDN_CONTEXT is more " 3975 "than one element.Failing to load\n"); 3976 return -ENOMEM; 3977 } 3978 3979 iscsi_init_global_templates(phba); 3980 if (beiscsi_init_wrb_handle(phba)) 3981 return -ENOMEM; 3982 3983 if (hwi_init_async_pdu_ctx(phba)) { 3984 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3985 "BM_%d : hwi_init_async_pdu_ctx failed\n"); 3986 return -ENOMEM; 3987 } 3988 3989 if (hwi_init_port(phba) != 0) { 3990 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 3991 "BM_%d : hwi_init_controller failed\n"); 3992 3993 return -ENOMEM; 3994 } 3995 return 0; 3996 } 3997 3998 static void beiscsi_free_mem(struct beiscsi_hba *phba) 3999 { 4000 struct be_mem_descriptor *mem_descr; 4001 int i, j; 4002 4003 mem_descr = phba->init_mem; 4004 i = 0; 4005 j = 0; 4006 for (i = 0; i < SE_MEM_MAX; i++) { 4007 for (j = mem_descr->num_elements; j > 0; j--) { 4008 pci_free_consistent(phba->pcidev, 4009 mem_descr->mem_array[j - 1].size, 4010 mem_descr->mem_array[j - 1].virtual_address, 4011 (unsigned long)mem_descr->mem_array[j - 1]. 4012 bus_address.u.a64.address); 4013 } 4014 4015 kfree(mem_descr->mem_array); 4016 mem_descr++; 4017 } 4018 kfree(phba->init_mem); 4019 kfree(phba->phwi_ctrlr->wrb_context); 4020 kfree(phba->phwi_ctrlr); 4021 } 4022 4023 static int beiscsi_init_controller(struct beiscsi_hba *phba) 4024 { 4025 int ret = -ENOMEM; 4026 4027 ret = beiscsi_get_memory(phba); 4028 if (ret < 0) { 4029 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 4030 "BM_%d : beiscsi_dev_probe -" 4031 "Failed in beiscsi_alloc_memory\n"); 4032 return ret; 4033 } 4034 4035 ret = hwi_init_controller(phba); 4036 if (ret) 4037 goto free_init; 4038 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 4039 "BM_%d : Return success from beiscsi_init_controller"); 4040 4041 return 0; 4042 4043 free_init: 4044 beiscsi_free_mem(phba); 4045 return ret; 4046 } 4047 4048 static int beiscsi_init_sgl_handle(struct beiscsi_hba *phba) 4049 { 4050 struct be_mem_descriptor *mem_descr_sglh, *mem_descr_sg; 4051 struct sgl_handle *psgl_handle; 4052 struct iscsi_sge *pfrag; 4053 unsigned int arr_index, i, idx; 4054 unsigned int ulp_icd_start, ulp_num = 0; 4055 4056 phba->io_sgl_hndl_avbl = 0; 4057 phba->eh_sgl_hndl_avbl = 0; 4058 4059 mem_descr_sglh = phba->init_mem; 4060 mem_descr_sglh += HWI_MEM_SGLH; 4061 if (1 == mem_descr_sglh->num_elements) { 4062 phba->io_sgl_hndl_base = kzalloc(sizeof(struct sgl_handle *) * 4063 phba->params.ios_per_ctrl, 4064 GFP_KERNEL); 4065 if (!phba->io_sgl_hndl_base) { 4066 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 4067 "BM_%d : Mem Alloc Failed. Failing to load\n"); 4068 return -ENOMEM; 4069 } 4070 phba->eh_sgl_hndl_base = kzalloc(sizeof(struct sgl_handle *) * 4071 (phba->params.icds_per_ctrl - 4072 phba->params.ios_per_ctrl), 4073 GFP_KERNEL); 4074 if (!phba->eh_sgl_hndl_base) { 4075 kfree(phba->io_sgl_hndl_base); 4076 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 4077 "BM_%d : Mem Alloc Failed. Failing to load\n"); 4078 return -ENOMEM; 4079 } 4080 } else { 4081 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 4082 "BM_%d : HWI_MEM_SGLH is more than one element." 4083 "Failing to load\n"); 4084 return -ENOMEM; 4085 } 4086 4087 arr_index = 0; 4088 idx = 0; 4089 while (idx < mem_descr_sglh->num_elements) { 4090 psgl_handle = mem_descr_sglh->mem_array[idx].virtual_address; 4091 4092 for (i = 0; i < (mem_descr_sglh->mem_array[idx].size / 4093 sizeof(struct sgl_handle)); i++) { 4094 if (arr_index < phba->params.ios_per_ctrl) { 4095 phba->io_sgl_hndl_base[arr_index] = psgl_handle; 4096 phba->io_sgl_hndl_avbl++; 4097 arr_index++; 4098 } else { 4099 phba->eh_sgl_hndl_base[arr_index - 4100 phba->params.ios_per_ctrl] = 4101 psgl_handle; 4102 arr_index++; 4103 phba->eh_sgl_hndl_avbl++; 4104 } 4105 psgl_handle++; 4106 } 4107 idx++; 4108 } 4109 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 4110 "BM_%d : phba->io_sgl_hndl_avbl=%d" 4111 "phba->eh_sgl_hndl_avbl=%d\n", 4112 phba->io_sgl_hndl_avbl, 4113 phba->eh_sgl_hndl_avbl); 4114 4115 mem_descr_sg = phba->init_mem; 4116 mem_descr_sg += HWI_MEM_SGE; 4117 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 4118 "\n BM_%d : mem_descr_sg->num_elements=%d\n", 4119 mem_descr_sg->num_elements); 4120 4121 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) 4122 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) 4123 break; 4124 4125 ulp_icd_start = phba->fw_config.iscsi_icd_start[ulp_num]; 4126 4127 arr_index = 0; 4128 idx = 0; 4129 while (idx < mem_descr_sg->num_elements) { 4130 pfrag = mem_descr_sg->mem_array[idx].virtual_address; 4131 4132 for (i = 0; 4133 i < (mem_descr_sg->mem_array[idx].size) / 4134 (sizeof(struct iscsi_sge) * phba->params.num_sge_per_io); 4135 i++) { 4136 if (arr_index < phba->params.ios_per_ctrl) 4137 psgl_handle = phba->io_sgl_hndl_base[arr_index]; 4138 else 4139 psgl_handle = phba->eh_sgl_hndl_base[arr_index - 4140 phba->params.ios_per_ctrl]; 4141 psgl_handle->pfrag = pfrag; 4142 AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, pfrag, 0); 4143 AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, pfrag, 0); 4144 pfrag += phba->params.num_sge_per_io; 4145 psgl_handle->sgl_index = ulp_icd_start + arr_index++; 4146 } 4147 idx++; 4148 } 4149 phba->io_sgl_free_index = 0; 4150 phba->io_sgl_alloc_index = 0; 4151 phba->eh_sgl_free_index = 0; 4152 phba->eh_sgl_alloc_index = 0; 4153 return 0; 4154 } 4155 4156 static int hba_setup_cid_tbls(struct beiscsi_hba *phba) 4157 { 4158 int ret; 4159 uint16_t i, ulp_num; 4160 struct ulp_cid_info *ptr_cid_info = NULL; 4161 4162 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) { 4163 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) { 4164 ptr_cid_info = kzalloc(sizeof(struct ulp_cid_info), 4165 GFP_KERNEL); 4166 4167 if (!ptr_cid_info) { 4168 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 4169 "BM_%d : Failed to allocate memory" 4170 "for ULP_CID_INFO for ULP : %d\n", 4171 ulp_num); 4172 ret = -ENOMEM; 4173 goto free_memory; 4174 4175 } 4176 4177 /* Allocate memory for CID array */ 4178 ptr_cid_info->cid_array = kzalloc(sizeof(void *) * 4179 BEISCSI_GET_CID_COUNT(phba, 4180 ulp_num), GFP_KERNEL); 4181 if (!ptr_cid_info->cid_array) { 4182 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 4183 "BM_%d : Failed to allocate memory" 4184 "for CID_ARRAY for ULP : %d\n", 4185 ulp_num); 4186 kfree(ptr_cid_info); 4187 ptr_cid_info = NULL; 4188 ret = -ENOMEM; 4189 4190 goto free_memory; 4191 } 4192 ptr_cid_info->avlbl_cids = BEISCSI_GET_CID_COUNT( 4193 phba, ulp_num); 4194 4195 /* Save the cid_info_array ptr */ 4196 phba->cid_array_info[ulp_num] = ptr_cid_info; 4197 } 4198 } 4199 phba->ep_array = kzalloc(sizeof(struct iscsi_endpoint *) * 4200 phba->params.cxns_per_ctrl, GFP_KERNEL); 4201 if (!phba->ep_array) { 4202 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 4203 "BM_%d : Failed to allocate memory in " 4204 "hba_setup_cid_tbls\n"); 4205 ret = -ENOMEM; 4206 4207 goto free_memory; 4208 } 4209 4210 phba->conn_table = kzalloc(sizeof(struct beiscsi_conn *) * 4211 phba->params.cxns_per_ctrl, GFP_KERNEL); 4212 if (!phba->conn_table) { 4213 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 4214 "BM_%d : Failed to allocate memory in" 4215 "hba_setup_cid_tbls\n"); 4216 4217 kfree(phba->ep_array); 4218 phba->ep_array = NULL; 4219 ret = -ENOMEM; 4220 } 4221 4222 for (i = 0; i < phba->params.cxns_per_ctrl; i++) { 4223 ulp_num = phba->phwi_ctrlr->wrb_context[i].ulp_num; 4224 4225 ptr_cid_info = phba->cid_array_info[ulp_num]; 4226 ptr_cid_info->cid_array[ptr_cid_info->cid_alloc++] = 4227 phba->phwi_ctrlr->wrb_context[i].cid; 4228 4229 } 4230 4231 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) { 4232 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) { 4233 ptr_cid_info = phba->cid_array_info[ulp_num]; 4234 4235 ptr_cid_info->cid_alloc = 0; 4236 ptr_cid_info->cid_free = 0; 4237 } 4238 } 4239 return 0; 4240 4241 free_memory: 4242 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) { 4243 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) { 4244 ptr_cid_info = phba->cid_array_info[ulp_num]; 4245 4246 if (ptr_cid_info) { 4247 kfree(ptr_cid_info->cid_array); 4248 kfree(ptr_cid_info); 4249 phba->cid_array_info[ulp_num] = NULL; 4250 } 4251 } 4252 } 4253 4254 return ret; 4255 } 4256 4257 static void hwi_enable_intr(struct beiscsi_hba *phba) 4258 { 4259 struct be_ctrl_info *ctrl = &phba->ctrl; 4260 struct hwi_controller *phwi_ctrlr; 4261 struct hwi_context_memory *phwi_context; 4262 struct be_queue_info *eq; 4263 u8 __iomem *addr; 4264 u32 reg, i; 4265 u32 enabled; 4266 4267 phwi_ctrlr = phba->phwi_ctrlr; 4268 phwi_context = phwi_ctrlr->phwi_ctxt; 4269 4270 addr = (u8 __iomem *) ((u8 __iomem *) ctrl->pcicfg + 4271 PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET); 4272 reg = ioread32(addr); 4273 4274 enabled = reg & MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK; 4275 if (!enabled) { 4276 reg |= MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK; 4277 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 4278 "BM_%d : reg =x%08x addr=%p\n", reg, addr); 4279 iowrite32(reg, addr); 4280 } 4281 4282 if (!phba->msix_enabled) { 4283 eq = &phwi_context->be_eq[0].q; 4284 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 4285 "BM_%d : eq->id=%d\n", eq->id); 4286 4287 hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1); 4288 } else { 4289 for (i = 0; i <= phba->num_cpus; i++) { 4290 eq = &phwi_context->be_eq[i].q; 4291 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 4292 "BM_%d : eq->id=%d\n", eq->id); 4293 hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1); 4294 } 4295 } 4296 } 4297 4298 static void hwi_disable_intr(struct beiscsi_hba *phba) 4299 { 4300 struct be_ctrl_info *ctrl = &phba->ctrl; 4301 4302 u8 __iomem *addr = ctrl->pcicfg + PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET; 4303 u32 reg = ioread32(addr); 4304 4305 u32 enabled = reg & MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK; 4306 if (enabled) { 4307 reg &= ~MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK; 4308 iowrite32(reg, addr); 4309 } else 4310 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, 4311 "BM_%d : In hwi_disable_intr, Already Disabled\n"); 4312 } 4313 4314 /** 4315 * beiscsi_get_boot_info()- Get the boot session info 4316 * @phba: The device priv structure instance 4317 * 4318 * Get the boot target info and store in driver priv structure 4319 * 4320 * return values 4321 * Success: 0 4322 * Failure: Non-Zero Value 4323 **/ 4324 static int beiscsi_get_boot_info(struct beiscsi_hba *phba) 4325 { 4326 struct be_cmd_get_session_resp *session_resp; 4327 struct be_dma_mem nonemb_cmd; 4328 unsigned int tag; 4329 unsigned int s_handle; 4330 int ret = -ENOMEM; 4331 4332 /* Get the session handle of the boot target */ 4333 ret = be_mgmt_get_boot_shandle(phba, &s_handle); 4334 if (ret) { 4335 beiscsi_log(phba, KERN_ERR, 4336 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, 4337 "BM_%d : No boot session\n"); 4338 return ret; 4339 } 4340 nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev, 4341 sizeof(*session_resp), 4342 &nonemb_cmd.dma); 4343 if (nonemb_cmd.va == NULL) { 4344 beiscsi_log(phba, KERN_ERR, 4345 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, 4346 "BM_%d : Failed to allocate memory for" 4347 "beiscsi_get_session_info\n"); 4348 4349 return -ENOMEM; 4350 } 4351 4352 memset(nonemb_cmd.va, 0, sizeof(*session_resp)); 4353 tag = mgmt_get_session_info(phba, s_handle, 4354 &nonemb_cmd); 4355 if (!tag) { 4356 beiscsi_log(phba, KERN_ERR, 4357 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, 4358 "BM_%d : beiscsi_get_session_info" 4359 " Failed\n"); 4360 4361 goto boot_freemem; 4362 } 4363 4364 ret = beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd.va); 4365 if (ret) { 4366 beiscsi_log(phba, KERN_ERR, 4367 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, 4368 "BM_%d : beiscsi_get_session_info Failed"); 4369 goto boot_freemem; 4370 } 4371 4372 session_resp = nonemb_cmd.va ; 4373 4374 memcpy(&phba->boot_sess, &session_resp->session_info, 4375 sizeof(struct mgmt_session_info)); 4376 ret = 0; 4377 4378 boot_freemem: 4379 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, 4380 nonemb_cmd.va, nonemb_cmd.dma); 4381 return ret; 4382 } 4383 4384 static void beiscsi_boot_release(void *data) 4385 { 4386 struct beiscsi_hba *phba = data; 4387 4388 scsi_host_put(phba->shost); 4389 } 4390 4391 static int beiscsi_setup_boot_info(struct beiscsi_hba *phba) 4392 { 4393 struct iscsi_boot_kobj *boot_kobj; 4394 4395 /* get boot info using mgmt cmd */ 4396 if (beiscsi_get_boot_info(phba)) 4397 /* Try to see if we can carry on without this */ 4398 return 0; 4399 4400 phba->boot_kset = iscsi_boot_create_host_kset(phba->shost->host_no); 4401 if (!phba->boot_kset) 4402 return -ENOMEM; 4403 4404 /* get a ref because the show function will ref the phba */ 4405 if (!scsi_host_get(phba->shost)) 4406 goto free_kset; 4407 boot_kobj = iscsi_boot_create_target(phba->boot_kset, 0, phba, 4408 beiscsi_show_boot_tgt_info, 4409 beiscsi_tgt_get_attr_visibility, 4410 beiscsi_boot_release); 4411 if (!boot_kobj) 4412 goto put_shost; 4413 4414 if (!scsi_host_get(phba->shost)) 4415 goto free_kset; 4416 boot_kobj = iscsi_boot_create_initiator(phba->boot_kset, 0, phba, 4417 beiscsi_show_boot_ini_info, 4418 beiscsi_ini_get_attr_visibility, 4419 beiscsi_boot_release); 4420 if (!boot_kobj) 4421 goto put_shost; 4422 4423 if (!scsi_host_get(phba->shost)) 4424 goto free_kset; 4425 boot_kobj = iscsi_boot_create_ethernet(phba->boot_kset, 0, phba, 4426 beiscsi_show_boot_eth_info, 4427 beiscsi_eth_get_attr_visibility, 4428 beiscsi_boot_release); 4429 if (!boot_kobj) 4430 goto put_shost; 4431 return 0; 4432 4433 put_shost: 4434 scsi_host_put(phba->shost); 4435 free_kset: 4436 iscsi_boot_destroy_kset(phba->boot_kset); 4437 return -ENOMEM; 4438 } 4439 4440 static int beiscsi_init_port(struct beiscsi_hba *phba) 4441 { 4442 int ret; 4443 4444 ret = beiscsi_init_controller(phba); 4445 if (ret < 0) { 4446 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 4447 "BM_%d : beiscsi_dev_probe - Failed in" 4448 "beiscsi_init_controller\n"); 4449 return ret; 4450 } 4451 ret = beiscsi_init_sgl_handle(phba); 4452 if (ret < 0) { 4453 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 4454 "BM_%d : beiscsi_dev_probe - Failed in" 4455 "beiscsi_init_sgl_handle\n"); 4456 goto do_cleanup_ctrlr; 4457 } 4458 4459 if (hba_setup_cid_tbls(phba)) { 4460 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 4461 "BM_%d : Failed in hba_setup_cid_tbls\n"); 4462 kfree(phba->io_sgl_hndl_base); 4463 kfree(phba->eh_sgl_hndl_base); 4464 goto do_cleanup_ctrlr; 4465 } 4466 4467 return ret; 4468 4469 do_cleanup_ctrlr: 4470 hwi_cleanup(phba); 4471 return ret; 4472 } 4473 4474 static void hwi_purge_eq(struct beiscsi_hba *phba) 4475 { 4476 struct hwi_controller *phwi_ctrlr; 4477 struct hwi_context_memory *phwi_context; 4478 struct be_queue_info *eq; 4479 struct be_eq_entry *eqe = NULL; 4480 int i, eq_msix; 4481 unsigned int num_processed; 4482 4483 phwi_ctrlr = phba->phwi_ctrlr; 4484 phwi_context = phwi_ctrlr->phwi_ctxt; 4485 if (phba->msix_enabled) 4486 eq_msix = 1; 4487 else 4488 eq_msix = 0; 4489 4490 for (i = 0; i < (phba->num_cpus + eq_msix); i++) { 4491 eq = &phwi_context->be_eq[i].q; 4492 eqe = queue_tail_node(eq); 4493 num_processed = 0; 4494 while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32] 4495 & EQE_VALID_MASK) { 4496 AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0); 4497 queue_tail_inc(eq); 4498 eqe = queue_tail_node(eq); 4499 num_processed++; 4500 } 4501 4502 if (num_processed) 4503 hwi_ring_eq_db(phba, eq->id, 1, num_processed, 1, 1); 4504 } 4505 } 4506 4507 static void beiscsi_clean_port(struct beiscsi_hba *phba) 4508 { 4509 int mgmt_status, ulp_num; 4510 struct ulp_cid_info *ptr_cid_info = NULL; 4511 4512 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) { 4513 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) { 4514 mgmt_status = mgmt_epfw_cleanup(phba, ulp_num); 4515 if (mgmt_status) 4516 beiscsi_log(phba, KERN_WARNING, 4517 BEISCSI_LOG_INIT, 4518 "BM_%d : mgmt_epfw_cleanup FAILED" 4519 " for ULP_%d\n", ulp_num); 4520 } 4521 } 4522 4523 hwi_purge_eq(phba); 4524 hwi_cleanup(phba); 4525 kfree(phba->io_sgl_hndl_base); 4526 kfree(phba->eh_sgl_hndl_base); 4527 kfree(phba->ep_array); 4528 kfree(phba->conn_table); 4529 4530 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) { 4531 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) { 4532 ptr_cid_info = phba->cid_array_info[ulp_num]; 4533 4534 if (ptr_cid_info) { 4535 kfree(ptr_cid_info->cid_array); 4536 kfree(ptr_cid_info); 4537 phba->cid_array_info[ulp_num] = NULL; 4538 } 4539 } 4540 } 4541 4542 } 4543 4544 /** 4545 * beiscsi_free_mgmt_task_handles()- Free driver CXN resources 4546 * @beiscsi_conn: ptr to the conn to be cleaned up 4547 * @task: ptr to iscsi_task resource to be freed. 4548 * 4549 * Free driver mgmt resources binded to CXN. 4550 **/ 4551 void 4552 beiscsi_free_mgmt_task_handles(struct beiscsi_conn *beiscsi_conn, 4553 struct iscsi_task *task) 4554 { 4555 struct beiscsi_io_task *io_task; 4556 struct beiscsi_hba *phba = beiscsi_conn->phba; 4557 struct hwi_wrb_context *pwrb_context; 4558 struct hwi_controller *phwi_ctrlr; 4559 uint16_t cri_index = BE_GET_CRI_FROM_CID( 4560 beiscsi_conn->beiscsi_conn_cid); 4561 4562 phwi_ctrlr = phba->phwi_ctrlr; 4563 pwrb_context = &phwi_ctrlr->wrb_context[cri_index]; 4564 4565 io_task = task->dd_data; 4566 4567 if (io_task->pwrb_handle) { 4568 memset(io_task->pwrb_handle->pwrb, 0, 4569 sizeof(struct iscsi_wrb)); 4570 free_wrb_handle(phba, pwrb_context, 4571 io_task->pwrb_handle); 4572 io_task->pwrb_handle = NULL; 4573 } 4574 4575 if (io_task->psgl_handle) { 4576 spin_lock_bh(&phba->mgmt_sgl_lock); 4577 free_mgmt_sgl_handle(phba, 4578 io_task->psgl_handle); 4579 io_task->psgl_handle = NULL; 4580 spin_unlock_bh(&phba->mgmt_sgl_lock); 4581 } 4582 4583 if (io_task->mtask_addr) 4584 pci_unmap_single(phba->pcidev, 4585 io_task->mtask_addr, 4586 io_task->mtask_data_count, 4587 PCI_DMA_TODEVICE); 4588 } 4589 4590 /** 4591 * beiscsi_cleanup_task()- Free driver resources of the task 4592 * @task: ptr to the iscsi task 4593 * 4594 **/ 4595 static void beiscsi_cleanup_task(struct iscsi_task *task) 4596 { 4597 struct beiscsi_io_task *io_task = task->dd_data; 4598 struct iscsi_conn *conn = task->conn; 4599 struct beiscsi_conn *beiscsi_conn = conn->dd_data; 4600 struct beiscsi_hba *phba = beiscsi_conn->phba; 4601 struct beiscsi_session *beiscsi_sess = beiscsi_conn->beiscsi_sess; 4602 struct hwi_wrb_context *pwrb_context; 4603 struct hwi_controller *phwi_ctrlr; 4604 uint16_t cri_index = BE_GET_CRI_FROM_CID( 4605 beiscsi_conn->beiscsi_conn_cid); 4606 4607 phwi_ctrlr = phba->phwi_ctrlr; 4608 pwrb_context = &phwi_ctrlr->wrb_context[cri_index]; 4609 4610 if (io_task->cmd_bhs) { 4611 pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs, 4612 io_task->bhs_pa.u.a64.address); 4613 io_task->cmd_bhs = NULL; 4614 } 4615 4616 if (task->sc) { 4617 if (io_task->pwrb_handle) { 4618 free_wrb_handle(phba, pwrb_context, 4619 io_task->pwrb_handle); 4620 io_task->pwrb_handle = NULL; 4621 } 4622 4623 if (io_task->psgl_handle) { 4624 spin_lock(&phba->io_sgl_lock); 4625 free_io_sgl_handle(phba, io_task->psgl_handle); 4626 spin_unlock(&phba->io_sgl_lock); 4627 io_task->psgl_handle = NULL; 4628 } 4629 } else { 4630 if (!beiscsi_conn->login_in_progress) 4631 beiscsi_free_mgmt_task_handles(beiscsi_conn, task); 4632 } 4633 } 4634 4635 void 4636 beiscsi_offload_connection(struct beiscsi_conn *beiscsi_conn, 4637 struct beiscsi_offload_params *params) 4638 { 4639 struct wrb_handle *pwrb_handle; 4640 struct beiscsi_hba *phba = beiscsi_conn->phba; 4641 struct iscsi_task *task = beiscsi_conn->task; 4642 struct iscsi_session *session = task->conn->session; 4643 u32 doorbell = 0; 4644 4645 /* 4646 * We can always use 0 here because it is reserved by libiscsi for 4647 * login/startup related tasks. 4648 */ 4649 beiscsi_conn->login_in_progress = 0; 4650 spin_lock_bh(&session->lock); 4651 beiscsi_cleanup_task(task); 4652 spin_unlock_bh(&session->lock); 4653 4654 pwrb_handle = alloc_wrb_handle(phba, beiscsi_conn->beiscsi_conn_cid); 4655 4656 /* Check for the adapter family */ 4657 if (is_chip_be2_be3r(phba)) 4658 beiscsi_offload_cxn_v0(params, pwrb_handle, 4659 phba->init_mem); 4660 else 4661 beiscsi_offload_cxn_v2(params, pwrb_handle); 4662 4663 be_dws_le_to_cpu(pwrb_handle->pwrb, 4664 sizeof(struct iscsi_target_context_update_wrb)); 4665 4666 doorbell |= beiscsi_conn->beiscsi_conn_cid & DB_WRB_POST_CID_MASK; 4667 doorbell |= (pwrb_handle->wrb_index & DB_DEF_PDU_WRB_INDEX_MASK) 4668 << DB_DEF_PDU_WRB_INDEX_SHIFT; 4669 doorbell |= 1 << DB_DEF_PDU_NUM_POSTED_SHIFT; 4670 iowrite32(doorbell, phba->db_va + 4671 beiscsi_conn->doorbell_offset); 4672 } 4673 4674 static void beiscsi_parse_pdu(struct iscsi_conn *conn, itt_t itt, 4675 int *index, int *age) 4676 { 4677 *index = (int)itt; 4678 if (age) 4679 *age = conn->session->age; 4680 } 4681 4682 /** 4683 * beiscsi_alloc_pdu - allocates pdu and related resources 4684 * @task: libiscsi task 4685 * @opcode: opcode of pdu for task 4686 * 4687 * This is called with the session lock held. It will allocate 4688 * the wrb and sgl if needed for the command. And it will prep 4689 * the pdu's itt. beiscsi_parse_pdu will later translate 4690 * the pdu itt to the libiscsi task itt. 4691 */ 4692 static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode) 4693 { 4694 struct beiscsi_io_task *io_task = task->dd_data; 4695 struct iscsi_conn *conn = task->conn; 4696 struct beiscsi_conn *beiscsi_conn = conn->dd_data; 4697 struct beiscsi_hba *phba = beiscsi_conn->phba; 4698 struct hwi_wrb_context *pwrb_context; 4699 struct hwi_controller *phwi_ctrlr; 4700 itt_t itt; 4701 uint16_t cri_index = 0; 4702 struct beiscsi_session *beiscsi_sess = beiscsi_conn->beiscsi_sess; 4703 dma_addr_t paddr; 4704 4705 io_task->cmd_bhs = pci_pool_alloc(beiscsi_sess->bhs_pool, 4706 GFP_ATOMIC, &paddr); 4707 if (!io_task->cmd_bhs) 4708 return -ENOMEM; 4709 io_task->bhs_pa.u.a64.address = paddr; 4710 io_task->libiscsi_itt = (itt_t)task->itt; 4711 io_task->conn = beiscsi_conn; 4712 4713 task->hdr = (struct iscsi_hdr *)&io_task->cmd_bhs->iscsi_hdr; 4714 task->hdr_max = sizeof(struct be_cmd_bhs); 4715 io_task->psgl_handle = NULL; 4716 io_task->pwrb_handle = NULL; 4717 4718 if (task->sc) { 4719 spin_lock(&phba->io_sgl_lock); 4720 io_task->psgl_handle = alloc_io_sgl_handle(phba); 4721 spin_unlock(&phba->io_sgl_lock); 4722 if (!io_task->psgl_handle) { 4723 beiscsi_log(phba, KERN_ERR, 4724 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, 4725 "BM_%d : Alloc of IO_SGL_ICD Failed" 4726 "for the CID : %d\n", 4727 beiscsi_conn->beiscsi_conn_cid); 4728 goto free_hndls; 4729 } 4730 io_task->pwrb_handle = alloc_wrb_handle(phba, 4731 beiscsi_conn->beiscsi_conn_cid); 4732 if (!io_task->pwrb_handle) { 4733 beiscsi_log(phba, KERN_ERR, 4734 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, 4735 "BM_%d : Alloc of WRB_HANDLE Failed" 4736 "for the CID : %d\n", 4737 beiscsi_conn->beiscsi_conn_cid); 4738 goto free_io_hndls; 4739 } 4740 } else { 4741 io_task->scsi_cmnd = NULL; 4742 if ((opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGIN) { 4743 beiscsi_conn->task = task; 4744 if (!beiscsi_conn->login_in_progress) { 4745 spin_lock(&phba->mgmt_sgl_lock); 4746 io_task->psgl_handle = (struct sgl_handle *) 4747 alloc_mgmt_sgl_handle(phba); 4748 spin_unlock(&phba->mgmt_sgl_lock); 4749 if (!io_task->psgl_handle) { 4750 beiscsi_log(phba, KERN_ERR, 4751 BEISCSI_LOG_IO | 4752 BEISCSI_LOG_CONFIG, 4753 "BM_%d : Alloc of MGMT_SGL_ICD Failed" 4754 "for the CID : %d\n", 4755 beiscsi_conn-> 4756 beiscsi_conn_cid); 4757 goto free_hndls; 4758 } 4759 4760 beiscsi_conn->login_in_progress = 1; 4761 beiscsi_conn->plogin_sgl_handle = 4762 io_task->psgl_handle; 4763 io_task->pwrb_handle = 4764 alloc_wrb_handle(phba, 4765 beiscsi_conn->beiscsi_conn_cid); 4766 if (!io_task->pwrb_handle) { 4767 beiscsi_log(phba, KERN_ERR, 4768 BEISCSI_LOG_IO | 4769 BEISCSI_LOG_CONFIG, 4770 "BM_%d : Alloc of WRB_HANDLE Failed" 4771 "for the CID : %d\n", 4772 beiscsi_conn-> 4773 beiscsi_conn_cid); 4774 goto free_mgmt_hndls; 4775 } 4776 beiscsi_conn->plogin_wrb_handle = 4777 io_task->pwrb_handle; 4778 4779 } else { 4780 io_task->psgl_handle = 4781 beiscsi_conn->plogin_sgl_handle; 4782 io_task->pwrb_handle = 4783 beiscsi_conn->plogin_wrb_handle; 4784 } 4785 } else { 4786 spin_lock(&phba->mgmt_sgl_lock); 4787 io_task->psgl_handle = alloc_mgmt_sgl_handle(phba); 4788 spin_unlock(&phba->mgmt_sgl_lock); 4789 if (!io_task->psgl_handle) { 4790 beiscsi_log(phba, KERN_ERR, 4791 BEISCSI_LOG_IO | 4792 BEISCSI_LOG_CONFIG, 4793 "BM_%d : Alloc of MGMT_SGL_ICD Failed" 4794 "for the CID : %d\n", 4795 beiscsi_conn-> 4796 beiscsi_conn_cid); 4797 goto free_hndls; 4798 } 4799 io_task->pwrb_handle = 4800 alloc_wrb_handle(phba, 4801 beiscsi_conn->beiscsi_conn_cid); 4802 if (!io_task->pwrb_handle) { 4803 beiscsi_log(phba, KERN_ERR, 4804 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG, 4805 "BM_%d : Alloc of WRB_HANDLE Failed" 4806 "for the CID : %d\n", 4807 beiscsi_conn->beiscsi_conn_cid); 4808 goto free_mgmt_hndls; 4809 } 4810 4811 } 4812 } 4813 itt = (itt_t) cpu_to_be32(((unsigned int)io_task->pwrb_handle-> 4814 wrb_index << 16) | (unsigned int) 4815 (io_task->psgl_handle->sgl_index)); 4816 io_task->pwrb_handle->pio_handle = task; 4817 4818 io_task->cmd_bhs->iscsi_hdr.itt = itt; 4819 return 0; 4820 4821 free_io_hndls: 4822 spin_lock(&phba->io_sgl_lock); 4823 free_io_sgl_handle(phba, io_task->psgl_handle); 4824 spin_unlock(&phba->io_sgl_lock); 4825 goto free_hndls; 4826 free_mgmt_hndls: 4827 spin_lock(&phba->mgmt_sgl_lock); 4828 free_mgmt_sgl_handle(phba, io_task->psgl_handle); 4829 io_task->psgl_handle = NULL; 4830 spin_unlock(&phba->mgmt_sgl_lock); 4831 free_hndls: 4832 phwi_ctrlr = phba->phwi_ctrlr; 4833 cri_index = BE_GET_CRI_FROM_CID( 4834 beiscsi_conn->beiscsi_conn_cid); 4835 pwrb_context = &phwi_ctrlr->wrb_context[cri_index]; 4836 if (io_task->pwrb_handle) 4837 free_wrb_handle(phba, pwrb_context, io_task->pwrb_handle); 4838 io_task->pwrb_handle = NULL; 4839 pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs, 4840 io_task->bhs_pa.u.a64.address); 4841 io_task->cmd_bhs = NULL; 4842 return -ENOMEM; 4843 } 4844 int beiscsi_iotask_v2(struct iscsi_task *task, struct scatterlist *sg, 4845 unsigned int num_sg, unsigned int xferlen, 4846 unsigned int writedir) 4847 { 4848 4849 struct beiscsi_io_task *io_task = task->dd_data; 4850 struct iscsi_conn *conn = task->conn; 4851 struct beiscsi_conn *beiscsi_conn = conn->dd_data; 4852 struct beiscsi_hba *phba = beiscsi_conn->phba; 4853 struct iscsi_wrb *pwrb = NULL; 4854 unsigned int doorbell = 0; 4855 4856 pwrb = io_task->pwrb_handle->pwrb; 4857 4858 io_task->cmd_bhs->iscsi_hdr.exp_statsn = 0; 4859 io_task->bhs_len = sizeof(struct be_cmd_bhs); 4860 4861 if (writedir) { 4862 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, type, pwrb, 4863 INI_WR_CMD); 4864 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, dsp, pwrb, 1); 4865 } else { 4866 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, type, pwrb, 4867 INI_RD_CMD); 4868 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, dsp, pwrb, 0); 4869 } 4870 4871 io_task->wrb_type = AMAP_GET_BITS(struct amap_iscsi_wrb_v2, 4872 type, pwrb); 4873 4874 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, lun, pwrb, 4875 cpu_to_be16(*(unsigned short *) 4876 &io_task->cmd_bhs->iscsi_hdr.lun)); 4877 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, r2t_exp_dtl, pwrb, xferlen); 4878 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, wrb_idx, pwrb, 4879 io_task->pwrb_handle->wrb_index); 4880 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, cmdsn_itt, pwrb, 4881 be32_to_cpu(task->cmdsn)); 4882 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sgl_idx, pwrb, 4883 io_task->psgl_handle->sgl_index); 4884 4885 hwi_write_sgl_v2(pwrb, sg, num_sg, io_task); 4886 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, ptr2nextwrb, pwrb, 4887 io_task->pwrb_handle->nxt_wrb_index); 4888 4889 be_dws_le_to_cpu(pwrb, sizeof(struct iscsi_wrb)); 4890 4891 doorbell |= beiscsi_conn->beiscsi_conn_cid & DB_WRB_POST_CID_MASK; 4892 doorbell |= (io_task->pwrb_handle->wrb_index & 4893 DB_DEF_PDU_WRB_INDEX_MASK) << 4894 DB_DEF_PDU_WRB_INDEX_SHIFT; 4895 doorbell |= 1 << DB_DEF_PDU_NUM_POSTED_SHIFT; 4896 iowrite32(doorbell, phba->db_va + 4897 beiscsi_conn->doorbell_offset); 4898 return 0; 4899 } 4900 4901 static int beiscsi_iotask(struct iscsi_task *task, struct scatterlist *sg, 4902 unsigned int num_sg, unsigned int xferlen, 4903 unsigned int writedir) 4904 { 4905 4906 struct beiscsi_io_task *io_task = task->dd_data; 4907 struct iscsi_conn *conn = task->conn; 4908 struct beiscsi_conn *beiscsi_conn = conn->dd_data; 4909 struct beiscsi_hba *phba = beiscsi_conn->phba; 4910 struct iscsi_wrb *pwrb = NULL; 4911 unsigned int doorbell = 0; 4912 4913 pwrb = io_task->pwrb_handle->pwrb; 4914 io_task->cmd_bhs->iscsi_hdr.exp_statsn = 0; 4915 io_task->bhs_len = sizeof(struct be_cmd_bhs); 4916 4917 if (writedir) { 4918 AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb, 4919 INI_WR_CMD); 4920 AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 1); 4921 } else { 4922 AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb, 4923 INI_RD_CMD); 4924 AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 0); 4925 } 4926 4927 io_task->wrb_type = AMAP_GET_BITS(struct amap_iscsi_wrb, 4928 type, pwrb); 4929 4930 AMAP_SET_BITS(struct amap_iscsi_wrb, lun, pwrb, 4931 cpu_to_be16(*(unsigned short *) 4932 &io_task->cmd_bhs->iscsi_hdr.lun)); 4933 AMAP_SET_BITS(struct amap_iscsi_wrb, r2t_exp_dtl, pwrb, xferlen); 4934 AMAP_SET_BITS(struct amap_iscsi_wrb, wrb_idx, pwrb, 4935 io_task->pwrb_handle->wrb_index); 4936 AMAP_SET_BITS(struct amap_iscsi_wrb, cmdsn_itt, pwrb, 4937 be32_to_cpu(task->cmdsn)); 4938 AMAP_SET_BITS(struct amap_iscsi_wrb, sgl_icd_idx, pwrb, 4939 io_task->psgl_handle->sgl_index); 4940 4941 hwi_write_sgl(pwrb, sg, num_sg, io_task); 4942 4943 AMAP_SET_BITS(struct amap_iscsi_wrb, ptr2nextwrb, pwrb, 4944 io_task->pwrb_handle->nxt_wrb_index); 4945 be_dws_le_to_cpu(pwrb, sizeof(struct iscsi_wrb)); 4946 4947 doorbell |= beiscsi_conn->beiscsi_conn_cid & DB_WRB_POST_CID_MASK; 4948 doorbell |= (io_task->pwrb_handle->wrb_index & 4949 DB_DEF_PDU_WRB_INDEX_MASK) << DB_DEF_PDU_WRB_INDEX_SHIFT; 4950 doorbell |= 1 << DB_DEF_PDU_NUM_POSTED_SHIFT; 4951 4952 iowrite32(doorbell, phba->db_va + 4953 beiscsi_conn->doorbell_offset); 4954 return 0; 4955 } 4956 4957 static int beiscsi_mtask(struct iscsi_task *task) 4958 { 4959 struct beiscsi_io_task *io_task = task->dd_data; 4960 struct iscsi_conn *conn = task->conn; 4961 struct beiscsi_conn *beiscsi_conn = conn->dd_data; 4962 struct beiscsi_hba *phba = beiscsi_conn->phba; 4963 struct iscsi_wrb *pwrb = NULL; 4964 unsigned int doorbell = 0; 4965 unsigned int cid; 4966 unsigned int pwrb_typeoffset = 0; 4967 4968 cid = beiscsi_conn->beiscsi_conn_cid; 4969 pwrb = io_task->pwrb_handle->pwrb; 4970 memset(pwrb, 0, sizeof(*pwrb)); 4971 4972 if (is_chip_be2_be3r(phba)) { 4973 AMAP_SET_BITS(struct amap_iscsi_wrb, cmdsn_itt, pwrb, 4974 be32_to_cpu(task->cmdsn)); 4975 AMAP_SET_BITS(struct amap_iscsi_wrb, wrb_idx, pwrb, 4976 io_task->pwrb_handle->wrb_index); 4977 AMAP_SET_BITS(struct amap_iscsi_wrb, sgl_icd_idx, pwrb, 4978 io_task->psgl_handle->sgl_index); 4979 AMAP_SET_BITS(struct amap_iscsi_wrb, r2t_exp_dtl, pwrb, 4980 task->data_count); 4981 AMAP_SET_BITS(struct amap_iscsi_wrb, ptr2nextwrb, pwrb, 4982 io_task->pwrb_handle->nxt_wrb_index); 4983 pwrb_typeoffset = BE_WRB_TYPE_OFFSET; 4984 } else { 4985 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, cmdsn_itt, pwrb, 4986 be32_to_cpu(task->cmdsn)); 4987 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, wrb_idx, pwrb, 4988 io_task->pwrb_handle->wrb_index); 4989 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sgl_idx, pwrb, 4990 io_task->psgl_handle->sgl_index); 4991 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, r2t_exp_dtl, pwrb, 4992 task->data_count); 4993 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, ptr2nextwrb, pwrb, 4994 io_task->pwrb_handle->nxt_wrb_index); 4995 pwrb_typeoffset = SKH_WRB_TYPE_OFFSET; 4996 } 4997 4998 4999 switch (task->hdr->opcode & ISCSI_OPCODE_MASK) { 5000 case ISCSI_OP_LOGIN: 5001 AMAP_SET_BITS(struct amap_iscsi_wrb, cmdsn_itt, pwrb, 1); 5002 ADAPTER_SET_WRB_TYPE(pwrb, TGT_DM_CMD, pwrb_typeoffset); 5003 hwi_write_buffer(pwrb, task); 5004 break; 5005 case ISCSI_OP_NOOP_OUT: 5006 if (task->hdr->ttt != ISCSI_RESERVED_TAG) { 5007 ADAPTER_SET_WRB_TYPE(pwrb, TGT_DM_CMD, pwrb_typeoffset); 5008 if (is_chip_be2_be3r(phba)) 5009 AMAP_SET_BITS(struct amap_iscsi_wrb, 5010 dmsg, pwrb, 1); 5011 else 5012 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, 5013 dmsg, pwrb, 1); 5014 } else { 5015 ADAPTER_SET_WRB_TYPE(pwrb, INI_RD_CMD, pwrb_typeoffset); 5016 if (is_chip_be2_be3r(phba)) 5017 AMAP_SET_BITS(struct amap_iscsi_wrb, 5018 dmsg, pwrb, 0); 5019 else 5020 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, 5021 dmsg, pwrb, 0); 5022 } 5023 hwi_write_buffer(pwrb, task); 5024 break; 5025 case ISCSI_OP_TEXT: 5026 ADAPTER_SET_WRB_TYPE(pwrb, TGT_DM_CMD, pwrb_typeoffset); 5027 hwi_write_buffer(pwrb, task); 5028 break; 5029 case ISCSI_OP_SCSI_TMFUNC: 5030 ADAPTER_SET_WRB_TYPE(pwrb, INI_TMF_CMD, pwrb_typeoffset); 5031 hwi_write_buffer(pwrb, task); 5032 break; 5033 case ISCSI_OP_LOGOUT: 5034 ADAPTER_SET_WRB_TYPE(pwrb, HWH_TYPE_LOGOUT, pwrb_typeoffset); 5035 hwi_write_buffer(pwrb, task); 5036 break; 5037 5038 default: 5039 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 5040 "BM_%d : opcode =%d Not supported\n", 5041 task->hdr->opcode & ISCSI_OPCODE_MASK); 5042 5043 return -EINVAL; 5044 } 5045 5046 /* Set the task type */ 5047 io_task->wrb_type = (is_chip_be2_be3r(phba)) ? 5048 AMAP_GET_BITS(struct amap_iscsi_wrb, type, pwrb) : 5049 AMAP_GET_BITS(struct amap_iscsi_wrb_v2, type, pwrb); 5050 5051 doorbell |= cid & DB_WRB_POST_CID_MASK; 5052 doorbell |= (io_task->pwrb_handle->wrb_index & 5053 DB_DEF_PDU_WRB_INDEX_MASK) << DB_DEF_PDU_WRB_INDEX_SHIFT; 5054 doorbell |= 1 << DB_DEF_PDU_NUM_POSTED_SHIFT; 5055 iowrite32(doorbell, phba->db_va + 5056 beiscsi_conn->doorbell_offset); 5057 return 0; 5058 } 5059 5060 static int beiscsi_task_xmit(struct iscsi_task *task) 5061 { 5062 struct beiscsi_io_task *io_task = task->dd_data; 5063 struct scsi_cmnd *sc = task->sc; 5064 struct beiscsi_hba *phba = NULL; 5065 struct scatterlist *sg; 5066 int num_sg; 5067 unsigned int writedir = 0, xferlen = 0; 5068 5069 phba = ((struct beiscsi_conn *)task->conn->dd_data)->phba; 5070 5071 if (!sc) 5072 return beiscsi_mtask(task); 5073 5074 io_task->scsi_cmnd = sc; 5075 num_sg = scsi_dma_map(sc); 5076 if (num_sg < 0) { 5077 struct iscsi_conn *conn = task->conn; 5078 struct beiscsi_hba *phba = NULL; 5079 5080 phba = ((struct beiscsi_conn *)conn->dd_data)->phba; 5081 beiscsi_log(phba, KERN_ERR, 5082 BEISCSI_LOG_IO | BEISCSI_LOG_ISCSI, 5083 "BM_%d : scsi_dma_map Failed " 5084 "Driver_ITT : 0x%x ITT : 0x%x Xferlen : 0x%x\n", 5085 be32_to_cpu(io_task->cmd_bhs->iscsi_hdr.itt), 5086 io_task->libiscsi_itt, scsi_bufflen(sc)); 5087 5088 return num_sg; 5089 } 5090 xferlen = scsi_bufflen(sc); 5091 sg = scsi_sglist(sc); 5092 if (sc->sc_data_direction == DMA_TO_DEVICE) 5093 writedir = 1; 5094 else 5095 writedir = 0; 5096 5097 return phba->iotask_fn(task, sg, num_sg, xferlen, writedir); 5098 } 5099 5100 /** 5101 * beiscsi_bsg_request - handle bsg request from ISCSI transport 5102 * @job: job to handle 5103 */ 5104 static int beiscsi_bsg_request(struct bsg_job *job) 5105 { 5106 struct Scsi_Host *shost; 5107 struct beiscsi_hba *phba; 5108 struct iscsi_bsg_request *bsg_req = job->request; 5109 int rc = -EINVAL; 5110 unsigned int tag; 5111 struct be_dma_mem nonemb_cmd; 5112 struct be_cmd_resp_hdr *resp; 5113 struct iscsi_bsg_reply *bsg_reply = job->reply; 5114 unsigned short status, extd_status; 5115 5116 shost = iscsi_job_to_shost(job); 5117 phba = iscsi_host_priv(shost); 5118 5119 switch (bsg_req->msgcode) { 5120 case ISCSI_BSG_HST_VENDOR: 5121 nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev, 5122 job->request_payload.payload_len, 5123 &nonemb_cmd.dma); 5124 if (nonemb_cmd.va == NULL) { 5125 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 5126 "BM_%d : Failed to allocate memory for " 5127 "beiscsi_bsg_request\n"); 5128 return -ENOMEM; 5129 } 5130 tag = mgmt_vendor_specific_fw_cmd(&phba->ctrl, phba, job, 5131 &nonemb_cmd); 5132 if (!tag) { 5133 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 5134 "BM_%d : MBX Tag Allocation Failed\n"); 5135 5136 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, 5137 nonemb_cmd.va, nonemb_cmd.dma); 5138 return -EAGAIN; 5139 } 5140 5141 rc = wait_event_interruptible_timeout( 5142 phba->ctrl.mcc_wait[tag], 5143 phba->ctrl.mcc_numtag[tag], 5144 msecs_to_jiffies( 5145 BEISCSI_HOST_MBX_TIMEOUT)); 5146 extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8; 5147 status = phba->ctrl.mcc_numtag[tag] & 0x000000FF; 5148 free_mcc_tag(&phba->ctrl, tag); 5149 resp = (struct be_cmd_resp_hdr *)nonemb_cmd.va; 5150 sg_copy_from_buffer(job->reply_payload.sg_list, 5151 job->reply_payload.sg_cnt, 5152 nonemb_cmd.va, (resp->response_length 5153 + sizeof(*resp))); 5154 bsg_reply->reply_payload_rcv_len = resp->response_length; 5155 bsg_reply->result = status; 5156 bsg_job_done(job, bsg_reply->result, 5157 bsg_reply->reply_payload_rcv_len); 5158 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, 5159 nonemb_cmd.va, nonemb_cmd.dma); 5160 if (status || extd_status) { 5161 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 5162 "BM_%d : MBX Cmd Failed" 5163 " status = %d extd_status = %d\n", 5164 status, extd_status); 5165 5166 return -EIO; 5167 } else { 5168 rc = 0; 5169 } 5170 break; 5171 5172 default: 5173 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 5174 "BM_%d : Unsupported bsg command: 0x%x\n", 5175 bsg_req->msgcode); 5176 break; 5177 } 5178 5179 return rc; 5180 } 5181 5182 void beiscsi_hba_attrs_init(struct beiscsi_hba *phba) 5183 { 5184 /* Set the logging parameter */ 5185 beiscsi_log_enable_init(phba, beiscsi_log_enable); 5186 } 5187 5188 /* 5189 * beiscsi_quiesce()- Cleanup Driver resources 5190 * @phba: Instance Priv structure 5191 * @unload_state:i Clean or EEH unload state 5192 * 5193 * Free the OS and HW resources held by the driver 5194 **/ 5195 static void beiscsi_quiesce(struct beiscsi_hba *phba, 5196 uint32_t unload_state) 5197 { 5198 struct hwi_controller *phwi_ctrlr; 5199 struct hwi_context_memory *phwi_context; 5200 struct be_eq_obj *pbe_eq; 5201 unsigned int i, msix_vec; 5202 5203 phwi_ctrlr = phba->phwi_ctrlr; 5204 phwi_context = phwi_ctrlr->phwi_ctxt; 5205 hwi_disable_intr(phba); 5206 if (phba->msix_enabled) { 5207 for (i = 0; i <= phba->num_cpus; i++) { 5208 msix_vec = phba->msix_entries[i].vector; 5209 synchronize_irq(msix_vec); 5210 free_irq(msix_vec, &phwi_context->be_eq[i]); 5211 kfree(phba->msi_name[i]); 5212 } 5213 } else 5214 if (phba->pcidev->irq) { 5215 synchronize_irq(phba->pcidev->irq); 5216 free_irq(phba->pcidev->irq, phba); 5217 } 5218 pci_disable_msix(phba->pcidev); 5219 5220 if (blk_iopoll_enabled) 5221 for (i = 0; i < phba->num_cpus; i++) { 5222 pbe_eq = &phwi_context->be_eq[i]; 5223 blk_iopoll_disable(&pbe_eq->iopoll); 5224 } 5225 5226 if (unload_state == BEISCSI_CLEAN_UNLOAD) { 5227 destroy_workqueue(phba->wq); 5228 beiscsi_clean_port(phba); 5229 beiscsi_free_mem(phba); 5230 5231 beiscsi_unmap_pci_function(phba); 5232 pci_free_consistent(phba->pcidev, 5233 phba->ctrl.mbox_mem_alloced.size, 5234 phba->ctrl.mbox_mem_alloced.va, 5235 phba->ctrl.mbox_mem_alloced.dma); 5236 } else { 5237 hwi_purge_eq(phba); 5238 hwi_cleanup(phba); 5239 } 5240 5241 cancel_delayed_work_sync(&phba->beiscsi_hw_check_task); 5242 } 5243 5244 static void beiscsi_remove(struct pci_dev *pcidev) 5245 { 5246 5247 struct beiscsi_hba *phba = NULL; 5248 5249 phba = pci_get_drvdata(pcidev); 5250 if (!phba) { 5251 dev_err(&pcidev->dev, "beiscsi_remove called with no phba\n"); 5252 return; 5253 } 5254 5255 beiscsi_destroy_def_ifaces(phba); 5256 beiscsi_quiesce(phba, BEISCSI_CLEAN_UNLOAD); 5257 iscsi_boot_destroy_kset(phba->boot_kset); 5258 iscsi_host_remove(phba->shost); 5259 pci_dev_put(phba->pcidev); 5260 iscsi_host_free(phba->shost); 5261 pci_disable_pcie_error_reporting(pcidev); 5262 pci_set_drvdata(pcidev, NULL); 5263 pci_disable_device(pcidev); 5264 } 5265 5266 static void beiscsi_shutdown(struct pci_dev *pcidev) 5267 { 5268 5269 struct beiscsi_hba *phba = NULL; 5270 5271 phba = (struct beiscsi_hba *)pci_get_drvdata(pcidev); 5272 if (!phba) { 5273 dev_err(&pcidev->dev, "beiscsi_shutdown called with no phba\n"); 5274 return; 5275 } 5276 5277 beiscsi_quiesce(phba, BEISCSI_CLEAN_UNLOAD); 5278 pci_disable_device(pcidev); 5279 } 5280 5281 static void beiscsi_msix_enable(struct beiscsi_hba *phba) 5282 { 5283 int i, status; 5284 5285 for (i = 0; i <= phba->num_cpus; i++) 5286 phba->msix_entries[i].entry = i; 5287 5288 status = pci_enable_msix(phba->pcidev, phba->msix_entries, 5289 (phba->num_cpus + 1)); 5290 if (!status) 5291 phba->msix_enabled = true; 5292 5293 return; 5294 } 5295 5296 /* 5297 * beiscsi_hw_health_check()- Check adapter health 5298 * @work: work item to check HW health 5299 * 5300 * Check if adapter in an unrecoverable state or not. 5301 **/ 5302 static void 5303 beiscsi_hw_health_check(struct work_struct *work) 5304 { 5305 struct beiscsi_hba *phba = 5306 container_of(work, struct beiscsi_hba, 5307 beiscsi_hw_check_task.work); 5308 5309 beiscsi_ue_detect(phba); 5310 5311 schedule_delayed_work(&phba->beiscsi_hw_check_task, 5312 msecs_to_jiffies(1000)); 5313 } 5314 5315 5316 static pci_ers_result_t beiscsi_eeh_err_detected(struct pci_dev *pdev, 5317 pci_channel_state_t state) 5318 { 5319 struct beiscsi_hba *phba = NULL; 5320 5321 phba = (struct beiscsi_hba *)pci_get_drvdata(pdev); 5322 phba->state |= BE_ADAPTER_PCI_ERR; 5323 5324 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 5325 "BM_%d : EEH error detected\n"); 5326 5327 beiscsi_quiesce(phba, BEISCSI_EEH_UNLOAD); 5328 5329 if (state == pci_channel_io_perm_failure) { 5330 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 5331 "BM_%d : EEH : State PERM Failure"); 5332 return PCI_ERS_RESULT_DISCONNECT; 5333 } 5334 5335 pci_disable_device(pdev); 5336 5337 /* The error could cause the FW to trigger a flash debug dump. 5338 * Resetting the card while flash dump is in progress 5339 * can cause it not to recover; wait for it to finish. 5340 * Wait only for first function as it is needed only once per 5341 * adapter. 5342 **/ 5343 if (pdev->devfn == 0) 5344 ssleep(30); 5345 5346 return PCI_ERS_RESULT_NEED_RESET; 5347 } 5348 5349 static pci_ers_result_t beiscsi_eeh_reset(struct pci_dev *pdev) 5350 { 5351 struct beiscsi_hba *phba = NULL; 5352 int status = 0; 5353 5354 phba = (struct beiscsi_hba *)pci_get_drvdata(pdev); 5355 5356 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 5357 "BM_%d : EEH Reset\n"); 5358 5359 status = pci_enable_device(pdev); 5360 if (status) 5361 return PCI_ERS_RESULT_DISCONNECT; 5362 5363 pci_set_master(pdev); 5364 pci_set_power_state(pdev, PCI_D0); 5365 pci_restore_state(pdev); 5366 5367 /* Wait for the CHIP Reset to complete */ 5368 status = be_chk_reset_complete(phba); 5369 if (!status) { 5370 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, 5371 "BM_%d : EEH Reset Completed\n"); 5372 } else { 5373 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, 5374 "BM_%d : EEH Reset Completion Failure\n"); 5375 return PCI_ERS_RESULT_DISCONNECT; 5376 } 5377 5378 pci_cleanup_aer_uncorrect_error_status(pdev); 5379 return PCI_ERS_RESULT_RECOVERED; 5380 } 5381 5382 static void beiscsi_eeh_resume(struct pci_dev *pdev) 5383 { 5384 int ret = 0, i; 5385 struct be_eq_obj *pbe_eq; 5386 struct beiscsi_hba *phba = NULL; 5387 struct hwi_controller *phwi_ctrlr; 5388 struct hwi_context_memory *phwi_context; 5389 5390 phba = (struct beiscsi_hba *)pci_get_drvdata(pdev); 5391 pci_save_state(pdev); 5392 5393 if (enable_msix) 5394 find_num_cpus(phba); 5395 else 5396 phba->num_cpus = 1; 5397 5398 if (enable_msix) { 5399 beiscsi_msix_enable(phba); 5400 if (!phba->msix_enabled) 5401 phba->num_cpus = 1; 5402 } 5403 5404 ret = beiscsi_cmd_reset_function(phba); 5405 if (ret) { 5406 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 5407 "BM_%d : Reset Failed\n"); 5408 goto ret_err; 5409 } 5410 5411 ret = be_chk_reset_complete(phba); 5412 if (ret) { 5413 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 5414 "BM_%d : Failed to get out of reset.\n"); 5415 goto ret_err; 5416 } 5417 5418 beiscsi_get_params(phba); 5419 phba->shost->max_id = phba->params.cxns_per_ctrl; 5420 phba->shost->can_queue = phba->params.ios_per_ctrl; 5421 ret = hwi_init_controller(phba); 5422 5423 for (i = 0; i < MAX_MCC_CMD; i++) { 5424 init_waitqueue_head(&phba->ctrl.mcc_wait[i + 1]); 5425 phba->ctrl.mcc_tag[i] = i + 1; 5426 phba->ctrl.mcc_numtag[i + 1] = 0; 5427 phba->ctrl.mcc_tag_available++; 5428 } 5429 5430 phwi_ctrlr = phba->phwi_ctrlr; 5431 phwi_context = phwi_ctrlr->phwi_ctxt; 5432 5433 if (blk_iopoll_enabled) { 5434 for (i = 0; i < phba->num_cpus; i++) { 5435 pbe_eq = &phwi_context->be_eq[i]; 5436 blk_iopoll_init(&pbe_eq->iopoll, be_iopoll_budget, 5437 be_iopoll); 5438 blk_iopoll_enable(&pbe_eq->iopoll); 5439 } 5440 5441 i = (phba->msix_enabled) ? i : 0; 5442 /* Work item for MCC handling */ 5443 pbe_eq = &phwi_context->be_eq[i]; 5444 INIT_WORK(&pbe_eq->work_cqs, beiscsi_process_all_cqs); 5445 } else { 5446 if (phba->msix_enabled) { 5447 for (i = 0; i <= phba->num_cpus; i++) { 5448 pbe_eq = &phwi_context->be_eq[i]; 5449 INIT_WORK(&pbe_eq->work_cqs, 5450 beiscsi_process_all_cqs); 5451 } 5452 } else { 5453 pbe_eq = &phwi_context->be_eq[0]; 5454 INIT_WORK(&pbe_eq->work_cqs, 5455 beiscsi_process_all_cqs); 5456 } 5457 } 5458 5459 ret = beiscsi_init_irqs(phba); 5460 if (ret < 0) { 5461 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 5462 "BM_%d : beiscsi_eeh_resume - " 5463 "Failed to beiscsi_init_irqs\n"); 5464 goto ret_err; 5465 } 5466 5467 hwi_enable_intr(phba); 5468 phba->state &= ~BE_ADAPTER_PCI_ERR; 5469 5470 return; 5471 ret_err: 5472 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 5473 "BM_%d : AER EEH Resume Failed\n"); 5474 } 5475 5476 static int beiscsi_dev_probe(struct pci_dev *pcidev, 5477 const struct pci_device_id *id) 5478 { 5479 struct beiscsi_hba *phba = NULL; 5480 struct hwi_controller *phwi_ctrlr; 5481 struct hwi_context_memory *phwi_context; 5482 struct be_eq_obj *pbe_eq; 5483 int ret = 0, i; 5484 5485 ret = beiscsi_enable_pci(pcidev); 5486 if (ret < 0) { 5487 dev_err(&pcidev->dev, 5488 "beiscsi_dev_probe - Failed to enable pci device\n"); 5489 return ret; 5490 } 5491 5492 phba = beiscsi_hba_alloc(pcidev); 5493 if (!phba) { 5494 dev_err(&pcidev->dev, 5495 "beiscsi_dev_probe - Failed in beiscsi_hba_alloc\n"); 5496 goto disable_pci; 5497 } 5498 5499 /* Enable EEH reporting */ 5500 ret = pci_enable_pcie_error_reporting(pcidev); 5501 if (ret) 5502 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, 5503 "BM_%d : PCIe Error Reporting " 5504 "Enabling Failed\n"); 5505 5506 pci_save_state(pcidev); 5507 5508 /* Initialize Driver configuration Paramters */ 5509 beiscsi_hba_attrs_init(phba); 5510 5511 phba->fw_timeout = false; 5512 phba->mac_addr_set = false; 5513 5514 5515 switch (pcidev->device) { 5516 case BE_DEVICE_ID1: 5517 case OC_DEVICE_ID1: 5518 case OC_DEVICE_ID2: 5519 phba->generation = BE_GEN2; 5520 phba->iotask_fn = beiscsi_iotask; 5521 break; 5522 case BE_DEVICE_ID2: 5523 case OC_DEVICE_ID3: 5524 phba->generation = BE_GEN3; 5525 phba->iotask_fn = beiscsi_iotask; 5526 break; 5527 case OC_SKH_ID1: 5528 phba->generation = BE_GEN4; 5529 phba->iotask_fn = beiscsi_iotask_v2; 5530 break; 5531 default: 5532 phba->generation = 0; 5533 } 5534 5535 ret = be_ctrl_init(phba, pcidev); 5536 if (ret) { 5537 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 5538 "BM_%d : beiscsi_dev_probe-" 5539 "Failed in be_ctrl_init\n"); 5540 goto hba_free; 5541 } 5542 5543 ret = beiscsi_cmd_reset_function(phba); 5544 if (ret) { 5545 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 5546 "BM_%d : Reset Failed\n"); 5547 goto hba_free; 5548 } 5549 ret = be_chk_reset_complete(phba); 5550 if (ret) { 5551 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 5552 "BM_%d : Failed to get out of reset.\n"); 5553 goto hba_free; 5554 } 5555 5556 spin_lock_init(&phba->io_sgl_lock); 5557 spin_lock_init(&phba->mgmt_sgl_lock); 5558 spin_lock_init(&phba->isr_lock); 5559 spin_lock_init(&phba->async_pdu_lock); 5560 ret = mgmt_get_fw_config(&phba->ctrl, phba); 5561 if (ret != 0) { 5562 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 5563 "BM_%d : Error getting fw config\n"); 5564 goto free_port; 5565 } 5566 5567 if (enable_msix) 5568 find_num_cpus(phba); 5569 else 5570 phba->num_cpus = 1; 5571 5572 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 5573 "BM_%d : num_cpus = %d\n", 5574 phba->num_cpus); 5575 5576 if (enable_msix) { 5577 beiscsi_msix_enable(phba); 5578 if (!phba->msix_enabled) 5579 phba->num_cpus = 1; 5580 } 5581 5582 phba->shost->max_id = phba->params.cxns_per_ctrl; 5583 beiscsi_get_params(phba); 5584 phba->shost->can_queue = phba->params.ios_per_ctrl; 5585 ret = beiscsi_init_port(phba); 5586 if (ret < 0) { 5587 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 5588 "BM_%d : beiscsi_dev_probe-" 5589 "Failed in beiscsi_init_port\n"); 5590 goto free_port; 5591 } 5592 5593 for (i = 0; i < MAX_MCC_CMD; i++) { 5594 init_waitqueue_head(&phba->ctrl.mcc_wait[i + 1]); 5595 phba->ctrl.mcc_tag[i] = i + 1; 5596 phba->ctrl.mcc_numtag[i + 1] = 0; 5597 phba->ctrl.mcc_tag_available++; 5598 } 5599 5600 phba->ctrl.mcc_alloc_index = phba->ctrl.mcc_free_index = 0; 5601 5602 snprintf(phba->wq_name, sizeof(phba->wq_name), "beiscsi_%02x_wq", 5603 phba->shost->host_no); 5604 phba->wq = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, phba->wq_name); 5605 if (!phba->wq) { 5606 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 5607 "BM_%d : beiscsi_dev_probe-" 5608 "Failed to allocate work queue\n"); 5609 goto free_twq; 5610 } 5611 5612 INIT_DELAYED_WORK(&phba->beiscsi_hw_check_task, 5613 beiscsi_hw_health_check); 5614 5615 phwi_ctrlr = phba->phwi_ctrlr; 5616 phwi_context = phwi_ctrlr->phwi_ctxt; 5617 5618 if (blk_iopoll_enabled) { 5619 for (i = 0; i < phba->num_cpus; i++) { 5620 pbe_eq = &phwi_context->be_eq[i]; 5621 blk_iopoll_init(&pbe_eq->iopoll, be_iopoll_budget, 5622 be_iopoll); 5623 blk_iopoll_enable(&pbe_eq->iopoll); 5624 } 5625 5626 i = (phba->msix_enabled) ? i : 0; 5627 /* Work item for MCC handling */ 5628 pbe_eq = &phwi_context->be_eq[i]; 5629 INIT_WORK(&pbe_eq->work_cqs, beiscsi_process_all_cqs); 5630 } else { 5631 if (phba->msix_enabled) { 5632 for (i = 0; i <= phba->num_cpus; i++) { 5633 pbe_eq = &phwi_context->be_eq[i]; 5634 INIT_WORK(&pbe_eq->work_cqs, 5635 beiscsi_process_all_cqs); 5636 } 5637 } else { 5638 pbe_eq = &phwi_context->be_eq[0]; 5639 INIT_WORK(&pbe_eq->work_cqs, 5640 beiscsi_process_all_cqs); 5641 } 5642 } 5643 5644 ret = beiscsi_init_irqs(phba); 5645 if (ret < 0) { 5646 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 5647 "BM_%d : beiscsi_dev_probe-" 5648 "Failed to beiscsi_init_irqs\n"); 5649 goto free_blkenbld; 5650 } 5651 hwi_enable_intr(phba); 5652 5653 if (beiscsi_setup_boot_info(phba)) 5654 /* 5655 * log error but continue, because we may not be using 5656 * iscsi boot. 5657 */ 5658 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, 5659 "BM_%d : Could not set up " 5660 "iSCSI boot info.\n"); 5661 5662 beiscsi_create_def_ifaces(phba); 5663 schedule_delayed_work(&phba->beiscsi_hw_check_task, 5664 msecs_to_jiffies(1000)); 5665 5666 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, 5667 "\n\n\n BM_%d : SUCCESS - DRIVER LOADED\n\n\n"); 5668 return 0; 5669 5670 free_blkenbld: 5671 destroy_workqueue(phba->wq); 5672 if (blk_iopoll_enabled) 5673 for (i = 0; i < phba->num_cpus; i++) { 5674 pbe_eq = &phwi_context->be_eq[i]; 5675 blk_iopoll_disable(&pbe_eq->iopoll); 5676 } 5677 free_twq: 5678 beiscsi_clean_port(phba); 5679 beiscsi_free_mem(phba); 5680 free_port: 5681 pci_free_consistent(phba->pcidev, 5682 phba->ctrl.mbox_mem_alloced.size, 5683 phba->ctrl.mbox_mem_alloced.va, 5684 phba->ctrl.mbox_mem_alloced.dma); 5685 beiscsi_unmap_pci_function(phba); 5686 hba_free: 5687 if (phba->msix_enabled) 5688 pci_disable_msix(phba->pcidev); 5689 iscsi_host_remove(phba->shost); 5690 pci_dev_put(phba->pcidev); 5691 iscsi_host_free(phba->shost); 5692 disable_pci: 5693 pci_disable_device(pcidev); 5694 return ret; 5695 } 5696 5697 static struct pci_error_handlers beiscsi_eeh_handlers = { 5698 .error_detected = beiscsi_eeh_err_detected, 5699 .slot_reset = beiscsi_eeh_reset, 5700 .resume = beiscsi_eeh_resume, 5701 }; 5702 5703 struct iscsi_transport beiscsi_iscsi_transport = { 5704 .owner = THIS_MODULE, 5705 .name = DRV_NAME, 5706 .caps = CAP_RECOVERY_L0 | CAP_HDRDGST | CAP_TEXT_NEGO | 5707 CAP_MULTI_R2T | CAP_DATADGST | CAP_DATA_PATH_OFFLOAD, 5708 .create_session = beiscsi_session_create, 5709 .destroy_session = beiscsi_session_destroy, 5710 .create_conn = beiscsi_conn_create, 5711 .bind_conn = beiscsi_conn_bind, 5712 .destroy_conn = iscsi_conn_teardown, 5713 .attr_is_visible = be2iscsi_attr_is_visible, 5714 .set_iface_param = be2iscsi_iface_set_param, 5715 .get_iface_param = be2iscsi_iface_get_param, 5716 .set_param = beiscsi_set_param, 5717 .get_conn_param = iscsi_conn_get_param, 5718 .get_session_param = iscsi_session_get_param, 5719 .get_host_param = beiscsi_get_host_param, 5720 .start_conn = beiscsi_conn_start, 5721 .stop_conn = iscsi_conn_stop, 5722 .send_pdu = iscsi_conn_send_pdu, 5723 .xmit_task = beiscsi_task_xmit, 5724 .cleanup_task = beiscsi_cleanup_task, 5725 .alloc_pdu = beiscsi_alloc_pdu, 5726 .parse_pdu_itt = beiscsi_parse_pdu, 5727 .get_stats = beiscsi_conn_get_stats, 5728 .get_ep_param = beiscsi_ep_get_param, 5729 .ep_connect = beiscsi_ep_connect, 5730 .ep_poll = beiscsi_ep_poll, 5731 .ep_disconnect = beiscsi_ep_disconnect, 5732 .session_recovery_timedout = iscsi_session_recovery_timedout, 5733 .bsg_request = beiscsi_bsg_request, 5734 }; 5735 5736 static struct pci_driver beiscsi_pci_driver = { 5737 .name = DRV_NAME, 5738 .probe = beiscsi_dev_probe, 5739 .remove = beiscsi_remove, 5740 .shutdown = beiscsi_shutdown, 5741 .id_table = beiscsi_pci_id_table, 5742 .err_handler = &beiscsi_eeh_handlers 5743 }; 5744 5745 5746 static int __init beiscsi_module_init(void) 5747 { 5748 int ret; 5749 5750 beiscsi_scsi_transport = 5751 iscsi_register_transport(&beiscsi_iscsi_transport); 5752 if (!beiscsi_scsi_transport) { 5753 printk(KERN_ERR 5754 "beiscsi_module_init - Unable to register beiscsi transport.\n"); 5755 return -ENOMEM; 5756 } 5757 printk(KERN_INFO "In beiscsi_module_init, tt=%p\n", 5758 &beiscsi_iscsi_transport); 5759 5760 ret = pci_register_driver(&beiscsi_pci_driver); 5761 if (ret) { 5762 printk(KERN_ERR 5763 "beiscsi_module_init - Unable to register beiscsi pci driver.\n"); 5764 goto unregister_iscsi_transport; 5765 } 5766 return 0; 5767 5768 unregister_iscsi_transport: 5769 iscsi_unregister_transport(&beiscsi_iscsi_transport); 5770 return ret; 5771 } 5772 5773 static void __exit beiscsi_module_exit(void) 5774 { 5775 pci_unregister_driver(&beiscsi_pci_driver); 5776 iscsi_unregister_transport(&beiscsi_iscsi_transport); 5777 } 5778 5779 module_init(beiscsi_module_init); 5780 module_exit(beiscsi_module_exit); 5781 5782 5783 5784 5785 5786 /* LDV_COMMENT_BEGIN_MAIN */ 5787 #ifdef LDV_MAIN1_sequence_infinite_withcheck_stateful 5788 5789 /*###########################################################################*/ 5790 5791 /*############## Driver Environment Generator 0.2 output ####################*/ 5792 5793 /*###########################################################################*/ 5794 5795 5796 5797 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test if all kernel resources are correctly released by driver before driver will be unloaded. */ 5798 void ldv_check_final_state(void); 5799 5800 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result. */ 5801 void ldv_check_return_value(int res); 5802 5803 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result of probe() function. */ 5804 void ldv_check_return_value_probe(int res); 5805 5806 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Initializes the model. */ 5807 void ldv_initialize(void); 5808 5809 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Reinitializes the model between distinct model function calls. */ 5810 void ldv_handler_precall(void); 5811 5812 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Returns arbitrary interger value. */ 5813 int nondet_int(void); 5814 5815 /* LDV_COMMENT_VAR_DECLARE_LDV Special variable for LDV verifier. */ 5816 int LDV_IN_INTERRUPT; 5817 5818 /* LDV_COMMENT_FUNCTION_MAIN Main function for LDV verifier. */ 5819 void ldv_main1_sequence_infinite_withcheck_stateful(void) { 5820 5821 5822 5823 /* LDV_COMMENT_BEGIN_VARIABLE_DECLARATION_PART */ 5824 /*============================= VARIABLE DECLARATION PART =============================*/ 5825 /** STRUCT: struct type: scsi_host_template, struct name: beiscsi_sht **/ 5826 /* content: static int beiscsi_slave_configure(struct scsi_device *sdev)*/ 5827 /* LDV_COMMENT_BEGIN_PREP */ 5828 #define beiscsi_disp_param(_name)\ 5829 ssize_t \ 5830 beiscsi_##_name##_disp(struct device *dev,\ 5831 struct device_attribute *attrib, char *buf) \ 5832 { \ 5833 struct Scsi_Host *shost = class_to_shost(dev);\ 5834 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 5835 uint32_t param_val = 0; \ 5836 param_val = phba->attr_##_name;\ 5837 return snprintf(buf, PAGE_SIZE, "%d\n",\ 5838 phba->attr_##_name);\ 5839 } 5840 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 5841 int \ 5842 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 5843 {\ 5844 if (val >= _minval && val <= _maxval) {\ 5845 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 5846 "BA_%d : beiscsi_"#_name" updated "\ 5847 "from 0x%x ==> 0x%x\n",\ 5848 phba->attr_##_name, val); \ 5849 phba->attr_##_name = val;\ 5850 return 0;\ 5851 } \ 5852 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 5853 "BA_%d beiscsi_"#_name" attribute "\ 5854 "cannot be updated to 0x%x, "\ 5855 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 5856 return -EINVAL;\ 5857 } 5858 #define beiscsi_store_param(_name) \ 5859 ssize_t \ 5860 beiscsi_##_name##_store(struct device *dev,\ 5861 struct device_attribute *attr, const char *buf,\ 5862 size_t count) \ 5863 { \ 5864 struct Scsi_Host *shost = class_to_shost(dev);\ 5865 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 5866 uint32_t param_val = 0;\ 5867 if (!isdigit(buf[0]))\ 5868 return -EINVAL;\ 5869 if (sscanf(buf, "%i", &param_val) != 1)\ 5870 return -EINVAL;\ 5871 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 5872 return strlen(buf);\ 5873 else \ 5874 return -EINVAL;\ 5875 } 5876 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 5877 int \ 5878 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 5879 { \ 5880 if (val >= _minval && val <= _maxval) {\ 5881 phba->attr_##_name = val;\ 5882 return 0;\ 5883 } \ 5884 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 5885 "BA_%d beiscsi_"#_name" attribute " \ 5886 "cannot be updated to 0x%x, "\ 5887 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 5888 phba->attr_##_name = _defval;\ 5889 return -EINVAL;\ 5890 } 5891 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 5892 static uint beiscsi_##_name = _defval;\ 5893 module_param(beiscsi_##_name, uint, S_IRUGO);\ 5894 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 5895 beiscsi_disp_param(_name)\ 5896 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 5897 beiscsi_store_param(_name)\ 5898 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 5899 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 5900 beiscsi_##_name##_disp, beiscsi_##_name##_store) 5901 /* LDV_COMMENT_END_PREP */ 5902 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_slave_configure" */ 5903 struct scsi_device * var_group1; 5904 /* content: static int beiscsi_eh_abort(struct scsi_cmnd *sc)*/ 5905 /* LDV_COMMENT_BEGIN_PREP */ 5906 #define beiscsi_disp_param(_name)\ 5907 ssize_t \ 5908 beiscsi_##_name##_disp(struct device *dev,\ 5909 struct device_attribute *attrib, char *buf) \ 5910 { \ 5911 struct Scsi_Host *shost = class_to_shost(dev);\ 5912 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 5913 uint32_t param_val = 0; \ 5914 param_val = phba->attr_##_name;\ 5915 return snprintf(buf, PAGE_SIZE, "%d\n",\ 5916 phba->attr_##_name);\ 5917 } 5918 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 5919 int \ 5920 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 5921 {\ 5922 if (val >= _minval && val <= _maxval) {\ 5923 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 5924 "BA_%d : beiscsi_"#_name" updated "\ 5925 "from 0x%x ==> 0x%x\n",\ 5926 phba->attr_##_name, val); \ 5927 phba->attr_##_name = val;\ 5928 return 0;\ 5929 } \ 5930 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 5931 "BA_%d beiscsi_"#_name" attribute "\ 5932 "cannot be updated to 0x%x, "\ 5933 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 5934 return -EINVAL;\ 5935 } 5936 #define beiscsi_store_param(_name) \ 5937 ssize_t \ 5938 beiscsi_##_name##_store(struct device *dev,\ 5939 struct device_attribute *attr, const char *buf,\ 5940 size_t count) \ 5941 { \ 5942 struct Scsi_Host *shost = class_to_shost(dev);\ 5943 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 5944 uint32_t param_val = 0;\ 5945 if (!isdigit(buf[0]))\ 5946 return -EINVAL;\ 5947 if (sscanf(buf, "%i", &param_val) != 1)\ 5948 return -EINVAL;\ 5949 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 5950 return strlen(buf);\ 5951 else \ 5952 return -EINVAL;\ 5953 } 5954 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 5955 int \ 5956 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 5957 { \ 5958 if (val >= _minval && val <= _maxval) {\ 5959 phba->attr_##_name = val;\ 5960 return 0;\ 5961 } \ 5962 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 5963 "BA_%d beiscsi_"#_name" attribute " \ 5964 "cannot be updated to 0x%x, "\ 5965 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 5966 phba->attr_##_name = _defval;\ 5967 return -EINVAL;\ 5968 } 5969 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 5970 static uint beiscsi_##_name = _defval;\ 5971 module_param(beiscsi_##_name, uint, S_IRUGO);\ 5972 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 5973 beiscsi_disp_param(_name)\ 5974 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 5975 beiscsi_store_param(_name)\ 5976 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 5977 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 5978 beiscsi_##_name##_disp, beiscsi_##_name##_store) 5979 /* LDV_COMMENT_END_PREP */ 5980 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_eh_abort" */ 5981 struct scsi_cmnd * var_group2; 5982 /* content: static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)*/ 5983 /* LDV_COMMENT_BEGIN_PREP */ 5984 #define beiscsi_disp_param(_name)\ 5985 ssize_t \ 5986 beiscsi_##_name##_disp(struct device *dev,\ 5987 struct device_attribute *attrib, char *buf) \ 5988 { \ 5989 struct Scsi_Host *shost = class_to_shost(dev);\ 5990 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 5991 uint32_t param_val = 0; \ 5992 param_val = phba->attr_##_name;\ 5993 return snprintf(buf, PAGE_SIZE, "%d\n",\ 5994 phba->attr_##_name);\ 5995 } 5996 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 5997 int \ 5998 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 5999 {\ 6000 if (val >= _minval && val <= _maxval) {\ 6001 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6002 "BA_%d : beiscsi_"#_name" updated "\ 6003 "from 0x%x ==> 0x%x\n",\ 6004 phba->attr_##_name, val); \ 6005 phba->attr_##_name = val;\ 6006 return 0;\ 6007 } \ 6008 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 6009 "BA_%d beiscsi_"#_name" attribute "\ 6010 "cannot be updated to 0x%x, "\ 6011 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6012 return -EINVAL;\ 6013 } 6014 #define beiscsi_store_param(_name) \ 6015 ssize_t \ 6016 beiscsi_##_name##_store(struct device *dev,\ 6017 struct device_attribute *attr, const char *buf,\ 6018 size_t count) \ 6019 { \ 6020 struct Scsi_Host *shost = class_to_shost(dev);\ 6021 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 6022 uint32_t param_val = 0;\ 6023 if (!isdigit(buf[0]))\ 6024 return -EINVAL;\ 6025 if (sscanf(buf, "%i", &param_val) != 1)\ 6026 return -EINVAL;\ 6027 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 6028 return strlen(buf);\ 6029 else \ 6030 return -EINVAL;\ 6031 } 6032 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 6033 int \ 6034 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 6035 { \ 6036 if (val >= _minval && val <= _maxval) {\ 6037 phba->attr_##_name = val;\ 6038 return 0;\ 6039 } \ 6040 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6041 "BA_%d beiscsi_"#_name" attribute " \ 6042 "cannot be updated to 0x%x, "\ 6043 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6044 phba->attr_##_name = _defval;\ 6045 return -EINVAL;\ 6046 } 6047 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 6048 static uint beiscsi_##_name = _defval;\ 6049 module_param(beiscsi_##_name, uint, S_IRUGO);\ 6050 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 6051 beiscsi_disp_param(_name)\ 6052 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 6053 beiscsi_store_param(_name)\ 6054 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 6055 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 6056 beiscsi_##_name##_disp, beiscsi_##_name##_store) 6057 /* LDV_COMMENT_END_PREP */ 6058 6059 /** STRUCT: struct type: pci_error_handlers, struct name: beiscsi_eeh_handlers **/ 6060 /* content: static pci_ers_result_t beiscsi_eeh_err_detected(struct pci_dev *pdev, pci_channel_state_t state)*/ 6061 /* LDV_COMMENT_BEGIN_PREP */ 6062 #define beiscsi_disp_param(_name)\ 6063 ssize_t \ 6064 beiscsi_##_name##_disp(struct device *dev,\ 6065 struct device_attribute *attrib, char *buf) \ 6066 { \ 6067 struct Scsi_Host *shost = class_to_shost(dev);\ 6068 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 6069 uint32_t param_val = 0; \ 6070 param_val = phba->attr_##_name;\ 6071 return snprintf(buf, PAGE_SIZE, "%d\n",\ 6072 phba->attr_##_name);\ 6073 } 6074 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 6075 int \ 6076 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 6077 {\ 6078 if (val >= _minval && val <= _maxval) {\ 6079 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6080 "BA_%d : beiscsi_"#_name" updated "\ 6081 "from 0x%x ==> 0x%x\n",\ 6082 phba->attr_##_name, val); \ 6083 phba->attr_##_name = val;\ 6084 return 0;\ 6085 } \ 6086 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 6087 "BA_%d beiscsi_"#_name" attribute "\ 6088 "cannot be updated to 0x%x, "\ 6089 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6090 return -EINVAL;\ 6091 } 6092 #define beiscsi_store_param(_name) \ 6093 ssize_t \ 6094 beiscsi_##_name##_store(struct device *dev,\ 6095 struct device_attribute *attr, const char *buf,\ 6096 size_t count) \ 6097 { \ 6098 struct Scsi_Host *shost = class_to_shost(dev);\ 6099 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 6100 uint32_t param_val = 0;\ 6101 if (!isdigit(buf[0]))\ 6102 return -EINVAL;\ 6103 if (sscanf(buf, "%i", &param_val) != 1)\ 6104 return -EINVAL;\ 6105 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 6106 return strlen(buf);\ 6107 else \ 6108 return -EINVAL;\ 6109 } 6110 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 6111 int \ 6112 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 6113 { \ 6114 if (val >= _minval && val <= _maxval) {\ 6115 phba->attr_##_name = val;\ 6116 return 0;\ 6117 } \ 6118 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6119 "BA_%d beiscsi_"#_name" attribute " \ 6120 "cannot be updated to 0x%x, "\ 6121 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6122 phba->attr_##_name = _defval;\ 6123 return -EINVAL;\ 6124 } 6125 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 6126 static uint beiscsi_##_name = _defval;\ 6127 module_param(beiscsi_##_name, uint, S_IRUGO);\ 6128 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 6129 beiscsi_disp_param(_name)\ 6130 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 6131 beiscsi_store_param(_name)\ 6132 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 6133 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 6134 beiscsi_##_name##_disp, beiscsi_##_name##_store) 6135 /* LDV_COMMENT_END_PREP */ 6136 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_eeh_err_detected" */ 6137 struct pci_dev * var_group3; 6138 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_eeh_err_detected" */ 6139 pci_channel_state_t var_beiscsi_eeh_err_detected_107_p1; 6140 /* content: static pci_ers_result_t beiscsi_eeh_reset(struct pci_dev *pdev)*/ 6141 /* LDV_COMMENT_BEGIN_PREP */ 6142 #define beiscsi_disp_param(_name)\ 6143 ssize_t \ 6144 beiscsi_##_name##_disp(struct device *dev,\ 6145 struct device_attribute *attrib, char *buf) \ 6146 { \ 6147 struct Scsi_Host *shost = class_to_shost(dev);\ 6148 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 6149 uint32_t param_val = 0; \ 6150 param_val = phba->attr_##_name;\ 6151 return snprintf(buf, PAGE_SIZE, "%d\n",\ 6152 phba->attr_##_name);\ 6153 } 6154 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 6155 int \ 6156 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 6157 {\ 6158 if (val >= _minval && val <= _maxval) {\ 6159 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6160 "BA_%d : beiscsi_"#_name" updated "\ 6161 "from 0x%x ==> 0x%x\n",\ 6162 phba->attr_##_name, val); \ 6163 phba->attr_##_name = val;\ 6164 return 0;\ 6165 } \ 6166 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 6167 "BA_%d beiscsi_"#_name" attribute "\ 6168 "cannot be updated to 0x%x, "\ 6169 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6170 return -EINVAL;\ 6171 } 6172 #define beiscsi_store_param(_name) \ 6173 ssize_t \ 6174 beiscsi_##_name##_store(struct device *dev,\ 6175 struct device_attribute *attr, const char *buf,\ 6176 size_t count) \ 6177 { \ 6178 struct Scsi_Host *shost = class_to_shost(dev);\ 6179 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 6180 uint32_t param_val = 0;\ 6181 if (!isdigit(buf[0]))\ 6182 return -EINVAL;\ 6183 if (sscanf(buf, "%i", &param_val) != 1)\ 6184 return -EINVAL;\ 6185 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 6186 return strlen(buf);\ 6187 else \ 6188 return -EINVAL;\ 6189 } 6190 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 6191 int \ 6192 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 6193 { \ 6194 if (val >= _minval && val <= _maxval) {\ 6195 phba->attr_##_name = val;\ 6196 return 0;\ 6197 } \ 6198 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6199 "BA_%d beiscsi_"#_name" attribute " \ 6200 "cannot be updated to 0x%x, "\ 6201 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6202 phba->attr_##_name = _defval;\ 6203 return -EINVAL;\ 6204 } 6205 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 6206 static uint beiscsi_##_name = _defval;\ 6207 module_param(beiscsi_##_name, uint, S_IRUGO);\ 6208 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 6209 beiscsi_disp_param(_name)\ 6210 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 6211 beiscsi_store_param(_name)\ 6212 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 6213 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 6214 beiscsi_##_name##_disp, beiscsi_##_name##_store) 6215 /* LDV_COMMENT_END_PREP */ 6216 /* content: static void beiscsi_eeh_resume(struct pci_dev *pdev)*/ 6217 /* LDV_COMMENT_BEGIN_PREP */ 6218 #define beiscsi_disp_param(_name)\ 6219 ssize_t \ 6220 beiscsi_##_name##_disp(struct device *dev,\ 6221 struct device_attribute *attrib, char *buf) \ 6222 { \ 6223 struct Scsi_Host *shost = class_to_shost(dev);\ 6224 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 6225 uint32_t param_val = 0; \ 6226 param_val = phba->attr_##_name;\ 6227 return snprintf(buf, PAGE_SIZE, "%d\n",\ 6228 phba->attr_##_name);\ 6229 } 6230 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 6231 int \ 6232 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 6233 {\ 6234 if (val >= _minval && val <= _maxval) {\ 6235 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6236 "BA_%d : beiscsi_"#_name" updated "\ 6237 "from 0x%x ==> 0x%x\n",\ 6238 phba->attr_##_name, val); \ 6239 phba->attr_##_name = val;\ 6240 return 0;\ 6241 } \ 6242 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 6243 "BA_%d beiscsi_"#_name" attribute "\ 6244 "cannot be updated to 0x%x, "\ 6245 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6246 return -EINVAL;\ 6247 } 6248 #define beiscsi_store_param(_name) \ 6249 ssize_t \ 6250 beiscsi_##_name##_store(struct device *dev,\ 6251 struct device_attribute *attr, const char *buf,\ 6252 size_t count) \ 6253 { \ 6254 struct Scsi_Host *shost = class_to_shost(dev);\ 6255 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 6256 uint32_t param_val = 0;\ 6257 if (!isdigit(buf[0]))\ 6258 return -EINVAL;\ 6259 if (sscanf(buf, "%i", &param_val) != 1)\ 6260 return -EINVAL;\ 6261 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 6262 return strlen(buf);\ 6263 else \ 6264 return -EINVAL;\ 6265 } 6266 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 6267 int \ 6268 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 6269 { \ 6270 if (val >= _minval && val <= _maxval) {\ 6271 phba->attr_##_name = val;\ 6272 return 0;\ 6273 } \ 6274 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6275 "BA_%d beiscsi_"#_name" attribute " \ 6276 "cannot be updated to 0x%x, "\ 6277 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6278 phba->attr_##_name = _defval;\ 6279 return -EINVAL;\ 6280 } 6281 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 6282 static uint beiscsi_##_name = _defval;\ 6283 module_param(beiscsi_##_name, uint, S_IRUGO);\ 6284 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 6285 beiscsi_disp_param(_name)\ 6286 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 6287 beiscsi_store_param(_name)\ 6288 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 6289 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 6290 beiscsi_##_name##_disp, beiscsi_##_name##_store) 6291 /* LDV_COMMENT_END_PREP */ 6292 6293 /** STRUCT: struct type: iscsi_transport, struct name: beiscsi_iscsi_transport **/ 6294 /* content: static int beiscsi_task_xmit(struct iscsi_task *task)*/ 6295 /* LDV_COMMENT_BEGIN_PREP */ 6296 #define beiscsi_disp_param(_name)\ 6297 ssize_t \ 6298 beiscsi_##_name##_disp(struct device *dev,\ 6299 struct device_attribute *attrib, char *buf) \ 6300 { \ 6301 struct Scsi_Host *shost = class_to_shost(dev);\ 6302 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 6303 uint32_t param_val = 0; \ 6304 param_val = phba->attr_##_name;\ 6305 return snprintf(buf, PAGE_SIZE, "%d\n",\ 6306 phba->attr_##_name);\ 6307 } 6308 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 6309 int \ 6310 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 6311 {\ 6312 if (val >= _minval && val <= _maxval) {\ 6313 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6314 "BA_%d : beiscsi_"#_name" updated "\ 6315 "from 0x%x ==> 0x%x\n",\ 6316 phba->attr_##_name, val); \ 6317 phba->attr_##_name = val;\ 6318 return 0;\ 6319 } \ 6320 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 6321 "BA_%d beiscsi_"#_name" attribute "\ 6322 "cannot be updated to 0x%x, "\ 6323 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6324 return -EINVAL;\ 6325 } 6326 #define beiscsi_store_param(_name) \ 6327 ssize_t \ 6328 beiscsi_##_name##_store(struct device *dev,\ 6329 struct device_attribute *attr, const char *buf,\ 6330 size_t count) \ 6331 { \ 6332 struct Scsi_Host *shost = class_to_shost(dev);\ 6333 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 6334 uint32_t param_val = 0;\ 6335 if (!isdigit(buf[0]))\ 6336 return -EINVAL;\ 6337 if (sscanf(buf, "%i", &param_val) != 1)\ 6338 return -EINVAL;\ 6339 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 6340 return strlen(buf);\ 6341 else \ 6342 return -EINVAL;\ 6343 } 6344 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 6345 int \ 6346 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 6347 { \ 6348 if (val >= _minval && val <= _maxval) {\ 6349 phba->attr_##_name = val;\ 6350 return 0;\ 6351 } \ 6352 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6353 "BA_%d beiscsi_"#_name" attribute " \ 6354 "cannot be updated to 0x%x, "\ 6355 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6356 phba->attr_##_name = _defval;\ 6357 return -EINVAL;\ 6358 } 6359 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 6360 static uint beiscsi_##_name = _defval;\ 6361 module_param(beiscsi_##_name, uint, S_IRUGO);\ 6362 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 6363 beiscsi_disp_param(_name)\ 6364 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 6365 beiscsi_store_param(_name)\ 6366 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 6367 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 6368 beiscsi_##_name##_disp, beiscsi_##_name##_store) 6369 /* LDV_COMMENT_END_PREP */ 6370 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_task_xmit" */ 6371 struct iscsi_task * var_group4; 6372 /* content: static void beiscsi_cleanup_task(struct iscsi_task *task)*/ 6373 /* LDV_COMMENT_BEGIN_PREP */ 6374 #define beiscsi_disp_param(_name)\ 6375 ssize_t \ 6376 beiscsi_##_name##_disp(struct device *dev,\ 6377 struct device_attribute *attrib, char *buf) \ 6378 { \ 6379 struct Scsi_Host *shost = class_to_shost(dev);\ 6380 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 6381 uint32_t param_val = 0; \ 6382 param_val = phba->attr_##_name;\ 6383 return snprintf(buf, PAGE_SIZE, "%d\n",\ 6384 phba->attr_##_name);\ 6385 } 6386 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 6387 int \ 6388 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 6389 {\ 6390 if (val >= _minval && val <= _maxval) {\ 6391 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6392 "BA_%d : beiscsi_"#_name" updated "\ 6393 "from 0x%x ==> 0x%x\n",\ 6394 phba->attr_##_name, val); \ 6395 phba->attr_##_name = val;\ 6396 return 0;\ 6397 } \ 6398 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 6399 "BA_%d beiscsi_"#_name" attribute "\ 6400 "cannot be updated to 0x%x, "\ 6401 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6402 return -EINVAL;\ 6403 } 6404 #define beiscsi_store_param(_name) \ 6405 ssize_t \ 6406 beiscsi_##_name##_store(struct device *dev,\ 6407 struct device_attribute *attr, const char *buf,\ 6408 size_t count) \ 6409 { \ 6410 struct Scsi_Host *shost = class_to_shost(dev);\ 6411 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 6412 uint32_t param_val = 0;\ 6413 if (!isdigit(buf[0]))\ 6414 return -EINVAL;\ 6415 if (sscanf(buf, "%i", &param_val) != 1)\ 6416 return -EINVAL;\ 6417 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 6418 return strlen(buf);\ 6419 else \ 6420 return -EINVAL;\ 6421 } 6422 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 6423 int \ 6424 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 6425 { \ 6426 if (val >= _minval && val <= _maxval) {\ 6427 phba->attr_##_name = val;\ 6428 return 0;\ 6429 } \ 6430 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6431 "BA_%d beiscsi_"#_name" attribute " \ 6432 "cannot be updated to 0x%x, "\ 6433 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6434 phba->attr_##_name = _defval;\ 6435 return -EINVAL;\ 6436 } 6437 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 6438 static uint beiscsi_##_name = _defval;\ 6439 module_param(beiscsi_##_name, uint, S_IRUGO);\ 6440 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 6441 beiscsi_disp_param(_name)\ 6442 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 6443 beiscsi_store_param(_name)\ 6444 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 6445 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 6446 beiscsi_##_name##_disp, beiscsi_##_name##_store) 6447 /* LDV_COMMENT_END_PREP */ 6448 /* content: static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode)*/ 6449 /* LDV_COMMENT_BEGIN_PREP */ 6450 #define beiscsi_disp_param(_name)\ 6451 ssize_t \ 6452 beiscsi_##_name##_disp(struct device *dev,\ 6453 struct device_attribute *attrib, char *buf) \ 6454 { \ 6455 struct Scsi_Host *shost = class_to_shost(dev);\ 6456 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 6457 uint32_t param_val = 0; \ 6458 param_val = phba->attr_##_name;\ 6459 return snprintf(buf, PAGE_SIZE, "%d\n",\ 6460 phba->attr_##_name);\ 6461 } 6462 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 6463 int \ 6464 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 6465 {\ 6466 if (val >= _minval && val <= _maxval) {\ 6467 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6468 "BA_%d : beiscsi_"#_name" updated "\ 6469 "from 0x%x ==> 0x%x\n",\ 6470 phba->attr_##_name, val); \ 6471 phba->attr_##_name = val;\ 6472 return 0;\ 6473 } \ 6474 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 6475 "BA_%d beiscsi_"#_name" attribute "\ 6476 "cannot be updated to 0x%x, "\ 6477 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6478 return -EINVAL;\ 6479 } 6480 #define beiscsi_store_param(_name) \ 6481 ssize_t \ 6482 beiscsi_##_name##_store(struct device *dev,\ 6483 struct device_attribute *attr, const char *buf,\ 6484 size_t count) \ 6485 { \ 6486 struct Scsi_Host *shost = class_to_shost(dev);\ 6487 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 6488 uint32_t param_val = 0;\ 6489 if (!isdigit(buf[0]))\ 6490 return -EINVAL;\ 6491 if (sscanf(buf, "%i", &param_val) != 1)\ 6492 return -EINVAL;\ 6493 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 6494 return strlen(buf);\ 6495 else \ 6496 return -EINVAL;\ 6497 } 6498 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 6499 int \ 6500 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 6501 { \ 6502 if (val >= _minval && val <= _maxval) {\ 6503 phba->attr_##_name = val;\ 6504 return 0;\ 6505 } \ 6506 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6507 "BA_%d beiscsi_"#_name" attribute " \ 6508 "cannot be updated to 0x%x, "\ 6509 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6510 phba->attr_##_name = _defval;\ 6511 return -EINVAL;\ 6512 } 6513 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 6514 static uint beiscsi_##_name = _defval;\ 6515 module_param(beiscsi_##_name, uint, S_IRUGO);\ 6516 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 6517 beiscsi_disp_param(_name)\ 6518 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 6519 beiscsi_store_param(_name)\ 6520 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 6521 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 6522 beiscsi_##_name##_disp, beiscsi_##_name##_store) 6523 /* LDV_COMMENT_END_PREP */ 6524 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_alloc_pdu" */ 6525 uint8_t var_beiscsi_alloc_pdu_95_p1; 6526 /* content: static void beiscsi_parse_pdu(struct iscsi_conn *conn, itt_t itt, int *index, int *age)*/ 6527 /* LDV_COMMENT_BEGIN_PREP */ 6528 #define beiscsi_disp_param(_name)\ 6529 ssize_t \ 6530 beiscsi_##_name##_disp(struct device *dev,\ 6531 struct device_attribute *attrib, char *buf) \ 6532 { \ 6533 struct Scsi_Host *shost = class_to_shost(dev);\ 6534 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 6535 uint32_t param_val = 0; \ 6536 param_val = phba->attr_##_name;\ 6537 return snprintf(buf, PAGE_SIZE, "%d\n",\ 6538 phba->attr_##_name);\ 6539 } 6540 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 6541 int \ 6542 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 6543 {\ 6544 if (val >= _minval && val <= _maxval) {\ 6545 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6546 "BA_%d : beiscsi_"#_name" updated "\ 6547 "from 0x%x ==> 0x%x\n",\ 6548 phba->attr_##_name, val); \ 6549 phba->attr_##_name = val;\ 6550 return 0;\ 6551 } \ 6552 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 6553 "BA_%d beiscsi_"#_name" attribute "\ 6554 "cannot be updated to 0x%x, "\ 6555 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6556 return -EINVAL;\ 6557 } 6558 #define beiscsi_store_param(_name) \ 6559 ssize_t \ 6560 beiscsi_##_name##_store(struct device *dev,\ 6561 struct device_attribute *attr, const char *buf,\ 6562 size_t count) \ 6563 { \ 6564 struct Scsi_Host *shost = class_to_shost(dev);\ 6565 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 6566 uint32_t param_val = 0;\ 6567 if (!isdigit(buf[0]))\ 6568 return -EINVAL;\ 6569 if (sscanf(buf, "%i", &param_val) != 1)\ 6570 return -EINVAL;\ 6571 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 6572 return strlen(buf);\ 6573 else \ 6574 return -EINVAL;\ 6575 } 6576 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 6577 int \ 6578 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 6579 { \ 6580 if (val >= _minval && val <= _maxval) {\ 6581 phba->attr_##_name = val;\ 6582 return 0;\ 6583 } \ 6584 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6585 "BA_%d beiscsi_"#_name" attribute " \ 6586 "cannot be updated to 0x%x, "\ 6587 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6588 phba->attr_##_name = _defval;\ 6589 return -EINVAL;\ 6590 } 6591 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 6592 static uint beiscsi_##_name = _defval;\ 6593 module_param(beiscsi_##_name, uint, S_IRUGO);\ 6594 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 6595 beiscsi_disp_param(_name)\ 6596 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 6597 beiscsi_store_param(_name)\ 6598 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 6599 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 6600 beiscsi_##_name##_disp, beiscsi_##_name##_store) 6601 /* LDV_COMMENT_END_PREP */ 6602 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_parse_pdu" */ 6603 struct iscsi_conn * var_group5; 6604 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_parse_pdu" */ 6605 itt_t var_beiscsi_parse_pdu_94_p1; 6606 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_parse_pdu" */ 6607 int * var_beiscsi_parse_pdu_94_p2; 6608 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_parse_pdu" */ 6609 int * var_beiscsi_parse_pdu_94_p3; 6610 /* content: static int beiscsi_bsg_request(struct bsg_job *job)*/ 6611 /* LDV_COMMENT_BEGIN_PREP */ 6612 #define beiscsi_disp_param(_name)\ 6613 ssize_t \ 6614 beiscsi_##_name##_disp(struct device *dev,\ 6615 struct device_attribute *attrib, char *buf) \ 6616 { \ 6617 struct Scsi_Host *shost = class_to_shost(dev);\ 6618 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 6619 uint32_t param_val = 0; \ 6620 param_val = phba->attr_##_name;\ 6621 return snprintf(buf, PAGE_SIZE, "%d\n",\ 6622 phba->attr_##_name);\ 6623 } 6624 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 6625 int \ 6626 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 6627 {\ 6628 if (val >= _minval && val <= _maxval) {\ 6629 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6630 "BA_%d : beiscsi_"#_name" updated "\ 6631 "from 0x%x ==> 0x%x\n",\ 6632 phba->attr_##_name, val); \ 6633 phba->attr_##_name = val;\ 6634 return 0;\ 6635 } \ 6636 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 6637 "BA_%d beiscsi_"#_name" attribute "\ 6638 "cannot be updated to 0x%x, "\ 6639 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6640 return -EINVAL;\ 6641 } 6642 #define beiscsi_store_param(_name) \ 6643 ssize_t \ 6644 beiscsi_##_name##_store(struct device *dev,\ 6645 struct device_attribute *attr, const char *buf,\ 6646 size_t count) \ 6647 { \ 6648 struct Scsi_Host *shost = class_to_shost(dev);\ 6649 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 6650 uint32_t param_val = 0;\ 6651 if (!isdigit(buf[0]))\ 6652 return -EINVAL;\ 6653 if (sscanf(buf, "%i", &param_val) != 1)\ 6654 return -EINVAL;\ 6655 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 6656 return strlen(buf);\ 6657 else \ 6658 return -EINVAL;\ 6659 } 6660 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 6661 int \ 6662 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 6663 { \ 6664 if (val >= _minval && val <= _maxval) {\ 6665 phba->attr_##_name = val;\ 6666 return 0;\ 6667 } \ 6668 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6669 "BA_%d beiscsi_"#_name" attribute " \ 6670 "cannot be updated to 0x%x, "\ 6671 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6672 phba->attr_##_name = _defval;\ 6673 return -EINVAL;\ 6674 } 6675 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 6676 static uint beiscsi_##_name = _defval;\ 6677 module_param(beiscsi_##_name, uint, S_IRUGO);\ 6678 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 6679 beiscsi_disp_param(_name)\ 6680 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 6681 beiscsi_store_param(_name)\ 6682 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 6683 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 6684 beiscsi_##_name##_disp, beiscsi_##_name##_store) 6685 /* LDV_COMMENT_END_PREP */ 6686 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_bsg_request" */ 6687 struct bsg_job * var_group6; 6688 6689 /** STRUCT: struct type: pci_driver, struct name: beiscsi_pci_driver **/ 6690 /* content: static int beiscsi_dev_probe(struct pci_dev *pcidev, const struct pci_device_id *id)*/ 6691 /* LDV_COMMENT_BEGIN_PREP */ 6692 #define beiscsi_disp_param(_name)\ 6693 ssize_t \ 6694 beiscsi_##_name##_disp(struct device *dev,\ 6695 struct device_attribute *attrib, char *buf) \ 6696 { \ 6697 struct Scsi_Host *shost = class_to_shost(dev);\ 6698 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 6699 uint32_t param_val = 0; \ 6700 param_val = phba->attr_##_name;\ 6701 return snprintf(buf, PAGE_SIZE, "%d\n",\ 6702 phba->attr_##_name);\ 6703 } 6704 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 6705 int \ 6706 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 6707 {\ 6708 if (val >= _minval && val <= _maxval) {\ 6709 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6710 "BA_%d : beiscsi_"#_name" updated "\ 6711 "from 0x%x ==> 0x%x\n",\ 6712 phba->attr_##_name, val); \ 6713 phba->attr_##_name = val;\ 6714 return 0;\ 6715 } \ 6716 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 6717 "BA_%d beiscsi_"#_name" attribute "\ 6718 "cannot be updated to 0x%x, "\ 6719 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6720 return -EINVAL;\ 6721 } 6722 #define beiscsi_store_param(_name) \ 6723 ssize_t \ 6724 beiscsi_##_name##_store(struct device *dev,\ 6725 struct device_attribute *attr, const char *buf,\ 6726 size_t count) \ 6727 { \ 6728 struct Scsi_Host *shost = class_to_shost(dev);\ 6729 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 6730 uint32_t param_val = 0;\ 6731 if (!isdigit(buf[0]))\ 6732 return -EINVAL;\ 6733 if (sscanf(buf, "%i", &param_val) != 1)\ 6734 return -EINVAL;\ 6735 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 6736 return strlen(buf);\ 6737 else \ 6738 return -EINVAL;\ 6739 } 6740 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 6741 int \ 6742 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 6743 { \ 6744 if (val >= _minval && val <= _maxval) {\ 6745 phba->attr_##_name = val;\ 6746 return 0;\ 6747 } \ 6748 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6749 "BA_%d beiscsi_"#_name" attribute " \ 6750 "cannot be updated to 0x%x, "\ 6751 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6752 phba->attr_##_name = _defval;\ 6753 return -EINVAL;\ 6754 } 6755 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 6756 static uint beiscsi_##_name = _defval;\ 6757 module_param(beiscsi_##_name, uint, S_IRUGO);\ 6758 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 6759 beiscsi_disp_param(_name)\ 6760 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 6761 beiscsi_store_param(_name)\ 6762 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 6763 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 6764 beiscsi_##_name##_disp, beiscsi_##_name##_store) 6765 /* LDV_COMMENT_END_PREP */ 6766 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_dev_probe" */ 6767 const struct pci_device_id * var_beiscsi_dev_probe_110_p1; 6768 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "beiscsi_dev_probe" */ 6769 static int res_beiscsi_dev_probe_110; 6770 /* content: static void beiscsi_remove(struct pci_dev *pcidev)*/ 6771 /* LDV_COMMENT_BEGIN_PREP */ 6772 #define beiscsi_disp_param(_name)\ 6773 ssize_t \ 6774 beiscsi_##_name##_disp(struct device *dev,\ 6775 struct device_attribute *attrib, char *buf) \ 6776 { \ 6777 struct Scsi_Host *shost = class_to_shost(dev);\ 6778 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 6779 uint32_t param_val = 0; \ 6780 param_val = phba->attr_##_name;\ 6781 return snprintf(buf, PAGE_SIZE, "%d\n",\ 6782 phba->attr_##_name);\ 6783 } 6784 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 6785 int \ 6786 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 6787 {\ 6788 if (val >= _minval && val <= _maxval) {\ 6789 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6790 "BA_%d : beiscsi_"#_name" updated "\ 6791 "from 0x%x ==> 0x%x\n",\ 6792 phba->attr_##_name, val); \ 6793 phba->attr_##_name = val;\ 6794 return 0;\ 6795 } \ 6796 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 6797 "BA_%d beiscsi_"#_name" attribute "\ 6798 "cannot be updated to 0x%x, "\ 6799 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6800 return -EINVAL;\ 6801 } 6802 #define beiscsi_store_param(_name) \ 6803 ssize_t \ 6804 beiscsi_##_name##_store(struct device *dev,\ 6805 struct device_attribute *attr, const char *buf,\ 6806 size_t count) \ 6807 { \ 6808 struct Scsi_Host *shost = class_to_shost(dev);\ 6809 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 6810 uint32_t param_val = 0;\ 6811 if (!isdigit(buf[0]))\ 6812 return -EINVAL;\ 6813 if (sscanf(buf, "%i", &param_val) != 1)\ 6814 return -EINVAL;\ 6815 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 6816 return strlen(buf);\ 6817 else \ 6818 return -EINVAL;\ 6819 } 6820 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 6821 int \ 6822 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 6823 { \ 6824 if (val >= _minval && val <= _maxval) {\ 6825 phba->attr_##_name = val;\ 6826 return 0;\ 6827 } \ 6828 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6829 "BA_%d beiscsi_"#_name" attribute " \ 6830 "cannot be updated to 0x%x, "\ 6831 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6832 phba->attr_##_name = _defval;\ 6833 return -EINVAL;\ 6834 } 6835 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 6836 static uint beiscsi_##_name = _defval;\ 6837 module_param(beiscsi_##_name, uint, S_IRUGO);\ 6838 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 6839 beiscsi_disp_param(_name)\ 6840 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 6841 beiscsi_store_param(_name)\ 6842 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 6843 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 6844 beiscsi_##_name##_disp, beiscsi_##_name##_store) 6845 /* LDV_COMMENT_END_PREP */ 6846 /* content: static void beiscsi_shutdown(struct pci_dev *pcidev)*/ 6847 /* LDV_COMMENT_BEGIN_PREP */ 6848 #define beiscsi_disp_param(_name)\ 6849 ssize_t \ 6850 beiscsi_##_name##_disp(struct device *dev,\ 6851 struct device_attribute *attrib, char *buf) \ 6852 { \ 6853 struct Scsi_Host *shost = class_to_shost(dev);\ 6854 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 6855 uint32_t param_val = 0; \ 6856 param_val = phba->attr_##_name;\ 6857 return snprintf(buf, PAGE_SIZE, "%d\n",\ 6858 phba->attr_##_name);\ 6859 } 6860 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 6861 int \ 6862 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 6863 {\ 6864 if (val >= _minval && val <= _maxval) {\ 6865 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6866 "BA_%d : beiscsi_"#_name" updated "\ 6867 "from 0x%x ==> 0x%x\n",\ 6868 phba->attr_##_name, val); \ 6869 phba->attr_##_name = val;\ 6870 return 0;\ 6871 } \ 6872 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 6873 "BA_%d beiscsi_"#_name" attribute "\ 6874 "cannot be updated to 0x%x, "\ 6875 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6876 return -EINVAL;\ 6877 } 6878 #define beiscsi_store_param(_name) \ 6879 ssize_t \ 6880 beiscsi_##_name##_store(struct device *dev,\ 6881 struct device_attribute *attr, const char *buf,\ 6882 size_t count) \ 6883 { \ 6884 struct Scsi_Host *shost = class_to_shost(dev);\ 6885 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 6886 uint32_t param_val = 0;\ 6887 if (!isdigit(buf[0]))\ 6888 return -EINVAL;\ 6889 if (sscanf(buf, "%i", &param_val) != 1)\ 6890 return -EINVAL;\ 6891 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 6892 return strlen(buf);\ 6893 else \ 6894 return -EINVAL;\ 6895 } 6896 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 6897 int \ 6898 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 6899 { \ 6900 if (val >= _minval && val <= _maxval) {\ 6901 phba->attr_##_name = val;\ 6902 return 0;\ 6903 } \ 6904 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6905 "BA_%d beiscsi_"#_name" attribute " \ 6906 "cannot be updated to 0x%x, "\ 6907 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6908 phba->attr_##_name = _defval;\ 6909 return -EINVAL;\ 6910 } 6911 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 6912 static uint beiscsi_##_name = _defval;\ 6913 module_param(beiscsi_##_name, uint, S_IRUGO);\ 6914 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 6915 beiscsi_disp_param(_name)\ 6916 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 6917 beiscsi_store_param(_name)\ 6918 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 6919 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 6920 beiscsi_##_name##_disp, beiscsi_##_name##_store) 6921 /* LDV_COMMENT_END_PREP */ 6922 6923 /** CALLBACK SECTION request_irq **/ 6924 /* content: static irqreturn_t be_isr(int irq, void *dev_id)*/ 6925 /* LDV_COMMENT_BEGIN_PREP */ 6926 #define beiscsi_disp_param(_name)\ 6927 ssize_t \ 6928 beiscsi_##_name##_disp(struct device *dev,\ 6929 struct device_attribute *attrib, char *buf) \ 6930 { \ 6931 struct Scsi_Host *shost = class_to_shost(dev);\ 6932 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 6933 uint32_t param_val = 0; \ 6934 param_val = phba->attr_##_name;\ 6935 return snprintf(buf, PAGE_SIZE, "%d\n",\ 6936 phba->attr_##_name);\ 6937 } 6938 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 6939 int \ 6940 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 6941 {\ 6942 if (val >= _minval && val <= _maxval) {\ 6943 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6944 "BA_%d : beiscsi_"#_name" updated "\ 6945 "from 0x%x ==> 0x%x\n",\ 6946 phba->attr_##_name, val); \ 6947 phba->attr_##_name = val;\ 6948 return 0;\ 6949 } \ 6950 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 6951 "BA_%d beiscsi_"#_name" attribute "\ 6952 "cannot be updated to 0x%x, "\ 6953 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6954 return -EINVAL;\ 6955 } 6956 #define beiscsi_store_param(_name) \ 6957 ssize_t \ 6958 beiscsi_##_name##_store(struct device *dev,\ 6959 struct device_attribute *attr, const char *buf,\ 6960 size_t count) \ 6961 { \ 6962 struct Scsi_Host *shost = class_to_shost(dev);\ 6963 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 6964 uint32_t param_val = 0;\ 6965 if (!isdigit(buf[0]))\ 6966 return -EINVAL;\ 6967 if (sscanf(buf, "%i", &param_val) != 1)\ 6968 return -EINVAL;\ 6969 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 6970 return strlen(buf);\ 6971 else \ 6972 return -EINVAL;\ 6973 } 6974 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 6975 int \ 6976 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 6977 { \ 6978 if (val >= _minval && val <= _maxval) {\ 6979 phba->attr_##_name = val;\ 6980 return 0;\ 6981 } \ 6982 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 6983 "BA_%d beiscsi_"#_name" attribute " \ 6984 "cannot be updated to 0x%x, "\ 6985 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 6986 phba->attr_##_name = _defval;\ 6987 return -EINVAL;\ 6988 } 6989 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 6990 static uint beiscsi_##_name = _defval;\ 6991 module_param(beiscsi_##_name, uint, S_IRUGO);\ 6992 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 6993 beiscsi_disp_param(_name)\ 6994 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 6995 beiscsi_store_param(_name)\ 6996 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 6997 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 6998 beiscsi_##_name##_disp, beiscsi_##_name##_store) 6999 /* LDV_COMMENT_END_PREP */ 7000 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "be_isr" */ 7001 int var_be_isr_18_p0; 7002 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "be_isr" */ 7003 void * var_be_isr_18_p1; 7004 /* content: static irqreturn_t be_isr_mcc(int irq, void *dev_id)*/ 7005 /* LDV_COMMENT_BEGIN_PREP */ 7006 #define beiscsi_disp_param(_name)\ 7007 ssize_t \ 7008 beiscsi_##_name##_disp(struct device *dev,\ 7009 struct device_attribute *attrib, char *buf) \ 7010 { \ 7011 struct Scsi_Host *shost = class_to_shost(dev);\ 7012 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 7013 uint32_t param_val = 0; \ 7014 param_val = phba->attr_##_name;\ 7015 return snprintf(buf, PAGE_SIZE, "%d\n",\ 7016 phba->attr_##_name);\ 7017 } 7018 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 7019 int \ 7020 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 7021 {\ 7022 if (val >= _minval && val <= _maxval) {\ 7023 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7024 "BA_%d : beiscsi_"#_name" updated "\ 7025 "from 0x%x ==> 0x%x\n",\ 7026 phba->attr_##_name, val); \ 7027 phba->attr_##_name = val;\ 7028 return 0;\ 7029 } \ 7030 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 7031 "BA_%d beiscsi_"#_name" attribute "\ 7032 "cannot be updated to 0x%x, "\ 7033 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7034 return -EINVAL;\ 7035 } 7036 #define beiscsi_store_param(_name) \ 7037 ssize_t \ 7038 beiscsi_##_name##_store(struct device *dev,\ 7039 struct device_attribute *attr, const char *buf,\ 7040 size_t count) \ 7041 { \ 7042 struct Scsi_Host *shost = class_to_shost(dev);\ 7043 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 7044 uint32_t param_val = 0;\ 7045 if (!isdigit(buf[0]))\ 7046 return -EINVAL;\ 7047 if (sscanf(buf, "%i", &param_val) != 1)\ 7048 return -EINVAL;\ 7049 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 7050 return strlen(buf);\ 7051 else \ 7052 return -EINVAL;\ 7053 } 7054 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 7055 int \ 7056 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 7057 { \ 7058 if (val >= _minval && val <= _maxval) {\ 7059 phba->attr_##_name = val;\ 7060 return 0;\ 7061 } \ 7062 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7063 "BA_%d beiscsi_"#_name" attribute " \ 7064 "cannot be updated to 0x%x, "\ 7065 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7066 phba->attr_##_name = _defval;\ 7067 return -EINVAL;\ 7068 } 7069 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 7070 static uint beiscsi_##_name = _defval;\ 7071 module_param(beiscsi_##_name, uint, S_IRUGO);\ 7072 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 7073 beiscsi_disp_param(_name)\ 7074 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 7075 beiscsi_store_param(_name)\ 7076 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 7077 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 7078 beiscsi_##_name##_disp, beiscsi_##_name##_store) 7079 /* LDV_COMMENT_END_PREP */ 7080 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "be_isr_mcc" */ 7081 int var_be_isr_mcc_16_p0; 7082 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "be_isr_mcc" */ 7083 void * var_be_isr_mcc_16_p1; 7084 /* content: static irqreturn_t be_isr_msix(int irq, void *dev_id)*/ 7085 /* LDV_COMMENT_BEGIN_PREP */ 7086 #define beiscsi_disp_param(_name)\ 7087 ssize_t \ 7088 beiscsi_##_name##_disp(struct device *dev,\ 7089 struct device_attribute *attrib, char *buf) \ 7090 { \ 7091 struct Scsi_Host *shost = class_to_shost(dev);\ 7092 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 7093 uint32_t param_val = 0; \ 7094 param_val = phba->attr_##_name;\ 7095 return snprintf(buf, PAGE_SIZE, "%d\n",\ 7096 phba->attr_##_name);\ 7097 } 7098 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 7099 int \ 7100 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 7101 {\ 7102 if (val >= _minval && val <= _maxval) {\ 7103 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7104 "BA_%d : beiscsi_"#_name" updated "\ 7105 "from 0x%x ==> 0x%x\n",\ 7106 phba->attr_##_name, val); \ 7107 phba->attr_##_name = val;\ 7108 return 0;\ 7109 } \ 7110 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 7111 "BA_%d beiscsi_"#_name" attribute "\ 7112 "cannot be updated to 0x%x, "\ 7113 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7114 return -EINVAL;\ 7115 } 7116 #define beiscsi_store_param(_name) \ 7117 ssize_t \ 7118 beiscsi_##_name##_store(struct device *dev,\ 7119 struct device_attribute *attr, const char *buf,\ 7120 size_t count) \ 7121 { \ 7122 struct Scsi_Host *shost = class_to_shost(dev);\ 7123 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 7124 uint32_t param_val = 0;\ 7125 if (!isdigit(buf[0]))\ 7126 return -EINVAL;\ 7127 if (sscanf(buf, "%i", &param_val) != 1)\ 7128 return -EINVAL;\ 7129 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 7130 return strlen(buf);\ 7131 else \ 7132 return -EINVAL;\ 7133 } 7134 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 7135 int \ 7136 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 7137 { \ 7138 if (val >= _minval && val <= _maxval) {\ 7139 phba->attr_##_name = val;\ 7140 return 0;\ 7141 } \ 7142 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7143 "BA_%d beiscsi_"#_name" attribute " \ 7144 "cannot be updated to 0x%x, "\ 7145 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7146 phba->attr_##_name = _defval;\ 7147 return -EINVAL;\ 7148 } 7149 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 7150 static uint beiscsi_##_name = _defval;\ 7151 module_param(beiscsi_##_name, uint, S_IRUGO);\ 7152 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 7153 beiscsi_disp_param(_name)\ 7154 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 7155 beiscsi_store_param(_name)\ 7156 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 7157 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 7158 beiscsi_##_name##_disp, beiscsi_##_name##_store) 7159 /* LDV_COMMENT_END_PREP */ 7160 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "be_isr_msix" */ 7161 int var_be_isr_msix_17_p0; 7162 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "be_isr_msix" */ 7163 void * var_be_isr_msix_17_p1; 7164 7165 7166 7167 7168 /* LDV_COMMENT_END_VARIABLE_DECLARATION_PART */ 7169 /* LDV_COMMENT_BEGIN_VARIABLE_INITIALIZING_PART */ 7170 /*============================= VARIABLE INITIALIZING PART =============================*/ 7171 LDV_IN_INTERRUPT=1; 7172 7173 7174 7175 7176 /* LDV_COMMENT_END_VARIABLE_INITIALIZING_PART */ 7177 /* LDV_COMMENT_BEGIN_FUNCTION_CALL_SECTION */ 7178 /*============================= FUNCTION CALL SECTION =============================*/ 7179 /* LDV_COMMENT_FUNCTION_CALL Initialize LDV model. */ 7180 ldv_initialize(); 7181 7182 /** INIT: init_type: ST_MODULE_INIT **/ 7183 /* content: static int __init beiscsi_module_init(void)*/ 7184 /* LDV_COMMENT_BEGIN_PREP */ 7185 #define beiscsi_disp_param(_name)\ 7186 ssize_t \ 7187 beiscsi_##_name##_disp(struct device *dev,\ 7188 struct device_attribute *attrib, char *buf) \ 7189 { \ 7190 struct Scsi_Host *shost = class_to_shost(dev);\ 7191 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 7192 uint32_t param_val = 0; \ 7193 param_val = phba->attr_##_name;\ 7194 return snprintf(buf, PAGE_SIZE, "%d\n",\ 7195 phba->attr_##_name);\ 7196 } 7197 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 7198 int \ 7199 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 7200 {\ 7201 if (val >= _minval && val <= _maxval) {\ 7202 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7203 "BA_%d : beiscsi_"#_name" updated "\ 7204 "from 0x%x ==> 0x%x\n",\ 7205 phba->attr_##_name, val); \ 7206 phba->attr_##_name = val;\ 7207 return 0;\ 7208 } \ 7209 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 7210 "BA_%d beiscsi_"#_name" attribute "\ 7211 "cannot be updated to 0x%x, "\ 7212 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7213 return -EINVAL;\ 7214 } 7215 #define beiscsi_store_param(_name) \ 7216 ssize_t \ 7217 beiscsi_##_name##_store(struct device *dev,\ 7218 struct device_attribute *attr, const char *buf,\ 7219 size_t count) \ 7220 { \ 7221 struct Scsi_Host *shost = class_to_shost(dev);\ 7222 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 7223 uint32_t param_val = 0;\ 7224 if (!isdigit(buf[0]))\ 7225 return -EINVAL;\ 7226 if (sscanf(buf, "%i", &param_val) != 1)\ 7227 return -EINVAL;\ 7228 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 7229 return strlen(buf);\ 7230 else \ 7231 return -EINVAL;\ 7232 } 7233 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 7234 int \ 7235 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 7236 { \ 7237 if (val >= _minval && val <= _maxval) {\ 7238 phba->attr_##_name = val;\ 7239 return 0;\ 7240 } \ 7241 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7242 "BA_%d beiscsi_"#_name" attribute " \ 7243 "cannot be updated to 0x%x, "\ 7244 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7245 phba->attr_##_name = _defval;\ 7246 return -EINVAL;\ 7247 } 7248 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 7249 static uint beiscsi_##_name = _defval;\ 7250 module_param(beiscsi_##_name, uint, S_IRUGO);\ 7251 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 7252 beiscsi_disp_param(_name)\ 7253 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 7254 beiscsi_store_param(_name)\ 7255 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 7256 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 7257 beiscsi_##_name##_disp, beiscsi_##_name##_store) 7258 /* LDV_COMMENT_END_PREP */ 7259 /* LDV_COMMENT_FUNCTION_CALL Kernel calls driver init function after driver loading to kernel. This function declared as "MODULE_INIT(function name)". */ 7260 ldv_handler_precall(); 7261 if(beiscsi_module_init()) 7262 goto ldv_final; 7263 7264 7265 7266 7267 7268 7269 int ldv_s_beiscsi_pci_driver_pci_driver = 0; 7270 7271 7272 7273 7274 7275 while( nondet_int() 7276 || !(ldv_s_beiscsi_pci_driver_pci_driver == 0) 7277 ) { 7278 7279 switch(nondet_int()) { 7280 7281 case 0: { 7282 7283 /** STRUCT: struct type: scsi_host_template, struct name: beiscsi_sht **/ 7284 7285 7286 /* content: static int beiscsi_slave_configure(struct scsi_device *sdev)*/ 7287 /* LDV_COMMENT_BEGIN_PREP */ 7288 #define beiscsi_disp_param(_name)\ 7289 ssize_t \ 7290 beiscsi_##_name##_disp(struct device *dev,\ 7291 struct device_attribute *attrib, char *buf) \ 7292 { \ 7293 struct Scsi_Host *shost = class_to_shost(dev);\ 7294 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 7295 uint32_t param_val = 0; \ 7296 param_val = phba->attr_##_name;\ 7297 return snprintf(buf, PAGE_SIZE, "%d\n",\ 7298 phba->attr_##_name);\ 7299 } 7300 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 7301 int \ 7302 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 7303 {\ 7304 if (val >= _minval && val <= _maxval) {\ 7305 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7306 "BA_%d : beiscsi_"#_name" updated "\ 7307 "from 0x%x ==> 0x%x\n",\ 7308 phba->attr_##_name, val); \ 7309 phba->attr_##_name = val;\ 7310 return 0;\ 7311 } \ 7312 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 7313 "BA_%d beiscsi_"#_name" attribute "\ 7314 "cannot be updated to 0x%x, "\ 7315 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7316 return -EINVAL;\ 7317 } 7318 #define beiscsi_store_param(_name) \ 7319 ssize_t \ 7320 beiscsi_##_name##_store(struct device *dev,\ 7321 struct device_attribute *attr, const char *buf,\ 7322 size_t count) \ 7323 { \ 7324 struct Scsi_Host *shost = class_to_shost(dev);\ 7325 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 7326 uint32_t param_val = 0;\ 7327 if (!isdigit(buf[0]))\ 7328 return -EINVAL;\ 7329 if (sscanf(buf, "%i", &param_val) != 1)\ 7330 return -EINVAL;\ 7331 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 7332 return strlen(buf);\ 7333 else \ 7334 return -EINVAL;\ 7335 } 7336 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 7337 int \ 7338 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 7339 { \ 7340 if (val >= _minval && val <= _maxval) {\ 7341 phba->attr_##_name = val;\ 7342 return 0;\ 7343 } \ 7344 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7345 "BA_%d beiscsi_"#_name" attribute " \ 7346 "cannot be updated to 0x%x, "\ 7347 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7348 phba->attr_##_name = _defval;\ 7349 return -EINVAL;\ 7350 } 7351 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 7352 static uint beiscsi_##_name = _defval;\ 7353 module_param(beiscsi_##_name, uint, S_IRUGO);\ 7354 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 7355 beiscsi_disp_param(_name)\ 7356 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 7357 beiscsi_store_param(_name)\ 7358 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 7359 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 7360 beiscsi_##_name##_disp, beiscsi_##_name##_store) 7361 /* LDV_COMMENT_END_PREP */ 7362 /* LDV_COMMENT_FUNCTION_CALL Function from field "slave_configure" from driver structure with callbacks "beiscsi_sht" */ 7363 ldv_handler_precall(); 7364 beiscsi_slave_configure( var_group1); 7365 7366 7367 7368 7369 } 7370 7371 break; 7372 case 1: { 7373 7374 /** STRUCT: struct type: scsi_host_template, struct name: beiscsi_sht **/ 7375 7376 7377 /* content: static int beiscsi_eh_abort(struct scsi_cmnd *sc)*/ 7378 /* LDV_COMMENT_BEGIN_PREP */ 7379 #define beiscsi_disp_param(_name)\ 7380 ssize_t \ 7381 beiscsi_##_name##_disp(struct device *dev,\ 7382 struct device_attribute *attrib, char *buf) \ 7383 { \ 7384 struct Scsi_Host *shost = class_to_shost(dev);\ 7385 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 7386 uint32_t param_val = 0; \ 7387 param_val = phba->attr_##_name;\ 7388 return snprintf(buf, PAGE_SIZE, "%d\n",\ 7389 phba->attr_##_name);\ 7390 } 7391 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 7392 int \ 7393 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 7394 {\ 7395 if (val >= _minval && val <= _maxval) {\ 7396 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7397 "BA_%d : beiscsi_"#_name" updated "\ 7398 "from 0x%x ==> 0x%x\n",\ 7399 phba->attr_##_name, val); \ 7400 phba->attr_##_name = val;\ 7401 return 0;\ 7402 } \ 7403 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 7404 "BA_%d beiscsi_"#_name" attribute "\ 7405 "cannot be updated to 0x%x, "\ 7406 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7407 return -EINVAL;\ 7408 } 7409 #define beiscsi_store_param(_name) \ 7410 ssize_t \ 7411 beiscsi_##_name##_store(struct device *dev,\ 7412 struct device_attribute *attr, const char *buf,\ 7413 size_t count) \ 7414 { \ 7415 struct Scsi_Host *shost = class_to_shost(dev);\ 7416 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 7417 uint32_t param_val = 0;\ 7418 if (!isdigit(buf[0]))\ 7419 return -EINVAL;\ 7420 if (sscanf(buf, "%i", &param_val) != 1)\ 7421 return -EINVAL;\ 7422 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 7423 return strlen(buf);\ 7424 else \ 7425 return -EINVAL;\ 7426 } 7427 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 7428 int \ 7429 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 7430 { \ 7431 if (val >= _minval && val <= _maxval) {\ 7432 phba->attr_##_name = val;\ 7433 return 0;\ 7434 } \ 7435 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7436 "BA_%d beiscsi_"#_name" attribute " \ 7437 "cannot be updated to 0x%x, "\ 7438 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7439 phba->attr_##_name = _defval;\ 7440 return -EINVAL;\ 7441 } 7442 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 7443 static uint beiscsi_##_name = _defval;\ 7444 module_param(beiscsi_##_name, uint, S_IRUGO);\ 7445 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 7446 beiscsi_disp_param(_name)\ 7447 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 7448 beiscsi_store_param(_name)\ 7449 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 7450 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 7451 beiscsi_##_name##_disp, beiscsi_##_name##_store) 7452 /* LDV_COMMENT_END_PREP */ 7453 /* LDV_COMMENT_FUNCTION_CALL Function from field "eh_abort_handler" from driver structure with callbacks "beiscsi_sht" */ 7454 ldv_handler_precall(); 7455 beiscsi_eh_abort( var_group2); 7456 7457 7458 7459 7460 } 7461 7462 break; 7463 case 2: { 7464 7465 /** STRUCT: struct type: scsi_host_template, struct name: beiscsi_sht **/ 7466 7467 7468 /* content: static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)*/ 7469 /* LDV_COMMENT_BEGIN_PREP */ 7470 #define beiscsi_disp_param(_name)\ 7471 ssize_t \ 7472 beiscsi_##_name##_disp(struct device *dev,\ 7473 struct device_attribute *attrib, char *buf) \ 7474 { \ 7475 struct Scsi_Host *shost = class_to_shost(dev);\ 7476 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 7477 uint32_t param_val = 0; \ 7478 param_val = phba->attr_##_name;\ 7479 return snprintf(buf, PAGE_SIZE, "%d\n",\ 7480 phba->attr_##_name);\ 7481 } 7482 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 7483 int \ 7484 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 7485 {\ 7486 if (val >= _minval && val <= _maxval) {\ 7487 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7488 "BA_%d : beiscsi_"#_name" updated "\ 7489 "from 0x%x ==> 0x%x\n",\ 7490 phba->attr_##_name, val); \ 7491 phba->attr_##_name = val;\ 7492 return 0;\ 7493 } \ 7494 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 7495 "BA_%d beiscsi_"#_name" attribute "\ 7496 "cannot be updated to 0x%x, "\ 7497 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7498 return -EINVAL;\ 7499 } 7500 #define beiscsi_store_param(_name) \ 7501 ssize_t \ 7502 beiscsi_##_name##_store(struct device *dev,\ 7503 struct device_attribute *attr, const char *buf,\ 7504 size_t count) \ 7505 { \ 7506 struct Scsi_Host *shost = class_to_shost(dev);\ 7507 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 7508 uint32_t param_val = 0;\ 7509 if (!isdigit(buf[0]))\ 7510 return -EINVAL;\ 7511 if (sscanf(buf, "%i", &param_val) != 1)\ 7512 return -EINVAL;\ 7513 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 7514 return strlen(buf);\ 7515 else \ 7516 return -EINVAL;\ 7517 } 7518 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 7519 int \ 7520 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 7521 { \ 7522 if (val >= _minval && val <= _maxval) {\ 7523 phba->attr_##_name = val;\ 7524 return 0;\ 7525 } \ 7526 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7527 "BA_%d beiscsi_"#_name" attribute " \ 7528 "cannot be updated to 0x%x, "\ 7529 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7530 phba->attr_##_name = _defval;\ 7531 return -EINVAL;\ 7532 } 7533 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 7534 static uint beiscsi_##_name = _defval;\ 7535 module_param(beiscsi_##_name, uint, S_IRUGO);\ 7536 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 7537 beiscsi_disp_param(_name)\ 7538 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 7539 beiscsi_store_param(_name)\ 7540 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 7541 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 7542 beiscsi_##_name##_disp, beiscsi_##_name##_store) 7543 /* LDV_COMMENT_END_PREP */ 7544 /* LDV_COMMENT_FUNCTION_CALL Function from field "eh_device_reset_handler" from driver structure with callbacks "beiscsi_sht" */ 7545 ldv_handler_precall(); 7546 beiscsi_eh_device_reset( var_group2); 7547 7548 7549 7550 7551 } 7552 7553 break; 7554 case 3: { 7555 7556 /** STRUCT: struct type: pci_error_handlers, struct name: beiscsi_eeh_handlers **/ 7557 7558 7559 /* content: static pci_ers_result_t beiscsi_eeh_err_detected(struct pci_dev *pdev, pci_channel_state_t state)*/ 7560 /* LDV_COMMENT_BEGIN_PREP */ 7561 #define beiscsi_disp_param(_name)\ 7562 ssize_t \ 7563 beiscsi_##_name##_disp(struct device *dev,\ 7564 struct device_attribute *attrib, char *buf) \ 7565 { \ 7566 struct Scsi_Host *shost = class_to_shost(dev);\ 7567 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 7568 uint32_t param_val = 0; \ 7569 param_val = phba->attr_##_name;\ 7570 return snprintf(buf, PAGE_SIZE, "%d\n",\ 7571 phba->attr_##_name);\ 7572 } 7573 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 7574 int \ 7575 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 7576 {\ 7577 if (val >= _minval && val <= _maxval) {\ 7578 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7579 "BA_%d : beiscsi_"#_name" updated "\ 7580 "from 0x%x ==> 0x%x\n",\ 7581 phba->attr_##_name, val); \ 7582 phba->attr_##_name = val;\ 7583 return 0;\ 7584 } \ 7585 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 7586 "BA_%d beiscsi_"#_name" attribute "\ 7587 "cannot be updated to 0x%x, "\ 7588 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7589 return -EINVAL;\ 7590 } 7591 #define beiscsi_store_param(_name) \ 7592 ssize_t \ 7593 beiscsi_##_name##_store(struct device *dev,\ 7594 struct device_attribute *attr, const char *buf,\ 7595 size_t count) \ 7596 { \ 7597 struct Scsi_Host *shost = class_to_shost(dev);\ 7598 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 7599 uint32_t param_val = 0;\ 7600 if (!isdigit(buf[0]))\ 7601 return -EINVAL;\ 7602 if (sscanf(buf, "%i", &param_val) != 1)\ 7603 return -EINVAL;\ 7604 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 7605 return strlen(buf);\ 7606 else \ 7607 return -EINVAL;\ 7608 } 7609 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 7610 int \ 7611 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 7612 { \ 7613 if (val >= _minval && val <= _maxval) {\ 7614 phba->attr_##_name = val;\ 7615 return 0;\ 7616 } \ 7617 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7618 "BA_%d beiscsi_"#_name" attribute " \ 7619 "cannot be updated to 0x%x, "\ 7620 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7621 phba->attr_##_name = _defval;\ 7622 return -EINVAL;\ 7623 } 7624 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 7625 static uint beiscsi_##_name = _defval;\ 7626 module_param(beiscsi_##_name, uint, S_IRUGO);\ 7627 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 7628 beiscsi_disp_param(_name)\ 7629 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 7630 beiscsi_store_param(_name)\ 7631 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 7632 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 7633 beiscsi_##_name##_disp, beiscsi_##_name##_store) 7634 /* LDV_COMMENT_END_PREP */ 7635 /* LDV_COMMENT_FUNCTION_CALL Function from field "error_detected" from driver structure with callbacks "beiscsi_eeh_handlers" */ 7636 ldv_handler_precall(); 7637 beiscsi_eeh_err_detected( var_group3, var_beiscsi_eeh_err_detected_107_p1); 7638 7639 7640 7641 7642 } 7643 7644 break; 7645 case 4: { 7646 7647 /** STRUCT: struct type: pci_error_handlers, struct name: beiscsi_eeh_handlers **/ 7648 7649 7650 /* content: static pci_ers_result_t beiscsi_eeh_reset(struct pci_dev *pdev)*/ 7651 /* LDV_COMMENT_BEGIN_PREP */ 7652 #define beiscsi_disp_param(_name)\ 7653 ssize_t \ 7654 beiscsi_##_name##_disp(struct device *dev,\ 7655 struct device_attribute *attrib, char *buf) \ 7656 { \ 7657 struct Scsi_Host *shost = class_to_shost(dev);\ 7658 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 7659 uint32_t param_val = 0; \ 7660 param_val = phba->attr_##_name;\ 7661 return snprintf(buf, PAGE_SIZE, "%d\n",\ 7662 phba->attr_##_name);\ 7663 } 7664 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 7665 int \ 7666 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 7667 {\ 7668 if (val >= _minval && val <= _maxval) {\ 7669 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7670 "BA_%d : beiscsi_"#_name" updated "\ 7671 "from 0x%x ==> 0x%x\n",\ 7672 phba->attr_##_name, val); \ 7673 phba->attr_##_name = val;\ 7674 return 0;\ 7675 } \ 7676 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 7677 "BA_%d beiscsi_"#_name" attribute "\ 7678 "cannot be updated to 0x%x, "\ 7679 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7680 return -EINVAL;\ 7681 } 7682 #define beiscsi_store_param(_name) \ 7683 ssize_t \ 7684 beiscsi_##_name##_store(struct device *dev,\ 7685 struct device_attribute *attr, const char *buf,\ 7686 size_t count) \ 7687 { \ 7688 struct Scsi_Host *shost = class_to_shost(dev);\ 7689 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 7690 uint32_t param_val = 0;\ 7691 if (!isdigit(buf[0]))\ 7692 return -EINVAL;\ 7693 if (sscanf(buf, "%i", &param_val) != 1)\ 7694 return -EINVAL;\ 7695 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 7696 return strlen(buf);\ 7697 else \ 7698 return -EINVAL;\ 7699 } 7700 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 7701 int \ 7702 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 7703 { \ 7704 if (val >= _minval && val <= _maxval) {\ 7705 phba->attr_##_name = val;\ 7706 return 0;\ 7707 } \ 7708 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7709 "BA_%d beiscsi_"#_name" attribute " \ 7710 "cannot be updated to 0x%x, "\ 7711 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7712 phba->attr_##_name = _defval;\ 7713 return -EINVAL;\ 7714 } 7715 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 7716 static uint beiscsi_##_name = _defval;\ 7717 module_param(beiscsi_##_name, uint, S_IRUGO);\ 7718 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 7719 beiscsi_disp_param(_name)\ 7720 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 7721 beiscsi_store_param(_name)\ 7722 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 7723 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 7724 beiscsi_##_name##_disp, beiscsi_##_name##_store) 7725 /* LDV_COMMENT_END_PREP */ 7726 /* LDV_COMMENT_FUNCTION_CALL Function from field "slot_reset" from driver structure with callbacks "beiscsi_eeh_handlers" */ 7727 ldv_handler_precall(); 7728 beiscsi_eeh_reset( var_group3); 7729 7730 7731 7732 7733 } 7734 7735 break; 7736 case 5: { 7737 7738 /** STRUCT: struct type: pci_error_handlers, struct name: beiscsi_eeh_handlers **/ 7739 7740 7741 /* content: static void beiscsi_eeh_resume(struct pci_dev *pdev)*/ 7742 /* LDV_COMMENT_BEGIN_PREP */ 7743 #define beiscsi_disp_param(_name)\ 7744 ssize_t \ 7745 beiscsi_##_name##_disp(struct device *dev,\ 7746 struct device_attribute *attrib, char *buf) \ 7747 { \ 7748 struct Scsi_Host *shost = class_to_shost(dev);\ 7749 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 7750 uint32_t param_val = 0; \ 7751 param_val = phba->attr_##_name;\ 7752 return snprintf(buf, PAGE_SIZE, "%d\n",\ 7753 phba->attr_##_name);\ 7754 } 7755 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 7756 int \ 7757 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 7758 {\ 7759 if (val >= _minval && val <= _maxval) {\ 7760 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7761 "BA_%d : beiscsi_"#_name" updated "\ 7762 "from 0x%x ==> 0x%x\n",\ 7763 phba->attr_##_name, val); \ 7764 phba->attr_##_name = val;\ 7765 return 0;\ 7766 } \ 7767 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 7768 "BA_%d beiscsi_"#_name" attribute "\ 7769 "cannot be updated to 0x%x, "\ 7770 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7771 return -EINVAL;\ 7772 } 7773 #define beiscsi_store_param(_name) \ 7774 ssize_t \ 7775 beiscsi_##_name##_store(struct device *dev,\ 7776 struct device_attribute *attr, const char *buf,\ 7777 size_t count) \ 7778 { \ 7779 struct Scsi_Host *shost = class_to_shost(dev);\ 7780 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 7781 uint32_t param_val = 0;\ 7782 if (!isdigit(buf[0]))\ 7783 return -EINVAL;\ 7784 if (sscanf(buf, "%i", &param_val) != 1)\ 7785 return -EINVAL;\ 7786 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 7787 return strlen(buf);\ 7788 else \ 7789 return -EINVAL;\ 7790 } 7791 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 7792 int \ 7793 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 7794 { \ 7795 if (val >= _minval && val <= _maxval) {\ 7796 phba->attr_##_name = val;\ 7797 return 0;\ 7798 } \ 7799 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7800 "BA_%d beiscsi_"#_name" attribute " \ 7801 "cannot be updated to 0x%x, "\ 7802 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7803 phba->attr_##_name = _defval;\ 7804 return -EINVAL;\ 7805 } 7806 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 7807 static uint beiscsi_##_name = _defval;\ 7808 module_param(beiscsi_##_name, uint, S_IRUGO);\ 7809 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 7810 beiscsi_disp_param(_name)\ 7811 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 7812 beiscsi_store_param(_name)\ 7813 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 7814 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 7815 beiscsi_##_name##_disp, beiscsi_##_name##_store) 7816 /* LDV_COMMENT_END_PREP */ 7817 /* LDV_COMMENT_FUNCTION_CALL Function from field "resume" from driver structure with callbacks "beiscsi_eeh_handlers" */ 7818 ldv_handler_precall(); 7819 beiscsi_eeh_resume( var_group3); 7820 7821 7822 7823 7824 } 7825 7826 break; 7827 case 6: { 7828 7829 /** STRUCT: struct type: iscsi_transport, struct name: beiscsi_iscsi_transport **/ 7830 7831 7832 /* content: static int beiscsi_task_xmit(struct iscsi_task *task)*/ 7833 /* LDV_COMMENT_BEGIN_PREP */ 7834 #define beiscsi_disp_param(_name)\ 7835 ssize_t \ 7836 beiscsi_##_name##_disp(struct device *dev,\ 7837 struct device_attribute *attrib, char *buf) \ 7838 { \ 7839 struct Scsi_Host *shost = class_to_shost(dev);\ 7840 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 7841 uint32_t param_val = 0; \ 7842 param_val = phba->attr_##_name;\ 7843 return snprintf(buf, PAGE_SIZE, "%d\n",\ 7844 phba->attr_##_name);\ 7845 } 7846 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 7847 int \ 7848 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 7849 {\ 7850 if (val >= _minval && val <= _maxval) {\ 7851 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7852 "BA_%d : beiscsi_"#_name" updated "\ 7853 "from 0x%x ==> 0x%x\n",\ 7854 phba->attr_##_name, val); \ 7855 phba->attr_##_name = val;\ 7856 return 0;\ 7857 } \ 7858 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 7859 "BA_%d beiscsi_"#_name" attribute "\ 7860 "cannot be updated to 0x%x, "\ 7861 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7862 return -EINVAL;\ 7863 } 7864 #define beiscsi_store_param(_name) \ 7865 ssize_t \ 7866 beiscsi_##_name##_store(struct device *dev,\ 7867 struct device_attribute *attr, const char *buf,\ 7868 size_t count) \ 7869 { \ 7870 struct Scsi_Host *shost = class_to_shost(dev);\ 7871 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 7872 uint32_t param_val = 0;\ 7873 if (!isdigit(buf[0]))\ 7874 return -EINVAL;\ 7875 if (sscanf(buf, "%i", &param_val) != 1)\ 7876 return -EINVAL;\ 7877 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 7878 return strlen(buf);\ 7879 else \ 7880 return -EINVAL;\ 7881 } 7882 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 7883 int \ 7884 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 7885 { \ 7886 if (val >= _minval && val <= _maxval) {\ 7887 phba->attr_##_name = val;\ 7888 return 0;\ 7889 } \ 7890 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7891 "BA_%d beiscsi_"#_name" attribute " \ 7892 "cannot be updated to 0x%x, "\ 7893 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7894 phba->attr_##_name = _defval;\ 7895 return -EINVAL;\ 7896 } 7897 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 7898 static uint beiscsi_##_name = _defval;\ 7899 module_param(beiscsi_##_name, uint, S_IRUGO);\ 7900 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 7901 beiscsi_disp_param(_name)\ 7902 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 7903 beiscsi_store_param(_name)\ 7904 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 7905 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 7906 beiscsi_##_name##_disp, beiscsi_##_name##_store) 7907 /* LDV_COMMENT_END_PREP */ 7908 /* LDV_COMMENT_FUNCTION_CALL Function from field "xmit_task" from driver structure with callbacks "beiscsi_iscsi_transport" */ 7909 ldv_handler_precall(); 7910 beiscsi_task_xmit( var_group4); 7911 7912 7913 7914 7915 } 7916 7917 break; 7918 case 7: { 7919 7920 /** STRUCT: struct type: iscsi_transport, struct name: beiscsi_iscsi_transport **/ 7921 7922 7923 /* content: static void beiscsi_cleanup_task(struct iscsi_task *task)*/ 7924 /* LDV_COMMENT_BEGIN_PREP */ 7925 #define beiscsi_disp_param(_name)\ 7926 ssize_t \ 7927 beiscsi_##_name##_disp(struct device *dev,\ 7928 struct device_attribute *attrib, char *buf) \ 7929 { \ 7930 struct Scsi_Host *shost = class_to_shost(dev);\ 7931 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 7932 uint32_t param_val = 0; \ 7933 param_val = phba->attr_##_name;\ 7934 return snprintf(buf, PAGE_SIZE, "%d\n",\ 7935 phba->attr_##_name);\ 7936 } 7937 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 7938 int \ 7939 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 7940 {\ 7941 if (val >= _minval && val <= _maxval) {\ 7942 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7943 "BA_%d : beiscsi_"#_name" updated "\ 7944 "from 0x%x ==> 0x%x\n",\ 7945 phba->attr_##_name, val); \ 7946 phba->attr_##_name = val;\ 7947 return 0;\ 7948 } \ 7949 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 7950 "BA_%d beiscsi_"#_name" attribute "\ 7951 "cannot be updated to 0x%x, "\ 7952 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7953 return -EINVAL;\ 7954 } 7955 #define beiscsi_store_param(_name) \ 7956 ssize_t \ 7957 beiscsi_##_name##_store(struct device *dev,\ 7958 struct device_attribute *attr, const char *buf,\ 7959 size_t count) \ 7960 { \ 7961 struct Scsi_Host *shost = class_to_shost(dev);\ 7962 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 7963 uint32_t param_val = 0;\ 7964 if (!isdigit(buf[0]))\ 7965 return -EINVAL;\ 7966 if (sscanf(buf, "%i", &param_val) != 1)\ 7967 return -EINVAL;\ 7968 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 7969 return strlen(buf);\ 7970 else \ 7971 return -EINVAL;\ 7972 } 7973 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 7974 int \ 7975 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 7976 { \ 7977 if (val >= _minval && val <= _maxval) {\ 7978 phba->attr_##_name = val;\ 7979 return 0;\ 7980 } \ 7981 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 7982 "BA_%d beiscsi_"#_name" attribute " \ 7983 "cannot be updated to 0x%x, "\ 7984 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 7985 phba->attr_##_name = _defval;\ 7986 return -EINVAL;\ 7987 } 7988 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 7989 static uint beiscsi_##_name = _defval;\ 7990 module_param(beiscsi_##_name, uint, S_IRUGO);\ 7991 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 7992 beiscsi_disp_param(_name)\ 7993 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 7994 beiscsi_store_param(_name)\ 7995 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 7996 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 7997 beiscsi_##_name##_disp, beiscsi_##_name##_store) 7998 /* LDV_COMMENT_END_PREP */ 7999 /* LDV_COMMENT_FUNCTION_CALL Function from field "cleanup_task" from driver structure with callbacks "beiscsi_iscsi_transport" */ 8000 ldv_handler_precall(); 8001 beiscsi_cleanup_task( var_group4); 8002 8003 8004 8005 8006 } 8007 8008 break; 8009 case 8: { 8010 8011 /** STRUCT: struct type: iscsi_transport, struct name: beiscsi_iscsi_transport **/ 8012 8013 8014 /* content: static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode)*/ 8015 /* LDV_COMMENT_BEGIN_PREP */ 8016 #define beiscsi_disp_param(_name)\ 8017 ssize_t \ 8018 beiscsi_##_name##_disp(struct device *dev,\ 8019 struct device_attribute *attrib, char *buf) \ 8020 { \ 8021 struct Scsi_Host *shost = class_to_shost(dev);\ 8022 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 8023 uint32_t param_val = 0; \ 8024 param_val = phba->attr_##_name;\ 8025 return snprintf(buf, PAGE_SIZE, "%d\n",\ 8026 phba->attr_##_name);\ 8027 } 8028 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 8029 int \ 8030 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 8031 {\ 8032 if (val >= _minval && val <= _maxval) {\ 8033 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8034 "BA_%d : beiscsi_"#_name" updated "\ 8035 "from 0x%x ==> 0x%x\n",\ 8036 phba->attr_##_name, val); \ 8037 phba->attr_##_name = val;\ 8038 return 0;\ 8039 } \ 8040 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 8041 "BA_%d beiscsi_"#_name" attribute "\ 8042 "cannot be updated to 0x%x, "\ 8043 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8044 return -EINVAL;\ 8045 } 8046 #define beiscsi_store_param(_name) \ 8047 ssize_t \ 8048 beiscsi_##_name##_store(struct device *dev,\ 8049 struct device_attribute *attr, const char *buf,\ 8050 size_t count) \ 8051 { \ 8052 struct Scsi_Host *shost = class_to_shost(dev);\ 8053 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 8054 uint32_t param_val = 0;\ 8055 if (!isdigit(buf[0]))\ 8056 return -EINVAL;\ 8057 if (sscanf(buf, "%i", &param_val) != 1)\ 8058 return -EINVAL;\ 8059 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 8060 return strlen(buf);\ 8061 else \ 8062 return -EINVAL;\ 8063 } 8064 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 8065 int \ 8066 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 8067 { \ 8068 if (val >= _minval && val <= _maxval) {\ 8069 phba->attr_##_name = val;\ 8070 return 0;\ 8071 } \ 8072 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8073 "BA_%d beiscsi_"#_name" attribute " \ 8074 "cannot be updated to 0x%x, "\ 8075 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8076 phba->attr_##_name = _defval;\ 8077 return -EINVAL;\ 8078 } 8079 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 8080 static uint beiscsi_##_name = _defval;\ 8081 module_param(beiscsi_##_name, uint, S_IRUGO);\ 8082 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 8083 beiscsi_disp_param(_name)\ 8084 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 8085 beiscsi_store_param(_name)\ 8086 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 8087 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 8088 beiscsi_##_name##_disp, beiscsi_##_name##_store) 8089 /* LDV_COMMENT_END_PREP */ 8090 /* LDV_COMMENT_FUNCTION_CALL Function from field "alloc_pdu" from driver structure with callbacks "beiscsi_iscsi_transport" */ 8091 ldv_handler_precall(); 8092 beiscsi_alloc_pdu( var_group4, var_beiscsi_alloc_pdu_95_p1); 8093 8094 8095 8096 8097 } 8098 8099 break; 8100 case 9: { 8101 8102 /** STRUCT: struct type: iscsi_transport, struct name: beiscsi_iscsi_transport **/ 8103 8104 8105 /* content: static void beiscsi_parse_pdu(struct iscsi_conn *conn, itt_t itt, int *index, int *age)*/ 8106 /* LDV_COMMENT_BEGIN_PREP */ 8107 #define beiscsi_disp_param(_name)\ 8108 ssize_t \ 8109 beiscsi_##_name##_disp(struct device *dev,\ 8110 struct device_attribute *attrib, char *buf) \ 8111 { \ 8112 struct Scsi_Host *shost = class_to_shost(dev);\ 8113 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 8114 uint32_t param_val = 0; \ 8115 param_val = phba->attr_##_name;\ 8116 return snprintf(buf, PAGE_SIZE, "%d\n",\ 8117 phba->attr_##_name);\ 8118 } 8119 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 8120 int \ 8121 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 8122 {\ 8123 if (val >= _minval && val <= _maxval) {\ 8124 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8125 "BA_%d : beiscsi_"#_name" updated "\ 8126 "from 0x%x ==> 0x%x\n",\ 8127 phba->attr_##_name, val); \ 8128 phba->attr_##_name = val;\ 8129 return 0;\ 8130 } \ 8131 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 8132 "BA_%d beiscsi_"#_name" attribute "\ 8133 "cannot be updated to 0x%x, "\ 8134 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8135 return -EINVAL;\ 8136 } 8137 #define beiscsi_store_param(_name) \ 8138 ssize_t \ 8139 beiscsi_##_name##_store(struct device *dev,\ 8140 struct device_attribute *attr, const char *buf,\ 8141 size_t count) \ 8142 { \ 8143 struct Scsi_Host *shost = class_to_shost(dev);\ 8144 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 8145 uint32_t param_val = 0;\ 8146 if (!isdigit(buf[0]))\ 8147 return -EINVAL;\ 8148 if (sscanf(buf, "%i", &param_val) != 1)\ 8149 return -EINVAL;\ 8150 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 8151 return strlen(buf);\ 8152 else \ 8153 return -EINVAL;\ 8154 } 8155 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 8156 int \ 8157 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 8158 { \ 8159 if (val >= _minval && val <= _maxval) {\ 8160 phba->attr_##_name = val;\ 8161 return 0;\ 8162 } \ 8163 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8164 "BA_%d beiscsi_"#_name" attribute " \ 8165 "cannot be updated to 0x%x, "\ 8166 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8167 phba->attr_##_name = _defval;\ 8168 return -EINVAL;\ 8169 } 8170 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 8171 static uint beiscsi_##_name = _defval;\ 8172 module_param(beiscsi_##_name, uint, S_IRUGO);\ 8173 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 8174 beiscsi_disp_param(_name)\ 8175 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 8176 beiscsi_store_param(_name)\ 8177 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 8178 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 8179 beiscsi_##_name##_disp, beiscsi_##_name##_store) 8180 /* LDV_COMMENT_END_PREP */ 8181 /* LDV_COMMENT_FUNCTION_CALL Function from field "parse_pdu_itt" from driver structure with callbacks "beiscsi_iscsi_transport" */ 8182 ldv_handler_precall(); 8183 beiscsi_parse_pdu( var_group5, var_beiscsi_parse_pdu_94_p1, var_beiscsi_parse_pdu_94_p2, var_beiscsi_parse_pdu_94_p3); 8184 8185 8186 8187 8188 } 8189 8190 break; 8191 case 10: { 8192 8193 /** STRUCT: struct type: iscsi_transport, struct name: beiscsi_iscsi_transport **/ 8194 8195 8196 /* content: static int beiscsi_bsg_request(struct bsg_job *job)*/ 8197 /* LDV_COMMENT_BEGIN_PREP */ 8198 #define beiscsi_disp_param(_name)\ 8199 ssize_t \ 8200 beiscsi_##_name##_disp(struct device *dev,\ 8201 struct device_attribute *attrib, char *buf) \ 8202 { \ 8203 struct Scsi_Host *shost = class_to_shost(dev);\ 8204 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 8205 uint32_t param_val = 0; \ 8206 param_val = phba->attr_##_name;\ 8207 return snprintf(buf, PAGE_SIZE, "%d\n",\ 8208 phba->attr_##_name);\ 8209 } 8210 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 8211 int \ 8212 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 8213 {\ 8214 if (val >= _minval && val <= _maxval) {\ 8215 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8216 "BA_%d : beiscsi_"#_name" updated "\ 8217 "from 0x%x ==> 0x%x\n",\ 8218 phba->attr_##_name, val); \ 8219 phba->attr_##_name = val;\ 8220 return 0;\ 8221 } \ 8222 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 8223 "BA_%d beiscsi_"#_name" attribute "\ 8224 "cannot be updated to 0x%x, "\ 8225 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8226 return -EINVAL;\ 8227 } 8228 #define beiscsi_store_param(_name) \ 8229 ssize_t \ 8230 beiscsi_##_name##_store(struct device *dev,\ 8231 struct device_attribute *attr, const char *buf,\ 8232 size_t count) \ 8233 { \ 8234 struct Scsi_Host *shost = class_to_shost(dev);\ 8235 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 8236 uint32_t param_val = 0;\ 8237 if (!isdigit(buf[0]))\ 8238 return -EINVAL;\ 8239 if (sscanf(buf, "%i", &param_val) != 1)\ 8240 return -EINVAL;\ 8241 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 8242 return strlen(buf);\ 8243 else \ 8244 return -EINVAL;\ 8245 } 8246 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 8247 int \ 8248 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 8249 { \ 8250 if (val >= _minval && val <= _maxval) {\ 8251 phba->attr_##_name = val;\ 8252 return 0;\ 8253 } \ 8254 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8255 "BA_%d beiscsi_"#_name" attribute " \ 8256 "cannot be updated to 0x%x, "\ 8257 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8258 phba->attr_##_name = _defval;\ 8259 return -EINVAL;\ 8260 } 8261 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 8262 static uint beiscsi_##_name = _defval;\ 8263 module_param(beiscsi_##_name, uint, S_IRUGO);\ 8264 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 8265 beiscsi_disp_param(_name)\ 8266 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 8267 beiscsi_store_param(_name)\ 8268 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 8269 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 8270 beiscsi_##_name##_disp, beiscsi_##_name##_store) 8271 /* LDV_COMMENT_END_PREP */ 8272 /* LDV_COMMENT_FUNCTION_CALL Function from field "bsg_request" from driver structure with callbacks "beiscsi_iscsi_transport" */ 8273 ldv_handler_precall(); 8274 beiscsi_bsg_request( var_group6); 8275 8276 8277 8278 8279 } 8280 8281 break; 8282 case 11: { 8283 8284 /** STRUCT: struct type: pci_driver, struct name: beiscsi_pci_driver **/ 8285 if(ldv_s_beiscsi_pci_driver_pci_driver==0) { 8286 8287 /* content: static int beiscsi_dev_probe(struct pci_dev *pcidev, const struct pci_device_id *id)*/ 8288 /* LDV_COMMENT_BEGIN_PREP */ 8289 #define beiscsi_disp_param(_name)\ 8290 ssize_t \ 8291 beiscsi_##_name##_disp(struct device *dev,\ 8292 struct device_attribute *attrib, char *buf) \ 8293 { \ 8294 struct Scsi_Host *shost = class_to_shost(dev);\ 8295 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 8296 uint32_t param_val = 0; \ 8297 param_val = phba->attr_##_name;\ 8298 return snprintf(buf, PAGE_SIZE, "%d\n",\ 8299 phba->attr_##_name);\ 8300 } 8301 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 8302 int \ 8303 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 8304 {\ 8305 if (val >= _minval && val <= _maxval) {\ 8306 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8307 "BA_%d : beiscsi_"#_name" updated "\ 8308 "from 0x%x ==> 0x%x\n",\ 8309 phba->attr_##_name, val); \ 8310 phba->attr_##_name = val;\ 8311 return 0;\ 8312 } \ 8313 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 8314 "BA_%d beiscsi_"#_name" attribute "\ 8315 "cannot be updated to 0x%x, "\ 8316 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8317 return -EINVAL;\ 8318 } 8319 #define beiscsi_store_param(_name) \ 8320 ssize_t \ 8321 beiscsi_##_name##_store(struct device *dev,\ 8322 struct device_attribute *attr, const char *buf,\ 8323 size_t count) \ 8324 { \ 8325 struct Scsi_Host *shost = class_to_shost(dev);\ 8326 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 8327 uint32_t param_val = 0;\ 8328 if (!isdigit(buf[0]))\ 8329 return -EINVAL;\ 8330 if (sscanf(buf, "%i", &param_val) != 1)\ 8331 return -EINVAL;\ 8332 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 8333 return strlen(buf);\ 8334 else \ 8335 return -EINVAL;\ 8336 } 8337 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 8338 int \ 8339 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 8340 { \ 8341 if (val >= _minval && val <= _maxval) {\ 8342 phba->attr_##_name = val;\ 8343 return 0;\ 8344 } \ 8345 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8346 "BA_%d beiscsi_"#_name" attribute " \ 8347 "cannot be updated to 0x%x, "\ 8348 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8349 phba->attr_##_name = _defval;\ 8350 return -EINVAL;\ 8351 } 8352 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 8353 static uint beiscsi_##_name = _defval;\ 8354 module_param(beiscsi_##_name, uint, S_IRUGO);\ 8355 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 8356 beiscsi_disp_param(_name)\ 8357 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 8358 beiscsi_store_param(_name)\ 8359 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 8360 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 8361 beiscsi_##_name##_disp, beiscsi_##_name##_store) 8362 /* LDV_COMMENT_END_PREP */ 8363 /* LDV_COMMENT_FUNCTION_CALL Function from field "probe" from driver structure with callbacks "beiscsi_pci_driver". Standart function test for correct return result. */ 8364 res_beiscsi_dev_probe_110 = beiscsi_dev_probe( var_group3, var_beiscsi_dev_probe_110_p1); 8365 ldv_check_return_value(res_beiscsi_dev_probe_110); 8366 ldv_check_return_value_probe(res_beiscsi_dev_probe_110); 8367 if(res_beiscsi_dev_probe_110) 8368 goto ldv_module_exit; 8369 ldv_s_beiscsi_pci_driver_pci_driver++; 8370 8371 } 8372 8373 } 8374 8375 break; 8376 case 12: { 8377 8378 /** STRUCT: struct type: pci_driver, struct name: beiscsi_pci_driver **/ 8379 if(ldv_s_beiscsi_pci_driver_pci_driver==1) { 8380 8381 /* content: static void beiscsi_remove(struct pci_dev *pcidev)*/ 8382 /* LDV_COMMENT_BEGIN_PREP */ 8383 #define beiscsi_disp_param(_name)\ 8384 ssize_t \ 8385 beiscsi_##_name##_disp(struct device *dev,\ 8386 struct device_attribute *attrib, char *buf) \ 8387 { \ 8388 struct Scsi_Host *shost = class_to_shost(dev);\ 8389 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 8390 uint32_t param_val = 0; \ 8391 param_val = phba->attr_##_name;\ 8392 return snprintf(buf, PAGE_SIZE, "%d\n",\ 8393 phba->attr_##_name);\ 8394 } 8395 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 8396 int \ 8397 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 8398 {\ 8399 if (val >= _minval && val <= _maxval) {\ 8400 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8401 "BA_%d : beiscsi_"#_name" updated "\ 8402 "from 0x%x ==> 0x%x\n",\ 8403 phba->attr_##_name, val); \ 8404 phba->attr_##_name = val;\ 8405 return 0;\ 8406 } \ 8407 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 8408 "BA_%d beiscsi_"#_name" attribute "\ 8409 "cannot be updated to 0x%x, "\ 8410 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8411 return -EINVAL;\ 8412 } 8413 #define beiscsi_store_param(_name) \ 8414 ssize_t \ 8415 beiscsi_##_name##_store(struct device *dev,\ 8416 struct device_attribute *attr, const char *buf,\ 8417 size_t count) \ 8418 { \ 8419 struct Scsi_Host *shost = class_to_shost(dev);\ 8420 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 8421 uint32_t param_val = 0;\ 8422 if (!isdigit(buf[0]))\ 8423 return -EINVAL;\ 8424 if (sscanf(buf, "%i", &param_val) != 1)\ 8425 return -EINVAL;\ 8426 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 8427 return strlen(buf);\ 8428 else \ 8429 return -EINVAL;\ 8430 } 8431 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 8432 int \ 8433 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 8434 { \ 8435 if (val >= _minval && val <= _maxval) {\ 8436 phba->attr_##_name = val;\ 8437 return 0;\ 8438 } \ 8439 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8440 "BA_%d beiscsi_"#_name" attribute " \ 8441 "cannot be updated to 0x%x, "\ 8442 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8443 phba->attr_##_name = _defval;\ 8444 return -EINVAL;\ 8445 } 8446 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 8447 static uint beiscsi_##_name = _defval;\ 8448 module_param(beiscsi_##_name, uint, S_IRUGO);\ 8449 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 8450 beiscsi_disp_param(_name)\ 8451 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 8452 beiscsi_store_param(_name)\ 8453 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 8454 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 8455 beiscsi_##_name##_disp, beiscsi_##_name##_store) 8456 /* LDV_COMMENT_END_PREP */ 8457 /* LDV_COMMENT_FUNCTION_CALL Function from field "remove" from driver structure with callbacks "beiscsi_pci_driver" */ 8458 ldv_handler_precall(); 8459 beiscsi_remove( var_group3); 8460 ldv_s_beiscsi_pci_driver_pci_driver=0; 8461 8462 } 8463 8464 } 8465 8466 break; 8467 case 13: { 8468 8469 /** STRUCT: struct type: pci_driver, struct name: beiscsi_pci_driver **/ 8470 8471 8472 /* content: static void beiscsi_shutdown(struct pci_dev *pcidev)*/ 8473 /* LDV_COMMENT_BEGIN_PREP */ 8474 #define beiscsi_disp_param(_name)\ 8475 ssize_t \ 8476 beiscsi_##_name##_disp(struct device *dev,\ 8477 struct device_attribute *attrib, char *buf) \ 8478 { \ 8479 struct Scsi_Host *shost = class_to_shost(dev);\ 8480 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 8481 uint32_t param_val = 0; \ 8482 param_val = phba->attr_##_name;\ 8483 return snprintf(buf, PAGE_SIZE, "%d\n",\ 8484 phba->attr_##_name);\ 8485 } 8486 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 8487 int \ 8488 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 8489 {\ 8490 if (val >= _minval && val <= _maxval) {\ 8491 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8492 "BA_%d : beiscsi_"#_name" updated "\ 8493 "from 0x%x ==> 0x%x\n",\ 8494 phba->attr_##_name, val); \ 8495 phba->attr_##_name = val;\ 8496 return 0;\ 8497 } \ 8498 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 8499 "BA_%d beiscsi_"#_name" attribute "\ 8500 "cannot be updated to 0x%x, "\ 8501 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8502 return -EINVAL;\ 8503 } 8504 #define beiscsi_store_param(_name) \ 8505 ssize_t \ 8506 beiscsi_##_name##_store(struct device *dev,\ 8507 struct device_attribute *attr, const char *buf,\ 8508 size_t count) \ 8509 { \ 8510 struct Scsi_Host *shost = class_to_shost(dev);\ 8511 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 8512 uint32_t param_val = 0;\ 8513 if (!isdigit(buf[0]))\ 8514 return -EINVAL;\ 8515 if (sscanf(buf, "%i", &param_val) != 1)\ 8516 return -EINVAL;\ 8517 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 8518 return strlen(buf);\ 8519 else \ 8520 return -EINVAL;\ 8521 } 8522 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 8523 int \ 8524 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 8525 { \ 8526 if (val >= _minval && val <= _maxval) {\ 8527 phba->attr_##_name = val;\ 8528 return 0;\ 8529 } \ 8530 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8531 "BA_%d beiscsi_"#_name" attribute " \ 8532 "cannot be updated to 0x%x, "\ 8533 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8534 phba->attr_##_name = _defval;\ 8535 return -EINVAL;\ 8536 } 8537 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 8538 static uint beiscsi_##_name = _defval;\ 8539 module_param(beiscsi_##_name, uint, S_IRUGO);\ 8540 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 8541 beiscsi_disp_param(_name)\ 8542 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 8543 beiscsi_store_param(_name)\ 8544 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 8545 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 8546 beiscsi_##_name##_disp, beiscsi_##_name##_store) 8547 /* LDV_COMMENT_END_PREP */ 8548 /* LDV_COMMENT_FUNCTION_CALL Function from field "shutdown" from driver structure with callbacks "beiscsi_pci_driver" */ 8549 ldv_handler_precall(); 8550 beiscsi_shutdown( var_group3); 8551 8552 8553 8554 8555 } 8556 8557 break; 8558 case 14: { 8559 8560 /** CALLBACK SECTION request_irq **/ 8561 LDV_IN_INTERRUPT=2; 8562 8563 /* content: static irqreturn_t be_isr(int irq, void *dev_id)*/ 8564 /* LDV_COMMENT_BEGIN_PREP */ 8565 #define beiscsi_disp_param(_name)\ 8566 ssize_t \ 8567 beiscsi_##_name##_disp(struct device *dev,\ 8568 struct device_attribute *attrib, char *buf) \ 8569 { \ 8570 struct Scsi_Host *shost = class_to_shost(dev);\ 8571 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 8572 uint32_t param_val = 0; \ 8573 param_val = phba->attr_##_name;\ 8574 return snprintf(buf, PAGE_SIZE, "%d\n",\ 8575 phba->attr_##_name);\ 8576 } 8577 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 8578 int \ 8579 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 8580 {\ 8581 if (val >= _minval && val <= _maxval) {\ 8582 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8583 "BA_%d : beiscsi_"#_name" updated "\ 8584 "from 0x%x ==> 0x%x\n",\ 8585 phba->attr_##_name, val); \ 8586 phba->attr_##_name = val;\ 8587 return 0;\ 8588 } \ 8589 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 8590 "BA_%d beiscsi_"#_name" attribute "\ 8591 "cannot be updated to 0x%x, "\ 8592 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8593 return -EINVAL;\ 8594 } 8595 #define beiscsi_store_param(_name) \ 8596 ssize_t \ 8597 beiscsi_##_name##_store(struct device *dev,\ 8598 struct device_attribute *attr, const char *buf,\ 8599 size_t count) \ 8600 { \ 8601 struct Scsi_Host *shost = class_to_shost(dev);\ 8602 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 8603 uint32_t param_val = 0;\ 8604 if (!isdigit(buf[0]))\ 8605 return -EINVAL;\ 8606 if (sscanf(buf, "%i", &param_val) != 1)\ 8607 return -EINVAL;\ 8608 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 8609 return strlen(buf);\ 8610 else \ 8611 return -EINVAL;\ 8612 } 8613 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 8614 int \ 8615 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 8616 { \ 8617 if (val >= _minval && val <= _maxval) {\ 8618 phba->attr_##_name = val;\ 8619 return 0;\ 8620 } \ 8621 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8622 "BA_%d beiscsi_"#_name" attribute " \ 8623 "cannot be updated to 0x%x, "\ 8624 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8625 phba->attr_##_name = _defval;\ 8626 return -EINVAL;\ 8627 } 8628 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 8629 static uint beiscsi_##_name = _defval;\ 8630 module_param(beiscsi_##_name, uint, S_IRUGO);\ 8631 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 8632 beiscsi_disp_param(_name)\ 8633 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 8634 beiscsi_store_param(_name)\ 8635 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 8636 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 8637 beiscsi_##_name##_disp, beiscsi_##_name##_store) 8638 /* LDV_COMMENT_END_PREP */ 8639 /* LDV_COMMENT_FUNCTION_CALL */ 8640 ldv_handler_precall(); 8641 be_isr( var_be_isr_18_p0, var_be_isr_18_p1); 8642 LDV_IN_INTERRUPT=1; 8643 8644 8645 8646 } 8647 8648 break; 8649 case 15: { 8650 8651 /** CALLBACK SECTION request_irq **/ 8652 LDV_IN_INTERRUPT=2; 8653 8654 /* content: static irqreturn_t be_isr_mcc(int irq, void *dev_id)*/ 8655 /* LDV_COMMENT_BEGIN_PREP */ 8656 #define beiscsi_disp_param(_name)\ 8657 ssize_t \ 8658 beiscsi_##_name##_disp(struct device *dev,\ 8659 struct device_attribute *attrib, char *buf) \ 8660 { \ 8661 struct Scsi_Host *shost = class_to_shost(dev);\ 8662 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 8663 uint32_t param_val = 0; \ 8664 param_val = phba->attr_##_name;\ 8665 return snprintf(buf, PAGE_SIZE, "%d\n",\ 8666 phba->attr_##_name);\ 8667 } 8668 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 8669 int \ 8670 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 8671 {\ 8672 if (val >= _minval && val <= _maxval) {\ 8673 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8674 "BA_%d : beiscsi_"#_name" updated "\ 8675 "from 0x%x ==> 0x%x\n",\ 8676 phba->attr_##_name, val); \ 8677 phba->attr_##_name = val;\ 8678 return 0;\ 8679 } \ 8680 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 8681 "BA_%d beiscsi_"#_name" attribute "\ 8682 "cannot be updated to 0x%x, "\ 8683 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8684 return -EINVAL;\ 8685 } 8686 #define beiscsi_store_param(_name) \ 8687 ssize_t \ 8688 beiscsi_##_name##_store(struct device *dev,\ 8689 struct device_attribute *attr, const char *buf,\ 8690 size_t count) \ 8691 { \ 8692 struct Scsi_Host *shost = class_to_shost(dev);\ 8693 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 8694 uint32_t param_val = 0;\ 8695 if (!isdigit(buf[0]))\ 8696 return -EINVAL;\ 8697 if (sscanf(buf, "%i", &param_val) != 1)\ 8698 return -EINVAL;\ 8699 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 8700 return strlen(buf);\ 8701 else \ 8702 return -EINVAL;\ 8703 } 8704 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 8705 int \ 8706 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 8707 { \ 8708 if (val >= _minval && val <= _maxval) {\ 8709 phba->attr_##_name = val;\ 8710 return 0;\ 8711 } \ 8712 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8713 "BA_%d beiscsi_"#_name" attribute " \ 8714 "cannot be updated to 0x%x, "\ 8715 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8716 phba->attr_##_name = _defval;\ 8717 return -EINVAL;\ 8718 } 8719 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 8720 static uint beiscsi_##_name = _defval;\ 8721 module_param(beiscsi_##_name, uint, S_IRUGO);\ 8722 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 8723 beiscsi_disp_param(_name)\ 8724 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 8725 beiscsi_store_param(_name)\ 8726 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 8727 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 8728 beiscsi_##_name##_disp, beiscsi_##_name##_store) 8729 /* LDV_COMMENT_END_PREP */ 8730 /* LDV_COMMENT_FUNCTION_CALL */ 8731 ldv_handler_precall(); 8732 be_isr_mcc( var_be_isr_mcc_16_p0, var_be_isr_mcc_16_p1); 8733 LDV_IN_INTERRUPT=1; 8734 8735 8736 8737 } 8738 8739 break; 8740 case 16: { 8741 8742 /** CALLBACK SECTION request_irq **/ 8743 LDV_IN_INTERRUPT=2; 8744 8745 /* content: static irqreturn_t be_isr_msix(int irq, void *dev_id)*/ 8746 /* LDV_COMMENT_BEGIN_PREP */ 8747 #define beiscsi_disp_param(_name)\ 8748 ssize_t \ 8749 beiscsi_##_name##_disp(struct device *dev,\ 8750 struct device_attribute *attrib, char *buf) \ 8751 { \ 8752 struct Scsi_Host *shost = class_to_shost(dev);\ 8753 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 8754 uint32_t param_val = 0; \ 8755 param_val = phba->attr_##_name;\ 8756 return snprintf(buf, PAGE_SIZE, "%d\n",\ 8757 phba->attr_##_name);\ 8758 } 8759 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 8760 int \ 8761 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 8762 {\ 8763 if (val >= _minval && val <= _maxval) {\ 8764 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8765 "BA_%d : beiscsi_"#_name" updated "\ 8766 "from 0x%x ==> 0x%x\n",\ 8767 phba->attr_##_name, val); \ 8768 phba->attr_##_name = val;\ 8769 return 0;\ 8770 } \ 8771 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 8772 "BA_%d beiscsi_"#_name" attribute "\ 8773 "cannot be updated to 0x%x, "\ 8774 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8775 return -EINVAL;\ 8776 } 8777 #define beiscsi_store_param(_name) \ 8778 ssize_t \ 8779 beiscsi_##_name##_store(struct device *dev,\ 8780 struct device_attribute *attr, const char *buf,\ 8781 size_t count) \ 8782 { \ 8783 struct Scsi_Host *shost = class_to_shost(dev);\ 8784 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 8785 uint32_t param_val = 0;\ 8786 if (!isdigit(buf[0]))\ 8787 return -EINVAL;\ 8788 if (sscanf(buf, "%i", &param_val) != 1)\ 8789 return -EINVAL;\ 8790 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 8791 return strlen(buf);\ 8792 else \ 8793 return -EINVAL;\ 8794 } 8795 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 8796 int \ 8797 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 8798 { \ 8799 if (val >= _minval && val <= _maxval) {\ 8800 phba->attr_##_name = val;\ 8801 return 0;\ 8802 } \ 8803 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8804 "BA_%d beiscsi_"#_name" attribute " \ 8805 "cannot be updated to 0x%x, "\ 8806 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8807 phba->attr_##_name = _defval;\ 8808 return -EINVAL;\ 8809 } 8810 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 8811 static uint beiscsi_##_name = _defval;\ 8812 module_param(beiscsi_##_name, uint, S_IRUGO);\ 8813 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 8814 beiscsi_disp_param(_name)\ 8815 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 8816 beiscsi_store_param(_name)\ 8817 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 8818 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 8819 beiscsi_##_name##_disp, beiscsi_##_name##_store) 8820 /* LDV_COMMENT_END_PREP */ 8821 /* LDV_COMMENT_FUNCTION_CALL */ 8822 ldv_handler_precall(); 8823 be_isr_msix( var_be_isr_msix_17_p0, var_be_isr_msix_17_p1); 8824 LDV_IN_INTERRUPT=1; 8825 8826 8827 8828 } 8829 8830 break; 8831 default: break; 8832 8833 } 8834 8835 } 8836 8837 ldv_module_exit: 8838 8839 /** INIT: init_type: ST_MODULE_EXIT **/ 8840 /* content: static void __exit beiscsi_module_exit(void)*/ 8841 /* LDV_COMMENT_BEGIN_PREP */ 8842 #define beiscsi_disp_param(_name)\ 8843 ssize_t \ 8844 beiscsi_##_name##_disp(struct device *dev,\ 8845 struct device_attribute *attrib, char *buf) \ 8846 { \ 8847 struct Scsi_Host *shost = class_to_shost(dev);\ 8848 struct beiscsi_hba *phba = iscsi_host_priv(shost); \ 8849 uint32_t param_val = 0; \ 8850 param_val = phba->attr_##_name;\ 8851 return snprintf(buf, PAGE_SIZE, "%d\n",\ 8852 phba->attr_##_name);\ 8853 } 8854 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\ 8855 int \ 8856 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\ 8857 {\ 8858 if (val >= _minval && val <= _maxval) {\ 8859 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8860 "BA_%d : beiscsi_"#_name" updated "\ 8861 "from 0x%x ==> 0x%x\n",\ 8862 phba->attr_##_name, val); \ 8863 phba->attr_##_name = val;\ 8864 return 0;\ 8865 } \ 8866 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \ 8867 "BA_%d beiscsi_"#_name" attribute "\ 8868 "cannot be updated to 0x%x, "\ 8869 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8870 return -EINVAL;\ 8871 } 8872 #define beiscsi_store_param(_name) \ 8873 ssize_t \ 8874 beiscsi_##_name##_store(struct device *dev,\ 8875 struct device_attribute *attr, const char *buf,\ 8876 size_t count) \ 8877 { \ 8878 struct Scsi_Host *shost = class_to_shost(dev);\ 8879 struct beiscsi_hba *phba = iscsi_host_priv(shost);\ 8880 uint32_t param_val = 0;\ 8881 if (!isdigit(buf[0]))\ 8882 return -EINVAL;\ 8883 if (sscanf(buf, "%i", &param_val) != 1)\ 8884 return -EINVAL;\ 8885 if (beiscsi_##_name##_change(phba, param_val) == 0) \ 8886 return strlen(buf);\ 8887 else \ 8888 return -EINVAL;\ 8889 } 8890 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \ 8891 int \ 8892 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \ 8893 { \ 8894 if (val >= _minval && val <= _maxval) {\ 8895 phba->attr_##_name = val;\ 8896 return 0;\ 8897 } \ 8898 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\ 8899 "BA_%d beiscsi_"#_name" attribute " \ 8900 "cannot be updated to 0x%x, "\ 8901 "range allowed is ["#_minval" - "#_maxval"]\n", val);\ 8902 phba->attr_##_name = _defval;\ 8903 return -EINVAL;\ 8904 } 8905 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \ 8906 static uint beiscsi_##_name = _defval;\ 8907 module_param(beiscsi_##_name, uint, S_IRUGO);\ 8908 MODULE_PARM_DESC(beiscsi_##_name, _descp);\ 8909 beiscsi_disp_param(_name)\ 8910 beiscsi_change_param(_name, _minval, _maxval, _defval)\ 8911 beiscsi_store_param(_name)\ 8912 beiscsi_init_param(_name, _minval, _maxval, _defval)\ 8913 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\ 8914 beiscsi_##_name##_disp, beiscsi_##_name##_store) 8915 /* LDV_COMMENT_END_PREP */ 8916 /* LDV_COMMENT_FUNCTION_CALL Kernel calls driver release function before driver will be uploaded from kernel. This function declared as "MODULE_EXIT(function name)". */ 8917 ldv_handler_precall(); 8918 beiscsi_module_exit(); 8919 8920 /* LDV_COMMENT_FUNCTION_CALL Checks that all resources and locks are correctly released before the driver will be unloaded. */ 8921 ldv_final: ldv_check_final_state(); 8922 8923 /* LDV_COMMENT_END_FUNCTION_CALL_SECTION */ 8924 return; 8925 8926 } 8927 #endif 8928 8929 /* LDV_COMMENT_END_MAIN */

Here is an explanation of a rule violation arisen while checking your driver against a corresponding kernel.

Note that it may be false positive, i.e. there isn't a real error indeed. Please analyze a given error trace and related source code to understand whether there is an error in your driver.

Error trace column contains a path on which the given rule is violated. You can expand/collapse some entity classes by clicking on corresponding checkboxes in a main menu or in an advanced Others menu. Also you can expand/collapse each particular entity by clicking on +/-. In hovering on some entities you can see some tips. Also the error trace is bound with related source code. Line numbers may be shown as links on the left. You can click on them to open corresponding lines in source code.

Source code column contains a content of files related with the error trace. There is source code of your driver (note that there are some LDV modifications at the end), kernel headers and rule model. Tabs show a currently opened file and other available files. In hovering on them you can see full file names. On clicking a corresponding file content will be shown.

Ядро Модуль Правило Верификатор Вердикт Статус Время создания Описание проблемы
linux-3.14.1.tar.xz drivers/scsi/be2iscsi/be2iscsi.ko 331_1a CPAchecker Bug Fixed 2016-01-16 00:47:35 L0219

Комментарий

Reported: 16 Jan 2016

[В начало]