Error Trace
[Home]
Bug # 105
Show/hide error trace Error trace
{ 19 typedef signed char __s8; 20 typedef unsigned char __u8; 22 typedef short __s16; 23 typedef unsigned short __u16; 25 typedef int __s32; 26 typedef unsigned int __u32; 30 typedef unsigned long long __u64; 15 typedef signed char s8; 16 typedef unsigned char u8; 18 typedef short s16; 19 typedef unsigned short u16; 21 typedef int s32; 22 typedef unsigned int u32; 24 typedef long long s64; 25 typedef unsigned long long u64; 14 typedef long __kernel_long_t; 15 typedef unsigned long __kernel_ulong_t; 27 typedef int __kernel_pid_t; 48 typedef unsigned int __kernel_uid32_t; 49 typedef unsigned int __kernel_gid32_t; 71 typedef __kernel_ulong_t __kernel_size_t; 72 typedef __kernel_long_t __kernel_ssize_t; 87 typedef long long __kernel_loff_t; 88 typedef __kernel_long_t __kernel_time_t; 89 typedef __kernel_long_t __kernel_clock_t; 90 typedef int __kernel_timer_t; 91 typedef int __kernel_clockid_t; 33 typedef __u16 __be16; 35 typedef __u32 __be32; 40 typedef __u32 __wsum; 12 typedef __u32 __kernel_dev_t; 15 typedef __kernel_dev_t dev_t; 18 typedef unsigned short umode_t; 21 typedef __kernel_pid_t pid_t; 26 typedef __kernel_clockid_t clockid_t; 29 typedef _Bool bool; 31 typedef __kernel_uid32_t uid_t; 32 typedef __kernel_gid32_t gid_t; 45 typedef __kernel_loff_t loff_t; 54 typedef __kernel_size_t size_t; 59 typedef __kernel_ssize_t ssize_t; 69 typedef __kernel_time_t time_t; 91 typedef unsigned int uint; 102 typedef __s32 int32_t; 106 typedef __u8 uint8_t; 107 typedef __u16 uint16_t; 108 typedef __u32 uint32_t; 111 typedef __u64 uint64_t; 133 typedef unsigned long sector_t; 134 typedef unsigned long blkcnt_t; 146 typedef u64 dma_addr_t; 157 typedef unsigned int gfp_t; 158 typedef unsigned int fmode_t; 159 typedef unsigned int oom_flags_t; 162 typedef u64 phys_addr_t; 167 typedef phys_addr_t resource_size_t; 177 struct __anonstruct_atomic_t_6 { int counter; } ; 177 typedef struct __anonstruct_atomic_t_6 atomic_t; 182 struct __anonstruct_atomic64_t_7 { long counter; } ; 182 typedef struct __anonstruct_atomic64_t_7 atomic64_t; 183 struct list_head { struct list_head *next; struct list_head *prev; } ; 188 struct hlist_node ; 188 struct hlist_head { struct hlist_node *first; } ; 192 struct hlist_node { struct hlist_node *next; struct hlist_node **pprev; } ; 203 struct callback_head { struct callback_head *next; void (*func)(struct callback_head *); } ; 213 enum dma_data_direction { DMA_BIDIRECTIONAL = 0, DMA_TO_DEVICE = 1, DMA_FROM_DEVICE = 2, DMA_NONE = 3 } ; 5 struct device ; 5 struct page ; 7 struct dma_attrs ; 686 struct kernel_symbol { unsigned long value; const char *name; } ; 33 struct module ; 65 struct pt_regs { unsigned long r15; unsigned long r14; unsigned long r13; unsigned long r12; unsigned long bp; unsigned long bx; unsigned long r11; unsigned long r10; unsigned long r9; unsigned long r8; unsigned long ax; unsigned long cx; unsigned long dx; unsigned long si; unsigned long di; unsigned long orig_ax; unsigned long ip; unsigned long cs; unsigned long flags; unsigned long sp; unsigned long ss; } ; 59 struct __anonstruct____missing_field_name_9 { unsigned int a; unsigned int b; } ; 59 struct __anonstruct____missing_field_name_10 { u16 limit0; u16 base0; unsigned char base1; unsigned char type; unsigned char s; unsigned char dpl; unsigned char p; unsigned char limit; unsigned char avl; unsigned char l; unsigned char d; unsigned char g; unsigned char base2; } ; 59 union __anonunion____missing_field_name_8 { struct __anonstruct____missing_field_name_9 __annonCompField4; struct __anonstruct____missing_field_name_10 __annonCompField5; } ; 59 struct desc_struct { union __anonunion____missing_field_name_8 __annonCompField6; } ; 15 typedef unsigned long pgdval_t; 16 typedef unsigned long pgprotval_t; 20 struct pgprot { pgprotval_t pgprot; } ; 243 typedef struct pgprot pgprot_t; 245 struct __anonstruct_pgd_t_12 { pgdval_t pgd; } ; 245 typedef struct __anonstruct_pgd_t_12 pgd_t; 333 typedef struct page *pgtable_t; 341 struct file ; 354 struct seq_file ; 389 struct thread_struct ; 391 struct mm_struct ; 392 struct task_struct ; 393 struct cpumask ; 394 struct paravirt_callee_save { void *func; } ; 196 struct pv_irq_ops { struct paravirt_callee_save save_fl; struct paravirt_callee_save restore_fl; struct paravirt_callee_save irq_disable; struct paravirt_callee_save irq_enable; void (*safe_halt)(); void (*halt)(); void (*adjust_exception_frame)(); } ; 327 struct arch_spinlock ; 18 typedef u16 __ticket_t; 19 typedef u32 __ticketpair_t; 20 struct __raw_tickets { __ticket_t head; __ticket_t tail; } ; 32 union __anonunion____missing_field_name_15 { __ticketpair_t head_tail; struct __raw_tickets tickets; } ; 32 struct arch_spinlock { union __anonunion____missing_field_name_15 __annonCompField7; } ; 33 typedef struct arch_spinlock arch_spinlock_t; 33 struct __anonstruct____missing_field_name_17 { u32 read; s32 write; } ; 33 union __anonunion_arch_rwlock_t_16 { s64 lock; struct __anonstruct____missing_field_name_17 __annonCompField8; } ; 33 typedef union __anonunion_arch_rwlock_t_16 arch_rwlock_t; 142 typedef void (*ctor_fn_t)(); 54 struct net_device ; 376 struct file_operations ; 388 struct completion ; 416 struct pid ; 527 struct bug_entry { int bug_addr_disp; int file_disp; unsigned short line; unsigned short flags; } ; 102 struct timespec ; 127 struct kernel_vm86_regs { struct pt_regs pt; unsigned short es; unsigned short __esh; unsigned short ds; unsigned short __dsh; unsigned short fs; unsigned short __fsh; unsigned short gs; unsigned short __gsh; } ; 79 union __anonunion____missing_field_name_22 { struct pt_regs *regs; struct kernel_vm86_regs *vm86; } ; 79 struct math_emu_info { long ___orig_eip; union __anonunion____missing_field_name_22 __annonCompField10; } ; 306 struct cpumask { unsigned long bits[128U]; } ; 14 typedef struct cpumask cpumask_t; 663 typedef struct cpumask *cpumask_var_t; 195 struct static_key ; 162 struct seq_operations ; 294 struct i387_fsave_struct { u32 cwd; u32 swd; u32 twd; u32 fip; u32 fcs; u32 foo; u32 fos; u32 st_space[20U]; u32 status; } ; 312 struct __anonstruct____missing_field_name_27 { u64 rip; u64 rdp; } ; 312 struct __anonstruct____missing_field_name_28 { u32 fip; u32 fcs; u32 foo; u32 fos; } ; 312 union __anonunion____missing_field_name_26 { struct __anonstruct____missing_field_name_27 __annonCompField14; struct __anonstruct____missing_field_name_28 __annonCompField15; } ; 312 union __anonunion____missing_field_name_29 { u32 padding1[12U]; u32 sw_reserved[12U]; } ; 312 struct i387_fxsave_struct { u16 cwd; u16 swd; u16 twd; u16 fop; union __anonunion____missing_field_name_26 __annonCompField16; u32 mxcsr; u32 mxcsr_mask; u32 st_space[32U]; u32 xmm_space[64U]; u32 padding[12U]; union __anonunion____missing_field_name_29 __annonCompField17; } ; 346 struct i387_soft_struct { u32 cwd; u32 swd; u32 twd; u32 fip; u32 fcs; u32 foo; u32 fos; u32 st_space[20U]; u8 ftop; u8 changed; u8 lookahead; u8 no_update; u8 rm; u8 alimit; struct math_emu_info *info; u32 entry_eip; } ; 367 struct ymmh_struct { u32 ymmh_space[64U]; } ; 372 struct lwp_struct { u8 reserved[128U]; } ; 377 struct bndregs_struct { u64 bndregs[8U]; } ; 381 struct bndcsr_struct { u64 cfg_reg_u; u64 status_reg; } ; 386 struct xsave_hdr_struct { u64 xstate_bv; u64 reserved1[2U]; u64 reserved2[5U]; } ; 392 struct xsave_struct { struct i387_fxsave_struct i387; struct xsave_hdr_struct xsave_hdr; struct ymmh_struct ymmh; struct lwp_struct lwp; struct bndregs_struct bndregs; struct bndcsr_struct bndcsr; } ; 401 union thread_xstate { struct i387_fsave_struct fsave; struct i387_fxsave_struct fxsave; struct i387_soft_struct soft; struct xsave_struct xsave; } ; 409 struct fpu { unsigned int last_cpu; unsigned int has_fpu; union thread_xstate *state; } ; 456 struct kmem_cache ; 457 struct perf_event ; 458 struct thread_struct { struct desc_struct tls_array[3U]; unsigned long sp0; unsigned long sp; unsigned long usersp; unsigned short es; unsigned short ds; unsigned short fsindex; unsigned short gsindex; unsigned long fs; unsigned long gs; struct perf_event *ptrace_bps[4U]; unsigned long debugreg6; unsigned long ptrace_dr7; unsigned long cr2; unsigned long trap_nr; unsigned long error_code; struct fpu fpu; unsigned long *io_bitmap_ptr; unsigned long iopl; unsigned int io_bitmap_max; unsigned char fpu_counter; } ; 23 typedef atomic64_t atomic_long_t; 152 struct lockdep_map ; 55 struct stack_trace { unsigned int nr_entries; unsigned int max_entries; unsigned long *entries; int skip; } ; 26 struct lockdep_subclass_key { char __one_byte; } ; 53 struct lock_class_key { struct lockdep_subclass_key subkeys[8U]; } ; 59 struct lock_class { struct list_head hash_entry; struct list_head lock_entry; struct lockdep_subclass_key *key; unsigned int subclass; unsigned int dep_gen_id; unsigned long usage_mask; struct stack_trace usage_traces[13U]; struct list_head locks_after; struct list_head locks_before; unsigned int version; unsigned long ops; const char *name; int name_version; unsigned long contention_point[4U]; unsigned long contending_point[4U]; } ; 144 struct lockdep_map { struct lock_class_key *key; struct lock_class *class_cache[2U]; const char *name; int cpu; unsigned long ip; } ; 205 struct held_lock { u64 prev_chain_key; unsigned long acquire_ip; struct lockdep_map *instance; struct lockdep_map *nest_lock; u64 waittime_stamp; u64 holdtime_stamp; unsigned short class_idx; unsigned char irq_context; unsigned char trylock; unsigned char read; unsigned char check; unsigned char hardirqs_off; unsigned short references; } ; 537 struct raw_spinlock { arch_spinlock_t raw_lock; unsigned int magic; unsigned int owner_cpu; void *owner; struct lockdep_map dep_map; } ; 32 typedef struct raw_spinlock raw_spinlock_t; 33 struct __anonstruct____missing_field_name_33 { u8 __padding[24U]; struct lockdep_map dep_map; } ; 33 union __anonunion____missing_field_name_32 { struct raw_spinlock rlock; struct __anonstruct____missing_field_name_33 __annonCompField19; } ; 33 struct spinlock { union __anonunion____missing_field_name_32 __annonCompField20; } ; 76 typedef struct spinlock spinlock_t; 23 struct __anonstruct_rwlock_t_34 { arch_rwlock_t raw_lock; unsigned int magic; unsigned int owner_cpu; void *owner; struct lockdep_map dep_map; } ; 23 typedef struct __anonstruct_rwlock_t_34 rwlock_t; 59 struct static_key { atomic_t enabled; } ; 34 struct __wait_queue_head { spinlock_t lock; struct list_head task_list; } ; 39 typedef struct __wait_queue_head wait_queue_head_t; 919 struct mutex { atomic_t count; spinlock_t wait_lock; struct list_head wait_list; struct task_struct *owner; const char *name; void *magic; struct lockdep_map dep_map; } ; 67 struct mutex_waiter { struct list_head list; struct task_struct *task; void *magic; } ; 177 struct seqcount { unsigned int sequence; struct lockdep_map dep_map; } ; 51 typedef struct seqcount seqcount_t; 259 struct __anonstruct_seqlock_t_35 { struct seqcount seqcount; spinlock_t lock; } ; 259 typedef struct __anonstruct_seqlock_t_35 seqlock_t; 433 struct timespec { __kernel_time_t tv_sec; long tv_nsec; } ; 323 union ktime { s64 tv64; } ; 59 typedef union ktime ktime_t; 105 struct tvec_base ; 106 struct timer_list { struct list_head entry; unsigned long expires; struct tvec_base *base; void (*function)(unsigned long); unsigned long data; int slack; int start_pid; void *start_site; char start_comm[16U]; struct lockdep_map lockdep_map; } ; 254 struct hrtimer ; 255 enum hrtimer_restart ; 266 struct workqueue_struct ; 267 struct work_struct ; 54 struct work_struct { atomic_long_t data; struct list_head entry; void (*func)(struct work_struct *); struct lockdep_map lockdep_map; } ; 107 struct delayed_work { struct work_struct work; struct timer_list timer; struct workqueue_struct *wq; int cpu; } ; 141 struct execute_work { struct work_struct work; } ; 98 struct __anonstruct_nodemask_t_36 { unsigned long bits[16U]; } ; 98 typedef struct __anonstruct_nodemask_t_36 nodemask_t; 799 struct rw_semaphore ; 800 struct rw_semaphore { long count; raw_spinlock_t wait_lock; struct list_head wait_list; struct lockdep_map dep_map; } ; 155 struct completion { unsigned int done; wait_queue_head_t wait; } ; 223 struct notifier_block ; 51 struct notifier_block { int (*notifier_call)(struct notifier_block *, unsigned long, void *); struct notifier_block *next; int priority; } ; 63 struct blocking_notifier_head { struct rw_semaphore rwsem; struct notifier_block *head; } ; 891 struct ctl_table ; 72 struct resource { resource_size_t start; resource_size_t end; const char *name; unsigned long flags; struct resource *parent; struct resource *sibling; struct resource *child; } ; 172 struct pci_dev ; 58 struct pm_message { int event; } ; 64 typedef struct pm_message pm_message_t; 65 struct dev_pm_ops { int (*prepare)(struct device *); void (*complete)(struct device *); int (*suspend)(struct device *); int (*resume)(struct device *); int (*freeze)(struct device *); int (*thaw)(struct device *); int (*poweroff)(struct device *); int (*restore)(struct device *); int (*suspend_late)(struct device *); int (*resume_early)(struct device *); int (*freeze_late)(struct device *); int (*thaw_early)(struct device *); int (*poweroff_late)(struct device *); int (*restore_early)(struct device *); int (*suspend_noirq)(struct device *); int (*resume_noirq)(struct device *); int (*freeze_noirq)(struct device *); int (*thaw_noirq)(struct device *); int (*poweroff_noirq)(struct device *); int (*restore_noirq)(struct device *); int (*runtime_suspend)(struct device *); int (*runtime_resume)(struct device *); int (*runtime_idle)(struct device *); } ; 301 enum rpm_status { RPM_ACTIVE = 0, RPM_RESUMING = 1, RPM_SUSPENDED = 2, RPM_SUSPENDING = 3 } ; 308 enum rpm_request { RPM_REQ_NONE = 0, RPM_REQ_IDLE = 1, RPM_REQ_SUSPEND = 2, RPM_REQ_AUTOSUSPEND = 3, RPM_REQ_RESUME = 4 } ; 316 struct wakeup_source ; 527 struct pm_subsys_data { spinlock_t lock; unsigned int refcount; struct list_head clock_list; } ; 534 struct dev_pm_qos ; 534 struct dev_pm_info { pm_message_t power_state; unsigned char can_wakeup; unsigned char async_suspend; bool is_prepared; bool is_suspended; bool ignore_children; bool early_init; spinlock_t lock; struct list_head entry; struct completion completion; struct wakeup_source *wakeup; bool wakeup_path; bool syscore; struct timer_list suspend_timer; unsigned long timer_expires; struct work_struct work; wait_queue_head_t wait_queue; atomic_t usage_count; atomic_t child_count; unsigned char disable_depth; unsigned char idle_notification; unsigned char request_pending; unsigned char deferred_resume; unsigned char run_wake; unsigned char runtime_auto; unsigned char no_callbacks; unsigned char irq_safe; unsigned char use_autosuspend; unsigned char timer_autosuspends; unsigned char memalloc_noio; enum rpm_request request; enum rpm_status runtime_status; int runtime_error; int autosuspend_delay; unsigned long last_busy; unsigned long active_jiffies; unsigned long suspended_jiffies; unsigned long accounting_timestamp; struct pm_subsys_data *subsys_data; struct dev_pm_qos *qos; } ; 591 struct dev_pm_domain { struct dev_pm_ops ops; } ; 133 struct pci_bus ; 22 struct __anonstruct_mm_context_t_101 { void *ldt; int size; unsigned short ia32_compat; struct mutex lock; void *vdso; } ; 22 typedef struct __anonstruct_mm_context_t_101 mm_context_t; 18 struct rb_node { unsigned long __rb_parent_color; struct rb_node *rb_right; struct rb_node *rb_left; } ; 40 struct rb_root { struct rb_node *rb_node; } ; 87 struct vm_area_struct ; 22 struct bio_vec ; 341 struct device_node ; 1276 struct llist_node ; 64 struct llist_node { struct llist_node *next; } ; 19 union __anonunion____missing_field_name_128 { struct list_head list; struct llist_node llist; } ; 19 struct call_single_data { union __anonunion____missing_field_name_128 __annonCompField31; void (*func)(void *); void *info; u16 flags; } ; 424 struct inode ; 45 struct arch_uprobe_task { unsigned long saved_scratch_register; unsigned int saved_trap_nr; unsigned int saved_tf; } ; 54 enum uprobe_task_state { UTASK_RUNNING = 0, UTASK_SSTEP = 1, UTASK_SSTEP_ACK = 2, UTASK_SSTEP_TRAPPED = 3 } ; 61 struct __anonstruct____missing_field_name_131 { struct arch_uprobe_task autask; unsigned long vaddr; } ; 61 struct __anonstruct____missing_field_name_132 { struct callback_head dup_xol_work; unsigned long dup_xol_addr; } ; 61 union __anonunion____missing_field_name_130 { struct __anonstruct____missing_field_name_131 __annonCompField33; struct __anonstruct____missing_field_name_132 __annonCompField34; } ; 61 struct uprobe ; 61 struct return_instance ; 61 struct uprobe_task { enum uprobe_task_state state; union __anonunion____missing_field_name_130 __annonCompField35; struct uprobe *active_uprobe; unsigned long xol_vaddr; struct return_instance *return_instances; unsigned int depth; } ; 93 struct xol_area ; 94 struct uprobes_state { struct xol_area *xol_area; } ; 129 struct address_space ; 130 union __anonunion____missing_field_name_133 { struct address_space *mapping; void *s_mem; } ; 130 union __anonunion____missing_field_name_135 { unsigned long index; void *freelist; bool pfmemalloc; } ; 130 struct __anonstruct____missing_field_name_139 { unsigned short inuse; unsigned short objects; unsigned char frozen; } ; 130 union __anonunion____missing_field_name_138 { atomic_t _mapcount; struct __anonstruct____missing_field_name_139 __annonCompField38; int units; } ; 130 struct __anonstruct____missing_field_name_137 { union __anonunion____missing_field_name_138 __annonCompField39; atomic_t _count; } ; 130 union __anonunion____missing_field_name_136 { unsigned long counters; struct __anonstruct____missing_field_name_137 __annonCompField40; unsigned int active; } ; 130 struct __anonstruct____missing_field_name_134 { union __anonunion____missing_field_name_135 __annonCompField37; union __anonunion____missing_field_name_136 __annonCompField41; } ; 130 struct __anonstruct____missing_field_name_141 { struct page *next; int pages; int pobjects; } ; 130 struct slab ; 130 union __anonunion____missing_field_name_140 { struct list_head lru; struct __anonstruct____missing_field_name_141 __annonCompField43; struct list_head list; struct slab *slab_page; struct callback_head callback_head; pgtable_t pmd_huge_pte; } ; 130 union __anonunion____missing_field_name_142 { unsigned long private; spinlock_t *ptl; struct kmem_cache *slab_cache; struct page *first_page; } ; 130 struct page { unsigned long flags; union __anonunion____missing_field_name_133 __annonCompField36; struct __anonstruct____missing_field_name_134 __annonCompField42; union __anonunion____missing_field_name_140 __annonCompField44; union __anonunion____missing_field_name_142 __annonCompField45; unsigned long debug_flags; } ; 186 struct page_frag { struct page *page; __u32 offset; __u32 size; } ; 238 struct __anonstruct_linear_144 { struct rb_node rb; unsigned long rb_subtree_last; } ; 238 union __anonunion_shared_143 { struct __anonstruct_linear_144 linear; struct list_head nonlinear; } ; 238 struct anon_vma ; 238 struct vm_operations_struct ; 238 struct mempolicy ; 238 struct vm_area_struct { unsigned long vm_start; unsigned long vm_end; struct vm_area_struct *vm_next; struct vm_area_struct *vm_prev; struct rb_node vm_rb; unsigned long rb_subtree_gap; struct mm_struct *vm_mm; pgprot_t vm_page_prot; unsigned long vm_flags; union __anonunion_shared_143 shared; struct list_head anon_vma_chain; struct anon_vma *anon_vma; const struct vm_operations_struct *vm_ops; unsigned long vm_pgoff; struct file *vm_file; void *vm_private_data; struct mempolicy *vm_policy; } ; 310 struct core_thread { struct task_struct *task; struct core_thread *next; } ; 316 struct core_state { atomic_t nr_threads; struct core_thread dumper; struct completion startup; } ; 329 struct task_rss_stat { int events; int count[3U]; } ; 337 struct mm_rss_stat { atomic_long_t count[3U]; } ; 342 struct kioctx_table ; 343 struct linux_binfmt ; 343 struct mmu_notifier_mm ; 343 struct mm_struct { struct vm_area_struct *mmap; struct rb_root mm_rb; struct vm_area_struct *mmap_cache; unsigned long int (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); unsigned long mmap_base; unsigned long mmap_legacy_base; unsigned long task_size; unsigned long highest_vm_end; pgd_t *pgd; atomic_t mm_users; atomic_t mm_count; atomic_long_t nr_ptes; int map_count; spinlock_t page_table_lock; struct rw_semaphore mmap_sem; struct list_head mmlist; unsigned long hiwater_rss; unsigned long hiwater_vm; unsigned long total_vm; unsigned long locked_vm; unsigned long pinned_vm; unsigned long shared_vm; unsigned long exec_vm; unsigned long stack_vm; unsigned long def_flags; unsigned long start_code; unsigned long end_code; unsigned long start_data; unsigned long end_data; unsigned long start_brk; unsigned long brk; unsigned long start_stack; unsigned long arg_start; unsigned long arg_end; unsigned long env_start; unsigned long env_end; unsigned long saved_auxv[46U]; struct mm_rss_stat rss_stat; struct linux_binfmt *binfmt; cpumask_var_t cpu_vm_mask_var; mm_context_t context; unsigned long flags; struct core_state *core_state; spinlock_t ioctx_lock; struct kioctx_table *ioctx_table; struct task_struct *owner; struct file *exe_file; struct mmu_notifier_mm *mmu_notifier_mm; struct cpumask cpumask_allocation; unsigned long numa_next_scan; unsigned long numa_scan_offset; int numa_scan_seq; bool tlb_flush_pending; struct uprobes_state uprobes_state; } ; 93 struct shrink_control { gfp_t gfp_mask; unsigned long nr_to_scan; nodemask_t nodes_to_scan; int nid; } ; 26 struct shrinker { unsigned long int (*count_objects)(struct shrinker *, struct shrink_control *); unsigned long int (*scan_objects)(struct shrinker *, struct shrink_control *); int seeks; long batch; unsigned long flags; struct list_head list; atomic_long_t *nr_deferred; } ; 71 struct file_ra_state ; 72 struct user_struct ; 73 struct writeback_control ; 185 struct vm_fault { unsigned int flags; unsigned long pgoff; void *virtual_address; struct page *page; } ; 210 struct vm_operations_struct { void (*open)(struct vm_area_struct *); void (*close)(struct vm_area_struct *); int (*fault)(struct vm_area_struct *, struct vm_fault *); int (*page_mkwrite)(struct vm_area_struct *, struct vm_fault *); int (*access)(struct vm_area_struct *, unsigned long, void *, int, int); int (*set_policy)(struct vm_area_struct *, struct mempolicy *); struct mempolicy * (*get_policy)(struct vm_area_struct *, unsigned long); int (*migrate)(struct vm_area_struct *, const nodemask_t *, const nodemask_t *, unsigned long); int (*remap_pages)(struct vm_area_struct *, unsigned long, unsigned long, unsigned long); } ; 2071 struct scatterlist { unsigned long sg_magic; unsigned long page_link; unsigned int offset; unsigned int length; dma_addr_t dma_address; unsigned int dma_length; } ; 17 struct sg_table { struct scatterlist *sgl; unsigned int nents; unsigned int orig_nents; } ; 351 struct __kfifo { unsigned int in; unsigned int out; unsigned int mask; unsigned int esize; void *data; } ; 65 union __anonunion____missing_field_name_145 { struct __kfifo kfifo; unsigned char *type; const unsigned char *const_type; char (*rectype)[0U]; void *ptr; const void *ptr_const; } ; 65 struct kfifo { union __anonunion____missing_field_name_145 __annonCompField46; unsigned char buf[0U]; } ; 832 struct scsi_cmnd ; 372 struct scsi_lun { __u8 scsi_lun[8U]; } ; 77 typedef uint32_t itt_t; 78 struct iscsi_hdr { uint8_t opcode; uint8_t flags; uint8_t rsvd2[2U]; uint8_t hlength; uint8_t dlength[3U]; struct scsi_lun lun; itt_t itt; __be32 ttt; __be32 statsn; __be32 exp_statsn; __be32 max_statsn; uint8_t other[12U]; } ; 143 struct iscsi_scsi_req { uint8_t opcode; uint8_t flags; __be16 rsvd2; uint8_t hlength; uint8_t dlength[3U]; struct scsi_lun lun; itt_t itt; __be32 data_length; __be32 cmdsn; __be32 exp_statsn; uint8_t cdb[16U]; } ; 282 struct iscsi_tm { uint8_t opcode; uint8_t flags; uint8_t rsvd1[2U]; uint8_t hlength; uint8_t dlength[3U]; struct scsi_lun lun; itt_t itt; itt_t rtt; __be32 cmdsn; __be32 exp_statsn; __be32 refcmdsn; __be32 exp_datasn; uint8_t rsvd2[8U]; } ; 627 struct iovec { void *iov_base; __kernel_size_t iov_len; } ; 11 typedef unsigned short __kernel_sa_family_t; 18 struct cred ; 23 typedef __kernel_sa_family_t sa_family_t; 24 struct sockaddr { sa_family_t sa_family; char sa_data[14U]; } ; 359 struct in_addr { __be32 s_addr; } ; 104 union __anonunion_in6_u_148 { __u8 u6_addr8[16U]; __be16 u6_addr16[8U]; __be32 u6_addr32[4U]; } ; 104 struct in6_addr { union __anonunion_in6_u_148 in6_u; } ; 93 enum iscsi_tgt_dscvr { ISCSI_TGT_DSCVR_SEND_TARGETS = 1, ISCSI_TGT_DSCVR_ISNS = 2, ISCSI_TGT_DSCVR_SLP = 3 } ; 311 enum iscsi_param_type { ISCSI_PARAM = 0, ISCSI_HOST_PARAM = 1, ISCSI_NET_PARAM = 2, ISCSI_FLASHNODE_PARAM = 3, ISCSI_CHAP_PARAM = 4, ISCSI_IFACE_PARAM = 5 } ; 327 struct iscsi_iface_param_info { uint32_t iface_num; uint32_t len; uint16_t param; uint8_t iface_type; uint8_t param_type; uint8_t value[0U]; } ; 336 union __anonunion_src_151 { struct in_addr v4_addr; struct in6_addr v6_addr; } ; 336 union __anonunion_dst_152 { struct in_addr v4_addr; struct in6_addr v6_addr; } ; 336 struct iscsi_path { uint64_t handle; uint8_t mac_addr[6U]; uint8_t mac_addr_old[6U]; uint32_t ip_addr_len; union __anonunion_src_151 src; union __anonunion_dst_152 dst; uint16_t vlan_id; uint16_t pmtu; } ; 490 enum iscsi_param { ISCSI_PARAM_MAX_RECV_DLENGTH = 0, ISCSI_PARAM_MAX_XMIT_DLENGTH = 1, ISCSI_PARAM_HDRDGST_EN = 2, ISCSI_PARAM_DATADGST_EN = 3, ISCSI_PARAM_INITIAL_R2T_EN = 4, ISCSI_PARAM_MAX_R2T = 5, ISCSI_PARAM_IMM_DATA_EN = 6, ISCSI_PARAM_FIRST_BURST = 7, ISCSI_PARAM_MAX_BURST = 8, ISCSI_PARAM_PDU_INORDER_EN = 9, ISCSI_PARAM_DATASEQ_INORDER_EN = 10, ISCSI_PARAM_ERL = 11, ISCSI_PARAM_IFMARKER_EN = 12, ISCSI_PARAM_OFMARKER_EN = 13, ISCSI_PARAM_EXP_STATSN = 14, ISCSI_PARAM_TARGET_NAME = 15, ISCSI_PARAM_TPGT = 16, ISCSI_PARAM_PERSISTENT_ADDRESS = 17, ISCSI_PARAM_PERSISTENT_PORT = 18, ISCSI_PARAM_SESS_RECOVERY_TMO = 19, ISCSI_PARAM_CONN_PORT = 20, ISCSI_PARAM_CONN_ADDRESS = 21, ISCSI_PARAM_USERNAME = 22, ISCSI_PARAM_USERNAME_IN = 23, ISCSI_PARAM_PASSWORD = 24, ISCSI_PARAM_PASSWORD_IN = 25, ISCSI_PARAM_FAST_ABORT = 26, ISCSI_PARAM_ABORT_TMO = 27, ISCSI_PARAM_LU_RESET_TMO = 28, ISCSI_PARAM_HOST_RESET_TMO = 29, ISCSI_PARAM_PING_TMO = 30, ISCSI_PARAM_RECV_TMO = 31, ISCSI_PARAM_IFACE_NAME = 32, ISCSI_PARAM_ISID = 33, ISCSI_PARAM_INITIATOR_NAME = 34, ISCSI_PARAM_TGT_RESET_TMO = 35, ISCSI_PARAM_TARGET_ALIAS = 36, ISCSI_PARAM_CHAP_IN_IDX = 37, ISCSI_PARAM_CHAP_OUT_IDX = 38, ISCSI_PARAM_BOOT_ROOT = 39, ISCSI_PARAM_BOOT_NIC = 40, ISCSI_PARAM_BOOT_TARGET = 41, ISCSI_PARAM_AUTO_SND_TGT_DISABLE = 42, ISCSI_PARAM_DISCOVERY_SESS = 43, ISCSI_PARAM_PORTAL_TYPE = 44, ISCSI_PARAM_CHAP_AUTH_EN = 45, ISCSI_PARAM_DISCOVERY_LOGOUT_EN = 46, ISCSI_PARAM_BIDI_CHAP_EN = 47, ISCSI_PARAM_DISCOVERY_AUTH_OPTIONAL = 48, ISCSI_PARAM_DEF_TIME2WAIT = 49, ISCSI_PARAM_DEF_TIME2RETAIN = 50, ISCSI_PARAM_MAX_SEGMENT_SIZE = 51, ISCSI_PARAM_STATSN = 52, ISCSI_PARAM_KEEPALIVE_TMO = 53, ISCSI_PARAM_LOCAL_PORT = 54, ISCSI_PARAM_TSID = 55, ISCSI_PARAM_DEF_TASKMGMT_TMO = 56, ISCSI_PARAM_TCP_TIMESTAMP_STAT = 57, ISCSI_PARAM_TCP_WSF_DISABLE = 58, ISCSI_PARAM_TCP_NAGLE_DISABLE = 59, ISCSI_PARAM_TCP_TIMER_SCALE = 60, ISCSI_PARAM_TCP_TIMESTAMP_EN = 61, ISCSI_PARAM_TCP_XMIT_WSF = 62, ISCSI_PARAM_TCP_RECV_WSF = 63, ISCSI_PARAM_IP_FRAGMENT_DISABLE = 64, ISCSI_PARAM_IPV4_TOS = 65, ISCSI_PARAM_IPV6_TC = 66, ISCSI_PARAM_IPV6_FLOW_LABEL = 67, ISCSI_PARAM_IS_FW_ASSIGNED_IPV6 = 68, ISCSI_PARAM_DISCOVERY_PARENT_IDX = 69, ISCSI_PARAM_DISCOVERY_PARENT_TYPE = 70, ISCSI_PARAM_LOCAL_IPADDR = 71, ISCSI_PARAM_MAX = 72 } ; 566 enum iscsi_host_param { ISCSI_HOST_PARAM_HWADDRESS = 0, ISCSI_HOST_PARAM_INITIATOR_NAME = 1, ISCSI_HOST_PARAM_NETDEV_NAME = 2, ISCSI_HOST_PARAM_IPADDRESS = 3, ISCSI_HOST_PARAM_PORT_STATE = 4, ISCSI_HOST_PARAM_PORT_SPEED = 5, ISCSI_HOST_PARAM_MAX = 6 } ; 744 struct iscsi_stats_custom { char desc[64U]; uint64_t value; } ; 784 struct iscsi_stats { uint64_t txdata_octets; uint64_t rxdata_octets; uint32_t noptx_pdus; uint32_t scsicmd_pdus; uint32_t tmfcmd_pdus; uint32_t login_pdus; uint32_t text_pdus; uint32_t dataout_pdus; uint32_t logout_pdus; uint32_t snack_pdus; uint32_t noprx_pdus; uint32_t scsirsp_pdus; uint32_t tmfrsp_pdus; uint32_t textrsp_pdus; uint32_t datain_pdus; uint32_t logoutrsp_pdus; uint32_t r2t_pdus; uint32_t async_pdus; uint32_t rjt_pdus; uint32_t digest_err; uint32_t timeout_err; uint32_t custom_length; struct iscsi_stats_custom custom[0U]; } ; 959 struct idr_layer { int prefix; unsigned long bitmap[4U]; struct idr_layer *ary[256U]; int count; int layer; struct callback_head callback_head; } ; 38 struct idr { struct idr_layer *hint; struct idr_layer *top; struct idr_layer *id_free; int layers; int id_free_cnt; int cur; spinlock_t lock; } ; 197 struct ida_bitmap { long nr_busy; unsigned long bitmap[15U]; } ; 213 struct ida { struct idr idr; struct ida_bitmap *free_bitmap; } ; 245 struct dentry ; 246 struct iattr ; 247 struct super_block ; 248 struct file_system_type ; 249 struct kernfs_open_node ; 250 struct kernfs_iattrs ; 266 struct kernfs_root ; 266 struct kernfs_elem_dir { unsigned long subdirs; struct rb_root children; struct kernfs_root *root; } ; 62 struct kernfs_node ; 62 struct kernfs_elem_symlink { struct kernfs_node *target_kn; } ; 66 struct kernfs_ops ; 66 struct kernfs_elem_attr { const struct kernfs_ops *ops; struct kernfs_open_node *open; loff_t size; } ; 72 union __anonunion_u_153 { struct completion *completion; struct kernfs_node *removed_list; } ; 72 union __anonunion____missing_field_name_154 { struct kernfs_elem_dir dir; struct kernfs_elem_symlink symlink; struct kernfs_elem_attr attr; } ; 72 struct kernfs_node { atomic_t count; atomic_t active; struct lockdep_map dep_map; struct kernfs_node *parent; const char *name; struct rb_node rb; union __anonunion_u_153 u; const void *ns; unsigned int hash; union __anonunion____missing_field_name_154 __annonCompField49; void *priv; unsigned short flags; umode_t mode; unsigned int ino; struct kernfs_iattrs *iattr; } ; 114 struct kernfs_dir_ops { int (*mkdir)(struct kernfs_node *, const char *, umode_t ); int (*rmdir)(struct kernfs_node *); int (*rename)(struct kernfs_node *, struct kernfs_node *, const char *); } ; 127 struct kernfs_root { struct kernfs_node *kn; struct ida ino_ida; struct kernfs_dir_ops *dir_ops; } ; 137 struct kernfs_open_file { struct kernfs_node *kn; struct file *file; struct mutex mutex; int event; struct list_head list; bool mmapped; const struct vm_operations_struct *vm_ops; } ; 151 struct kernfs_ops { int (*seq_show)(struct seq_file *, void *); void * (*seq_start)(struct seq_file *, loff_t *); void * (*seq_next)(struct seq_file *, void *, loff_t *); void (*seq_stop)(struct seq_file *, void *); ssize_t (*read)(struct kernfs_open_file *, char *, size_t , loff_t ); ssize_t (*write)(struct kernfs_open_file *, char *, size_t , loff_t ); int (*mmap)(struct kernfs_open_file *, struct vm_area_struct *); struct lock_class_key lockdep_key; } ; 376 struct sock ; 377 struct kobject ; 378 enum kobj_ns_type { KOBJ_NS_TYPE_NONE = 0, KOBJ_NS_TYPE_NET = 1, KOBJ_NS_TYPES = 2 } ; 384 struct kobj_ns_type_operations { enum kobj_ns_type type; bool (*current_may_mount)(); void * (*grab_current_ns)(); const void * (*netlink_ns)(struct sock *); const void * (*initial_ns)(); void (*drop_ns)(void *); } ; 83 struct user_namespace ; 22 struct __anonstruct_kuid_t_155 { uid_t val; } ; 22 typedef struct __anonstruct_kuid_t_155 kuid_t; 27 struct __anonstruct_kgid_t_156 { gid_t val; } ; 27 typedef struct __anonstruct_kgid_t_156 kgid_t; 127 struct kstat { u64 ino; dev_t dev; umode_t mode; unsigned int nlink; kuid_t uid; kgid_t gid; dev_t rdev; loff_t size; struct timespec atime; struct timespec mtime; struct timespec ctime; unsigned long blksize; unsigned long long blocks; } ; 36 struct bin_attribute ; 37 struct attribute { const char *name; umode_t mode; bool ignore_lockdep; struct lock_class_key *key; struct lock_class_key skey; } ; 37 struct attribute_group { const char *name; umode_t (*is_visible)(struct kobject *, struct attribute *, int); struct attribute **attrs; struct bin_attribute **bin_attrs; } ; 67 struct bin_attribute { struct attribute attr; size_t size; void *private; ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *, char *, loff_t , size_t ); ssize_t (*write)(struct file *, struct kobject *, struct bin_attribute *, char *, loff_t , size_t ); int (*mmap)(struct file *, struct kobject *, struct bin_attribute *, struct vm_area_struct *); } ; 130 struct sysfs_ops { ssize_t (*show)(struct kobject *, struct attribute *, char *); ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t ); } ; 462 struct kref { atomic_t refcount; } ; 50 struct kset ; 50 struct kobj_type ; 50 struct kobject { const char *name; struct list_head entry; struct kobject *parent; struct kset *kset; struct kobj_type *ktype; struct kernfs_node *sd; struct kref kref; struct delayed_work release; unsigned char state_initialized; unsigned char state_in_sysfs; unsigned char state_add_uevent_sent; unsigned char state_remove_uevent_sent; unsigned char uevent_suppress; } ; 112 struct kobj_type { void (*release)(struct kobject *); const struct sysfs_ops *sysfs_ops; struct attribute **default_attrs; const struct kobj_ns_type_operations * (*child_ns_type)(struct kobject *); const void * (*namespace)(struct kobject *); } ; 120 struct kobj_uevent_env { char *envp[32U]; int envp_idx; char buf[2048U]; int buflen; } ; 127 struct kset_uevent_ops { const int (*filter)(struct kset *, struct kobject *); const const char * (*name)(struct kset *, struct kobject *); const int (*uevent)(struct kset *, struct kobject *, struct kobj_uevent_env *); } ; 144 struct kset { struct list_head list; spinlock_t list_lock; struct kobject kobj; const struct kset_uevent_ops *uevent_ops; } ; 219 struct klist_node ; 220 struct klist { spinlock_t k_lock; struct list_head k_list; void (*get)(struct klist_node *); void (*put)(struct klist_node *); } ; 37 struct klist_node { void *n_klist; struct list_head n_node; struct kref n_ref; } ; 67 struct path ; 68 struct seq_file { char *buf; size_t size; size_t from; size_t count; size_t pad_until; loff_t index; loff_t read_pos; u64 version; struct mutex lock; const struct seq_operations *op; int poll_event; struct user_namespace *user_ns; void *private; } ; 35 struct seq_operations { void * (*start)(struct seq_file *, loff_t *); void (*stop)(struct seq_file *, void *); void * (*next)(struct seq_file *, void *, loff_t *); int (*show)(struct seq_file *, void *); } ; 196 struct pinctrl ; 197 struct pinctrl_state ; 194 struct dev_pin_info { struct pinctrl *p; struct pinctrl_state *default_state; struct pinctrl_state *sleep_state; struct pinctrl_state *idle_state; } ; 42 struct dma_map_ops ; 42 struct dev_archdata { struct dma_map_ops *dma_ops; void *iommu; } ; 14 struct device_private ; 15 struct device_driver ; 16 struct driver_private ; 17 struct class ; 18 struct subsys_private ; 19 struct bus_type ; 20 struct iommu_ops ; 21 struct iommu_group ; 60 struct device_attribute ; 60 struct bus_type { const char *name; const char *dev_name; struct device *dev_root; struct device_attribute *dev_attrs; const struct attribute_group **bus_groups; const struct attribute_group **dev_groups; const struct attribute_group **drv_groups; int (*match)(struct device *, struct device_driver *); int (*uevent)(struct device *, struct kobj_uevent_env *); int (*probe)(struct device *); int (*remove)(struct device *); void (*shutdown)(struct device *); int (*online)(struct device *); int (*offline)(struct device *); int (*suspend)(struct device *, pm_message_t ); int (*resume)(struct device *); const struct dev_pm_ops *pm; struct iommu_ops *iommu_ops; struct subsys_private *p; struct lock_class_key lock_key; } ; 138 struct device_type ; 195 struct of_device_id ; 195 struct acpi_device_id ; 195 struct device_driver { const char *name; struct bus_type *bus; struct module *owner; const char *mod_name; bool suppress_bind_attrs; const struct of_device_id *of_match_table; const struct acpi_device_id *acpi_match_table; int (*probe)(struct device *); int (*remove)(struct device *); void (*shutdown)(struct device *); int (*suspend)(struct device *, pm_message_t ); int (*resume)(struct device *); const struct attribute_group **groups; const struct dev_pm_ops *pm; struct driver_private *p; } ; 321 struct class_attribute ; 321 struct class { const char *name; struct module *owner; struct class_attribute *class_attrs; const struct attribute_group **dev_groups; struct kobject *dev_kobj; int (*dev_uevent)(struct device *, struct kobj_uevent_env *); char * (*devnode)(struct device *, umode_t *); void (*class_release)(struct class *); void (*dev_release)(struct device *); int (*suspend)(struct device *, pm_message_t ); int (*resume)(struct device *); const struct kobj_ns_type_operations *ns_type; const void * (*namespace)(struct device *); const struct dev_pm_ops *pm; struct subsys_private *p; } ; 414 struct class_attribute { struct attribute attr; ssize_t (*show)(struct class *, struct class_attribute *, char *); ssize_t (*store)(struct class *, struct class_attribute *, const char *, size_t ); } ; 482 struct device_type { const char *name; const struct attribute_group **groups; int (*uevent)(struct device *, struct kobj_uevent_env *); char * (*devnode)(struct device *, umode_t *, kuid_t *, kgid_t *); void (*release)(struct device *); const struct dev_pm_ops *pm; } ; 510 struct device_attribute { struct attribute attr; ssize_t (*show)(struct device *, struct device_attribute *, char *); ssize_t (*store)(struct device *, struct device_attribute *, const char *, size_t ); } ; 637 struct device_dma_parameters { unsigned int max_segment_size; unsigned long segment_boundary_mask; } ; 646 struct acpi_device ; 647 struct acpi_dev_node { struct acpi_device *companion; } ; 653 struct dma_coherent_mem ; 653 struct device { struct device *parent; struct device_private *p; struct kobject kobj; const char *init_name; const struct device_type *type; struct mutex mutex; struct bus_type *bus; struct device_driver *driver; void *platform_data; struct dev_pm_info power; struct dev_pm_domain *pm_domain; struct dev_pin_info *pins; int numa_node; u64 *dma_mask; u64 coherent_dma_mask; struct device_dma_parameters *dma_parms; struct list_head dma_pools; struct dma_coherent_mem *dma_mem; struct dev_archdata archdata; struct device_node *of_node; struct acpi_dev_node acpi_node; dev_t devt; u32 id; spinlock_t devres_lock; struct list_head devres_head; struct klist_node knode_class; struct class *class; const struct attribute_group **groups; void (*release)(struct device *); struct iommu_group *iommu_group; bool offline_disabled; bool offline; } ; 795 struct wakeup_source { const char *name; struct list_head entry; spinlock_t lock; struct timer_list timer; unsigned long timer_expires; ktime_t total_time; ktime_t max_time; ktime_t last_time; ktime_t start_prevent_time; ktime_t prevent_sleep_time; unsigned long event_count; unsigned long active_count; unsigned long relax_count; unsigned long expire_count; unsigned long wakeup_count; bool active; bool autosleep_enabled; } ; 1185 struct scsi_transport_template ; 1186 struct iscsi_transport ; 1187 struct iscsi_endpoint ; 1188 struct Scsi_Host ; 1189 struct iscsi_cls_conn ; 1190 struct iscsi_conn ; 1191 struct iscsi_task ; 1192 struct iscsi_iface ; 1193 struct bsg_job ; 1194 struct iscsi_bus_flash_session ; 1195 struct iscsi_bus_flash_conn ; 1196 struct iscsi_cls_session ; 1196 struct iscsi_transport { struct module *owner; char *name; unsigned int caps; struct iscsi_cls_session * (*create_session)(struct iscsi_endpoint *, uint16_t , uint16_t , uint32_t ); void (*destroy_session)(struct iscsi_cls_session *); struct iscsi_cls_conn * (*create_conn)(struct iscsi_cls_session *, uint32_t ); int (*bind_conn)(struct iscsi_cls_session *, struct iscsi_cls_conn *, uint64_t , int); int (*start_conn)(struct iscsi_cls_conn *); void (*stop_conn)(struct iscsi_cls_conn *, int); void (*destroy_conn)(struct iscsi_cls_conn *); int (*set_param)(struct iscsi_cls_conn *, enum iscsi_param , char *, int); int (*get_ep_param)(struct iscsi_endpoint *, enum iscsi_param , char *); int (*get_conn_param)(struct iscsi_cls_conn *, enum iscsi_param , char *); int (*get_session_param)(struct iscsi_cls_session *, enum iscsi_param , char *); int (*get_host_param)(struct Scsi_Host *, enum iscsi_host_param , char *); int (*set_host_param)(struct Scsi_Host *, enum iscsi_host_param , char *, int); int (*send_pdu)(struct iscsi_cls_conn *, struct iscsi_hdr *, char *, uint32_t ); void (*get_stats)(struct iscsi_cls_conn *, struct iscsi_stats *); int (*init_task)(struct iscsi_task *); int (*xmit_task)(struct iscsi_task *); void (*cleanup_task)(struct iscsi_task *); int (*alloc_pdu)(struct iscsi_task *, uint8_t ); int (*xmit_pdu)(struct iscsi_task *); int (*init_pdu)(struct iscsi_task *, unsigned int, unsigned int); void (*parse_pdu_itt)(struct iscsi_conn *, itt_t , int *, int *); void (*session_recovery_timedout)(struct iscsi_cls_session *); struct iscsi_endpoint * (*ep_connect)(struct Scsi_Host *, struct sockaddr *, int); int (*ep_poll)(struct iscsi_endpoint *, int); void (*ep_disconnect)(struct iscsi_endpoint *); int (*tgt_dscvr)(struct Scsi_Host *, enum iscsi_tgt_dscvr , uint32_t , struct sockaddr *); int (*set_path)(struct Scsi_Host *, struct iscsi_path *); int (*set_iface_param)(struct Scsi_Host *, void *, uint32_t ); int (*get_iface_param)(struct iscsi_iface *, enum iscsi_param_type , int, char *); umode_t (*attr_is_visible)(int, int); int (*bsg_request)(struct bsg_job *); int (*send_ping)(struct Scsi_Host *, uint32_t , uint32_t , uint32_t , uint32_t , struct sockaddr *); int (*get_chap)(struct Scsi_Host *, uint16_t , uint32_t *, char *); int (*delete_chap)(struct Scsi_Host *, uint16_t ); int (*set_chap)(struct Scsi_Host *, void *, int); int (*get_flashnode_param)(struct iscsi_bus_flash_session *, int, char *); int (*set_flashnode_param)(struct iscsi_bus_flash_session *, struct iscsi_bus_flash_conn *, void *, int); int (*new_flashnode)(struct Scsi_Host *, const char *, int); int (*del_flashnode)(struct iscsi_bus_flash_session *); int (*login_flashnode)(struct iscsi_bus_flash_session *, struct iscsi_bus_flash_conn *); int (*logout_flashnode)(struct iscsi_bus_flash_session *, struct iscsi_bus_flash_conn *); int (*logout_flashnode_sid)(struct iscsi_cls_session *); int (*get_host_stats)(struct Scsi_Host *, char *, int); } ; 199 struct iscsi_cls_conn { struct list_head conn_list; void *dd_data; struct iscsi_transport *transport; uint32_t cid; struct mutex ep_mutex; struct iscsi_endpoint *ep; struct device dev; } ; 219 struct iscsi_cls_session { struct list_head sess_list; struct iscsi_transport *transport; spinlock_t lock; struct work_struct block_work; struct work_struct unblock_work; struct work_struct scan_work; struct work_struct unbind_work; int recovery_tmo; struct delayed_work recovery_work; unsigned int target_id; bool ida_used; pid_t creator; int state; int sid; void *dd_data; struct device dev; } ; 258 struct request_queue ; 258 struct iscsi_cls_host { atomic_t nr_scans; struct mutex mutex; struct request_queue *bsg_q; uint32_t port_speed; uint32_t port_state; } ; 283 struct iscsi_endpoint { void *dd_data; struct device dev; uint64_t id; struct iscsi_cls_conn *conn; } ; 291 struct iscsi_iface { struct device dev; struct iscsi_transport *transport; uint32_t iface_type; uint32_t iface_num; void *dd_data; } ; 299 struct iscsi_bus_flash_conn { struct list_head conn_list; void *dd_data; struct iscsi_transport *transport; struct device dev; uint32_t exp_statsn; uint32_t statsn; unsigned int max_recv_dlength; unsigned int max_xmit_dlength; unsigned int max_segment_size; unsigned int tcp_xmit_wsf; unsigned int tcp_recv_wsf; int hdrdgst_en; int datadgst_en; int port; char *ipaddress; char *link_local_ipv6_addr; char *redirect_ipaddr; uint16_t keepalive_timeout; uint16_t local_port; uint8_t snack_req_en; uint8_t tcp_timestamp_stat; uint8_t tcp_nagle_disable; uint8_t tcp_wsf_disable; uint8_t tcp_timer_scale; uint8_t tcp_timestamp_en; uint8_t ipv4_tos; uint8_t ipv6_traffic_class; uint8_t ipv6_flow_label; uint8_t fragment_disable; uint8_t is_fw_assigned_ipv6; } ; 343 struct iscsi_bus_flash_session { struct list_head sess_list; struct iscsi_transport *transport; unsigned int target_id; int flash_state; void *dd_data; struct device dev; unsigned int first_burst; unsigned int max_burst; unsigned short max_r2t; int default_taskmgmt_timeout; int initial_r2t_en; int imm_data_en; int time2wait; int time2retain; int pdu_inorder_en; int dataseq_inorder_en; int erl; int tpgt; char *username; char *username_in; char *password; char *password_in; char *targetname; char *targetalias; char *portal_type; uint16_t tsid; uint16_t chap_in_idx; uint16_t chap_out_idx; uint16_t discovery_parent_idx; uint16_t discovery_parent_type; uint8_t auto_snd_tgt_disable; uint8_t discovery_sess; uint8_t entry_state; uint8_t chap_auth_en; uint8_t discovery_logout_en; uint8_t bidi_chap_en; uint8_t discovery_auth_optional; uint8_t isid[6U]; uint8_t is_boot_target; } ; 485 struct scsi_host_template ; 486 struct scsi_device ; 487 struct scsi_target ; 489 struct iscsi_session ; 514 struct iscsi_r2t_info { __be32 ttt; __be32 exp_statsn; uint32_t data_length; uint32_t data_offset; int data_count; int datasn; int sent; } ; 107 struct iscsi_task { struct iscsi_hdr *hdr; unsigned short hdr_max; unsigned short hdr_len; itt_t hdr_itt; __be32 cmdsn; struct scsi_lun lun; int itt; unsigned int imm_count; struct iscsi_r2t_info unsol_r2t; char *data; unsigned int data_count; struct scsi_cmnd *sc; struct iscsi_conn *conn; unsigned long last_xfer; unsigned long last_timeout; bool have_checked_conn; int state; atomic_t refcount; struct list_head running; void *dd_data; } ; 159 struct iscsi_conn { struct iscsi_cls_conn *cls_conn; void *dd_data; struct iscsi_session *session; int stop_stage; struct timer_list transport_timer; unsigned long last_recv; unsigned long last_ping; int ping_timeout; int recv_timeout; struct iscsi_task *ping_task; uint32_t exp_statsn; uint32_t statsn; int id; int c_stage; char *data; struct iscsi_task *login_task; struct iscsi_task *task; struct list_head mgmtqueue; struct list_head cmdqueue; struct list_head requeue; struct work_struct xmitwork; unsigned long suspend_tx; unsigned long suspend_rx; wait_queue_head_t ehwait; struct iscsi_tm tmhdr; struct timer_list tmf_timer; int tmf_state; unsigned int max_recv_dlength; unsigned int max_xmit_dlength; int hdrdgst_en; int datadgst_en; int ifmarker_en; int ofmarker_en; int persistent_port; char *persistent_address; unsigned int max_segment_size; unsigned int tcp_xmit_wsf; unsigned int tcp_recv_wsf; uint16_t keepalive_tmo; uint16_t local_port; uint8_t tcp_timestamp_stat; uint8_t tcp_nagle_disable; uint8_t tcp_wsf_disable; uint8_t tcp_timer_scale; uint8_t tcp_timestamp_en; uint8_t fragment_disable; uint8_t ipv4_tos; uint8_t ipv6_traffic_class; uint8_t ipv6_flow_label; uint8_t is_fw_assigned_ipv6; char *local_ipaddr; uint64_t txdata_octets; uint64_t rxdata_octets; uint32_t scsicmd_pdus_cnt; uint32_t dataout_pdus_cnt; uint32_t scsirsp_pdus_cnt; uint32_t datain_pdus_cnt; uint32_t r2t_pdus_cnt; uint32_t tmfcmd_pdus_cnt; int32_t tmfrsp_pdus_cnt; uint32_t eh_abort_cnt; uint32_t fmr_unalign_cnt; } ; 251 struct iscsi_pool { struct kfifo queue; void **pool; int max; } ; 267 struct iscsi_session { struct iscsi_cls_session *cls_session; struct mutex eh_mutex; uint32_t cmdsn; uint32_t exp_cmdsn; uint32_t max_cmdsn; uint32_t queued_cmdsn; int abort_timeout; int lu_reset_timeout; int tgt_reset_timeout; int initial_r2t_en; unsigned short max_r2t; int imm_data_en; unsigned int first_burst; unsigned int max_burst; int time2wait; int time2retain; int pdu_inorder_en; int dataseq_inorder_en; int erl; int fast_abort; int tpgt; char *username; char *username_in; char *password; char *password_in; char *targetname; char *targetalias; char *ifacename; char *initiatorname; char *boot_root; char *boot_nic; char *boot_target; char *portal_type; char *discovery_parent_type; uint16_t discovery_parent_idx; uint16_t def_taskmgmt_tmo; uint16_t tsid; uint8_t auto_snd_tgt_disable; uint8_t discovery_sess; uint8_t chap_auth_en; uint8_t discovery_logout_en; uint8_t bidi_chap_en; uint8_t discovery_auth_optional; uint8_t isid[6U]; struct iscsi_transport *tt; struct Scsi_Host *host; struct iscsi_conn *leadconn; spinlock_t lock; int state; int age; int scsi_cmds_max; int cmds_max; struct iscsi_task **cmds; struct iscsi_pool cmdpool; void *dd_data; } ; 485 struct attribute_container { struct list_head node; struct klist containers; struct class *class; const struct attribute_group *grp; struct device_attribute **attrs; int (*match)(struct attribute_container *, struct device *); unsigned long flags; } ; 71 struct transport_container ; 43 struct transport_container { struct attribute_container ac; const struct attribute_group *statistics; } ; 22 struct kernel_cap_struct { __u32 cap[2U]; } ; 25 typedef struct kernel_cap_struct kernel_cap_t; 218 struct plist_head { struct list_head node_list; } ; 84 struct plist_node { int prio; struct list_head prio_list; struct list_head node_list; } ; 4 typedef unsigned long cputime_t; 25 struct sem_undo_list ; 25 struct sysv_sem { struct sem_undo_list *undo_list; } ; 24 struct __anonstruct_sigset_t_158 { unsigned long sig[1U]; } ; 24 typedef struct __anonstruct_sigset_t_158 sigset_t; 25 struct siginfo ; 17 typedef void __signalfn_t(int); 18 typedef __signalfn_t *__sighandler_t; 20 typedef void __restorefn_t(); 21 typedef __restorefn_t *__sigrestore_t; 34 union sigval { int sival_int; void *sival_ptr; } ; 10 typedef union sigval sigval_t; 11 struct __anonstruct__kill_160 { __kernel_pid_t _pid; __kernel_uid32_t _uid; } ; 11 struct __anonstruct__timer_161 { __kernel_timer_t _tid; int _overrun; char _pad[0U]; sigval_t _sigval; int _sys_private; } ; 11 struct __anonstruct__rt_162 { __kernel_pid_t _pid; __kernel_uid32_t _uid; sigval_t _sigval; } ; 11 struct __anonstruct__sigchld_163 { __kernel_pid_t _pid; __kernel_uid32_t _uid; int _status; __kernel_clock_t _utime; __kernel_clock_t _stime; } ; 11 struct __anonstruct__sigfault_164 { void *_addr; short _addr_lsb; } ; 11 struct __anonstruct__sigpoll_165 { long _band; int _fd; } ; 11 struct __anonstruct__sigsys_166 { void *_call_addr; int _syscall; unsigned int _arch; } ; 11 union __anonunion__sifields_159 { int _pad[28U]; struct __anonstruct__kill_160 _kill; struct __anonstruct__timer_161 _timer; struct __anonstruct__rt_162 _rt; struct __anonstruct__sigchld_163 _sigchld; struct __anonstruct__sigfault_164 _sigfault; struct __anonstruct__sigpoll_165 _sigpoll; struct __anonstruct__sigsys_166 _sigsys; } ; 11 struct siginfo { int si_signo; int si_errno; int si_code; union __anonunion__sifields_159 _sifields; } ; 109 typedef struct siginfo siginfo_t; 21 struct sigpending { struct list_head list; sigset_t signal; } ; 251 struct sigaction { __sighandler_t sa_handler; unsigned long sa_flags; __sigrestore_t sa_restorer; sigset_t sa_mask; } ; 265 struct k_sigaction { struct sigaction sa; } ; 448 enum pid_type { PIDTYPE_PID = 0, PIDTYPE_PGID = 1, PIDTYPE_SID = 2, PIDTYPE_MAX = 3 } ; 455 struct pid_namespace ; 455 struct upid { int nr; struct pid_namespace *ns; struct hlist_node pid_chain; } ; 56 struct pid { atomic_t count; unsigned int level; struct hlist_head tasks[3U]; struct callback_head rcu; struct upid numbers[1U]; } ; 68 struct pid_link { struct hlist_node node; struct pid *pid; } ; 174 struct percpu_counter { raw_spinlock_t lock; s64 count; struct list_head list; s32 *counters; } ; 46 struct seccomp_filter ; 47 struct seccomp { int mode; struct seccomp_filter *filter; } ; 40 struct rt_mutex_waiter ; 41 struct rlimit { __kernel_ulong_t rlim_cur; __kernel_ulong_t rlim_max; } ; 11 struct timerqueue_node { struct rb_node node; ktime_t expires; } ; 12 struct timerqueue_head { struct rb_root head; struct timerqueue_node *next; } ; 50 struct hrtimer_clock_base ; 51 struct hrtimer_cpu_base ; 60 enum hrtimer_restart { HRTIMER_NORESTART = 0, HRTIMER_RESTART = 1 } ; 65 struct hrtimer { struct timerqueue_node node; ktime_t _softexpires; enum hrtimer_restart (*function)(struct hrtimer *); struct hrtimer_clock_base *base; unsigned long state; int start_pid; void *start_site; char start_comm[16U]; } ; 132 struct hrtimer_clock_base { struct hrtimer_cpu_base *cpu_base; int index; clockid_t clockid; struct timerqueue_head active; ktime_t resolution; ktime_t (*get_time)(); ktime_t softirq_time; ktime_t offset; } ; 163 struct hrtimer_cpu_base { raw_spinlock_t lock; unsigned int active_bases; unsigned int clock_was_set; ktime_t expires_next; int hres_active; int hang_detected; unsigned long nr_events; unsigned long nr_retries; unsigned long nr_hangs; ktime_t max_hang_time; struct hrtimer_clock_base clock_base[4U]; } ; 463 struct task_io_accounting { u64 rchar; u64 wchar; u64 syscr; u64 syscw; u64 read_bytes; u64 write_bytes; u64 cancelled_write_bytes; } ; 45 struct latency_record { unsigned long backtrace[12U]; unsigned int count; unsigned long time; unsigned long max; } ; 835 struct nsproxy ; 836 struct ctl_table_root ; 837 struct ctl_table_header ; 838 struct ctl_dir ; 39 typedef int proc_handler(struct ctl_table *, int, void *, size_t *, loff_t *); 59 struct ctl_table_poll { atomic_t event; wait_queue_head_t wait; } ; 98 struct ctl_table { const char *procname; void *data; int maxlen; umode_t mode; struct ctl_table *child; proc_handler *proc_handler; struct ctl_table_poll *poll; void *extra1; void *extra2; } ; 119 struct ctl_node { struct rb_node node; struct ctl_table_header *header; } ; 124 struct __anonstruct____missing_field_name_170 { struct ctl_table *ctl_table; int used; int count; int nreg; } ; 124 union __anonunion____missing_field_name_169 { struct __anonstruct____missing_field_name_170 __annonCompField50; struct callback_head rcu; } ; 124 struct ctl_table_set ; 124 struct ctl_table_header { union __anonunion____missing_field_name_169 __annonCompField51; struct completion *unregistering; struct ctl_table *ctl_table_arg; struct ctl_table_root *root; struct ctl_table_set *set; struct ctl_dir *parent; struct ctl_node *node; } ; 145 struct ctl_dir { struct ctl_table_header header; struct rb_root root; } ; 151 struct ctl_table_set { int (*is_seen)(struct ctl_table_set *); struct ctl_dir dir; } ; 156 struct ctl_table_root { struct ctl_table_set default_set; struct ctl_table_set * (*lookup)(struct ctl_table_root *, struct nsproxy *); int (*permissions)(struct ctl_table_header *, struct ctl_table *); } ; 193 struct assoc_array_ptr ; 193 struct assoc_array { struct assoc_array_ptr *root; unsigned long nr_leaves_on_tree; } ; 31 typedef int32_t key_serial_t; 34 typedef uint32_t key_perm_t; 35 struct key ; 36 struct signal_struct ; 37 struct key_type ; 41 struct keyring_index_key { struct key_type *type; const char *description; size_t desc_len; } ; 123 union __anonunion____missing_field_name_171 { struct list_head graveyard_link; struct rb_node serial_node; } ; 123 struct key_user ; 123 union __anonunion____missing_field_name_172 { time_t expiry; time_t revoked_at; } ; 123 struct __anonstruct____missing_field_name_174 { struct key_type *type; char *description; } ; 123 union __anonunion____missing_field_name_173 { struct keyring_index_key index_key; struct __anonstruct____missing_field_name_174 __annonCompField54; } ; 123 union __anonunion_type_data_175 { struct list_head link; unsigned long x[2U]; void *p[2U]; int reject_error; } ; 123 union __anonunion_payload_177 { unsigned long value; void *rcudata; void *data; void *data2[2U]; } ; 123 union __anonunion____missing_field_name_176 { union __anonunion_payload_177 payload; struct assoc_array keys; } ; 123 struct key { atomic_t usage; key_serial_t serial; union __anonunion____missing_field_name_171 __annonCompField52; struct rw_semaphore sem; struct key_user *user; void *security; union __anonunion____missing_field_name_172 __annonCompField53; time_t last_used_at; kuid_t uid; kgid_t gid; key_perm_t perm; unsigned short quotalen; unsigned short datalen; unsigned long flags; union __anonunion____missing_field_name_173 __annonCompField55; union __anonunion_type_data_175 type_data; union __anonunion____missing_field_name_176 __annonCompField56; } ; 345 struct audit_context ; 27 struct group_info { atomic_t usage; int ngroups; int nblocks; kgid_t small_block[32U]; kgid_t *blocks[0U]; } ; 78 struct cred { atomic_t usage; atomic_t subscribers; void *put_addr; unsigned int magic; kuid_t uid; kgid_t gid; kuid_t suid; kgid_t sgid; kuid_t euid; kgid_t egid; kuid_t fsuid; kgid_t fsgid; unsigned int securebits; kernel_cap_t cap_inheritable; kernel_cap_t cap_permitted; kernel_cap_t cap_effective; kernel_cap_t cap_bset; unsigned char jit_keyring; struct key *session_keyring; struct key *process_keyring; struct key *thread_keyring; struct key *request_key_auth; void *security; struct user_struct *user; struct user_namespace *user_ns; struct group_info *group_info; struct callback_head rcu; } ; 123 struct futex_pi_state ; 124 struct robust_list_head ; 125 struct bio_list ; 126 struct fs_struct ; 127 struct perf_event_context ; 128 struct blk_plug ; 180 struct cfs_rq ; 181 struct task_group ; 421 struct sighand_struct { atomic_t count; struct k_sigaction action[64U]; spinlock_t siglock; wait_queue_head_t signalfd_wqh; } ; 460 struct pacct_struct { int ac_flag; long ac_exitcode; unsigned long ac_mem; cputime_t ac_utime; cputime_t ac_stime; unsigned long ac_minflt; unsigned long ac_majflt; } ; 468 struct cpu_itimer { cputime_t expires; cputime_t incr; u32 error; u32 incr_error; } ; 475 struct cputime { cputime_t utime; cputime_t stime; } ; 487 struct task_cputime { cputime_t utime; cputime_t stime; unsigned long long sum_exec_runtime; } ; 507 struct thread_group_cputimer { struct task_cputime cputime; int running; raw_spinlock_t lock; } ; 549 struct autogroup ; 550 struct tty_struct ; 550 struct taskstats ; 550 struct tty_audit_buf ; 550 struct signal_struct { atomic_t sigcnt; atomic_t live; int nr_threads; struct list_head thread_head; wait_queue_head_t wait_chldexit; struct task_struct *curr_target; struct sigpending shared_pending; int group_exit_code; int notify_count; struct task_struct *group_exit_task; int group_stop_count; unsigned int flags; unsigned char is_child_subreaper; unsigned char has_child_subreaper; int posix_timer_id; struct list_head posix_timers; struct hrtimer real_timer; struct pid *leader_pid; ktime_t it_real_incr; struct cpu_itimer it[2U]; struct thread_group_cputimer cputimer; struct task_cputime cputime_expires; struct list_head cpu_timers[3U]; struct pid *tty_old_pgrp; int leader; struct tty_struct *tty; struct autogroup *autogroup; cputime_t utime; cputime_t stime; cputime_t cutime; cputime_t cstime; cputime_t gtime; cputime_t cgtime; struct cputime prev_cputime; unsigned long nvcsw; unsigned long nivcsw; unsigned long cnvcsw; unsigned long cnivcsw; unsigned long min_flt; unsigned long maj_flt; unsigned long cmin_flt; unsigned long cmaj_flt; unsigned long inblock; unsigned long oublock; unsigned long cinblock; unsigned long coublock; unsigned long maxrss; unsigned long cmaxrss; struct task_io_accounting ioac; unsigned long long sum_sched_runtime; struct rlimit rlim[16U]; struct pacct_struct pacct; struct taskstats *stats; unsigned int audit_tty; unsigned int audit_tty_log_passwd; struct tty_audit_buf *tty_audit_buf; struct rw_semaphore group_rwsem; oom_flags_t oom_flags; short oom_score_adj; short oom_score_adj_min; struct mutex cred_guard_mutex; } ; 730 struct user_struct { atomic_t __count; atomic_t processes; atomic_t files; atomic_t sigpending; atomic_t inotify_watches; atomic_t inotify_devs; atomic_t fanotify_listeners; atomic_long_t epoll_watches; unsigned long mq_bytes; unsigned long locked_shm; struct key *uid_keyring; struct key *session_keyring; struct hlist_node uidhash_node; kuid_t uid; atomic_long_t locked_vm; } ; 774 struct backing_dev_info ; 775 struct reclaim_state ; 776 struct sched_info { unsigned long pcount; unsigned long long run_delay; unsigned long long last_arrival; unsigned long long last_queued; } ; 790 struct task_delay_info { spinlock_t lock; unsigned int flags; struct timespec blkio_start; struct timespec blkio_end; u64 blkio_delay; u64 swapin_delay; u32 blkio_count; u32 swapin_count; struct timespec freepages_start; struct timespec freepages_end; u64 freepages_delay; u32 freepages_count; } ; 976 struct io_context ; 1004 struct pipe_inode_info ; 1005 struct uts_namespace ; 1006 struct load_weight { unsigned long weight; u32 inv_weight; } ; 1013 struct sched_avg { u32 runnable_avg_sum; u32 runnable_avg_period; u64 last_runnable_update; s64 decay_count; unsigned long load_avg_contrib; } ; 1025 struct sched_statistics { u64 wait_start; u64 wait_max; u64 wait_count; u64 wait_sum; u64 iowait_count; u64 iowait_sum; u64 sleep_start; u64 sleep_max; s64 sum_sleep_runtime; u64 block_start; u64 block_max; u64 exec_max; u64 slice_max; u64 nr_migrations_cold; u64 nr_failed_migrations_affine; u64 nr_failed_migrations_running; u64 nr_failed_migrations_hot; u64 nr_forced_migrations; u64 nr_wakeups; u64 nr_wakeups_sync; u64 nr_wakeups_migrate; u64 nr_wakeups_local; u64 nr_wakeups_remote; u64 nr_wakeups_affine; u64 nr_wakeups_affine_attempts; u64 nr_wakeups_passive; u64 nr_wakeups_idle; } ; 1060 struct sched_entity { struct load_weight load; struct rb_node run_node; struct list_head group_node; unsigned int on_rq; u64 exec_start; u64 sum_exec_runtime; u64 vruntime; u64 prev_sum_exec_runtime; u64 nr_migrations; struct sched_statistics statistics; struct sched_entity *parent; struct cfs_rq *cfs_rq; struct cfs_rq *my_q; struct sched_avg avg; } ; 1091 struct rt_rq ; 1091 struct sched_rt_entity { struct list_head run_list; unsigned long timeout; unsigned long watchdog_stamp; unsigned int time_slice; struct sched_rt_entity *back; struct sched_rt_entity *parent; struct rt_rq *rt_rq; struct rt_rq *my_q; } ; 1107 struct sched_dl_entity { struct rb_node rb_node; u64 dl_runtime; u64 dl_deadline; u64 dl_period; u64 dl_bw; s64 runtime; u64 deadline; unsigned int flags; int dl_throttled; int dl_new; int dl_boosted; struct hrtimer dl_timer; } ; 1162 struct mem_cgroup ; 1162 struct memcg_batch_info { int do_batch; struct mem_cgroup *memcg; unsigned long nr_pages; unsigned long memsw_nr_pages; } ; 1569 struct memcg_oom_info { struct mem_cgroup *memcg; gfp_t gfp_mask; int order; unsigned char may_oom; } ; 1576 struct sched_class ; 1576 struct files_struct ; 1576 struct css_set ; 1576 struct compat_robust_list_head ; 1576 struct numa_group ; 1576 struct task_struct { volatile long state; void *stack; atomic_t usage; unsigned int flags; unsigned int ptrace; struct llist_node wake_entry; int on_cpu; struct task_struct *last_wakee; unsigned long wakee_flips; unsigned long wakee_flip_decay_ts; int wake_cpu; int on_rq; int prio; int static_prio; int normal_prio; unsigned int rt_priority; const struct sched_class *sched_class; struct sched_entity se; struct sched_rt_entity rt; struct task_group *sched_task_group; struct sched_dl_entity dl; struct hlist_head preempt_notifiers; unsigned int policy; int nr_cpus_allowed; cpumask_t cpus_allowed; struct sched_info sched_info; struct list_head tasks; struct plist_node pushable_tasks; struct rb_node pushable_dl_tasks; struct mm_struct *mm; struct mm_struct *active_mm; unsigned char brk_randomized; struct task_rss_stat rss_stat; int exit_state; int exit_code; int exit_signal; int pdeath_signal; unsigned int jobctl; unsigned int personality; unsigned char in_execve; unsigned char in_iowait; unsigned char no_new_privs; unsigned char sched_reset_on_fork; unsigned char sched_contributes_to_load; pid_t pid; pid_t tgid; struct task_struct *real_parent; struct task_struct *parent; struct list_head children; struct list_head sibling; struct task_struct *group_leader; struct list_head ptraced; struct list_head ptrace_entry; struct pid_link pids[3U]; struct list_head thread_group; struct list_head thread_node; struct completion *vfork_done; int *set_child_tid; int *clear_child_tid; cputime_t utime; cputime_t stime; cputime_t utimescaled; cputime_t stimescaled; cputime_t gtime; struct cputime prev_cputime; unsigned long nvcsw; unsigned long nivcsw; struct timespec start_time; struct timespec real_start_time; unsigned long min_flt; unsigned long maj_flt; struct task_cputime cputime_expires; struct list_head cpu_timers[3U]; const struct cred *real_cred; const struct cred *cred; char comm[16U]; int link_count; int total_link_count; struct sysv_sem sysvsem; unsigned long last_switch_count; struct thread_struct thread; struct fs_struct *fs; struct files_struct *files; struct nsproxy *nsproxy; struct signal_struct *signal; struct sighand_struct *sighand; sigset_t blocked; sigset_t real_blocked; sigset_t saved_sigmask; struct sigpending pending; unsigned long sas_ss_sp; size_t sas_ss_size; int (*notifier)(void *); void *notifier_data; sigset_t *notifier_mask; struct callback_head *task_works; struct audit_context *audit_context; kuid_t loginuid; unsigned int sessionid; struct seccomp seccomp; u32 parent_exec_id; u32 self_exec_id; spinlock_t alloc_lock; raw_spinlock_t pi_lock; struct rb_root pi_waiters; struct rb_node *pi_waiters_leftmost; struct rt_mutex_waiter *pi_blocked_on; struct task_struct *pi_top_task; struct mutex_waiter *blocked_on; unsigned int irq_events; unsigned long hardirq_enable_ip; unsigned long hardirq_disable_ip; unsigned int hardirq_enable_event; unsigned int hardirq_disable_event; int hardirqs_enabled; int hardirq_context; unsigned long softirq_disable_ip; unsigned long softirq_enable_ip; unsigned int softirq_disable_event; unsigned int softirq_enable_event; int softirqs_enabled; int softirq_context; u64 curr_chain_key; int lockdep_depth; unsigned int lockdep_recursion; struct held_lock held_locks[48U]; gfp_t lockdep_reclaim_gfp; void *journal_info; struct bio_list *bio_list; struct blk_plug *plug; struct reclaim_state *reclaim_state; struct backing_dev_info *backing_dev_info; struct io_context *io_context; unsigned long ptrace_message; siginfo_t *last_siginfo; struct task_io_accounting ioac; u64 acct_rss_mem1; u64 acct_vm_mem1; cputime_t acct_timexpd; nodemask_t mems_allowed; seqcount_t mems_allowed_seq; int cpuset_mem_spread_rotor; int cpuset_slab_spread_rotor; struct css_set *cgroups; struct list_head cg_list; struct robust_list_head *robust_list; struct compat_robust_list_head *compat_robust_list; struct list_head pi_state_list; struct futex_pi_state *pi_state_cache; struct perf_event_context *perf_event_ctxp[2U]; struct mutex perf_event_mutex; struct list_head perf_event_list; struct mempolicy *mempolicy; short il_next; short pref_node_fork; int numa_scan_seq; unsigned int numa_scan_period; unsigned int numa_scan_period_max; int numa_preferred_nid; int numa_migrate_deferred; unsigned long numa_migrate_retry; u64 node_stamp; struct callback_head numa_work; struct list_head numa_entry; struct numa_group *numa_group; unsigned long *numa_faults; unsigned long total_numa_faults; unsigned long *numa_faults_buffer; unsigned long numa_faults_locality[2U]; unsigned long numa_pages_migrated; struct callback_head rcu; struct pipe_inode_info *splice_pipe; struct page_frag task_frag; struct task_delay_info *delays; int make_it_fail; int nr_dirtied; int nr_dirtied_pause; unsigned long dirty_paused_when; int latency_record_count; struct latency_record latency_record[32U]; unsigned long timer_slack_ns; unsigned long default_timer_slack_ns; unsigned long trace; unsigned long trace_recursion; struct memcg_batch_info memcg_batch; unsigned int memcg_kmem_skip_account; struct memcg_oom_info memcg_oom; struct uprobe_task *utask; unsigned int sequential_io; unsigned int sequential_io_avg; } ; 355 struct kmem_cache_cpu { void **freelist; unsigned long tid; struct page *page; struct page *partial; unsigned int stat[26U]; } ; 48 struct kmem_cache_order_objects { unsigned long x; } ; 58 struct memcg_cache_params ; 58 struct kmem_cache_node ; 58 struct kmem_cache { struct kmem_cache_cpu *cpu_slab; unsigned long flags; unsigned long min_partial; int size; int object_size; int offset; int cpu_partial; struct kmem_cache_order_objects oo; struct kmem_cache_order_objects max; struct kmem_cache_order_objects min; gfp_t allocflags; int refcount; void (*ctor)(void *); int inuse; int align; int reserved; const char *name; struct list_head list; struct kobject kobj; struct memcg_cache_params *memcg_params; int max_attr_size; int remote_node_defrag_ratio; struct kmem_cache_node *node[1024U]; } ; 497 struct __anonstruct____missing_field_name_180 { struct callback_head callback_head; struct kmem_cache *memcg_caches[0U]; } ; 497 struct __anonstruct____missing_field_name_181 { struct mem_cgroup *memcg; struct list_head list; struct kmem_cache *root_cache; bool dead; atomic_t nr_pages; struct work_struct destroy; } ; 497 union __anonunion____missing_field_name_179 { struct __anonstruct____missing_field_name_180 __annonCompField58; struct __anonstruct____missing_field_name_181 __annonCompField59; } ; 497 struct memcg_cache_params { bool is_root_cache; union __anonunion____missing_field_name_179 __annonCompField60; } ; 50 struct hlist_bl_node ; 50 struct hlist_bl_head { struct hlist_bl_node *first; } ; 36 struct hlist_bl_node { struct hlist_bl_node *next; struct hlist_bl_node **pprev; } ; 114 struct __anonstruct____missing_field_name_183 { spinlock_t lock; unsigned int count; } ; 114 union __anonunion____missing_field_name_182 { struct __anonstruct____missing_field_name_183 __annonCompField61; } ; 114 struct lockref { union __anonunion____missing_field_name_182 __annonCompField62; } ; 49 struct nameidata ; 50 struct vfsmount ; 51 struct __anonstruct____missing_field_name_185 { u32 hash; u32 len; } ; 51 union __anonunion____missing_field_name_184 { struct __anonstruct____missing_field_name_185 __annonCompField63; u64 hash_len; } ; 51 struct qstr { union __anonunion____missing_field_name_184 __annonCompField64; const unsigned char *name; } ; 90 struct dentry_operations ; 90 union __anonunion_d_u_186 { struct list_head d_child; struct callback_head d_rcu; } ; 90 struct dentry { unsigned int d_flags; seqcount_t d_seq; struct hlist_bl_node d_hash; struct dentry *d_parent; struct qstr d_name; struct inode *d_inode; unsigned char d_iname[32U]; struct lockref d_lockref; const struct dentry_operations *d_op; struct super_block *d_sb; unsigned long d_time; void *d_fsdata; struct list_head d_lru; union __anonunion_d_u_186 d_u; struct list_head d_subdirs; struct hlist_node d_alias; } ; 142 struct dentry_operations { int (*d_revalidate)(struct dentry *, unsigned int); int (*d_weak_revalidate)(struct dentry *, unsigned int); int (*d_hash)(const struct dentry *, struct qstr *); int (*d_compare)(const struct dentry *, const struct dentry *, unsigned int, const char *, const struct qstr *); int (*d_delete)(const struct dentry *); void (*d_release)(struct dentry *); void (*d_prune)(struct dentry *); void (*d_iput)(struct dentry *, struct inode *); char * (*d_dname)(struct dentry *, char *, int); struct vfsmount * (*d_automount)(struct path *); int (*d_manage)(struct dentry *, bool ); } ; 469 struct path { struct vfsmount *mnt; struct dentry *dentry; } ; 26 struct list_lru_node { spinlock_t lock; struct list_head list; long nr_items; } ; 28 struct list_lru { struct list_lru_node *node; nodemask_t active_nodes; } ; 58 struct radix_tree_node ; 58 struct radix_tree_root { unsigned int height; gfp_t gfp_mask; struct radix_tree_node *rnode; } ; 45 struct fiemap_extent { __u64 fe_logical; __u64 fe_physical; __u64 fe_length; __u64 fe_reserved64[2U]; __u32 fe_flags; __u32 fe_reserved[3U]; } ; 38 enum migrate_mode { MIGRATE_ASYNC = 0, MIGRATE_SYNC_LIGHT = 1, MIGRATE_SYNC = 2 } ; 27 struct bio_set ; 28 struct bio ; 29 struct bio_integrity_payload ; 30 struct block_device ; 31 struct cgroup_subsys_state ; 19 typedef void bio_end_io_t(struct bio *, int); 21 struct bio_vec { struct page *bv_page; unsigned int bv_len; unsigned int bv_offset; } ; 30 struct bvec_iter { sector_t bi_sector; unsigned int bi_size; unsigned int bi_idx; unsigned int bi_bvec_done; } ; 40 struct bio { struct bio *bi_next; struct block_device *bi_bdev; unsigned long bi_flags; unsigned long bi_rw; struct bvec_iter bi_iter; unsigned int bi_phys_segments; unsigned int bi_seg_front_size; unsigned int bi_seg_back_size; atomic_t bi_remaining; bio_end_io_t *bi_end_io; void *bi_private; struct io_context *bi_ioc; struct cgroup_subsys_state *bi_css; struct bio_integrity_payload *bi_integrity; unsigned short bi_vcnt; unsigned short bi_max_vecs; atomic_t bi_cnt; struct bio_vec *bi_io_vec; struct bio_set *bi_pool; struct bio_vec bi_inline_vecs[0U]; } ; 56 struct export_operations ; 57 struct hd_geometry ; 58 struct kiocb ; 59 struct poll_table_struct ; 60 struct kstatfs ; 61 struct swap_info_struct ; 68 struct iattr { unsigned int ia_valid; umode_t ia_mode; kuid_t ia_uid; kgid_t ia_gid; loff_t ia_size; struct timespec ia_atime; struct timespec ia_mtime; struct timespec ia_ctime; struct file *ia_file; } ; 246 struct fs_disk_quota { __s8 d_version; __s8 d_flags; __u16 d_fieldmask; __u32 d_id; __u64 d_blk_hardlimit; __u64 d_blk_softlimit; __u64 d_ino_hardlimit; __u64 d_ino_softlimit; __u64 d_bcount; __u64 d_icount; __s32 d_itimer; __s32 d_btimer; __u16 d_iwarns; __u16 d_bwarns; __s32 d_padding2; __u64 d_rtb_hardlimit; __u64 d_rtb_softlimit; __u64 d_rtbcount; __s32 d_rtbtimer; __u16 d_rtbwarns; __s16 d_padding3; char d_padding4[8U]; } ; 76 struct fs_qfilestat { __u64 qfs_ino; __u64 qfs_nblks; __u32 qfs_nextents; } ; 151 typedef struct fs_qfilestat fs_qfilestat_t; 152 struct fs_quota_stat { __s8 qs_version; __u16 qs_flags; __s8 qs_pad; fs_qfilestat_t qs_uquota; fs_qfilestat_t qs_gquota; __u32 qs_incoredqs; __s32 qs_btimelimit; __s32 qs_itimelimit; __s32 qs_rtbtimelimit; __u16 qs_bwarnlimit; __u16 qs_iwarnlimit; } ; 166 struct fs_qfilestatv { __u64 qfs_ino; __u64 qfs_nblks; __u32 qfs_nextents; __u32 qfs_pad; } ; 196 struct fs_quota_statv { __s8 qs_version; __u8 qs_pad1; __u16 qs_flags; __u32 qs_incoredqs; struct fs_qfilestatv qs_uquota; struct fs_qfilestatv qs_gquota; struct fs_qfilestatv qs_pquota; __s32 qs_btimelimit; __s32 qs_itimelimit; __s32 qs_rtbtimelimit; __u16 qs_bwarnlimit; __u16 qs_iwarnlimit; __u64 qs_pad2[8U]; } ; 212 struct dquot ; 19 typedef __kernel_uid32_t projid_t; 23 struct __anonstruct_kprojid_t_187 { projid_t val; } ; 23 typedef struct __anonstruct_kprojid_t_187 kprojid_t; 119 struct if_dqinfo { __u64 dqi_bgrace; __u64 dqi_igrace; __u32 dqi_flags; __u32 dqi_valid; } ; 152 enum quota_type { USRQUOTA = 0, GRPQUOTA = 1, PRJQUOTA = 2 } ; 60 typedef long long qsize_t; 61 union __anonunion____missing_field_name_188 { kuid_t uid; kgid_t gid; kprojid_t projid; } ; 61 struct kqid { union __anonunion____missing_field_name_188 __annonCompField65; enum quota_type type; } ; 178 struct mem_dqblk { qsize_t dqb_bhardlimit; qsize_t dqb_bsoftlimit; qsize_t dqb_curspace; qsize_t dqb_rsvspace; qsize_t dqb_ihardlimit; qsize_t dqb_isoftlimit; qsize_t dqb_curinodes; time_t dqb_btime; time_t dqb_itime; } ; 200 struct quota_format_type ; 201 struct mem_dqinfo { struct quota_format_type *dqi_format; int dqi_fmt_id; struct list_head dqi_dirty_list; unsigned long dqi_flags; unsigned int dqi_bgrace; unsigned int dqi_igrace; qsize_t dqi_maxblimit; qsize_t dqi_maxilimit; void *dqi_priv; } ; 264 struct dquot { struct hlist_node dq_hash; struct list_head dq_inuse; struct list_head dq_free; struct list_head dq_dirty; struct mutex dq_lock; atomic_t dq_count; wait_queue_head_t dq_wait_unused; struct super_block *dq_sb; struct kqid dq_id; loff_t dq_off; unsigned long dq_flags; struct mem_dqblk dq_dqb; } ; 291 struct quota_format_ops { int (*check_quota_file)(struct super_block *, int); int (*read_file_info)(struct super_block *, int); int (*write_file_info)(struct super_block *, int); int (*free_file_info)(struct super_block *, int); int (*read_dqblk)(struct dquot *); int (*commit_dqblk)(struct dquot *); int (*release_dqblk)(struct dquot *); } ; 302 struct dquot_operations { int (*write_dquot)(struct dquot *); struct dquot * (*alloc_dquot)(struct super_block *, int); void (*destroy_dquot)(struct dquot *); int (*acquire_dquot)(struct dquot *); int (*release_dquot)(struct dquot *); int (*mark_dirty)(struct dquot *); int (*write_info)(struct super_block *, int); qsize_t * (*get_reserved_space)(struct inode *); } ; 316 struct quotactl_ops { int (*quota_on)(struct super_block *, int, int, struct path *); int (*quota_on_meta)(struct super_block *, int, int); int (*quota_off)(struct super_block *, int); int (*quota_sync)(struct super_block *, int); int (*get_info)(struct super_block *, int, struct if_dqinfo *); int (*set_info)(struct super_block *, int, struct if_dqinfo *); int (*get_dqblk)(struct super_block *, struct kqid , struct fs_disk_quota *); int (*set_dqblk)(struct super_block *, struct kqid , struct fs_disk_quota *); int (*get_xstate)(struct super_block *, struct fs_quota_stat *); int (*set_xstate)(struct super_block *, unsigned int, int); int (*get_xstatev)(struct super_block *, struct fs_quota_statv *); } ; 333 struct quota_format_type { int qf_fmt_id; const struct quota_format_ops *qf_ops; struct module *qf_owner; struct quota_format_type *qf_next; } ; 379 struct quota_info { unsigned int flags; struct mutex dqio_mutex; struct mutex dqonoff_mutex; struct rw_semaphore dqptr_sem; struct inode *files[2U]; struct mem_dqinfo info[2U]; const struct quota_format_ops *ops[2U]; } ; 345 union __anonunion_arg_190 { char *buf; void *data; } ; 345 struct __anonstruct_read_descriptor_t_189 { size_t written; size_t count; union __anonunion_arg_190 arg; int error; } ; 345 typedef struct __anonstruct_read_descriptor_t_189 read_descriptor_t; 348 struct address_space_operations { int (*writepage)(struct page *, struct writeback_control *); int (*readpage)(struct file *, struct page *); int (*writepages)(struct address_space *, struct writeback_control *); int (*set_page_dirty)(struct page *); int (*readpages)(struct file *, struct address_space *, struct list_head *, unsigned int); int (*write_begin)(struct file *, struct address_space *, loff_t , unsigned int, unsigned int, struct page **, void **); int (*write_end)(struct file *, struct address_space *, loff_t , unsigned int, unsigned int, struct page *, void *); sector_t (*bmap)(struct address_space *, sector_t ); void (*invalidatepage)(struct page *, unsigned int, unsigned int); int (*releasepage)(struct page *, gfp_t ); void (*freepage)(struct page *); ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *, loff_t , unsigned long); int (*get_xip_mem)(struct address_space *, unsigned long, int, void **, unsigned long *); int (*migratepage)(struct address_space *, struct page *, struct page *, enum migrate_mode ); int (*launder_page)(struct page *); int (*is_partially_uptodate)(struct page *, read_descriptor_t *, unsigned long); void (*is_dirty_writeback)(struct page *, bool *, bool *); int (*error_remove_page)(struct address_space *, struct page *); int (*swap_activate)(struct swap_info_struct *, struct file *, sector_t *); void (*swap_deactivate)(struct file *); } ; 408 struct address_space { struct inode *host; struct radix_tree_root page_tree; spinlock_t tree_lock; unsigned int i_mmap_writable; struct rb_root i_mmap; struct list_head i_mmap_nonlinear; struct mutex i_mmap_mutex; unsigned long nrpages; unsigned long writeback_index; const struct address_space_operations *a_ops; unsigned long flags; struct backing_dev_info *backing_dev_info; spinlock_t private_lock; struct list_head private_list; void *private_data; } ; 430 struct hd_struct ; 430 struct gendisk ; 430 struct block_device { dev_t bd_dev; int bd_openers; struct inode *bd_inode; struct super_block *bd_super; struct mutex bd_mutex; struct list_head bd_inodes; void *bd_claiming; void *bd_holder; int bd_holders; bool bd_write_holder; struct list_head bd_holder_disks; struct block_device *bd_contains; unsigned int bd_block_size; struct hd_struct *bd_part; unsigned int bd_part_count; int bd_invalidated; struct gendisk *bd_disk; struct request_queue *bd_queue; struct list_head bd_list; unsigned long bd_private; int bd_fsfreeze_count; struct mutex bd_fsfreeze_mutex; } ; 503 struct posix_acl ; 504 struct inode_operations ; 504 union __anonunion____missing_field_name_191 { const unsigned int i_nlink; unsigned int __i_nlink; } ; 504 union __anonunion____missing_field_name_192 { struct hlist_head i_dentry; struct callback_head i_rcu; } ; 504 struct file_lock ; 504 struct cdev ; 504 union __anonunion____missing_field_name_193 { struct pipe_inode_info *i_pipe; struct block_device *i_bdev; struct cdev *i_cdev; } ; 504 struct inode { umode_t i_mode; unsigned short i_opflags; kuid_t i_uid; kgid_t i_gid; unsigned int i_flags; struct posix_acl *i_acl; struct posix_acl *i_default_acl; const struct inode_operations *i_op; struct super_block *i_sb; struct address_space *i_mapping; void *i_security; unsigned long i_ino; union __anonunion____missing_field_name_191 __annonCompField66; dev_t i_rdev; loff_t i_size; struct timespec i_atime; struct timespec i_mtime; struct timespec i_ctime; spinlock_t i_lock; unsigned short i_bytes; unsigned int i_blkbits; blkcnt_t i_blocks; unsigned long i_state; struct mutex i_mutex; unsigned long dirtied_when; struct hlist_node i_hash; struct list_head i_wb_list; struct list_head i_lru; struct list_head i_sb_list; union __anonunion____missing_field_name_192 __annonCompField67; u64 i_version; atomic_t i_count; atomic_t i_dio_count; atomic_t i_writecount; const struct file_operations *i_fop; struct file_lock *i_flock; struct address_space i_data; struct dquot *i_dquot[2U]; struct list_head i_devices; union __anonunion____missing_field_name_193 __annonCompField68; __u32 i_generation; __u32 i_fsnotify_mask; struct hlist_head i_fsnotify_marks; atomic_t i_readcount; void *i_private; } ; 740 struct fown_struct { rwlock_t lock; struct pid *pid; enum pid_type pid_type; kuid_t uid; kuid_t euid; int signum; } ; 748 struct file_ra_state { unsigned long start; unsigned int size; unsigned int async_size; unsigned int ra_pages; unsigned int mmap_miss; loff_t prev_pos; } ; 771 union __anonunion_f_u_194 { struct llist_node fu_llist; struct callback_head fu_rcuhead; } ; 771 struct file { union __anonunion_f_u_194 f_u; struct path f_path; struct inode *f_inode; const struct file_operations *f_op; spinlock_t f_lock; atomic_long_t f_count; unsigned int f_flags; fmode_t f_mode; struct mutex f_pos_lock; loff_t f_pos; struct fown_struct f_owner; const struct cred *f_cred; struct file_ra_state f_ra; u64 f_version; void *f_security; void *private_data; struct list_head f_ep_links; struct list_head f_tfile_llink; struct address_space *f_mapping; unsigned long f_mnt_write_state; } ; 909 typedef struct files_struct *fl_owner_t; 910 struct file_lock_operations { void (*fl_copy_lock)(struct file_lock *, struct file_lock *); void (*fl_release_private)(struct file_lock *); } ; 915 struct lock_manager_operations { int (*lm_compare_owner)(struct file_lock *, struct file_lock *); unsigned long int (*lm_owner_key)(struct file_lock *); void (*lm_notify)(struct file_lock *); int (*lm_grant)(struct file_lock *, struct file_lock *, int); void (*lm_break)(struct file_lock *); int (*lm_change)(struct file_lock **, int); } ; 928 struct net ; 933 struct nlm_lockowner ; 934 struct nfs_lock_info { u32 state; struct nlm_lockowner *owner; struct list_head list; } ; 14 struct nfs4_lock_state ; 15 struct nfs4_lock_info { struct nfs4_lock_state *owner; } ; 19 struct fasync_struct ; 19 struct __anonstruct_afs_196 { struct list_head link; int state; } ; 19 union __anonunion_fl_u_195 { struct nfs_lock_info nfs_fl; struct nfs4_lock_info nfs4_fl; struct __anonstruct_afs_196 afs; } ; 19 struct file_lock { struct file_lock *fl_next; struct hlist_node fl_link; struct list_head fl_block; fl_owner_t fl_owner; unsigned int fl_flags; unsigned char fl_type; unsigned int fl_pid; int fl_link_cpu; struct pid *fl_nspid; wait_queue_head_t fl_wait; struct file *fl_file; loff_t fl_start; loff_t fl_end; struct fasync_struct *fl_fasync; unsigned long fl_break_time; unsigned long fl_downgrade_time; const struct file_lock_operations *fl_ops; const struct lock_manager_operations *fl_lmops; union __anonunion_fl_u_195 fl_u; } ; 1036 struct fasync_struct { spinlock_t fa_lock; int magic; int fa_fd; struct fasync_struct *fa_next; struct file *fa_file; struct callback_head fa_rcu; } ; 1228 struct sb_writers { struct percpu_counter counter[3U]; wait_queue_head_t wait; int frozen; wait_queue_head_t wait_unfrozen; struct lockdep_map lock_map[3U]; } ; 1244 struct super_operations ; 1244 struct xattr_handler ; 1244 struct mtd_info ; 1244 struct super_block { struct list_head s_list; dev_t s_dev; unsigned char s_blocksize_bits; unsigned long s_blocksize; loff_t s_maxbytes; struct file_system_type *s_type; const struct super_operations *s_op; const struct dquot_operations *dq_op; const struct quotactl_ops *s_qcop; const struct export_operations *s_export_op; unsigned long s_flags; unsigned long s_magic; struct dentry *s_root; struct rw_semaphore s_umount; int s_count; atomic_t s_active; void *s_security; const struct xattr_handler **s_xattr; struct list_head s_inodes; struct hlist_bl_head s_anon; struct list_head s_mounts; struct block_device *s_bdev; struct backing_dev_info *s_bdi; struct mtd_info *s_mtd; struct hlist_node s_instances; struct quota_info s_dquot; struct sb_writers s_writers; char s_id[32U]; u8 s_uuid[16U]; void *s_fs_info; unsigned int s_max_links; fmode_t s_mode; u32 s_time_gran; struct mutex s_vfs_rename_mutex; char *s_subtype; char *s_options; const struct dentry_operations *s_d_op; int cleancache_poolid; struct shrinker s_shrink; atomic_long_t s_remove_count; int s_readonly_remount; struct workqueue_struct *s_dio_done_wq; struct list_lru s_dentry_lru; struct list_lru s_inode_lru; struct callback_head rcu; } ; 1474 struct fiemap_extent_info { unsigned int fi_flags; unsigned int fi_extents_mapped; unsigned int fi_extents_max; struct fiemap_extent *fi_extents_start; } ; 1512 struct dir_context { int (*actor)(void *, const char *, int, loff_t , u64 , unsigned int); loff_t pos; } ; 1516 struct block_device_operations ; 1517 struct file_operations { struct module *owner; loff_t (*llseek)(struct file *, loff_t , int); ssize_t (*read)(struct file *, char *, size_t , loff_t *); ssize_t (*write)(struct file *, const char *, size_t , loff_t *); ssize_t (*aio_read)(struct kiocb *, const struct iovec *, unsigned long, loff_t ); ssize_t (*aio_write)(struct kiocb *, const struct iovec *, unsigned long, loff_t ); int (*iterate)(struct file *, struct dir_context *); unsigned int (*poll)(struct file *, struct poll_table_struct *); long int (*unlocked_ioctl)(struct file *, unsigned int, unsigned long); long int (*compat_ioctl)(struct file *, unsigned int, unsigned long); int (*mmap)(struct file *, struct vm_area_struct *); int (*open)(struct inode *, struct file *); int (*flush)(struct file *, fl_owner_t ); int (*release)(struct inode *, struct file *); int (*fsync)(struct file *, loff_t , loff_t , int); int (*aio_fsync)(struct kiocb *, int); int (*fasync)(int, struct file *, int); int (*lock)(struct file *, int, struct file_lock *); ssize_t (*sendpage)(struct file *, struct page *, int, size_t , loff_t *, int); unsigned long int (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); int (*check_flags)(int); int (*flock)(struct file *, int, struct file_lock *); ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t , unsigned int); ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t , unsigned int); int (*setlease)(struct file *, long, struct file_lock **); long int (*fallocate)(struct file *, int, loff_t , loff_t ); int (*show_fdinfo)(struct seq_file *, struct file *); } ; 1555 struct inode_operations { struct dentry * (*lookup)(struct inode *, struct dentry *, unsigned int); void * (*follow_link)(struct dentry *, struct nameidata *); int (*permission)(struct inode *, int); struct posix_acl * (*get_acl)(struct inode *, int); int (*readlink)(struct dentry *, char *, int); void (*put_link)(struct dentry *, struct nameidata *, void *); int (*create)(struct inode *, struct dentry *, umode_t , bool ); int (*link)(struct dentry *, struct inode *, struct dentry *); int (*unlink)(struct inode *, struct dentry *); int (*symlink)(struct inode *, struct dentry *, const char *); int (*mkdir)(struct inode *, struct dentry *, umode_t ); int (*rmdir)(struct inode *, struct dentry *); int (*mknod)(struct inode *, struct dentry *, umode_t , dev_t ); int (*rename)(struct inode *, struct dentry *, struct inode *, struct dentry *); int (*setattr)(struct dentry *, struct iattr *); int (*getattr)(struct vfsmount *, struct dentry *, struct kstat *); int (*setxattr)(struct dentry *, const char *, const void *, size_t , int); ssize_t (*getxattr)(struct dentry *, const char *, void *, size_t ); ssize_t (*listxattr)(struct dentry *, char *, size_t ); int (*removexattr)(struct dentry *, const char *); int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 , u64 ); int (*update_time)(struct inode *, struct timespec *, int); int (*atomic_open)(struct inode *, struct dentry *, struct file *, unsigned int, umode_t , int *); int (*tmpfile)(struct inode *, struct dentry *, umode_t ); int (*set_acl)(struct inode *, struct posix_acl *, int); } ; 1600 struct super_operations { struct inode * (*alloc_inode)(struct super_block *); void (*destroy_inode)(struct inode *); void (*dirty_inode)(struct inode *, int); int (*write_inode)(struct inode *, struct writeback_control *); int (*drop_inode)(struct inode *); void (*evict_inode)(struct inode *); void (*put_super)(struct super_block *); int (*sync_fs)(struct super_block *, int); int (*freeze_fs)(struct super_block *); int (*unfreeze_fs)(struct super_block *); int (*statfs)(struct dentry *, struct kstatfs *); int (*remount_fs)(struct super_block *, int *, char *); void (*umount_begin)(struct super_block *); int (*show_options)(struct seq_file *, struct dentry *); int (*show_devname)(struct seq_file *, struct dentry *); int (*show_path)(struct seq_file *, struct dentry *); int (*show_stats)(struct seq_file *, struct dentry *); ssize_t (*quota_read)(struct super_block *, int, char *, size_t , loff_t ); ssize_t (*quota_write)(struct super_block *, int, const char *, size_t , loff_t ); int (*bdev_try_to_free_page)(struct super_block *, struct page *, gfp_t ); long int (*nr_cached_objects)(struct super_block *, int); long int (*free_cached_objects)(struct super_block *, long, int); } ; 1814 struct file_system_type { const char *name; int fs_flags; struct dentry * (*mount)(struct file_system_type *, int, const char *, void *); void (*kill_sb)(struct super_block *); struct module *owner; struct file_system_type *next; struct hlist_head fs_supers; struct lock_class_key s_lock_key; struct lock_class_key s_umount_key; struct lock_class_key s_vfs_rename_key; struct lock_class_key s_writers_key[3U]; struct lock_class_key i_lock_key; struct lock_class_key i_mutex_key; struct lock_class_key i_mutex_dir_key; } ; 80 struct disk_stats { unsigned long sectors[2U]; unsigned long ios[2U]; unsigned long merges[2U]; unsigned long ticks[2U]; unsigned long io_ticks; unsigned long time_in_queue; } ; 89 struct partition_meta_info { char uuid[37U]; u8 volname[64U]; } ; 101 struct hd_struct { sector_t start_sect; sector_t nr_sects; seqcount_t nr_sects_seq; sector_t alignment_offset; unsigned int discard_alignment; struct device __dev; struct kobject *holder_dir; int policy; int partno; struct partition_meta_info *info; int make_it_fail; unsigned long stamp; atomic_t in_flight[2U]; struct disk_stats *dkstats; atomic_t ref; struct callback_head callback_head; } ; 155 struct disk_part_tbl { struct callback_head callback_head; int len; struct hd_struct *last_lookup; struct hd_struct *part[]; } ; 162 struct disk_events ; 163 struct timer_rand_state ; 163 struct blk_integrity ; 163 struct gendisk { int major; int first_minor; int minors; char disk_name[32U]; char * (*devnode)(struct gendisk *, umode_t *); unsigned int events; unsigned int async_events; struct disk_part_tbl *part_tbl; struct hd_struct part0; const struct block_device_operations *fops; struct request_queue *queue; void *private_data; int flags; struct device *driverfs_dev; struct kobject *slave_dir; struct timer_rand_state *random; atomic_t sync_io; struct disk_events *ev; struct blk_integrity *integrity; int node_id; } ; 62 struct exception_table_entry { int insn; int fixup; } ; 352 struct proc_dir_entry ; 71 struct fprop_local_percpu { struct percpu_counter events; unsigned int period; raw_spinlock_t lock; } ; 12 enum writeback_sync_modes { WB_SYNC_NONE = 0, WB_SYNC_ALL = 1 } ; 29 struct writeback_control { long nr_to_write; long pages_skipped; loff_t range_start; loff_t range_end; enum writeback_sync_modes sync_mode; unsigned char for_kupdate; unsigned char for_background; unsigned char tagged_writepages; unsigned char for_reclaim; unsigned char range_cyclic; unsigned char for_sync; } ; 88 struct bdi_writeback ; 39 typedef int congested_fn(void *, int); 48 struct bdi_writeback { struct backing_dev_info *bdi; unsigned int nr; unsigned long last_old_flush; struct delayed_work dwork; struct list_head b_dirty; struct list_head b_io; struct list_head b_more_io; spinlock_t list_lock; } ; 63 struct backing_dev_info { struct list_head bdi_list; unsigned long ra_pages; unsigned long state; unsigned int capabilities; congested_fn *congested_fn; void *congested_data; char *name; struct percpu_counter bdi_stat[4U]; unsigned long bw_time_stamp; unsigned long dirtied_stamp; unsigned long written_stamp; unsigned long write_bandwidth; unsigned long avg_write_bandwidth; unsigned long dirty_ratelimit; unsigned long balanced_dirty_ratelimit; struct fprop_local_percpu completions; int dirty_exceeded; unsigned int min_ratio; unsigned int max_ratio; unsigned int max_prop_frac; struct bdi_writeback wb; spinlock_t wb_lock; struct list_head work_list; struct device *dev; struct timer_list laptop_mode_wb_timer; struct dentry *debug_dir; struct dentry *debug_stats; } ; 11 typedef void * mempool_alloc_t(gfp_t , void *); 12 typedef void mempool_free_t(void *, void *); 13 struct mempool_s { spinlock_t lock; int min_nr; int curr_nr; void **elements; void *pool_data; mempool_alloc_t *alloc; mempool_free_t *free; wait_queue_head_t wait; } ; 24 typedef struct mempool_s mempool_t; 77 union __anonunion____missing_field_name_199 { struct list_head q_node; struct kmem_cache *__rcu_icq_cache; } ; 77 union __anonunion____missing_field_name_200 { struct hlist_node ioc_node; struct callback_head __rcu_head; } ; 77 struct io_cq { struct request_queue *q; struct io_context *ioc; union __anonunion____missing_field_name_199 __annonCompField70; union __anonunion____missing_field_name_200 __annonCompField71; unsigned int flags; } ; 92 struct io_context { atomic_long_t refcount; atomic_t active_ref; atomic_t nr_tasks; spinlock_t lock; unsigned short ioprio; int nr_batch_requests; unsigned long last_waited; struct radix_tree_root icq_tree; struct io_cq *icq_hint; struct hlist_head icq_list; struct work_struct release_work; } ; 269 struct bio_integrity_payload { struct bio *bip_bio; struct bvec_iter bip_iter; void *bip_buf; bio_end_io_t *bip_end_io; unsigned short bip_slab; unsigned short bip_vcnt; unsigned char bip_owns_buf; struct work_struct bip_work; struct bio_vec *bip_vec; struct bio_vec bip_inline_vecs[0U]; } ; 479 struct bio_list { struct bio *head; struct bio *tail; } ; 600 struct bio_set { struct kmem_cache *bio_slab; unsigned int front_pad; mempool_t *bio_pool; mempool_t *bvec_pool; mempool_t *bio_integrity_pool; mempool_t *bvec_integrity_pool; spinlock_t rescue_lock; struct bio_list rescue_list; struct work_struct rescue_work; struct workqueue_struct *rescue_workqueue; } ; 63 struct bsg_class_device { struct device *class_dev; struct device *parent; int minor; struct request_queue *queue; struct kref ref; void (*release)(struct device *); } ; 22 struct elevator_queue ; 25 struct request ; 27 struct blkcg_gq ; 49 typedef void rq_end_io_fn(struct request *, int); 50 struct request_list { struct request_queue *q; struct blkcg_gq *blkg; int count[2U]; int starved[2U]; mempool_t *rq_pool; wait_queue_head_t wait[2U]; unsigned int flags; } ; 69 enum rq_cmd_type_bits { REQ_TYPE_FS = 1, REQ_TYPE_BLOCK_PC = 2, REQ_TYPE_SENSE = 3, REQ_TYPE_PM_SUSPEND = 4, REQ_TYPE_PM_RESUME = 5, REQ_TYPE_PM_SHUTDOWN = 6, REQ_TYPE_SPECIAL = 7, REQ_TYPE_ATA_TASKFILE = 8, REQ_TYPE_ATA_PC = 9 } ; 81 union __anonunion____missing_field_name_201 { struct call_single_data csd; struct work_struct mq_flush_work; } ; 81 struct blk_mq_ctx ; 81 union __anonunion____missing_field_name_202 { struct rb_node rb_node; void *completion_data; } ; 81 struct __anonstruct_elv_204 { struct io_cq *icq; void *priv[2U]; } ; 81 struct __anonstruct_flush_205 { unsigned int seq; struct list_head list; rq_end_io_fn *saved_end_io; } ; 81 union __anonunion____missing_field_name_203 { struct __anonstruct_elv_204 elv; struct __anonstruct_flush_205 flush; } ; 81 struct request { struct list_head queuelist; union __anonunion____missing_field_name_201 __annonCompField72; struct request_queue *q; struct blk_mq_ctx *mq_ctx; u64 cmd_flags; enum rq_cmd_type_bits cmd_type; unsigned long atomic_flags; int cpu; unsigned int __data_len; sector_t __sector; struct bio *bio; struct bio *biotail; struct hlist_node hash; union __anonunion____missing_field_name_202 __annonCompField73; union __anonunion____missing_field_name_203 __annonCompField74; struct gendisk *rq_disk; struct hd_struct *part; unsigned long start_time; struct request_list *rl; unsigned long long start_time_ns; unsigned long long io_start_time_ns; unsigned short nr_phys_segments; unsigned short nr_integrity_segments; unsigned short ioprio; void *special; char *buffer; int tag; int errors; unsigned char __cmd[16U]; unsigned char *cmd; unsigned short cmd_len; unsigned int extra_len; unsigned int sense_len; unsigned int resid_len; void *sense; unsigned long deadline; struct list_head timeout_list; unsigned int timeout; int retries; rq_end_io_fn *end_io; void *end_io_data; struct request *next_rq; } ; 113 struct elevator_type ; 12 typedef int elevator_merge_fn(struct request_queue *, struct request **, struct bio *); 15 typedef void elevator_merge_req_fn(struct request_queue *, struct request *, struct request *); 17 typedef void elevator_merged_fn(struct request_queue *, struct request *, int); 19 typedef int elevator_allow_merge_fn(struct request_queue *, struct request *, struct bio *); 21 typedef void elevator_bio_merged_fn(struct request_queue *, struct request *, struct bio *); 24 typedef int elevator_dispatch_fn(struct request_queue *, int); 26 typedef void elevator_add_req_fn(struct request_queue *, struct request *); 27 typedef struct request * elevator_request_list_fn(struct request_queue *, struct request *); 28 typedef void elevator_completed_req_fn(struct request_queue *, struct request *); 29 typedef int elevator_may_queue_fn(struct request_queue *, int); 31 typedef void elevator_init_icq_fn(struct io_cq *); 32 typedef void elevator_exit_icq_fn(struct io_cq *); 33 typedef int elevator_set_req_fn(struct request_queue *, struct request *, struct bio *, gfp_t ); 35 typedef void elevator_put_req_fn(struct request *); 36 typedef void elevator_activate_req_fn(struct request_queue *, struct request *); 37 typedef void elevator_deactivate_req_fn(struct request_queue *, struct request *); 39 typedef int elevator_init_fn(struct request_queue *, struct elevator_type *); 41 typedef void elevator_exit_fn(struct elevator_queue *); 42 struct elevator_ops { elevator_merge_fn *elevator_merge_fn; elevator_merged_fn *elevator_merged_fn; elevator_merge_req_fn *elevator_merge_req_fn; elevator_allow_merge_fn *elevator_allow_merge_fn; elevator_bio_merged_fn *elevator_bio_merged_fn; elevator_dispatch_fn *elevator_dispatch_fn; elevator_add_req_fn *elevator_add_req_fn; elevator_activate_req_fn *elevator_activate_req_fn; elevator_deactivate_req_fn *elevator_deactivate_req_fn; elevator_completed_req_fn *elevator_completed_req_fn; elevator_request_list_fn *elevator_former_req_fn; elevator_request_list_fn *elevator_latter_req_fn; elevator_init_icq_fn *elevator_init_icq_fn; elevator_exit_icq_fn *elevator_exit_icq_fn; elevator_set_req_fn *elevator_set_req_fn; elevator_put_req_fn *elevator_put_req_fn; elevator_may_queue_fn *elevator_may_queue_fn; elevator_init_fn *elevator_init_fn; elevator_exit_fn *elevator_exit_fn; } ; 72 struct elv_fs_entry { struct attribute attr; ssize_t (*show)(struct elevator_queue *, char *); ssize_t (*store)(struct elevator_queue *, const char *, size_t ); } ; 80 struct elevator_type { struct kmem_cache *icq_cache; struct elevator_ops ops; size_t icq_size; size_t icq_align; struct elv_fs_entry *elevator_attrs; char elevator_name[16U]; struct module *elevator_owner; char icq_cache_name[21U]; struct list_head list; } ; 101 struct elevator_queue { struct elevator_type *type; void *elevator_data; struct kobject kobj; struct mutex sysfs_lock; unsigned char registered; struct hlist_head hash[64U]; } ; 223 typedef void request_fn_proc(struct request_queue *); 224 typedef void make_request_fn(struct request_queue *, struct bio *); 225 typedef int prep_rq_fn(struct request_queue *, struct request *); 226 typedef void unprep_rq_fn(struct request_queue *, struct request *); 227 struct bvec_merge_data { struct block_device *bi_bdev; sector_t bi_sector; unsigned int bi_size; unsigned long bi_rw; } ; 235 typedef int merge_bvec_fn(struct request_queue *, struct bvec_merge_data *, struct bio_vec *); 237 typedef void softirq_done_fn(struct request *); 238 typedef int dma_drain_needed_fn(struct request *); 239 typedef int lld_busy_fn(struct request_queue *); 240 typedef int bsg_job_fn(struct bsg_job *); 241 enum blk_eh_timer_return { BLK_EH_NOT_HANDLED = 0, BLK_EH_HANDLED = 1, BLK_EH_RESET_TIMER = 2 } ; 248 typedef enum blk_eh_timer_return rq_timed_out_fn(struct request *); 254 struct blk_queue_tag { struct request **tag_index; unsigned long *tag_map; int busy; int max_depth; int real_max_depth; atomic_t refcnt; } ; 263 struct queue_limits { unsigned long bounce_pfn; unsigned long seg_boundary_mask; unsigned int max_hw_sectors; unsigned int max_sectors; unsigned int max_segment_size; unsigned int physical_block_size; unsigned int alignment_offset; unsigned int io_min; unsigned int io_opt; unsigned int max_discard_sectors; unsigned int max_write_same_sectors; unsigned int discard_granularity; unsigned int discard_alignment; unsigned short logical_block_size; unsigned short max_segments; unsigned short max_integrity_segments; unsigned char misaligned; unsigned char discard_misaligned; unsigned char cluster; unsigned char discard_zeroes_data; unsigned char raid_partial_stripes_expensive; } ; 293 struct blk_mq_ops ; 293 struct blk_mq_hw_ctx ; 293 struct throtl_data ; 293 struct request_queue { struct list_head queue_head; struct request *last_merge; struct elevator_queue *elevator; int nr_rqs[2U]; int nr_rqs_elvpriv; struct request_list root_rl; request_fn_proc *request_fn; make_request_fn *make_request_fn; prep_rq_fn *prep_rq_fn; unprep_rq_fn *unprep_rq_fn; merge_bvec_fn *merge_bvec_fn; softirq_done_fn *softirq_done_fn; rq_timed_out_fn *rq_timed_out_fn; dma_drain_needed_fn *dma_drain_needed; lld_busy_fn *lld_busy_fn; struct blk_mq_ops *mq_ops; unsigned int *mq_map; struct blk_mq_ctx *queue_ctx; unsigned int nr_queues; struct blk_mq_hw_ctx **queue_hw_ctx; unsigned int nr_hw_queues; sector_t end_sector; struct request *boundary_rq; struct delayed_work delay_work; struct backing_dev_info backing_dev_info; void *queuedata; unsigned long queue_flags; int id; gfp_t bounce_gfp; spinlock_t __queue_lock; spinlock_t *queue_lock; struct kobject kobj; struct kobject mq_kobj; struct device *dev; int rpm_status; unsigned int nr_pending; unsigned long nr_requests; unsigned int nr_congestion_on; unsigned int nr_congestion_off; unsigned int nr_batching; unsigned int dma_drain_size; void *dma_drain_buffer; unsigned int dma_pad_mask; unsigned int dma_alignment; struct blk_queue_tag *queue_tags; struct list_head tag_busy_list; unsigned int nr_sorted; unsigned int in_flight[2U]; unsigned int request_fn_active; unsigned int rq_timeout; struct timer_list timeout; struct list_head timeout_list; struct list_head icq_list; unsigned long blkcg_pols[1U]; struct blkcg_gq *root_blkg; struct list_head blkg_list; struct queue_limits limits; unsigned int sg_timeout; unsigned int sg_reserved_size; int node; unsigned int flush_flags; unsigned char flush_not_queueable; unsigned char flush_queue_delayed; unsigned char flush_pending_idx; unsigned char flush_running_idx; unsigned long flush_pending_since; struct list_head flush_queue[2U]; struct list_head flush_data_in_flight; struct request *flush_rq; spinlock_t mq_flush_lock; struct mutex sysfs_lock; int bypass_depth; bsg_job_fn *bsg_job_fn; int bsg_job_size; struct bsg_class_device bsg_dev; struct throtl_data *td; struct callback_head callback_head; wait_queue_head_t mq_freeze_wq; struct percpu_counter mq_usage_counter; struct list_head all_q_node; } ; 1019 struct blk_plug { unsigned long magic; struct list_head list; struct list_head mq_list; struct list_head cb_list; } ; 1393 struct blk_integrity_exchg { void *prot_buf; void *data_buf; sector_t sector; unsigned int data_size; unsigned short sector_size; const char *disk_name; } ; 1425 typedef void integrity_gen_fn(struct blk_integrity_exchg *); 1426 typedef int integrity_vrfy_fn(struct blk_integrity_exchg *); 1427 typedef void integrity_set_tag_fn(void *, void *, unsigned int); 1428 typedef void integrity_get_tag_fn(void *, void *, unsigned int); 1429 struct blk_integrity { integrity_gen_fn *generate_fn; integrity_vrfy_fn *verify_fn; integrity_set_tag_fn *set_tag_fn; integrity_get_tag_fn *get_tag_fn; unsigned short flags; unsigned short tuple_size; unsigned short sector_size; unsigned short tag_size; const char *name; struct kobject kobj; } ; 1488 struct block_device_operations { int (*open)(struct block_device *, fmode_t ); void (*release)(struct gendisk *, fmode_t ); int (*ioctl)(struct block_device *, fmode_t , unsigned int, unsigned long); int (*compat_ioctl)(struct block_device *, fmode_t , unsigned int, unsigned long); int (*direct_access)(struct block_device *, sector_t , void **, unsigned long *); unsigned int (*check_events)(struct gendisk *, unsigned int); int (*media_changed)(struct gendisk *); void (*unlock_native_capacity)(struct gendisk *); int (*revalidate_disk)(struct gendisk *); int (*getgeo)(struct block_device *, struct hd_geometry *); void (*swap_slot_free_notify)(struct block_device *, unsigned long); struct module *owner; } ; 1578 struct scsi_host_cmd_pool ; 1586 struct scsi_host_template { struct module *module; const char *name; int (*detect)(struct scsi_host_template *); int (*release)(struct Scsi_Host *); const char * (*info)(struct Scsi_Host *); int (*ioctl)(struct scsi_device *, int, void *); int (*compat_ioctl)(struct scsi_device *, int, void *); int (*queuecommand)(struct Scsi_Host *, struct scsi_cmnd *); int (*transfer_response)(struct scsi_cmnd *, void (*)(struct scsi_cmnd *)); int (*eh_abort_handler)(struct scsi_cmnd *); int (*eh_device_reset_handler)(struct scsi_cmnd *); int (*eh_target_reset_handler)(struct scsi_cmnd *); int (*eh_bus_reset_handler)(struct scsi_cmnd *); int (*eh_host_reset_handler)(struct scsi_cmnd *); int (*slave_alloc)(struct scsi_device *); int (*slave_configure)(struct scsi_device *); void (*slave_destroy)(struct scsi_device *); int (*target_alloc)(struct scsi_target *); void (*target_destroy)(struct scsi_target *); int (*scan_finished)(struct Scsi_Host *, unsigned long); void (*scan_start)(struct Scsi_Host *); int (*change_queue_depth)(struct scsi_device *, int, int); int (*change_queue_type)(struct scsi_device *, int); int (*bios_param)(struct scsi_device *, struct block_device *, sector_t , int *); void (*unlock_native_capacity)(struct scsi_device *); int (*show_info)(struct seq_file *, struct Scsi_Host *); int (*write_info)(struct Scsi_Host *, char *, int); enum blk_eh_timer_return (*eh_timed_out)(struct scsi_cmnd *); int (*host_reset)(struct Scsi_Host *, int); const char *proc_name; struct proc_dir_entry *proc_dir; int can_queue; int this_id; unsigned short sg_tablesize; unsigned short sg_prot_tablesize; unsigned short max_sectors; unsigned long dma_boundary; short cmd_per_lun; unsigned char present; unsigned char supported_mode; unsigned char unchecked_isa_dma; unsigned char use_clustering; unsigned char emulated; unsigned char skip_settle_delay; unsigned char ordered_tag; unsigned char no_write_same; unsigned char no_async_abort; unsigned int max_host_blocked; struct device_attribute **shost_attrs; struct device_attribute **sdev_attrs; struct list_head legacy_hosts; u64 vendor_id; } ; 528 enum scsi_host_state { SHOST_CREATED = 1, SHOST_RUNNING = 2, SHOST_CANCEL = 3, SHOST_DEL = 4, SHOST_RECOVERY = 5, SHOST_CANCEL_RECOVERY = 6, SHOST_DEL_RECOVERY = 7 } ; 538 struct Scsi_Host { struct list_head __devices; struct list_head __targets; struct scsi_host_cmd_pool *cmd_pool; spinlock_t free_list_lock; struct list_head free_list; struct list_head starved_list; spinlock_t default_lock; spinlock_t *host_lock; struct mutex scan_mutex; struct list_head eh_cmd_q; struct task_struct *ehandler; struct completion *eh_action; wait_queue_head_t host_wait; struct scsi_host_template *hostt; struct scsi_transport_template *transportt; struct blk_queue_tag *bqt; unsigned int host_busy; unsigned int host_failed; unsigned int host_eh_scheduled; unsigned int host_no; int eh_deadline; unsigned long last_reset; unsigned int max_id; unsigned int max_lun; unsigned int max_channel; unsigned int unique_id; unsigned short max_cmd_len; int this_id; int can_queue; short cmd_per_lun; unsigned short sg_tablesize; unsigned short sg_prot_tablesize; unsigned short max_sectors; unsigned long dma_boundary; unsigned long cmd_serial_number; unsigned char active_mode; unsigned char unchecked_isa_dma; unsigned char use_clustering; unsigned char use_blk_tcq; unsigned char host_self_blocked; unsigned char reverse_ordering; unsigned char ordered_tag; unsigned char tmf_in_progress; unsigned char async_scan; unsigned char eh_noresume; unsigned char no_write_same; char work_q_name[20U]; struct workqueue_struct *work_q; struct workqueue_struct *tmf_work_q; unsigned int host_blocked; unsigned int max_host_blocked; unsigned int prot_capabilities; unsigned char prot_guard_type; struct request_queue *uspace_req_q; unsigned long base; unsigned long io_port; unsigned char n_io_port; unsigned char dma_channel; unsigned int irq; enum scsi_host_state shost_state; struct device shost_gendev; struct device shost_dev; struct list_head sht_legacy_list; void *shost_data; struct device *dma_dev; unsigned long hostdata[0U]; } ; 947 struct scsi_sense_hdr ; 25 enum scsi_device_state { SDEV_CREATED = 1, SDEV_RUNNING = 2, SDEV_CANCEL = 3, SDEV_DEL = 4, SDEV_QUIESCE = 5, SDEV_OFFLINE = 6, SDEV_TRANSPORT_OFFLINE = 7, SDEV_BLOCK = 8, SDEV_CREATED_BLOCK = 9 } ; 71 struct scsi_dh_data ; 71 struct scsi_device { struct Scsi_Host *host; struct request_queue *request_queue; struct list_head siblings; struct list_head same_target_siblings; unsigned int device_busy; spinlock_t list_lock; struct list_head cmd_list; struct list_head starved_entry; struct scsi_cmnd *current_cmnd; unsigned short queue_depth; unsigned short max_queue_depth; unsigned short last_queue_full_depth; unsigned short last_queue_full_count; unsigned long last_queue_full_time; unsigned long queue_ramp_up_period; unsigned long last_queue_ramp_up; unsigned int id; unsigned int lun; unsigned int channel; unsigned int manufacturer; unsigned int sector_size; void *hostdata; char type; char scsi_level; char inq_periph_qual; unsigned char inquiry_len; unsigned char *inquiry; const char *vendor; const char *model; const char *rev; unsigned char current_tag; struct scsi_target *sdev_target; unsigned int sdev_bflags; unsigned int eh_timeout; unsigned char writeable; unsigned char removable; unsigned char changed; unsigned char busy; unsigned char lockable; unsigned char locked; unsigned char borken; unsigned char disconnect; unsigned char soft_reset; unsigned char sdtr; unsigned char wdtr; unsigned char ppr; unsigned char tagged_supported; unsigned char simple_tags; unsigned char ordered_tags; unsigned char was_reset; unsigned char expecting_cc_ua; unsigned char use_10_for_rw; unsigned char use_10_for_ms; unsigned char no_report_opcodes; unsigned char no_write_same; unsigned char use_16_for_rw; unsigned char skip_ms_page_8; unsigned char skip_ms_page_3f; unsigned char skip_vpd_pages; unsigned char use_192_bytes_for_3f; unsigned char no_start_on_add; unsigned char allow_restart; unsigned char manage_start_stop; unsigned char start_stop_pwr_cond; unsigned char no_uld_attach; unsigned char select_no_atn; unsigned char fix_capacity; unsigned char guess_capacity; unsigned char retry_hwerror; unsigned char last_sector_bug; unsigned char no_read_disc_info; unsigned char no_read_capacity_16; unsigned char try_rc_10_first; unsigned char is_visible; unsigned char wce_default_on; unsigned char no_dif; atomic_t disk_events_disable_depth; unsigned long supported_events[1U]; unsigned long pending_events[1U]; struct list_head event_list; struct work_struct event_work; unsigned int device_blocked; unsigned int max_device_blocked; atomic_t iorequest_cnt; atomic_t iodone_cnt; atomic_t ioerr_cnt; struct device sdev_gendev; struct device sdev_dev; struct execute_work ew; struct work_struct requeue_work; struct scsi_dh_data *scsi_dh_data; enum scsi_device_state sdev_state; unsigned long sdev_data[0U]; } ; 197 struct scsi_dh_devlist { char *vendor; char *model; } ; 204 struct scsi_device_handler { struct list_head list; struct module *module; const char *name; const struct scsi_dh_devlist *devlist; int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *); int (*attach)(struct scsi_device *); void (*detach)(struct scsi_device *); int (*activate)(struct scsi_device *, void (*)(void *, int), void *); int (*prep_fn)(struct scsi_device *, struct request *); int (*set_params)(struct scsi_device *, const char *); bool (*match)(struct scsi_device *); } ; 220 struct scsi_dh_data { struct scsi_device_handler *scsi_dh; struct scsi_device *sdev; struct kref kref; char buf[0U]; } ; 227 enum scsi_target_state { STARGET_CREATED = 1, STARGET_RUNNING = 2, STARGET_DEL = 3 } ; 233 struct scsi_target { struct scsi_device *starget_sdev_user; struct list_head siblings; struct list_head devices; struct device dev; unsigned int reap_ref; unsigned int channel; unsigned int id; unsigned char create; unsigned char single_lun; unsigned char pdt_1f_for_no_lun; unsigned char no_report_luns; unsigned char expecting_lun_change; unsigned int target_busy; unsigned int can_queue; unsigned int target_blocked; unsigned int max_target_blocked; char scsi_level; struct execute_work ew; enum scsi_target_state state; void *hostdata; unsigned long starget_data[0U]; } ; 518 struct scsi_transport_template { struct transport_container host_attrs; struct transport_container target_attrs; struct transport_container device_attrs; int (*user_scan)(struct Scsi_Host *, uint , uint , uint ); int device_size; int device_private_offset; int target_size; int target_private_offset; int host_size; unsigned char create_work_queue; void (*eh_strategy_handler)(struct Scsi_Host *); enum blk_eh_timer_return (*eh_timed_out)(struct scsi_cmnd *); int (*it_nexus_response)(struct Scsi_Host *, u64 , int); int (*tsk_mgmt_response)(struct Scsi_Host *, u64 , u64 , int); } ; 132 struct dma_attrs { unsigned long flags[1U]; } ; 70 struct dma_map_ops { void * (*alloc)(struct device *, size_t , dma_addr_t *, gfp_t , struct dma_attrs *); void (*free)(struct device *, size_t , void *, dma_addr_t , struct dma_attrs *); int (*mmap)(struct device *, struct vm_area_struct *, void *, dma_addr_t , size_t , struct dma_attrs *); int (*get_sgtable)(struct device *, struct sg_table *, void *, dma_addr_t , size_t , struct dma_attrs *); dma_addr_t (*map_page)(struct device *, struct page *, unsigned long, size_t , enum dma_data_direction , struct dma_attrs *); void (*unmap_page)(struct device *, dma_addr_t , size_t , enum dma_data_direction , struct dma_attrs *); int (*map_sg)(struct device *, struct scatterlist *, int, enum dma_data_direction , struct dma_attrs *); void (*unmap_sg)(struct device *, struct scatterlist *, int, enum dma_data_direction , struct dma_attrs *); void (*sync_single_for_cpu)(struct device *, dma_addr_t , size_t , enum dma_data_direction ); void (*sync_single_for_device)(struct device *, dma_addr_t , size_t , enum dma_data_direction ); void (*sync_sg_for_cpu)(struct device *, struct scatterlist *, int, enum dma_data_direction ); void (*sync_sg_for_device)(struct device *, struct scatterlist *, int, enum dma_data_direction ); int (*mapping_error)(struct device *, dma_addr_t ); int (*dma_supported)(struct device *, u64 ); int (*set_dma_mask)(struct device *, u64 ); int is_phys; } ; 236 struct scsi_data_buffer { struct sg_table table; unsigned int length; int resid; } ; 37 struct scsi_pointer { char *ptr; int this_residual; struct scatterlist *buffer; int buffers_residual; dma_addr_t dma_handle; volatile int Status; volatile int Message; volatile int have_data_in; volatile int sent_command; volatile int phase; } ; 53 struct scsi_cmnd { struct scsi_device *device; struct list_head list; struct list_head eh_entry; struct delayed_work abort_work; int eh_eflags; unsigned long serial_number; unsigned long jiffies_at_alloc; int retries; int allowed; unsigned char prot_op; unsigned char prot_type; unsigned short cmd_len; enum dma_data_direction sc_data_direction; unsigned char *cmnd; struct scsi_data_buffer sdb; struct scsi_data_buffer *prot_sdb; unsigned int underflow; unsigned int transfersize; struct request *request; unsigned char *sense_buffer; void (*scsi_done)(struct scsi_cmnd *); struct scsi_pointer SCp; unsigned char *host_scribble; int result; unsigned char tag; } ; 119 struct sk_buff ; 38 typedef s32 dma_cookie_t; 15 typedef u64 netdev_features_t; 18 struct nf_conntrack { atomic_t use; } ; 136 struct nf_bridge_info { atomic_t use; unsigned int mask; struct net_device *physindev; struct net_device *physoutdev; unsigned long data[4U]; } ; 146 struct sk_buff_head { struct sk_buff *next; struct sk_buff *prev; __u32 qlen; spinlock_t lock; } ; 354 typedef unsigned int sk_buff_data_t; 355 struct sec_path ; 355 struct __anonstruct____missing_field_name_213 { __u16 csum_start; __u16 csum_offset; } ; 355 union __anonunion____missing_field_name_212 { __wsum csum; struct __anonstruct____missing_field_name_213 __annonCompField76; } ; 355 union __anonunion____missing_field_name_214 { unsigned int napi_id; dma_cookie_t dma_cookie; } ; 355 union __anonunion____missing_field_name_215 { __u32 mark; __u32 dropcount; __u32 reserved_tailroom; } ; 355 struct sk_buff { struct sk_buff *next; struct sk_buff *prev; ktime_t tstamp; struct sock *sk; struct net_device *dev; char cb[48U]; unsigned long _skb_refdst; struct sec_path *sp; unsigned int len; unsigned int data_len; __u16 mac_len; __u16 hdr_len; union __anonunion____missing_field_name_212 __annonCompField77; __u32 priority; unsigned char local_df; unsigned char cloned; unsigned char ip_summed; unsigned char nohdr; unsigned char nfctinfo; unsigned char pkt_type; unsigned char fclone; unsigned char ipvs_property; unsigned char peeked; unsigned char nf_trace; __be16 protocol; void (*destructor)(struct sk_buff *); struct nf_conntrack *nfct; struct nf_bridge_info *nf_bridge; int skb_iif; __u32 rxhash; __be16 vlan_proto; __u16 vlan_tci; __u16 tc_index; __u16 tc_verd; __u16 queue_mapping; unsigned char ndisc_nodetype; unsigned char pfmemalloc; unsigned char ooo_okay; unsigned char l4_rxhash; unsigned char wifi_acked_valid; unsigned char wifi_acked; unsigned char no_fcs; unsigned char head_frag; unsigned char encapsulation; union __anonunion____missing_field_name_214 __annonCompField78; __u32 secmark; union __anonunion____missing_field_name_215 __annonCompField79; __be16 inner_protocol; __u16 inner_transport_header; __u16 inner_network_header; __u16 inner_mac_header; __u16 transport_header; __u16 network_header; __u16 mac_header; sk_buff_data_t tail; sk_buff_data_t end; unsigned char *head; unsigned char *data; unsigned int truesize; atomic_t users; } ; 578 struct dst_entry ; 3157 struct mnt_namespace ; 3158 struct ipc_namespace ; 3159 struct nsproxy { atomic_t count; struct uts_namespace *uts_ns; struct ipc_namespace *ipc_ns; struct mnt_namespace *mnt_ns; struct pid_namespace *pid_ns_for_children; struct net *net_ns; } ; 41 struct nlmsghdr { __u32 nlmsg_len; __u16 nlmsg_type; __u16 nlmsg_flags; __u32 nlmsg_seq; __u32 nlmsg_pid; } ; 145 struct nlattr { __u16 nla_len; __u16 nla_type; } ; 102 struct netlink_callback { struct sk_buff *skb; const struct nlmsghdr *nlh; int (*dump)(struct sk_buff *, struct netlink_callback *); int (*done)(struct netlink_callback *); void *data; struct module *module; u16 family; u16 min_dump_alloc; unsigned int prev_seq; unsigned int seq; long args[6U]; } ; 13 typedef unsigned long kernel_ulong_t; 14 struct pci_device_id { __u32 vendor; __u32 device; __u32 subvendor; __u32 subdevice; __u32 class; __u32 class_mask; kernel_ulong_t driver_data; } ; 186 struct acpi_device_id { __u8 id[9U]; kernel_ulong_t driver_data; } ; 219 struct of_device_id { char name[32U]; char type[32U]; char compatible[128U]; const void *data; } ; 69 struct hotplug_slot ; 69 struct pci_slot { struct pci_bus *bus; struct list_head list; struct hotplug_slot *hotplug; unsigned char number; struct kobject kobj; } ; 110 typedef int pci_power_t; 137 typedef unsigned int pci_channel_state_t; 138 enum pci_channel_state { pci_channel_io_normal = 1, pci_channel_io_frozen = 2, pci_channel_io_perm_failure = 3 } ; 163 typedef unsigned short pci_dev_flags_t; 180 typedef unsigned short pci_bus_flags_t; 237 struct pcie_link_state ; 238 struct pci_vpd ; 239 struct pci_sriov ; 240 struct pci_ats ; 241 struct pci_driver ; 241 union __anonunion____missing_field_name_219 { struct pci_sriov *sriov; struct pci_dev *physfn; } ; 241 struct pci_dev { struct list_head bus_list; struct pci_bus *bus; struct pci_bus *subordinate; void *sysdata; struct proc_dir_entry *procent; struct pci_slot *slot; unsigned int devfn; unsigned short vendor; unsigned short device; unsigned short subsystem_vendor; unsigned short subsystem_device; unsigned int class; u8 revision; u8 hdr_type; u8 pcie_cap; u8 msi_cap; u8 msix_cap; unsigned char pcie_mpss; u8 rom_base_reg; u8 pin; u16 pcie_flags_reg; struct pci_driver *driver; u64 dma_mask; struct device_dma_parameters dma_parms; pci_power_t current_state; u8 pm_cap; unsigned char pme_support; unsigned char pme_interrupt; unsigned char pme_poll; unsigned char d1_support; unsigned char d2_support; unsigned char no_d1d2; unsigned char no_d3cold; unsigned char d3cold_allowed; unsigned char mmio_always_on; unsigned char wakeup_prepared; unsigned char runtime_d3cold; unsigned int d3_delay; unsigned int d3cold_delay; struct pcie_link_state *link_state; pci_channel_state_t error_state; struct device dev; int cfg_size; unsigned int irq; struct resource resource[17U]; bool match_driver; unsigned char transparent; unsigned char multifunction; unsigned char is_added; unsigned char is_busmaster; unsigned char no_msi; unsigned char block_cfg_access; unsigned char broken_parity_status; unsigned char irq_reroute_variant; unsigned char msi_enabled; unsigned char msix_enabled; unsigned char ari_enabled; unsigned char is_managed; unsigned char needs_freset; unsigned char state_saved; unsigned char is_physfn; unsigned char is_virtfn; unsigned char reset_fn; unsigned char is_hotplug_bridge; unsigned char __aer_firmware_first_valid; unsigned char __aer_firmware_first; unsigned char broken_intx_masking; unsigned char io_window_1k; pci_dev_flags_t dev_flags; atomic_t enable_cnt; u32 saved_config_space[16U]; struct hlist_head saved_cap_space; struct bin_attribute *rom_attr; int rom_attr_enabled; struct bin_attribute *res_attr[17U]; struct bin_attribute *res_attr_wc[17U]; struct list_head msi_list; const struct attribute_group **msi_irq_groups; struct pci_vpd *vpd; union __anonunion____missing_field_name_219 __annonCompField80; struct pci_ats *ats; phys_addr_t rom; size_t romlen; } ; 429 struct pci_ops ; 429 struct msi_chip ; 429 struct pci_bus { struct list_head node; struct pci_bus *parent; struct list_head children; struct list_head devices; struct pci_dev *self; struct list_head slots; struct resource *resource[4U]; struct list_head resources; struct resource busn_res; struct pci_ops *ops; struct msi_chip *msi; void *sysdata; struct proc_dir_entry *procdir; unsigned char number; unsigned char primary; unsigned char max_bus_speed; unsigned char cur_bus_speed; char name[48U]; unsigned short bridge_ctl; pci_bus_flags_t bus_flags; struct device *bridge; struct device dev; struct bin_attribute *legacy_io; struct bin_attribute *legacy_mem; unsigned char is_added; } ; 534 struct pci_ops { int (*read)(struct pci_bus *, unsigned int, int, int, u32 *); int (*write)(struct pci_bus *, unsigned int, int, int, u32 ); } ; 555 struct pci_dynids { spinlock_t lock; struct list_head list; } ; 569 typedef unsigned int pci_ers_result_t; 579 struct pci_error_handlers { pci_ers_result_t (*error_detected)(struct pci_dev *, enum pci_channel_state ); pci_ers_result_t (*mmio_enabled)(struct pci_dev *); pci_ers_result_t (*link_reset)(struct pci_dev *); pci_ers_result_t (*slot_reset)(struct pci_dev *); void (*resume)(struct pci_dev *); } ; 609 struct pci_driver { struct list_head node; const char *name; const struct pci_device_id *id_table; int (*probe)(struct pci_dev *, const struct pci_device_id *); void (*remove)(struct pci_dev *); int (*suspend)(struct pci_dev *, pm_message_t ); int (*suspend_late)(struct pci_dev *, pm_message_t ); int (*resume_early)(struct pci_dev *); int (*resume)(struct pci_dev *); void (*shutdown)(struct pci_dev *); int (*sriov_configure)(struct pci_dev *, int); const struct pci_error_handlers *err_handler; struct device_driver driver; struct pci_dynids dynids; } ; 17 struct dma_pool ; 39 struct msix_entry { u32 vector; u16 entry; } ; 1809 struct ethhdr { unsigned char h_dest[6U]; unsigned char h_source[6U]; __be16 h_proto; } ; 15 typedef __u64 Elf64_Addr; 16 typedef __u16 Elf64_Half; 20 typedef __u32 Elf64_Word; 21 typedef __u64 Elf64_Xword; 190 struct elf64_sym { Elf64_Word st_name; unsigned char st_info; unsigned char st_other; Elf64_Half st_shndx; Elf64_Addr st_value; Elf64_Xword st_size; } ; 198 typedef struct elf64_sym Elf64_Sym; 48 struct kernel_param ; 53 struct kernel_param_ops { unsigned int flags; int (*set)(const char *, const struct kernel_param *); int (*get)(char *, const struct kernel_param *); void (*free)(void *); } ; 58 struct kparam_string ; 58 struct kparam_array ; 58 union __anonunion____missing_field_name_224 { void *arg; const struct kparam_string *str; const struct kparam_array *arr; } ; 58 struct kernel_param { const char *name; const struct kernel_param_ops *ops; u16 perm; s16 level; union __anonunion____missing_field_name_224 __annonCompField81; } ; 70 struct kparam_string { unsigned int maxlen; char *string; } ; 76 struct kparam_array { unsigned int max; unsigned int elemsize; unsigned int *num; const struct kernel_param_ops *ops; void *elem; } ; 463 struct tracepoint ; 464 struct tracepoint_func { void *func; void *data; } ; 29 struct tracepoint { const char *name; struct static_key key; void (*regfunc)(); void (*unregfunc)(); struct tracepoint_func *funcs; } ; 92 struct mod_arch_specific { } ; 36 struct module_param_attrs ; 36 struct module_kobject { struct kobject kobj; struct module *mod; struct kobject *drivers_dir; struct module_param_attrs *mp; struct completion *kobj_completion; } ; 46 struct module_attribute { struct attribute attr; ssize_t (*show)(struct module_attribute *, struct module_kobject *, char *); ssize_t (*store)(struct module_attribute *, struct module_kobject *, const char *, size_t ); void (*setup)(struct module *, const char *); int (*test)(struct module *); void (*free)(struct module *); } ; 208 enum module_state { MODULE_STATE_LIVE = 0, MODULE_STATE_COMING = 1, MODULE_STATE_GOING = 2, MODULE_STATE_UNFORMED = 3 } ; 215 struct module_ref { unsigned long incs; unsigned long decs; } ; 229 struct module_sect_attrs ; 229 struct module_notes_attrs ; 229 struct ftrace_event_call ; 229 struct module { enum module_state state; struct list_head list; char name[56U]; struct module_kobject mkobj; struct module_attribute *modinfo_attrs; const char *version; const char *srcversion; struct kobject *holders_dir; const struct kernel_symbol *syms; const unsigned long *crcs; unsigned int num_syms; struct kernel_param *kp; unsigned int num_kp; unsigned int num_gpl_syms; const struct kernel_symbol *gpl_syms; const unsigned long *gpl_crcs; const struct kernel_symbol *unused_syms; const unsigned long *unused_crcs; unsigned int num_unused_syms; unsigned int num_unused_gpl_syms; const struct kernel_symbol *unused_gpl_syms; const unsigned long *unused_gpl_crcs; bool sig_ok; const struct kernel_symbol *gpl_future_syms; const unsigned long *gpl_future_crcs; unsigned int num_gpl_future_syms; unsigned int num_exentries; struct exception_table_entry *extable; int (*init)(); void *module_init; void *module_core; unsigned int init_size; unsigned int core_size; unsigned int init_text_size; unsigned int core_text_size; unsigned int init_ro_size; unsigned int core_ro_size; struct mod_arch_specific arch; unsigned int taints; unsigned int num_bugs; struct list_head bug_list; struct bug_entry *bug_table; Elf64_Sym *symtab; Elf64_Sym *core_symtab; unsigned int num_symtab; unsigned int core_num_syms; char *strtab; char *core_strtab; struct module_sect_attrs *sect_attrs; struct module_notes_attrs *notes_attrs; char *args; void *percpu; unsigned int percpu_size; unsigned int num_tracepoints; const struct tracepoint **tracepoints_ptrs; unsigned int num_trace_bprintk_fmt; const char **trace_bprintk_fmt_start; struct ftrace_event_call **trace_events; unsigned int num_trace_events; struct list_head source_list; struct list_head target_list; void (*exit)(); struct module_ref *refptr; ctor_fn_t (**ctors)(); unsigned int num_ctors; } ; 86 struct be_bus_address32 { unsigned int address_lo; unsigned int address_hi; } ; 200 struct be_bus_address64 { unsigned long long address; } ; 204 union __anonunion_u_225 { struct be_bus_address32 a32; struct be_bus_address64 a64; } ; 204 struct be_bus_address { union __anonunion_u_225 u; } ; 211 struct mem_array { struct be_bus_address bus_address; void *virtual_address; unsigned int size; } ; 217 struct be_mem_descriptor { unsigned int index; unsigned int category; unsigned int num_elements; unsigned int alignment_mask; unsigned int size_in_bytes; struct mem_array *mem_array; } ; 228 struct iscsi_sge ; 228 struct sgl_handle { unsigned int sgl_index; unsigned int type; unsigned int cid; struct iscsi_task *task; struct iscsi_sge *pfrag; } ; 236 struct hba_parameters { unsigned int ios_per_ctrl; unsigned int cxns_per_ctrl; unsigned int asyncpdus_per_ctrl; unsigned int icds_per_ctrl; unsigned int num_sge_per_io; unsigned int defpdu_hdr_sz; unsigned int defpdu_data_sz; unsigned int num_cq_entries; unsigned int num_eq_entries; unsigned int wrbs_per_cxn; unsigned int crashmode; unsigned int hba_num; unsigned int mgmt_ws_sz; unsigned int hwi_ws_sz; unsigned int eto; unsigned int ldto; unsigned int dbg_flags; unsigned int num_cxn; unsigned int eq_timer; unsigned int num_mcc_pages; unsigned int num_mcc_cq_pages; unsigned int num_cq_pages; unsigned int num_eq_pages; unsigned int num_async_pdu_buf_pages; unsigned int num_async_pdu_buf_sgl_pages; unsigned int num_async_pdu_buf_cq_pages; unsigned int num_async_pdu_hdr_pages; unsigned int num_async_pdu_hdr_sgl_pages; unsigned int num_async_pdu_hdr_cq_pages; unsigned int num_sge; } ; 280 struct invalidate_command_table { unsigned short icd; unsigned short cid; } ; 285 struct wrb_handle ; 285 struct iscsi_wrb ; 285 struct hwi_wrb_context { struct list_head wrb_handle_list; struct list_head wrb_handle_drvr_list; struct wrb_handle **pwrb_handle_base; struct wrb_handle **pwrb_handle_basestd; struct iscsi_wrb *plast_wrb; unsigned short alloc_index; unsigned short free_index; unsigned short wrb_handles_available; unsigned short cid; uint8_t ulp_num; uint16_t register_set; uint16_t doorbell_format; uint32_t doorbell_offset; } ; 303 struct ulp_cid_info { unsigned short *cid_array; unsigned short avlbl_cids; unsigned short cid_alloc; unsigned short cid_free; } ; 83 struct pm_qos_request { struct plist_node node; int pm_qos_class; struct delayed_work work; } ; 45 struct pm_qos_flags_request { struct list_head node; s32 flags; } ; 50 enum dev_pm_qos_req_type { DEV_PM_QOS_LATENCY = 1, DEV_PM_QOS_FLAGS = 2 } ; 55 union __anonunion_data_226 { struct plist_node pnode; struct pm_qos_flags_request flr; } ; 55 struct dev_pm_qos_request { enum dev_pm_qos_req_type type; union __anonunion_data_226 data; struct device *dev; } ; 64 enum pm_qos_type { PM_QOS_UNITIALIZED = 0, PM_QOS_MAX = 1, PM_QOS_MIN = 2 } ; 70 struct pm_qos_constraints { struct plist_head list; s32 target_value; s32 default_value; enum pm_qos_type type; struct blocking_notifier_head *notifiers; } ; 83 struct pm_qos_flags { struct list_head list; s32 effective_flags; } ; 88 struct dev_pm_qos { struct pm_qos_constraints latency; struct pm_qos_flags flags; struct dev_pm_qos_request *latency_req; struct dev_pm_qos_request *flags_req; } ; 54 struct dql { unsigned int num_queued; unsigned int adj_limit; unsigned int last_obj_cnt; unsigned int limit; unsigned int num_completed; unsigned int prev_ovlimit; unsigned int prev_num_queued; unsigned int prev_last_obj_cnt; unsigned int lowest_slack; unsigned long slack_start_time; unsigned int max_limit; unsigned int min_limit; unsigned int slack_hold_time; } ; 43 struct __anonstruct_sync_serial_settings_227 { unsigned int clock_rate; unsigned int clock_type; unsigned short loopback; } ; 43 typedef struct __anonstruct_sync_serial_settings_227 sync_serial_settings; 50 struct __anonstruct_te1_settings_228 { unsigned int clock_rate; unsigned int clock_type; unsigned short loopback; unsigned int slot_map; } ; 50 typedef struct __anonstruct_te1_settings_228 te1_settings; 55 struct __anonstruct_raw_hdlc_proto_229 { unsigned short encoding; unsigned short parity; } ; 55 typedef struct __anonstruct_raw_hdlc_proto_229 raw_hdlc_proto; 65 struct __anonstruct_fr_proto_230 { unsigned int t391; unsigned int t392; unsigned int n391; unsigned int n392; unsigned int n393; unsigned short lmi; unsigned short dce; } ; 65 typedef struct __anonstruct_fr_proto_230 fr_proto; 69 struct __anonstruct_fr_proto_pvc_231 { unsigned int dlci; } ; 69 typedef struct __anonstruct_fr_proto_pvc_231 fr_proto_pvc; 74 struct __anonstruct_fr_proto_pvc_info_232 { unsigned int dlci; char master[16U]; } ; 74 typedef struct __anonstruct_fr_proto_pvc_info_232 fr_proto_pvc_info; 79 struct __anonstruct_cisco_proto_233 { unsigned int interval; unsigned int timeout; } ; 79 typedef struct __anonstruct_cisco_proto_233 cisco_proto; 95 struct ifmap { unsigned long mem_start; unsigned long mem_end; unsigned short base_addr; unsigned char irq; unsigned char dma; unsigned char port; } ; 151 union __anonunion_ifs_ifsu_234 { raw_hdlc_proto *raw_hdlc; cisco_proto *cisco; fr_proto *fr; fr_proto_pvc *fr_pvc; fr_proto_pvc_info *fr_pvc_info; sync_serial_settings *sync; te1_settings *te1; } ; 151 struct if_settings { unsigned int type; unsigned int size; union __anonunion_ifs_ifsu_234 ifs_ifsu; } ; 169 union __anonunion_ifr_ifrn_235 { char ifrn_name[16U]; } ; 169 union __anonunion_ifr_ifru_236 { struct sockaddr ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; struct sockaddr ifru_netmask; struct sockaddr ifru_hwaddr; short ifru_flags; int ifru_ivalue; int ifru_mtu; struct ifmap ifru_map; char ifru_slave[16U]; char ifru_newname[16U]; void *ifru_data; struct if_settings ifru_settings; } ; 169 struct ifreq { union __anonunion_ifr_ifrn_235 ifr_ifrn; union __anonunion_ifr_ifru_236 ifr_ifru; } ; 39 typedef s32 compat_long_t; 44 typedef u32 compat_uptr_t; 273 struct compat_robust_list { compat_uptr_t next; } ; 277 struct compat_robust_list_head { struct compat_robust_list list; compat_long_t futex_offset; compat_uptr_t list_op_pending; } ; 685 struct ethtool_cmd { __u32 cmd; __u32 supported; __u32 advertising; __u16 speed; __u8 duplex; __u8 port; __u8 phy_address; __u8 transceiver; __u8 autoneg; __u8 mdio_support; __u32 maxtxpkt; __u32 maxrxpkt; __u16 speed_hi; __u8 eth_tp_mdix; __u8 eth_tp_mdix_ctrl; __u32 lp_advertising; __u32 reserved[2U]; } ; 65 struct ethtool_drvinfo { __u32 cmd; char driver[32U]; char version[32U]; char fw_version[32U]; char bus_info[32U]; char reserved1[32U]; char reserved2[12U]; __u32 n_priv_flags; __u32 n_stats; __u32 testinfo_len; __u32 eedump_len; __u32 regdump_len; } ; 105 struct ethtool_wolinfo { __u32 cmd; __u32 supported; __u32 wolopts; __u8 sopass[6U]; } ; 120 struct ethtool_regs { __u32 cmd; __u32 version; __u32 len; __u8 data[0U]; } ; 128 struct ethtool_eeprom { __u32 cmd; __u32 magic; __u32 offset; __u32 len; __u8 data[0U]; } ; 137 struct ethtool_eee { __u32 cmd; __u32 supported; __u32 advertised; __u32 lp_advertised; __u32 eee_active; __u32 eee_enabled; __u32 tx_lpi_enabled; __u32 tx_lpi_timer; __u32 reserved[2U]; } ; 166 struct ethtool_modinfo { __u32 cmd; __u32 type; __u32 eeprom_len; __u32 reserved[8U]; } ; 183 struct ethtool_coalesce { __u32 cmd; __u32 rx_coalesce_usecs; __u32 rx_max_coalesced_frames; __u32 rx_coalesce_usecs_irq; __u32 rx_max_coalesced_frames_irq; __u32 tx_coalesce_usecs; __u32 tx_max_coalesced_frames; __u32 tx_coalesce_usecs_irq; __u32 tx_max_coalesced_frames_irq; __u32 stats_block_coalesce_usecs; __u32 use_adaptive_rx_coalesce; __u32 use_adaptive_tx_coalesce; __u32 pkt_rate_low; __u32 rx_coalesce_usecs_low; __u32 rx_max_coalesced_frames_low; __u32 tx_coalesce_usecs_low; __u32 tx_max_coalesced_frames_low; __u32 pkt_rate_high; __u32 rx_coalesce_usecs_high; __u32 rx_max_coalesced_frames_high; __u32 tx_coalesce_usecs_high; __u32 tx_max_coalesced_frames_high; __u32 rate_sample_interval; } ; 281 struct ethtool_ringparam { __u32 cmd; __u32 rx_max_pending; __u32 rx_mini_max_pending; __u32 rx_jumbo_max_pending; __u32 tx_max_pending; __u32 rx_pending; __u32 rx_mini_pending; __u32 rx_jumbo_pending; __u32 tx_pending; } ; 303 struct ethtool_channels { __u32 cmd; __u32 max_rx; __u32 max_tx; __u32 max_other; __u32 max_combined; __u32 rx_count; __u32 tx_count; __u32 other_count; __u32 combined_count; } ; 331 struct ethtool_pauseparam { __u32 cmd; __u32 autoneg; __u32 rx_pause; __u32 tx_pause; } ; 382 struct ethtool_test { __u32 cmd; __u32 flags; __u32 reserved; __u32 len; __u64 data[0U]; } ; 404 struct ethtool_stats { __u32 cmd; __u32 n_stats; __u64 data[0U]; } ; 425 struct ethtool_tcpip4_spec { __be32 ip4src; __be32 ip4dst; __be16 psrc; __be16 pdst; __u8 tos; } ; 458 struct ethtool_ah_espip4_spec { __be32 ip4src; __be32 ip4dst; __be32 spi; __u8 tos; } ; 474 struct ethtool_usrip4_spec { __be32 ip4src; __be32 ip4dst; __be32 l4_4_bytes; __u8 tos; __u8 ip_ver; __u8 proto; } ; 494 union ethtool_flow_union { struct ethtool_tcpip4_spec tcp_ip4_spec; struct ethtool_tcpip4_spec udp_ip4_spec; struct ethtool_tcpip4_spec sctp_ip4_spec; struct ethtool_ah_espip4_spec ah_ip4_spec; struct ethtool_ah_espip4_spec esp_ip4_spec; struct ethtool_usrip4_spec usr_ip4_spec; struct ethhdr ether_spec; __u8 hdata[52U]; } ; 505 struct ethtool_flow_ext { __u8 padding[2U]; unsigned char h_dest[6U]; __be16 vlan_etype; __be16 vlan_tci; __be32 data[2U]; } ; 524 struct ethtool_rx_flow_spec { __u32 flow_type; union ethtool_flow_union h_u; struct ethtool_flow_ext h_ext; union ethtool_flow_union m_u; struct ethtool_flow_ext m_ext; __u64 ring_cookie; __u32 location; } ; 550 struct ethtool_rxnfc { __u32 cmd; __u32 flow_type; __u64 data; struct ethtool_rx_flow_spec fs; __u32 rule_cnt; __u32 rule_locs[0U]; } ; 684 struct ethtool_flash { __u32 cmd; __u32 region; char data[128U]; } ; 692 struct ethtool_dump { __u32 cmd; __u32 version; __u32 flag; __u32 len; __u8 data[0U]; } ; 768 struct ethtool_ts_info { __u32 cmd; __u32 so_timestamping; __s32 phc_index; __u32 tx_types; __u32 tx_reserved[3U]; __u32 rx_filters; __u32 rx_reserved[3U]; } ; 44 enum ethtool_phys_id_state { ETHTOOL_ID_INACTIVE = 0, ETHTOOL_ID_ACTIVE = 1, ETHTOOL_ID_ON = 2, ETHTOOL_ID_OFF = 3 } ; 79 struct ethtool_ops { int (*get_settings)(struct net_device *, struct ethtool_cmd *); int (*set_settings)(struct net_device *, struct ethtool_cmd *); void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *); int (*get_regs_len)(struct net_device *); void (*get_regs)(struct net_device *, struct ethtool_regs *, void *); void (*get_wol)(struct net_device *, struct ethtool_wolinfo *); int (*set_wol)(struct net_device *, struct ethtool_wolinfo *); u32 (*get_msglevel)(struct net_device *); void (*set_msglevel)(struct net_device *, u32 ); int (*nway_reset)(struct net_device *); u32 (*get_link)(struct net_device *); int (*get_eeprom_len)(struct net_device *); int (*get_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *); int (*set_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *); int (*get_coalesce)(struct net_device *, struct ethtool_coalesce *); int (*set_coalesce)(struct net_device *, struct ethtool_coalesce *); void (*get_ringparam)(struct net_device *, struct ethtool_ringparam *); int (*set_ringparam)(struct net_device *, struct ethtool_ringparam *); void (*get_pauseparam)(struct net_device *, struct ethtool_pauseparam *); int (*set_pauseparam)(struct net_device *, struct ethtool_pauseparam *); void (*self_test)(struct net_device *, struct ethtool_test *, u64 *); void (*get_strings)(struct net_device *, u32 , u8 *); int (*set_phys_id)(struct net_device *, enum ethtool_phys_id_state ); void (*get_ethtool_stats)(struct net_device *, struct ethtool_stats *, u64 *); int (*begin)(struct net_device *); void (*complete)(struct net_device *); u32 (*get_priv_flags)(struct net_device *); int (*set_priv_flags)(struct net_device *, u32 ); int (*get_sset_count)(struct net_device *, int); int (*get_rxnfc)(struct net_device *, struct ethtool_rxnfc *, u32 *); int (*set_rxnfc)(struct net_device *, struct ethtool_rxnfc *); int (*flash_device)(struct net_device *, struct ethtool_flash *); int (*reset)(struct net_device *, u32 *); u32 (*get_rxfh_indir_size)(struct net_device *); int (*get_rxfh_indir)(struct net_device *, u32 *); int (*set_rxfh_indir)(struct net_device *, const u32 *); void (*get_channels)(struct net_device *, struct ethtool_channels *); int (*set_channels)(struct net_device *, struct ethtool_channels *); int (*get_dump_flag)(struct net_device *, struct ethtool_dump *); int (*get_dump_data)(struct net_device *, struct ethtool_dump *, void *); int (*set_dump)(struct net_device *, struct ethtool_dump *); int (*get_ts_info)(struct net_device *, struct ethtool_ts_info *); int (*get_module_info)(struct net_device *, struct ethtool_modinfo *); int (*get_module_eeprom)(struct net_device *, struct ethtool_eeprom *, u8 *); int (*get_eee)(struct net_device *, struct ethtool_eee *); int (*set_eee)(struct net_device *, struct ethtool_eee *); } ; 249 struct prot_inuse ; 250 struct netns_core { struct ctl_table_header *sysctl_hdr; int sysctl_somaxconn; struct prot_inuse *inuse; } ; 38 struct u64_stats_sync { } ; 145 struct ipstats_mib { u64 mibs[36U]; struct u64_stats_sync syncp; } ; 61 struct icmp_mib { unsigned long mibs[28U]; } ; 67 struct icmpmsg_mib { atomic_long_t mibs[512U]; } ; 72 struct icmpv6_mib { unsigned long mibs[6U]; } ; 83 struct icmpv6msg_mib { atomic_long_t mibs[512U]; } ; 93 struct tcp_mib { unsigned long mibs[16U]; } ; 100 struct udp_mib { unsigned long mibs[8U]; } ; 106 struct linux_mib { unsigned long mibs[97U]; } ; 112 struct linux_xfrm_mib { unsigned long mibs[29U]; } ; 118 struct netns_mib { struct tcp_mib *tcp_statistics[1U]; struct ipstats_mib *ip_statistics[1U]; struct linux_mib *net_statistics[1U]; struct udp_mib *udp_statistics[1U]; struct udp_mib *udplite_statistics[1U]; struct icmp_mib *icmp_statistics[1U]; struct icmpmsg_mib *icmpmsg_statistics; struct proc_dir_entry *proc_net_devsnmp6; struct udp_mib *udp_stats_in6[1U]; struct udp_mib *udplite_stats_in6[1U]; struct ipstats_mib *ipv6_statistics[1U]; struct icmpv6_mib *icmpv6_statistics[1U]; struct icmpv6msg_mib *icmpv6msg_statistics; struct linux_xfrm_mib *xfrm_statistics[1U]; } ; 26 struct netns_unix { int sysctl_max_dgram_qlen; struct ctl_table_header *ctl; } ; 12 struct netns_packet { struct mutex sklist_lock; struct hlist_head sklist; } ; 14 struct netns_frags { int nqueues; struct list_head lru_list; spinlock_t lru_lock; struct percpu_counter mem; int timeout; int high_thresh; int low_thresh; } ; 180 struct tcpm_hash_bucket ; 181 struct ipv4_devconf ; 182 struct fib_rules_ops ; 183 struct fib_table ; 184 struct local_ports { seqlock_t lock; int range[2U]; } ; 22 struct inet_peer_base ; 22 struct xt_table ; 22 struct netns_ipv4 { struct ctl_table_header *forw_hdr; struct ctl_table_header *frags_hdr; struct ctl_table_header *ipv4_hdr; struct ctl_table_header *route_hdr; struct ctl_table_header *xfrm4_hdr; struct ipv4_devconf *devconf_all; struct ipv4_devconf *devconf_dflt; struct fib_rules_ops *rules_ops; bool fib_has_custom_rules; struct fib_table *fib_local; struct fib_table *fib_main; struct fib_table *fib_default; int fib_num_tclassid_users; struct hlist_head *fib_table_hash; struct sock *fibnl; struct sock **icmp_sk; struct inet_peer_base *peers; struct tcpm_hash_bucket *tcp_metrics_hash; unsigned int tcp_metrics_hash_log; struct netns_frags frags; struct xt_table *iptable_filter; struct xt_table *iptable_mangle; struct xt_table *iptable_raw; struct xt_table *arptable_filter; struct xt_table *iptable_security; struct xt_table *nat_table; int sysctl_icmp_echo_ignore_all; int sysctl_icmp_echo_ignore_broadcasts; int sysctl_icmp_ignore_bogus_error_responses; int sysctl_icmp_ratelimit; int sysctl_icmp_ratemask; int sysctl_icmp_errors_use_inbound_ifaddr; struct local_ports sysctl_local_ports; int sysctl_tcp_ecn; int sysctl_ip_no_pmtu_disc; int sysctl_ip_fwd_use_pmtu; kgid_t sysctl_ping_group_range[2U]; atomic_t dev_addr_genid; struct list_head mr_tables; struct fib_rules_ops *mr_rules_ops; atomic_t rt_genid; } ; 90 struct neighbour ; 90 struct dst_ops { unsigned short family; __be16 protocol; unsigned int gc_thresh; int (*gc)(struct dst_ops *); struct dst_entry * (*check)(struct dst_entry *, __u32 ); unsigned int (*default_advmss)(const struct dst_entry *); unsigned int (*mtu)(const struct dst_entry *); u32 * (*cow_metrics)(struct dst_entry *, unsigned long); void (*destroy)(struct dst_entry *); void (*ifdown)(struct dst_entry *, struct net_device *, int); struct dst_entry * (*negative_advice)(struct dst_entry *); void (*link_failure)(struct sk_buff *); void (*update_pmtu)(struct dst_entry *, struct sock *, struct sk_buff *, u32 ); void (*redirect)(struct dst_entry *, struct sock *, struct sk_buff *); int (*local_out)(struct sk_buff *); struct neighbour * (*neigh_lookup)(const struct dst_entry *, struct sk_buff *, const void *); struct kmem_cache *kmem_cachep; struct percpu_counter pcpuc_entries; } ; 73 struct netns_sysctl_ipv6 { struct ctl_table_header *hdr; struct ctl_table_header *route_hdr; struct ctl_table_header *icmp_hdr; struct ctl_table_header *frags_hdr; struct ctl_table_header *xfrm6_hdr; int bindv6only; int flush_delay; int ip6_rt_max_size; int ip6_rt_gc_min_interval; int ip6_rt_gc_timeout; int ip6_rt_gc_interval; int ip6_rt_gc_elasticity; int ip6_rt_mtu_expires; int ip6_rt_min_advmss; int flowlabel_consistency; int icmpv6_time; int anycast_src_echo_reply; } ; 34 struct ipv6_devconf ; 34 struct rt6_info ; 34 struct rt6_statistics ; 34 struct fib6_table ; 34 struct netns_ipv6 { struct netns_sysctl_ipv6 sysctl; struct ipv6_devconf *devconf_all; struct ipv6_devconf *devconf_dflt; struct inet_peer_base *peers; struct netns_frags frags; struct xt_table *ip6table_filter; struct xt_table *ip6table_mangle; struct xt_table *ip6table_raw; struct xt_table *ip6table_security; struct xt_table *ip6table_nat; struct rt6_info *ip6_null_entry; struct rt6_statistics *rt6_stats; struct timer_list ip6_fib_timer; struct hlist_head *fib_table_hash; struct fib6_table *fib6_main_tbl; struct dst_ops ip6_dst_ops; unsigned int ip6_rt_gc_expire; unsigned long ip6_rt_last_gc; struct rt6_info *ip6_prohibit_entry; struct rt6_info *ip6_blk_hole_entry; struct fib6_table *fib6_local_tbl; struct fib_rules_ops *fib6_rules_ops; struct sock **icmp_sk; struct sock *ndisc_sk; struct sock *tcp_sk; struct sock *igmp_sk; struct list_head mr6_tables; struct fib_rules_ops *mr6_rules_ops; atomic_t dev_addr_genid; atomic_t rt_genid; } ; 79 struct netns_nf_frag { struct netns_sysctl_ipv6 sysctl; struct netns_frags frags; } ; 85 struct sctp_mib ; 86 struct netns_sctp { struct sctp_mib *sctp_statistics[1U]; struct proc_dir_entry *proc_net_sctp; struct ctl_table_header *sysctl_header; struct sock *ctl_sock; struct list_head local_addr_list; struct list_head addr_waitq; struct timer_list addr_wq_timer; struct list_head auto_asconf_splist; spinlock_t addr_wq_lock; spinlock_t local_addr_lock; unsigned int rto_initial; unsigned int rto_min; unsigned int rto_max; int rto_alpha; int rto_beta; int max_burst; int cookie_preserve_enable; char *sctp_hmac_alg; unsigned int valid_cookie_life; unsigned int sack_timeout; unsigned int hb_interval; int max_retrans_association; int max_retrans_path; int max_retrans_init; int pf_retrans; int sndbuf_policy; int rcvbuf_policy; int default_auto_asconf; int addip_enable; int addip_noauth; int prsctp_enable; int auth_enable; int scope_policy; int rwnd_upd_shift; unsigned long max_autoclose; } ; 133 struct netns_dccp { struct sock *v4_ctl_sk; struct sock *v6_ctl_sk; } ; 337 struct nf_logger ; 338 struct netns_nf { struct proc_dir_entry *proc_netfilter; const struct nf_logger *nf_loggers[13U]; struct ctl_table_header *nf_log_dir_header; } ; 17 struct ebt_table ; 18 struct netns_xt { struct list_head tables[13U]; bool notrack_deprecated_warning; struct ebt_table *broute_table; struct ebt_table *frame_filter; struct ebt_table *frame_nat; bool ulog_warn_deprecated; bool ebt_ulog_warn_deprecated; } ; 24 struct hlist_nulls_node ; 24 struct hlist_nulls_head { struct hlist_nulls_node *first; } ; 20 struct hlist_nulls_node { struct hlist_nulls_node *next; struct hlist_nulls_node **pprev; } ; 32 struct nf_proto_net { struct ctl_table_header *ctl_table_header; struct ctl_table *ctl_table; struct ctl_table_header *ctl_compat_header; struct ctl_table *ctl_compat_table; unsigned int users; } ; 23 struct nf_generic_net { struct nf_proto_net pn; unsigned int timeout; } ; 28 struct nf_tcp_net { struct nf_proto_net pn; unsigned int timeouts[14U]; unsigned int tcp_loose; unsigned int tcp_be_liberal; unsigned int tcp_max_retrans; } ; 42 struct nf_udp_net { struct nf_proto_net pn; unsigned int timeouts[2U]; } ; 47 struct nf_icmp_net { struct nf_proto_net pn; unsigned int timeout; } ; 52 struct nf_ip_net { struct nf_generic_net generic; struct nf_tcp_net tcp; struct nf_udp_net udp; struct nf_icmp_net icmp; struct nf_icmp_net icmpv6; struct ctl_table_header *ctl_table_header; struct ctl_table *ctl_table; } ; 63 struct ip_conntrack_stat ; 63 struct nf_ct_event_notifier ; 63 struct nf_exp_event_notifier ; 63 struct netns_ct { atomic_t count; unsigned int expect_count; struct ctl_table_header *sysctl_header; struct ctl_table_header *acct_sysctl_header; struct ctl_table_header *tstamp_sysctl_header; struct ctl_table_header *event_sysctl_header; struct ctl_table_header *helper_sysctl_header; char *slabname; unsigned int sysctl_log_invalid; unsigned int sysctl_events_retry_timeout; int sysctl_events; int sysctl_acct; int sysctl_auto_assign_helper; bool auto_assign_helper_warned; int sysctl_tstamp; int sysctl_checksum; unsigned int htable_size; struct kmem_cache *nf_conntrack_cachep; struct hlist_nulls_head *hash; struct hlist_head *expect_hash; struct hlist_nulls_head unconfirmed; struct hlist_nulls_head dying; struct hlist_nulls_head tmpl; struct ip_conntrack_stat *stat; struct nf_ct_event_notifier *nf_conntrack_event_cb; struct nf_exp_event_notifier *nf_expect_event_cb; struct nf_ip_net nf_ct_proto; unsigned int labels_used; u8 label_words; struct hlist_head *nat_bysource; unsigned int nat_htable_size; } ; 104 struct nft_af_info ; 105 struct netns_nftables { struct list_head af_info; struct list_head commit_list; struct nft_af_info *ipv4; struct nft_af_info *ipv6; struct nft_af_info *inet; struct nft_af_info *arp; struct nft_af_info *bridge; u8 gencursor; u8 genctr; } ; 489 struct xfrm_policy_hash { struct hlist_head *table; unsigned int hmask; } ; 16 struct netns_xfrm { struct list_head state_all; struct hlist_head *state_bydst; struct hlist_head *state_bysrc; struct hlist_head *state_byspi; unsigned int state_hmask; unsigned int state_num; struct work_struct state_hash_work; struct hlist_head state_gc_list; struct work_struct state_gc_work; struct list_head policy_all; struct hlist_head *policy_byidx; unsigned int policy_idx_hmask; struct hlist_head policy_inexact[6U]; struct xfrm_policy_hash policy_bydst[6U]; unsigned int policy_count[6U]; struct work_struct policy_hash_work; struct sock *nlsk; struct sock *nlsk_stash; u32 sysctl_aevent_etime; u32 sysctl_aevent_rseqth; int sysctl_larval_drop; u32 sysctl_acq_expires; struct ctl_table_header *sysctl_hdr; struct dst_ops xfrm4_dst_ops; struct dst_ops xfrm6_dst_ops; spinlock_t xfrm_state_lock; spinlock_t xfrm_policy_sk_bundle_lock; rwlock_t xfrm_policy_lock; struct mutex xfrm_cfg_mutex; } ; 65 struct net_generic ; 66 struct netns_ipvs ; 67 struct net { atomic_t passive; atomic_t count; spinlock_t rules_mod_lock; struct list_head list; struct list_head cleanup_list; struct list_head exit_list; struct user_namespace *user_ns; unsigned int proc_inum; struct proc_dir_entry *proc_net; struct proc_dir_entry *proc_net_stat; struct ctl_table_set sysctls; struct sock *rtnl; struct sock *genl_sock; struct list_head dev_base_head; struct hlist_head *dev_name_head; struct hlist_head *dev_index_head; unsigned int dev_base_seq; int ifindex; unsigned int dev_unreg_count; struct list_head rules_ops; struct net_device *loopback_dev; struct netns_core core; struct netns_mib mib; struct netns_packet packet; struct netns_unix unx; struct netns_ipv4 ipv4; struct netns_ipv6 ipv6; struct netns_sctp sctp; struct netns_dccp dccp; struct netns_nf nf; struct netns_xt xt; struct netns_ct ct; struct netns_nftables nft; struct netns_nf_frag nf_frag; struct sock *nfnl; struct sock *nfnl_stash; struct sk_buff_head wext_nlevents; struct net_generic *gen; struct netns_xfrm xfrm; struct netns_ipvs *ipvs; struct sock *diag_nlsk; atomic_t fnhe_genid; } ; 395 struct dsa_chip_data { struct device *mii_bus; int sw_addr; char *port_names[12U]; s8 *rtable; } ; 46 struct dsa_platform_data { struct device *netdev; int nr_chips; struct dsa_chip_data *chip; } ; 61 struct dsa_switch ; 61 struct dsa_switch_tree { struct dsa_platform_data *pd; struct net_device *master_netdev; __be16 tag_protocol; s8 cpu_switch; s8 cpu_port; int link_poll_needed; struct work_struct link_poll_work; struct timer_list link_poll_timer; struct dsa_switch *ds[4U]; } ; 94 struct dsa_switch_driver ; 94 struct mii_bus ; 94 struct dsa_switch { struct dsa_switch_tree *dst; int index; struct dsa_chip_data *pd; struct dsa_switch_driver *drv; struct mii_bus *master_mii_bus; u32 dsa_port_mask; u32 phys_port_mask; struct mii_bus *slave_mii_bus; struct net_device *ports[12U]; } ; 146 struct dsa_switch_driver { struct list_head list; __be16 tag_protocol; int priv_size; char * (*probe)(struct mii_bus *, int); int (*setup)(struct dsa_switch *); int (*set_addr)(struct dsa_switch *, u8 *); int (*phy_read)(struct dsa_switch *, int, int); int (*phy_write)(struct dsa_switch *, int, int, u16 ); void (*poll_link)(struct dsa_switch *); void (*get_strings)(struct dsa_switch *, int, uint8_t *); void (*get_ethtool_stats)(struct dsa_switch *, int, uint64_t *); int (*get_sset_count)(struct dsa_switch *); } ; 200 struct ieee_ets { __u8 willing; __u8 ets_cap; __u8 cbs; __u8 tc_tx_bw[8U]; __u8 tc_rx_bw[8U]; __u8 tc_tsa[8U]; __u8 prio_tc[8U]; __u8 tc_reco_bw[8U]; __u8 tc_reco_tsa[8U]; __u8 reco_prio_tc[8U]; } ; 69 struct ieee_maxrate { __u64 tc_maxrate[8U]; } ; 80 struct ieee_pfc { __u8 pfc_cap; __u8 pfc_en; __u8 mbc; __u16 delay; __u64 requests[8U]; __u64 indications[8U]; } ; 100 struct cee_pg { __u8 willing; __u8 error; __u8 pg_en; __u8 tcs_supported; __u8 pg_bw[8U]; __u8 prio_pg[8U]; } ; 123 struct cee_pfc { __u8 willing; __u8 error; __u8 pfc_en; __u8 tcs_supported; } ; 138 struct dcb_app { __u8 selector; __u8 priority; __u16 protocol; } ; 167 struct dcb_peer_app_info { __u8 willing; __u8 error; } ; 40 struct dcbnl_rtnl_ops { int (*ieee_getets)(struct net_device *, struct ieee_ets *); int (*ieee_setets)(struct net_device *, struct ieee_ets *); int (*ieee_getmaxrate)(struct net_device *, struct ieee_maxrate *); int (*ieee_setmaxrate)(struct net_device *, struct ieee_maxrate *); int (*ieee_getpfc)(struct net_device *, struct ieee_pfc *); int (*ieee_setpfc)(struct net_device *, struct ieee_pfc *); int (*ieee_getapp)(struct net_device *, struct dcb_app *); int (*ieee_setapp)(struct net_device *, struct dcb_app *); int (*ieee_delapp)(struct net_device *, struct dcb_app *); int (*ieee_peer_getets)(struct net_device *, struct ieee_ets *); int (*ieee_peer_getpfc)(struct net_device *, struct ieee_pfc *); u8 (*getstate)(struct net_device *); u8 (*setstate)(struct net_device *, u8 ); void (*getpermhwaddr)(struct net_device *, u8 *); void (*setpgtccfgtx)(struct net_device *, int, u8 , u8 , u8 , u8 ); void (*setpgbwgcfgtx)(struct net_device *, int, u8 ); void (*setpgtccfgrx)(struct net_device *, int, u8 , u8 , u8 , u8 ); void (*setpgbwgcfgrx)(struct net_device *, int, u8 ); void (*getpgtccfgtx)(struct net_device *, int, u8 *, u8 *, u8 *, u8 *); void (*getpgbwgcfgtx)(struct net_device *, int, u8 *); void (*getpgtccfgrx)(struct net_device *, int, u8 *, u8 *, u8 *, u8 *); void (*getpgbwgcfgrx)(struct net_device *, int, u8 *); void (*setpfccfg)(struct net_device *, int, u8 ); void (*getpfccfg)(struct net_device *, int, u8 *); u8 (*setall)(struct net_device *); u8 (*getcap)(struct net_device *, int, u8 *); int (*getnumtcs)(struct net_device *, int, u8 *); int (*setnumtcs)(struct net_device *, int, u8 ); u8 (*getpfcstate)(struct net_device *); void (*setpfcstate)(struct net_device *, u8 ); void (*getbcncfg)(struct net_device *, int, u32 *); void (*setbcncfg)(struct net_device *, int, u32 ); void (*getbcnrp)(struct net_device *, int, u8 *); void (*setbcnrp)(struct net_device *, int, u8 ); u8 (*setapp)(struct net_device *, u8 , u16 , u8 ); u8 (*getapp)(struct net_device *, u8 , u16 ); u8 (*getfeatcfg)(struct net_device *, int, u8 *); u8 (*setfeatcfg)(struct net_device *, int, u8 ); u8 (*getdcbx)(struct net_device *); u8 (*setdcbx)(struct net_device *, u8 ); int (*peer_getappinfo)(struct net_device *, struct dcb_peer_app_info *, u16 *); int (*peer_getapptable)(struct net_device *, struct dcb_app *); int (*cee_peer_getpg)(struct net_device *, struct cee_pg *); int (*cee_peer_getpfc)(struct net_device *, struct cee_pfc *); } ; 102 struct taskstats { __u16 version; __u32 ac_exitcode; __u8 ac_flag; __u8 ac_nice; __u64 cpu_count; __u64 cpu_delay_total; __u64 blkio_count; __u64 blkio_delay_total; __u64 swapin_count; __u64 swapin_delay_total; __u64 cpu_run_real_total; __u64 cpu_run_virtual_total; char ac_comm[32U]; __u8 ac_sched; __u8 ac_pad[3U]; __u32 ac_uid; __u32 ac_gid; __u32 ac_pid; __u32 ac_ppid; __u32 ac_btime; __u64 ac_etime; __u64 ac_utime; __u64 ac_stime; __u64 ac_minflt; __u64 ac_majflt; __u64 coremem; __u64 virtmem; __u64 hiwater_rss; __u64 hiwater_vm; __u64 read_char; __u64 write_char; __u64 read_syscalls; __u64 write_syscalls; __u64 read_bytes; __u64 write_bytes; __u64 cancelled_write_bytes; __u64 nvcsw; __u64 nivcsw; __u64 ac_utimescaled; __u64 ac_stimescaled; __u64 cpu_scaled_run_real_total; __u64 freepages_count; __u64 freepages_delay_total; } ; 55 struct xattr_handler { const char *prefix; int flags; size_t (*list)(struct dentry *, char *, size_t , const char *, size_t , int); int (*get)(struct dentry *, const char *, void *, size_t , int); int (*set)(struct dentry *, const char *, const void *, size_t , int, int); } ; 53 struct simple_xattrs { struct list_head head; spinlock_t lock; } ; 98 struct percpu_ref ; 54 typedef void percpu_ref_func_t(struct percpu_ref *); 55 struct percpu_ref { atomic_t count; unsigned int *pcpu_count; percpu_ref_func_t *release; percpu_ref_func_t *confirm_kill; struct callback_head rcu; } ; 173 struct cgroupfs_root ; 174 struct cgroup_subsys ; 175 struct cgroup ; 62 struct cgroup_subsys_state { struct cgroup *cgroup; struct cgroup_subsys *ss; struct percpu_ref refcnt; struct cgroup_subsys_state *parent; unsigned long flags; struct callback_head callback_head; struct work_struct destroy_work; } ; 142 struct cgroup_name { struct callback_head callback_head; char name[]; } ; 160 struct cgroup { unsigned long flags; int id; int nr_css; struct list_head sibling; struct list_head children; struct list_head files; struct cgroup *parent; struct dentry *dentry; u64 serial_nr; struct cgroup_name *name; struct cgroup_subsys_state *subsys[12U]; struct cgroupfs_root *root; struct list_head cset_links; struct list_head release_list; struct list_head pidlists; struct mutex pidlist_mutex; struct cgroup_subsys_state dummy_css; struct callback_head callback_head; struct work_struct destroy_work; struct simple_xattrs xattrs; } ; 252 struct cgroupfs_root { struct super_block *sb; unsigned long subsys_mask; int hierarchy_id; struct cgroup top_cgroup; int number_of_cgroups; struct list_head root_list; unsigned long flags; struct idr cgroup_idr; char release_agent_path[4096U]; char name[64U]; } ; 342 struct css_set { atomic_t refcount; struct hlist_node hlist; struct list_head tasks; struct list_head cgrp_links; struct cgroup_subsys_state *subsys[12U]; struct callback_head callback_head; } ; 392 struct cftype { char name[64U]; int private; umode_t mode; size_t max_write_len; unsigned int flags; struct cgroup_subsys *ss; u64 (*read_u64)(struct cgroup_subsys_state *, struct cftype *); s64 (*read_s64)(struct cgroup_subsys_state *, struct cftype *); int (*seq_show)(struct seq_file *, void *); void * (*seq_start)(struct seq_file *, loff_t *); void * (*seq_next)(struct seq_file *, void *, loff_t *); void (*seq_stop)(struct seq_file *, void *); int (*write_u64)(struct cgroup_subsys_state *, struct cftype *, u64 ); int (*write_s64)(struct cgroup_subsys_state *, struct cftype *, s64 ); int (*write_string)(struct cgroup_subsys_state *, struct cftype *, const char *); int (*trigger)(struct cgroup_subsys_state *, unsigned int); } ; 479 struct cftype_set { struct list_head node; struct cftype *cfts; } ; 546 struct cgroup_taskset ; 557 struct cgroup_subsys { struct cgroup_subsys_state * (*css_alloc)(struct cgroup_subsys_state *); int (*css_online)(struct cgroup_subsys_state *); void (*css_offline)(struct cgroup_subsys_state *); void (*css_free)(struct cgroup_subsys_state *); int (*can_attach)(struct cgroup_subsys_state *, struct cgroup_taskset *); void (*cancel_attach)(struct cgroup_subsys_state *, struct cgroup_taskset *); void (*attach)(struct cgroup_subsys_state *, struct cgroup_taskset *); void (*fork)(struct task_struct *); void (*exit)(struct cgroup_subsys_state *, struct cgroup_subsys_state *, struct task_struct *); void (*bind)(struct cgroup_subsys_state *); int subsys_id; int disabled; int early_init; bool broken_hierarchy; bool warned_broken_hierarchy; const char *name; struct cgroupfs_root *root; struct list_head cftsets; struct cftype *base_cftypes; struct cftype_set base_cftset; struct module *module; } ; 849 struct netprio_map { struct callback_head rcu; u32 priomap_len; u32 priomap[]; } ; 55 struct ndmsg { __u8 ndm_family; __u8 ndm_pad1; __u16 ndm_pad2; __s32 ndm_ifindex; __u16 ndm_state; __u8 ndm_flags; __u8 ndm_type; } ; 39 struct rtnl_link_stats64 { __u64 rx_packets; __u64 tx_packets; __u64 rx_bytes; __u64 tx_bytes; __u64 rx_errors; __u64 tx_errors; __u64 rx_dropped; __u64 tx_dropped; __u64 multicast; __u64 collisions; __u64 rx_length_errors; __u64 rx_over_errors; __u64 rx_crc_errors; __u64 rx_frame_errors; __u64 rx_fifo_errors; __u64 rx_missed_errors; __u64 tx_aborted_errors; __u64 tx_carrier_errors; __u64 tx_fifo_errors; __u64 tx_heartbeat_errors; __u64 tx_window_errors; __u64 rx_compressed; __u64 tx_compressed; } ; 536 struct ifla_vf_info { __u32 vf; __u8 mac[32U]; __u32 vlan; __u32 qos; __u32 tx_rate; __u32 spoofchk; __u32 linkstate; } ; 27 struct netpoll_info ; 28 struct phy_device ; 29 struct wireless_dev ; 64 enum netdev_tx { __NETDEV_TX_MIN = -2147483648, NETDEV_TX_OK = 0, NETDEV_TX_BUSY = 16, NETDEV_TX_LOCKED = 32 } ; 116 typedef enum netdev_tx netdev_tx_t; 135 struct net_device_stats { unsigned long rx_packets; unsigned long tx_packets; unsigned long rx_bytes; unsigned long tx_bytes; unsigned long rx_errors; unsigned long tx_errors; unsigned long rx_dropped; unsigned long tx_dropped; unsigned long multicast; unsigned long collisions; unsigned long rx_length_errors; unsigned long rx_over_errors; unsigned long rx_crc_errors; unsigned long rx_frame_errors; unsigned long rx_fifo_errors; unsigned long rx_missed_errors; unsigned long tx_aborted_errors; unsigned long tx_carrier_errors; unsigned long tx_fifo_errors; unsigned long tx_heartbeat_errors; unsigned long tx_window_errors; unsigned long rx_compressed; unsigned long tx_compressed; } ; 196 struct neigh_parms ; 217 struct netdev_hw_addr_list { struct list_head list; int count; } ; 222 struct hh_cache { u16 hh_len; u16 __pad; seqlock_t hh_lock; unsigned long hh_data[16U]; } ; 251 struct header_ops { int (*create)(struct sk_buff *, struct net_device *, unsigned short, const void *, const void *, unsigned int); int (*parse)(const struct sk_buff *, unsigned char *); int (*rebuild)(struct sk_buff *); int (*cache)(const struct neighbour *, struct hh_cache *, __be16 ); void (*cache_update)(struct hh_cache *, const struct net_device *, const unsigned char *); } ; 302 struct napi_struct { struct list_head poll_list; unsigned long state; int weight; unsigned int gro_count; int (*poll)(struct napi_struct *, int); spinlock_t poll_lock; int poll_owner; struct net_device *dev; struct sk_buff *gro_list; struct sk_buff *skb; struct list_head dev_list; struct hlist_node napi_hash_node; unsigned int napi_id; } ; 346 enum rx_handler_result { RX_HANDLER_CONSUMED = 0, RX_HANDLER_ANOTHER = 1, RX_HANDLER_EXACT = 2, RX_HANDLER_PASS = 3 } ; 394 typedef enum rx_handler_result rx_handler_result_t; 395 typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **); 532 struct Qdisc ; 532 struct netdev_queue { struct net_device *dev; struct Qdisc *qdisc; struct Qdisc *qdisc_sleeping; struct kobject kobj; int numa_node; spinlock_t _xmit_lock; int xmit_lock_owner; unsigned long trans_start; unsigned long trans_timeout; unsigned long state; struct dql dql; } ; 594 struct rps_map { unsigned int len; struct callback_head rcu; u16 cpus[0U]; } ; 606 struct rps_dev_flow { u16 cpu; u16 filter; unsigned int last_qtail; } ; 618 struct rps_dev_flow_table { unsigned int mask; struct callback_head rcu; struct rps_dev_flow flows[0U]; } ; 669 struct netdev_rx_queue { struct rps_map *rps_map; struct rps_dev_flow_table *rps_flow_table; struct kobject kobj; struct net_device *dev; } ; 692 struct xps_map { unsigned int len; unsigned int alloc_len; struct callback_head rcu; u16 queues[0U]; } ; 705 struct xps_dev_maps { struct callback_head rcu; struct xps_map *cpu_map[0U]; } ; 716 struct netdev_tc_txq { u16 count; u16 offset; } ; 727 struct netdev_fcoe_hbainfo { char manufacturer[64U]; char serial_number[64U]; char hardware_version[64U]; char driver_version[64U]; char optionrom_version[64U]; char firmware_version[64U]; char model[256U]; char model_description[256U]; } ; 743 struct netdev_phys_port_id { unsigned char id[32U]; unsigned char id_len; } ; 756 struct net_device_ops { int (*ndo_init)(struct net_device *); void (*ndo_uninit)(struct net_device *); int (*ndo_open)(struct net_device *); int (*ndo_stop)(struct net_device *); netdev_tx_t (*ndo_start_xmit)(struct sk_buff *, struct net_device *); u16 (*ndo_select_queue)(struct net_device *, struct sk_buff *, void *, u16 (*)(struct net_device *, struct sk_buff *)); void (*ndo_change_rx_flags)(struct net_device *, int); void (*ndo_set_rx_mode)(struct net_device *); int (*ndo_set_mac_address)(struct net_device *, void *); int (*ndo_validate_addr)(struct net_device *); int (*ndo_do_ioctl)(struct net_device *, struct ifreq *, int); int (*ndo_set_config)(struct net_device *, struct ifmap *); int (*ndo_change_mtu)(struct net_device *, int); int (*ndo_neigh_setup)(struct net_device *, struct neigh_parms *); void (*ndo_tx_timeout)(struct net_device *); struct rtnl_link_stats64 * (*ndo_get_stats64)(struct net_device *, struct rtnl_link_stats64 *); struct net_device_stats * (*ndo_get_stats)(struct net_device *); int (*ndo_vlan_rx_add_vid)(struct net_device *, __be16 , u16 ); int (*ndo_vlan_rx_kill_vid)(struct net_device *, __be16 , u16 ); void (*ndo_poll_controller)(struct net_device *); int (*ndo_netpoll_setup)(struct net_device *, struct netpoll_info *, gfp_t ); void (*ndo_netpoll_cleanup)(struct net_device *); int (*ndo_busy_poll)(struct napi_struct *); int (*ndo_set_vf_mac)(struct net_device *, int, u8 *); int (*ndo_set_vf_vlan)(struct net_device *, int, u16 , u8 ); int (*ndo_set_vf_tx_rate)(struct net_device *, int, int); int (*ndo_set_vf_spoofchk)(struct net_device *, int, bool ); int (*ndo_get_vf_config)(struct net_device *, int, struct ifla_vf_info *); int (*ndo_set_vf_link_state)(struct net_device *, int, int); int (*ndo_set_vf_port)(struct net_device *, int, struct nlattr **); int (*ndo_get_vf_port)(struct net_device *, int, struct sk_buff *); int (*ndo_setup_tc)(struct net_device *, u8 ); int (*ndo_fcoe_enable)(struct net_device *); int (*ndo_fcoe_disable)(struct net_device *); int (*ndo_fcoe_ddp_setup)(struct net_device *, u16 , struct scatterlist *, unsigned int); int (*ndo_fcoe_ddp_done)(struct net_device *, u16 ); int (*ndo_fcoe_ddp_target)(struct net_device *, u16 , struct scatterlist *, unsigned int); int (*ndo_fcoe_get_hbainfo)(struct net_device *, struct netdev_fcoe_hbainfo *); int (*ndo_fcoe_get_wwn)(struct net_device *, u64 *, int); int (*ndo_rx_flow_steer)(struct net_device *, const struct sk_buff *, u16 , u32 ); int (*ndo_add_slave)(struct net_device *, struct net_device *); int (*ndo_del_slave)(struct net_device *, struct net_device *); netdev_features_t (*ndo_fix_features)(struct net_device *, netdev_features_t ); int (*ndo_set_features)(struct net_device *, netdev_features_t ); int (*ndo_neigh_construct)(struct neighbour *); void (*ndo_neigh_destroy)(struct neighbour *); int (*ndo_fdb_add)(struct ndmsg *, struct nlattr **, struct net_device *, const unsigned char *, u16 ); int (*ndo_fdb_del)(struct ndmsg *, struct nlattr **, struct net_device *, const unsigned char *); int (*ndo_fdb_dump)(struct sk_buff *, struct netlink_callback *, struct net_device *, int); int (*ndo_bridge_setlink)(struct net_device *, struct nlmsghdr *); int (*ndo_bridge_getlink)(struct sk_buff *, u32 , u32 , struct net_device *, u32 ); int (*ndo_bridge_dellink)(struct net_device *, struct nlmsghdr *); int (*ndo_change_carrier)(struct net_device *, bool ); int (*ndo_get_phys_port_id)(struct net_device *, struct netdev_phys_port_id *); void (*ndo_add_vxlan_port)(struct net_device *, sa_family_t , __be16 ); void (*ndo_del_vxlan_port)(struct net_device *, sa_family_t , __be16 ); void * (*ndo_dfwd_add_station)(struct net_device *, struct net_device *); void (*ndo_dfwd_del_station)(struct net_device *, void *); netdev_tx_t (*ndo_dfwd_start_xmit)(struct sk_buff *, struct net_device *, void *); } ; 1161 struct __anonstruct_adj_list_262 { struct list_head upper; struct list_head lower; } ; 1161 struct __anonstruct_all_adj_list_263 { struct list_head upper; struct list_head lower; } ; 1161 struct iw_handler_def ; 1161 struct iw_public_data ; 1161 struct forwarding_accel_ops ; 1161 struct vlan_info ; 1161 struct tipc_bearer ; 1161 struct in_device ; 1161 struct dn_dev ; 1161 struct inet6_dev ; 1161 struct cpu_rmap ; 1161 struct pcpu_lstats ; 1161 struct pcpu_sw_netstats ; 1161 struct pcpu_dstats ; 1161 struct pcpu_vstats ; 1161 union __anonunion____missing_field_name_264 { void *ml_priv; struct pcpu_lstats *lstats; struct pcpu_sw_netstats *tstats; struct pcpu_dstats *dstats; struct pcpu_vstats *vstats; } ; 1161 struct garp_port ; 1161 struct mrp_port ; 1161 struct rtnl_link_ops ; 1161 struct net_device { char name[16U]; struct hlist_node name_hlist; char *ifalias; unsigned long mem_end; unsigned long mem_start; unsigned long base_addr; int irq; unsigned long state; struct list_head dev_list; struct list_head napi_list; struct list_head unreg_list; struct list_head close_list; struct __anonstruct_adj_list_262 adj_list; struct __anonstruct_all_adj_list_263 all_adj_list; netdev_features_t features; netdev_features_t hw_features; netdev_features_t wanted_features; netdev_features_t vlan_features; netdev_features_t hw_enc_features; netdev_features_t mpls_features; int ifindex; int iflink; struct net_device_stats stats; atomic_long_t rx_dropped; const struct iw_handler_def *wireless_handlers; struct iw_public_data *wireless_data; const struct net_device_ops *netdev_ops; const struct ethtool_ops *ethtool_ops; const struct forwarding_accel_ops *fwd_ops; const struct header_ops *header_ops; unsigned int flags; unsigned int priv_flags; unsigned short gflags; unsigned short padded; unsigned char operstate; unsigned char link_mode; unsigned char if_port; unsigned char dma; unsigned int mtu; unsigned short type; unsigned short hard_header_len; unsigned short needed_headroom; unsigned short needed_tailroom; unsigned char perm_addr[32U]; unsigned char addr_assign_type; unsigned char addr_len; unsigned short neigh_priv_len; unsigned short dev_id; spinlock_t addr_list_lock; struct netdev_hw_addr_list uc; struct netdev_hw_addr_list mc; struct netdev_hw_addr_list dev_addrs; struct kset *queues_kset; bool uc_promisc; unsigned int promiscuity; unsigned int allmulti; struct vlan_info *vlan_info; struct dsa_switch_tree *dsa_ptr; struct tipc_bearer *tipc_ptr; void *atalk_ptr; struct in_device *ip_ptr; struct dn_dev *dn_ptr; struct inet6_dev *ip6_ptr; void *ax25_ptr; struct wireless_dev *ieee80211_ptr; unsigned long last_rx; unsigned char *dev_addr; struct netdev_rx_queue *_rx; unsigned int num_rx_queues; unsigned int real_num_rx_queues; rx_handler_func_t *rx_handler; void *rx_handler_data; struct netdev_queue *ingress_queue; unsigned char broadcast[32U]; struct netdev_queue *_tx; unsigned int num_tx_queues; unsigned int real_num_tx_queues; struct Qdisc *qdisc; unsigned long tx_queue_len; spinlock_t tx_global_lock; struct xps_dev_maps *xps_maps; struct cpu_rmap *rx_cpu_rmap; unsigned long trans_start; int watchdog_timeo; struct timer_list watchdog_timer; int *pcpu_refcnt; struct list_head todo_list; struct hlist_node index_hlist; struct list_head link_watch_list; unsigned char reg_state; bool dismantle; unsigned short rtnl_link_state; void (*destructor)(struct net_device *); struct netpoll_info *npinfo; struct net *nd_net; union __anonunion____missing_field_name_264 __annonCompField84; struct garp_port *garp_port; struct mrp_port *mrp_port; struct device dev; const struct attribute_group *sysfs_groups[4U]; const struct attribute_group *sysfs_rx_queue_group; const struct rtnl_link_ops *rtnl_link_ops; unsigned int gso_max_size; u16 gso_max_segs; const struct dcbnl_rtnl_ops *dcbnl_ops; u8 num_tc; struct netdev_tc_txq tc_to_txq[16U]; u8 prio_tc_map[16U]; unsigned int fcoe_ddp_xid; struct netprio_map *priomap; struct phy_device *phydev; struct lock_class_key *qdisc_tx_busylock; int group; struct pm_qos_request pm_qos_req; } ; 1722 struct pcpu_sw_netstats { u64 rx_packets; u64 rx_bytes; u64 tx_packets; u64 tx_bytes; struct u64_stats_sync syncp; } ; 479 struct blk_iopoll ; 5 typedef int blk_iopoll_fn(struct blk_iopoll *, int); 6 struct blk_iopoll { struct list_head list; unsigned long state; unsigned long data; int weight; int max; blk_iopoll_fn *poll; } ; 47 struct be_dma_mem { void *va; dma_addr_t dma; u32 size; } ; 37 struct be_queue_info { struct be_dma_mem dma_mem; u16 len; u16 entry_size; u16 id; u16 tail; u16 head; bool created; atomic_t used; } ; 83 struct beiscsi_hba ; 83 struct be_eq_obj { bool todo_mcc_cq; bool todo_cq; struct be_queue_info q; struct beiscsi_hba *phba; struct be_queue_info *cq; struct work_struct work_cqs; struct blk_iopoll iopoll; } ; 95 struct be_mcc_obj { struct be_queue_info q; struct be_queue_info cq; } ; 100 struct be_ctrl_info { u8 *csr; u8 *db; u8 *pcicfg; struct pci_dev *pdev; spinlock_t mbox_lock; struct be_dma_mem mbox_mem; struct be_dma_mem mbox_mem_alloced; struct be_mcc_obj mcc_obj; spinlock_t mcc_lock; spinlock_t mcc_cq_lock; wait_queue_head_t mcc_wait[17U]; unsigned int mcc_tag[16U]; unsigned int mcc_numtag[17U]; unsigned short mcc_alloc_index; unsigned short mcc_free_index; unsigned int mcc_tag_available; } ; 126 struct be_sge { u32 pa_lo; u32 pa_hi; u32 len; } ; 33 union __anonunion_payload_269 { u8 embedded_payload[236U]; struct be_sge sgl[19U]; } ; 33 struct be_mcc_wrb { u32 embedded; u32 payload_length; u32 tag0; u32 tag1; u32 rsvd; union __anonunion_payload_269 payload; } ; 151 struct be_cmd_req_hdr { u8 opcode; u8 subsystem; u8 port_number; u8 domain; u32 timeout; u32 request_length; u8 version; u8 rsvd0[3U]; } ; 210 struct be_cmd_resp_hdr { u32 info; u32 status; u32 response_length; u32 actual_resp_len; } ; 273 struct mgmt_chap_format { u32 flags; u8 intr_chap_name[256U]; u8 intr_secret[16U]; u8 target_chap_name[256U]; u8 target_secret[16U]; u16 intr_chap_name_length; u16 intr_secret_length; u16 target_chap_name_length; u16 target_secret_length; } ; 285 struct mgmt_auth_method_format { u8 auth_method_type; u8 padding[3U]; struct mgmt_chap_format chap; } ; 291 struct mgmt_conn_login_options { u8 flags; u8 header_digest; u8 data_digest; u8 rsvd0; u32 max_recv_datasegment_len_ini; u32 max_recv_datasegment_len_tgt; u32 tcp_mss; u32 tcp_window_size; struct mgmt_auth_method_format auth_data; } ; 303 struct ip_addr_format { u16 size_of_structure; u8 reserved; u8 ip_type; u8 addr[16U]; u32 rsvd0; } ; 311 struct mgmt_conn_info { u32 connection_handle; u32 connection_status; u16 src_port; u16 dest_port; u16 dest_port_redirected; u16 cid; u32 estimated_throughput; struct ip_addr_format src_ipaddr; struct ip_addr_format dest_ipaddr; struct ip_addr_format dest_ipaddr_redirected; struct mgmt_conn_login_options negotiated_login_options; } ; 325 struct mgmt_session_login_options { u8 flags; u8 error_recovery_level; u16 rsvd0; u32 first_burst_length; u32 max_burst_length; u16 max_connections; u16 max_outstanding_r2t; u16 default_time2wait; u16 default_time2retain; } ; 337 struct mgmt_session_info { u32 session_handle; u32 status; u8 isid[6U]; u16 tsih; u32 session_flags; u16 conn_count; u16 pad; u8 target_name[224U]; u8 initiator_iscsiname[224U]; struct mgmt_session_login_options negotiated_login_options; struct mgmt_conn_info conn_list[1U]; } ; 405 struct be_ip_addr_subnet_format { u16 size_of_structure; u8 ip_type; u8 ipv6_prefix_length; u8 addr[16U]; u8 subnet_mask[16U]; u32 rsvd0; } ; 420 struct be_cmd_get_if_info_resp { struct be_cmd_req_hdr hdr; u32 interface_hndl; u32 vlan_priority; u32 ip_addr_count; u32 dhcp_state; struct be_ip_addr_subnet_format ip_addr; } ; 472 struct be_cmd_get_def_gateway_resp { struct be_cmd_req_hdr hdr; struct ip_addr_format ip_addr; } ; 643 struct be_cmd_get_nic_conf_resp { struct be_cmd_resp_hdr hdr; u32 nic_port_count; u32 speed; u32 max_speed; u32 link_state; u32 max_frame_size; u16 size_of_structure; u8 mac_address[6U]; u32 rsvd[23U]; } ; 655 struct be_cmd_hba_name { struct be_cmd_req_hdr hdr; u16 flags; u16 rsvd0; u8 initiator_name[224U]; u8 initiator_alias[32U]; } ; 670 struct be_cmd_ntwk_link_status_resp { struct be_cmd_resp_hdr hdr; u8 phys_port; u8 mac_duplex; u8 mac_speed; u8 mac_fault; u8 mgmt_mac_duplex; u8 mgmt_mac_speed; u16 qos_link_speed; u32 logical_link_speed; } ; 1006 struct tcp_connect_and_offload_out { struct be_cmd_resp_hdr hdr; u32 connection_handle; u16 cid; u16 rsvd0; } ; 180 struct hwi_controller ; 180 struct beiscsi_conn ; 180 struct iscsi_boot_kset ; 180 struct __anonstruct_fw_config_271 { unsigned int phys_port; unsigned int eqid_count; unsigned int cqid_count; unsigned int iscsi_cid_start[2U]; unsigned int iscsi_cid_count[2U]; unsigned int iscsi_icd_count[2U]; unsigned int iscsi_icd_start[2U]; unsigned int iscsi_chain_start[2U]; unsigned int iscsi_chain_count[2U]; unsigned short iscsi_features; uint16_t dual_ulp_aware; unsigned long ulp_supported; } ; 180 struct beiscsi_hba { struct hba_parameters params; struct hwi_controller *phwi_ctrlr; unsigned int mem_req[22U]; u8 *csr_va; u8 *db_va; u8 *pci_va; struct be_bus_address csr_pa; struct be_bus_address db_pa; struct be_bus_address pci_pa; struct pci_dev *pcidev; unsigned short asic_revision; unsigned int num_cpus; unsigned int nxt_cqid; struct msix_entry msix_entries[64U]; char *msi_name[64U]; bool msix_enabled; struct be_mem_descriptor *init_mem; unsigned short io_sgl_alloc_index; unsigned short io_sgl_free_index; unsigned short io_sgl_hndl_avbl; struct sgl_handle **io_sgl_hndl_base; struct sgl_handle **sgl_hndl_array; unsigned short eh_sgl_alloc_index; unsigned short eh_sgl_free_index; unsigned short eh_sgl_hndl_avbl; struct sgl_handle **eh_sgl_hndl_base; spinlock_t io_sgl_lock; spinlock_t mgmt_sgl_lock; spinlock_t isr_lock; spinlock_t async_pdu_lock; unsigned int age; struct list_head hba_queue; unsigned short cid_to_cri_map[2048U]; struct ulp_cid_info *cid_array_info[2U]; struct iscsi_endpoint **ep_array; struct beiscsi_conn **conn_table; struct iscsi_boot_kset *boot_kset; struct Scsi_Host *shost; struct iscsi_iface *ipv4_iface; struct iscsi_iface *ipv6_iface; struct __anonstruct_fw_config_271 fw_config; unsigned int state; bool fw_timeout; bool ue_detected; struct delayed_work beiscsi_hw_check_task; bool mac_addr_set; u8 mac_address[6U]; char fw_ver_str[32U]; char wq_name[20U]; struct workqueue_struct *wq; struct be_ctrl_info ctrl; unsigned int generation; unsigned int interface_handle; struct mgmt_session_info boot_sess; struct invalidate_command_table inv_tbl[128U]; unsigned int attr_log_enable; int (*iotask_fn)(struct iscsi_task *, struct scatterlist *, uint32_t , uint32_t , uint32_t ); } ; 419 struct beiscsi_session { struct dma_pool *bhs_pool; } ; 426 struct beiscsi_endpoint ; 426 struct beiscsi_conn { struct iscsi_conn *conn; struct beiscsi_hba *phba; u32 exp_statsn; u32 doorbell_offset; u32 beiscsi_conn_cid; struct beiscsi_endpoint *ep; unsigned short login_in_progress; struct wrb_handle *plogin_wrb_handle; struct sgl_handle *plogin_sgl_handle; struct beiscsi_session *beiscsi_sess; struct iscsi_task *task; } ; 443 struct pdu_data_out { u32 dw[12U]; } ; 471 struct be_cmd_bhs { struct iscsi_scsi_req iscsi_hdr; unsigned char pad1[16U]; struct pdu_data_out iscsi_data_pdu; unsigned char pad2[210U]; } ; 478 struct beiscsi_io_task { struct wrb_handle *pwrb_handle; struct sgl_handle *psgl_handle; struct beiscsi_conn *conn; struct scsi_cmnd *scsi_cmnd; unsigned int cmd_sn; unsigned int flags; unsigned short cid; unsigned short header_len; itt_t libiscsi_itt; struct be_cmd_bhs *cmd_bhs; struct be_bus_address bhs_pa; unsigned short bhs_len; dma_addr_t mtask_addr; uint32_t mtask_data_count; uint8_t wrb_type; } ; 515 struct iscsi_sge { u32 dw[4U]; } ; 533 struct beiscsi_offload_params { u32 dw[6U]; } ; 567 struct async_pdu_handle { struct list_head link; struct be_bus_address pa; void *pbuffer; unsigned int consumed; unsigned char index; unsigned char is_header; unsigned short cri; unsigned long buffer_len; } ; 581 struct __anonstruct_wait_queue_272 { unsigned char hdr_received; unsigned char hdr_len; unsigned short bytes_received; unsigned int bytes_needed; struct list_head list; } ; 581 struct hwi_async_entry { struct __anonstruct_wait_queue_272 wait_queue; struct list_head header_busy_list; struct list_head data_busy_list; } ; 594 struct __anonstruct_async_header_273 { struct be_bus_address pa_base; void *va_base; void *ring_base; struct async_pdu_handle *handle_base; unsigned int host_write_ptr; unsigned int ep_read_ptr; unsigned int writables; unsigned int free_entries; unsigned int busy_entries; struct list_head free_list; } ; 594 struct __anonstruct_async_data_274 { struct be_bus_address pa_base; void *va_base; void *ring_base; struct async_pdu_handle *handle_base; unsigned int host_write_ptr; unsigned int ep_read_ptr; unsigned int writables; unsigned int free_entries; unsigned int busy_entries; struct list_head free_list; } ; 594 struct hwi_async_pdu_context { struct __anonstruct_async_header_273 async_header; struct __anonstruct_async_data_274 async_data; unsigned int buffer_size; unsigned int num_entries; unsigned short cid_to_async_cri_map[2048U]; struct hwi_async_entry *async_entry; } ; 719 struct iscsi_wrb { u32 dw[16U]; } ; 975 struct be_ring { u32 pages; u32 id; u32 num; u32 cidx; u32 pidx; u32 item_size; u8 ulp_num; u16 register_set; u16 doorbell_format; u32 doorbell_offset; void *va; } ; 991 struct mcc_wrb ; 991 struct hwi_context_memory ; 991 struct hwi_controller { struct list_head io_sgl_list; struct list_head eh_sgl_list; struct sgl_handle *psgl_handle_base; unsigned int wrb_mem_index; struct hwi_wrb_context *wrb_context; struct mcc_wrb *pmcc_wrb_base; struct be_ring default_pdu_hdr[2U]; struct be_ring default_pdu_data[2U]; struct hwi_context_memory *phwi_ctxt; } ; 1007 enum hwh_type_enum { HWH_TYPE_IO = 1, HWH_TYPE_LOGOUT = 2, HWH_TYPE_TMF = 3, HWH_TYPE_NOP = 4, HWH_TYPE_IO_RD = 5, HWH_TYPE_LOGIN = 11, HWH_TYPE_INVALID = 4294967295 } ; 1017 struct wrb_handle { enum hwh_type_enum type; unsigned short wrb_index; unsigned short nxt_wrb_index; struct iscsi_task *pio_handle; struct iscsi_wrb *pwrb; } ; 1026 struct hwi_context_memory { u16 min_eqd; u16 max_eqd; u16 cur_eqd; struct be_eq_obj be_eq[64U]; struct be_queue_info be_cq[63U]; struct be_queue_info *be_wrbq; struct be_queue_info be_def_hdrq[2U]; struct be_queue_info be_def_dataq[2U]; struct hwi_async_pdu_context *pasync_ctx[2U]; } ; 75 struct mcc_sge { u32 pa_lo; u32 pa_hi; u32 length; } ; 81 union __anonunion_u_278 { struct mcc_sge sgl[19U]; u32 embedded[59U]; } ; 81 struct mcc_wrb_payload { union __anonunion_u_278 u; } ; 88 struct mcc_wrb { u32 dw[0U]; u32 payload_length; u32 tag[2U]; u32 rsvd2[1U]; struct mcc_wrb_payload payload; } ; 230 struct beiscsi_sess ; 230 struct beiscsi_endpoint { struct beiscsi_hba *phba; struct beiscsi_sess *sess; struct beiscsi_conn *conn; struct iscsi_endpoint *openiscsi_ep; unsigned short ip_type; char dst6_addr[64U]; unsigned long dst_addr; unsigned short ep_cid; unsigned int fw_handle; u16 dst_tcpport; u16 cid_vld; } ; 12 struct __wait_queue ; 12 typedef struct __wait_queue wait_queue_t; 15 struct __wait_queue { unsigned int flags; void *private; int (*func)(wait_queue_t *, unsigned int, int, void *); struct list_head task_list; } ; 663 enum irqreturn { IRQ_NONE = 0, IRQ_HANDLED = 1, IRQ_WAKE_THREAD = 2 } ; 16 typedef enum irqreturn irqreturn_t; 1852 struct iscsi_boot_kobj { struct kobject kobj; struct attribute_group *attr_group; struct list_head list; void *data; ssize_t (*show)(void *, int, char *); umode_t (*is_visible)(void *, int); void (*release)(void *); } ; 103 struct iscsi_boot_kset { struct list_head kobj_list; struct kset *kset; } ; 651 struct bsg_buffer { unsigned int payload_len; int sg_cnt; struct scatterlist *sg_list; } ; 38 struct bsg_job { struct device *dev; struct request *req; void *request; void *reply; unsigned int request_len; unsigned int reply_len; struct bsg_buffer request_payload; struct bsg_buffer reply_payload; void *dd_data; } ; 266 struct iscsi_nopin { uint8_t opcode; uint8_t flags; __be16 rsvd2; uint8_t rsvd3; uint8_t dlength[3U]; struct scsi_lun lun; itt_t itt; __be32 ttt; __be32 statsn; __be32 exp_cmdsn; __be32 max_cmdsn; uint8_t rsvd4[12U]; } ; 299 struct iscsi_tm_rsp { uint8_t opcode; uint8_t flags; uint8_t response; uint8_t qualifier; uint8_t hlength; uint8_t dlength[3U]; uint8_t rsvd2[8U]; itt_t itt; itt_t rtt; __be32 statsn; __be32 exp_cmdsn; __be32 max_cmdsn; uint8_t rsvd3[12U]; } ; 547 struct iscsi_logout_rsp { uint8_t opcode; uint8_t flags; uint8_t response; uint8_t rsvd2; uint8_t hlength; uint8_t dlength[3U]; uint8_t rsvd3[8U]; itt_t itt; __be32 rsvd4; __be32 statsn; __be32 exp_cmdsn; __be32 max_cmdsn; __be32 rsvd5; __be16 t2wait; __be16 t2retain; __be32 rsvd6; } ; 465 enum iscsi_err { ISCSI_OK = 0, ISCSI_ERR_DATASN = 1001, ISCSI_ERR_DATA_OFFSET = 1002, ISCSI_ERR_MAX_CMDSN = 1003, ISCSI_ERR_EXP_CMDSN = 1004, ISCSI_ERR_BAD_OPCODE = 1005, ISCSI_ERR_DATALEN = 1006, ISCSI_ERR_AHSLEN = 1007, ISCSI_ERR_PROTO = 1008, ISCSI_ERR_LUN = 1009, ISCSI_ERR_BAD_ITT = 1010, ISCSI_ERR_CONN_FAILED = 1011, ISCSI_ERR_R2TSN = 1012, ISCSI_ERR_SESSION_FAILED = 1013, ISCSI_ERR_HDR_DGST = 1014, ISCSI_ERR_DATA_DGST = 1015, ISCSI_ERR_PARAM_NOT_FOUND = 1016, ISCSI_ERR_NO_SCSI_CMD = 1017, ISCSI_ERR_INVALID_HOST = 1018, ISCSI_ERR_XMIT_FAILED = 1019, ISCSI_ERR_TCP_CONN_CLOSE = 1020, ISCSI_ERR_SCSI_EH_SESSION_RST = 1021 } ; 485 struct iscsi_bsg_host_vendor { uint64_t vendor_id; uint32_t vendor_cmd[0U]; } ; 71 struct iscsi_bsg_host_vendor_reply { uint32_t vendor_rsp[0U]; } ; 78 union __anonunion_rqst_data_216 { struct iscsi_bsg_host_vendor h_vendor; } ; 78 struct iscsi_bsg_request { uint32_t msgcode; union __anonunion_rqst_data_216 rqst_data; } ; 87 union __anonunion_reply_data_217 { struct iscsi_bsg_host_vendor_reply vendor_reply; } ; 87 struct iscsi_bsg_reply { uint32_t result; uint32_t reply_payload_rcv_len; union __anonunion_reply_data_217 reply_data; } ; 48 struct be_mcc_compl { u32 status; u32 tag0; u32 tag1; u32 flags; } ; 82 struct be_async_event_trailer { u32 code; } ; 129 struct be_async_event_link_state { u8 physical_port; u8 port_link_status; u8 port_duplex; u8 port_speed; u8 port_fault; u8 rsvd0[7U]; struct be_async_event_trailer trailer; } ; 217 struct phys_addr { u32 lo; u32 hi; } ; 356 struct be_cmd_get_session_resp { struct be_cmd_resp_hdr hdr; struct mgmt_session_info session_info; } ; 854 struct sol_cqe { u32 dw[4U]; } ; 918 struct common_sol_cqe { u32 exp_cmdsn; u32 res_cnt; u16 wrb_index; u16 cid; u8 hw_sts; u8 cmd_wnd; u8 res_flag; u8 i_resp; u8 i_flags; u8 i_sts; } ; 1019 struct dmsg_cqe { u32 dw[4U]; } ; 504 struct be_status_bhs { struct iscsi_scsi_req iscsi_hdr; unsigned char pad1[16U]; unsigned char sense_info[258U]; } ; 637 struct i_t_dpdu_cqe { u32 dw[4U]; } ; 676 struct be_eq_entry { u32 dw[1U]; } ; 828 struct pdu_nop_out { u32 dw[12U]; } ; 854 struct pdu_base { u32 dw[16U]; } ; 210 struct sockaddr_in { __kernel_sa_family_t sin_family; __be16 sin_port; struct in_addr sin_addr; unsigned char __pad[8U]; } ; 41 struct sockaddr_in6 { unsigned short sin6_family; __be16 sin6_port; __be32 sin6_flowinfo; struct in6_addr sin6_addr; __u32 sin6_scope_id; } ; 351 struct be_cmd_get_session_req { struct be_cmd_req_hdr hdr; u32 session_handle; } ; 366 struct be_cmd_get_boot_target_req { struct be_cmd_req_hdr hdr; } ; 370 struct be_cmd_get_boot_target_resp { struct be_cmd_resp_hdr hdr; u32 boot_session_count; int boot_session_handle; } ; 376 struct be_cmd_reopen_session_req { struct be_cmd_req_hdr hdr; u16 reopen_type; u16 rsvd; u32 session_handle; } ; 414 struct be_cmd_get_if_info_req { struct be_cmd_req_hdr hdr; u32 interface_hndl; u32 ip_type; } ; 429 struct be_ip_addr_record { u32 action; u32 interface_hndl; struct be_ip_addr_subnet_format ip_addr; u32 status; } ; 436 struct be_ip_addr_record_params { u32 record_entry_count; struct be_ip_addr_record ip_record; } ; 441 struct be_cmd_set_ip_addr_req { struct be_cmd_req_hdr hdr; struct be_ip_addr_record_params ip_params; } ; 446 struct be_cmd_set_dhcp_req { struct be_cmd_req_hdr hdr; u32 interface_hndl; u32 ip_type; u32 flags; u32 retry_count; } ; 455 struct be_cmd_rel_dhcp_req { struct be_cmd_req_hdr hdr; u32 interface_hndl; u32 ip_type; } ; 461 struct be_cmd_set_def_gateway_req { struct be_cmd_req_hdr hdr; u32 action; struct ip_addr_format ip_addr; } ; 467 struct be_cmd_get_def_gateway_req { struct be_cmd_req_hdr hdr; u32 ip_type; } ; 665 struct be_cmd_ntwk_link_status_req { struct be_cmd_req_hdr hdr; u32 rsvd0; } ; 972 struct iscsi_cleanup_req { struct be_cmd_req_hdr hdr; u16 chute; u8 hdr_ring_id; u8 data_ring_id; } ; 992 struct tcp_connect_and_offload_in { struct be_cmd_req_hdr hdr; struct ip_addr_format ip_address; u16 tcp_port; u16 cid; u16 cq_id; u16 defq_id; struct phys_addr dataout_template_pa; u16 hdr_ring_id; u16 data_ring_id; u8 do_offload; u8 rsvd0[3U]; } ; 1029 struct tcp_upload_params_in { struct be_cmd_req_hdr hdr; u16 id; u16 upload_type; u32 reset_seq; } ; 1045 struct be_ulp_fw_cfg { u32 ulp_mode; u32 etx_base; u32 etx_count; u32 sq_base; u32 sq_count; u32 rq_base; u32 rq_count; u32 dq_base; u32 dq_count; u32 lro_base; u32 lro_count; u32 icd_base; u32 icd_count; } ; 1062 struct be_ulp_chain_icd { u32 chain_base; u32 chain_count; } ; 1067 struct be_fw_cfg { struct be_cmd_req_hdr hdr; u32 be_config_number; u32 asic_revision; u32 phys_port; u32 function_mode; struct be_ulp_fw_cfg ulp[2U]; u32 function_caps; u32 cqid_base; u32 cqid_count; u32 eqid_base; u32 eqid_count; struct be_ulp_chain_icd chain_icd[2U]; } ; 1084 struct be_cmd_get_all_if_id_req { struct be_cmd_req_hdr hdr; u32 if_count; u32 if_hndl_list[1U]; } ; 113 struct iscsi_invalidate_connection_params_in { struct be_cmd_req_hdr hdr; unsigned int session_handle; unsigned short cid; unsigned short unused; unsigned short cleanup_type; unsigned short save_cfg; } ; 137 struct invalidate_commands_params_in { struct be_cmd_req_hdr hdr; unsigned int ref_handle; unsigned int icd_count; struct invalidate_command_table table[128U]; unsigned short cleanup_type; unsigned short unused; } ; 157 struct mgmt_hba_attributes { u8 flashrom_version_string[32U]; u8 manufacturer_name[32U]; u32 supported_modes; u8 seeprom_version_lo; u8 seeprom_version_hi; u8 rsvd0[2U]; u32 fw_cmd_data_struct_version; u32 ep_fw_data_struct_version; u8 ncsi_version_string[12U]; u32 default_extended_timeout; u8 controller_model_number[32U]; u8 controller_description[64U]; u8 controller_serial_number[32U]; u8 ip_version_string[32U]; u8 firmware_version_string[32U]; u8 bios_version_string[32U]; u8 redboot_version_string[32U]; u8 driver_version_string[32U]; u8 fw_on_flash_version_string[32U]; u32 functionalities_supported; u16 max_cdblength; u8 asic_revision; u8 generational_guid[16U]; u8 hba_port_count; u16 default_link_down_timeout; u8 iscsi_ver_min_max; u8 multifunction_device; u8 cache_valid; u8 hba_status; u8 max_domains_supported; u8 phy_port; u32 firmware_post_status; u32 hba_mtu[8U]; u8 iscsi_features; u8 asic_generation; u8 future_u8[2U]; u32 future_u32[3U]; } ; 197 struct mgmt_controller_attributes { struct mgmt_hba_attributes hba_attribs; u16 pci_vendor_id; u16 pci_device_id; u16 pci_sub_vendor_id; u16 pci_sub_system_id; u8 pci_bus_number; u8 pci_device_number; u8 pci_function_number; u8 interface_type; u64 unique_identifier; u8 netfilters; u8 rsvd0[3U]; u32 future_u32[4U]; } ; 213 struct be_mgmt_controller_attributes { struct be_cmd_req_hdr hdr; struct mgmt_controller_attributes params; } ; 218 struct be_mgmt_controller_attributes_resp { struct be_cmd_resp_hdr hdr; struct mgmt_controller_attributes params; } ; 223 struct be_bsg_vendor_cmd { struct be_cmd_req_hdr hdr; unsigned short region; unsigned short offset; unsigned short sector; } ; 146 struct be_mcc_mailbox { struct be_mcc_wrb wrb; struct be_mcc_compl compl; } ; 222 struct virt_addr { u32 lo; u32 hi; } ; 259 struct be_cmd_req_eq_create { struct be_cmd_req_hdr hdr; u16 num_pages; u16 rsvd0; u8 context[16U]; struct phys_addr pages[8U]; } ; 267 struct be_cmd_resp_eq_create { struct be_cmd_resp_hdr resp_hdr; u16 eq_id; u16 rsvd0; } ; 477 struct be_cmd_set_vlan_req { struct be_cmd_req_hdr hdr; u32 interface_hndl; u32 vlan_priority; } ; 528 struct be_cmd_req_cq_create { struct be_cmd_req_hdr hdr; u16 num_pages; u8 page_size; u8 rsvd0; u8 context[16U]; struct phys_addr pages[4U]; } ; 537 struct be_cmd_resp_cq_create { struct be_cmd_resp_hdr hdr; u16 cq_id; u16 rsvd0; } ; 563 struct be_cmd_req_mcc_create { struct be_cmd_req_hdr hdr; u16 num_pages; u16 rsvd0; u8 context[16U]; struct phys_addr pages[8U]; } ; 571 struct be_cmd_resp_mcc_create { struct be_cmd_resp_hdr hdr; u16 id; u16 rsvd0; } ; 586 struct be_cmd_req_q_destroy { struct be_cmd_req_hdr hdr; u16 id; u16 bypass_flush; } ; 755 struct be_default_pdu_context { u32 dw[4U]; } ; 789 struct be_defq_create_req { struct be_cmd_req_hdr hdr; u16 num_pages; u8 ulp_num; u8 dua_feature; struct be_default_pdu_context context; struct phys_addr pages[8U]; } ; 800 struct be_defq_create_resp { struct be_cmd_req_hdr hdr; u16 id; u8 rsvd0; u8 ulp_num; u32 doorbell_offset; u16 register_set; u16 doorbell_format; } ; 810 struct be_post_template_pages_req { struct be_cmd_req_hdr hdr; u16 num_pages; u16 type; struct phys_addr scratch_pa; struct virt_addr scratch_va; struct virt_addr pages_va; struct phys_addr pages[16U]; } ; 821 struct be_remove_template_pages_req { struct be_cmd_req_hdr hdr; u16 type; u16 rsvd0; } ; 827 struct be_post_sgl_pages_req { struct be_cmd_req_hdr hdr; u16 num_pages; u16 page_offset; u32 rsvd0; struct phys_addr pages[26U]; u32 rsvd1; } ; 836 struct be_wrbq_create_req { struct be_cmd_req_hdr hdr; u16 num_pages; u8 ulp_num; u8 dua_feature; struct phys_addr pages[8U]; } ; 844 struct be_wrbq_create_resp { struct be_cmd_resp_hdr resp_hdr; u16 cid; u8 rsvd0; u8 ulp_num; u32 doorbell_offset; u16 register_set; u16 doorbell_format; } ; 38 typedef int Set; 1 long int __builtin_expect(long, long); 1 void * __builtin_memcpy(void *, const void *, unsigned long); 358 extern struct pv_irq_ops pv_irq_ops; 316 int variable_test_bit(long nr, const volatile unsigned long *addr); 132 int printk(const char *, ...); 388 int sprintf(char *, const char *, ...); 71 void warn_slowpath_null(const char *, const int); 34 void * __memcpy(void *, const void *, size_t ); 55 void * memset(void *, int, size_t ); 62 char * strcpy(char *, const char *); 802 unsigned long int arch_local_save_flags(); 22 void * ERR_PTR(long error); 155 int arch_irqs_disabled_flags(unsigned long flags); 1020 int dev_printk(const char *, const struct device *, const char *, ...); 442 struct iscsi_endpoint * iscsi_create_endpoint(int); 443 void iscsi_destroy_endpoint(struct iscsi_endpoint *); 444 struct iscsi_endpoint * iscsi_lookup_endpoint(u64 ); 446 struct iscsi_iface * iscsi_create_iface(struct Scsi_Host *, struct iscsi_transport *, uint32_t , uint32_t , int); 450 void iscsi_destroy_iface(struct iscsi_iface *); 452 char * iscsi_get_port_speed_name(struct Scsi_Host *); 453 char * iscsi_get_port_state_name(struct Scsi_Host *); 387 int iscsi_host_get_param(struct Scsi_Host *, enum iscsi_host_param , char *); 401 struct iscsi_cls_session * iscsi_session_setup(struct iscsi_transport *, struct Scsi_Host *, uint16_t , int, int, uint32_t , unsigned int); 403 void iscsi_session_teardown(struct iscsi_cls_session *); 405 int iscsi_set_param(struct iscsi_cls_conn *, enum iscsi_param , char *, int); 416 struct iscsi_cls_conn * iscsi_conn_setup(struct iscsi_cls_session *, int, uint32_t ); 419 int iscsi_conn_start(struct iscsi_cls_conn *); 421 int iscsi_conn_bind(struct iscsi_cls_session *, struct iscsi_cls_conn *, int); 431 void iscsi_suspend_queue(struct iscsi_conn *); 142 void kfree(const void *); 771 void * shost_priv(struct Scsi_Host *shost); 776 int scsi_is_host_device(const struct device *); 778 struct Scsi_Host * dev_to_shost(struct device *dev); 70 int is_device_dma_capable(struct device *dev); 53 void debug_dma_alloc_coherent(struct device *, size_t , dma_addr_t , void *); 56 void debug_dma_free_coherent(struct device *, size_t , void *, dma_addr_t ); 27 extern struct device x86_dma_fallback_dev; 30 extern struct dma_map_ops *dma_ops; 32 struct dma_map_ops * get_dma_ops(struct device *dev); 107 unsigned long int dma_alloc_coherent_mask(struct device *dev, gfp_t gfp); 119 gfp_t dma_alloc_coherent_gfp_flags(struct device *dev, gfp_t gfp); 135 void * dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t gfp, struct dma_attrs *attrs); 164 void dma_free_attrs(struct device *dev, size_t size, void *vaddr, dma_addr_t bus, struct dma_attrs *attrs); 238 struct nlattr * nla_find(const struct nlattr *, int, int); 668 void * nla_data(const struct nlattr *nla); 687 int nla_ok(const struct nlattr *nla, int remaining); 702 struct nlattr * nla_next(const struct nlattr *nla, int *remaining); 17 struct dma_pool * dma_pool_create(const char *, struct device *, size_t , size_t , size_t ); 20 void dma_pool_destroy(struct dma_pool *); 16 void * pci_alloc_consistent(struct pci_dev *hwdev, size_t size, dma_addr_t *dma_handle); 23 void pci_free_consistent(struct pci_dev *hwdev, size_t size, void *vaddr, dma_addr_t dma_handle); 33 ssize_t sysfs_format_mac(char *, const unsigned char *, int); 607 void * embedded_payload(struct be_mcc_wrb *wrb); 706 unsigned int be_cmd_get_initname(struct beiscsi_hba *phba); 707 unsigned int be_cmd_get_port_speed(struct beiscsi_hba *phba); 711 int beiscsi_mccq_compl(struct beiscsi_hba *phba, uint32_t tag, struct be_mcc_wrb **wrb, void *cmd_hdr); 143 u32 amap_mask(u32 bitsize); 148 void amap_set(void *ptr, u32 dw_offset, u32 mask, u32 offset, u32 value); 821 void beiscsi_free_mgmt_task_handles(struct beiscsi_conn *beiscsi_conn, struct iscsi_task *task); 824 bool beiscsi_error(struct beiscsi_hba *phba); 100 int mgmt_open_connection(struct beiscsi_hba *phba, struct sockaddr *dst_addr, struct beiscsi_endpoint *beiscsi_ep, struct be_dma_mem *nonemb_cmd); 105 unsigned int mgmt_upload_connection(struct beiscsi_hba *phba, unsigned short cid, unsigned int upload_flag); 272 unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba, struct beiscsi_endpoint *beiscsi_ep, unsigned short cid, unsigned short issue_reset, unsigned short savecfg_flag); 278 int mgmt_set_ip(struct beiscsi_hba *phba, struct iscsi_iface_param_info *ip_param, struct iscsi_iface_param_info *subnet_param, uint32_t boot_proto); 293 int mgmt_get_nic_conf(struct beiscsi_hba *phba, struct be_cmd_get_nic_conf_resp *nic); 296 int mgmt_get_if_info(struct beiscsi_hba *phba, int ip_type, struct be_cmd_get_if_info_resp **if_info); 299 int mgmt_get_gateway(struct beiscsi_hba *phba, int ip_type, struct be_cmd_get_def_gateway_resp *gateway); 302 int mgmt_set_gateway(struct beiscsi_hba *phba, struct iscsi_iface_param_info *gateway_param); 308 unsigned int mgmt_get_all_if_id(struct beiscsi_hba *phba); 310 int mgmt_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag); 33 void beiscsi_create_def_ifaces(struct beiscsi_hba *phba); 35 void beiscsi_destroy_def_ifaces(struct beiscsi_hba *phba); 37 int be2iscsi_iface_get_param(struct iscsi_iface *iface, enum iscsi_param_type param_type, int param, char *buf); 41 int be2iscsi_iface_set_param(struct Scsi_Host *shost, void *data, uint32_t dt_len); 44 umode_t be2iscsi_attr_is_visible(int param_type, int param); 46 void beiscsi_offload_connection(struct beiscsi_conn *beiscsi_conn, struct beiscsi_offload_params *params); 53 struct iscsi_cls_session * beiscsi_session_create(struct iscsi_endpoint *ep, unsigned short cmds_max, unsigned short qdepth, unsigned int initial_cmdsn); 58 void beiscsi_session_destroy(struct iscsi_cls_session *cls_session); 60 struct iscsi_cls_conn * beiscsi_conn_create(struct iscsi_cls_session *cls_session, unsigned int cid); 63 int beiscsi_conn_bind(struct iscsi_cls_session *cls_session, struct iscsi_cls_conn *cls_conn, unsigned long long transport_fd, int is_leading); 67 int beiscsi_ep_get_param(struct iscsi_endpoint *ep, enum iscsi_param param, char *buf); 70 int beiscsi_get_host_param(struct Scsi_Host *shost, enum iscsi_host_param param, char *buf); 73 int beiscsi_get_macaddr(char *buf, struct beiscsi_hba *phba); 75 int beiscsi_set_param(struct iscsi_cls_conn *cls_conn, enum iscsi_param param, char *buf, int buflen); 78 int beiscsi_conn_start(struct iscsi_cls_conn *cls_conn); 80 struct iscsi_endpoint * beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr, int non_blocking); 84 int beiscsi_ep_poll(struct iscsi_endpoint *ep, int timeout_ms); 86 void beiscsi_ep_disconnect(struct iscsi_endpoint *ep); 88 void beiscsi_conn_get_stats(struct iscsi_cls_conn *cls_conn, struct iscsi_stats *stats); 32 struct iscsi_transport beiscsi_iscsi_transport; 166 int beiscsi_bindconn_cid(struct beiscsi_hba *phba, struct beiscsi_conn *beiscsi_conn, unsigned int cid); 240 int beiscsi_create_ipv4_iface(struct beiscsi_hba *phba); 259 int beiscsi_create_ipv6_iface(struct beiscsi_hba *phba); 302 int beiscsi_set_static_ip(struct Scsi_Host *shost, struct iscsi_iface_param_info *iface_param, void *data, uint32_t dt_len); 366 int beiscsi_set_vlan_tag(struct Scsi_Host *shost, struct iscsi_iface_param_info *iface_param); 399 int beiscsi_set_ipv4(struct Scsi_Host *shost, struct iscsi_iface_param_info *iface_param, void *data, uint32_t dt_len); 448 int beiscsi_set_ipv6(struct Scsi_Host *shost, struct iscsi_iface_param_info *iface_param, void *data, uint32_t dt_len); 533 int be2iscsi_get_if_param(struct beiscsi_hba *phba, struct iscsi_iface *iface, int param, char *buf); 718 int beiscsi_get_initname(char *buf, struct beiscsi_hba *phba); 751 void beiscsi_get_port_state(struct Scsi_Host *shost); 766 int beiscsi_get_port_speed(struct Scsi_Host *shost); 927 void beiscsi_set_params_for_offld(struct beiscsi_conn *beiscsi_conn, struct beiscsi_offload_params *params); 1008 int beiscsi_get_cid(struct beiscsi_hba *phba); 1043 void beiscsi_put_cid(struct beiscsi_hba *phba, unsigned short cid); 1067 void beiscsi_free_ep(struct beiscsi_endpoint *beiscsi_ep); 1101 int beiscsi_open_conn(struct iscsi_endpoint *ep, struct sockaddr *src_addr, struct sockaddr *dst_addr, int non_blocking); 1273 int beiscsi_close_conn(struct beiscsi_endpoint *beiscsi_ep, int flag); 1297 int beiscsi_unbind_conn_to_cid(struct beiscsi_hba *phba, unsigned int cid); 7 dma_addr_t ldv_dma_map_single_attrs(struct device *dev, void *ptr, size_t size, enum dma_data_direction dir, struct dma_attrs *attrs); 33 extern struct module __this_module; 206 int test_and_set_bit(long nr, volatile unsigned long *addr); 310 int constant_test_bit(long nr, const volatile unsigned long *addr); 481 int fls64(__u64 x); 7 __u32 __arch_swab32(__u32 val); 46 __u16 __fswab16(__u16 val); 57 __u32 __fswab32(__u32 val); 171 unsigned int fls_long(unsigned long l); 61 unsigned long int __roundup_pow_of_two(unsigned long n); 70 unsigned long int __rounddown_pow_of_two(unsigned long n); 391 int snprintf(char *, size_t , const char *, ...); 403 int sscanf(const char *, const char *, ...); 24 void INIT_LIST_HEAD(struct list_head *list); 47 void __list_add(struct list_head *, struct list_head *, struct list_head *); 60 void list_add(struct list_head *new, struct list_head *head); 74 void list_add_tail(struct list_head *new, struct list_head *head); 111 void __list_del_entry(struct list_head *); 112 void list_del(struct list_head *); 153 void list_move(struct list_head *list, struct list_head *head); 186 int list_empty(const struct list_head *head); 61 size_t strlen(const char *); 113 int __bitmap_weight(const unsigned long *, int); 276 int bitmap_weight(const unsigned long *src, int nbits); 28 extern int nr_cpu_ids; 80 extern const const struct cpumask *cpu_online_mask; 459 unsigned int cpumask_weight(const struct cpumask *srcp); 802 unsigned long int arch_local_save_flags___0(); 101 void atomic_dec(atomic_t *v); 279 void lockdep_init_map(struct lockdep_map *, const char *, struct lock_class_key *, int); 93 void __raw_spin_lock_init(raw_spinlock_t *, const char *, struct lock_class_key *); 22 void _raw_spin_lock(raw_spinlock_t *); 28 void _raw_spin_lock_bh(raw_spinlock_t *); 32 unsigned long int _raw_spin_lock_irqsave(raw_spinlock_t *); 39 void _raw_spin_unlock(raw_spinlock_t *); 40 void _raw_spin_unlock_bh(raw_spinlock_t *); 43 void _raw_spin_unlock_irqrestore(raw_spinlock_t *, unsigned long); 290 raw_spinlock_t * spinlock_check(spinlock_t *lock); 301 void spin_lock(spinlock_t *lock); 306 void spin_lock_bh(spinlock_t *lock); 341 void spin_unlock(spinlock_t *lock); 346 void spin_unlock_bh(spinlock_t *lock); 356 void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags); 68 void __init_waitqueue_head(wait_queue_head_t *, const char *, struct lock_class_key *); 822 long int prepare_to_wait_event(wait_queue_head_t *, wait_queue_t *, int); 823 void finish_wait(wait_queue_head_t *, wait_queue_t *); 303 unsigned long int msecs_to_jiffies(const unsigned int); 94 void init_timer_key(struct timer_list *, unsigned int, const char *, struct lock_class_key *); 20 void delayed_work_timer_fn(unsigned long); 192 void __init_work(struct work_struct *, int); 375 extern struct workqueue_struct *system_wq; 397 struct workqueue_struct * __alloc_workqueue_key(const char *, unsigned int, int, struct lock_class_key *, const char *, ...); 457 void destroy_workqueue(struct workqueue_struct *); 464 bool queue_work_on(int, struct workqueue_struct *, struct work_struct *); 466 bool queue_delayed_work_on(int, struct workqueue_struct *, struct delayed_work *, unsigned long); 484 bool cancel_delayed_work_sync(struct delayed_work *); 504 bool queue_work(struct workqueue_struct *wq, struct work_struct *work); 518 bool queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay); 591 bool schedule_delayed_work(struct delayed_work *dwork, unsigned long delay); 46 void msleep(unsigned int); 50 void ssleep(unsigned int seconds); 174 void * ioremap_nocache(resource_size_t , unsigned long); 187 void iounmap(volatile void *); 31 unsigned int ioread32(void *); 37 void iowrite32(u32 , void *); 302 void * __kmalloc(size_t , gfp_t ); 441 void * kmalloc(size_t size, gfp_t flags); 560 void * kmalloc_array(size_t n, size_t size, gfp_t flags); 573 void * kcalloc(size_t n, size_t size, gfp_t flags); 638 void * kzalloc(size_t size, gfp_t flags); 11 void synchronize_irq(unsigned int); 123 int request_threaded_irq(unsigned int, irqreturn_t (*)(int, void *), irqreturn_t (*)(int, void *), unsigned long, const char *, void *); 128 int request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *), unsigned long flags, const char *name, void *dev); 142 void free_irq(unsigned int, void *); 372 long int schedule_timeout(long); 913 void * dev_get_drvdata(const struct device *); 914 int dev_set_drvdata(struct device *, void *); 1029 int dev_err(const struct device *, const char *, ...); 958 void blk_queue_max_segment_size(struct request_queue *, unsigned int); 774 struct pci_dev * pci_dev_get(struct pci_dev *); 775 void pci_dev_put(struct pci_dev *); 902 int pci_enable_device(struct pci_dev *); 919 void pci_disable_device(struct pci_dev *); 922 void pci_set_master(struct pci_dev *); 975 int pci_save_state(struct pci_dev *); 976 void pci_restore_state(struct pci_dev *); 987 int pci_set_power_state(struct pci_dev *, pci_power_t ); 1085 int __pci_register_driver(struct pci_driver *, struct module *, const char *); 1094 void pci_unregister_driver(struct pci_driver *); 22 void * dma_pool_alloc(struct dma_pool *, gfp_t , dma_addr_t *); 25 void dma_pool_free(struct dma_pool *, void *, dma_addr_t ); 1165 int pci_enable_msix(struct pci_dev *, struct msix_entry *, int); 1167 void pci_disable_msix(struct pci_dev *); 224 struct scatterlist * sg_next(struct scatterlist *); 242 size_t sg_copy_from_buffer(struct scatterlist *, unsigned int, void *, size_t ); 63 int valid_dma_direction(int dma_direction); 44 void debug_dma_unmap_page(struct device *, dma_addr_t , size_t , int, bool ); 32 dma_addr_t ldv_dma_map_single_attrs_5(struct device *dev, void *ptr, size_t size, enum dma_data_direction dir, struct dma_attrs *attrs); 33 void dma_unmap_single_attrs(struct device *dev, dma_addr_t addr, size_t size, enum dma_data_direction dir, struct dma_attrs *attrs); 64 int dma_supported(struct device *, u64 ); 164 void dma_free_attrs___0(struct device *dev, size_t size, void *vaddr, dma_addr_t bus, struct dma_attrs *attrs); 91 int dma_set_coherent_mask(struct device *dev, u64 mask); 23 void pci_free_consistent___0(struct pci_dev *hwdev, size_t size, void *vaddr, dma_addr_t dma_handle); 30 dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction); 36 void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, size_t size, int direction); 110 int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask); 1407 void * pci_get_drvdata(struct pci_dev *pdev); 1412 void pci_set_drvdata(struct pci_dev *pdev, void *data); 110 struct iscsi_boot_kobj * iscsi_boot_create_initiator(struct iscsi_boot_kset *, int, void *, ssize_t (*)(void *, int, char *), umode_t (*)(void *, int), void (*)(void *)); 117 struct iscsi_boot_kobj * iscsi_boot_create_ethernet(struct iscsi_boot_kset *, int, void *, ssize_t (*)(void *, int, char *), umode_t (*)(void *, int), void (*)(void *)); 123 struct iscsi_boot_kobj * iscsi_boot_create_target(struct iscsi_boot_kset *, int, void *, ssize_t (*)(void *, int, char *), umode_t (*)(void *, int), void (*)(void *)); 130 struct iscsi_boot_kset * iscsi_boot_create_host_kset(unsigned int); 131 void iscsi_boot_destroy_kset(struct iscsi_boot_kset *); 65 void bsg_job_done(struct bsg_job *, int, unsigned int); 175 struct scsi_transport_template * iscsi_register_transport(struct iscsi_transport *); 176 int iscsi_unregister_transport(struct iscsi_transport *); 370 int iscsi_change_queue_depth(struct scsi_device *, int, int); 372 int iscsi_eh_abort(struct scsi_cmnd *); 374 int iscsi_eh_session_reset(struct scsi_cmnd *); 375 int iscsi_eh_device_reset(struct scsi_cmnd *); 376 int iscsi_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); 389 int iscsi_host_add(struct Scsi_Host *, struct device *); 390 struct Scsi_Host * iscsi_host_alloc(struct scsi_host_template *, int, bool ); 393 void iscsi_host_remove(struct Scsi_Host *); 394 void iscsi_host_free(struct Scsi_Host *); 395 int iscsi_target_alloc(struct scsi_target *); 404 void iscsi_session_recovery_timedout(struct iscsi_cls_session *); 407 int iscsi_session_get_param(struct iscsi_cls_session *, enum iscsi_param , char *); 418 void iscsi_conn_teardown(struct iscsi_cls_conn *); 420 void iscsi_conn_stop(struct iscsi_cls_conn *, int); 423 void iscsi_conn_failure(struct iscsi_conn *, enum iscsi_err ); 426 int iscsi_conn_get_param(struct iscsi_cls_conn *, enum iscsi_param , char *); 445 int iscsi_conn_send_pdu(struct iscsi_cls_conn *, struct iscsi_hdr *, char *, uint32_t ); 449 int __iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *, char *, int); 455 void iscsi_put_task(struct iscsi_task *); 458 void iscsi_complete_scsi_task(struct iscsi_task *, uint32_t , uint32_t ); 778 struct Scsi_Host * dev_to_shost___0(struct device *dev); 806 struct Scsi_Host * scsi_host_get(struct Scsi_Host *); 807 void scsi_host_put(struct Scsi_Host *); 295 struct scsi_target * scsi_target(struct scsi_device *sdev); 156 int scsi_dma_map(struct scsi_cmnd *); 157 void scsi_dma_unmap(struct scsi_cmnd *); 167 struct scatterlist * scsi_sglist(struct scsi_cmnd *cmd); 172 unsigned int scsi_bufflen(struct scsi_cmnd *cmd); 177 void scsi_set_resid(struct scsi_cmnd *cmd, int resid); 18 extern const unsigned char _ctype[]; 38 int pci_enable_pcie_error_reporting(struct pci_dev *); 39 int pci_disable_pcie_error_reporting(struct pci_dev *); 40 int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *); 26 int blk_iopoll_sched_prep(struct blk_iopoll *iop); 39 void blk_iopoll_sched(struct blk_iopoll *); 40 void blk_iopoll_init(struct blk_iopoll *, int, blk_iopoll_fn *); 41 void blk_iopoll_complete(struct blk_iopoll *); 43 void blk_iopoll_enable(struct blk_iopoll *); 44 void blk_iopoll_disable(struct blk_iopoll *); 46 extern int blk_iopoll_enabled; 48 u32 MODULO(u16 val, u16 limit); 54 void index_inc(u16 *index, u16 limit); 69 void * queue_tail_node(struct be_queue_info *q); 79 void queue_tail_inc(struct be_queue_info *q); 689 int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl, struct be_queue_info *eq, int eq_delay); 692 int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl, struct be_queue_info *cq, struct be_queue_info *eq, bool sol_evts, bool no_delay, int coalesce_wm); 697 int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q, int queue_type); 699 int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba, struct be_queue_info *mccq, struct be_queue_info *cq); 704 int mgmt_check_supported_fw(struct be_ctrl_info *ctrl, struct beiscsi_hba *phba); 709 void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag); 714 int be_cmd_fw_initialize(struct be_ctrl_info *ctrl); 715 int be_cmd_fw_uninit(struct be_ctrl_info *ctrl); 722 void beiscsi_async_link_state_process(struct beiscsi_hba *phba, struct be_async_event_link_state *evt); 724 int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl, struct be_mcc_compl *compl); 729 int be_cmd_create_default_pdu_queue(struct be_ctrl_info *ctrl, struct be_queue_info *cq, struct be_queue_info *dq, int length, int entry_size, uint8_t is_header, uint8_t ulp_num); 735 int be_cmd_iscsi_post_template_hdr(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem); 738 int be_cmd_iscsi_remove_template_hdr(struct be_ctrl_info *ctrl); 740 int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem, u32 page_offset___0, u32 num_pages); 744 int beiscsi_cmd_reset_function(struct beiscsi_hba *phba); 746 int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem, struct be_queue_info *wrbq, struct hwi_wrb_context *pwrb_context, uint8_t ulp_num); 751 bool is_link_state_evt(u32 trailer); 1312 int be_chk_reset_complete(struct beiscsi_hba *phba); 163 u32 amap_get(void *ptr, u32 dw_offset, u32 mask, u32 offset); 177 void swap_dws(void *wrb, int len); 816 struct wrb_handle * alloc_wrb_handle(struct beiscsi_hba *phba, unsigned int cid); 818 void free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle); 820 void beiscsi_process_all_cqs(struct work_struct *work); 99 int mgmt_epfw_cleanup(struct beiscsi_hba *phba, unsigned short ulp_num); 108 unsigned int mgmt_invalidate_icds(struct beiscsi_hba *phba, struct invalidate_command_table *inv_tbl, unsigned int num_invalidate, unsigned int cid, struct be_dma_mem *nonemb_cmd); 112 unsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info *ctrl, struct beiscsi_hba *phba, struct bsg_job *job, struct be_dma_mem *nonemb_cmd); 269 int mgmt_get_fw_config(struct be_ctrl_info *ctrl, struct beiscsi_hba *phba); 289 unsigned int mgmt_get_session_info(struct beiscsi_hba *phba, u32 boot_session_handle, struct be_dma_mem *nonemb_cmd); 305 int be_mgmt_get_boot_shandle(struct beiscsi_hba *phba, unsigned int *s_handle); 312 ssize_t beiscsi_drvr_ver_disp(struct device *dev, struct device_attribute *attr, char *buf); 315 ssize_t beiscsi_fw_ver_disp(struct device *dev, struct device_attribute *attr, char *buf); 318 ssize_t beiscsi_active_session_disp(struct device *dev, struct device_attribute *attr, char *buf); 321 ssize_t beiscsi_adap_family_disp(struct device *dev, struct device_attribute *attr, char *buf); 325 ssize_t beiscsi_free_session_disp(struct device *dev, struct device_attribute *attr, char *buf); 328 ssize_t beiscsi_phys_port_disp(struct device *dev, struct device_attribute *attr, char *buf); 331 void beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params, struct wrb_handle *pwrb_handle, struct be_mem_descriptor *mem_descr); 335 void beiscsi_offload_cxn_v2(struct beiscsi_offload_params *params, struct wrb_handle *pwrb_handle); 337 void beiscsi_ue_detect(struct beiscsi_hba *phba); 48 unsigned int be_iopoll_budget = 10U; 49 unsigned int be_max_phys_size = 64U; 50 unsigned int enable_msix = 1U; 52 const struct pci_device_id __mod_pci_device_table = { }; 154 unsigned int beiscsi_log_enable = 0U; 154 ssize_t beiscsi_log_enable_disp(struct device *dev, struct device_attribute *attrib, char *buf); 154 int beiscsi_log_enable_change(struct beiscsi_hba *phba, uint32_t val); 154 ssize_t beiscsi_log_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); 154 int beiscsi_log_enable_init(struct beiscsi_hba *phba, uint32_t val); 154 struct device_attribute dev_attr_beiscsi_log_enable = { { "beiscsi_log_enable", 420U, (_Bool)0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &beiscsi_log_enable_disp, &beiscsi_log_enable_store }; 156 struct device_attribute dev_attr_beiscsi_drvr_ver = { { "beiscsi_drvr_ver", 292U, (_Bool)0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &beiscsi_drvr_ver_disp, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 }; 157 struct device_attribute dev_attr_beiscsi_adapter_family = { { "beiscsi_adapter_family", 292U, (_Bool)0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &beiscsi_adap_family_disp, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 }; 158 struct device_attribute dev_attr_beiscsi_fw_ver = { { "beiscsi_fw_ver", 292U, (_Bool)0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &beiscsi_fw_ver_disp, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 }; 159 struct device_attribute dev_attr_beiscsi_phys_port = { { "beiscsi_phys_port", 292U, (_Bool)0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &beiscsi_phys_port_disp, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 }; 161 struct device_attribute dev_attr_beiscsi_active_session_count = { { "beiscsi_active_session_count", 292U, (_Bool)0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &beiscsi_active_session_disp, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 }; 163 struct device_attribute dev_attr_beiscsi_free_session_count = { { "beiscsi_free_session_count", 292U, (_Bool)0, 0, { { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } } } }, &beiscsi_free_session_disp, (ssize_t (*)(struct device *, struct device_attribute *, const char *, size_t ))0 }; 164 struct device_attribute *beiscsi_attrs[8U] = { &dev_attr_beiscsi_log_enable, &dev_attr_beiscsi_drvr_ver, &dev_attr_beiscsi_adapter_family, &dev_attr_beiscsi_fw_ver, &dev_attr_beiscsi_active_session_count, &dev_attr_beiscsi_free_session_count, &dev_attr_beiscsi_phys_port, (struct device_attribute *)0 }; 175 const char *cqe_desc[36U] = { "RESERVED_DESC", "SOL_CMD_COMPLETE", "SOL_CMD_KILLED_DATA_DIGEST_ERR", "CXN_KILLED_PDU_SIZE_EXCEEDS_DSL", "CXN_KILLED_BURST_LEN_MISMATCH", "CXN_KILLED_AHS_RCVD", "CXN_KILLED_HDR_DIGEST_ERR", "CXN_KILLED_UNKNOWN_HDR", "CXN_KILLED_STALE_ITT_TTT_RCVD", "CXN_KILLED_INVALID_ITT_TTT_RCVD", "CXN_KILLED_RST_RCVD", "CXN_KILLED_TIMED_OUT", "CXN_KILLED_RST_SENT", "CXN_KILLED_FIN_RCVD", "CXN_KILLED_BAD_UNSOL_PDU_RCVD", "CXN_KILLED_BAD_WRB_INDEX_ERROR", "CXN_KILLED_OVER_RUN_RESIDUAL", "CXN_KILLED_UNDER_RUN_RESIDUAL", "CMD_KILLED_INVALID_STATSN_RCVD", "CMD_KILLED_INVALID_R2T_RCVD", "CMD_CXN_KILLED_LUN_INVALID", "CMD_CXN_KILLED_ICD_INVALID", "CMD_CXN_KILLED_ITT_INVALID", "CMD_CXN_KILLED_SEQ_OUTOFORDER", "CMD_CXN_KILLED_INVALID_DATASN_RCVD", "CXN_INVALIDATE_NOTIFY", "CXN_INVALIDATE_INDEX_NOTIFY", "CMD_INVALIDATED_NOTIFY", "UNSOL_HDR_NOTIFY", "UNSOL_DATA_NOTIFY", "UNSOL_DATA_DIGEST_ERROR_NOTIFY", "DRIVERMSG_NOTIFY", "CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN", "SOL_CMD_KILLED_DIF_ERR", "CXN_KILLED_SYN_RCVD", "CXN_KILLED_IMM_DATA_RCVD" }; 214 int beiscsi_slave_configure(struct scsi_device *sdev); 220 int beiscsi_eh_abort(struct scsi_cmnd *sc); 295 int beiscsi_eh_device_reset(struct scsi_cmnd *sc); 373 ssize_t beiscsi_show_boot_tgt_info(void *data, int type, char *buf); 440 ssize_t beiscsi_show_boot_ini_info(void *data, int type, char *buf); 457 ssize_t beiscsi_show_boot_eth_info(void *data, int type, char *buf); 481 umode_t beiscsi_tgt_get_attr_visibility(void *data, int type); 504 umode_t beiscsi_ini_get_attr_visibility(void *data, int type); 520 umode_t beiscsi_eth_get_attr_visibility(void *data, int type); 538 const struct pci_device_id beiscsi_pci_id_table[7U] = { { 6562U, 530U, 4294967295U, 4294967295U, 0U, 0U, 0UL }, { 6562U, 546U, 4294967295U, 4294967295U, 0U, 0U, 0UL }, { 6562U, 1794U, 4294967295U, 4294967295U, 0U, 0U, 0UL }, { 6562U, 1795U, 4294967295U, 4294967295U, 0U, 0U, 0UL }, { 6562U, 1810U, 4294967295U, 4294967295U, 0U, 0U, 0UL }, { 4319U, 1826U, 4294967295U, 4294967295U, 0U, 0U, 0UL }, { 0U, 0U, 0U, 0U, 0U, 0U, 0UL } }; 550 struct scsi_host_template beiscsi_sht = { &__this_module, "Emulex 10Gbe open-iscsi Initiator Driver", 0, 0, 0, 0, 0, &iscsi_queuecommand, 0, &beiscsi_eh_abort, &beiscsi_eh_device_reset, &iscsi_eh_session_reset, 0, 0, 0, &beiscsi_slave_configure, 0, &iscsi_target_alloc, 0, 0, 0, &iscsi_change_queue_depth, 0, 0, 0, 0, 0, 0, 0, "be2iscsi", 0, 1024, -1, 30U, (unsigned short)0, 2048U, 0UL, 128, 0U, 0U, 0U, 1U, 0U, 0U, 0U, 0U, 0U, 0U, (struct device_attribute **)(&beiscsi_attrs), 0, { 0, 0 }, 72057594037934498ULL }; 572 struct scsi_transport_template *beiscsi_scsi_transport = 0; 574 struct beiscsi_hba * beiscsi_hba_alloc(struct pci_dev *pcidev); 609 void beiscsi_unmap_pci_function(struct beiscsi_hba *phba); 625 int beiscsi_map_pci_bars(struct beiscsi_hba *phba, struct pci_dev *pcidev); 666 int beiscsi_enable_pci(struct pci_dev *pcidev); 689 int be_ctrl_init(struct beiscsi_hba *phba, struct pci_dev *pdev); 724 void beiscsi_get_params(struct beiscsi_hba *phba); 802 void hwi_ring_eq_db(struct beiscsi_hba *phba, unsigned int id, unsigned int clr_interrupt, unsigned int num_processed, unsigned char rearm, unsigned char event); 824 irqreturn_t be_isr_mcc(int irq, void *dev_id); 869 irqreturn_t be_isr_msix(int irq, void *dev_id); 924 irqreturn_t be_isr(int irq, void *dev_id); 1025 int beiscsi_init_irqs(struct beiscsi_hba *phba); 1097 void hwi_ring_cq_db(struct beiscsi_hba *phba, unsigned int id, unsigned int num_processed, unsigned char rearm, unsigned char event); 1110 unsigned int beiscsi_process_async_pdu(struct beiscsi_conn *beiscsi_conn, struct beiscsi_hba *phba, struct pdu_base *ppdu, unsigned long pdu_len, void *pbuffer, unsigned long buf_len); 1160 struct sgl_handle * alloc_io_sgl_handle(struct beiscsi_hba *phba); 1185 void free_io_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle); 1253 void free_wrb_handle(struct beiscsi_hba *phba, struct hwi_wrb_context *pwrb_context, struct wrb_handle *pwrb_handle); 1271 struct sgl_handle * alloc_mgmt_sgl_handle(struct beiscsi_hba *phba); 1325 void be_complete_io(struct beiscsi_conn *beiscsi_conn, struct iscsi_task *task, struct common_sol_cqe *csol_cqe); 1388 void be_complete_logout(struct beiscsi_conn *beiscsi_conn, struct iscsi_task *task, struct common_sol_cqe *csol_cqe); 1415 void be_complete_tmf(struct beiscsi_conn *beiscsi_conn, struct iscsi_task *task, struct common_sol_cqe *csol_cqe); 1436 void hwi_complete_drvr_msgs(struct beiscsi_conn *beiscsi_conn, struct beiscsi_hba *phba, struct sol_cqe *psol); 1470 void be_complete_nopin_resp(struct beiscsi_conn *beiscsi_conn, struct iscsi_task *task, struct common_sol_cqe *csol_cqe); 1489 void adapter_get_sol_cqe(struct beiscsi_hba *phba, struct sol_cqe *psol, struct common_sol_cqe *csol_cqe); 1543 void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn, struct beiscsi_hba *phba, struct sol_cqe *psol); 1614 struct list_head * hwi_get_async_busy_list(struct hwi_async_pdu_context *pasync_ctx, unsigned int is_header, unsigned int host_write_ptr); 1626 struct async_pdu_handle * hwi_get_async_handle(struct beiscsi_hba *phba, struct beiscsi_conn *beiscsi_conn, struct hwi_async_pdu_context *pasync_ctx, struct i_t_dpdu_cqe *pdpdu_cqe, unsigned int *pcq_index); 1699 unsigned int hwi_update_async_writables(struct beiscsi_hba *phba, struct hwi_async_pdu_context *pasync_ctx, unsigned int is_header, unsigned int cq_index); 1749 void hwi_free_async_msg(struct beiscsi_hba *phba, struct hwi_async_pdu_context *pasync_ctx, unsigned int cri); 1777 struct phys_addr * hwi_get_ring_address(struct hwi_async_pdu_context *pasync_ctx, unsigned int is_header, unsigned int host_write_ptr); 1790 void hwi_post_async_buffers(struct beiscsi_hba *phba, unsigned int is_header, uint8_t ulp_num); 1875 void hwi_flush_default_pdu_buffer(struct beiscsi_hba *phba, struct beiscsi_conn *beiscsi_conn, struct i_t_dpdu_cqe *pdpdu_cqe); 1905 unsigned int hwi_fwd_async_msg(struct beiscsi_conn *beiscsi_conn, struct beiscsi_hba *phba, struct hwi_async_pdu_context *pasync_ctx, unsigned short cri); 1945 unsigned int hwi_gather_async_pdu(struct beiscsi_conn *beiscsi_conn, struct beiscsi_hba *phba, struct async_pdu_handle *pasync_handle); 2012 void hwi_process_default_pdu_ring(struct beiscsi_conn *beiscsi_conn, struct beiscsi_hba *phba, struct i_t_dpdu_cqe *pdpdu_cqe); 2041 void beiscsi_process_mcc_isr(struct beiscsi_hba *phba); 2092 unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq); 2287 int be_iopoll(struct blk_iopoll *iop, int budget); 2308 void hwi_write_sgl_v2(struct iscsi_wrb *pwrb, struct scatterlist *sg, unsigned int num_sg, struct beiscsi_io_task *io_task); 2403 void hwi_write_sgl(struct iscsi_wrb *pwrb, struct scatterlist *sg, unsigned int num_sg, struct beiscsi_io_task *io_task); 2495 void hwi_write_buffer(struct iscsi_wrb *pwrb, struct iscsi_task *task); 2577 void beiscsi_find_mem_req(struct beiscsi_hba *phba); 2682 int beiscsi_alloc_mem(struct beiscsi_hba *phba); 2796 int beiscsi_get_memory(struct beiscsi_hba *phba); 2802 void iscsi_init_global_templates(struct beiscsi_hba *phba); 2827 int beiscsi_init_wrb_handle(struct beiscsi_hba *phba); 2928 int hwi_init_async_pdu_ctx(struct beiscsi_hba *phba); 3171 int be_sgl_create_contiguous(void *virtual_address, u64 physical_address, u32 length, struct be_dma_mem *sgl); 3187 void be_sgl_destroy_contiguous(struct be_dma_mem *sgl); 3193 void hwi_build_be_sgl_arr(struct beiscsi_hba *phba, struct mem_array *pmem, struct be_dma_mem *sgl); 3205 void hwi_build_be_sgl_by_offset(struct beiscsi_hba *phba, struct mem_array *pmem, struct be_dma_mem *sgl); 3216 int be_fill_queue(struct be_queue_info *q, u16 len, u16 entry_size, void *vaddress); 3232 int beiscsi_create_eqs(struct beiscsi_hba *phba, struct hwi_context_memory *phwi_context); 3295 int beiscsi_create_cqs(struct beiscsi_hba *phba, struct hwi_context_memory *phwi_context); 3359 int beiscsi_create_def_hdr(struct beiscsi_hba *phba, struct hwi_context_memory *phwi_context, struct hwi_controller *phwi_ctrlr, unsigned int def_pdu_ring_sz, uint8_t ulp_num); 3412 int beiscsi_create_def_data(struct beiscsi_hba *phba, struct hwi_context_memory *phwi_context, struct hwi_controller *phwi_ctrlr, unsigned int def_pdu_ring_sz, uint8_t ulp_num); 3472 int beiscsi_post_template_hdr(struct beiscsi_hba *phba); 3506 int beiscsi_post_pages(struct beiscsi_hba *phba); 3542 void be_queue_free(struct beiscsi_hba *phba, struct be_queue_info *q); 3552 int be_queue_alloc(struct beiscsi_hba *phba, struct be_queue_info *q, u16 len, u16 entry_size); 3569 int beiscsi_create_wrb_rings(struct beiscsi_hba *phba, struct hwi_context_memory *phwi_context, struct hwi_controller *phwi_ctrlr); 3671 void free_wrb_handles(struct beiscsi_hba *phba); 3685 void be_mcc_queues_destroy(struct beiscsi_hba *phba); 3701 void hwi_cleanup(struct beiscsi_hba *phba); 3758 int be_mcc_queues_create(struct beiscsi_hba *phba, struct hwi_context_memory *phwi_context); 3807 void find_num_cpus(struct beiscsi_hba *phba); 3839 int hwi_init_port(struct beiscsi_hba *phba); 3961 int hwi_init_controller(struct beiscsi_hba *phba); 3998 void beiscsi_free_mem(struct beiscsi_hba *phba); 4023 int beiscsi_init_controller(struct beiscsi_hba *phba); 4048 int beiscsi_init_sgl_handle(struct beiscsi_hba *phba); 4156 int hba_setup_cid_tbls(struct beiscsi_hba *phba); 4257 void hwi_enable_intr(struct beiscsi_hba *phba); 4298 void hwi_disable_intr(struct beiscsi_hba *phba); 4324 int beiscsi_get_boot_info(struct beiscsi_hba *phba); 4384 void beiscsi_boot_release(void *data); 4391 int beiscsi_setup_boot_info(struct beiscsi_hba *phba); 4440 int beiscsi_init_port(struct beiscsi_hba *phba); 4474 void hwi_purge_eq(struct beiscsi_hba *phba); 4507 void beiscsi_clean_port(struct beiscsi_hba *phba); 4595 void beiscsi_cleanup_task(struct iscsi_task *task); 4674 void beiscsi_parse_pdu(struct iscsi_conn *conn, itt_t itt, int *index, int *age); 4692 int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode); 4844 int beiscsi_iotask_v2(struct iscsi_task *task, struct scatterlist *sg, unsigned int num_sg, unsigned int xferlen, unsigned int writedir); 4901 int beiscsi_iotask(struct iscsi_task *task, struct scatterlist *sg, unsigned int num_sg, unsigned int xferlen, unsigned int writedir); 4957 int beiscsi_mtask(struct iscsi_task *task); 5060 int beiscsi_task_xmit(struct iscsi_task *task); 5104 int beiscsi_bsg_request(struct bsg_job *job); 5182 void beiscsi_hba_attrs_init(struct beiscsi_hba *phba); 5195 void beiscsi_quiesce(struct beiscsi_hba *phba, uint32_t unload_state); 5244 void beiscsi_remove(struct pci_dev *pcidev); 5266 void beiscsi_shutdown(struct pci_dev *pcidev); 5281 void beiscsi_msix_enable(struct beiscsi_hba *phba); 5303 void beiscsi_hw_health_check(struct work_struct *work); 5316 pci_ers_result_t beiscsi_eeh_err_detected(struct pci_dev *pdev, pci_channel_state_t state); 5349 pci_ers_result_t beiscsi_eeh_reset(struct pci_dev *pdev); 5382 void beiscsi_eeh_resume(struct pci_dev *pdev); 5476 int beiscsi_dev_probe(struct pci_dev *pcidev, const struct pci_device_id *id); 5697 struct pci_error_handlers beiscsi_eeh_handlers = { (pci_ers_result_t (*)(struct pci_dev *, enum pci_channel_state ))(&beiscsi_eeh_err_detected), 0, 0, &beiscsi_eeh_reset, &beiscsi_eeh_resume }; 5703 struct iscsi_transport beiscsi_iscsi_transport = { &__this_module, (char *)"be2iscsi", 2233U, &beiscsi_session_create, &beiscsi_session_destroy, &beiscsi_conn_create, &beiscsi_conn_bind, &beiscsi_conn_start, &iscsi_conn_stop, &iscsi_conn_teardown, &beiscsi_set_param, &beiscsi_ep_get_param, &iscsi_conn_get_param, &iscsi_session_get_param, &beiscsi_get_host_param, 0, &iscsi_conn_send_pdu, &beiscsi_conn_get_stats, 0, &beiscsi_task_xmit, &beiscsi_cleanup_task, &beiscsi_alloc_pdu, 0, 0, &beiscsi_parse_pdu, &iscsi_session_recovery_timedout, &beiscsi_ep_connect, &beiscsi_ep_poll, &beiscsi_ep_disconnect, 0, 0, &be2iscsi_iface_set_param, &be2iscsi_iface_get_param, &be2iscsi_attr_is_visible, &beiscsi_bsg_request, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 5736 struct pci_driver beiscsi_pci_driver = { { 0, 0 }, "be2iscsi", (const struct pci_device_id *)(&beiscsi_pci_id_table), &beiscsi_dev_probe, &beiscsi_remove, 0, 0, 0, 0, &beiscsi_shutdown, 0, (const struct pci_error_handlers *)(&beiscsi_eeh_handlers), { 0, 0, 0, 0, (_Bool)0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { { { { { { 0U } }, 0U, 0U, 0, { 0, { 0, 0 }, 0, 0, 0UL } } } }, { 0, 0 } } }; 5746 int beiscsi_module_init(); 5773 void beiscsi_module_exit(); 5798 void ldv_check_final_state(); 5801 void ldv_check_return_value(int); 5804 void ldv_check_return_value_probe(int); 5807 void ldv_initialize(); 5810 void ldv_handler_precall(); 5813 int nondet_int(); 5816 int LDV_IN_INTERRUPT = 0; 5819 void ldv_main1_sequence_infinite_withcheck_stateful(); 71 void set_bit(long nr, volatile unsigned long *addr); 802 unsigned long int arch_local_save_flags___1(); 244 size_t sg_copy_to_buffer(struct scatterlist *, unsigned int, void *, size_t ); 824 int pci_bus_read_config_dword(struct pci_bus *, unsigned int, int, u32 *); 842 int pci_read_config_dword(const struct pci_dev *dev, int where, u32 *val); 164 void dma_free_attrs___1(struct device *dev, size_t size, void *vaddr, dma_addr_t bus, struct dma_attrs *attrs); 23 void pci_free_consistent___1(struct pci_dev *hwdev, size_t size, void *vaddr, dma_addr_t dma_handle); 612 struct be_sge * nonembedded_sgl(struct be_mcc_wrb *wrb); 717 struct be_mcc_wrb * wrb_from_mbox(struct be_dma_mem *mbox_mem); 718 struct be_mcc_wrb * wrb_from_mccq(struct beiscsi_hba *phba); 719 int be_mcc_notify_wait(struct beiscsi_hba *phba); 720 void be_mcc_notify(struct beiscsi_hba *phba); 721 unsigned int alloc_mcc_tag(struct beiscsi_hba *phba); 727 int be_mbox_notify(struct be_ctrl_info *ctrl); 754 int be_cmd_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag); 1314 void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len, bool embedded, u8 sge_cnt); 1317 void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr, u8 subsystem, u8 opcode, int cmd_len); 283 unsigned int mgmt_get_boot_target(struct beiscsi_hba *phba); 285 unsigned int mgmt_reopen_session(struct beiscsi_hba *phba, unsigned int reopen_type, unsigned int sess_handle); 28 const const char *desc_ue_status_low[32U] = { "CEV", "CTX", "DBUF", "ERX", "Host", "MPU", "NDMA", "PTC ", "RDMA ", "RXF ", "RXIPS ", "RXULP0 ", "RXULP1 ", "RXULP2 ", "TIM ", "TPOST ", "TPRE ", "TXIPS ", "TXULP0 ", "TXULP1 ", "UC ", "WDMA ", "TXULP2 ", "HOST1 ", "P0_OB_LINK ", "P1_OB_LINK ", "HOST_GPIO ", "MBOX ", "AXGMAC0", "AXGMAC1", "JTAG", "MPU_INTPEND" }; 64 const const char *desc_ue_status_hi[32U] = { "LPCMEMHOST", "MGMT_MAC", "PCS0ONLINE", "MPU_IRAM", "PCS1ONLINE", "PCTL0", "PCTL1", "PMEM", "RR", "TXPB", "RXPP", "XAUI", "TXP", "ARM", "IPC", "HOST2", "HOST3", "HOST4", "HOST5", "HOST6", "HOST7", "HOST8", "HOST9", "NETC", "Unknown", "Unknown", "Unknown", "Unknown", "Unknown", "Unknown", "Unknown", "Unknown" }; 802 int mgmt_exec_nonemb_cmd(struct beiscsi_hba *phba, struct be_dma_mem *nonemb_cmd, void *resp_buf, int resp_buf_len); 853 int mgmt_alloc_cmd_data(struct beiscsi_hba *phba, struct be_dma_mem *cmd, int iscsi_cmd, int size); 869 int mgmt_static_ip_modify(struct beiscsi_hba *phba, struct be_cmd_get_if_info_resp *if_info, struct iscsi_iface_param_info *ip_param, struct iscsi_iface_param_info *subnet_param, uint32_t ip_action); 920 int mgmt_modify_gateway(struct beiscsi_hba *phba, uint8_t *gt_addr, uint32_t gtway_action, uint32_t param_len); 439 int fls(int x); 32 int __ilog2_u32(u32 n); 24 int atomic_read(const atomic_t *v); 89 void atomic_inc(atomic_t *v); 144 void __wake_up(wait_queue_head_t *, unsigned int, int, void *); 77 extern volatile unsigned long jiffies; 55 unsigned int readl(const volatile void *addr); 63 void writel(unsigned int val, volatile void *addr); 282 void iscsi_host_for_each_session(struct Scsi_Host *, void (*)(struct iscsi_cls_session *)); 424 void iscsi_session_failure(struct iscsi_session *, enum iscsi_err ); 10 void __const_udelay(unsigned long); 59 void * queue_head_node(struct be_queue_info *q); 64 void * queue_get_wrb(struct be_queue_info *q, unsigned int wrb_num); 74 void queue_head_inc(struct be_queue_info *q); 1311 int beiscsi_pci_soft_reset(struct beiscsi_hba *phba); 258 bool be_mcc_compl_is_new(struct be_mcc_compl *compl); 268 void be_mcc_compl_use(struct be_mcc_compl *compl); 284 int be_mcc_compl_process(struct be_ctrl_info *ctrl, struct be_mcc_compl *compl); 345 struct be_mcc_compl * be_mcc_compl_get(struct beiscsi_hba *phba); 357 void be2iscsi_fail_session(struct iscsi_cls_session *cls_session); 389 void beiscsi_cq_notify(struct beiscsi_hba *phba, u16 qid, bool arm, u16 num_popped); 401 int beiscsi_process_mcc(struct beiscsi_hba *phba); 448 int be_mcc_wait_compl(struct beiscsi_hba *phba); 501 int be_mbox_db_ready_wait(struct be_ctrl_info *ctrl); 614 int be_mbox_notify_wait(struct beiscsi_hba *phba); 684 void be_cmd_page_addrs_prepare(struct phys_addr *pages, u32 max_pages, struct be_dma_mem *mem); 698 u32 eq_delay_to_mult(u32 usec_delay); 928 u32 be_encoded_q_len(int q_len); 10 void ldv_error(); 25 int ldv_undef_int(); 26 void * ldv_undef_ptr(); 8 int LDV_DMA_MAP_CALLS = 0; 11 dma_addr_t ldv_dma_map_page(struct device *dev, struct page *page, size_t offset, size_t size, enum dma_data_direction dir); 25 int ldv_dma_mapping_error(struct device *dev, dma_addr_t dma_addr); 41 dma_addr_t ldv_dma_map_single(struct device *dev, void *cpu_addr, size_t size, enum dma_data_direction dir); return ; } { 5821 struct scsi_device *var_group1; 5822 struct scsi_cmnd *var_group2; 5823 struct pci_dev *var_group3; 5824 unsigned int var_beiscsi_eeh_err_detected_107_p1; 5825 struct iscsi_task *var_group4; 5826 unsigned char var_beiscsi_alloc_pdu_95_p1; 5827 struct iscsi_conn *var_group5; 5828 unsigned int var_beiscsi_parse_pdu_94_p1; 5829 int *var_beiscsi_parse_pdu_94_p2; 5830 int *var_beiscsi_parse_pdu_94_p3; 5831 struct bsg_job *var_group6; 5832 const struct pci_device_id *var_beiscsi_dev_probe_110_p1; 5833 int res_beiscsi_dev_probe_110; 5834 int var_be_isr_18_p0; 5835 void *var_be_isr_18_p1; 5836 int var_be_isr_mcc_16_p0; 5837 void *var_be_isr_mcc_16_p1; 5838 int var_be_isr_msix_17_p0; 5839 void *var_be_isr_msix_17_p1; 5840 int ldv_s_beiscsi_pci_driver_pci_driver; 5841 int tmp; 5842 int tmp___0; 5843 int tmp___1; 7269 ldv_s_beiscsi_pci_driver_pci_driver = 0; 7171 LDV_IN_INTERRUPT = 1; 7260 ldv_handler_precall() { /* Function call is skipped due to function is undefined */} { 5748 int ret; 5750 beiscsi_scsi_transport = iscsi_register_transport(&beiscsi_iscsi_transport) { /* Function call is skipped due to function is undefined */} 5752 assume(!(((unsigned long)beiscsi_scsi_transport) == ((unsigned long)((struct scsi_transport_template *)0)))); 5757 printk("\016In beiscsi_module_init, tt=%p\n", &beiscsi_iscsi_transport) { /* Function call is skipped due to function is undefined */} 5760 ret = __pci_register_driver(&beiscsi_pci_driver, &__this_module, "be2iscsi") { /* Function call is skipped due to function is undefined */} } 7275 goto ldv_53267; 7275 tmp___1 = nondet_int() { /* Function call is skipped due to function is undefined */} 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) 7909 ldv_handler_precall() { /* Function call is skipped due to function is undefined */} { 5062 struct beiscsi_io_task *io_task; 5063 struct scsi_cmnd *sc; 5064 struct beiscsi_hba *phba; 5065 struct scatterlist *sg; 5066 int num_sg; 5067 unsigned int writedir; 5068 unsigned int xferlen; 5069 int tmp; 5070 struct iscsi_conn *conn; 5071 struct beiscsi_hba *phba___0; 5072 unsigned int log_value; 5073 unsigned int tmp___0; 5074 unsigned int tmp___1; 5075 int tmp___2; 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; { } 4959 struct beiscsi_io_task *io_task; 4960 struct iscsi_conn *conn; 4961 struct beiscsi_conn *beiscsi_conn; 4962 struct beiscsi_hba *phba; 4963 struct iscsi_wrb *pwrb; 4964 unsigned int doorbell; 4965 unsigned int cid; 4966 unsigned int pwrb_typeoffset; 4967 unsigned int tmp; 4968 unsigned int tmp___0; 4969 unsigned int tmp___1; 4970 unsigned int tmp___2; 4971 unsigned int tmp___3; 4972 unsigned int tmp___4; 4973 unsigned int tmp___5; 4974 unsigned int tmp___6; 4975 unsigned int tmp___7; 4976 unsigned int tmp___8; 4977 unsigned int tmp___9; 4978 unsigned int tmp___10; 4979 unsigned int tmp___11; 4980 unsigned int tmp___12; 4981 unsigned int tmp___13; 4982 unsigned int tmp___14; 4983 unsigned int tmp___15; 4984 unsigned int log_value; 4985 unsigned int tmp___16; 4986 unsigned int tmp___17; 4987 unsigned int tmp___18; 4988 unsigned int tmp___19; 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 */} { 145 u32 __CPAchecker_TMP_0; 145 assume(!(bitsize != 32U)); 145 __CPAchecker_TMP_0 = 4294967295U; 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } 4987 u32 __CPAchecker_TMP_4 = (u32 )(io_task->pwrb_handle->wrb_index); { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } 4993 u32 __CPAchecker_TMP_5 = (u32 )(io_task->pwrb_handle->nxt_wrb_index); { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } 4995 pwrb_typeoffset = 27U; 4999 int __CPAchecker_TMP_6 = (int)(task->hdr->opcode); 4999 switch (__CPAchecker_TMP_6 & 63) { 145 u32 __CPAchecker_TMP_0; 145 assume(!(bitsize != 32U)); 145 __CPAchecker_TMP_0 = 4294967295U; 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } 5002 (pwrb->dw)[0] = ((pwrb->dw)[0]) | ((u32 )(11 << ((int)pwrb_typeoffset))); { 2497 struct iscsi_sge *psgl; 2498 struct beiscsi_io_task *io_task; 2499 struct beiscsi_conn *beiscsi_conn; 2500 struct beiscsi_hba *phba; 2501 unsigned char dsp_value; 2502 unsigned int tmp; 2503 unsigned int tmp___0; 2504 unsigned int tmp___1; 2505 unsigned int tmp___2; 2506 unsigned int tmp___3; 2507 unsigned int tmp___4; 2508 unsigned int tmp___5; 2509 unsigned int tmp___6; 2510 unsigned int tmp___7; 2511 unsigned int tmp___8; 2512 unsigned int tmp___9; 2513 unsigned int tmp___10; 2514 unsigned int tmp___11; 2515 unsigned int tmp___12; 2516 unsigned int tmp___13; 2517 unsigned int tmp___14; 2518 unsigned int tmp___15; 2519 unsigned int tmp___16; 2520 unsigned int tmp___17; 2521 unsigned int tmp___18; 2522 unsigned int tmp___19; 2523 unsigned int tmp___20; 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; { 145 u32 __CPAchecker_TMP_0; 145 assume(!(bitsize != 32U)); 145 __CPAchecker_TMP_0 = 4294967295U; 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(!(bitsize != 32U)); 145 __CPAchecker_TMP_0 = 4294967295U; 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } 2509 unsigned long __CPAchecker_TMP_1 = (unsigned long)(task->data); 2512 dsp_value = (task->data_count) != 0U; { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } 2523 void *__CPAchecker_TMP_2 = (void *)(task->data); 2523 size_t __CPAchecker_TMP_3 = (size_t )(task->data_count); { 33 unsigned long long tmp; 32 struct device *__CPAchecker_TMP_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) { } 14 unsigned long long tmp; { } 58 unsigned long long nonedetermined; 59 void *tmp; 58 tmp = ldv_undef_ptr() { /* Function call is skipped due to function is undefined */} 58 nonedetermined = (dma_addr_t )tmp; 63 LDV_DMA_MAP_CALLS = LDV_DMA_MAP_CALLS + 1; } 2527 io_task->mtask_data_count = task->data_count; { 145 u32 __CPAchecker_TMP_0; 145 assume(!(bitsize != 32U)); 145 __CPAchecker_TMP_0 = 4294967295U; 145 return __CPAchecker_TMP_0;; } 2531 unsigned int __CPAchecker_TMP_4 = (unsigned int)(io_task->mtask_addr); { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(!(bitsize != 32U)); 145 __CPAchecker_TMP_0 = 4294967295U; 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } 2544 psgl = io_task->psgl_handle->pfrag; { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } 2546 u32 __CPAchecker_TMP_5 = (u32 )(io_task->bhs_len); { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(!(bitsize != 32U)); 145 __CPAchecker_TMP_0 = 4294967295U; 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(!(bitsize != 32U)); 145 __CPAchecker_TMP_0 = 4294967295U; 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } 2552 unsigned long __CPAchecker_TMP_6 = (unsigned long)(task->data); 2553 psgl = psgl + 1; { 145 u32 __CPAchecker_TMP_0; 145 assume(!(bitsize != 32U)); 145 __CPAchecker_TMP_0 = 4294967295U; 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(!(bitsize != 32U)); 145 __CPAchecker_TMP_0 = 4294967295U; 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } 2561 psgl = psgl + 1; 2562 unsigned long __CPAchecker_TMP_7 = (unsigned long)(task->data); { 145 u32 __CPAchecker_TMP_0; 145 assume(!(bitsize != 32U)); 145 __CPAchecker_TMP_0 = 4294967295U; 145 return __CPAchecker_TMP_0;; } 2563 unsigned int __CPAchecker_TMP_8 = (unsigned int)(io_task->mtask_addr); { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(!(bitsize != 32U)); 145 __CPAchecker_TMP_0 = 4294967295U; 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } { } 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } 5004 goto ldv_52987; 5045 ldv_52987:; { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } { 165 u32 *dw; 165 dw = (u32 *)ptr; 166 return ((*(dw + ((unsigned long)dw_offset))) >> ((int)offset)) & mask;; } 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 */} } 7917 goto ldv_53247; 8833 ldv_53247:; 8834 ldv_53267:; 7275 tmp___1 = nondet_int() { /* Function call is skipped due to function is undefined */} 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) 7909 ldv_handler_precall() { /* Function call is skipped due to function is undefined */} { } 5062 struct beiscsi_io_task *io_task; 5063 struct scsi_cmnd *sc; 5064 struct beiscsi_hba *phba; 5065 struct scatterlist *sg; 5066 int num_sg; 5067 unsigned int writedir; 5068 unsigned int xferlen; 5069 int tmp; 5070 struct iscsi_conn *conn; 5071 struct beiscsi_hba *phba___0; 5072 unsigned int log_value; 5073 unsigned int tmp___0; 5074 unsigned int tmp___1; 5075 int tmp___2; 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; { } 4959 struct beiscsi_io_task *io_task; 4960 struct iscsi_conn *conn; 4961 struct beiscsi_conn *beiscsi_conn; 4962 struct beiscsi_hba *phba; 4963 struct iscsi_wrb *pwrb; 4964 unsigned int doorbell; 4965 unsigned int cid; 4966 unsigned int pwrb_typeoffset; 4967 unsigned int tmp; 4968 unsigned int tmp___0; 4969 unsigned int tmp___1; 4970 unsigned int tmp___2; 4971 unsigned int tmp___3; 4972 unsigned int tmp___4; 4973 unsigned int tmp___5; 4974 unsigned int tmp___6; 4975 unsigned int tmp___7; 4976 unsigned int tmp___8; 4977 unsigned int tmp___9; 4978 unsigned int tmp___10; 4979 unsigned int tmp___11; 4980 unsigned int tmp___12; 4981 unsigned int tmp___13; 4982 unsigned int tmp___14; 4983 unsigned int tmp___15; 4984 unsigned int log_value; 4985 unsigned int tmp___16; 4986 unsigned int tmp___17; 4987 unsigned int tmp___18; 4988 unsigned int tmp___19; 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 */} { 145 u32 __CPAchecker_TMP_0; 145 assume(!(bitsize != 32U)); 145 __CPAchecker_TMP_0 = 4294967295U; 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } 4987 u32 __CPAchecker_TMP_4 = (u32 )(io_task->pwrb_handle->wrb_index); { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } 4993 u32 __CPAchecker_TMP_5 = (u32 )(io_task->pwrb_handle->nxt_wrb_index); { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } 4995 pwrb_typeoffset = 27U; 4999 int __CPAchecker_TMP_6 = (int)(task->hdr->opcode); 4999 switch (__CPAchecker_TMP_6 & 63) 5034 (pwrb->dw)[0] = ((pwrb->dw)[0]) | ((u32 )(2 << ((int)pwrb_typeoffset))); { } 2497 struct iscsi_sge *psgl; 2498 struct beiscsi_io_task *io_task; 2499 struct beiscsi_conn *beiscsi_conn; 2500 struct beiscsi_hba *phba; 2501 unsigned char dsp_value; 2502 unsigned int tmp; 2503 unsigned int tmp___0; 2504 unsigned int tmp___1; 2505 unsigned int tmp___2; 2506 unsigned int tmp___3; 2507 unsigned int tmp___4; 2508 unsigned int tmp___5; 2509 unsigned int tmp___6; 2510 unsigned int tmp___7; 2511 unsigned int tmp___8; 2512 unsigned int tmp___9; 2513 unsigned int tmp___10; 2514 unsigned int tmp___11; 2515 unsigned int tmp___12; 2516 unsigned int tmp___13; 2517 unsigned int tmp___14; 2518 unsigned int tmp___15; 2519 unsigned int tmp___16; 2520 unsigned int tmp___17; 2521 unsigned int tmp___18; 2522 unsigned int tmp___19; 2523 unsigned int tmp___20; 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; { 145 u32 __CPAchecker_TMP_0; 145 assume(!(bitsize != 32U)); 145 __CPAchecker_TMP_0 = 4294967295U; 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } { 145 u32 __CPAchecker_TMP_0; 145 assume(!(bitsize != 32U)); 145 __CPAchecker_TMP_0 = 4294967295U; 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } 2509 unsigned long __CPAchecker_TMP_1 = (unsigned long)(task->data); 2512 dsp_value = (task->data_count) != 0U; { 145 u32 __CPAchecker_TMP_0; 145 assume(bitsize != 32U); 145 __CPAchecker_TMP_0 = (u32 )((1 << ((int)bitsize)) + -1); 145 return __CPAchecker_TMP_0;; } { 151 u32 *dw; 151 dw = ((u32 *)ptr) + ((unsigned long)dw_offset); 152 *dw = (*dw) & (~(mask << ((int)offset))); 153 *dw = (*dw) | ((mask & value) << ((int)offset)); 154 return ;; } 2523 void *__CPAchecker_TMP_2 = (void *)(task->data); 2523 size_t __CPAchecker_TMP_3 = (size_t )(task->data_count); { } 33 unsigned long long tmp; 32 struct device *__CPAchecker_TMP_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) { } 14 unsigned long long tmp; { } 58 unsigned long long nonedetermined; 59 void *tmp; 58 tmp = ldv_undef_ptr() { /* Function call is skipped due to function is undefined */} 58 nonedetermined = (dma_addr_t )tmp; } | 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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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", ¶m_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 */ 1
2 #include <linux/types.h>
3 #include <linux/dma-direction.h>
4
5 extern dma_addr_t ldv_dma_map_page(struct device *dev, struct page *page, size_t offset, size_t size, enum dma_data_direction dir);
6 extern dma_addr_t ldv_dma_map_single(struct device *dev, void *cpu_addr, size_t size, enum dma_data_direction dir);
7 extern dma_addr_t ldv_dma_map_single_attrs(struct device *dev, void *ptr, size_t size, enum dma_data_direction dir, struct dma_attrs *attrs);
8 extern int ldv_dma_mapping_error(struct device *dev, dma_addr_t dma_addr);
9 #line 1 "/home/druidos/temp/331_1a/work/current--X--drivers--X--defaultlinux-3.14.1.tar.xz--X--331_1a--X--cpachecker/linux-3.14.1.tar.xz/csd_deg_dscv/8229/dscv_tempdir/dscv/ri/331_1a/drivers/scsi/be2iscsi/be_main.c"
10
11 /**
12 * Copyright (C) 2005 - 2013 Emulex
13 * All rights reserved.
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License version 2
17 * as published by the Free Software Foundation. The full GNU General
18 * Public License is included in this distribution in the file called COPYING.
19 *
20 * Written by: Jayamohan Kallickal (jayamohan.kallickal@emulex.com)
21 *
22 * Contact Information:
23 * linux-drivers@emulex.com
24 *
25 * Emulex
26 * 3333 Susan Street
27 * Costa Mesa, CA 92626
28 */
29
30 #include <linux/reboot.h>
31 #include <linux/delay.h>
32 #include <linux/slab.h>
33 #include <linux/interrupt.h>
34 #include <linux/blkdev.h>
35 #include <linux/pci.h>
36 #include <linux/string.h>
37 #include <linux/kernel.h>
38 #include <linux/semaphore.h>
39 #include <linux/iscsi_boot_sysfs.h>
40 #include <linux/module.h>
41 #include <linux/bsg-lib.h>
42
43 #include <scsi/libiscsi.h>
44 #include <scsi/scsi_bsg_iscsi.h>
45 #include <scsi/scsi_netlink.h>
46 #include <scsi/scsi_transport_iscsi.h>
47 #include <scsi/scsi_transport.h>
48 #include <scsi/scsi_cmnd.h>
49 #include <scsi/scsi_device.h>
50 #include <scsi/scsi_host.h>
51 #include <scsi/scsi.h>
52 #include "be_main.h"
53 #include "be_iscsi.h"
54 #include "be_mgmt.h"
55 #include "be_cmds.h"
56
57 static unsigned int be_iopoll_budget = 10;
58 static unsigned int be_max_phys_size = 64;
59 static unsigned int enable_msix = 1;
60
61 MODULE_DEVICE_TABLE(pci, beiscsi_pci_id_table);
62 MODULE_DESCRIPTION(DRV_DESC " " BUILD_STR);
63 MODULE_VERSION(BUILD_STR);
64 MODULE_AUTHOR("Emulex Corporation");
65 MODULE_LICENSE("GPL");
66 module_param(be_iopoll_budget, int, 0);
67 module_param(enable_msix, int, 0);
68 module_param(be_max_phys_size, uint, S_IRUGO);
69 MODULE_PARM_DESC(be_max_phys_size,
70 "Maximum Size (In Kilobytes) of physically contiguous "
71 "memory that can be allocated. Range is 16 - 128");
72
73 #define beiscsi_disp_param(_name)\
74 ssize_t \
75 beiscsi_##_name##_disp(struct device *dev,\
76 struct device_attribute *attrib, char *buf) \
77 { \
78 struct Scsi_Host *shost = class_to_shost(dev);\
79 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
80 uint32_t param_val = 0; \
81 param_val = phba->attr_##_name;\
82 return snprintf(buf, PAGE_SIZE, "%d\n",\
83 phba->attr_##_name);\
84 }
85
86 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
87 int \
88 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
89 {\
90 if (val >= _minval && val <= _maxval) {\
91 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
92 "BA_%d : beiscsi_"#_name" updated "\
93 "from 0x%x ==> 0x%x\n",\
94 phba->attr_##_name, val); \
95 phba->attr_##_name = val;\
96 return 0;\
97 } \
98 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
99 "BA_%d beiscsi_"#_name" attribute "\
100 "cannot be updated to 0x%x, "\
101 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
102 return -EINVAL;\
103 }
104
105 #define beiscsi_store_param(_name) \
106 ssize_t \
107 beiscsi_##_name##_store(struct device *dev,\
108 struct device_attribute *attr, const char *buf,\
109 size_t count) \
110 { \
111 struct Scsi_Host *shost = class_to_shost(dev);\
112 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
113 uint32_t param_val = 0;\
114 if (!isdigit(buf[0]))\
115 return -EINVAL;\
116 if (sscanf(buf, "%i", ¶m_val) != 1)\
117 return -EINVAL;\
118 if (beiscsi_##_name##_change(phba, param_val) == 0) \
119 return strlen(buf);\
120 else \
121 return -EINVAL;\
122 }
123
124 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
125 int \
126 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
127 { \
128 if (val >= _minval && val <= _maxval) {\
129 phba->attr_##_name = val;\
130 return 0;\
131 } \
132 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
133 "BA_%d beiscsi_"#_name" attribute " \
134 "cannot be updated to 0x%x, "\
135 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
136 phba->attr_##_name = _defval;\
137 return -EINVAL;\
138 }
139
140 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
141 static uint beiscsi_##_name = _defval;\
142 module_param(beiscsi_##_name, uint, S_IRUGO);\
143 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
144 beiscsi_disp_param(_name)\
145 beiscsi_change_param(_name, _minval, _maxval, _defval)\
146 beiscsi_store_param(_name)\
147 beiscsi_init_param(_name, _minval, _maxval, _defval)\
148 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
149 beiscsi_##_name##_disp, beiscsi_##_name##_store)
150
151 /*
152 * When new log level added update the
153 * the MAX allowed value for log_enable
154 */
155 BEISCSI_RW_ATTR(log_enable, 0x00,
156 0xFF, 0x00, "Enable logging Bit Mask\n"
157 "\t\t\t\tInitialization Events : 0x01\n"
158 "\t\t\t\tMailbox Events : 0x02\n"
159 "\t\t\t\tMiscellaneous Events : 0x04\n"
160 "\t\t\t\tError Handling : 0x08\n"
161 "\t\t\t\tIO Path Events : 0x10\n"
162 "\t\t\t\tConfiguration Path : 0x20\n"
163 "\t\t\t\tiSCSI Protocol : 0x40\n");
164
165 DEVICE_ATTR(beiscsi_drvr_ver, S_IRUGO, beiscsi_drvr_ver_disp, NULL);
166 DEVICE_ATTR(beiscsi_adapter_family, S_IRUGO, beiscsi_adap_family_disp, NULL);
167 DEVICE_ATTR(beiscsi_fw_ver, S_IRUGO, beiscsi_fw_ver_disp, NULL);
168 DEVICE_ATTR(beiscsi_phys_port, S_IRUGO, beiscsi_phys_port_disp, NULL);
169 DEVICE_ATTR(beiscsi_active_session_count, S_IRUGO,
170 beiscsi_active_session_disp, NULL);
171 DEVICE_ATTR(beiscsi_free_session_count, S_IRUGO,
172 beiscsi_free_session_disp, NULL);
173 struct device_attribute *beiscsi_attrs[] = {
174 &dev_attr_beiscsi_log_enable,
175 &dev_attr_beiscsi_drvr_ver,
176 &dev_attr_beiscsi_adapter_family,
177 &dev_attr_beiscsi_fw_ver,
178 &dev_attr_beiscsi_active_session_count,
179 &dev_attr_beiscsi_free_session_count,
180 &dev_attr_beiscsi_phys_port,
181 NULL,
182 };
183
184 static char const *cqe_desc[] = {
185 "RESERVED_DESC",
186 "SOL_CMD_COMPLETE",
187 "SOL_CMD_KILLED_DATA_DIGEST_ERR",
188 "CXN_KILLED_PDU_SIZE_EXCEEDS_DSL",
189 "CXN_KILLED_BURST_LEN_MISMATCH",
190 "CXN_KILLED_AHS_RCVD",
191 "CXN_KILLED_HDR_DIGEST_ERR",
192 "CXN_KILLED_UNKNOWN_HDR",
193 "CXN_KILLED_STALE_ITT_TTT_RCVD",
194 "CXN_KILLED_INVALID_ITT_TTT_RCVD",
195 "CXN_KILLED_RST_RCVD",
196 "CXN_KILLED_TIMED_OUT",
197 "CXN_KILLED_RST_SENT",
198 "CXN_KILLED_FIN_RCVD",
199 "CXN_KILLED_BAD_UNSOL_PDU_RCVD",
200 "CXN_KILLED_BAD_WRB_INDEX_ERROR",
201 "CXN_KILLED_OVER_RUN_RESIDUAL",
202 "CXN_KILLED_UNDER_RUN_RESIDUAL",
203 "CMD_KILLED_INVALID_STATSN_RCVD",
204 "CMD_KILLED_INVALID_R2T_RCVD",
205 "CMD_CXN_KILLED_LUN_INVALID",
206 "CMD_CXN_KILLED_ICD_INVALID",
207 "CMD_CXN_KILLED_ITT_INVALID",
208 "CMD_CXN_KILLED_SEQ_OUTOFORDER",
209 "CMD_CXN_KILLED_INVALID_DATASN_RCVD",
210 "CXN_INVALIDATE_NOTIFY",
211 "CXN_INVALIDATE_INDEX_NOTIFY",
212 "CMD_INVALIDATED_NOTIFY",
213 "UNSOL_HDR_NOTIFY",
214 "UNSOL_DATA_NOTIFY",
215 "UNSOL_DATA_DIGEST_ERROR_NOTIFY",
216 "DRIVERMSG_NOTIFY",
217 "CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN",
218 "SOL_CMD_KILLED_DIF_ERR",
219 "CXN_KILLED_SYN_RCVD",
220 "CXN_KILLED_IMM_DATA_RCVD"
221 };
222
223 static int beiscsi_slave_configure(struct scsi_device *sdev)
224 {
225 blk_queue_max_segment_size(sdev->request_queue, 65536);
226 return 0;
227 }
228
229 static int beiscsi_eh_abort(struct scsi_cmnd *sc)
230 {
231 struct iscsi_cls_session *cls_session;
232 struct iscsi_task *aborted_task = (struct iscsi_task *)sc->SCp.ptr;
233 struct beiscsi_io_task *aborted_io_task;
234 struct iscsi_conn *conn;
235 struct beiscsi_conn *beiscsi_conn;
236 struct beiscsi_hba *phba;
237 struct iscsi_session *session;
238 struct invalidate_command_table *inv_tbl;
239 struct be_dma_mem nonemb_cmd;
240 unsigned int cid, tag, num_invalidate;
241
242 cls_session = starget_to_session(scsi_target(sc->device));
243 session = cls_session->dd_data;
244
245 spin_lock_bh(&session->lock);
246 if (!aborted_task || !aborted_task->sc) {
247 /* we raced */
248 spin_unlock_bh(&session->lock);
249 return SUCCESS;
250 }
251
252 aborted_io_task = aborted_task->dd_data;
253 if (!aborted_io_task->scsi_cmnd) {
254 /* raced or invalid command */
255 spin_unlock_bh(&session->lock);
256 return SUCCESS;
257 }
258 spin_unlock_bh(&session->lock);
259 /* Invalidate WRB Posted for this Task */
260 AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
261 aborted_io_task->pwrb_handle->pwrb,
262 1);
263
264 conn = aborted_task->conn;
265 beiscsi_conn = conn->dd_data;
266 phba = beiscsi_conn->phba;
267
268 /* invalidate iocb */
269 cid = beiscsi_conn->beiscsi_conn_cid;
270 inv_tbl = phba->inv_tbl;
271 memset(inv_tbl, 0x0, sizeof(*inv_tbl));
272 inv_tbl->cid = cid;
273 inv_tbl->icd = aborted_io_task->psgl_handle->sgl_index;
274 num_invalidate = 1;
275 nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev,
276 sizeof(struct invalidate_commands_params_in),
277 &nonemb_cmd.dma);
278 if (nonemb_cmd.va == NULL) {
279 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH,
280 "BM_%d : Failed to allocate memory for"
281 "mgmt_invalidate_icds\n");
282 return FAILED;
283 }
284 nonemb_cmd.size = sizeof(struct invalidate_commands_params_in);
285
286 tag = mgmt_invalidate_icds(phba, inv_tbl, num_invalidate,
287 cid, &nonemb_cmd);
288 if (!tag) {
289 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_EH,
290 "BM_%d : mgmt_invalidate_icds could not be"
291 "submitted\n");
292 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
293 nonemb_cmd.va, nonemb_cmd.dma);
294
295 return FAILED;
296 }
297
298 beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd.va);
299 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
300 nonemb_cmd.va, nonemb_cmd.dma);
301 return iscsi_eh_abort(sc);
302 }
303
304 static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
305 {
306 struct iscsi_task *abrt_task;
307 struct beiscsi_io_task *abrt_io_task;
308 struct iscsi_conn *conn;
309 struct beiscsi_conn *beiscsi_conn;
310 struct beiscsi_hba *phba;
311 struct iscsi_session *session;
312 struct iscsi_cls_session *cls_session;
313 struct invalidate_command_table *inv_tbl;
314 struct be_dma_mem nonemb_cmd;
315 unsigned int cid, tag, i, num_invalidate;
316
317 /* invalidate iocbs */
318 cls_session = starget_to_session(scsi_target(sc->device));
319 session = cls_session->dd_data;
320 spin_lock_bh(&session->lock);
321 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN) {
322 spin_unlock_bh(&session->lock);
323 return FAILED;
324 }
325 conn = session->leadconn;
326 beiscsi_conn = conn->dd_data;
327 phba = beiscsi_conn->phba;
328 cid = beiscsi_conn->beiscsi_conn_cid;
329 inv_tbl = phba->inv_tbl;
330 memset(inv_tbl, 0x0, sizeof(*inv_tbl) * BE2_CMDS_PER_CXN);
331 num_invalidate = 0;
332 for (i = 0; i < conn->session->cmds_max; i++) {
333 abrt_task = conn->session->cmds[i];
334 abrt_io_task = abrt_task->dd_data;
335 if (!abrt_task->sc || abrt_task->state == ISCSI_TASK_FREE)
336 continue;
337
338 if (sc->device->lun != abrt_task->sc->device->lun)
339 continue;
340
341 /* Invalidate WRB Posted for this Task */
342 AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
343 abrt_io_task->pwrb_handle->pwrb,
344 1);
345
346 inv_tbl->cid = cid;
347 inv_tbl->icd = abrt_io_task->psgl_handle->sgl_index;
348 num_invalidate++;
349 inv_tbl++;
350 }
351 spin_unlock_bh(&session->lock);
352 inv_tbl = phba->inv_tbl;
353
354 nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev,
355 sizeof(struct invalidate_commands_params_in),
356 &nonemb_cmd.dma);
357 if (nonemb_cmd.va == NULL) {
358 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH,
359 "BM_%d : Failed to allocate memory for"
360 "mgmt_invalidate_icds\n");
361 return FAILED;
362 }
363 nonemb_cmd.size = sizeof(struct invalidate_commands_params_in);
364 memset(nonemb_cmd.va, 0, nonemb_cmd.size);
365 tag = mgmt_invalidate_icds(phba, inv_tbl, num_invalidate,
366 cid, &nonemb_cmd);
367 if (!tag) {
368 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_EH,
369 "BM_%d : mgmt_invalidate_icds could not be"
370 " submitted\n");
371 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
372 nonemb_cmd.va, nonemb_cmd.dma);
373 return FAILED;
374 }
375
376 beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd.va);
377 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
378 nonemb_cmd.va, nonemb_cmd.dma);
379 return iscsi_eh_device_reset(sc);
380 }
381
382 static ssize_t beiscsi_show_boot_tgt_info(void *data, int type, char *buf)
383 {
384 struct beiscsi_hba *phba = data;
385 struct mgmt_session_info *boot_sess = &phba->boot_sess;
386 struct mgmt_conn_info *boot_conn = &boot_sess->conn_list[0];
387 char *str = buf;
388 int rc;
389
390 switch (type) {
391 case ISCSI_BOOT_TGT_NAME:
392 rc = sprintf(buf, "%.*s\n",
393 (int)strlen(boot_sess->target_name),
394 (char *)&boot_sess->target_name);
395 break;
396 case ISCSI_BOOT_TGT_IP_ADDR:
397 if (boot_conn->dest_ipaddr.ip_type == 0x1)
398 rc = sprintf(buf, "%pI4\n",
399 (char *)&boot_conn->dest_ipaddr.addr);
400 else
401 rc = sprintf(str, "%pI6\n",
402 (char *)&boot_conn->dest_ipaddr.addr);
403 break;
404 case ISCSI_BOOT_TGT_PORT:
405 rc = sprintf(str, "%d\n", boot_conn->dest_port);
406 break;
407
408 case ISCSI_BOOT_TGT_CHAP_NAME:
409 rc = sprintf(str, "%.*s\n",
410 boot_conn->negotiated_login_options.auth_data.chap.
411 target_chap_name_length,
412 (char *)&boot_conn->negotiated_login_options.
413 auth_data.chap.target_chap_name);
414 break;
415 case ISCSI_BOOT_TGT_CHAP_SECRET:
416 rc = sprintf(str, "%.*s\n",
417 boot_conn->negotiated_login_options.auth_data.chap.
418 target_secret_length,
419 (char *)&boot_conn->negotiated_login_options.
420 auth_data.chap.target_secret);
421 break;
422 case ISCSI_BOOT_TGT_REV_CHAP_NAME:
423 rc = sprintf(str, "%.*s\n",
424 boot_conn->negotiated_login_options.auth_data.chap.
425 intr_chap_name_length,
426 (char *)&boot_conn->negotiated_login_options.
427 auth_data.chap.intr_chap_name);
428 break;
429 case ISCSI_BOOT_TGT_REV_CHAP_SECRET:
430 rc = sprintf(str, "%.*s\n",
431 boot_conn->negotiated_login_options.auth_data.chap.
432 intr_secret_length,
433 (char *)&boot_conn->negotiated_login_options.
434 auth_data.chap.intr_secret);
435 break;
436 case ISCSI_BOOT_TGT_FLAGS:
437 rc = sprintf(str, "2\n");
438 break;
439 case ISCSI_BOOT_TGT_NIC_ASSOC:
440 rc = sprintf(str, "0\n");
441 break;
442 default:
443 rc = -ENOSYS;
444 break;
445 }
446 return rc;
447 }
448
449 static ssize_t beiscsi_show_boot_ini_info(void *data, int type, char *buf)
450 {
451 struct beiscsi_hba *phba = data;
452 char *str = buf;
453 int rc;
454
455 switch (type) {
456 case ISCSI_BOOT_INI_INITIATOR_NAME:
457 rc = sprintf(str, "%s\n", phba->boot_sess.initiator_iscsiname);
458 break;
459 default:
460 rc = -ENOSYS;
461 break;
462 }
463 return rc;
464 }
465
466 static ssize_t beiscsi_show_boot_eth_info(void *data, int type, char *buf)
467 {
468 struct beiscsi_hba *phba = data;
469 char *str = buf;
470 int rc;
471
472 switch (type) {
473 case ISCSI_BOOT_ETH_FLAGS:
474 rc = sprintf(str, "2\n");
475 break;
476 case ISCSI_BOOT_ETH_INDEX:
477 rc = sprintf(str, "0\n");
478 break;
479 case ISCSI_BOOT_ETH_MAC:
480 rc = beiscsi_get_macaddr(str, phba);
481 break;
482 default:
483 rc = -ENOSYS;
484 break;
485 }
486 return rc;
487 }
488
489
490 static umode_t beiscsi_tgt_get_attr_visibility(void *data, int type)
491 {
492 umode_t rc;
493
494 switch (type) {
495 case ISCSI_BOOT_TGT_NAME:
496 case ISCSI_BOOT_TGT_IP_ADDR:
497 case ISCSI_BOOT_TGT_PORT:
498 case ISCSI_BOOT_TGT_CHAP_NAME:
499 case ISCSI_BOOT_TGT_CHAP_SECRET:
500 case ISCSI_BOOT_TGT_REV_CHAP_NAME:
501 case ISCSI_BOOT_TGT_REV_CHAP_SECRET:
502 case ISCSI_BOOT_TGT_NIC_ASSOC:
503 case ISCSI_BOOT_TGT_FLAGS:
504 rc = S_IRUGO;
505 break;
506 default:
507 rc = 0;
508 break;
509 }
510 return rc;
511 }
512
513 static umode_t beiscsi_ini_get_attr_visibility(void *data, int type)
514 {
515 umode_t rc;
516
517 switch (type) {
518 case ISCSI_BOOT_INI_INITIATOR_NAME:
519 rc = S_IRUGO;
520 break;
521 default:
522 rc = 0;
523 break;
524 }
525 return rc;
526 }
527
528
529 static umode_t beiscsi_eth_get_attr_visibility(void *data, int type)
530 {
531 umode_t rc;
532
533 switch (type) {
534 case ISCSI_BOOT_ETH_FLAGS:
535 case ISCSI_BOOT_ETH_MAC:
536 case ISCSI_BOOT_ETH_INDEX:
537 rc = S_IRUGO;
538 break;
539 default:
540 rc = 0;
541 break;
542 }
543 return rc;
544 }
545
546 /*------------------- PCI Driver operations and data ----------------- */
547 static DEFINE_PCI_DEVICE_TABLE(beiscsi_pci_id_table) = {
548 { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID1) },
549 { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID2) },
550 { PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID1) },
551 { PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID2) },
552 { PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID3) },
553 { PCI_DEVICE(ELX_VENDOR_ID, OC_SKH_ID1) },
554 { 0 }
555 };
556 MODULE_DEVICE_TABLE(pci, beiscsi_pci_id_table);
557
558
559 static struct scsi_host_template beiscsi_sht = {
560 .module = THIS_MODULE,
561 .name = "Emulex 10Gbe open-iscsi Initiator Driver",
562 .proc_name = DRV_NAME,
563 .queuecommand = iscsi_queuecommand,
564 .change_queue_depth = iscsi_change_queue_depth,
565 .slave_configure = beiscsi_slave_configure,
566 .target_alloc = iscsi_target_alloc,
567 .eh_abort_handler = beiscsi_eh_abort,
568 .eh_device_reset_handler = beiscsi_eh_device_reset,
569 .eh_target_reset_handler = iscsi_eh_session_reset,
570 .shost_attrs = beiscsi_attrs,
571 .sg_tablesize = BEISCSI_SGLIST_ELEMENTS,
572 .can_queue = BE2_IO_DEPTH,
573 .this_id = -1,
574 .max_sectors = BEISCSI_MAX_SECTORS,
575 .cmd_per_lun = BEISCSI_CMD_PER_LUN,
576 .use_clustering = ENABLE_CLUSTERING,
577 .vendor_id = SCSI_NL_VID_TYPE_PCI | BE_VENDOR_ID,
578
579 };
580
581 static struct scsi_transport_template *beiscsi_scsi_transport;
582
583 static struct beiscsi_hba *beiscsi_hba_alloc(struct pci_dev *pcidev)
584 {
585 struct beiscsi_hba *phba;
586 struct Scsi_Host *shost;
587
588 shost = iscsi_host_alloc(&beiscsi_sht, sizeof(*phba), 0);
589 if (!shost) {
590 dev_err(&pcidev->dev,
591 "beiscsi_hba_alloc - iscsi_host_alloc failed\n");
592 return NULL;
593 }
594 shost->dma_boundary = pcidev->dma_mask;
595 shost->max_id = BE2_MAX_SESSIONS;
596 shost->max_channel = 0;
597 shost->max_cmd_len = BEISCSI_MAX_CMD_LEN;
598 shost->max_lun = BEISCSI_NUM_MAX_LUN;
599 shost->transportt = beiscsi_scsi_transport;
600 phba = iscsi_host_priv(shost);
601 memset(phba, 0, sizeof(*phba));
602 phba->shost = shost;
603 phba->pcidev = pci_dev_get(pcidev);
604 pci_set_drvdata(pcidev, phba);
605 phba->interface_handle = 0xFFFFFFFF;
606
607 if (iscsi_host_add(shost, &phba->pcidev->dev))
608 goto free_devices;
609
610 return phba;
611
612 free_devices:
613 pci_dev_put(phba->pcidev);
614 iscsi_host_free(phba->shost);
615 return NULL;
616 }
617
618 static void beiscsi_unmap_pci_function(struct beiscsi_hba *phba)
619 {
620 if (phba->csr_va) {
621 iounmap(phba->csr_va);
622 phba->csr_va = NULL;
623 }
624 if (phba->db_va) {
625 iounmap(phba->db_va);
626 phba->db_va = NULL;
627 }
628 if (phba->pci_va) {
629 iounmap(phba->pci_va);
630 phba->pci_va = NULL;
631 }
632 }
633
634 static int beiscsi_map_pci_bars(struct beiscsi_hba *phba,
635 struct pci_dev *pcidev)
636 {
637 u8 __iomem *addr;
638 int pcicfg_reg;
639
640 addr = ioremap_nocache(pci_resource_start(pcidev, 2),
641 pci_resource_len(pcidev, 2));
642 if (addr == NULL)
643 return -ENOMEM;
644 phba->ctrl.csr = addr;
645 phba->csr_va = addr;
646 phba->csr_pa.u.a64.address = pci_resource_start(pcidev, 2);
647
648 addr = ioremap_nocache(pci_resource_start(pcidev, 4), 128 * 1024);
649 if (addr == NULL)
650 goto pci_map_err;
651 phba->ctrl.db = addr;
652 phba->db_va = addr;
653 phba->db_pa.u.a64.address = pci_resource_start(pcidev, 4);
654
655 if (phba->generation == BE_GEN2)
656 pcicfg_reg = 1;
657 else
658 pcicfg_reg = 0;
659
660 addr = ioremap_nocache(pci_resource_start(pcidev, pcicfg_reg),
661 pci_resource_len(pcidev, pcicfg_reg));
662
663 if (addr == NULL)
664 goto pci_map_err;
665 phba->ctrl.pcicfg = addr;
666 phba->pci_va = addr;
667 phba->pci_pa.u.a64.address = pci_resource_start(pcidev, pcicfg_reg);
668 return 0;
669
670 pci_map_err:
671 beiscsi_unmap_pci_function(phba);
672 return -ENOMEM;
673 }
674
675 static int beiscsi_enable_pci(struct pci_dev *pcidev)
676 {
677 int ret;
678
679 ret = pci_enable_device(pcidev);
680 if (ret) {
681 dev_err(&pcidev->dev,
682 "beiscsi_enable_pci - enable device failed\n");
683 return ret;
684 }
685
686 pci_set_master(pcidev);
687 if (pci_set_consistent_dma_mask(pcidev, DMA_BIT_MASK(64))) {
688 ret = pci_set_consistent_dma_mask(pcidev, DMA_BIT_MASK(32));
689 if (ret) {
690 dev_err(&pcidev->dev, "Could not set PCI DMA Mask\n");
691 pci_disable_device(pcidev);
692 return ret;
693 }
694 }
695 return 0;
696 }
697
698 static int be_ctrl_init(struct beiscsi_hba *phba, struct pci_dev *pdev)
699 {
700 struct be_ctrl_info *ctrl = &phba->ctrl;
701 struct be_dma_mem *mbox_mem_alloc = &ctrl->mbox_mem_alloced;
702 struct be_dma_mem *mbox_mem_align = &ctrl->mbox_mem;
703 int status = 0;
704
705 ctrl->pdev = pdev;
706 status = beiscsi_map_pci_bars(phba, pdev);
707 if (status)
708 return status;
709 mbox_mem_alloc->size = sizeof(struct be_mcc_mailbox) + 16;
710 mbox_mem_alloc->va = pci_alloc_consistent(pdev,
711 mbox_mem_alloc->size,
712 &mbox_mem_alloc->dma);
713 if (!mbox_mem_alloc->va) {
714 beiscsi_unmap_pci_function(phba);
715 return -ENOMEM;
716 }
717
718 mbox_mem_align->size = sizeof(struct be_mcc_mailbox);
719 mbox_mem_align->va = PTR_ALIGN(mbox_mem_alloc->va, 16);
720 mbox_mem_align->dma = PTR_ALIGN(mbox_mem_alloc->dma, 16);
721 memset(mbox_mem_align->va, 0, sizeof(struct be_mcc_mailbox));
722 spin_lock_init(&ctrl->mbox_lock);
723 spin_lock_init(&phba->ctrl.mcc_lock);
724 spin_lock_init(&phba->ctrl.mcc_cq_lock);
725
726 return status;
727 }
728
729 /**
730 * beiscsi_get_params()- Set the config paramters
731 * @phba: ptr device priv structure
732 **/
733 static void beiscsi_get_params(struct beiscsi_hba *phba)
734 {
735 uint32_t total_cid_count = 0;
736 uint32_t total_icd_count = 0;
737 uint8_t ulp_num = 0;
738
739 total_cid_count = BEISCSI_GET_CID_COUNT(phba, BEISCSI_ULP0) +
740 BEISCSI_GET_CID_COUNT(phba, BEISCSI_ULP1);
741
742 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
743 uint32_t align_mask = 0;
744 uint32_t icd_post_per_page = 0;
745 uint32_t icd_count_unavailable = 0;
746 uint32_t icd_start = 0, icd_count = 0;
747 uint32_t icd_start_align = 0, icd_count_align = 0;
748
749 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) {
750 icd_start = phba->fw_config.iscsi_icd_start[ulp_num];
751 icd_count = phba->fw_config.iscsi_icd_count[ulp_num];
752
753 /* Get ICD count that can be posted on each page */
754 icd_post_per_page = (PAGE_SIZE / (BE2_SGE *
755 sizeof(struct iscsi_sge)));
756 align_mask = (icd_post_per_page - 1);
757
758 /* Check if icd_start is aligned ICD per page posting */
759 if (icd_start % icd_post_per_page) {
760 icd_start_align = ((icd_start +
761 icd_post_per_page) &
762 ~(align_mask));
763 phba->fw_config.
764 iscsi_icd_start[ulp_num] =
765 icd_start_align;
766 }
767
768 icd_count_align = (icd_count & ~align_mask);
769
770 /* ICD discarded in the process of alignment */
771 if (icd_start_align)
772 icd_count_unavailable = ((icd_start_align -
773 icd_start) +
774 (icd_count -
775 icd_count_align));
776
777 /* Updated ICD count available */
778 phba->fw_config.iscsi_icd_count[ulp_num] = (icd_count -
779 icd_count_unavailable);
780
781 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
782 "BM_%d : Aligned ICD values\n"
783 "\t ICD Start : %d\n"
784 "\t ICD Count : %d\n"
785 "\t ICD Discarded : %d\n",
786 phba->fw_config.
787 iscsi_icd_start[ulp_num],
788 phba->fw_config.
789 iscsi_icd_count[ulp_num],
790 icd_count_unavailable);
791 break;
792 }
793 }
794
795 total_icd_count = phba->fw_config.iscsi_icd_count[ulp_num];
796 phba->params.ios_per_ctrl = (total_icd_count -
797 (total_cid_count +
798 BE2_TMFS + BE2_NOPOUT_REQ));
799 phba->params.cxns_per_ctrl = total_cid_count;
800 phba->params.asyncpdus_per_ctrl = total_cid_count;
801 phba->params.icds_per_ctrl = total_icd_count;
802 phba->params.num_sge_per_io = BE2_SGE;
803 phba->params.defpdu_hdr_sz = BE2_DEFPDU_HDR_SZ;
804 phba->params.defpdu_data_sz = BE2_DEFPDU_DATA_SZ;
805 phba->params.eq_timer = 64;
806 phba->params.num_eq_entries = 1024;
807 phba->params.num_cq_entries = 1024;
808 phba->params.wrbs_per_cxn = 256;
809 }
810
811 static void hwi_ring_eq_db(struct beiscsi_hba *phba,
812 unsigned int id, unsigned int clr_interrupt,
813 unsigned int num_processed,
814 unsigned char rearm, unsigned char event)
815 {
816 u32 val = 0;
817 val |= id & DB_EQ_RING_ID_MASK;
818 if (rearm)
819 val |= 1 << DB_EQ_REARM_SHIFT;
820 if (clr_interrupt)
821 val |= 1 << DB_EQ_CLR_SHIFT;
822 if (event)
823 val |= 1 << DB_EQ_EVNT_SHIFT;
824 val |= num_processed << DB_EQ_NUM_POPPED_SHIFT;
825 iowrite32(val, phba->db_va + DB_EQ_OFFSET);
826 }
827
828 /**
829 * be_isr_mcc - The isr routine of the driver.
830 * @irq: Not used
831 * @dev_id: Pointer to host adapter structure
832 */
833 static irqreturn_t be_isr_mcc(int irq, void *dev_id)
834 {
835 struct beiscsi_hba *phba;
836 struct be_eq_entry *eqe = NULL;
837 struct be_queue_info *eq;
838 struct be_queue_info *mcc;
839 unsigned int num_eq_processed;
840 struct be_eq_obj *pbe_eq;
841 unsigned long flags;
842
843 pbe_eq = dev_id;
844 eq = &pbe_eq->q;
845 phba = pbe_eq->phba;
846 mcc = &phba->ctrl.mcc_obj.cq;
847 eqe = queue_tail_node(eq);
848
849 num_eq_processed = 0;
850
851 while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32]
852 & EQE_VALID_MASK) {
853 if (((eqe->dw[offsetof(struct amap_eq_entry,
854 resource_id) / 32] &
855 EQE_RESID_MASK) >> 16) == mcc->id) {
856 spin_lock_irqsave(&phba->isr_lock, flags);
857 pbe_eq->todo_mcc_cq = true;
858 spin_unlock_irqrestore(&phba->isr_lock, flags);
859 }
860 AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0);
861 queue_tail_inc(eq);
862 eqe = queue_tail_node(eq);
863 num_eq_processed++;
864 }
865 if (pbe_eq->todo_mcc_cq)
866 queue_work(phba->wq, &pbe_eq->work_cqs);
867 if (num_eq_processed)
868 hwi_ring_eq_db(phba, eq->id, 1, num_eq_processed, 1, 1);
869
870 return IRQ_HANDLED;
871 }
872
873 /**
874 * be_isr_msix - The isr routine of the driver.
875 * @irq: Not used
876 * @dev_id: Pointer to host adapter structure
877 */
878 static irqreturn_t be_isr_msix(int irq, void *dev_id)
879 {
880 struct beiscsi_hba *phba;
881 struct be_eq_entry *eqe = NULL;
882 struct be_queue_info *eq;
883 struct be_queue_info *cq;
884 unsigned int num_eq_processed;
885 struct be_eq_obj *pbe_eq;
886 unsigned long flags;
887
888 pbe_eq = dev_id;
889 eq = &pbe_eq->q;
890 cq = pbe_eq->cq;
891 eqe = queue_tail_node(eq);
892
893 phba = pbe_eq->phba;
894 num_eq_processed = 0;
895 if (blk_iopoll_enabled) {
896 while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32]
897 & EQE_VALID_MASK) {
898 if (!blk_iopoll_sched_prep(&pbe_eq->iopoll))
899 blk_iopoll_sched(&pbe_eq->iopoll);
900
901 AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0);
902 queue_tail_inc(eq);
903 eqe = queue_tail_node(eq);
904 num_eq_processed++;
905 }
906 } else {
907 while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32]
908 & EQE_VALID_MASK) {
909 spin_lock_irqsave(&phba->isr_lock, flags);
910 pbe_eq->todo_cq = true;
911 spin_unlock_irqrestore(&phba->isr_lock, flags);
912 AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0);
913 queue_tail_inc(eq);
914 eqe = queue_tail_node(eq);
915 num_eq_processed++;
916 }
917
918 if (pbe_eq->todo_cq)
919 queue_work(phba->wq, &pbe_eq->work_cqs);
920 }
921
922 if (num_eq_processed)
923 hwi_ring_eq_db(phba, eq->id, 1, num_eq_processed, 0, 1);
924
925 return IRQ_HANDLED;
926 }
927
928 /**
929 * be_isr - The isr routine of the driver.
930 * @irq: Not used
931 * @dev_id: Pointer to host adapter structure
932 */
933 static irqreturn_t be_isr(int irq, void *dev_id)
934 {
935 struct beiscsi_hba *phba;
936 struct hwi_controller *phwi_ctrlr;
937 struct hwi_context_memory *phwi_context;
938 struct be_eq_entry *eqe = NULL;
939 struct be_queue_info *eq;
940 struct be_queue_info *cq;
941 struct be_queue_info *mcc;
942 unsigned long flags, index;
943 unsigned int num_mcceq_processed, num_ioeq_processed;
944 struct be_ctrl_info *ctrl;
945 struct be_eq_obj *pbe_eq;
946 int isr;
947
948 phba = dev_id;
949 ctrl = &phba->ctrl;
950 isr = ioread32(ctrl->csr + CEV_ISR0_OFFSET +
951 (PCI_FUNC(ctrl->pdev->devfn) * CEV_ISR_SIZE));
952 if (!isr)
953 return IRQ_NONE;
954
955 phwi_ctrlr = phba->phwi_ctrlr;
956 phwi_context = phwi_ctrlr->phwi_ctxt;
957 pbe_eq = &phwi_context->be_eq[0];
958
959 eq = &phwi_context->be_eq[0].q;
960 mcc = &phba->ctrl.mcc_obj.cq;
961 index = 0;
962 eqe = queue_tail_node(eq);
963
964 num_ioeq_processed = 0;
965 num_mcceq_processed = 0;
966 if (blk_iopoll_enabled) {
967 while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32]
968 & EQE_VALID_MASK) {
969 if (((eqe->dw[offsetof(struct amap_eq_entry,
970 resource_id) / 32] &
971 EQE_RESID_MASK) >> 16) == mcc->id) {
972 spin_lock_irqsave(&phba->isr_lock, flags);
973 pbe_eq->todo_mcc_cq = true;
974 spin_unlock_irqrestore(&phba->isr_lock, flags);
975 num_mcceq_processed++;
976 } else {
977 if (!blk_iopoll_sched_prep(&pbe_eq->iopoll))
978 blk_iopoll_sched(&pbe_eq->iopoll);
979 num_ioeq_processed++;
980 }
981 AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0);
982 queue_tail_inc(eq);
983 eqe = queue_tail_node(eq);
984 }
985 if (num_ioeq_processed || num_mcceq_processed) {
986 if (pbe_eq->todo_mcc_cq)
987 queue_work(phba->wq, &pbe_eq->work_cqs);
988
989 if ((num_mcceq_processed) && (!num_ioeq_processed))
990 hwi_ring_eq_db(phba, eq->id, 0,
991 (num_ioeq_processed +
992 num_mcceq_processed) , 1, 1);
993 else
994 hwi_ring_eq_db(phba, eq->id, 0,
995 (num_ioeq_processed +
996 num_mcceq_processed), 0, 1);
997
998 return IRQ_HANDLED;
999 } else
1000 return IRQ_NONE;
1001 } else {
1002 cq = &phwi_context->be_cq[0];
1003 while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32]
1004 & EQE_VALID_MASK) {
1005
1006 if (((eqe->dw[offsetof(struct amap_eq_entry,
1007 resource_id) / 32] &
1008 EQE_RESID_MASK) >> 16) != cq->id) {
1009 spin_lock_irqsave(&phba->isr_lock, flags);
1010 pbe_eq->todo_mcc_cq = true;
1011 spin_unlock_irqrestore(&phba->isr_lock, flags);
1012 } else {
1013 spin_lock_irqsave(&phba->isr_lock, flags);
1014 pbe_eq->todo_cq = true;
1015 spin_unlock_irqrestore(&phba->isr_lock, flags);
1016 }
1017 AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0);
1018 queue_tail_inc(eq);
1019 eqe = queue_tail_node(eq);
1020 num_ioeq_processed++;
1021 }
1022 if (pbe_eq->todo_cq || pbe_eq->todo_mcc_cq)
1023 queue_work(phba->wq, &pbe_eq->work_cqs);
1024
1025 if (num_ioeq_processed) {
1026 hwi_ring_eq_db(phba, eq->id, 0,
1027 num_ioeq_processed, 1, 1);
1028 return IRQ_HANDLED;
1029 } else
1030 return IRQ_NONE;
1031 }
1032 }
1033
1034 static int beiscsi_init_irqs(struct beiscsi_hba *phba)
1035 {
1036 struct pci_dev *pcidev = phba->pcidev;
1037 struct hwi_controller *phwi_ctrlr;
1038 struct hwi_context_memory *phwi_context;
1039 int ret, msix_vec, i, j;
1040
1041 phwi_ctrlr = phba->phwi_ctrlr;
1042 phwi_context = phwi_ctrlr->phwi_ctxt;
1043
1044 if (phba->msix_enabled) {
1045 for (i = 0; i < phba->num_cpus; i++) {
1046 phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME,
1047 GFP_KERNEL);
1048 if (!phba->msi_name[i]) {
1049 ret = -ENOMEM;
1050 goto free_msix_irqs;
1051 }
1052
1053 sprintf(phba->msi_name[i], "beiscsi_%02x_%02x",
1054 phba->shost->host_no, i);
1055 msix_vec = phba->msix_entries[i].vector;
1056 ret = request_irq(msix_vec, be_isr_msix, 0,
1057 phba->msi_name[i],
1058 &phwi_context->be_eq[i]);
1059 if (ret) {
1060 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
1061 "BM_%d : beiscsi_init_irqs-Failed to"
1062 "register msix for i = %d\n",
1063 i);
1064 kfree(phba->msi_name[i]);
1065 goto free_msix_irqs;
1066 }
1067 }
1068 phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME, GFP_KERNEL);
1069 if (!phba->msi_name[i]) {
1070 ret = -ENOMEM;
1071 goto free_msix_irqs;
1072 }
1073 sprintf(phba->msi_name[i], "beiscsi_mcc_%02x",
1074 phba->shost->host_no);
1075 msix_vec = phba->msix_entries[i].vector;
1076 ret = request_irq(msix_vec, be_isr_mcc, 0, phba->msi_name[i],
1077 &phwi_context->be_eq[i]);
1078 if (ret) {
1079 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT ,
1080 "BM_%d : beiscsi_init_irqs-"
1081 "Failed to register beiscsi_msix_mcc\n");
1082 kfree(phba->msi_name[i]);
1083 goto free_msix_irqs;
1084 }
1085
1086 } else {
1087 ret = request_irq(pcidev->irq, be_isr, IRQF_SHARED,
1088 "beiscsi", phba);
1089 if (ret) {
1090 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
1091 "BM_%d : beiscsi_init_irqs-"
1092 "Failed to register irq\\n");
1093 return ret;
1094 }
1095 }
1096 return 0;
1097 free_msix_irqs:
1098 for (j = i - 1; j >= 0; j--) {
1099 kfree(phba->msi_name[j]);
1100 msix_vec = phba->msix_entries[j].vector;
1101 free_irq(msix_vec, &phwi_context->be_eq[j]);
1102 }
1103 return ret;
1104 }
1105
1106 static void hwi_ring_cq_db(struct beiscsi_hba *phba,
1107 unsigned int id, unsigned int num_processed,
1108 unsigned char rearm, unsigned char event)
1109 {
1110 u32 val = 0;
1111 val |= id & DB_CQ_RING_ID_MASK;
1112 if (rearm)
1113 val |= 1 << DB_CQ_REARM_SHIFT;
1114 val |= num_processed << DB_CQ_NUM_POPPED_SHIFT;
1115 iowrite32(val, phba->db_va + DB_CQ_OFFSET);
1116 }
1117
1118 static unsigned int
1119 beiscsi_process_async_pdu(struct beiscsi_conn *beiscsi_conn,
1120 struct beiscsi_hba *phba,
1121 struct pdu_base *ppdu,
1122 unsigned long pdu_len,
1123 void *pbuffer, unsigned long buf_len)
1124 {
1125 struct iscsi_conn *conn = beiscsi_conn->conn;
1126 struct iscsi_session *session = conn->session;
1127 struct iscsi_task *task;
1128 struct beiscsi_io_task *io_task;
1129 struct iscsi_hdr *login_hdr;
1130
1131 switch (ppdu->dw[offsetof(struct amap_pdu_base, opcode) / 32] &
1132 PDUBASE_OPCODE_MASK) {
1133 case ISCSI_OP_NOOP_IN:
1134 pbuffer = NULL;
1135 buf_len = 0;
1136 break;
1137 case ISCSI_OP_ASYNC_EVENT:
1138 break;
1139 case ISCSI_OP_REJECT:
1140 WARN_ON(!pbuffer);
1141 WARN_ON(!(buf_len == 48));
1142 beiscsi_log(phba, KERN_ERR,
1143 BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO,
1144 "BM_%d : In ISCSI_OP_REJECT\n");
1145 break;
1146 case ISCSI_OP_LOGIN_RSP:
1147 case ISCSI_OP_TEXT_RSP:
1148 task = conn->login_task;
1149 io_task = task->dd_data;
1150 login_hdr = (struct iscsi_hdr *)ppdu;
1151 login_hdr->itt = io_task->libiscsi_itt;
1152 break;
1153 default:
1154 beiscsi_log(phba, KERN_WARNING,
1155 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG,
1156 "BM_%d : Unrecognized opcode 0x%x in async msg\n",
1157 (ppdu->
1158 dw[offsetof(struct amap_pdu_base, opcode) / 32]
1159 & PDUBASE_OPCODE_MASK));
1160 return 1;
1161 }
1162
1163 spin_lock_bh(&session->lock);
1164 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)ppdu, pbuffer, buf_len);
1165 spin_unlock_bh(&session->lock);
1166 return 0;
1167 }
1168
1169 static struct sgl_handle *alloc_io_sgl_handle(struct beiscsi_hba *phba)
1170 {
1171 struct sgl_handle *psgl_handle;
1172
1173 if (phba->io_sgl_hndl_avbl) {
1174 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO,
1175 "BM_%d : In alloc_io_sgl_handle,"
1176 " io_sgl_alloc_index=%d\n",
1177 phba->io_sgl_alloc_index);
1178
1179 psgl_handle = phba->io_sgl_hndl_base[phba->
1180 io_sgl_alloc_index];
1181 phba->io_sgl_hndl_base[phba->io_sgl_alloc_index] = NULL;
1182 phba->io_sgl_hndl_avbl--;
1183 if (phba->io_sgl_alloc_index == (phba->params.
1184 ios_per_ctrl - 1))
1185 phba->io_sgl_alloc_index = 0;
1186 else
1187 phba->io_sgl_alloc_index++;
1188 } else
1189 psgl_handle = NULL;
1190 return psgl_handle;
1191 }
1192
1193 static void
1194 free_io_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle)
1195 {
1196 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO,
1197 "BM_%d : In free_,io_sgl_free_index=%d\n",
1198 phba->io_sgl_free_index);
1199
1200 if (phba->io_sgl_hndl_base[phba->io_sgl_free_index]) {
1201 /*
1202 * this can happen if clean_task is called on a task that
1203 * failed in xmit_task or alloc_pdu.
1204 */
1205 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO,
1206 "BM_%d : Double Free in IO SGL io_sgl_free_index=%d,"
1207 "value there=%p\n", phba->io_sgl_free_index,
1208 phba->io_sgl_hndl_base
1209 [phba->io_sgl_free_index]);
1210 return;
1211 }
1212 phba->io_sgl_hndl_base[phba->io_sgl_free_index] = psgl_handle;
1213 phba->io_sgl_hndl_avbl++;
1214 if (phba->io_sgl_free_index == (phba->params.ios_per_ctrl - 1))
1215 phba->io_sgl_free_index = 0;
1216 else
1217 phba->io_sgl_free_index++;
1218 }
1219
1220 /**
1221 * alloc_wrb_handle - To allocate a wrb handle
1222 * @phba: The hba pointer
1223 * @cid: The cid to use for allocation
1224 *
1225 * This happens under session_lock until submission to chip
1226 */
1227 struct wrb_handle *alloc_wrb_handle(struct beiscsi_hba *phba, unsigned int cid)
1228 {
1229 struct hwi_wrb_context *pwrb_context;
1230 struct hwi_controller *phwi_ctrlr;
1231 struct wrb_handle *pwrb_handle, *pwrb_handle_tmp;
1232 uint16_t cri_index = BE_GET_CRI_FROM_CID(cid);
1233
1234 phwi_ctrlr = phba->phwi_ctrlr;
1235 pwrb_context = &phwi_ctrlr->wrb_context[cri_index];
1236 if (pwrb_context->wrb_handles_available >= 2) {
1237 pwrb_handle = pwrb_context->pwrb_handle_base[
1238 pwrb_context->alloc_index];
1239 pwrb_context->wrb_handles_available--;
1240 if (pwrb_context->alloc_index ==
1241 (phba->params.wrbs_per_cxn - 1))
1242 pwrb_context->alloc_index = 0;
1243 else
1244 pwrb_context->alloc_index++;
1245 pwrb_handle_tmp = pwrb_context->pwrb_handle_base[
1246 pwrb_context->alloc_index];
1247 pwrb_handle->nxt_wrb_index = pwrb_handle_tmp->wrb_index;
1248 } else
1249 pwrb_handle = NULL;
1250 return pwrb_handle;
1251 }
1252
1253 /**
1254 * free_wrb_handle - To free the wrb handle back to pool
1255 * @phba: The hba pointer
1256 * @pwrb_context: The context to free from
1257 * @pwrb_handle: The wrb_handle to free
1258 *
1259 * This happens under session_lock until submission to chip
1260 */
1261 static void
1262 free_wrb_handle(struct beiscsi_hba *phba, struct hwi_wrb_context *pwrb_context,
1263 struct wrb_handle *pwrb_handle)
1264 {
1265 pwrb_context->pwrb_handle_base[pwrb_context->free_index] = pwrb_handle;
1266 pwrb_context->wrb_handles_available++;
1267 if (pwrb_context->free_index == (phba->params.wrbs_per_cxn - 1))
1268 pwrb_context->free_index = 0;
1269 else
1270 pwrb_context->free_index++;
1271
1272 beiscsi_log(phba, KERN_INFO,
1273 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG,
1274 "BM_%d : FREE WRB: pwrb_handle=%p free_index=0x%x"
1275 "wrb_handles_available=%d\n",
1276 pwrb_handle, pwrb_context->free_index,
1277 pwrb_context->wrb_handles_available);
1278 }
1279
1280 static struct sgl_handle *alloc_mgmt_sgl_handle(struct beiscsi_hba *phba)
1281 {
1282 struct sgl_handle *psgl_handle;
1283
1284 if (phba->eh_sgl_hndl_avbl) {
1285 psgl_handle = phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index];
1286 phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index] = NULL;
1287 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
1288 "BM_%d : mgmt_sgl_alloc_index=%d=0x%x\n",
1289 phba->eh_sgl_alloc_index,
1290 phba->eh_sgl_alloc_index);
1291
1292 phba->eh_sgl_hndl_avbl--;
1293 if (phba->eh_sgl_alloc_index ==
1294 (phba->params.icds_per_ctrl - phba->params.ios_per_ctrl -
1295 1))
1296 phba->eh_sgl_alloc_index = 0;
1297 else
1298 phba->eh_sgl_alloc_index++;
1299 } else
1300 psgl_handle = NULL;
1301 return psgl_handle;
1302 }
1303
1304 void
1305 free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle)
1306 {
1307
1308 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
1309 "BM_%d : In free_mgmt_sgl_handle,"
1310 "eh_sgl_free_index=%d\n",
1311 phba->eh_sgl_free_index);
1312
1313 if (phba->eh_sgl_hndl_base[phba->eh_sgl_free_index]) {
1314 /*
1315 * this can happen if clean_task is called on a task that
1316 * failed in xmit_task or alloc_pdu.
1317 */
1318 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
1319 "BM_%d : Double Free in eh SGL ,"
1320 "eh_sgl_free_index=%d\n",
1321 phba->eh_sgl_free_index);
1322 return;
1323 }
1324 phba->eh_sgl_hndl_base[phba->eh_sgl_free_index] = psgl_handle;
1325 phba->eh_sgl_hndl_avbl++;
1326 if (phba->eh_sgl_free_index ==
1327 (phba->params.icds_per_ctrl - phba->params.ios_per_ctrl - 1))
1328 phba->eh_sgl_free_index = 0;
1329 else
1330 phba->eh_sgl_free_index++;
1331 }
1332
1333 static void
1334 be_complete_io(struct beiscsi_conn *beiscsi_conn,
1335 struct iscsi_task *task,
1336 struct common_sol_cqe *csol_cqe)
1337 {
1338 struct beiscsi_io_task *io_task = task->dd_data;
1339 struct be_status_bhs *sts_bhs =
1340 (struct be_status_bhs *)io_task->cmd_bhs;
1341 struct iscsi_conn *conn = beiscsi_conn->conn;
1342 unsigned char *sense;
1343 u32 resid = 0, exp_cmdsn, max_cmdsn;
1344 u8 rsp, status, flags;
1345
1346 exp_cmdsn = csol_cqe->exp_cmdsn;
1347 max_cmdsn = (csol_cqe->exp_cmdsn +
1348 csol_cqe->cmd_wnd - 1);
1349 rsp = csol_cqe->i_resp;
1350 status = csol_cqe->i_sts;
1351 flags = csol_cqe->i_flags;
1352 resid = csol_cqe->res_cnt;
1353
1354 if (!task->sc) {
1355 if (io_task->scsi_cmnd)
1356 scsi_dma_unmap(io_task->scsi_cmnd);
1357
1358 return;
1359 }
1360 task->sc->result = (DID_OK << 16) | status;
1361 if (rsp != ISCSI_STATUS_CMD_COMPLETED) {
1362 task->sc->result = DID_ERROR << 16;
1363 goto unmap;
1364 }
1365
1366 /* bidi not initially supported */
1367 if (flags & (ISCSI_FLAG_CMD_UNDERFLOW | ISCSI_FLAG_CMD_OVERFLOW)) {
1368 if (!status && (flags & ISCSI_FLAG_CMD_OVERFLOW))
1369 task->sc->result = DID_ERROR << 16;
1370
1371 if (flags & ISCSI_FLAG_CMD_UNDERFLOW) {
1372 scsi_set_resid(task->sc, resid);
1373 if (!status && (scsi_bufflen(task->sc) - resid <
1374 task->sc->underflow))
1375 task->sc->result = DID_ERROR << 16;
1376 }
1377 }
1378
1379 if (status == SAM_STAT_CHECK_CONDITION) {
1380 u16 sense_len;
1381 unsigned short *slen = (unsigned short *)sts_bhs->sense_info;
1382
1383 sense = sts_bhs->sense_info + sizeof(unsigned short);
1384 sense_len = be16_to_cpu(*slen);
1385 memcpy(task->sc->sense_buffer, sense,
1386 min_t(u16, sense_len, SCSI_SENSE_BUFFERSIZE));
1387 }
1388
1389 if (io_task->cmd_bhs->iscsi_hdr.flags & ISCSI_FLAG_CMD_READ)
1390 conn->rxdata_octets += resid;
1391 unmap:
1392 scsi_dma_unmap(io_task->scsi_cmnd);
1393 iscsi_complete_scsi_task(task, exp_cmdsn, max_cmdsn);
1394 }
1395
1396 static void
1397 be_complete_logout(struct beiscsi_conn *beiscsi_conn,
1398 struct iscsi_task *task,
1399 struct common_sol_cqe *csol_cqe)
1400 {
1401 struct iscsi_logout_rsp *hdr;
1402 struct beiscsi_io_task *io_task = task->dd_data;
1403 struct iscsi_conn *conn = beiscsi_conn->conn;
1404
1405 hdr = (struct iscsi_logout_rsp *)task->hdr;
1406 hdr->opcode = ISCSI_OP_LOGOUT_RSP;
1407 hdr->t2wait = 5;
1408 hdr->t2retain = 0;
1409 hdr->flags = csol_cqe->i_flags;
1410 hdr->response = csol_cqe->i_resp;
1411 hdr->exp_cmdsn = cpu_to_be32(csol_cqe->exp_cmdsn);
1412 hdr->max_cmdsn = cpu_to_be32(csol_cqe->exp_cmdsn +
1413 csol_cqe->cmd_wnd - 1);
1414
1415 hdr->dlength[0] = 0;
1416 hdr->dlength[1] = 0;
1417 hdr->dlength[2] = 0;
1418 hdr->hlength = 0;
1419 hdr->itt = io_task->libiscsi_itt;
1420 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0);
1421 }
1422
1423 static void
1424 be_complete_tmf(struct beiscsi_conn *beiscsi_conn,
1425 struct iscsi_task *task,
1426 struct common_sol_cqe *csol_cqe)
1427 {
1428 struct iscsi_tm_rsp *hdr;
1429 struct iscsi_conn *conn = beiscsi_conn->conn;
1430 struct beiscsi_io_task *io_task = task->dd_data;
1431
1432 hdr = (struct iscsi_tm_rsp *)task->hdr;
1433 hdr->opcode = ISCSI_OP_SCSI_TMFUNC_RSP;
1434 hdr->flags = csol_cqe->i_flags;
1435 hdr->response = csol_cqe->i_resp;
1436 hdr->exp_cmdsn = cpu_to_be32(csol_cqe->exp_cmdsn);
1437 hdr->max_cmdsn = cpu_to_be32(csol_cqe->exp_cmdsn +
1438 csol_cqe->cmd_wnd - 1);
1439
1440 hdr->itt = io_task->libiscsi_itt;
1441 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0);
1442 }
1443
1444 static void
1445 hwi_complete_drvr_msgs(struct beiscsi_conn *beiscsi_conn,
1446 struct beiscsi_hba *phba, struct sol_cqe *psol)
1447 {
1448 struct hwi_wrb_context *pwrb_context;
1449 struct wrb_handle *pwrb_handle = NULL;
1450 struct hwi_controller *phwi_ctrlr;
1451 struct iscsi_task *task;
1452 struct beiscsi_io_task *io_task;
1453 uint16_t wrb_index, cid, cri_index;
1454
1455 phwi_ctrlr = phba->phwi_ctrlr;
1456 if (is_chip_be2_be3r(phba)) {
1457 wrb_index = AMAP_GET_BITS(struct amap_it_dmsg_cqe,
1458 wrb_idx, psol);
1459 cid = AMAP_GET_BITS(struct amap_it_dmsg_cqe,
1460 cid, psol);
1461 } else {
1462 wrb_index = AMAP_GET_BITS(struct amap_it_dmsg_cqe_v2,
1463 wrb_idx, psol);
1464 cid = AMAP_GET_BITS(struct amap_it_dmsg_cqe_v2,
1465 cid, psol);
1466 }
1467
1468 cri_index = BE_GET_CRI_FROM_CID(cid);
1469 pwrb_context = &phwi_ctrlr->wrb_context[cri_index];
1470 pwrb_handle = pwrb_context->pwrb_handle_basestd[wrb_index];
1471 task = pwrb_handle->pio_handle;
1472
1473 io_task = task->dd_data;
1474 memset(io_task->pwrb_handle->pwrb, 0, sizeof(struct iscsi_wrb));
1475 iscsi_put_task(task);
1476 }
1477
1478 static void
1479 be_complete_nopin_resp(struct beiscsi_conn *beiscsi_conn,
1480 struct iscsi_task *task,
1481 struct common_sol_cqe *csol_cqe)
1482 {
1483 struct iscsi_nopin *hdr;
1484 struct iscsi_conn *conn = beiscsi_conn->conn;
1485 struct beiscsi_io_task *io_task = task->dd_data;
1486
1487 hdr = (struct iscsi_nopin *)task->hdr;
1488 hdr->flags = csol_cqe->i_flags;
1489 hdr->exp_cmdsn = cpu_to_be32(csol_cqe->exp_cmdsn);
1490 hdr->max_cmdsn = cpu_to_be32(csol_cqe->exp_cmdsn +
1491 csol_cqe->cmd_wnd - 1);
1492
1493 hdr->opcode = ISCSI_OP_NOOP_IN;
1494 hdr->itt = io_task->libiscsi_itt;
1495 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0);
1496 }
1497
1498 static void adapter_get_sol_cqe(struct beiscsi_hba *phba,
1499 struct sol_cqe *psol,
1500 struct common_sol_cqe *csol_cqe)
1501 {
1502 if (is_chip_be2_be3r(phba)) {
1503 csol_cqe->exp_cmdsn = AMAP_GET_BITS(struct amap_sol_cqe,
1504 i_exp_cmd_sn, psol);
1505 csol_cqe->res_cnt = AMAP_GET_BITS(struct amap_sol_cqe,
1506 i_res_cnt, psol);
1507 csol_cqe->cmd_wnd = AMAP_GET_BITS(struct amap_sol_cqe,
1508 i_cmd_wnd, psol);
1509 csol_cqe->wrb_index = AMAP_GET_BITS(struct amap_sol_cqe,
1510 wrb_index, psol);
1511 csol_cqe->cid = AMAP_GET_BITS(struct amap_sol_cqe,
1512 cid, psol);
1513 csol_cqe->hw_sts = AMAP_GET_BITS(struct amap_sol_cqe,
1514 hw_sts, psol);
1515 csol_cqe->i_resp = AMAP_GET_BITS(struct amap_sol_cqe,
1516 i_resp, psol);
1517 csol_cqe->i_sts = AMAP_GET_BITS(struct amap_sol_cqe,
1518 i_sts, psol);
1519 csol_cqe->i_flags = AMAP_GET_BITS(struct amap_sol_cqe,
1520 i_flags, psol);
1521 } else {
1522 csol_cqe->exp_cmdsn = AMAP_GET_BITS(struct amap_sol_cqe_v2,
1523 i_exp_cmd_sn, psol);
1524 csol_cqe->res_cnt = AMAP_GET_BITS(struct amap_sol_cqe_v2,
1525 i_res_cnt, psol);
1526 csol_cqe->wrb_index = AMAP_GET_BITS(struct amap_sol_cqe_v2,
1527 wrb_index, psol);
1528 csol_cqe->cid = AMAP_GET_BITS(struct amap_sol_cqe_v2,
1529 cid, psol);
1530 csol_cqe->hw_sts = AMAP_GET_BITS(struct amap_sol_cqe_v2,
1531 hw_sts, psol);
1532 csol_cqe->cmd_wnd = AMAP_GET_BITS(struct amap_sol_cqe_v2,
1533 i_cmd_wnd, psol);
1534 if (AMAP_GET_BITS(struct amap_sol_cqe_v2,
1535 cmd_cmpl, psol))
1536 csol_cqe->i_sts = AMAP_GET_BITS(struct amap_sol_cqe_v2,
1537 i_sts, psol);
1538 else
1539 csol_cqe->i_resp = AMAP_GET_BITS(struct amap_sol_cqe_v2,
1540 i_sts, psol);
1541 if (AMAP_GET_BITS(struct amap_sol_cqe_v2,
1542 u, psol))
1543 csol_cqe->i_flags = ISCSI_FLAG_CMD_UNDERFLOW;
1544
1545 if (AMAP_GET_BITS(struct amap_sol_cqe_v2,
1546 o, psol))
1547 csol_cqe->i_flags |= ISCSI_FLAG_CMD_OVERFLOW;
1548 }
1549 }
1550
1551
1552 static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn,
1553 struct beiscsi_hba *phba, struct sol_cqe *psol)
1554 {
1555 struct hwi_wrb_context *pwrb_context;
1556 struct wrb_handle *pwrb_handle;
1557 struct iscsi_wrb *pwrb = NULL;
1558 struct hwi_controller *phwi_ctrlr;
1559 struct iscsi_task *task;
1560 unsigned int type;
1561 struct iscsi_conn *conn = beiscsi_conn->conn;
1562 struct iscsi_session *session = conn->session;
1563 struct common_sol_cqe csol_cqe = {0};
1564 uint16_t cri_index = 0;
1565
1566 phwi_ctrlr = phba->phwi_ctrlr;
1567
1568 /* Copy the elements to a common structure */
1569 adapter_get_sol_cqe(phba, psol, &csol_cqe);
1570
1571 cri_index = BE_GET_CRI_FROM_CID(csol_cqe.cid);
1572 pwrb_context = &phwi_ctrlr->wrb_context[cri_index];
1573
1574 pwrb_handle = pwrb_context->pwrb_handle_basestd[
1575 csol_cqe.wrb_index];
1576
1577 task = pwrb_handle->pio_handle;
1578 pwrb = pwrb_handle->pwrb;
1579 type = ((struct beiscsi_io_task *)task->dd_data)->wrb_type;
1580
1581 spin_lock_bh(&session->lock);
1582 switch (type) {
1583 case HWH_TYPE_IO:
1584 case HWH_TYPE_IO_RD:
1585 if ((task->hdr->opcode & ISCSI_OPCODE_MASK) ==
1586 ISCSI_OP_NOOP_OUT)
1587 be_complete_nopin_resp(beiscsi_conn, task, &csol_cqe);
1588 else
1589 be_complete_io(beiscsi_conn, task, &csol_cqe);
1590 break;
1591
1592 case HWH_TYPE_LOGOUT:
1593 if ((task->hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGOUT)
1594 be_complete_logout(beiscsi_conn, task, &csol_cqe);
1595 else
1596 be_complete_tmf(beiscsi_conn, task, &csol_cqe);
1597 break;
1598
1599 case HWH_TYPE_LOGIN:
1600 beiscsi_log(phba, KERN_ERR,
1601 BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO,
1602 "BM_%d :\t\t No HWH_TYPE_LOGIN Expected in"
1603 " hwi_complete_cmd- Solicited path\n");
1604 break;
1605
1606 case HWH_TYPE_NOP:
1607 be_complete_nopin_resp(beiscsi_conn, task, &csol_cqe);
1608 break;
1609
1610 default:
1611 beiscsi_log(phba, KERN_WARNING,
1612 BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO,
1613 "BM_%d : In hwi_complete_cmd, unknown type = %d"
1614 "wrb_index 0x%x CID 0x%x\n", type,
1615 csol_cqe.wrb_index,
1616 csol_cqe.cid);
1617 break;
1618 }
1619
1620 spin_unlock_bh(&session->lock);
1621 }
1622
1623 static struct list_head *hwi_get_async_busy_list(struct hwi_async_pdu_context
1624 *pasync_ctx, unsigned int is_header,
1625 unsigned int host_write_ptr)
1626 {
1627 if (is_header)
1628 return &pasync_ctx->async_entry[host_write_ptr].
1629 header_busy_list;
1630 else
1631 return &pasync_ctx->async_entry[host_write_ptr].data_busy_list;
1632 }
1633
1634 static struct async_pdu_handle *
1635 hwi_get_async_handle(struct beiscsi_hba *phba,
1636 struct beiscsi_conn *beiscsi_conn,
1637 struct hwi_async_pdu_context *pasync_ctx,
1638 struct i_t_dpdu_cqe *pdpdu_cqe, unsigned int *pcq_index)
1639 {
1640 struct be_bus_address phys_addr;
1641 struct list_head *pbusy_list;
1642 struct async_pdu_handle *pasync_handle = NULL;
1643 unsigned char is_header = 0;
1644 unsigned int index, dpl;
1645
1646 if (is_chip_be2_be3r(phba)) {
1647 dpl = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe,
1648 dpl, pdpdu_cqe);
1649 index = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe,
1650 index, pdpdu_cqe);
1651 } else {
1652 dpl = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe_v2,
1653 dpl, pdpdu_cqe);
1654 index = AMAP_GET_BITS(struct amap_i_t_dpdu_cqe_v2,
1655 index, pdpdu_cqe);
1656 }
1657
1658 phys_addr.u.a32.address_lo =
1659 (pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe,
1660 db_addr_lo) / 32] - dpl);
1661 phys_addr.u.a32.address_hi =
1662 pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe,
1663 db_addr_hi) / 32];
1664
1665 phys_addr.u.a64.address =
1666 *((unsigned long long *)(&phys_addr.u.a64.address));
1667
1668 switch (pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe, code) / 32]
1669 & PDUCQE_CODE_MASK) {
1670 case UNSOL_HDR_NOTIFY:
1671 is_header = 1;
1672
1673 pbusy_list = hwi_get_async_busy_list(pasync_ctx,
1674 is_header, index);
1675 break;
1676 case UNSOL_DATA_NOTIFY:
1677 pbusy_list = hwi_get_async_busy_list(pasync_ctx,
1678 is_header, index);
1679 break;
1680 default:
1681 pbusy_list = NULL;
1682 beiscsi_log(phba, KERN_WARNING,
1683 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG,
1684 "BM_%d : Unexpected code=%d\n",
1685 pdpdu_cqe->dw[offsetof(struct amap_i_t_dpdu_cqe,
1686 code) / 32] & PDUCQE_CODE_MASK);
1687 return NULL;
1688 }
1689
1690 WARN_ON(list_empty(pbusy_list));
1691 list_for_each_entry(pasync_handle, pbusy_list, link) {
1692 if (pasync_handle->pa.u.a64.address == phys_addr.u.a64.address)
1693 break;
1694 }
1695
1696 WARN_ON(!pasync_handle);
1697
1698 pasync_handle->cri = BE_GET_ASYNC_CRI_FROM_CID(
1699 beiscsi_conn->beiscsi_conn_cid);
1700 pasync_handle->is_header = is_header;
1701 pasync_handle->buffer_len = dpl;
1702 *pcq_index = index;
1703
1704 return pasync_handle;
1705 }
1706
1707 static unsigned int
1708 hwi_update_async_writables(struct beiscsi_hba *phba,
1709 struct hwi_async_pdu_context *pasync_ctx,
1710 unsigned int is_header, unsigned int cq_index)
1711 {
1712 struct list_head *pbusy_list;
1713 struct async_pdu_handle *pasync_handle;
1714 unsigned int num_entries, writables = 0;
1715 unsigned int *pep_read_ptr, *pwritables;
1716
1717 num_entries = pasync_ctx->num_entries;
1718 if (is_header) {
1719 pep_read_ptr = &pasync_ctx->async_header.ep_read_ptr;
1720 pwritables = &pasync_ctx->async_header.writables;
1721 } else {
1722 pep_read_ptr = &pasync_ctx->async_data.ep_read_ptr;
1723 pwritables = &pasync_ctx->async_data.writables;
1724 }
1725
1726 while ((*pep_read_ptr) != cq_index) {
1727 (*pep_read_ptr)++;
1728 *pep_read_ptr = (*pep_read_ptr) % num_entries;
1729
1730 pbusy_list = hwi_get_async_busy_list(pasync_ctx, is_header,
1731 *pep_read_ptr);
1732 if (writables == 0)
1733 WARN_ON(list_empty(pbusy_list));
1734
1735 if (!list_empty(pbusy_list)) {
1736 pasync_handle = list_entry(pbusy_list->next,
1737 struct async_pdu_handle,
1738 link);
1739 WARN_ON(!pasync_handle);
1740 pasync_handle->consumed = 1;
1741 }
1742
1743 writables++;
1744 }
1745
1746 if (!writables) {
1747 beiscsi_log(phba, KERN_ERR,
1748 BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO,
1749 "BM_%d : Duplicate notification received - index 0x%x!!\n",
1750 cq_index);
1751 WARN_ON(1);
1752 }
1753
1754 *pwritables = *pwritables + writables;
1755 return 0;
1756 }
1757
1758 static void hwi_free_async_msg(struct beiscsi_hba *phba,
1759 struct hwi_async_pdu_context *pasync_ctx,
1760 unsigned int cri)
1761 {
1762 struct async_pdu_handle *pasync_handle, *tmp_handle;
1763 struct list_head *plist;
1764
1765 plist = &pasync_ctx->async_entry[cri].wait_queue.list;
1766 list_for_each_entry_safe(pasync_handle, tmp_handle, plist, link) {
1767 list_del(&pasync_handle->link);
1768
1769 if (pasync_handle->is_header) {
1770 list_add_tail(&pasync_handle->link,
1771 &pasync_ctx->async_header.free_list);
1772 pasync_ctx->async_header.free_entries++;
1773 } else {
1774 list_add_tail(&pasync_handle->link,
1775 &pasync_ctx->async_data.free_list);
1776 pasync_ctx->async_data.free_entries++;
1777 }
1778 }
1779
1780 INIT_LIST_HEAD(&pasync_ctx->async_entry[cri].wait_queue.list);
1781 pasync_ctx->async_entry[cri].wait_queue.hdr_received = 0;
1782 pasync_ctx->async_entry[cri].wait_queue.bytes_received = 0;
1783 }
1784
1785 static struct phys_addr *
1786 hwi_get_ring_address(struct hwi_async_pdu_context *pasync_ctx,
1787 unsigned int is_header, unsigned int host_write_ptr)
1788 {
1789 struct phys_addr *pasync_sge = NULL;
1790
1791 if (is_header)
1792 pasync_sge = pasync_ctx->async_header.ring_base;
1793 else
1794 pasync_sge = pasync_ctx->async_data.ring_base;
1795
1796 return pasync_sge + host_write_ptr;
1797 }
1798
1799 static void hwi_post_async_buffers(struct beiscsi_hba *phba,
1800 unsigned int is_header, uint8_t ulp_num)
1801 {
1802 struct hwi_controller *phwi_ctrlr;
1803 struct hwi_async_pdu_context *pasync_ctx;
1804 struct async_pdu_handle *pasync_handle;
1805 struct list_head *pfree_link, *pbusy_list;
1806 struct phys_addr *pasync_sge;
1807 unsigned int ring_id, num_entries;
1808 unsigned int host_write_num, doorbell_offset;
1809 unsigned int writables;
1810 unsigned int i = 0;
1811 u32 doorbell = 0;
1812
1813 phwi_ctrlr = phba->phwi_ctrlr;
1814 pasync_ctx = HWI_GET_ASYNC_PDU_CTX(phwi_ctrlr, ulp_num);
1815 num_entries = pasync_ctx->num_entries;
1816
1817 if (is_header) {
1818 writables = min(pasync_ctx->async_header.writables,
1819 pasync_ctx->async_header.free_entries);
1820 pfree_link = pasync_ctx->async_header.free_list.next;
1821 host_write_num = pasync_ctx->async_header.host_write_ptr;
1822 ring_id = phwi_ctrlr->default_pdu_hdr[ulp_num].id;
1823 doorbell_offset = phwi_ctrlr->default_pdu_hdr[ulp_num].
1824 doorbell_offset;
1825 } else {
1826 writables = min(pasync_ctx->async_data.writables,
1827 pasync_ctx->async_data.free_entries);
1828 pfree_link = pasync_ctx->async_data.free_list.next;
1829 host_write_num = pasync_ctx->async_data.host_write_ptr;
1830 ring_id = phwi_ctrlr->default_pdu_data[ulp_num].id;
1831 doorbell_offset = phwi_ctrlr->default_pdu_data[ulp_num].
1832 doorbell_offset;
1833 }
1834
1835 writables = (writables / 8) * 8;
1836 if (writables) {
1837 for (i = 0; i < writables; i++) {
1838 pbusy_list =
1839 hwi_get_async_busy_list(pasync_ctx, is_header,
1840 host_write_num);
1841 pasync_handle =
1842 list_entry(pfree_link, struct async_pdu_handle,
1843 link);
1844 WARN_ON(!pasync_handle);
1845 pasync_handle->consumed = 0;
1846
1847 pfree_link = pfree_link->next;
1848
1849 pasync_sge = hwi_get_ring_address(pasync_ctx,
1850 is_header, host_write_num);
1851
1852 pasync_sge->hi = pasync_handle->pa.u.a32.address_lo;
1853 pasync_sge->lo = pasync_handle->pa.u.a32.address_hi;
1854
1855 list_move(&pasync_handle->link, pbusy_list);
1856
1857 host_write_num++;
1858 host_write_num = host_write_num % num_entries;
1859 }
1860
1861 if (is_header) {
1862 pasync_ctx->async_header.host_write_ptr =
1863 host_write_num;
1864 pasync_ctx->async_header.free_entries -= writables;
1865 pasync_ctx->async_header.writables -= writables;
1866 pasync_ctx->async_header.busy_entries += writables;
1867 } else {
1868 pasync_ctx->async_data.host_write_ptr = host_write_num;
1869 pasync_ctx->async_data.free_entries -= writables;
1870 pasync_ctx->async_data.writables -= writables;
1871 pasync_ctx->async_data.busy_entries += writables;
1872 }
1873
1874 doorbell |= ring_id & DB_DEF_PDU_RING_ID_MASK;
1875 doorbell |= 1 << DB_DEF_PDU_REARM_SHIFT;
1876 doorbell |= 0 << DB_DEF_PDU_EVENT_SHIFT;
1877 doorbell |= (writables & DB_DEF_PDU_CQPROC_MASK)
1878 << DB_DEF_PDU_CQPROC_SHIFT;
1879
1880 iowrite32(doorbell, phba->db_va + doorbell_offset);
1881 }
1882 }
1883
1884 static void hwi_flush_default_pdu_buffer(struct beiscsi_hba *phba,
1885 struct beiscsi_conn *beiscsi_conn,
1886 struct i_t_dpdu_cqe *pdpdu_cqe)
1887 {
1888 struct hwi_controller *phwi_ctrlr;
1889 struct hwi_async_pdu_context *pasync_ctx;
1890 struct async_pdu_handle *pasync_handle = NULL;
1891 unsigned int cq_index = -1;
1892 uint16_t cri_index = BE_GET_CRI_FROM_CID(
1893 beiscsi_conn->beiscsi_conn_cid);
1894
1895 phwi_ctrlr = phba->phwi_ctrlr;
1896 pasync_ctx = HWI_GET_ASYNC_PDU_CTX(phwi_ctrlr,
1897 BEISCSI_GET_ULP_FROM_CRI(phwi_ctrlr,
1898 cri_index));
1899
1900 pasync_handle = hwi_get_async_handle(phba, beiscsi_conn, pasync_ctx,
1901 pdpdu_cqe, &cq_index);
1902 BUG_ON(pasync_handle->is_header != 0);
1903 if (pasync_handle->consumed == 0)
1904 hwi_update_async_writables(phba, pasync_ctx,
1905 pasync_handle->is_header, cq_index);
1906
1907 hwi_free_async_msg(phba, pasync_ctx, pasync_handle->cri);
1908 hwi_post_async_buffers(phba, pasync_handle->is_header,
1909 BEISCSI_GET_ULP_FROM_CRI(phwi_ctrlr,
1910 cri_index));
1911 }
1912
1913 static unsigned int
1914 hwi_fwd_async_msg(struct beiscsi_conn *beiscsi_conn,
1915 struct beiscsi_hba *phba,
1916 struct hwi_async_pdu_context *pasync_ctx, unsigned short cri)
1917 {
1918 struct list_head *plist;
1919 struct async_pdu_handle *pasync_handle;
1920 void *phdr = NULL;
1921 unsigned int hdr_len = 0, buf_len = 0;
1922 unsigned int status, index = 0, offset = 0;
1923 void *pfirst_buffer = NULL;
1924 unsigned int num_buf = 0;
1925
1926 plist = &pasync_ctx->async_entry[cri].wait_queue.list;
1927
1928 list_for_each_entry(pasync_handle, plist, link) {
1929 if (index == 0) {
1930 phdr = pasync_handle->pbuffer;
1931 hdr_len = pasync_handle->buffer_len;
1932 } else {
1933 buf_len = pasync_handle->buffer_len;
1934 if (!num_buf) {
1935 pfirst_buffer = pasync_handle->pbuffer;
1936 num_buf++;
1937 }
1938 memcpy(pfirst_buffer + offset,
1939 pasync_handle->pbuffer, buf_len);
1940 offset += buf_len;
1941 }
1942 index++;
1943 }
1944
1945 status = beiscsi_process_async_pdu(beiscsi_conn, phba,
1946 phdr, hdr_len, pfirst_buffer,
1947 offset);
1948
1949 hwi_free_async_msg(phba, pasync_ctx, cri);
1950 return 0;
1951 }
1952
1953 static unsigned int
1954 hwi_gather_async_pdu(struct beiscsi_conn *beiscsi_conn,
1955 struct beiscsi_hba *phba,
1956 struct async_pdu_handle *pasync_handle)
1957 {
1958 struct hwi_async_pdu_context *pasync_ctx;
1959 struct hwi_controller *phwi_ctrlr;
1960 unsigned int bytes_needed = 0, status = 0;
1961 unsigned short cri = pasync_handle->cri;
1962 struct pdu_base *ppdu;
1963
1964 phwi_ctrlr = phba->phwi_ctrlr;
1965 pasync_ctx = HWI_GET_ASYNC_PDU_CTX(phwi_ctrlr,
1966 BEISCSI_GET_ULP_FROM_CRI(phwi_ctrlr,
1967 BE_GET_CRI_FROM_CID(beiscsi_conn->
1968 beiscsi_conn_cid)));
1969
1970 list_del(&pasync_handle->link);
1971 if (pasync_handle->is_header) {
1972 pasync_ctx->async_header.busy_entries--;
1973 if (pasync_ctx->async_entry[cri].wait_queue.hdr_received) {
1974 hwi_free_async_msg(phba, pasync_ctx, cri);
1975 BUG();
1976 }
1977
1978 pasync_ctx->async_entry[cri].wait_queue.bytes_received = 0;
1979 pasync_ctx->async_entry[cri].wait_queue.hdr_received = 1;
1980 pasync_ctx->async_entry[cri].wait_queue.hdr_len =
1981 (unsigned short)pasync_handle->buffer_len;
1982 list_add_tail(&pasync_handle->link,
1983 &pasync_ctx->async_entry[cri].wait_queue.list);
1984
1985 ppdu = pasync_handle->pbuffer;
1986 bytes_needed = ((((ppdu->dw[offsetof(struct amap_pdu_base,
1987 data_len_hi) / 32] & PDUBASE_DATALENHI_MASK) << 8) &
1988 0xFFFF0000) | ((be16_to_cpu((ppdu->
1989 dw[offsetof(struct amap_pdu_base, data_len_lo) / 32]
1990 & PDUBASE_DATALENLO_MASK) >> 16)) & 0x0000FFFF));
1991
1992 if (status == 0) {
1993 pasync_ctx->async_entry[cri].wait_queue.bytes_needed =
1994 bytes_needed;
1995
1996 if (bytes_needed == 0)
1997 status = hwi_fwd_async_msg(beiscsi_conn, phba,
1998 pasync_ctx, cri);
1999 }
2000 } else {
2001 pasync_ctx->async_data.busy_entries--;
2002 if (pasync_ctx->async_entry[cri].wait_queue.hdr_received) {
2003 list_add_tail(&pasync_handle->link,
2004 &pasync_ctx->async_entry[cri].wait_queue.
2005 list);
2006 pasync_ctx->async_entry[cri].wait_queue.
2007 bytes_received +=
2008 (unsigned short)pasync_handle->buffer_len;
2009
2010 if (pasync_ctx->async_entry[cri].wait_queue.
2011 bytes_received >=
2012 pasync_ctx->async_entry[cri].wait_queue.
2013 bytes_needed)
2014 status = hwi_fwd_async_msg(beiscsi_conn, phba,
2015 pasync_ctx, cri);
2016 }
2017 }
2018 return status;
2019 }
2020
2021 static void hwi_process_default_pdu_ring(struct beiscsi_conn *beiscsi_conn,
2022 struct beiscsi_hba *phba,
2023 struct i_t_dpdu_cqe *pdpdu_cqe)
2024 {
2025 struct hwi_controller *phwi_ctrlr;
2026 struct hwi_async_pdu_context *pasync_ctx;
2027 struct async_pdu_handle *pasync_handle = NULL;
2028 unsigned int cq_index = -1;
2029 uint16_t cri_index = BE_GET_CRI_FROM_CID(
2030 beiscsi_conn->beiscsi_conn_cid);
2031
2032 phwi_ctrlr = phba->phwi_ctrlr;
2033 pasync_ctx = HWI_GET_ASYNC_PDU_CTX(phwi_ctrlr,
2034 BEISCSI_GET_ULP_FROM_CRI(phwi_ctrlr,
2035 cri_index));
2036
2037 pasync_handle = hwi_get_async_handle(phba, beiscsi_conn, pasync_ctx,
2038 pdpdu_cqe, &cq_index);
2039
2040 if (pasync_handle->consumed == 0)
2041 hwi_update_async_writables(phba, pasync_ctx,
2042 pasync_handle->is_header, cq_index);
2043
2044 hwi_gather_async_pdu(beiscsi_conn, phba, pasync_handle);
2045 hwi_post_async_buffers(phba, pasync_handle->is_header,
2046 BEISCSI_GET_ULP_FROM_CRI(
2047 phwi_ctrlr, cri_index));
2048 }
2049
2050 static void beiscsi_process_mcc_isr(struct beiscsi_hba *phba)
2051 {
2052 struct be_queue_info *mcc_cq;
2053 struct be_mcc_compl *mcc_compl;
2054 unsigned int num_processed = 0;
2055
2056 mcc_cq = &phba->ctrl.mcc_obj.cq;
2057 mcc_compl = queue_tail_node(mcc_cq);
2058 mcc_compl->flags = le32_to_cpu(mcc_compl->flags);
2059 while (mcc_compl->flags & CQE_FLAGS_VALID_MASK) {
2060
2061 if (num_processed >= 32) {
2062 hwi_ring_cq_db(phba, mcc_cq->id,
2063 num_processed, 0, 0);
2064 num_processed = 0;
2065 }
2066 if (mcc_compl->flags & CQE_FLAGS_ASYNC_MASK) {
2067 /* Interpret flags as an async trailer */
2068 if (is_link_state_evt(mcc_compl->flags))
2069 /* Interpret compl as a async link evt */
2070 beiscsi_async_link_state_process(phba,
2071 (struct be_async_event_link_state *) mcc_compl);
2072 else
2073 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_MBOX,
2074 "BM_%d : Unsupported Async Event, flags"
2075 " = 0x%08x\n",
2076 mcc_compl->flags);
2077 } else if (mcc_compl->flags & CQE_FLAGS_COMPLETED_MASK) {
2078 be_mcc_compl_process_isr(&phba->ctrl, mcc_compl);
2079 atomic_dec(&phba->ctrl.mcc_obj.q.used);
2080 }
2081
2082 mcc_compl->flags = 0;
2083 queue_tail_inc(mcc_cq);
2084 mcc_compl = queue_tail_node(mcc_cq);
2085 mcc_compl->flags = le32_to_cpu(mcc_compl->flags);
2086 num_processed++;
2087 }
2088
2089 if (num_processed > 0)
2090 hwi_ring_cq_db(phba, mcc_cq->id, num_processed, 1, 0);
2091
2092 }
2093
2094 /**
2095 * beiscsi_process_cq()- Process the Completion Queue
2096 * @pbe_eq: Event Q on which the Completion has come
2097 *
2098 * return
2099 * Number of Completion Entries processed.
2100 **/
2101 static unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq)
2102 {
2103 struct be_queue_info *cq;
2104 struct sol_cqe *sol;
2105 struct dmsg_cqe *dmsg;
2106 unsigned int num_processed = 0;
2107 unsigned int tot_nump = 0;
2108 unsigned short code = 0, cid = 0;
2109 uint16_t cri_index = 0;
2110 struct beiscsi_conn *beiscsi_conn;
2111 struct beiscsi_endpoint *beiscsi_ep;
2112 struct iscsi_endpoint *ep;
2113 struct beiscsi_hba *phba;
2114
2115 cq = pbe_eq->cq;
2116 sol = queue_tail_node(cq);
2117 phba = pbe_eq->phba;
2118
2119 while (sol->dw[offsetof(struct amap_sol_cqe, valid) / 32] &
2120 CQE_VALID_MASK) {
2121 be_dws_le_to_cpu(sol, sizeof(struct sol_cqe));
2122
2123 code = (sol->dw[offsetof(struct amap_sol_cqe, code) /
2124 32] & CQE_CODE_MASK);
2125
2126 /* Get the CID */
2127 if (is_chip_be2_be3r(phba)) {
2128 cid = AMAP_GET_BITS(struct amap_sol_cqe, cid, sol);
2129 } else {
2130 if ((code == DRIVERMSG_NOTIFY) ||
2131 (code == UNSOL_HDR_NOTIFY) ||
2132 (code == UNSOL_DATA_NOTIFY))
2133 cid = AMAP_GET_BITS(
2134 struct amap_i_t_dpdu_cqe_v2,
2135 cid, sol);
2136 else
2137 cid = AMAP_GET_BITS(struct amap_sol_cqe_v2,
2138 cid, sol);
2139 }
2140
2141 cri_index = BE_GET_CRI_FROM_CID(cid);
2142 ep = phba->ep_array[cri_index];
2143 beiscsi_ep = ep->dd_data;
2144 beiscsi_conn = beiscsi_ep->conn;
2145
2146 if (num_processed >= 32) {
2147 hwi_ring_cq_db(phba, cq->id,
2148 num_processed, 0, 0);
2149 tot_nump += num_processed;
2150 num_processed = 0;
2151 }
2152
2153 switch (code) {
2154 case SOL_CMD_COMPLETE:
2155 hwi_complete_cmd(beiscsi_conn, phba, sol);
2156 break;
2157 case DRIVERMSG_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 dmsg = (struct dmsg_cqe *)sol;
2164 hwi_complete_drvr_msgs(beiscsi_conn, phba, sol);
2165 break;
2166 case UNSOL_HDR_NOTIFY:
2167 beiscsi_log(phba, KERN_INFO,
2168 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG,
2169 "BM_%d : Received %s[%d] on CID : %d\n",
2170 cqe_desc[code], code, cid);
2171
2172 spin_lock_bh(&phba->async_pdu_lock);
2173 hwi_process_default_pdu_ring(beiscsi_conn, phba,
2174 (struct i_t_dpdu_cqe *)sol);
2175 spin_unlock_bh(&phba->async_pdu_lock);
2176 break;
2177 case UNSOL_DATA_NOTIFY:
2178 beiscsi_log(phba, KERN_INFO,
2179 BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO,
2180 "BM_%d : Received %s[%d] on CID : %d\n",
2181 cqe_desc[code], code, cid);
2182
2183 spin_lock_bh(&phba->async_pdu_lock);
2184 hwi_process_default_pdu_ring(beiscsi_conn, phba,
2185 (struct i_t_dpdu_cqe *)sol);
2186 spin_unlock_bh(&phba->async_pdu_lock);
2187 break;
2188 case CXN_INVALIDATE_INDEX_NOTIFY:
2189 case CMD_INVALIDATED_NOTIFY:
2190 case CXN_INVALIDATE_NOTIFY:
2191 beiscsi_log(phba, KERN_ERR,
2192 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG,
2193 "BM_%d : Ignoring %s[%d] on CID : %d\n",
2194 cqe_desc[code], code, cid);
2195 break;
2196 case SOL_CMD_KILLED_DATA_DIGEST_ERR:
2197 case CMD_KILLED_INVALID_STATSN_RCVD:
2198 case CMD_KILLED_INVALID_R2T_RCVD:
2199 case CMD_CXN_KILLED_LUN_INVALID:
2200 case CMD_CXN_KILLED_ICD_INVALID:
2201 case CMD_CXN_KILLED_ITT_INVALID:
2202 case CMD_CXN_KILLED_SEQ_OUTOFORDER:
2203 case CMD_CXN_KILLED_INVALID_DATASN_RCVD:
2204 beiscsi_log(phba, KERN_ERR,
2205 BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO,
2206 "BM_%d : Cmd Notification %s[%d] on CID : %d\n",
2207 cqe_desc[code], code, cid);
2208 break;
2209 case UNSOL_DATA_DIGEST_ERROR_NOTIFY:
2210 beiscsi_log(phba, KERN_ERR,
2211 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG,
2212 "BM_%d : Dropping %s[%d] on DPDU ring on CID : %d\n",
2213 cqe_desc[code], code, cid);
2214 spin_lock_bh(&phba->async_pdu_lock);
2215 hwi_flush_default_pdu_buffer(phba, beiscsi_conn,
2216 (struct i_t_dpdu_cqe *) sol);
2217 spin_unlock_bh(&phba->async_pdu_lock);
2218 break;
2219 case CXN_KILLED_PDU_SIZE_EXCEEDS_DSL:
2220 case CXN_KILLED_BURST_LEN_MISMATCH:
2221 case CXN_KILLED_AHS_RCVD:
2222 case CXN_KILLED_HDR_DIGEST_ERR:
2223 case CXN_KILLED_UNKNOWN_HDR:
2224 case CXN_KILLED_STALE_ITT_TTT_RCVD:
2225 case CXN_KILLED_INVALID_ITT_TTT_RCVD:
2226 case CXN_KILLED_TIMED_OUT:
2227 case CXN_KILLED_FIN_RCVD:
2228 case CXN_KILLED_RST_SENT:
2229 case CXN_KILLED_RST_RCVD:
2230 case CXN_KILLED_BAD_UNSOL_PDU_RCVD:
2231 case CXN_KILLED_BAD_WRB_INDEX_ERROR:
2232 case CXN_KILLED_OVER_RUN_RESIDUAL:
2233 case CXN_KILLED_UNDER_RUN_RESIDUAL:
2234 case CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN:
2235 beiscsi_log(phba, KERN_ERR,
2236 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG,
2237 "BM_%d : Event %s[%d] received on CID : %d\n",
2238 cqe_desc[code], code, cid);
2239 if (beiscsi_conn)
2240 iscsi_conn_failure(beiscsi_conn->conn,
2241 ISCSI_ERR_CONN_FAILED);
2242 break;
2243 default:
2244 beiscsi_log(phba, KERN_ERR,
2245 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG,
2246 "BM_%d : Invalid CQE Event Received Code : %d"
2247 "CID 0x%x...\n",
2248 code, cid);
2249 break;
2250 }
2251
2252 AMAP_SET_BITS(struct amap_sol_cqe, valid, sol, 0);
2253 queue_tail_inc(cq);
2254 sol = queue_tail_node(cq);
2255 num_processed++;
2256 }
2257
2258 if (num_processed > 0) {
2259 tot_nump += num_processed;
2260 hwi_ring_cq_db(phba, cq->id, num_processed, 1, 0);
2261 }
2262 return tot_nump;
2263 }
2264
2265 void beiscsi_process_all_cqs(struct work_struct *work)
2266 {
2267 unsigned long flags;
2268 struct hwi_controller *phwi_ctrlr;
2269 struct hwi_context_memory *phwi_context;
2270 struct beiscsi_hba *phba;
2271 struct be_eq_obj *pbe_eq =
2272 container_of(work, struct be_eq_obj, work_cqs);
2273
2274 phba = pbe_eq->phba;
2275 phwi_ctrlr = phba->phwi_ctrlr;
2276 phwi_context = phwi_ctrlr->phwi_ctxt;
2277
2278 if (pbe_eq->todo_mcc_cq) {
2279 spin_lock_irqsave(&phba->isr_lock, flags);
2280 pbe_eq->todo_mcc_cq = false;
2281 spin_unlock_irqrestore(&phba->isr_lock, flags);
2282 beiscsi_process_mcc_isr(phba);
2283 }
2284
2285 if (pbe_eq->todo_cq) {
2286 spin_lock_irqsave(&phba->isr_lock, flags);
2287 pbe_eq->todo_cq = false;
2288 spin_unlock_irqrestore(&phba->isr_lock, flags);
2289 beiscsi_process_cq(pbe_eq);
2290 }
2291
2292 /* rearm EQ for further interrupts */
2293 hwi_ring_eq_db(phba, pbe_eq->q.id, 0, 0, 1, 1);
2294 }
2295
2296 static int be_iopoll(struct blk_iopoll *iop, int budget)
2297 {
2298 unsigned int ret;
2299 struct beiscsi_hba *phba;
2300 struct be_eq_obj *pbe_eq;
2301
2302 pbe_eq = container_of(iop, struct be_eq_obj, iopoll);
2303 ret = beiscsi_process_cq(pbe_eq);
2304 if (ret < budget) {
2305 phba = pbe_eq->phba;
2306 blk_iopoll_complete(iop);
2307 beiscsi_log(phba, KERN_INFO,
2308 BEISCSI_LOG_CONFIG | BEISCSI_LOG_IO,
2309 "BM_%d : rearm pbe_eq->q.id =%d\n",
2310 pbe_eq->q.id);
2311 hwi_ring_eq_db(phba, pbe_eq->q.id, 0, 0, 1, 1);
2312 }
2313 return ret;
2314 }
2315
2316 static void
2317 hwi_write_sgl_v2(struct iscsi_wrb *pwrb, struct scatterlist *sg,
2318 unsigned int num_sg, struct beiscsi_io_task *io_task)
2319 {
2320 struct iscsi_sge *psgl;
2321 unsigned int sg_len, index;
2322 unsigned int sge_len = 0;
2323 unsigned long long addr;
2324 struct scatterlist *l_sg;
2325 unsigned int offset;
2326
2327 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, iscsi_bhs_addr_lo, pwrb,
2328 io_task->bhs_pa.u.a32.address_lo);
2329 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, iscsi_bhs_addr_hi, pwrb,
2330 io_task->bhs_pa.u.a32.address_hi);
2331
2332 l_sg = sg;
2333 for (index = 0; (index < num_sg) && (index < 2); index++,
2334 sg = sg_next(sg)) {
2335 if (index == 0) {
2336 sg_len = sg_dma_len(sg);
2337 addr = (u64) sg_dma_address(sg);
2338 AMAP_SET_BITS(struct amap_iscsi_wrb_v2,
2339 sge0_addr_lo, pwrb,
2340 lower_32_bits(addr));
2341 AMAP_SET_BITS(struct amap_iscsi_wrb_v2,
2342 sge0_addr_hi, pwrb,
2343 upper_32_bits(addr));
2344 AMAP_SET_BITS(struct amap_iscsi_wrb_v2,
2345 sge0_len, pwrb,
2346 sg_len);
2347 sge_len = sg_len;
2348 } else {
2349 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge1_r2t_offset,
2350 pwrb, sge_len);
2351 sg_len = sg_dma_len(sg);
2352 addr = (u64) sg_dma_address(sg);
2353 AMAP_SET_BITS(struct amap_iscsi_wrb_v2,
2354 sge1_addr_lo, pwrb,
2355 lower_32_bits(addr));
2356 AMAP_SET_BITS(struct amap_iscsi_wrb_v2,
2357 sge1_addr_hi, pwrb,
2358 upper_32_bits(addr));
2359 AMAP_SET_BITS(struct amap_iscsi_wrb_v2,
2360 sge1_len, pwrb,
2361 sg_len);
2362 }
2363 }
2364 psgl = (struct iscsi_sge *)io_task->psgl_handle->pfrag;
2365 memset(psgl, 0, sizeof(*psgl) * BE2_SGE);
2366
2367 AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, io_task->bhs_len - 2);
2368
2369 AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl,
2370 io_task->bhs_pa.u.a32.address_hi);
2371 AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl,
2372 io_task->bhs_pa.u.a32.address_lo);
2373
2374 if (num_sg == 1) {
2375 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge0_last, pwrb,
2376 1);
2377 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge1_last, pwrb,
2378 0);
2379 } else if (num_sg == 2) {
2380 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge0_last, pwrb,
2381 0);
2382 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge1_last, pwrb,
2383 1);
2384 } else {
2385 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge0_last, pwrb,
2386 0);
2387 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sge1_last, pwrb,
2388 0);
2389 }
2390
2391 sg = l_sg;
2392 psgl++;
2393 psgl++;
2394 offset = 0;
2395 for (index = 0; index < num_sg; index++, sg = sg_next(sg), psgl++) {
2396 sg_len = sg_dma_len(sg);
2397 addr = (u64) sg_dma_address(sg);
2398 AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl,
2399 lower_32_bits(addr));
2400 AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl,
2401 upper_32_bits(addr));
2402 AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, sg_len);
2403 AMAP_SET_BITS(struct amap_iscsi_sge, sge_offset, psgl, offset);
2404 AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 0);
2405 offset += sg_len;
2406 }
2407 psgl--;
2408 AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 1);
2409 }
2410
2411 static void
2412 hwi_write_sgl(struct iscsi_wrb *pwrb, struct scatterlist *sg,
2413 unsigned int num_sg, struct beiscsi_io_task *io_task)
2414 {
2415 struct iscsi_sge *psgl;
2416 unsigned int sg_len, index;
2417 unsigned int sge_len = 0;
2418 unsigned long long addr;
2419 struct scatterlist *l_sg;
2420 unsigned int offset;
2421
2422 AMAP_SET_BITS(struct amap_iscsi_wrb, iscsi_bhs_addr_lo, pwrb,
2423 io_task->bhs_pa.u.a32.address_lo);
2424 AMAP_SET_BITS(struct amap_iscsi_wrb, iscsi_bhs_addr_hi, pwrb,
2425 io_task->bhs_pa.u.a32.address_hi);
2426
2427 l_sg = sg;
2428 for (index = 0; (index < num_sg) && (index < 2); index++,
2429 sg = sg_next(sg)) {
2430 if (index == 0) {
2431 sg_len = sg_dma_len(sg);
2432 addr = (u64) sg_dma_address(sg);
2433 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_lo, pwrb,
2434 ((u32)(addr & 0xFFFFFFFF)));
2435 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_hi, pwrb,
2436 ((u32)(addr >> 32)));
2437 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_len, pwrb,
2438 sg_len);
2439 sge_len = sg_len;
2440 } else {
2441 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_r2t_offset,
2442 pwrb, sge_len);
2443 sg_len = sg_dma_len(sg);
2444 addr = (u64) sg_dma_address(sg);
2445 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_addr_lo, pwrb,
2446 ((u32)(addr & 0xFFFFFFFF)));
2447 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_addr_hi, pwrb,
2448 ((u32)(addr >> 32)));
2449 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_len, pwrb,
2450 sg_len);
2451 }
2452 }
2453 psgl = (struct iscsi_sge *)io_task->psgl_handle->pfrag;
2454 memset(psgl, 0, sizeof(*psgl) * BE2_SGE);
2455
2456 AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, io_task->bhs_len - 2);
2457
2458 AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl,
2459 io_task->bhs_pa.u.a32.address_hi);
2460 AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl,
2461 io_task->bhs_pa.u.a32.address_lo);
2462
2463 if (num_sg == 1) {
2464 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_last, pwrb,
2465 1);
2466 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_last, pwrb,
2467 0);
2468 } else if (num_sg == 2) {
2469 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_last, pwrb,
2470 0);
2471 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_last, pwrb,
2472 1);
2473 } else {
2474 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_last, pwrb,
2475 0);
2476 AMAP_SET_BITS(struct amap_iscsi_wrb, sge1_last, pwrb,
2477 0);
2478 }
2479 sg = l_sg;
2480 psgl++;
2481 psgl++;
2482 offset = 0;
2483 for (index = 0; index < num_sg; index++, sg = sg_next(sg), psgl++) {
2484 sg_len = sg_dma_len(sg);
2485 addr = (u64) sg_dma_address(sg);
2486 AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl,
2487 (addr & 0xFFFFFFFF));
2488 AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl,
2489 (addr >> 32));
2490 AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, sg_len);
2491 AMAP_SET_BITS(struct amap_iscsi_sge, sge_offset, psgl, offset);
2492 AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 0);
2493 offset += sg_len;
2494 }
2495 psgl--;
2496 AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 1);
2497 }
2498
2499 /**
2500 * hwi_write_buffer()- Populate the WRB with task info
2501 * @pwrb: ptr to the WRB entry
2502 * @task: iscsi task which is to be executed
2503 **/
2504 static void hwi_write_buffer(struct iscsi_wrb *pwrb, struct iscsi_task *task)
2505 {
2506 struct iscsi_sge *psgl;
2507 struct beiscsi_io_task *io_task = task->dd_data;
2508 struct beiscsi_conn *beiscsi_conn = io_task->conn;
2509 struct beiscsi_hba *phba = beiscsi_conn->phba;
2510 uint8_t dsp_value = 0;
2511
2512 io_task->bhs_len = sizeof(struct be_nonio_bhs) - 2;
2513 AMAP_SET_BITS(struct amap_iscsi_wrb, iscsi_bhs_addr_lo, pwrb,
2514 io_task->bhs_pa.u.a32.address_lo);
2515 AMAP_SET_BITS(struct amap_iscsi_wrb, iscsi_bhs_addr_hi, pwrb,
2516 io_task->bhs_pa.u.a32.address_hi);
2517
2518 if (task->data) {
2519
2520 /* Check for the data_count */
2521 dsp_value = (task->data_count) ? 1 : 0;
2522
2523 if (is_chip_be2_be3r(phba))
2524 AMAP_SET_BITS(struct amap_iscsi_wrb, dsp,
2525 pwrb, dsp_value);
2526 else
2527 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, dsp,
2528 pwrb, dsp_value);
2529
2530 /* Map addr only if there is data_count */
2531 if (dsp_value) {
2532 io_task->mtask_addr = pci_map_single(phba->pcidev,
2533 task->data,
2534 task->data_count,
2535 PCI_DMA_TODEVICE);
2536 io_task->mtask_data_count = task->data_count;
2537 } else
2538 io_task->mtask_addr = 0;
2539
2540 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_lo, pwrb,
2541 lower_32_bits(io_task->mtask_addr));
2542 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_addr_hi, pwrb,
2543 upper_32_bits(io_task->mtask_addr));
2544 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_len, pwrb,
2545 task->data_count);
2546
2547 AMAP_SET_BITS(struct amap_iscsi_wrb, sge0_last, pwrb, 1);
2548 } else {
2549 AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 0);
2550 io_task->mtask_addr = 0;
2551 }
2552
2553 psgl = (struct iscsi_sge *)io_task->psgl_handle->pfrag;
2554
2555 AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, io_task->bhs_len);
2556
2557 AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl,
2558 io_task->bhs_pa.u.a32.address_hi);
2559 AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl,
2560 io_task->bhs_pa.u.a32.address_lo);
2561 if (task->data) {
2562 psgl++;
2563 AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl, 0);
2564 AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl, 0);
2565 AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, 0);
2566 AMAP_SET_BITS(struct amap_iscsi_sge, sge_offset, psgl, 0);
2567 AMAP_SET_BITS(struct amap_iscsi_sge, rsvd0, psgl, 0);
2568 AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 0);
2569
2570 psgl++;
2571 if (task->data) {
2572 AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, psgl,
2573 lower_32_bits(io_task->mtask_addr));
2574 AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, psgl,
2575 upper_32_bits(io_task->mtask_addr));
2576 }
2577 AMAP_SET_BITS(struct amap_iscsi_sge, len, psgl, 0x106);
2578 }
2579 AMAP_SET_BITS(struct amap_iscsi_sge, last_sge, psgl, 1);
2580 }
2581
2582 /**
2583 * beiscsi_find_mem_req()- Find mem needed
2584 * @phba: ptr to HBA struct
2585 **/
2586 static void beiscsi_find_mem_req(struct beiscsi_hba *phba)
2587 {
2588 uint8_t mem_descr_index, ulp_num;
2589 unsigned int num_cq_pages, num_async_pdu_buf_pages;
2590 unsigned int num_async_pdu_data_pages, wrb_sz_per_cxn;
2591 unsigned int num_async_pdu_buf_sgl_pages, num_async_pdu_data_sgl_pages;
2592
2593 num_cq_pages = PAGES_REQUIRED(phba->params.num_cq_entries * \
2594 sizeof(struct sol_cqe));
2595
2596 phba->params.hwi_ws_sz = sizeof(struct hwi_controller);
2597
2598 phba->mem_req[ISCSI_MEM_GLOBAL_HEADER] = 2 *
2599 BE_ISCSI_PDU_HEADER_SIZE;
2600 phba->mem_req[HWI_MEM_ADDN_CONTEXT] =
2601 sizeof(struct hwi_context_memory);
2602
2603
2604 phba->mem_req[HWI_MEM_WRB] = sizeof(struct iscsi_wrb)
2605 * (phba->params.wrbs_per_cxn)
2606 * phba->params.cxns_per_ctrl;
2607 wrb_sz_per_cxn = sizeof(struct wrb_handle) *
2608 (phba->params.wrbs_per_cxn);
2609 phba->mem_req[HWI_MEM_WRBH] = roundup_pow_of_two((wrb_sz_per_cxn) *
2610 phba->params.cxns_per_ctrl);
2611
2612 phba->mem_req[HWI_MEM_SGLH] = sizeof(struct sgl_handle) *
2613 phba->params.icds_per_ctrl;
2614 phba->mem_req[HWI_MEM_SGE] = sizeof(struct iscsi_sge) *
2615 phba->params.num_sge_per_io * phba->params.icds_per_ctrl;
2616 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
2617 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) {
2618
2619 num_async_pdu_buf_sgl_pages =
2620 PAGES_REQUIRED(BEISCSI_GET_CID_COUNT(
2621 phba, ulp_num) *
2622 sizeof(struct phys_addr));
2623
2624 num_async_pdu_buf_pages =
2625 PAGES_REQUIRED(BEISCSI_GET_CID_COUNT(
2626 phba, ulp_num) *
2627 phba->params.defpdu_hdr_sz);
2628
2629 num_async_pdu_data_pages =
2630 PAGES_REQUIRED(BEISCSI_GET_CID_COUNT(
2631 phba, ulp_num) *
2632 phba->params.defpdu_data_sz);
2633
2634 num_async_pdu_data_sgl_pages =
2635 PAGES_REQUIRED(BEISCSI_GET_CID_COUNT(
2636 phba, ulp_num) *
2637 sizeof(struct phys_addr));
2638
2639 mem_descr_index = (HWI_MEM_TEMPLATE_HDR_ULP0 +
2640 (ulp_num * MEM_DESCR_OFFSET));
2641 phba->mem_req[mem_descr_index] =
2642 BEISCSI_GET_CID_COUNT(phba, ulp_num) *
2643 BEISCSI_TEMPLATE_HDR_PER_CXN_SIZE;
2644
2645 mem_descr_index = (HWI_MEM_ASYNC_HEADER_BUF_ULP0 +
2646 (ulp_num * MEM_DESCR_OFFSET));
2647 phba->mem_req[mem_descr_index] =
2648 num_async_pdu_buf_pages *
2649 PAGE_SIZE;
2650
2651 mem_descr_index = (HWI_MEM_ASYNC_DATA_BUF_ULP0 +
2652 (ulp_num * MEM_DESCR_OFFSET));
2653 phba->mem_req[mem_descr_index] =
2654 num_async_pdu_data_pages *
2655 PAGE_SIZE;
2656
2657 mem_descr_index = (HWI_MEM_ASYNC_HEADER_RING_ULP0 +
2658 (ulp_num * MEM_DESCR_OFFSET));
2659 phba->mem_req[mem_descr_index] =
2660 num_async_pdu_buf_sgl_pages *
2661 PAGE_SIZE;
2662
2663 mem_descr_index = (HWI_MEM_ASYNC_DATA_RING_ULP0 +
2664 (ulp_num * MEM_DESCR_OFFSET));
2665 phba->mem_req[mem_descr_index] =
2666 num_async_pdu_data_sgl_pages *
2667 PAGE_SIZE;
2668
2669 mem_descr_index = (HWI_MEM_ASYNC_HEADER_HANDLE_ULP0 +
2670 (ulp_num * MEM_DESCR_OFFSET));
2671 phba->mem_req[mem_descr_index] =
2672 BEISCSI_GET_CID_COUNT(phba, ulp_num) *
2673 sizeof(struct async_pdu_handle);
2674
2675 mem_descr_index = (HWI_MEM_ASYNC_DATA_HANDLE_ULP0 +
2676 (ulp_num * MEM_DESCR_OFFSET));
2677 phba->mem_req[mem_descr_index] =
2678 BEISCSI_GET_CID_COUNT(phba, ulp_num) *
2679 sizeof(struct async_pdu_handle);
2680
2681 mem_descr_index = (HWI_MEM_ASYNC_PDU_CONTEXT_ULP0 +
2682 (ulp_num * MEM_DESCR_OFFSET));
2683 phba->mem_req[mem_descr_index] =
2684 sizeof(struct hwi_async_pdu_context) +
2685 (BEISCSI_GET_CID_COUNT(phba, ulp_num) *
2686 sizeof(struct hwi_async_entry));
2687 }
2688 }
2689 }
2690
2691 static int beiscsi_alloc_mem(struct beiscsi_hba *phba)
2692 {
2693 dma_addr_t bus_add;
2694 struct hwi_controller *phwi_ctrlr;
2695 struct be_mem_descriptor *mem_descr;
2696 struct mem_array *mem_arr, *mem_arr_orig;
2697 unsigned int i, j, alloc_size, curr_alloc_size;
2698
2699 phba->phwi_ctrlr = kzalloc(phba->params.hwi_ws_sz, GFP_KERNEL);
2700 if (!phba->phwi_ctrlr)
2701 return -ENOMEM;
2702
2703 /* Allocate memory for wrb_context */
2704 phwi_ctrlr = phba->phwi_ctrlr;
2705 phwi_ctrlr->wrb_context = kzalloc(sizeof(struct hwi_wrb_context) *
2706 phba->params.cxns_per_ctrl,
2707 GFP_KERNEL);
2708 if (!phwi_ctrlr->wrb_context)
2709 return -ENOMEM;
2710
2711 phba->init_mem = kcalloc(SE_MEM_MAX, sizeof(*mem_descr),
2712 GFP_KERNEL);
2713 if (!phba->init_mem) {
2714 kfree(phwi_ctrlr->wrb_context);
2715 kfree(phba->phwi_ctrlr);
2716 return -ENOMEM;
2717 }
2718
2719 mem_arr_orig = kmalloc(sizeof(*mem_arr_orig) * BEISCSI_MAX_FRAGS_INIT,
2720 GFP_KERNEL);
2721 if (!mem_arr_orig) {
2722 kfree(phba->init_mem);
2723 kfree(phwi_ctrlr->wrb_context);
2724 kfree(phba->phwi_ctrlr);
2725 return -ENOMEM;
2726 }
2727
2728 mem_descr = phba->init_mem;
2729 for (i = 0; i < SE_MEM_MAX; i++) {
2730 if (!phba->mem_req[i]) {
2731 mem_descr->mem_array = NULL;
2732 mem_descr++;
2733 continue;
2734 }
2735
2736 j = 0;
2737 mem_arr = mem_arr_orig;
2738 alloc_size = phba->mem_req[i];
2739 memset(mem_arr, 0, sizeof(struct mem_array) *
2740 BEISCSI_MAX_FRAGS_INIT);
2741 curr_alloc_size = min(be_max_phys_size * 1024, alloc_size);
2742 do {
2743 mem_arr->virtual_address = pci_alloc_consistent(
2744 phba->pcidev,
2745 curr_alloc_size,
2746 &bus_add);
2747 if (!mem_arr->virtual_address) {
2748 if (curr_alloc_size <= BE_MIN_MEM_SIZE)
2749 goto free_mem;
2750 if (curr_alloc_size -
2751 rounddown_pow_of_two(curr_alloc_size))
2752 curr_alloc_size = rounddown_pow_of_two
2753 (curr_alloc_size);
2754 else
2755 curr_alloc_size = curr_alloc_size / 2;
2756 } else {
2757 mem_arr->bus_address.u.
2758 a64.address = (__u64) bus_add;
2759 mem_arr->size = curr_alloc_size;
2760 alloc_size -= curr_alloc_size;
2761 curr_alloc_size = min(be_max_phys_size *
2762 1024, alloc_size);
2763 j++;
2764 mem_arr++;
2765 }
2766 } while (alloc_size);
2767 mem_descr->num_elements = j;
2768 mem_descr->size_in_bytes = phba->mem_req[i];
2769 mem_descr->mem_array = kmalloc(sizeof(*mem_arr) * j,
2770 GFP_KERNEL);
2771 if (!mem_descr->mem_array)
2772 goto free_mem;
2773
2774 memcpy(mem_descr->mem_array, mem_arr_orig,
2775 sizeof(struct mem_array) * j);
2776 mem_descr++;
2777 }
2778 kfree(mem_arr_orig);
2779 return 0;
2780 free_mem:
2781 mem_descr->num_elements = j;
2782 while ((i) || (j)) {
2783 for (j = mem_descr->num_elements; j > 0; j--) {
2784 pci_free_consistent(phba->pcidev,
2785 mem_descr->mem_array[j - 1].size,
2786 mem_descr->mem_array[j - 1].
2787 virtual_address,
2788 (unsigned long)mem_descr->
2789 mem_array[j - 1].
2790 bus_address.u.a64.address);
2791 }
2792 if (i) {
2793 i--;
2794 kfree(mem_descr->mem_array);
2795 mem_descr--;
2796 }
2797 }
2798 kfree(mem_arr_orig);
2799 kfree(phba->init_mem);
2800 kfree(phba->phwi_ctrlr->wrb_context);
2801 kfree(phba->phwi_ctrlr);
2802 return -ENOMEM;
2803 }
2804
2805 static int beiscsi_get_memory(struct beiscsi_hba *phba)
2806 {
2807 beiscsi_find_mem_req(phba);
2808 return beiscsi_alloc_mem(phba);
2809 }
2810
2811 static void iscsi_init_global_templates(struct beiscsi_hba *phba)
2812 {
2813 struct pdu_data_out *pdata_out;
2814 struct pdu_nop_out *pnop_out;
2815 struct be_mem_descriptor *mem_descr;
2816
2817 mem_descr = phba->init_mem;
2818 mem_descr += ISCSI_MEM_GLOBAL_HEADER;
2819 pdata_out =
2820 (struct pdu_data_out *)mem_descr->mem_array[0].virtual_address;
2821 memset(pdata_out, 0, BE_ISCSI_PDU_HEADER_SIZE);
2822
2823 AMAP_SET_BITS(struct amap_pdu_data_out, opcode, pdata_out,
2824 IIOC_SCSI_DATA);
2825
2826 pnop_out =
2827 (struct pdu_nop_out *)((unsigned char *)mem_descr->mem_array[0].
2828 virtual_address + BE_ISCSI_PDU_HEADER_SIZE);
2829
2830 memset(pnop_out, 0, BE_ISCSI_PDU_HEADER_SIZE);
2831 AMAP_SET_BITS(struct amap_pdu_nop_out, ttt, pnop_out, 0xFFFFFFFF);
2832 AMAP_SET_BITS(struct amap_pdu_nop_out, f_bit, pnop_out, 1);
2833 AMAP_SET_BITS(struct amap_pdu_nop_out, i_bit, pnop_out, 0);
2834 }
2835
2836 static int beiscsi_init_wrb_handle(struct beiscsi_hba *phba)
2837 {
2838 struct be_mem_descriptor *mem_descr_wrbh, *mem_descr_wrb;
2839 struct hwi_context_memory *phwi_ctxt;
2840 struct wrb_handle *pwrb_handle = NULL;
2841 struct hwi_controller *phwi_ctrlr;
2842 struct hwi_wrb_context *pwrb_context;
2843 struct iscsi_wrb *pwrb = NULL;
2844 unsigned int num_cxn_wrbh = 0;
2845 unsigned int num_cxn_wrb = 0, j, idx = 0, index;
2846
2847 mem_descr_wrbh = phba->init_mem;
2848 mem_descr_wrbh += HWI_MEM_WRBH;
2849
2850 mem_descr_wrb = phba->init_mem;
2851 mem_descr_wrb += HWI_MEM_WRB;
2852 phwi_ctrlr = phba->phwi_ctrlr;
2853
2854 /* Allocate memory for WRBQ */
2855 phwi_ctxt = phwi_ctrlr->phwi_ctxt;
2856 phwi_ctxt->be_wrbq = kzalloc(sizeof(struct be_queue_info) *
2857 phba->params.cxns_per_ctrl,
2858 GFP_KERNEL);
2859 if (!phwi_ctxt->be_wrbq) {
2860 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
2861 "BM_%d : WRBQ Mem Alloc Failed\n");
2862 return -ENOMEM;
2863 }
2864
2865 for (index = 0; index < phba->params.cxns_per_ctrl; index++) {
2866 pwrb_context = &phwi_ctrlr->wrb_context[index];
2867 pwrb_context->pwrb_handle_base =
2868 kzalloc(sizeof(struct wrb_handle *) *
2869 phba->params.wrbs_per_cxn, GFP_KERNEL);
2870 if (!pwrb_context->pwrb_handle_base) {
2871 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
2872 "BM_%d : Mem Alloc Failed. Failing to load\n");
2873 goto init_wrb_hndl_failed;
2874 }
2875 pwrb_context->pwrb_handle_basestd =
2876 kzalloc(sizeof(struct wrb_handle *) *
2877 phba->params.wrbs_per_cxn, GFP_KERNEL);
2878 if (!pwrb_context->pwrb_handle_basestd) {
2879 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
2880 "BM_%d : Mem Alloc Failed. Failing to load\n");
2881 goto init_wrb_hndl_failed;
2882 }
2883 if (!num_cxn_wrbh) {
2884 pwrb_handle =
2885 mem_descr_wrbh->mem_array[idx].virtual_address;
2886 num_cxn_wrbh = ((mem_descr_wrbh->mem_array[idx].size) /
2887 ((sizeof(struct wrb_handle)) *
2888 phba->params.wrbs_per_cxn));
2889 idx++;
2890 }
2891 pwrb_context->alloc_index = 0;
2892 pwrb_context->wrb_handles_available = 0;
2893 pwrb_context->free_index = 0;
2894
2895 if (num_cxn_wrbh) {
2896 for (j = 0; j < phba->params.wrbs_per_cxn; j++) {
2897 pwrb_context->pwrb_handle_base[j] = pwrb_handle;
2898 pwrb_context->pwrb_handle_basestd[j] =
2899 pwrb_handle;
2900 pwrb_context->wrb_handles_available++;
2901 pwrb_handle->wrb_index = j;
2902 pwrb_handle++;
2903 }
2904 num_cxn_wrbh--;
2905 }
2906 }
2907 idx = 0;
2908 for (index = 0; index < phba->params.cxns_per_ctrl; index++) {
2909 pwrb_context = &phwi_ctrlr->wrb_context[index];
2910 if (!num_cxn_wrb) {
2911 pwrb = mem_descr_wrb->mem_array[idx].virtual_address;
2912 num_cxn_wrb = (mem_descr_wrb->mem_array[idx].size) /
2913 ((sizeof(struct iscsi_wrb) *
2914 phba->params.wrbs_per_cxn));
2915 idx++;
2916 }
2917
2918 if (num_cxn_wrb) {
2919 for (j = 0; j < phba->params.wrbs_per_cxn; j++) {
2920 pwrb_handle = pwrb_context->pwrb_handle_base[j];
2921 pwrb_handle->pwrb = pwrb;
2922 pwrb++;
2923 }
2924 num_cxn_wrb--;
2925 }
2926 }
2927 return 0;
2928 init_wrb_hndl_failed:
2929 for (j = index; j > 0; j--) {
2930 pwrb_context = &phwi_ctrlr->wrb_context[j];
2931 kfree(pwrb_context->pwrb_handle_base);
2932 kfree(pwrb_context->pwrb_handle_basestd);
2933 }
2934 return -ENOMEM;
2935 }
2936
2937 static int hwi_init_async_pdu_ctx(struct beiscsi_hba *phba)
2938 {
2939 uint8_t ulp_num;
2940 struct hwi_controller *phwi_ctrlr;
2941 struct hba_parameters *p = &phba->params;
2942 struct hwi_async_pdu_context *pasync_ctx;
2943 struct async_pdu_handle *pasync_header_h, *pasync_data_h;
2944 unsigned int index, idx, num_per_mem, num_async_data;
2945 struct be_mem_descriptor *mem_descr;
2946
2947 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
2948 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) {
2949
2950 mem_descr = (struct be_mem_descriptor *)phba->init_mem;
2951 mem_descr += (HWI_MEM_ASYNC_PDU_CONTEXT_ULP0 +
2952 (ulp_num * MEM_DESCR_OFFSET));
2953
2954 phwi_ctrlr = phba->phwi_ctrlr;
2955 phwi_ctrlr->phwi_ctxt->pasync_ctx[ulp_num] =
2956 (struct hwi_async_pdu_context *)
2957 mem_descr->mem_array[0].virtual_address;
2958
2959 pasync_ctx = phwi_ctrlr->phwi_ctxt->pasync_ctx[ulp_num];
2960 memset(pasync_ctx, 0, sizeof(*pasync_ctx));
2961
2962 pasync_ctx->async_entry =
2963 (struct hwi_async_entry *)
2964 ((long unsigned int)pasync_ctx +
2965 sizeof(struct hwi_async_pdu_context));
2966
2967 pasync_ctx->num_entries = BEISCSI_GET_CID_COUNT(phba,
2968 ulp_num);
2969 pasync_ctx->buffer_size = p->defpdu_hdr_sz;
2970
2971 mem_descr = (struct be_mem_descriptor *)phba->init_mem;
2972 mem_descr += HWI_MEM_ASYNC_HEADER_BUF_ULP0 +
2973 (ulp_num * MEM_DESCR_OFFSET);
2974 if (mem_descr->mem_array[0].virtual_address) {
2975 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
2976 "BM_%d : hwi_init_async_pdu_ctx"
2977 " HWI_MEM_ASYNC_HEADER_BUF_ULP%d va=%p\n",
2978 ulp_num,
2979 mem_descr->mem_array[0].
2980 virtual_address);
2981 } else
2982 beiscsi_log(phba, KERN_WARNING,
2983 BEISCSI_LOG_INIT,
2984 "BM_%d : No Virtual address for ULP : %d\n",
2985 ulp_num);
2986
2987 pasync_ctx->async_header.va_base =
2988 mem_descr->mem_array[0].virtual_address;
2989
2990 pasync_ctx->async_header.pa_base.u.a64.address =
2991 mem_descr->mem_array[0].
2992 bus_address.u.a64.address;
2993
2994 mem_descr = (struct be_mem_descriptor *)phba->init_mem;
2995 mem_descr += HWI_MEM_ASYNC_HEADER_RING_ULP0 +
2996 (ulp_num * MEM_DESCR_OFFSET);
2997 if (mem_descr->mem_array[0].virtual_address) {
2998 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
2999 "BM_%d : hwi_init_async_pdu_ctx"
3000 " HWI_MEM_ASYNC_HEADER_RING_ULP%d va=%p\n",
3001 ulp_num,
3002 mem_descr->mem_array[0].
3003 virtual_address);
3004 } else
3005 beiscsi_log(phba, KERN_WARNING,
3006 BEISCSI_LOG_INIT,
3007 "BM_%d : No Virtual address for ULP : %d\n",
3008 ulp_num);
3009
3010 pasync_ctx->async_header.ring_base =
3011 mem_descr->mem_array[0].virtual_address;
3012
3013 mem_descr = (struct be_mem_descriptor *)phba->init_mem;
3014 mem_descr += HWI_MEM_ASYNC_HEADER_HANDLE_ULP0 +
3015 (ulp_num * MEM_DESCR_OFFSET);
3016 if (mem_descr->mem_array[0].virtual_address) {
3017 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
3018 "BM_%d : hwi_init_async_pdu_ctx"
3019 " HWI_MEM_ASYNC_HEADER_HANDLE_ULP%d va=%p\n",
3020 ulp_num,
3021 mem_descr->mem_array[0].
3022 virtual_address);
3023 } else
3024 beiscsi_log(phba, KERN_WARNING,
3025 BEISCSI_LOG_INIT,
3026 "BM_%d : No Virtual address for ULP : %d\n",
3027 ulp_num);
3028
3029 pasync_ctx->async_header.handle_base =
3030 mem_descr->mem_array[0].virtual_address;
3031 pasync_ctx->async_header.writables = 0;
3032 INIT_LIST_HEAD(&pasync_ctx->async_header.free_list);
3033
3034 mem_descr = (struct be_mem_descriptor *)phba->init_mem;
3035 mem_descr += HWI_MEM_ASYNC_DATA_RING_ULP0 +
3036 (ulp_num * MEM_DESCR_OFFSET);
3037 if (mem_descr->mem_array[0].virtual_address) {
3038 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
3039 "BM_%d : hwi_init_async_pdu_ctx"
3040 " HWI_MEM_ASYNC_DATA_RING_ULP%d va=%p\n",
3041 ulp_num,
3042 mem_descr->mem_array[0].
3043 virtual_address);
3044 } else
3045 beiscsi_log(phba, KERN_WARNING,
3046 BEISCSI_LOG_INIT,
3047 "BM_%d : No Virtual address for ULP : %d\n",
3048 ulp_num);
3049
3050 pasync_ctx->async_data.ring_base =
3051 mem_descr->mem_array[0].virtual_address;
3052
3053 mem_descr = (struct be_mem_descriptor *)phba->init_mem;
3054 mem_descr += HWI_MEM_ASYNC_DATA_HANDLE_ULP0 +
3055 (ulp_num * MEM_DESCR_OFFSET);
3056 if (!mem_descr->mem_array[0].virtual_address)
3057 beiscsi_log(phba, KERN_WARNING,
3058 BEISCSI_LOG_INIT,
3059 "BM_%d : No Virtual address for ULP : %d\n",
3060 ulp_num);
3061
3062 pasync_ctx->async_data.handle_base =
3063 mem_descr->mem_array[0].virtual_address;
3064 pasync_ctx->async_data.writables = 0;
3065 INIT_LIST_HEAD(&pasync_ctx->async_data.free_list);
3066
3067 pasync_header_h =
3068 (struct async_pdu_handle *)
3069 pasync_ctx->async_header.handle_base;
3070 pasync_data_h =
3071 (struct async_pdu_handle *)
3072 pasync_ctx->async_data.handle_base;
3073
3074 mem_descr = (struct be_mem_descriptor *)phba->init_mem;
3075 mem_descr += HWI_MEM_ASYNC_DATA_BUF_ULP0 +
3076 (ulp_num * MEM_DESCR_OFFSET);
3077 if (mem_descr->mem_array[0].virtual_address) {
3078 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
3079 "BM_%d : hwi_init_async_pdu_ctx"
3080 " HWI_MEM_ASYNC_DATA_BUF_ULP%d va=%p\n",
3081 ulp_num,
3082 mem_descr->mem_array[0].
3083 virtual_address);
3084 } else
3085 beiscsi_log(phba, KERN_WARNING,
3086 BEISCSI_LOG_INIT,
3087 "BM_%d : No Virtual address for ULP : %d\n",
3088 ulp_num);
3089
3090 idx = 0;
3091 pasync_ctx->async_data.va_base =
3092 mem_descr->mem_array[idx].virtual_address;
3093 pasync_ctx->async_data.pa_base.u.a64.address =
3094 mem_descr->mem_array[idx].
3095 bus_address.u.a64.address;
3096
3097 num_async_data = ((mem_descr->mem_array[idx].size) /
3098 phba->params.defpdu_data_sz);
3099 num_per_mem = 0;
3100
3101 for (index = 0; index < BEISCSI_GET_CID_COUNT
3102 (phba, ulp_num); index++) {
3103 pasync_header_h->cri = -1;
3104 pasync_header_h->index = (char)index;
3105 INIT_LIST_HEAD(&pasync_header_h->link);
3106 pasync_header_h->pbuffer =
3107 (void *)((unsigned long)
3108 (pasync_ctx->
3109 async_header.va_base) +
3110 (p->defpdu_hdr_sz * index));
3111
3112 pasync_header_h->pa.u.a64.address =
3113 pasync_ctx->async_header.pa_base.u.a64.
3114 address + (p->defpdu_hdr_sz * index);
3115
3116 list_add_tail(&pasync_header_h->link,
3117 &pasync_ctx->async_header.
3118 free_list);
3119 pasync_header_h++;
3120 pasync_ctx->async_header.free_entries++;
3121 pasync_ctx->async_header.writables++;
3122
3123 INIT_LIST_HEAD(&pasync_ctx->async_entry[index].
3124 wait_queue.list);
3125 INIT_LIST_HEAD(&pasync_ctx->async_entry[index].
3126 header_busy_list);
3127 pasync_data_h->cri = -1;
3128 pasync_data_h->index = (char)index;
3129 INIT_LIST_HEAD(&pasync_data_h->link);
3130
3131 if (!num_async_data) {
3132 num_per_mem = 0;
3133 idx++;
3134 pasync_ctx->async_data.va_base =
3135 mem_descr->mem_array[idx].
3136 virtual_address;
3137 pasync_ctx->async_data.pa_base.u.
3138 a64.address =
3139 mem_descr->mem_array[idx].
3140 bus_address.u.a64.address;
3141 num_async_data =
3142 ((mem_descr->mem_array[idx].
3143 size) /
3144 phba->params.defpdu_data_sz);
3145 }
3146 pasync_data_h->pbuffer =
3147 (void *)((unsigned long)
3148 (pasync_ctx->async_data.va_base) +
3149 (p->defpdu_data_sz * num_per_mem));
3150
3151 pasync_data_h->pa.u.a64.address =
3152 pasync_ctx->async_data.pa_base.u.a64.
3153 address + (p->defpdu_data_sz *
3154 num_per_mem);
3155 num_per_mem++;
3156 num_async_data--;
3157
3158 list_add_tail(&pasync_data_h->link,
3159 &pasync_ctx->async_data.
3160 free_list);
3161 pasync_data_h++;
3162 pasync_ctx->async_data.free_entries++;
3163 pasync_ctx->async_data.writables++;
3164
3165 INIT_LIST_HEAD(&pasync_ctx->async_entry[index].
3166 data_busy_list);
3167 }
3168
3169 pasync_ctx->async_header.host_write_ptr = 0;
3170 pasync_ctx->async_header.ep_read_ptr = -1;
3171 pasync_ctx->async_data.host_write_ptr = 0;
3172 pasync_ctx->async_data.ep_read_ptr = -1;
3173 }
3174 }
3175
3176 return 0;
3177 }
3178
3179 static int
3180 be_sgl_create_contiguous(void *virtual_address,
3181 u64 physical_address, u32 length,
3182 struct be_dma_mem *sgl)
3183 {
3184 WARN_ON(!virtual_address);
3185 WARN_ON(!physical_address);
3186 WARN_ON(!length > 0);
3187 WARN_ON(!sgl);
3188
3189 sgl->va = virtual_address;
3190 sgl->dma = (unsigned long)physical_address;
3191 sgl->size = length;
3192
3193 return 0;
3194 }
3195
3196 static void be_sgl_destroy_contiguous(struct be_dma_mem *sgl)
3197 {
3198 memset(sgl, 0, sizeof(*sgl));
3199 }
3200
3201 static void
3202 hwi_build_be_sgl_arr(struct beiscsi_hba *phba,
3203 struct mem_array *pmem, struct be_dma_mem *sgl)
3204 {
3205 if (sgl->va)
3206 be_sgl_destroy_contiguous(sgl);
3207
3208 be_sgl_create_contiguous(pmem->virtual_address,
3209 pmem->bus_address.u.a64.address,
3210 pmem->size, sgl);
3211 }
3212
3213 static void
3214 hwi_build_be_sgl_by_offset(struct beiscsi_hba *phba,
3215 struct mem_array *pmem, struct be_dma_mem *sgl)
3216 {
3217 if (sgl->va)
3218 be_sgl_destroy_contiguous(sgl);
3219
3220 be_sgl_create_contiguous((unsigned char *)pmem->virtual_address,
3221 pmem->bus_address.u.a64.address,
3222 pmem->size, sgl);
3223 }
3224
3225 static int be_fill_queue(struct be_queue_info *q,
3226 u16 len, u16 entry_size, void *vaddress)
3227 {
3228 struct be_dma_mem *mem = &q->dma_mem;
3229
3230 memset(q, 0, sizeof(*q));
3231 q->len = len;
3232 q->entry_size = entry_size;
3233 mem->size = len * entry_size;
3234 mem->va = vaddress;
3235 if (!mem->va)
3236 return -ENOMEM;
3237 memset(mem->va, 0, mem->size);
3238 return 0;
3239 }
3240
3241 static int beiscsi_create_eqs(struct beiscsi_hba *phba,
3242 struct hwi_context_memory *phwi_context)
3243 {
3244 unsigned int i, num_eq_pages;
3245 int ret = 0, eq_for_mcc;
3246 struct be_queue_info *eq;
3247 struct be_dma_mem *mem;
3248 void *eq_vaddress;
3249 dma_addr_t paddr;
3250
3251 num_eq_pages = PAGES_REQUIRED(phba->params.num_eq_entries * \
3252 sizeof(struct be_eq_entry));
3253
3254 if (phba->msix_enabled)
3255 eq_for_mcc = 1;
3256 else
3257 eq_for_mcc = 0;
3258 for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) {
3259 eq = &phwi_context->be_eq[i].q;
3260 mem = &eq->dma_mem;
3261 phwi_context->be_eq[i].phba = phba;
3262 eq_vaddress = pci_alloc_consistent(phba->pcidev,
3263 num_eq_pages * PAGE_SIZE,
3264 &paddr);
3265 if (!eq_vaddress)
3266 goto create_eq_error;
3267
3268 mem->va = eq_vaddress;
3269 ret = be_fill_queue(eq, phba->params.num_eq_entries,
3270 sizeof(struct be_eq_entry), eq_vaddress);
3271 if (ret) {
3272 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3273 "BM_%d : be_fill_queue Failed for EQ\n");
3274 goto create_eq_error;
3275 }
3276
3277 mem->dma = paddr;
3278 ret = beiscsi_cmd_eq_create(&phba->ctrl, eq,
3279 phwi_context->cur_eqd);
3280 if (ret) {
3281 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3282 "BM_%d : beiscsi_cmd_eq_create"
3283 "Failed for EQ\n");
3284 goto create_eq_error;
3285 }
3286
3287 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
3288 "BM_%d : eqid = %d\n",
3289 phwi_context->be_eq[i].q.id);
3290 }
3291 return 0;
3292 create_eq_error:
3293 for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) {
3294 eq = &phwi_context->be_eq[i].q;
3295 mem = &eq->dma_mem;
3296 if (mem->va)
3297 pci_free_consistent(phba->pcidev, num_eq_pages
3298 * PAGE_SIZE,
3299 mem->va, mem->dma);
3300 }
3301 return ret;
3302 }
3303
3304 static int beiscsi_create_cqs(struct beiscsi_hba *phba,
3305 struct hwi_context_memory *phwi_context)
3306 {
3307 unsigned int i, num_cq_pages;
3308 int ret = 0;
3309 struct be_queue_info *cq, *eq;
3310 struct be_dma_mem *mem;
3311 struct be_eq_obj *pbe_eq;
3312 void *cq_vaddress;
3313 dma_addr_t paddr;
3314
3315 num_cq_pages = PAGES_REQUIRED(phba->params.num_cq_entries * \
3316 sizeof(struct sol_cqe));
3317
3318 for (i = 0; i < phba->num_cpus; i++) {
3319 cq = &phwi_context->be_cq[i];
3320 eq = &phwi_context->be_eq[i].q;
3321 pbe_eq = &phwi_context->be_eq[i];
3322 pbe_eq->cq = cq;
3323 pbe_eq->phba = phba;
3324 mem = &cq->dma_mem;
3325 cq_vaddress = pci_alloc_consistent(phba->pcidev,
3326 num_cq_pages * PAGE_SIZE,
3327 &paddr);
3328 if (!cq_vaddress)
3329 goto create_cq_error;
3330 ret = be_fill_queue(cq, phba->params.num_cq_entries,
3331 sizeof(struct sol_cqe), cq_vaddress);
3332 if (ret) {
3333 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3334 "BM_%d : be_fill_queue Failed "
3335 "for ISCSI CQ\n");
3336 goto create_cq_error;
3337 }
3338
3339 mem->dma = paddr;
3340 ret = beiscsi_cmd_cq_create(&phba->ctrl, cq, eq, false,
3341 false, 0);
3342 if (ret) {
3343 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3344 "BM_%d : beiscsi_cmd_eq_create"
3345 "Failed for ISCSI CQ\n");
3346 goto create_cq_error;
3347 }
3348 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
3349 "BM_%d : iscsi cq_id is %d for eq_id %d\n"
3350 "iSCSI CQ CREATED\n", cq->id, eq->id);
3351 }
3352 return 0;
3353
3354 create_cq_error:
3355 for (i = 0; i < phba->num_cpus; i++) {
3356 cq = &phwi_context->be_cq[i];
3357 mem = &cq->dma_mem;
3358 if (mem->va)
3359 pci_free_consistent(phba->pcidev, num_cq_pages
3360 * PAGE_SIZE,
3361 mem->va, mem->dma);
3362 }
3363 return ret;
3364
3365 }
3366
3367 static int
3368 beiscsi_create_def_hdr(struct beiscsi_hba *phba,
3369 struct hwi_context_memory *phwi_context,
3370 struct hwi_controller *phwi_ctrlr,
3371 unsigned int def_pdu_ring_sz, uint8_t ulp_num)
3372 {
3373 unsigned int idx;
3374 int ret;
3375 struct be_queue_info *dq, *cq;
3376 struct be_dma_mem *mem;
3377 struct be_mem_descriptor *mem_descr;
3378 void *dq_vaddress;
3379
3380 idx = 0;
3381 dq = &phwi_context->be_def_hdrq[ulp_num];
3382 cq = &phwi_context->be_cq[0];
3383 mem = &dq->dma_mem;
3384 mem_descr = phba->init_mem;
3385 mem_descr += HWI_MEM_ASYNC_HEADER_RING_ULP0 +
3386 (ulp_num * MEM_DESCR_OFFSET);
3387 dq_vaddress = mem_descr->mem_array[idx].virtual_address;
3388 ret = be_fill_queue(dq, mem_descr->mem_array[0].size /
3389 sizeof(struct phys_addr),
3390 sizeof(struct phys_addr), dq_vaddress);
3391 if (ret) {
3392 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3393 "BM_%d : be_fill_queue Failed for DEF PDU HDR on ULP : %d\n",
3394 ulp_num);
3395
3396 return ret;
3397 }
3398 mem->dma = (unsigned long)mem_descr->mem_array[idx].
3399 bus_address.u.a64.address;
3400 ret = be_cmd_create_default_pdu_queue(&phba->ctrl, cq, dq,
3401 def_pdu_ring_sz,
3402 phba->params.defpdu_hdr_sz,
3403 BEISCSI_DEFQ_HDR, ulp_num);
3404 if (ret) {
3405 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3406 "BM_%d : be_cmd_create_default_pdu_queue Failed DEFHDR on ULP : %d\n",
3407 ulp_num);
3408
3409 return ret;
3410 }
3411
3412 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
3413 "BM_%d : iscsi hdr def pdu id for ULP : %d is %d\n",
3414 ulp_num,
3415 phwi_context->be_def_hdrq[ulp_num].id);
3416 hwi_post_async_buffers(phba, BEISCSI_DEFQ_HDR, ulp_num);
3417 return 0;
3418 }
3419
3420 static int
3421 beiscsi_create_def_data(struct beiscsi_hba *phba,
3422 struct hwi_context_memory *phwi_context,
3423 struct hwi_controller *phwi_ctrlr,
3424 unsigned int def_pdu_ring_sz, uint8_t ulp_num)
3425 {
3426 unsigned int idx;
3427 int ret;
3428 struct be_queue_info *dataq, *cq;
3429 struct be_dma_mem *mem;
3430 struct be_mem_descriptor *mem_descr;
3431 void *dq_vaddress;
3432
3433 idx = 0;
3434 dataq = &phwi_context->be_def_dataq[ulp_num];
3435 cq = &phwi_context->be_cq[0];
3436 mem = &dataq->dma_mem;
3437 mem_descr = phba->init_mem;
3438 mem_descr += HWI_MEM_ASYNC_DATA_RING_ULP0 +
3439 (ulp_num * MEM_DESCR_OFFSET);
3440 dq_vaddress = mem_descr->mem_array[idx].virtual_address;
3441 ret = be_fill_queue(dataq, mem_descr->mem_array[0].size /
3442 sizeof(struct phys_addr),
3443 sizeof(struct phys_addr), dq_vaddress);
3444 if (ret) {
3445 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3446 "BM_%d : be_fill_queue Failed for DEF PDU "
3447 "DATA on ULP : %d\n",
3448 ulp_num);
3449
3450 return ret;
3451 }
3452 mem->dma = (unsigned long)mem_descr->mem_array[idx].
3453 bus_address.u.a64.address;
3454 ret = be_cmd_create_default_pdu_queue(&phba->ctrl, cq, dataq,
3455 def_pdu_ring_sz,
3456 phba->params.defpdu_data_sz,
3457 BEISCSI_DEFQ_DATA, ulp_num);
3458 if (ret) {
3459 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3460 "BM_%d be_cmd_create_default_pdu_queue"
3461 " Failed for DEF PDU DATA on ULP : %d\n",
3462 ulp_num);
3463 return ret;
3464 }
3465
3466 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
3467 "BM_%d : iscsi def data id on ULP : %d is %d\n",
3468 ulp_num,
3469 phwi_context->be_def_dataq[ulp_num].id);
3470
3471 hwi_post_async_buffers(phba, BEISCSI_DEFQ_DATA, ulp_num);
3472 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
3473 "BM_%d : DEFAULT PDU DATA RING CREATED"
3474 "on ULP : %d\n", ulp_num);
3475
3476 return 0;
3477 }
3478
3479
3480 static int
3481 beiscsi_post_template_hdr(struct beiscsi_hba *phba)
3482 {
3483 struct be_mem_descriptor *mem_descr;
3484 struct mem_array *pm_arr;
3485 struct be_dma_mem sgl;
3486 int status, ulp_num;
3487
3488 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
3489 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) {
3490 mem_descr = (struct be_mem_descriptor *)phba->init_mem;
3491 mem_descr += HWI_MEM_TEMPLATE_HDR_ULP0 +
3492 (ulp_num * MEM_DESCR_OFFSET);
3493 pm_arr = mem_descr->mem_array;
3494
3495 hwi_build_be_sgl_arr(phba, pm_arr, &sgl);
3496 status = be_cmd_iscsi_post_template_hdr(
3497 &phba->ctrl, &sgl);
3498
3499 if (status != 0) {
3500 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3501 "BM_%d : Post Template HDR Failed for"
3502 "ULP_%d\n", ulp_num);
3503 return status;
3504 }
3505
3506 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
3507 "BM_%d : Template HDR Pages Posted for"
3508 "ULP_%d\n", ulp_num);
3509 }
3510 }
3511 return 0;
3512 }
3513
3514 static int
3515 beiscsi_post_pages(struct beiscsi_hba *phba)
3516 {
3517 struct be_mem_descriptor *mem_descr;
3518 struct mem_array *pm_arr;
3519 unsigned int page_offset, i;
3520 struct be_dma_mem sgl;
3521 int status, ulp_num = 0;
3522
3523 mem_descr = phba->init_mem;
3524 mem_descr += HWI_MEM_SGE;
3525 pm_arr = mem_descr->mem_array;
3526
3527 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++)
3528 if (test_bit(ulp_num, &phba->fw_config.ulp_supported))
3529 break;
3530
3531 page_offset = (sizeof(struct iscsi_sge) * phba->params.num_sge_per_io *
3532 phba->fw_config.iscsi_icd_start[ulp_num]) / PAGE_SIZE;
3533 for (i = 0; i < mem_descr->num_elements; i++) {
3534 hwi_build_be_sgl_arr(phba, pm_arr, &sgl);
3535 status = be_cmd_iscsi_post_sgl_pages(&phba->ctrl, &sgl,
3536 page_offset,
3537 (pm_arr->size / PAGE_SIZE));
3538 page_offset += pm_arr->size / PAGE_SIZE;
3539 if (status != 0) {
3540 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3541 "BM_%d : post sgl failed.\n");
3542 return status;
3543 }
3544 pm_arr++;
3545 }
3546 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
3547 "BM_%d : POSTED PAGES\n");
3548 return 0;
3549 }
3550
3551 static void be_queue_free(struct beiscsi_hba *phba, struct be_queue_info *q)
3552 {
3553 struct be_dma_mem *mem = &q->dma_mem;
3554 if (mem->va) {
3555 pci_free_consistent(phba->pcidev, mem->size,
3556 mem->va, mem->dma);
3557 mem->va = NULL;
3558 }
3559 }
3560
3561 static int be_queue_alloc(struct beiscsi_hba *phba, struct be_queue_info *q,
3562 u16 len, u16 entry_size)
3563 {
3564 struct be_dma_mem *mem = &q->dma_mem;
3565
3566 memset(q, 0, sizeof(*q));
3567 q->len = len;
3568 q->entry_size = entry_size;
3569 mem->size = len * entry_size;
3570 mem->va = pci_alloc_consistent(phba->pcidev, mem->size, &mem->dma);
3571 if (!mem->va)
3572 return -ENOMEM;
3573 memset(mem->va, 0, mem->size);
3574 return 0;
3575 }
3576
3577 static int
3578 beiscsi_create_wrb_rings(struct beiscsi_hba *phba,
3579 struct hwi_context_memory *phwi_context,
3580 struct hwi_controller *phwi_ctrlr)
3581 {
3582 unsigned int wrb_mem_index, offset, size, num_wrb_rings;
3583 u64 pa_addr_lo;
3584 unsigned int idx, num, i, ulp_num;
3585 struct mem_array *pwrb_arr;
3586 void *wrb_vaddr;
3587 struct be_dma_mem sgl;
3588 struct be_mem_descriptor *mem_descr;
3589 struct hwi_wrb_context *pwrb_context;
3590 int status;
3591 uint8_t ulp_count = 0, ulp_base_num = 0;
3592 uint16_t cid_count_ulp[BEISCSI_ULP_COUNT] = { 0 };
3593
3594 idx = 0;
3595 mem_descr = phba->init_mem;
3596 mem_descr += HWI_MEM_WRB;
3597 pwrb_arr = kmalloc(sizeof(*pwrb_arr) * phba->params.cxns_per_ctrl,
3598 GFP_KERNEL);
3599 if (!pwrb_arr) {
3600 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3601 "BM_%d : Memory alloc failed in create wrb ring.\n");
3602 return -ENOMEM;
3603 }
3604 wrb_vaddr = mem_descr->mem_array[idx].virtual_address;
3605 pa_addr_lo = mem_descr->mem_array[idx].bus_address.u.a64.address;
3606 num_wrb_rings = mem_descr->mem_array[idx].size /
3607 (phba->params.wrbs_per_cxn * sizeof(struct iscsi_wrb));
3608
3609 for (num = 0; num < phba->params.cxns_per_ctrl; num++) {
3610 if (num_wrb_rings) {
3611 pwrb_arr[num].virtual_address = wrb_vaddr;
3612 pwrb_arr[num].bus_address.u.a64.address = pa_addr_lo;
3613 pwrb_arr[num].size = phba->params.wrbs_per_cxn *
3614 sizeof(struct iscsi_wrb);
3615 wrb_vaddr += pwrb_arr[num].size;
3616 pa_addr_lo += pwrb_arr[num].size;
3617 num_wrb_rings--;
3618 } else {
3619 idx++;
3620 wrb_vaddr = mem_descr->mem_array[idx].virtual_address;
3621 pa_addr_lo = mem_descr->mem_array[idx].\
3622 bus_address.u.a64.address;
3623 num_wrb_rings = mem_descr->mem_array[idx].size /
3624 (phba->params.wrbs_per_cxn *
3625 sizeof(struct iscsi_wrb));
3626 pwrb_arr[num].virtual_address = wrb_vaddr;
3627 pwrb_arr[num].bus_address.u.a64.address\
3628 = pa_addr_lo;
3629 pwrb_arr[num].size = phba->params.wrbs_per_cxn *
3630 sizeof(struct iscsi_wrb);
3631 wrb_vaddr += pwrb_arr[num].size;
3632 pa_addr_lo += pwrb_arr[num].size;
3633 num_wrb_rings--;
3634 }
3635 }
3636
3637 /* Get the ULP Count */
3638 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++)
3639 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) {
3640 ulp_count++;
3641 ulp_base_num = ulp_num;
3642 cid_count_ulp[ulp_num] =
3643 BEISCSI_GET_CID_COUNT(phba, ulp_num);
3644 }
3645
3646 for (i = 0; i < phba->params.cxns_per_ctrl; i++) {
3647 wrb_mem_index = 0;
3648 offset = 0;
3649 size = 0;
3650
3651 if (ulp_count > 1) {
3652 ulp_base_num = (ulp_base_num + 1) % BEISCSI_ULP_COUNT;
3653
3654 if (!cid_count_ulp[ulp_base_num])
3655 ulp_base_num = (ulp_base_num + 1) %
3656 BEISCSI_ULP_COUNT;
3657
3658 cid_count_ulp[ulp_base_num]--;
3659 }
3660
3661
3662 hwi_build_be_sgl_by_offset(phba, &pwrb_arr[i], &sgl);
3663 status = be_cmd_wrbq_create(&phba->ctrl, &sgl,
3664 &phwi_context->be_wrbq[i],
3665 &phwi_ctrlr->wrb_context[i],
3666 ulp_base_num);
3667 if (status != 0) {
3668 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3669 "BM_%d : wrbq create failed.");
3670 kfree(pwrb_arr);
3671 return status;
3672 }
3673 pwrb_context = &phwi_ctrlr->wrb_context[i];
3674 BE_SET_CID_TO_CRI(i, pwrb_context->cid);
3675 }
3676 kfree(pwrb_arr);
3677 return 0;
3678 }
3679
3680 static void free_wrb_handles(struct beiscsi_hba *phba)
3681 {
3682 unsigned int index;
3683 struct hwi_controller *phwi_ctrlr;
3684 struct hwi_wrb_context *pwrb_context;
3685
3686 phwi_ctrlr = phba->phwi_ctrlr;
3687 for (index = 0; index < phba->params.cxns_per_ctrl; index++) {
3688 pwrb_context = &phwi_ctrlr->wrb_context[index];
3689 kfree(pwrb_context->pwrb_handle_base);
3690 kfree(pwrb_context->pwrb_handle_basestd);
3691 }
3692 }
3693
3694 static void be_mcc_queues_destroy(struct beiscsi_hba *phba)
3695 {
3696 struct be_queue_info *q;
3697 struct be_ctrl_info *ctrl = &phba->ctrl;
3698
3699 q = &phba->ctrl.mcc_obj.q;
3700 if (q->created)
3701 beiscsi_cmd_q_destroy(ctrl, q, QTYPE_MCCQ);
3702 be_queue_free(phba, q);
3703
3704 q = &phba->ctrl.mcc_obj.cq;
3705 if (q->created)
3706 beiscsi_cmd_q_destroy(ctrl, q, QTYPE_CQ);
3707 be_queue_free(phba, q);
3708 }
3709
3710 static void hwi_cleanup(struct beiscsi_hba *phba)
3711 {
3712 struct be_queue_info *q;
3713 struct be_ctrl_info *ctrl = &phba->ctrl;
3714 struct hwi_controller *phwi_ctrlr;
3715 struct hwi_context_memory *phwi_context;
3716 struct hwi_async_pdu_context *pasync_ctx;
3717 int i, eq_num, ulp_num;
3718
3719 phwi_ctrlr = phba->phwi_ctrlr;
3720 phwi_context = phwi_ctrlr->phwi_ctxt;
3721
3722 be_cmd_iscsi_remove_template_hdr(ctrl);
3723
3724 for (i = 0; i < phba->params.cxns_per_ctrl; i++) {
3725 q = &phwi_context->be_wrbq[i];
3726 if (q->created)
3727 beiscsi_cmd_q_destroy(ctrl, q, QTYPE_WRBQ);
3728 }
3729 kfree(phwi_context->be_wrbq);
3730 free_wrb_handles(phba);
3731
3732 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
3733 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) {
3734
3735 q = &phwi_context->be_def_hdrq[ulp_num];
3736 if (q->created)
3737 beiscsi_cmd_q_destroy(ctrl, q, QTYPE_DPDUQ);
3738
3739 q = &phwi_context->be_def_dataq[ulp_num];
3740 if (q->created)
3741 beiscsi_cmd_q_destroy(ctrl, q, QTYPE_DPDUQ);
3742
3743 pasync_ctx = phwi_ctrlr->phwi_ctxt->pasync_ctx[ulp_num];
3744 }
3745 }
3746
3747 beiscsi_cmd_q_destroy(ctrl, NULL, QTYPE_SGL);
3748
3749 for (i = 0; i < (phba->num_cpus); i++) {
3750 q = &phwi_context->be_cq[i];
3751 if (q->created)
3752 beiscsi_cmd_q_destroy(ctrl, q, QTYPE_CQ);
3753 }
3754 if (phba->msix_enabled)
3755 eq_num = 1;
3756 else
3757 eq_num = 0;
3758 for (i = 0; i < (phba->num_cpus + eq_num); i++) {
3759 q = &phwi_context->be_eq[i].q;
3760 if (q->created)
3761 beiscsi_cmd_q_destroy(ctrl, q, QTYPE_EQ);
3762 }
3763 be_mcc_queues_destroy(phba);
3764 be_cmd_fw_uninit(ctrl);
3765 }
3766
3767 static int be_mcc_queues_create(struct beiscsi_hba *phba,
3768 struct hwi_context_memory *phwi_context)
3769 {
3770 struct be_queue_info *q, *cq;
3771 struct be_ctrl_info *ctrl = &phba->ctrl;
3772
3773 /* Alloc MCC compl queue */
3774 cq = &phba->ctrl.mcc_obj.cq;
3775 if (be_queue_alloc(phba, cq, MCC_CQ_LEN,
3776 sizeof(struct be_mcc_compl)))
3777 goto err;
3778 /* Ask BE to create MCC compl queue; */
3779 if (phba->msix_enabled) {
3780 if (beiscsi_cmd_cq_create(ctrl, cq, &phwi_context->be_eq
3781 [phba->num_cpus].q, false, true, 0))
3782 goto mcc_cq_free;
3783 } else {
3784 if (beiscsi_cmd_cq_create(ctrl, cq, &phwi_context->be_eq[0].q,
3785 false, true, 0))
3786 goto mcc_cq_free;
3787 }
3788
3789 /* Alloc MCC queue */
3790 q = &phba->ctrl.mcc_obj.q;
3791 if (be_queue_alloc(phba, q, MCC_Q_LEN, sizeof(struct be_mcc_wrb)))
3792 goto mcc_cq_destroy;
3793
3794 /* Ask BE to create MCC queue */
3795 if (beiscsi_cmd_mccq_create(phba, q, cq))
3796 goto mcc_q_free;
3797
3798 return 0;
3799
3800 mcc_q_free:
3801 be_queue_free(phba, q);
3802 mcc_cq_destroy:
3803 beiscsi_cmd_q_destroy(ctrl, cq, QTYPE_CQ);
3804 mcc_cq_free:
3805 be_queue_free(phba, cq);
3806 err:
3807 return -ENOMEM;
3808 }
3809
3810 /**
3811 * find_num_cpus()- Get the CPU online count
3812 * @phba: ptr to priv structure
3813 *
3814 * CPU count is used for creating EQ.
3815 **/
3816 static void find_num_cpus(struct beiscsi_hba *phba)
3817 {
3818 int num_cpus = 0;
3819
3820 num_cpus = num_online_cpus();
3821
3822 switch (phba->generation) {
3823 case BE_GEN2:
3824 case BE_GEN3:
3825 phba->num_cpus = (num_cpus > BEISCSI_MAX_NUM_CPUS) ?
3826 BEISCSI_MAX_NUM_CPUS : num_cpus;
3827 break;
3828 case BE_GEN4:
3829 /*
3830 * If eqid_count == 1 fall back to
3831 * INTX mechanism
3832 **/
3833 if (phba->fw_config.eqid_count == 1) {
3834 enable_msix = 0;
3835 phba->num_cpus = 1;
3836 return;
3837 }
3838
3839 phba->num_cpus =
3840 (num_cpus > (phba->fw_config.eqid_count - 1)) ?
3841 (phba->fw_config.eqid_count - 1) : num_cpus;
3842 break;
3843 default:
3844 phba->num_cpus = 1;
3845 }
3846 }
3847
3848 static int hwi_init_port(struct beiscsi_hba *phba)
3849 {
3850 struct hwi_controller *phwi_ctrlr;
3851 struct hwi_context_memory *phwi_context;
3852 unsigned int def_pdu_ring_sz;
3853 struct be_ctrl_info *ctrl = &phba->ctrl;
3854 int status, ulp_num;
3855
3856 phwi_ctrlr = phba->phwi_ctrlr;
3857 phwi_context = phwi_ctrlr->phwi_ctxt;
3858 phwi_context->max_eqd = 0;
3859 phwi_context->min_eqd = 0;
3860 phwi_context->cur_eqd = 64;
3861 be_cmd_fw_initialize(&phba->ctrl);
3862
3863 status = beiscsi_create_eqs(phba, phwi_context);
3864 if (status != 0) {
3865 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3866 "BM_%d : EQ not created\n");
3867 goto error;
3868 }
3869
3870 status = be_mcc_queues_create(phba, phwi_context);
3871 if (status != 0)
3872 goto error;
3873
3874 status = mgmt_check_supported_fw(ctrl, phba);
3875 if (status != 0) {
3876 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3877 "BM_%d : Unsupported fw version\n");
3878 goto error;
3879 }
3880
3881 status = beiscsi_create_cqs(phba, phwi_context);
3882 if (status != 0) {
3883 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3884 "BM_%d : CQ not created\n");
3885 goto error;
3886 }
3887
3888 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
3889 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) {
3890
3891 def_pdu_ring_sz =
3892 BEISCSI_GET_CID_COUNT(phba, ulp_num) *
3893 sizeof(struct phys_addr);
3894
3895 status = beiscsi_create_def_hdr(phba, phwi_context,
3896 phwi_ctrlr,
3897 def_pdu_ring_sz,
3898 ulp_num);
3899 if (status != 0) {
3900 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3901 "BM_%d : Default Header not created for ULP : %d\n",
3902 ulp_num);
3903 goto error;
3904 }
3905
3906 status = beiscsi_create_def_data(phba, phwi_context,
3907 phwi_ctrlr,
3908 def_pdu_ring_sz,
3909 ulp_num);
3910 if (status != 0) {
3911 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3912 "BM_%d : Default Data not created for ULP : %d\n",
3913 ulp_num);
3914 goto error;
3915 }
3916 }
3917 }
3918
3919 status = beiscsi_post_pages(phba);
3920 if (status != 0) {
3921 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3922 "BM_%d : Post SGL Pages Failed\n");
3923 goto error;
3924 }
3925
3926 status = beiscsi_post_template_hdr(phba);
3927 if (status != 0) {
3928 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3929 "BM_%d : Template HDR Posting for CXN Failed\n");
3930 }
3931
3932 status = beiscsi_create_wrb_rings(phba, phwi_context, phwi_ctrlr);
3933 if (status != 0) {
3934 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3935 "BM_%d : WRB Rings not created\n");
3936 goto error;
3937 }
3938
3939 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
3940 uint16_t async_arr_idx = 0;
3941
3942 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) {
3943 uint16_t cri = 0;
3944 struct hwi_async_pdu_context *pasync_ctx;
3945
3946 pasync_ctx = HWI_GET_ASYNC_PDU_CTX(
3947 phwi_ctrlr, ulp_num);
3948 for (cri = 0; cri <
3949 phba->params.cxns_per_ctrl; cri++) {
3950 if (ulp_num == BEISCSI_GET_ULP_FROM_CRI
3951 (phwi_ctrlr, cri))
3952 pasync_ctx->cid_to_async_cri_map[
3953 phwi_ctrlr->wrb_context[cri].cid] =
3954 async_arr_idx++;
3955 }
3956 }
3957 }
3958
3959 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
3960 "BM_%d : hwi_init_port success\n");
3961 return 0;
3962
3963 error:
3964 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3965 "BM_%d : hwi_init_port failed");
3966 hwi_cleanup(phba);
3967 return status;
3968 }
3969
3970 static int hwi_init_controller(struct beiscsi_hba *phba)
3971 {
3972 struct hwi_controller *phwi_ctrlr;
3973
3974 phwi_ctrlr = phba->phwi_ctrlr;
3975 if (1 == phba->init_mem[HWI_MEM_ADDN_CONTEXT].num_elements) {
3976 phwi_ctrlr->phwi_ctxt = (struct hwi_context_memory *)phba->
3977 init_mem[HWI_MEM_ADDN_CONTEXT].mem_array[0].virtual_address;
3978 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
3979 "BM_%d : phwi_ctrlr->phwi_ctxt=%p\n",
3980 phwi_ctrlr->phwi_ctxt);
3981 } else {
3982 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3983 "BM_%d : HWI_MEM_ADDN_CONTEXT is more "
3984 "than one element.Failing to load\n");
3985 return -ENOMEM;
3986 }
3987
3988 iscsi_init_global_templates(phba);
3989 if (beiscsi_init_wrb_handle(phba))
3990 return -ENOMEM;
3991
3992 if (hwi_init_async_pdu_ctx(phba)) {
3993 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
3994 "BM_%d : hwi_init_async_pdu_ctx failed\n");
3995 return -ENOMEM;
3996 }
3997
3998 if (hwi_init_port(phba) != 0) {
3999 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
4000 "BM_%d : hwi_init_controller failed\n");
4001
4002 return -ENOMEM;
4003 }
4004 return 0;
4005 }
4006
4007 static void beiscsi_free_mem(struct beiscsi_hba *phba)
4008 {
4009 struct be_mem_descriptor *mem_descr;
4010 int i, j;
4011
4012 mem_descr = phba->init_mem;
4013 i = 0;
4014 j = 0;
4015 for (i = 0; i < SE_MEM_MAX; i++) {
4016 for (j = mem_descr->num_elements; j > 0; j--) {
4017 pci_free_consistent(phba->pcidev,
4018 mem_descr->mem_array[j - 1].size,
4019 mem_descr->mem_array[j - 1].virtual_address,
4020 (unsigned long)mem_descr->mem_array[j - 1].
4021 bus_address.u.a64.address);
4022 }
4023
4024 kfree(mem_descr->mem_array);
4025 mem_descr++;
4026 }
4027 kfree(phba->init_mem);
4028 kfree(phba->phwi_ctrlr->wrb_context);
4029 kfree(phba->phwi_ctrlr);
4030 }
4031
4032 static int beiscsi_init_controller(struct beiscsi_hba *phba)
4033 {
4034 int ret = -ENOMEM;
4035
4036 ret = beiscsi_get_memory(phba);
4037 if (ret < 0) {
4038 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
4039 "BM_%d : beiscsi_dev_probe -"
4040 "Failed in beiscsi_alloc_memory\n");
4041 return ret;
4042 }
4043
4044 ret = hwi_init_controller(phba);
4045 if (ret)
4046 goto free_init;
4047 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
4048 "BM_%d : Return success from beiscsi_init_controller");
4049
4050 return 0;
4051
4052 free_init:
4053 beiscsi_free_mem(phba);
4054 return ret;
4055 }
4056
4057 static int beiscsi_init_sgl_handle(struct beiscsi_hba *phba)
4058 {
4059 struct be_mem_descriptor *mem_descr_sglh, *mem_descr_sg;
4060 struct sgl_handle *psgl_handle;
4061 struct iscsi_sge *pfrag;
4062 unsigned int arr_index, i, idx;
4063 unsigned int ulp_icd_start, ulp_num = 0;
4064
4065 phba->io_sgl_hndl_avbl = 0;
4066 phba->eh_sgl_hndl_avbl = 0;
4067
4068 mem_descr_sglh = phba->init_mem;
4069 mem_descr_sglh += HWI_MEM_SGLH;
4070 if (1 == mem_descr_sglh->num_elements) {
4071 phba->io_sgl_hndl_base = kzalloc(sizeof(struct sgl_handle *) *
4072 phba->params.ios_per_ctrl,
4073 GFP_KERNEL);
4074 if (!phba->io_sgl_hndl_base) {
4075 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
4076 "BM_%d : Mem Alloc Failed. Failing to load\n");
4077 return -ENOMEM;
4078 }
4079 phba->eh_sgl_hndl_base = kzalloc(sizeof(struct sgl_handle *) *
4080 (phba->params.icds_per_ctrl -
4081 phba->params.ios_per_ctrl),
4082 GFP_KERNEL);
4083 if (!phba->eh_sgl_hndl_base) {
4084 kfree(phba->io_sgl_hndl_base);
4085 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
4086 "BM_%d : Mem Alloc Failed. Failing to load\n");
4087 return -ENOMEM;
4088 }
4089 } else {
4090 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
4091 "BM_%d : HWI_MEM_SGLH is more than one element."
4092 "Failing to load\n");
4093 return -ENOMEM;
4094 }
4095
4096 arr_index = 0;
4097 idx = 0;
4098 while (idx < mem_descr_sglh->num_elements) {
4099 psgl_handle = mem_descr_sglh->mem_array[idx].virtual_address;
4100
4101 for (i = 0; i < (mem_descr_sglh->mem_array[idx].size /
4102 sizeof(struct sgl_handle)); i++) {
4103 if (arr_index < phba->params.ios_per_ctrl) {
4104 phba->io_sgl_hndl_base[arr_index] = psgl_handle;
4105 phba->io_sgl_hndl_avbl++;
4106 arr_index++;
4107 } else {
4108 phba->eh_sgl_hndl_base[arr_index -
4109 phba->params.ios_per_ctrl] =
4110 psgl_handle;
4111 arr_index++;
4112 phba->eh_sgl_hndl_avbl++;
4113 }
4114 psgl_handle++;
4115 }
4116 idx++;
4117 }
4118 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
4119 "BM_%d : phba->io_sgl_hndl_avbl=%d"
4120 "phba->eh_sgl_hndl_avbl=%d\n",
4121 phba->io_sgl_hndl_avbl,
4122 phba->eh_sgl_hndl_avbl);
4123
4124 mem_descr_sg = phba->init_mem;
4125 mem_descr_sg += HWI_MEM_SGE;
4126 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
4127 "\n BM_%d : mem_descr_sg->num_elements=%d\n",
4128 mem_descr_sg->num_elements);
4129
4130 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++)
4131 if (test_bit(ulp_num, &phba->fw_config.ulp_supported))
4132 break;
4133
4134 ulp_icd_start = phba->fw_config.iscsi_icd_start[ulp_num];
4135
4136 arr_index = 0;
4137 idx = 0;
4138 while (idx < mem_descr_sg->num_elements) {
4139 pfrag = mem_descr_sg->mem_array[idx].virtual_address;
4140
4141 for (i = 0;
4142 i < (mem_descr_sg->mem_array[idx].size) /
4143 (sizeof(struct iscsi_sge) * phba->params.num_sge_per_io);
4144 i++) {
4145 if (arr_index < phba->params.ios_per_ctrl)
4146 psgl_handle = phba->io_sgl_hndl_base[arr_index];
4147 else
4148 psgl_handle = phba->eh_sgl_hndl_base[arr_index -
4149 phba->params.ios_per_ctrl];
4150 psgl_handle->pfrag = pfrag;
4151 AMAP_SET_BITS(struct amap_iscsi_sge, addr_hi, pfrag, 0);
4152 AMAP_SET_BITS(struct amap_iscsi_sge, addr_lo, pfrag, 0);
4153 pfrag += phba->params.num_sge_per_io;
4154 psgl_handle->sgl_index = ulp_icd_start + arr_index++;
4155 }
4156 idx++;
4157 }
4158 phba->io_sgl_free_index = 0;
4159 phba->io_sgl_alloc_index = 0;
4160 phba->eh_sgl_free_index = 0;
4161 phba->eh_sgl_alloc_index = 0;
4162 return 0;
4163 }
4164
4165 static int hba_setup_cid_tbls(struct beiscsi_hba *phba)
4166 {
4167 int ret;
4168 uint16_t i, ulp_num;
4169 struct ulp_cid_info *ptr_cid_info = NULL;
4170
4171 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
4172 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) {
4173 ptr_cid_info = kzalloc(sizeof(struct ulp_cid_info),
4174 GFP_KERNEL);
4175
4176 if (!ptr_cid_info) {
4177 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
4178 "BM_%d : Failed to allocate memory"
4179 "for ULP_CID_INFO for ULP : %d\n",
4180 ulp_num);
4181 ret = -ENOMEM;
4182 goto free_memory;
4183
4184 }
4185
4186 /* Allocate memory for CID array */
4187 ptr_cid_info->cid_array = kzalloc(sizeof(void *) *
4188 BEISCSI_GET_CID_COUNT(phba,
4189 ulp_num), GFP_KERNEL);
4190 if (!ptr_cid_info->cid_array) {
4191 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
4192 "BM_%d : Failed to allocate memory"
4193 "for CID_ARRAY for ULP : %d\n",
4194 ulp_num);
4195 kfree(ptr_cid_info);
4196 ptr_cid_info = NULL;
4197 ret = -ENOMEM;
4198
4199 goto free_memory;
4200 }
4201 ptr_cid_info->avlbl_cids = BEISCSI_GET_CID_COUNT(
4202 phba, ulp_num);
4203
4204 /* Save the cid_info_array ptr */
4205 phba->cid_array_info[ulp_num] = ptr_cid_info;
4206 }
4207 }
4208 phba->ep_array = kzalloc(sizeof(struct iscsi_endpoint *) *
4209 phba->params.cxns_per_ctrl, GFP_KERNEL);
4210 if (!phba->ep_array) {
4211 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
4212 "BM_%d : Failed to allocate memory in "
4213 "hba_setup_cid_tbls\n");
4214 ret = -ENOMEM;
4215
4216 goto free_memory;
4217 }
4218
4219 phba->conn_table = kzalloc(sizeof(struct beiscsi_conn *) *
4220 phba->params.cxns_per_ctrl, GFP_KERNEL);
4221 if (!phba->conn_table) {
4222 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
4223 "BM_%d : Failed to allocate memory in"
4224 "hba_setup_cid_tbls\n");
4225
4226 kfree(phba->ep_array);
4227 phba->ep_array = NULL;
4228 ret = -ENOMEM;
4229 }
4230
4231 for (i = 0; i < phba->params.cxns_per_ctrl; i++) {
4232 ulp_num = phba->phwi_ctrlr->wrb_context[i].ulp_num;
4233
4234 ptr_cid_info = phba->cid_array_info[ulp_num];
4235 ptr_cid_info->cid_array[ptr_cid_info->cid_alloc++] =
4236 phba->phwi_ctrlr->wrb_context[i].cid;
4237
4238 }
4239
4240 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
4241 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) {
4242 ptr_cid_info = phba->cid_array_info[ulp_num];
4243
4244 ptr_cid_info->cid_alloc = 0;
4245 ptr_cid_info->cid_free = 0;
4246 }
4247 }
4248 return 0;
4249
4250 free_memory:
4251 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
4252 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) {
4253 ptr_cid_info = phba->cid_array_info[ulp_num];
4254
4255 if (ptr_cid_info) {
4256 kfree(ptr_cid_info->cid_array);
4257 kfree(ptr_cid_info);
4258 phba->cid_array_info[ulp_num] = NULL;
4259 }
4260 }
4261 }
4262
4263 return ret;
4264 }
4265
4266 static void hwi_enable_intr(struct beiscsi_hba *phba)
4267 {
4268 struct be_ctrl_info *ctrl = &phba->ctrl;
4269 struct hwi_controller *phwi_ctrlr;
4270 struct hwi_context_memory *phwi_context;
4271 struct be_queue_info *eq;
4272 u8 __iomem *addr;
4273 u32 reg, i;
4274 u32 enabled;
4275
4276 phwi_ctrlr = phba->phwi_ctrlr;
4277 phwi_context = phwi_ctrlr->phwi_ctxt;
4278
4279 addr = (u8 __iomem *) ((u8 __iomem *) ctrl->pcicfg +
4280 PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET);
4281 reg = ioread32(addr);
4282
4283 enabled = reg & MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK;
4284 if (!enabled) {
4285 reg |= MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK;
4286 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
4287 "BM_%d : reg =x%08x addr=%p\n", reg, addr);
4288 iowrite32(reg, addr);
4289 }
4290
4291 if (!phba->msix_enabled) {
4292 eq = &phwi_context->be_eq[0].q;
4293 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
4294 "BM_%d : eq->id=%d\n", eq->id);
4295
4296 hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1);
4297 } else {
4298 for (i = 0; i <= phba->num_cpus; i++) {
4299 eq = &phwi_context->be_eq[i].q;
4300 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
4301 "BM_%d : eq->id=%d\n", eq->id);
4302 hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1);
4303 }
4304 }
4305 }
4306
4307 static void hwi_disable_intr(struct beiscsi_hba *phba)
4308 {
4309 struct be_ctrl_info *ctrl = &phba->ctrl;
4310
4311 u8 __iomem *addr = ctrl->pcicfg + PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET;
4312 u32 reg = ioread32(addr);
4313
4314 u32 enabled = reg & MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK;
4315 if (enabled) {
4316 reg &= ~MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK;
4317 iowrite32(reg, addr);
4318 } else
4319 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT,
4320 "BM_%d : In hwi_disable_intr, Already Disabled\n");
4321 }
4322
4323 /**
4324 * beiscsi_get_boot_info()- Get the boot session info
4325 * @phba: The device priv structure instance
4326 *
4327 * Get the boot target info and store in driver priv structure
4328 *
4329 * return values
4330 * Success: 0
4331 * Failure: Non-Zero Value
4332 **/
4333 static int beiscsi_get_boot_info(struct beiscsi_hba *phba)
4334 {
4335 struct be_cmd_get_session_resp *session_resp;
4336 struct be_dma_mem nonemb_cmd;
4337 unsigned int tag;
4338 unsigned int s_handle;
4339 int ret = -ENOMEM;
4340
4341 /* Get the session handle of the boot target */
4342 ret = be_mgmt_get_boot_shandle(phba, &s_handle);
4343 if (ret) {
4344 beiscsi_log(phba, KERN_ERR,
4345 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG,
4346 "BM_%d : No boot session\n");
4347 return ret;
4348 }
4349 nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev,
4350 sizeof(*session_resp),
4351 &nonemb_cmd.dma);
4352 if (nonemb_cmd.va == NULL) {
4353 beiscsi_log(phba, KERN_ERR,
4354 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG,
4355 "BM_%d : Failed to allocate memory for"
4356 "beiscsi_get_session_info\n");
4357
4358 return -ENOMEM;
4359 }
4360
4361 memset(nonemb_cmd.va, 0, sizeof(*session_resp));
4362 tag = mgmt_get_session_info(phba, s_handle,
4363 &nonemb_cmd);
4364 if (!tag) {
4365 beiscsi_log(phba, KERN_ERR,
4366 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG,
4367 "BM_%d : beiscsi_get_session_info"
4368 " Failed\n");
4369
4370 goto boot_freemem;
4371 }
4372
4373 ret = beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd.va);
4374 if (ret) {
4375 beiscsi_log(phba, KERN_ERR,
4376 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG,
4377 "BM_%d : beiscsi_get_session_info Failed");
4378 goto boot_freemem;
4379 }
4380
4381 session_resp = nonemb_cmd.va ;
4382
4383 memcpy(&phba->boot_sess, &session_resp->session_info,
4384 sizeof(struct mgmt_session_info));
4385 ret = 0;
4386
4387 boot_freemem:
4388 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
4389 nonemb_cmd.va, nonemb_cmd.dma);
4390 return ret;
4391 }
4392
4393 static void beiscsi_boot_release(void *data)
4394 {
4395 struct beiscsi_hba *phba = data;
4396
4397 scsi_host_put(phba->shost);
4398 }
4399
4400 static int beiscsi_setup_boot_info(struct beiscsi_hba *phba)
4401 {
4402 struct iscsi_boot_kobj *boot_kobj;
4403
4404 /* get boot info using mgmt cmd */
4405 if (beiscsi_get_boot_info(phba))
4406 /* Try to see if we can carry on without this */
4407 return 0;
4408
4409 phba->boot_kset = iscsi_boot_create_host_kset(phba->shost->host_no);
4410 if (!phba->boot_kset)
4411 return -ENOMEM;
4412
4413 /* get a ref because the show function will ref the phba */
4414 if (!scsi_host_get(phba->shost))
4415 goto free_kset;
4416 boot_kobj = iscsi_boot_create_target(phba->boot_kset, 0, phba,
4417 beiscsi_show_boot_tgt_info,
4418 beiscsi_tgt_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_initiator(phba->boot_kset, 0, phba,
4426 beiscsi_show_boot_ini_info,
4427 beiscsi_ini_get_attr_visibility,
4428 beiscsi_boot_release);
4429 if (!boot_kobj)
4430 goto put_shost;
4431
4432 if (!scsi_host_get(phba->shost))
4433 goto free_kset;
4434 boot_kobj = iscsi_boot_create_ethernet(phba->boot_kset, 0, phba,
4435 beiscsi_show_boot_eth_info,
4436 beiscsi_eth_get_attr_visibility,
4437 beiscsi_boot_release);
4438 if (!boot_kobj)
4439 goto put_shost;
4440 return 0;
4441
4442 put_shost:
4443 scsi_host_put(phba->shost);
4444 free_kset:
4445 iscsi_boot_destroy_kset(phba->boot_kset);
4446 return -ENOMEM;
4447 }
4448
4449 static int beiscsi_init_port(struct beiscsi_hba *phba)
4450 {
4451 int ret;
4452
4453 ret = beiscsi_init_controller(phba);
4454 if (ret < 0) {
4455 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
4456 "BM_%d : beiscsi_dev_probe - Failed in"
4457 "beiscsi_init_controller\n");
4458 return ret;
4459 }
4460 ret = beiscsi_init_sgl_handle(phba);
4461 if (ret < 0) {
4462 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
4463 "BM_%d : beiscsi_dev_probe - Failed in"
4464 "beiscsi_init_sgl_handle\n");
4465 goto do_cleanup_ctrlr;
4466 }
4467
4468 if (hba_setup_cid_tbls(phba)) {
4469 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
4470 "BM_%d : Failed in hba_setup_cid_tbls\n");
4471 kfree(phba->io_sgl_hndl_base);
4472 kfree(phba->eh_sgl_hndl_base);
4473 goto do_cleanup_ctrlr;
4474 }
4475
4476 return ret;
4477
4478 do_cleanup_ctrlr:
4479 hwi_cleanup(phba);
4480 return ret;
4481 }
4482
4483 static void hwi_purge_eq(struct beiscsi_hba *phba)
4484 {
4485 struct hwi_controller *phwi_ctrlr;
4486 struct hwi_context_memory *phwi_context;
4487 struct be_queue_info *eq;
4488 struct be_eq_entry *eqe = NULL;
4489 int i, eq_msix;
4490 unsigned int num_processed;
4491
4492 phwi_ctrlr = phba->phwi_ctrlr;
4493 phwi_context = phwi_ctrlr->phwi_ctxt;
4494 if (phba->msix_enabled)
4495 eq_msix = 1;
4496 else
4497 eq_msix = 0;
4498
4499 for (i = 0; i < (phba->num_cpus + eq_msix); i++) {
4500 eq = &phwi_context->be_eq[i].q;
4501 eqe = queue_tail_node(eq);
4502 num_processed = 0;
4503 while (eqe->dw[offsetof(struct amap_eq_entry, valid) / 32]
4504 & EQE_VALID_MASK) {
4505 AMAP_SET_BITS(struct amap_eq_entry, valid, eqe, 0);
4506 queue_tail_inc(eq);
4507 eqe = queue_tail_node(eq);
4508 num_processed++;
4509 }
4510
4511 if (num_processed)
4512 hwi_ring_eq_db(phba, eq->id, 1, num_processed, 1, 1);
4513 }
4514 }
4515
4516 static void beiscsi_clean_port(struct beiscsi_hba *phba)
4517 {
4518 int mgmt_status, ulp_num;
4519 struct ulp_cid_info *ptr_cid_info = NULL;
4520
4521 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
4522 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) {
4523 mgmt_status = mgmt_epfw_cleanup(phba, ulp_num);
4524 if (mgmt_status)
4525 beiscsi_log(phba, KERN_WARNING,
4526 BEISCSI_LOG_INIT,
4527 "BM_%d : mgmt_epfw_cleanup FAILED"
4528 " for ULP_%d\n", ulp_num);
4529 }
4530 }
4531
4532 hwi_purge_eq(phba);
4533 hwi_cleanup(phba);
4534 kfree(phba->io_sgl_hndl_base);
4535 kfree(phba->eh_sgl_hndl_base);
4536 kfree(phba->ep_array);
4537 kfree(phba->conn_table);
4538
4539 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
4540 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) {
4541 ptr_cid_info = phba->cid_array_info[ulp_num];
4542
4543 if (ptr_cid_info) {
4544 kfree(ptr_cid_info->cid_array);
4545 kfree(ptr_cid_info);
4546 phba->cid_array_info[ulp_num] = NULL;
4547 }
4548 }
4549 }
4550
4551 }
4552
4553 /**
4554 * beiscsi_free_mgmt_task_handles()- Free driver CXN resources
4555 * @beiscsi_conn: ptr to the conn to be cleaned up
4556 * @task: ptr to iscsi_task resource to be freed.
4557 *
4558 * Free driver mgmt resources binded to CXN.
4559 **/
4560 void
4561 beiscsi_free_mgmt_task_handles(struct beiscsi_conn *beiscsi_conn,
4562 struct iscsi_task *task)
4563 {
4564 struct beiscsi_io_task *io_task;
4565 struct beiscsi_hba *phba = beiscsi_conn->phba;
4566 struct hwi_wrb_context *pwrb_context;
4567 struct hwi_controller *phwi_ctrlr;
4568 uint16_t cri_index = BE_GET_CRI_FROM_CID(
4569 beiscsi_conn->beiscsi_conn_cid);
4570
4571 phwi_ctrlr = phba->phwi_ctrlr;
4572 pwrb_context = &phwi_ctrlr->wrb_context[cri_index];
4573
4574 io_task = task->dd_data;
4575
4576 if (io_task->pwrb_handle) {
4577 memset(io_task->pwrb_handle->pwrb, 0,
4578 sizeof(struct iscsi_wrb));
4579 free_wrb_handle(phba, pwrb_context,
4580 io_task->pwrb_handle);
4581 io_task->pwrb_handle = NULL;
4582 }
4583
4584 if (io_task->psgl_handle) {
4585 spin_lock_bh(&phba->mgmt_sgl_lock);
4586 free_mgmt_sgl_handle(phba,
4587 io_task->psgl_handle);
4588 io_task->psgl_handle = NULL;
4589 spin_unlock_bh(&phba->mgmt_sgl_lock);
4590 }
4591
4592 if (io_task->mtask_addr)
4593 pci_unmap_single(phba->pcidev,
4594 io_task->mtask_addr,
4595 io_task->mtask_data_count,
4596 PCI_DMA_TODEVICE);
4597 }
4598
4599 /**
4600 * beiscsi_cleanup_task()- Free driver resources of the task
4601 * @task: ptr to the iscsi task
4602 *
4603 **/
4604 static void beiscsi_cleanup_task(struct iscsi_task *task)
4605 {
4606 struct beiscsi_io_task *io_task = task->dd_data;
4607 struct iscsi_conn *conn = task->conn;
4608 struct beiscsi_conn *beiscsi_conn = conn->dd_data;
4609 struct beiscsi_hba *phba = beiscsi_conn->phba;
4610 struct beiscsi_session *beiscsi_sess = beiscsi_conn->beiscsi_sess;
4611 struct hwi_wrb_context *pwrb_context;
4612 struct hwi_controller *phwi_ctrlr;
4613 uint16_t cri_index = BE_GET_CRI_FROM_CID(
4614 beiscsi_conn->beiscsi_conn_cid);
4615
4616 phwi_ctrlr = phba->phwi_ctrlr;
4617 pwrb_context = &phwi_ctrlr->wrb_context[cri_index];
4618
4619 if (io_task->cmd_bhs) {
4620 pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs,
4621 io_task->bhs_pa.u.a64.address);
4622 io_task->cmd_bhs = NULL;
4623 }
4624
4625 if (task->sc) {
4626 if (io_task->pwrb_handle) {
4627 free_wrb_handle(phba, pwrb_context,
4628 io_task->pwrb_handle);
4629 io_task->pwrb_handle = NULL;
4630 }
4631
4632 if (io_task->psgl_handle) {
4633 spin_lock(&phba->io_sgl_lock);
4634 free_io_sgl_handle(phba, io_task->psgl_handle);
4635 spin_unlock(&phba->io_sgl_lock);
4636 io_task->psgl_handle = NULL;
4637 }
4638 } else {
4639 if (!beiscsi_conn->login_in_progress)
4640 beiscsi_free_mgmt_task_handles(beiscsi_conn, task);
4641 }
4642 }
4643
4644 void
4645 beiscsi_offload_connection(struct beiscsi_conn *beiscsi_conn,
4646 struct beiscsi_offload_params *params)
4647 {
4648 struct wrb_handle *pwrb_handle;
4649 struct beiscsi_hba *phba = beiscsi_conn->phba;
4650 struct iscsi_task *task = beiscsi_conn->task;
4651 struct iscsi_session *session = task->conn->session;
4652 u32 doorbell = 0;
4653
4654 /*
4655 * We can always use 0 here because it is reserved by libiscsi for
4656 * login/startup related tasks.
4657 */
4658 beiscsi_conn->login_in_progress = 0;
4659 spin_lock_bh(&session->lock);
4660 beiscsi_cleanup_task(task);
4661 spin_unlock_bh(&session->lock);
4662
4663 pwrb_handle = alloc_wrb_handle(phba, beiscsi_conn->beiscsi_conn_cid);
4664
4665 /* Check for the adapter family */
4666 if (is_chip_be2_be3r(phba))
4667 beiscsi_offload_cxn_v0(params, pwrb_handle,
4668 phba->init_mem);
4669 else
4670 beiscsi_offload_cxn_v2(params, pwrb_handle);
4671
4672 be_dws_le_to_cpu(pwrb_handle->pwrb,
4673 sizeof(struct iscsi_target_context_update_wrb));
4674
4675 doorbell |= beiscsi_conn->beiscsi_conn_cid & DB_WRB_POST_CID_MASK;
4676 doorbell |= (pwrb_handle->wrb_index & DB_DEF_PDU_WRB_INDEX_MASK)
4677 << DB_DEF_PDU_WRB_INDEX_SHIFT;
4678 doorbell |= 1 << DB_DEF_PDU_NUM_POSTED_SHIFT;
4679 iowrite32(doorbell, phba->db_va +
4680 beiscsi_conn->doorbell_offset);
4681 }
4682
4683 static void beiscsi_parse_pdu(struct iscsi_conn *conn, itt_t itt,
4684 int *index, int *age)
4685 {
4686 *index = (int)itt;
4687 if (age)
4688 *age = conn->session->age;
4689 }
4690
4691 /**
4692 * beiscsi_alloc_pdu - allocates pdu and related resources
4693 * @task: libiscsi task
4694 * @opcode: opcode of pdu for task
4695 *
4696 * This is called with the session lock held. It will allocate
4697 * the wrb and sgl if needed for the command. And it will prep
4698 * the pdu's itt. beiscsi_parse_pdu will later translate
4699 * the pdu itt to the libiscsi task itt.
4700 */
4701 static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode)
4702 {
4703 struct beiscsi_io_task *io_task = task->dd_data;
4704 struct iscsi_conn *conn = task->conn;
4705 struct beiscsi_conn *beiscsi_conn = conn->dd_data;
4706 struct beiscsi_hba *phba = beiscsi_conn->phba;
4707 struct hwi_wrb_context *pwrb_context;
4708 struct hwi_controller *phwi_ctrlr;
4709 itt_t itt;
4710 uint16_t cri_index = 0;
4711 struct beiscsi_session *beiscsi_sess = beiscsi_conn->beiscsi_sess;
4712 dma_addr_t paddr;
4713
4714 io_task->cmd_bhs = pci_pool_alloc(beiscsi_sess->bhs_pool,
4715 GFP_ATOMIC, &paddr);
4716 if (!io_task->cmd_bhs)
4717 return -ENOMEM;
4718 io_task->bhs_pa.u.a64.address = paddr;
4719 io_task->libiscsi_itt = (itt_t)task->itt;
4720 io_task->conn = beiscsi_conn;
4721
4722 task->hdr = (struct iscsi_hdr *)&io_task->cmd_bhs->iscsi_hdr;
4723 task->hdr_max = sizeof(struct be_cmd_bhs);
4724 io_task->psgl_handle = NULL;
4725 io_task->pwrb_handle = NULL;
4726
4727 if (task->sc) {
4728 spin_lock(&phba->io_sgl_lock);
4729 io_task->psgl_handle = alloc_io_sgl_handle(phba);
4730 spin_unlock(&phba->io_sgl_lock);
4731 if (!io_task->psgl_handle) {
4732 beiscsi_log(phba, KERN_ERR,
4733 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG,
4734 "BM_%d : Alloc of IO_SGL_ICD Failed"
4735 "for the CID : %d\n",
4736 beiscsi_conn->beiscsi_conn_cid);
4737 goto free_hndls;
4738 }
4739 io_task->pwrb_handle = alloc_wrb_handle(phba,
4740 beiscsi_conn->beiscsi_conn_cid);
4741 if (!io_task->pwrb_handle) {
4742 beiscsi_log(phba, KERN_ERR,
4743 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG,
4744 "BM_%d : Alloc of WRB_HANDLE Failed"
4745 "for the CID : %d\n",
4746 beiscsi_conn->beiscsi_conn_cid);
4747 goto free_io_hndls;
4748 }
4749 } else {
4750 io_task->scsi_cmnd = NULL;
4751 if ((opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGIN) {
4752 beiscsi_conn->task = task;
4753 if (!beiscsi_conn->login_in_progress) {
4754 spin_lock(&phba->mgmt_sgl_lock);
4755 io_task->psgl_handle = (struct sgl_handle *)
4756 alloc_mgmt_sgl_handle(phba);
4757 spin_unlock(&phba->mgmt_sgl_lock);
4758 if (!io_task->psgl_handle) {
4759 beiscsi_log(phba, KERN_ERR,
4760 BEISCSI_LOG_IO |
4761 BEISCSI_LOG_CONFIG,
4762 "BM_%d : Alloc of MGMT_SGL_ICD Failed"
4763 "for the CID : %d\n",
4764 beiscsi_conn->
4765 beiscsi_conn_cid);
4766 goto free_hndls;
4767 }
4768
4769 beiscsi_conn->login_in_progress = 1;
4770 beiscsi_conn->plogin_sgl_handle =
4771 io_task->psgl_handle;
4772 io_task->pwrb_handle =
4773 alloc_wrb_handle(phba,
4774 beiscsi_conn->beiscsi_conn_cid);
4775 if (!io_task->pwrb_handle) {
4776 beiscsi_log(phba, KERN_ERR,
4777 BEISCSI_LOG_IO |
4778 BEISCSI_LOG_CONFIG,
4779 "BM_%d : Alloc of WRB_HANDLE Failed"
4780 "for the CID : %d\n",
4781 beiscsi_conn->
4782 beiscsi_conn_cid);
4783 goto free_mgmt_hndls;
4784 }
4785 beiscsi_conn->plogin_wrb_handle =
4786 io_task->pwrb_handle;
4787
4788 } else {
4789 io_task->psgl_handle =
4790 beiscsi_conn->plogin_sgl_handle;
4791 io_task->pwrb_handle =
4792 beiscsi_conn->plogin_wrb_handle;
4793 }
4794 } else {
4795 spin_lock(&phba->mgmt_sgl_lock);
4796 io_task->psgl_handle = alloc_mgmt_sgl_handle(phba);
4797 spin_unlock(&phba->mgmt_sgl_lock);
4798 if (!io_task->psgl_handle) {
4799 beiscsi_log(phba, KERN_ERR,
4800 BEISCSI_LOG_IO |
4801 BEISCSI_LOG_CONFIG,
4802 "BM_%d : Alloc of MGMT_SGL_ICD Failed"
4803 "for the CID : %d\n",
4804 beiscsi_conn->
4805 beiscsi_conn_cid);
4806 goto free_hndls;
4807 }
4808 io_task->pwrb_handle =
4809 alloc_wrb_handle(phba,
4810 beiscsi_conn->beiscsi_conn_cid);
4811 if (!io_task->pwrb_handle) {
4812 beiscsi_log(phba, KERN_ERR,
4813 BEISCSI_LOG_IO | BEISCSI_LOG_CONFIG,
4814 "BM_%d : Alloc of WRB_HANDLE Failed"
4815 "for the CID : %d\n",
4816 beiscsi_conn->beiscsi_conn_cid);
4817 goto free_mgmt_hndls;
4818 }
4819
4820 }
4821 }
4822 itt = (itt_t) cpu_to_be32(((unsigned int)io_task->pwrb_handle->
4823 wrb_index << 16) | (unsigned int)
4824 (io_task->psgl_handle->sgl_index));
4825 io_task->pwrb_handle->pio_handle = task;
4826
4827 io_task->cmd_bhs->iscsi_hdr.itt = itt;
4828 return 0;
4829
4830 free_io_hndls:
4831 spin_lock(&phba->io_sgl_lock);
4832 free_io_sgl_handle(phba, io_task->psgl_handle);
4833 spin_unlock(&phba->io_sgl_lock);
4834 goto free_hndls;
4835 free_mgmt_hndls:
4836 spin_lock(&phba->mgmt_sgl_lock);
4837 free_mgmt_sgl_handle(phba, io_task->psgl_handle);
4838 io_task->psgl_handle = NULL;
4839 spin_unlock(&phba->mgmt_sgl_lock);
4840 free_hndls:
4841 phwi_ctrlr = phba->phwi_ctrlr;
4842 cri_index = BE_GET_CRI_FROM_CID(
4843 beiscsi_conn->beiscsi_conn_cid);
4844 pwrb_context = &phwi_ctrlr->wrb_context[cri_index];
4845 if (io_task->pwrb_handle)
4846 free_wrb_handle(phba, pwrb_context, io_task->pwrb_handle);
4847 io_task->pwrb_handle = NULL;
4848 pci_pool_free(beiscsi_sess->bhs_pool, io_task->cmd_bhs,
4849 io_task->bhs_pa.u.a64.address);
4850 io_task->cmd_bhs = NULL;
4851 return -ENOMEM;
4852 }
4853 int beiscsi_iotask_v2(struct iscsi_task *task, struct scatterlist *sg,
4854 unsigned int num_sg, unsigned int xferlen,
4855 unsigned int writedir)
4856 {
4857
4858 struct beiscsi_io_task *io_task = task->dd_data;
4859 struct iscsi_conn *conn = task->conn;
4860 struct beiscsi_conn *beiscsi_conn = conn->dd_data;
4861 struct beiscsi_hba *phba = beiscsi_conn->phba;
4862 struct iscsi_wrb *pwrb = NULL;
4863 unsigned int doorbell = 0;
4864
4865 pwrb = io_task->pwrb_handle->pwrb;
4866
4867 io_task->cmd_bhs->iscsi_hdr.exp_statsn = 0;
4868 io_task->bhs_len = sizeof(struct be_cmd_bhs);
4869
4870 if (writedir) {
4871 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, type, pwrb,
4872 INI_WR_CMD);
4873 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, dsp, pwrb, 1);
4874 } else {
4875 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, type, pwrb,
4876 INI_RD_CMD);
4877 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, dsp, pwrb, 0);
4878 }
4879
4880 io_task->wrb_type = AMAP_GET_BITS(struct amap_iscsi_wrb_v2,
4881 type, pwrb);
4882
4883 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, lun, pwrb,
4884 cpu_to_be16(*(unsigned short *)
4885 &io_task->cmd_bhs->iscsi_hdr.lun));
4886 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, r2t_exp_dtl, pwrb, xferlen);
4887 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, wrb_idx, pwrb,
4888 io_task->pwrb_handle->wrb_index);
4889 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, cmdsn_itt, pwrb,
4890 be32_to_cpu(task->cmdsn));
4891 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sgl_idx, pwrb,
4892 io_task->psgl_handle->sgl_index);
4893
4894 hwi_write_sgl_v2(pwrb, sg, num_sg, io_task);
4895 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, ptr2nextwrb, pwrb,
4896 io_task->pwrb_handle->nxt_wrb_index);
4897
4898 be_dws_le_to_cpu(pwrb, sizeof(struct iscsi_wrb));
4899
4900 doorbell |= beiscsi_conn->beiscsi_conn_cid & DB_WRB_POST_CID_MASK;
4901 doorbell |= (io_task->pwrb_handle->wrb_index &
4902 DB_DEF_PDU_WRB_INDEX_MASK) <<
4903 DB_DEF_PDU_WRB_INDEX_SHIFT;
4904 doorbell |= 1 << DB_DEF_PDU_NUM_POSTED_SHIFT;
4905 iowrite32(doorbell, phba->db_va +
4906 beiscsi_conn->doorbell_offset);
4907 return 0;
4908 }
4909
4910 static int beiscsi_iotask(struct iscsi_task *task, struct scatterlist *sg,
4911 unsigned int num_sg, unsigned int xferlen,
4912 unsigned int writedir)
4913 {
4914
4915 struct beiscsi_io_task *io_task = task->dd_data;
4916 struct iscsi_conn *conn = task->conn;
4917 struct beiscsi_conn *beiscsi_conn = conn->dd_data;
4918 struct beiscsi_hba *phba = beiscsi_conn->phba;
4919 struct iscsi_wrb *pwrb = NULL;
4920 unsigned int doorbell = 0;
4921
4922 pwrb = io_task->pwrb_handle->pwrb;
4923 io_task->cmd_bhs->iscsi_hdr.exp_statsn = 0;
4924 io_task->bhs_len = sizeof(struct be_cmd_bhs);
4925
4926 if (writedir) {
4927 AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb,
4928 INI_WR_CMD);
4929 AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 1);
4930 } else {
4931 AMAP_SET_BITS(struct amap_iscsi_wrb, type, pwrb,
4932 INI_RD_CMD);
4933 AMAP_SET_BITS(struct amap_iscsi_wrb, dsp, pwrb, 0);
4934 }
4935
4936 io_task->wrb_type = AMAP_GET_BITS(struct amap_iscsi_wrb,
4937 type, pwrb);
4938
4939 AMAP_SET_BITS(struct amap_iscsi_wrb, lun, pwrb,
4940 cpu_to_be16(*(unsigned short *)
4941 &io_task->cmd_bhs->iscsi_hdr.lun));
4942 AMAP_SET_BITS(struct amap_iscsi_wrb, r2t_exp_dtl, pwrb, xferlen);
4943 AMAP_SET_BITS(struct amap_iscsi_wrb, wrb_idx, pwrb,
4944 io_task->pwrb_handle->wrb_index);
4945 AMAP_SET_BITS(struct amap_iscsi_wrb, cmdsn_itt, pwrb,
4946 be32_to_cpu(task->cmdsn));
4947 AMAP_SET_BITS(struct amap_iscsi_wrb, sgl_icd_idx, pwrb,
4948 io_task->psgl_handle->sgl_index);
4949
4950 hwi_write_sgl(pwrb, sg, num_sg, io_task);
4951
4952 AMAP_SET_BITS(struct amap_iscsi_wrb, ptr2nextwrb, pwrb,
4953 io_task->pwrb_handle->nxt_wrb_index);
4954 be_dws_le_to_cpu(pwrb, sizeof(struct iscsi_wrb));
4955
4956 doorbell |= beiscsi_conn->beiscsi_conn_cid & DB_WRB_POST_CID_MASK;
4957 doorbell |= (io_task->pwrb_handle->wrb_index &
4958 DB_DEF_PDU_WRB_INDEX_MASK) << DB_DEF_PDU_WRB_INDEX_SHIFT;
4959 doorbell |= 1 << DB_DEF_PDU_NUM_POSTED_SHIFT;
4960
4961 iowrite32(doorbell, phba->db_va +
4962 beiscsi_conn->doorbell_offset);
4963 return 0;
4964 }
4965
4966 static int beiscsi_mtask(struct iscsi_task *task)
4967 {
4968 struct beiscsi_io_task *io_task = task->dd_data;
4969 struct iscsi_conn *conn = task->conn;
4970 struct beiscsi_conn *beiscsi_conn = conn->dd_data;
4971 struct beiscsi_hba *phba = beiscsi_conn->phba;
4972 struct iscsi_wrb *pwrb = NULL;
4973 unsigned int doorbell = 0;
4974 unsigned int cid;
4975 unsigned int pwrb_typeoffset = 0;
4976
4977 cid = beiscsi_conn->beiscsi_conn_cid;
4978 pwrb = io_task->pwrb_handle->pwrb;
4979 memset(pwrb, 0, sizeof(*pwrb));
4980
4981 if (is_chip_be2_be3r(phba)) {
4982 AMAP_SET_BITS(struct amap_iscsi_wrb, cmdsn_itt, pwrb,
4983 be32_to_cpu(task->cmdsn));
4984 AMAP_SET_BITS(struct amap_iscsi_wrb, wrb_idx, pwrb,
4985 io_task->pwrb_handle->wrb_index);
4986 AMAP_SET_BITS(struct amap_iscsi_wrb, sgl_icd_idx, pwrb,
4987 io_task->psgl_handle->sgl_index);
4988 AMAP_SET_BITS(struct amap_iscsi_wrb, r2t_exp_dtl, pwrb,
4989 task->data_count);
4990 AMAP_SET_BITS(struct amap_iscsi_wrb, ptr2nextwrb, pwrb,
4991 io_task->pwrb_handle->nxt_wrb_index);
4992 pwrb_typeoffset = BE_WRB_TYPE_OFFSET;
4993 } else {
4994 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, cmdsn_itt, pwrb,
4995 be32_to_cpu(task->cmdsn));
4996 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, wrb_idx, pwrb,
4997 io_task->pwrb_handle->wrb_index);
4998 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, sgl_idx, pwrb,
4999 io_task->psgl_handle->sgl_index);
5000 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, r2t_exp_dtl, pwrb,
5001 task->data_count);
5002 AMAP_SET_BITS(struct amap_iscsi_wrb_v2, ptr2nextwrb, pwrb,
5003 io_task->pwrb_handle->nxt_wrb_index);
5004 pwrb_typeoffset = SKH_WRB_TYPE_OFFSET;
5005 }
5006
5007
5008 switch (task->hdr->opcode & ISCSI_OPCODE_MASK) {
5009 case ISCSI_OP_LOGIN:
5010 AMAP_SET_BITS(struct amap_iscsi_wrb, cmdsn_itt, pwrb, 1);
5011 ADAPTER_SET_WRB_TYPE(pwrb, TGT_DM_CMD, pwrb_typeoffset);
5012 hwi_write_buffer(pwrb, task);
5013 break;
5014 case ISCSI_OP_NOOP_OUT:
5015 if (task->hdr->ttt != ISCSI_RESERVED_TAG) {
5016 ADAPTER_SET_WRB_TYPE(pwrb, TGT_DM_CMD, pwrb_typeoffset);
5017 if (is_chip_be2_be3r(phba))
5018 AMAP_SET_BITS(struct amap_iscsi_wrb,
5019 dmsg, pwrb, 1);
5020 else
5021 AMAP_SET_BITS(struct amap_iscsi_wrb_v2,
5022 dmsg, pwrb, 1);
5023 } else {
5024 ADAPTER_SET_WRB_TYPE(pwrb, INI_RD_CMD, pwrb_typeoffset);
5025 if (is_chip_be2_be3r(phba))
5026 AMAP_SET_BITS(struct amap_iscsi_wrb,
5027 dmsg, pwrb, 0);
5028 else
5029 AMAP_SET_BITS(struct amap_iscsi_wrb_v2,
5030 dmsg, pwrb, 0);
5031 }
5032 hwi_write_buffer(pwrb, task);
5033 break;
5034 case ISCSI_OP_TEXT:
5035 ADAPTER_SET_WRB_TYPE(pwrb, TGT_DM_CMD, pwrb_typeoffset);
5036 hwi_write_buffer(pwrb, task);
5037 break;
5038 case ISCSI_OP_SCSI_TMFUNC:
5039 ADAPTER_SET_WRB_TYPE(pwrb, INI_TMF_CMD, pwrb_typeoffset);
5040 hwi_write_buffer(pwrb, task);
5041 break;
5042 case ISCSI_OP_LOGOUT:
5043 ADAPTER_SET_WRB_TYPE(pwrb, HWH_TYPE_LOGOUT, pwrb_typeoffset);
5044 hwi_write_buffer(pwrb, task);
5045 break;
5046
5047 default:
5048 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
5049 "BM_%d : opcode =%d Not supported\n",
5050 task->hdr->opcode & ISCSI_OPCODE_MASK);
5051
5052 return -EINVAL;
5053 }
5054
5055 /* Set the task type */
5056 io_task->wrb_type = (is_chip_be2_be3r(phba)) ?
5057 AMAP_GET_BITS(struct amap_iscsi_wrb, type, pwrb) :
5058 AMAP_GET_BITS(struct amap_iscsi_wrb_v2, type, pwrb);
5059
5060 doorbell |= cid & DB_WRB_POST_CID_MASK;
5061 doorbell |= (io_task->pwrb_handle->wrb_index &
5062 DB_DEF_PDU_WRB_INDEX_MASK) << DB_DEF_PDU_WRB_INDEX_SHIFT;
5063 doorbell |= 1 << DB_DEF_PDU_NUM_POSTED_SHIFT;
5064 iowrite32(doorbell, phba->db_va +
5065 beiscsi_conn->doorbell_offset);
5066 return 0;
5067 }
5068
5069 static int beiscsi_task_xmit(struct iscsi_task *task)
5070 {
5071 struct beiscsi_io_task *io_task = task->dd_data;
5072 struct scsi_cmnd *sc = task->sc;
5073 struct beiscsi_hba *phba = NULL;
5074 struct scatterlist *sg;
5075 int num_sg;
5076 unsigned int writedir = 0, xferlen = 0;
5077
5078 phba = ((struct beiscsi_conn *)task->conn->dd_data)->phba;
5079
5080 if (!sc)
5081 return beiscsi_mtask(task);
5082
5083 io_task->scsi_cmnd = sc;
5084 num_sg = scsi_dma_map(sc);
5085 if (num_sg < 0) {
5086 struct iscsi_conn *conn = task->conn;
5087 struct beiscsi_hba *phba = NULL;
5088
5089 phba = ((struct beiscsi_conn *)conn->dd_data)->phba;
5090 beiscsi_log(phba, KERN_ERR,
5091 BEISCSI_LOG_IO | BEISCSI_LOG_ISCSI,
5092 "BM_%d : scsi_dma_map Failed "
5093 "Driver_ITT : 0x%x ITT : 0x%x Xferlen : 0x%x\n",
5094 be32_to_cpu(io_task->cmd_bhs->iscsi_hdr.itt),
5095 io_task->libiscsi_itt, scsi_bufflen(sc));
5096
5097 return num_sg;
5098 }
5099 xferlen = scsi_bufflen(sc);
5100 sg = scsi_sglist(sc);
5101 if (sc->sc_data_direction == DMA_TO_DEVICE)
5102 writedir = 1;
5103 else
5104 writedir = 0;
5105
5106 return phba->iotask_fn(task, sg, num_sg, xferlen, writedir);
5107 }
5108
5109 /**
5110 * beiscsi_bsg_request - handle bsg request from ISCSI transport
5111 * @job: job to handle
5112 */
5113 static int beiscsi_bsg_request(struct bsg_job *job)
5114 {
5115 struct Scsi_Host *shost;
5116 struct beiscsi_hba *phba;
5117 struct iscsi_bsg_request *bsg_req = job->request;
5118 int rc = -EINVAL;
5119 unsigned int tag;
5120 struct be_dma_mem nonemb_cmd;
5121 struct be_cmd_resp_hdr *resp;
5122 struct iscsi_bsg_reply *bsg_reply = job->reply;
5123 unsigned short status, extd_status;
5124
5125 shost = iscsi_job_to_shost(job);
5126 phba = iscsi_host_priv(shost);
5127
5128 switch (bsg_req->msgcode) {
5129 case ISCSI_BSG_HST_VENDOR:
5130 nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev,
5131 job->request_payload.payload_len,
5132 &nonemb_cmd.dma);
5133 if (nonemb_cmd.va == NULL) {
5134 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
5135 "BM_%d : Failed to allocate memory for "
5136 "beiscsi_bsg_request\n");
5137 return -ENOMEM;
5138 }
5139 tag = mgmt_vendor_specific_fw_cmd(&phba->ctrl, phba, job,
5140 &nonemb_cmd);
5141 if (!tag) {
5142 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
5143 "BM_%d : MBX Tag Allocation Failed\n");
5144
5145 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
5146 nonemb_cmd.va, nonemb_cmd.dma);
5147 return -EAGAIN;
5148 }
5149
5150 rc = wait_event_interruptible_timeout(
5151 phba->ctrl.mcc_wait[tag],
5152 phba->ctrl.mcc_numtag[tag],
5153 msecs_to_jiffies(
5154 BEISCSI_HOST_MBX_TIMEOUT));
5155 extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8;
5156 status = phba->ctrl.mcc_numtag[tag] & 0x000000FF;
5157 free_mcc_tag(&phba->ctrl, tag);
5158 resp = (struct be_cmd_resp_hdr *)nonemb_cmd.va;
5159 sg_copy_from_buffer(job->reply_payload.sg_list,
5160 job->reply_payload.sg_cnt,
5161 nonemb_cmd.va, (resp->response_length
5162 + sizeof(*resp)));
5163 bsg_reply->reply_payload_rcv_len = resp->response_length;
5164 bsg_reply->result = status;
5165 bsg_job_done(job, bsg_reply->result,
5166 bsg_reply->reply_payload_rcv_len);
5167 pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
5168 nonemb_cmd.va, nonemb_cmd.dma);
5169 if (status || extd_status) {
5170 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
5171 "BM_%d : MBX Cmd Failed"
5172 " status = %d extd_status = %d\n",
5173 status, extd_status);
5174
5175 return -EIO;
5176 } else {
5177 rc = 0;
5178 }
5179 break;
5180
5181 default:
5182 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
5183 "BM_%d : Unsupported bsg command: 0x%x\n",
5184 bsg_req->msgcode);
5185 break;
5186 }
5187
5188 return rc;
5189 }
5190
5191 void beiscsi_hba_attrs_init(struct beiscsi_hba *phba)
5192 {
5193 /* Set the logging parameter */
5194 beiscsi_log_enable_init(phba, beiscsi_log_enable);
5195 }
5196
5197 /*
5198 * beiscsi_quiesce()- Cleanup Driver resources
5199 * @phba: Instance Priv structure
5200 * @unload_state:i Clean or EEH unload state
5201 *
5202 * Free the OS and HW resources held by the driver
5203 **/
5204 static void beiscsi_quiesce(struct beiscsi_hba *phba,
5205 uint32_t unload_state)
5206 {
5207 struct hwi_controller *phwi_ctrlr;
5208 struct hwi_context_memory *phwi_context;
5209 struct be_eq_obj *pbe_eq;
5210 unsigned int i, msix_vec;
5211
5212 phwi_ctrlr = phba->phwi_ctrlr;
5213 phwi_context = phwi_ctrlr->phwi_ctxt;
5214 hwi_disable_intr(phba);
5215 if (phba->msix_enabled) {
5216 for (i = 0; i <= phba->num_cpus; i++) {
5217 msix_vec = phba->msix_entries[i].vector;
5218 synchronize_irq(msix_vec);
5219 free_irq(msix_vec, &phwi_context->be_eq[i]);
5220 kfree(phba->msi_name[i]);
5221 }
5222 } else
5223 if (phba->pcidev->irq) {
5224 synchronize_irq(phba->pcidev->irq);
5225 free_irq(phba->pcidev->irq, phba);
5226 }
5227 pci_disable_msix(phba->pcidev);
5228
5229 if (blk_iopoll_enabled)
5230 for (i = 0; i < phba->num_cpus; i++) {
5231 pbe_eq = &phwi_context->be_eq[i];
5232 blk_iopoll_disable(&pbe_eq->iopoll);
5233 }
5234
5235 if (unload_state == BEISCSI_CLEAN_UNLOAD) {
5236 destroy_workqueue(phba->wq);
5237 beiscsi_clean_port(phba);
5238 beiscsi_free_mem(phba);
5239
5240 beiscsi_unmap_pci_function(phba);
5241 pci_free_consistent(phba->pcidev,
5242 phba->ctrl.mbox_mem_alloced.size,
5243 phba->ctrl.mbox_mem_alloced.va,
5244 phba->ctrl.mbox_mem_alloced.dma);
5245 } else {
5246 hwi_purge_eq(phba);
5247 hwi_cleanup(phba);
5248 }
5249
5250 cancel_delayed_work_sync(&phba->beiscsi_hw_check_task);
5251 }
5252
5253 static void beiscsi_remove(struct pci_dev *pcidev)
5254 {
5255
5256 struct beiscsi_hba *phba = NULL;
5257
5258 phba = pci_get_drvdata(pcidev);
5259 if (!phba) {
5260 dev_err(&pcidev->dev, "beiscsi_remove called with no phba\n");
5261 return;
5262 }
5263
5264 beiscsi_destroy_def_ifaces(phba);
5265 beiscsi_quiesce(phba, BEISCSI_CLEAN_UNLOAD);
5266 iscsi_boot_destroy_kset(phba->boot_kset);
5267 iscsi_host_remove(phba->shost);
5268 pci_dev_put(phba->pcidev);
5269 iscsi_host_free(phba->shost);
5270 pci_disable_pcie_error_reporting(pcidev);
5271 pci_set_drvdata(pcidev, NULL);
5272 pci_disable_device(pcidev);
5273 }
5274
5275 static void beiscsi_shutdown(struct pci_dev *pcidev)
5276 {
5277
5278 struct beiscsi_hba *phba = NULL;
5279
5280 phba = (struct beiscsi_hba *)pci_get_drvdata(pcidev);
5281 if (!phba) {
5282 dev_err(&pcidev->dev, "beiscsi_shutdown called with no phba\n");
5283 return;
5284 }
5285
5286 beiscsi_quiesce(phba, BEISCSI_CLEAN_UNLOAD);
5287 pci_disable_device(pcidev);
5288 }
5289
5290 static void beiscsi_msix_enable(struct beiscsi_hba *phba)
5291 {
5292 int i, status;
5293
5294 for (i = 0; i <= phba->num_cpus; i++)
5295 phba->msix_entries[i].entry = i;
5296
5297 status = pci_enable_msix(phba->pcidev, phba->msix_entries,
5298 (phba->num_cpus + 1));
5299 if (!status)
5300 phba->msix_enabled = true;
5301
5302 return;
5303 }
5304
5305 /*
5306 * beiscsi_hw_health_check()- Check adapter health
5307 * @work: work item to check HW health
5308 *
5309 * Check if adapter in an unrecoverable state or not.
5310 **/
5311 static void
5312 beiscsi_hw_health_check(struct work_struct *work)
5313 {
5314 struct beiscsi_hba *phba =
5315 container_of(work, struct beiscsi_hba,
5316 beiscsi_hw_check_task.work);
5317
5318 beiscsi_ue_detect(phba);
5319
5320 schedule_delayed_work(&phba->beiscsi_hw_check_task,
5321 msecs_to_jiffies(1000));
5322 }
5323
5324
5325 static pci_ers_result_t beiscsi_eeh_err_detected(struct pci_dev *pdev,
5326 pci_channel_state_t state)
5327 {
5328 struct beiscsi_hba *phba = NULL;
5329
5330 phba = (struct beiscsi_hba *)pci_get_drvdata(pdev);
5331 phba->state |= BE_ADAPTER_PCI_ERR;
5332
5333 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
5334 "BM_%d : EEH error detected\n");
5335
5336 beiscsi_quiesce(phba, BEISCSI_EEH_UNLOAD);
5337
5338 if (state == pci_channel_io_perm_failure) {
5339 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
5340 "BM_%d : EEH : State PERM Failure");
5341 return PCI_ERS_RESULT_DISCONNECT;
5342 }
5343
5344 pci_disable_device(pdev);
5345
5346 /* The error could cause the FW to trigger a flash debug dump.
5347 * Resetting the card while flash dump is in progress
5348 * can cause it not to recover; wait for it to finish.
5349 * Wait only for first function as it is needed only once per
5350 * adapter.
5351 **/
5352 if (pdev->devfn == 0)
5353 ssleep(30);
5354
5355 return PCI_ERS_RESULT_NEED_RESET;
5356 }
5357
5358 static pci_ers_result_t beiscsi_eeh_reset(struct pci_dev *pdev)
5359 {
5360 struct beiscsi_hba *phba = NULL;
5361 int status = 0;
5362
5363 phba = (struct beiscsi_hba *)pci_get_drvdata(pdev);
5364
5365 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
5366 "BM_%d : EEH Reset\n");
5367
5368 status = pci_enable_device(pdev);
5369 if (status)
5370 return PCI_ERS_RESULT_DISCONNECT;
5371
5372 pci_set_master(pdev);
5373 pci_set_power_state(pdev, PCI_D0);
5374 pci_restore_state(pdev);
5375
5376 /* Wait for the CHIP Reset to complete */
5377 status = be_chk_reset_complete(phba);
5378 if (!status) {
5379 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT,
5380 "BM_%d : EEH Reset Completed\n");
5381 } else {
5382 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT,
5383 "BM_%d : EEH Reset Completion Failure\n");
5384 return PCI_ERS_RESULT_DISCONNECT;
5385 }
5386
5387 pci_cleanup_aer_uncorrect_error_status(pdev);
5388 return PCI_ERS_RESULT_RECOVERED;
5389 }
5390
5391 static void beiscsi_eeh_resume(struct pci_dev *pdev)
5392 {
5393 int ret = 0, i;
5394 struct be_eq_obj *pbe_eq;
5395 struct beiscsi_hba *phba = NULL;
5396 struct hwi_controller *phwi_ctrlr;
5397 struct hwi_context_memory *phwi_context;
5398
5399 phba = (struct beiscsi_hba *)pci_get_drvdata(pdev);
5400 pci_save_state(pdev);
5401
5402 if (enable_msix)
5403 find_num_cpus(phba);
5404 else
5405 phba->num_cpus = 1;
5406
5407 if (enable_msix) {
5408 beiscsi_msix_enable(phba);
5409 if (!phba->msix_enabled)
5410 phba->num_cpus = 1;
5411 }
5412
5413 ret = beiscsi_cmd_reset_function(phba);
5414 if (ret) {
5415 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
5416 "BM_%d : Reset Failed\n");
5417 goto ret_err;
5418 }
5419
5420 ret = be_chk_reset_complete(phba);
5421 if (ret) {
5422 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
5423 "BM_%d : Failed to get out of reset.\n");
5424 goto ret_err;
5425 }
5426
5427 beiscsi_get_params(phba);
5428 phba->shost->max_id = phba->params.cxns_per_ctrl;
5429 phba->shost->can_queue = phba->params.ios_per_ctrl;
5430 ret = hwi_init_controller(phba);
5431
5432 for (i = 0; i < MAX_MCC_CMD; i++) {
5433 init_waitqueue_head(&phba->ctrl.mcc_wait[i + 1]);
5434 phba->ctrl.mcc_tag[i] = i + 1;
5435 phba->ctrl.mcc_numtag[i + 1] = 0;
5436 phba->ctrl.mcc_tag_available++;
5437 }
5438
5439 phwi_ctrlr = phba->phwi_ctrlr;
5440 phwi_context = phwi_ctrlr->phwi_ctxt;
5441
5442 if (blk_iopoll_enabled) {
5443 for (i = 0; i < phba->num_cpus; i++) {
5444 pbe_eq = &phwi_context->be_eq[i];
5445 blk_iopoll_init(&pbe_eq->iopoll, be_iopoll_budget,
5446 be_iopoll);
5447 blk_iopoll_enable(&pbe_eq->iopoll);
5448 }
5449
5450 i = (phba->msix_enabled) ? i : 0;
5451 /* Work item for MCC handling */
5452 pbe_eq = &phwi_context->be_eq[i];
5453 INIT_WORK(&pbe_eq->work_cqs, beiscsi_process_all_cqs);
5454 } else {
5455 if (phba->msix_enabled) {
5456 for (i = 0; i <= phba->num_cpus; i++) {
5457 pbe_eq = &phwi_context->be_eq[i];
5458 INIT_WORK(&pbe_eq->work_cqs,
5459 beiscsi_process_all_cqs);
5460 }
5461 } else {
5462 pbe_eq = &phwi_context->be_eq[0];
5463 INIT_WORK(&pbe_eq->work_cqs,
5464 beiscsi_process_all_cqs);
5465 }
5466 }
5467
5468 ret = beiscsi_init_irqs(phba);
5469 if (ret < 0) {
5470 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
5471 "BM_%d : beiscsi_eeh_resume - "
5472 "Failed to beiscsi_init_irqs\n");
5473 goto ret_err;
5474 }
5475
5476 hwi_enable_intr(phba);
5477 phba->state &= ~BE_ADAPTER_PCI_ERR;
5478
5479 return;
5480 ret_err:
5481 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
5482 "BM_%d : AER EEH Resume Failed\n");
5483 }
5484
5485 static int beiscsi_dev_probe(struct pci_dev *pcidev,
5486 const struct pci_device_id *id)
5487 {
5488 struct beiscsi_hba *phba = NULL;
5489 struct hwi_controller *phwi_ctrlr;
5490 struct hwi_context_memory *phwi_context;
5491 struct be_eq_obj *pbe_eq;
5492 int ret = 0, i;
5493
5494 ret = beiscsi_enable_pci(pcidev);
5495 if (ret < 0) {
5496 dev_err(&pcidev->dev,
5497 "beiscsi_dev_probe - Failed to enable pci device\n");
5498 return ret;
5499 }
5500
5501 phba = beiscsi_hba_alloc(pcidev);
5502 if (!phba) {
5503 dev_err(&pcidev->dev,
5504 "beiscsi_dev_probe - Failed in beiscsi_hba_alloc\n");
5505 goto disable_pci;
5506 }
5507
5508 /* Enable EEH reporting */
5509 ret = pci_enable_pcie_error_reporting(pcidev);
5510 if (ret)
5511 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT,
5512 "BM_%d : PCIe Error Reporting "
5513 "Enabling Failed\n");
5514
5515 pci_save_state(pcidev);
5516
5517 /* Initialize Driver configuration Paramters */
5518 beiscsi_hba_attrs_init(phba);
5519
5520 phba->fw_timeout = false;
5521 phba->mac_addr_set = false;
5522
5523
5524 switch (pcidev->device) {
5525 case BE_DEVICE_ID1:
5526 case OC_DEVICE_ID1:
5527 case OC_DEVICE_ID2:
5528 phba->generation = BE_GEN2;
5529 phba->iotask_fn = beiscsi_iotask;
5530 break;
5531 case BE_DEVICE_ID2:
5532 case OC_DEVICE_ID3:
5533 phba->generation = BE_GEN3;
5534 phba->iotask_fn = beiscsi_iotask;
5535 break;
5536 case OC_SKH_ID1:
5537 phba->generation = BE_GEN4;
5538 phba->iotask_fn = beiscsi_iotask_v2;
5539 break;
5540 default:
5541 phba->generation = 0;
5542 }
5543
5544 ret = be_ctrl_init(phba, pcidev);
5545 if (ret) {
5546 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
5547 "BM_%d : beiscsi_dev_probe-"
5548 "Failed in be_ctrl_init\n");
5549 goto hba_free;
5550 }
5551
5552 ret = beiscsi_cmd_reset_function(phba);
5553 if (ret) {
5554 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
5555 "BM_%d : Reset Failed\n");
5556 goto hba_free;
5557 }
5558 ret = be_chk_reset_complete(phba);
5559 if (ret) {
5560 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
5561 "BM_%d : Failed to get out of reset.\n");
5562 goto hba_free;
5563 }
5564
5565 spin_lock_init(&phba->io_sgl_lock);
5566 spin_lock_init(&phba->mgmt_sgl_lock);
5567 spin_lock_init(&phba->isr_lock);
5568 spin_lock_init(&phba->async_pdu_lock);
5569 ret = mgmt_get_fw_config(&phba->ctrl, phba);
5570 if (ret != 0) {
5571 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
5572 "BM_%d : Error getting fw config\n");
5573 goto free_port;
5574 }
5575
5576 if (enable_msix)
5577 find_num_cpus(phba);
5578 else
5579 phba->num_cpus = 1;
5580
5581 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
5582 "BM_%d : num_cpus = %d\n",
5583 phba->num_cpus);
5584
5585 if (enable_msix) {
5586 beiscsi_msix_enable(phba);
5587 if (!phba->msix_enabled)
5588 phba->num_cpus = 1;
5589 }
5590
5591 phba->shost->max_id = phba->params.cxns_per_ctrl;
5592 beiscsi_get_params(phba);
5593 phba->shost->can_queue = phba->params.ios_per_ctrl;
5594 ret = beiscsi_init_port(phba);
5595 if (ret < 0) {
5596 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
5597 "BM_%d : beiscsi_dev_probe-"
5598 "Failed in beiscsi_init_port\n");
5599 goto free_port;
5600 }
5601
5602 for (i = 0; i < MAX_MCC_CMD; i++) {
5603 init_waitqueue_head(&phba->ctrl.mcc_wait[i + 1]);
5604 phba->ctrl.mcc_tag[i] = i + 1;
5605 phba->ctrl.mcc_numtag[i + 1] = 0;
5606 phba->ctrl.mcc_tag_available++;
5607 }
5608
5609 phba->ctrl.mcc_alloc_index = phba->ctrl.mcc_free_index = 0;
5610
5611 snprintf(phba->wq_name, sizeof(phba->wq_name), "beiscsi_%02x_wq",
5612 phba->shost->host_no);
5613 phba->wq = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, phba->wq_name);
5614 if (!phba->wq) {
5615 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
5616 "BM_%d : beiscsi_dev_probe-"
5617 "Failed to allocate work queue\n");
5618 goto free_twq;
5619 }
5620
5621 INIT_DELAYED_WORK(&phba->beiscsi_hw_check_task,
5622 beiscsi_hw_health_check);
5623
5624 phwi_ctrlr = phba->phwi_ctrlr;
5625 phwi_context = phwi_ctrlr->phwi_ctxt;
5626
5627 if (blk_iopoll_enabled) {
5628 for (i = 0; i < phba->num_cpus; i++) {
5629 pbe_eq = &phwi_context->be_eq[i];
5630 blk_iopoll_init(&pbe_eq->iopoll, be_iopoll_budget,
5631 be_iopoll);
5632 blk_iopoll_enable(&pbe_eq->iopoll);
5633 }
5634
5635 i = (phba->msix_enabled) ? i : 0;
5636 /* Work item for MCC handling */
5637 pbe_eq = &phwi_context->be_eq[i];
5638 INIT_WORK(&pbe_eq->work_cqs, beiscsi_process_all_cqs);
5639 } else {
5640 if (phba->msix_enabled) {
5641 for (i = 0; i <= phba->num_cpus; i++) {
5642 pbe_eq = &phwi_context->be_eq[i];
5643 INIT_WORK(&pbe_eq->work_cqs,
5644 beiscsi_process_all_cqs);
5645 }
5646 } else {
5647 pbe_eq = &phwi_context->be_eq[0];
5648 INIT_WORK(&pbe_eq->work_cqs,
5649 beiscsi_process_all_cqs);
5650 }
5651 }
5652
5653 ret = beiscsi_init_irqs(phba);
5654 if (ret < 0) {
5655 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
5656 "BM_%d : beiscsi_dev_probe-"
5657 "Failed to beiscsi_init_irqs\n");
5658 goto free_blkenbld;
5659 }
5660 hwi_enable_intr(phba);
5661
5662 if (beiscsi_setup_boot_info(phba))
5663 /*
5664 * log error but continue, because we may not be using
5665 * iscsi boot.
5666 */
5667 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
5668 "BM_%d : Could not set up "
5669 "iSCSI boot info.\n");
5670
5671 beiscsi_create_def_ifaces(phba);
5672 schedule_delayed_work(&phba->beiscsi_hw_check_task,
5673 msecs_to_jiffies(1000));
5674
5675 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,
5676 "\n\n\n BM_%d : SUCCESS - DRIVER LOADED\n\n\n");
5677 return 0;
5678
5679 free_blkenbld:
5680 destroy_workqueue(phba->wq);
5681 if (blk_iopoll_enabled)
5682 for (i = 0; i < phba->num_cpus; i++) {
5683 pbe_eq = &phwi_context->be_eq[i];
5684 blk_iopoll_disable(&pbe_eq->iopoll);
5685 }
5686 free_twq:
5687 beiscsi_clean_port(phba);
5688 beiscsi_free_mem(phba);
5689 free_port:
5690 pci_free_consistent(phba->pcidev,
5691 phba->ctrl.mbox_mem_alloced.size,
5692 phba->ctrl.mbox_mem_alloced.va,
5693 phba->ctrl.mbox_mem_alloced.dma);
5694 beiscsi_unmap_pci_function(phba);
5695 hba_free:
5696 if (phba->msix_enabled)
5697 pci_disable_msix(phba->pcidev);
5698 iscsi_host_remove(phba->shost);
5699 pci_dev_put(phba->pcidev);
5700 iscsi_host_free(phba->shost);
5701 disable_pci:
5702 pci_disable_device(pcidev);
5703 return ret;
5704 }
5705
5706 static struct pci_error_handlers beiscsi_eeh_handlers = {
5707 .error_detected = beiscsi_eeh_err_detected,
5708 .slot_reset = beiscsi_eeh_reset,
5709 .resume = beiscsi_eeh_resume,
5710 };
5711
5712 struct iscsi_transport beiscsi_iscsi_transport = {
5713 .owner = THIS_MODULE,
5714 .name = DRV_NAME,
5715 .caps = CAP_RECOVERY_L0 | CAP_HDRDGST | CAP_TEXT_NEGO |
5716 CAP_MULTI_R2T | CAP_DATADGST | CAP_DATA_PATH_OFFLOAD,
5717 .create_session = beiscsi_session_create,
5718 .destroy_session = beiscsi_session_destroy,
5719 .create_conn = beiscsi_conn_create,
5720 .bind_conn = beiscsi_conn_bind,
5721 .destroy_conn = iscsi_conn_teardown,
5722 .attr_is_visible = be2iscsi_attr_is_visible,
5723 .set_iface_param = be2iscsi_iface_set_param,
5724 .get_iface_param = be2iscsi_iface_get_param,
5725 .set_param = beiscsi_set_param,
5726 .get_conn_param = iscsi_conn_get_param,
5727 .get_session_param = iscsi_session_get_param,
5728 .get_host_param = beiscsi_get_host_param,
5729 .start_conn = beiscsi_conn_start,
5730 .stop_conn = iscsi_conn_stop,
5731 .send_pdu = iscsi_conn_send_pdu,
5732 .xmit_task = beiscsi_task_xmit,
5733 .cleanup_task = beiscsi_cleanup_task,
5734 .alloc_pdu = beiscsi_alloc_pdu,
5735 .parse_pdu_itt = beiscsi_parse_pdu,
5736 .get_stats = beiscsi_conn_get_stats,
5737 .get_ep_param = beiscsi_ep_get_param,
5738 .ep_connect = beiscsi_ep_connect,
5739 .ep_poll = beiscsi_ep_poll,
5740 .ep_disconnect = beiscsi_ep_disconnect,
5741 .session_recovery_timedout = iscsi_session_recovery_timedout,
5742 .bsg_request = beiscsi_bsg_request,
5743 };
5744
5745 static struct pci_driver beiscsi_pci_driver = {
5746 .name = DRV_NAME,
5747 .probe = beiscsi_dev_probe,
5748 .remove = beiscsi_remove,
5749 .shutdown = beiscsi_shutdown,
5750 .id_table = beiscsi_pci_id_table,
5751 .err_handler = &beiscsi_eeh_handlers
5752 };
5753
5754
5755 static int __init beiscsi_module_init(void)
5756 {
5757 int ret;
5758
5759 beiscsi_scsi_transport =
5760 iscsi_register_transport(&beiscsi_iscsi_transport);
5761 if (!beiscsi_scsi_transport) {
5762 printk(KERN_ERR
5763 "beiscsi_module_init - Unable to register beiscsi transport.\n");
5764 return -ENOMEM;
5765 }
5766 printk(KERN_INFO "In beiscsi_module_init, tt=%p\n",
5767 &beiscsi_iscsi_transport);
5768
5769 ret = pci_register_driver(&beiscsi_pci_driver);
5770 if (ret) {
5771 printk(KERN_ERR
5772 "beiscsi_module_init - Unable to register beiscsi pci driver.\n");
5773 goto unregister_iscsi_transport;
5774 }
5775 return 0;
5776
5777 unregister_iscsi_transport:
5778 iscsi_unregister_transport(&beiscsi_iscsi_transport);
5779 return ret;
5780 }
5781
5782 static void __exit beiscsi_module_exit(void)
5783 {
5784 pci_unregister_driver(&beiscsi_pci_driver);
5785 iscsi_unregister_transport(&beiscsi_iscsi_transport);
5786 }
5787
5788 module_init(beiscsi_module_init);
5789 module_exit(beiscsi_module_exit);
5790
5791
5792
5793
5794
5795 /* LDV_COMMENT_BEGIN_MAIN */
5796 #ifdef LDV_MAIN1_sequence_infinite_withcheck_stateful
5797
5798 /*###########################################################################*/
5799
5800 /*############## Driver Environment Generator 0.2 output ####################*/
5801
5802 /*###########################################################################*/
5803
5804
5805
5806 /* 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. */
5807 void ldv_check_final_state(void);
5808
5809 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result. */
5810 void ldv_check_return_value(int res);
5811
5812 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Test correct return result of probe() function. */
5813 void ldv_check_return_value_probe(int res);
5814
5815 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Initializes the model. */
5816 void ldv_initialize(void);
5817
5818 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Reinitializes the model between distinct model function calls. */
5819 void ldv_handler_precall(void);
5820
5821 /* LDV_COMMENT_FUNCTION_DECLARE_LDV Special function for LDV verifier. Returns arbitrary interger value. */
5822 int nondet_int(void);
5823
5824 /* LDV_COMMENT_VAR_DECLARE_LDV Special variable for LDV verifier. */
5825 int LDV_IN_INTERRUPT;
5826
5827 /* LDV_COMMENT_FUNCTION_MAIN Main function for LDV verifier. */
5828 void ldv_main1_sequence_infinite_withcheck_stateful(void) {
5829
5830
5831
5832 /* LDV_COMMENT_BEGIN_VARIABLE_DECLARATION_PART */
5833 /*============================= VARIABLE DECLARATION PART =============================*/
5834 /** STRUCT: struct type: scsi_host_template, struct name: beiscsi_sht **/
5835 /* content: static int beiscsi_slave_configure(struct scsi_device *sdev)*/
5836 /* LDV_COMMENT_BEGIN_PREP */
5837 #define beiscsi_disp_param(_name)\
5838 ssize_t \
5839 beiscsi_##_name##_disp(struct device *dev,\
5840 struct device_attribute *attrib, char *buf) \
5841 { \
5842 struct Scsi_Host *shost = class_to_shost(dev);\
5843 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
5844 uint32_t param_val = 0; \
5845 param_val = phba->attr_##_name;\
5846 return snprintf(buf, PAGE_SIZE, "%d\n",\
5847 phba->attr_##_name);\
5848 }
5849 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
5850 int \
5851 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
5852 {\
5853 if (val >= _minval && val <= _maxval) {\
5854 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
5855 "BA_%d : beiscsi_"#_name" updated "\
5856 "from 0x%x ==> 0x%x\n",\
5857 phba->attr_##_name, val); \
5858 phba->attr_##_name = val;\
5859 return 0;\
5860 } \
5861 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
5862 "BA_%d beiscsi_"#_name" attribute "\
5863 "cannot be updated to 0x%x, "\
5864 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
5865 return -EINVAL;\
5866 }
5867 #define beiscsi_store_param(_name) \
5868 ssize_t \
5869 beiscsi_##_name##_store(struct device *dev,\
5870 struct device_attribute *attr, const char *buf,\
5871 size_t count) \
5872 { \
5873 struct Scsi_Host *shost = class_to_shost(dev);\
5874 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
5875 uint32_t param_val = 0;\
5876 if (!isdigit(buf[0]))\
5877 return -EINVAL;\
5878 if (sscanf(buf, "%i", ¶m_val) != 1)\
5879 return -EINVAL;\
5880 if (beiscsi_##_name##_change(phba, param_val) == 0) \
5881 return strlen(buf);\
5882 else \
5883 return -EINVAL;\
5884 }
5885 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
5886 int \
5887 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
5888 { \
5889 if (val >= _minval && val <= _maxval) {\
5890 phba->attr_##_name = val;\
5891 return 0;\
5892 } \
5893 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
5894 "BA_%d beiscsi_"#_name" attribute " \
5895 "cannot be updated to 0x%x, "\
5896 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
5897 phba->attr_##_name = _defval;\
5898 return -EINVAL;\
5899 }
5900 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
5901 static uint beiscsi_##_name = _defval;\
5902 module_param(beiscsi_##_name, uint, S_IRUGO);\
5903 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
5904 beiscsi_disp_param(_name)\
5905 beiscsi_change_param(_name, _minval, _maxval, _defval)\
5906 beiscsi_store_param(_name)\
5907 beiscsi_init_param(_name, _minval, _maxval, _defval)\
5908 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
5909 beiscsi_##_name##_disp, beiscsi_##_name##_store)
5910 /* LDV_COMMENT_END_PREP */
5911 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_slave_configure" */
5912 struct scsi_device * var_group1;
5913 /* content: static int beiscsi_eh_abort(struct scsi_cmnd *sc)*/
5914 /* LDV_COMMENT_BEGIN_PREP */
5915 #define beiscsi_disp_param(_name)\
5916 ssize_t \
5917 beiscsi_##_name##_disp(struct device *dev,\
5918 struct device_attribute *attrib, char *buf) \
5919 { \
5920 struct Scsi_Host *shost = class_to_shost(dev);\
5921 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
5922 uint32_t param_val = 0; \
5923 param_val = phba->attr_##_name;\
5924 return snprintf(buf, PAGE_SIZE, "%d\n",\
5925 phba->attr_##_name);\
5926 }
5927 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
5928 int \
5929 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
5930 {\
5931 if (val >= _minval && val <= _maxval) {\
5932 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
5933 "BA_%d : beiscsi_"#_name" updated "\
5934 "from 0x%x ==> 0x%x\n",\
5935 phba->attr_##_name, val); \
5936 phba->attr_##_name = val;\
5937 return 0;\
5938 } \
5939 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
5940 "BA_%d beiscsi_"#_name" attribute "\
5941 "cannot be updated to 0x%x, "\
5942 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
5943 return -EINVAL;\
5944 }
5945 #define beiscsi_store_param(_name) \
5946 ssize_t \
5947 beiscsi_##_name##_store(struct device *dev,\
5948 struct device_attribute *attr, const char *buf,\
5949 size_t count) \
5950 { \
5951 struct Scsi_Host *shost = class_to_shost(dev);\
5952 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
5953 uint32_t param_val = 0;\
5954 if (!isdigit(buf[0]))\
5955 return -EINVAL;\
5956 if (sscanf(buf, "%i", ¶m_val) != 1)\
5957 return -EINVAL;\
5958 if (beiscsi_##_name##_change(phba, param_val) == 0) \
5959 return strlen(buf);\
5960 else \
5961 return -EINVAL;\
5962 }
5963 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
5964 int \
5965 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
5966 { \
5967 if (val >= _minval && val <= _maxval) {\
5968 phba->attr_##_name = val;\
5969 return 0;\
5970 } \
5971 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
5972 "BA_%d beiscsi_"#_name" attribute " \
5973 "cannot be updated to 0x%x, "\
5974 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
5975 phba->attr_##_name = _defval;\
5976 return -EINVAL;\
5977 }
5978 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
5979 static uint beiscsi_##_name = _defval;\
5980 module_param(beiscsi_##_name, uint, S_IRUGO);\
5981 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
5982 beiscsi_disp_param(_name)\
5983 beiscsi_change_param(_name, _minval, _maxval, _defval)\
5984 beiscsi_store_param(_name)\
5985 beiscsi_init_param(_name, _minval, _maxval, _defval)\
5986 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
5987 beiscsi_##_name##_disp, beiscsi_##_name##_store)
5988 /* LDV_COMMENT_END_PREP */
5989 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_eh_abort" */
5990 struct scsi_cmnd * var_group2;
5991 /* content: static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)*/
5992 /* LDV_COMMENT_BEGIN_PREP */
5993 #define beiscsi_disp_param(_name)\
5994 ssize_t \
5995 beiscsi_##_name##_disp(struct device *dev,\
5996 struct device_attribute *attrib, char *buf) \
5997 { \
5998 struct Scsi_Host *shost = class_to_shost(dev);\
5999 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
6000 uint32_t param_val = 0; \
6001 param_val = phba->attr_##_name;\
6002 return snprintf(buf, PAGE_SIZE, "%d\n",\
6003 phba->attr_##_name);\
6004 }
6005 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
6006 int \
6007 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
6008 {\
6009 if (val >= _minval && val <= _maxval) {\
6010 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6011 "BA_%d : beiscsi_"#_name" updated "\
6012 "from 0x%x ==> 0x%x\n",\
6013 phba->attr_##_name, val); \
6014 phba->attr_##_name = val;\
6015 return 0;\
6016 } \
6017 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
6018 "BA_%d beiscsi_"#_name" attribute "\
6019 "cannot be updated to 0x%x, "\
6020 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6021 return -EINVAL;\
6022 }
6023 #define beiscsi_store_param(_name) \
6024 ssize_t \
6025 beiscsi_##_name##_store(struct device *dev,\
6026 struct device_attribute *attr, const char *buf,\
6027 size_t count) \
6028 { \
6029 struct Scsi_Host *shost = class_to_shost(dev);\
6030 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
6031 uint32_t param_val = 0;\
6032 if (!isdigit(buf[0]))\
6033 return -EINVAL;\
6034 if (sscanf(buf, "%i", ¶m_val) != 1)\
6035 return -EINVAL;\
6036 if (beiscsi_##_name##_change(phba, param_val) == 0) \
6037 return strlen(buf);\
6038 else \
6039 return -EINVAL;\
6040 }
6041 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
6042 int \
6043 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
6044 { \
6045 if (val >= _minval && val <= _maxval) {\
6046 phba->attr_##_name = val;\
6047 return 0;\
6048 } \
6049 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6050 "BA_%d beiscsi_"#_name" attribute " \
6051 "cannot be updated to 0x%x, "\
6052 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6053 phba->attr_##_name = _defval;\
6054 return -EINVAL;\
6055 }
6056 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
6057 static uint beiscsi_##_name = _defval;\
6058 module_param(beiscsi_##_name, uint, S_IRUGO);\
6059 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
6060 beiscsi_disp_param(_name)\
6061 beiscsi_change_param(_name, _minval, _maxval, _defval)\
6062 beiscsi_store_param(_name)\
6063 beiscsi_init_param(_name, _minval, _maxval, _defval)\
6064 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
6065 beiscsi_##_name##_disp, beiscsi_##_name##_store)
6066 /* LDV_COMMENT_END_PREP */
6067
6068 /** STRUCT: struct type: pci_error_handlers, struct name: beiscsi_eeh_handlers **/
6069 /* content: static pci_ers_result_t beiscsi_eeh_err_detected(struct pci_dev *pdev, pci_channel_state_t state)*/
6070 /* LDV_COMMENT_BEGIN_PREP */
6071 #define beiscsi_disp_param(_name)\
6072 ssize_t \
6073 beiscsi_##_name##_disp(struct device *dev,\
6074 struct device_attribute *attrib, char *buf) \
6075 { \
6076 struct Scsi_Host *shost = class_to_shost(dev);\
6077 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
6078 uint32_t param_val = 0; \
6079 param_val = phba->attr_##_name;\
6080 return snprintf(buf, PAGE_SIZE, "%d\n",\
6081 phba->attr_##_name);\
6082 }
6083 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
6084 int \
6085 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
6086 {\
6087 if (val >= _minval && val <= _maxval) {\
6088 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6089 "BA_%d : beiscsi_"#_name" updated "\
6090 "from 0x%x ==> 0x%x\n",\
6091 phba->attr_##_name, val); \
6092 phba->attr_##_name = val;\
6093 return 0;\
6094 } \
6095 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
6096 "BA_%d beiscsi_"#_name" attribute "\
6097 "cannot be updated to 0x%x, "\
6098 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6099 return -EINVAL;\
6100 }
6101 #define beiscsi_store_param(_name) \
6102 ssize_t \
6103 beiscsi_##_name##_store(struct device *dev,\
6104 struct device_attribute *attr, const char *buf,\
6105 size_t count) \
6106 { \
6107 struct Scsi_Host *shost = class_to_shost(dev);\
6108 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
6109 uint32_t param_val = 0;\
6110 if (!isdigit(buf[0]))\
6111 return -EINVAL;\
6112 if (sscanf(buf, "%i", ¶m_val) != 1)\
6113 return -EINVAL;\
6114 if (beiscsi_##_name##_change(phba, param_val) == 0) \
6115 return strlen(buf);\
6116 else \
6117 return -EINVAL;\
6118 }
6119 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
6120 int \
6121 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
6122 { \
6123 if (val >= _minval && val <= _maxval) {\
6124 phba->attr_##_name = val;\
6125 return 0;\
6126 } \
6127 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6128 "BA_%d beiscsi_"#_name" attribute " \
6129 "cannot be updated to 0x%x, "\
6130 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6131 phba->attr_##_name = _defval;\
6132 return -EINVAL;\
6133 }
6134 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
6135 static uint beiscsi_##_name = _defval;\
6136 module_param(beiscsi_##_name, uint, S_IRUGO);\
6137 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
6138 beiscsi_disp_param(_name)\
6139 beiscsi_change_param(_name, _minval, _maxval, _defval)\
6140 beiscsi_store_param(_name)\
6141 beiscsi_init_param(_name, _minval, _maxval, _defval)\
6142 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
6143 beiscsi_##_name##_disp, beiscsi_##_name##_store)
6144 /* LDV_COMMENT_END_PREP */
6145 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_eeh_err_detected" */
6146 struct pci_dev * var_group3;
6147 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_eeh_err_detected" */
6148 pci_channel_state_t var_beiscsi_eeh_err_detected_107_p1;
6149 /* content: static pci_ers_result_t beiscsi_eeh_reset(struct pci_dev *pdev)*/
6150 /* LDV_COMMENT_BEGIN_PREP */
6151 #define beiscsi_disp_param(_name)\
6152 ssize_t \
6153 beiscsi_##_name##_disp(struct device *dev,\
6154 struct device_attribute *attrib, char *buf) \
6155 { \
6156 struct Scsi_Host *shost = class_to_shost(dev);\
6157 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
6158 uint32_t param_val = 0; \
6159 param_val = phba->attr_##_name;\
6160 return snprintf(buf, PAGE_SIZE, "%d\n",\
6161 phba->attr_##_name);\
6162 }
6163 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
6164 int \
6165 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
6166 {\
6167 if (val >= _minval && val <= _maxval) {\
6168 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6169 "BA_%d : beiscsi_"#_name" updated "\
6170 "from 0x%x ==> 0x%x\n",\
6171 phba->attr_##_name, val); \
6172 phba->attr_##_name = val;\
6173 return 0;\
6174 } \
6175 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
6176 "BA_%d beiscsi_"#_name" attribute "\
6177 "cannot be updated to 0x%x, "\
6178 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6179 return -EINVAL;\
6180 }
6181 #define beiscsi_store_param(_name) \
6182 ssize_t \
6183 beiscsi_##_name##_store(struct device *dev,\
6184 struct device_attribute *attr, const char *buf,\
6185 size_t count) \
6186 { \
6187 struct Scsi_Host *shost = class_to_shost(dev);\
6188 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
6189 uint32_t param_val = 0;\
6190 if (!isdigit(buf[0]))\
6191 return -EINVAL;\
6192 if (sscanf(buf, "%i", ¶m_val) != 1)\
6193 return -EINVAL;\
6194 if (beiscsi_##_name##_change(phba, param_val) == 0) \
6195 return strlen(buf);\
6196 else \
6197 return -EINVAL;\
6198 }
6199 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
6200 int \
6201 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
6202 { \
6203 if (val >= _minval && val <= _maxval) {\
6204 phba->attr_##_name = val;\
6205 return 0;\
6206 } \
6207 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6208 "BA_%d beiscsi_"#_name" attribute " \
6209 "cannot be updated to 0x%x, "\
6210 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6211 phba->attr_##_name = _defval;\
6212 return -EINVAL;\
6213 }
6214 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
6215 static uint beiscsi_##_name = _defval;\
6216 module_param(beiscsi_##_name, uint, S_IRUGO);\
6217 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
6218 beiscsi_disp_param(_name)\
6219 beiscsi_change_param(_name, _minval, _maxval, _defval)\
6220 beiscsi_store_param(_name)\
6221 beiscsi_init_param(_name, _minval, _maxval, _defval)\
6222 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
6223 beiscsi_##_name##_disp, beiscsi_##_name##_store)
6224 /* LDV_COMMENT_END_PREP */
6225 /* content: static void beiscsi_eeh_resume(struct pci_dev *pdev)*/
6226 /* LDV_COMMENT_BEGIN_PREP */
6227 #define beiscsi_disp_param(_name)\
6228 ssize_t \
6229 beiscsi_##_name##_disp(struct device *dev,\
6230 struct device_attribute *attrib, char *buf) \
6231 { \
6232 struct Scsi_Host *shost = class_to_shost(dev);\
6233 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
6234 uint32_t param_val = 0; \
6235 param_val = phba->attr_##_name;\
6236 return snprintf(buf, PAGE_SIZE, "%d\n",\
6237 phba->attr_##_name);\
6238 }
6239 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
6240 int \
6241 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
6242 {\
6243 if (val >= _minval && val <= _maxval) {\
6244 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6245 "BA_%d : beiscsi_"#_name" updated "\
6246 "from 0x%x ==> 0x%x\n",\
6247 phba->attr_##_name, val); \
6248 phba->attr_##_name = val;\
6249 return 0;\
6250 } \
6251 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
6252 "BA_%d beiscsi_"#_name" attribute "\
6253 "cannot be updated to 0x%x, "\
6254 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6255 return -EINVAL;\
6256 }
6257 #define beiscsi_store_param(_name) \
6258 ssize_t \
6259 beiscsi_##_name##_store(struct device *dev,\
6260 struct device_attribute *attr, const char *buf,\
6261 size_t count) \
6262 { \
6263 struct Scsi_Host *shost = class_to_shost(dev);\
6264 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
6265 uint32_t param_val = 0;\
6266 if (!isdigit(buf[0]))\
6267 return -EINVAL;\
6268 if (sscanf(buf, "%i", ¶m_val) != 1)\
6269 return -EINVAL;\
6270 if (beiscsi_##_name##_change(phba, param_val) == 0) \
6271 return strlen(buf);\
6272 else \
6273 return -EINVAL;\
6274 }
6275 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
6276 int \
6277 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
6278 { \
6279 if (val >= _minval && val <= _maxval) {\
6280 phba->attr_##_name = val;\
6281 return 0;\
6282 } \
6283 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6284 "BA_%d beiscsi_"#_name" attribute " \
6285 "cannot be updated to 0x%x, "\
6286 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6287 phba->attr_##_name = _defval;\
6288 return -EINVAL;\
6289 }
6290 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
6291 static uint beiscsi_##_name = _defval;\
6292 module_param(beiscsi_##_name, uint, S_IRUGO);\
6293 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
6294 beiscsi_disp_param(_name)\
6295 beiscsi_change_param(_name, _minval, _maxval, _defval)\
6296 beiscsi_store_param(_name)\
6297 beiscsi_init_param(_name, _minval, _maxval, _defval)\
6298 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
6299 beiscsi_##_name##_disp, beiscsi_##_name##_store)
6300 /* LDV_COMMENT_END_PREP */
6301
6302 /** STRUCT: struct type: iscsi_transport, struct name: beiscsi_iscsi_transport **/
6303 /* content: static int beiscsi_task_xmit(struct iscsi_task *task)*/
6304 /* LDV_COMMENT_BEGIN_PREP */
6305 #define beiscsi_disp_param(_name)\
6306 ssize_t \
6307 beiscsi_##_name##_disp(struct device *dev,\
6308 struct device_attribute *attrib, char *buf) \
6309 { \
6310 struct Scsi_Host *shost = class_to_shost(dev);\
6311 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
6312 uint32_t param_val = 0; \
6313 param_val = phba->attr_##_name;\
6314 return snprintf(buf, PAGE_SIZE, "%d\n",\
6315 phba->attr_##_name);\
6316 }
6317 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
6318 int \
6319 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
6320 {\
6321 if (val >= _minval && val <= _maxval) {\
6322 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6323 "BA_%d : beiscsi_"#_name" updated "\
6324 "from 0x%x ==> 0x%x\n",\
6325 phba->attr_##_name, val); \
6326 phba->attr_##_name = val;\
6327 return 0;\
6328 } \
6329 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
6330 "BA_%d beiscsi_"#_name" attribute "\
6331 "cannot be updated to 0x%x, "\
6332 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6333 return -EINVAL;\
6334 }
6335 #define beiscsi_store_param(_name) \
6336 ssize_t \
6337 beiscsi_##_name##_store(struct device *dev,\
6338 struct device_attribute *attr, const char *buf,\
6339 size_t count) \
6340 { \
6341 struct Scsi_Host *shost = class_to_shost(dev);\
6342 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
6343 uint32_t param_val = 0;\
6344 if (!isdigit(buf[0]))\
6345 return -EINVAL;\
6346 if (sscanf(buf, "%i", ¶m_val) != 1)\
6347 return -EINVAL;\
6348 if (beiscsi_##_name##_change(phba, param_val) == 0) \
6349 return strlen(buf);\
6350 else \
6351 return -EINVAL;\
6352 }
6353 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
6354 int \
6355 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
6356 { \
6357 if (val >= _minval && val <= _maxval) {\
6358 phba->attr_##_name = val;\
6359 return 0;\
6360 } \
6361 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6362 "BA_%d beiscsi_"#_name" attribute " \
6363 "cannot be updated to 0x%x, "\
6364 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6365 phba->attr_##_name = _defval;\
6366 return -EINVAL;\
6367 }
6368 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
6369 static uint beiscsi_##_name = _defval;\
6370 module_param(beiscsi_##_name, uint, S_IRUGO);\
6371 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
6372 beiscsi_disp_param(_name)\
6373 beiscsi_change_param(_name, _minval, _maxval, _defval)\
6374 beiscsi_store_param(_name)\
6375 beiscsi_init_param(_name, _minval, _maxval, _defval)\
6376 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
6377 beiscsi_##_name##_disp, beiscsi_##_name##_store)
6378 /* LDV_COMMENT_END_PREP */
6379 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_task_xmit" */
6380 struct iscsi_task * var_group4;
6381 /* content: static void beiscsi_cleanup_task(struct iscsi_task *task)*/
6382 /* LDV_COMMENT_BEGIN_PREP */
6383 #define beiscsi_disp_param(_name)\
6384 ssize_t \
6385 beiscsi_##_name##_disp(struct device *dev,\
6386 struct device_attribute *attrib, char *buf) \
6387 { \
6388 struct Scsi_Host *shost = class_to_shost(dev);\
6389 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
6390 uint32_t param_val = 0; \
6391 param_val = phba->attr_##_name;\
6392 return snprintf(buf, PAGE_SIZE, "%d\n",\
6393 phba->attr_##_name);\
6394 }
6395 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
6396 int \
6397 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
6398 {\
6399 if (val >= _minval && val <= _maxval) {\
6400 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6401 "BA_%d : beiscsi_"#_name" updated "\
6402 "from 0x%x ==> 0x%x\n",\
6403 phba->attr_##_name, val); \
6404 phba->attr_##_name = val;\
6405 return 0;\
6406 } \
6407 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
6408 "BA_%d beiscsi_"#_name" attribute "\
6409 "cannot be updated to 0x%x, "\
6410 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6411 return -EINVAL;\
6412 }
6413 #define beiscsi_store_param(_name) \
6414 ssize_t \
6415 beiscsi_##_name##_store(struct device *dev,\
6416 struct device_attribute *attr, const char *buf,\
6417 size_t count) \
6418 { \
6419 struct Scsi_Host *shost = class_to_shost(dev);\
6420 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
6421 uint32_t param_val = 0;\
6422 if (!isdigit(buf[0]))\
6423 return -EINVAL;\
6424 if (sscanf(buf, "%i", ¶m_val) != 1)\
6425 return -EINVAL;\
6426 if (beiscsi_##_name##_change(phba, param_val) == 0) \
6427 return strlen(buf);\
6428 else \
6429 return -EINVAL;\
6430 }
6431 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
6432 int \
6433 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
6434 { \
6435 if (val >= _minval && val <= _maxval) {\
6436 phba->attr_##_name = val;\
6437 return 0;\
6438 } \
6439 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6440 "BA_%d beiscsi_"#_name" attribute " \
6441 "cannot be updated to 0x%x, "\
6442 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6443 phba->attr_##_name = _defval;\
6444 return -EINVAL;\
6445 }
6446 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
6447 static uint beiscsi_##_name = _defval;\
6448 module_param(beiscsi_##_name, uint, S_IRUGO);\
6449 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
6450 beiscsi_disp_param(_name)\
6451 beiscsi_change_param(_name, _minval, _maxval, _defval)\
6452 beiscsi_store_param(_name)\
6453 beiscsi_init_param(_name, _minval, _maxval, _defval)\
6454 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
6455 beiscsi_##_name##_disp, beiscsi_##_name##_store)
6456 /* LDV_COMMENT_END_PREP */
6457 /* content: static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode)*/
6458 /* LDV_COMMENT_BEGIN_PREP */
6459 #define beiscsi_disp_param(_name)\
6460 ssize_t \
6461 beiscsi_##_name##_disp(struct device *dev,\
6462 struct device_attribute *attrib, char *buf) \
6463 { \
6464 struct Scsi_Host *shost = class_to_shost(dev);\
6465 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
6466 uint32_t param_val = 0; \
6467 param_val = phba->attr_##_name;\
6468 return snprintf(buf, PAGE_SIZE, "%d\n",\
6469 phba->attr_##_name);\
6470 }
6471 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
6472 int \
6473 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
6474 {\
6475 if (val >= _minval && val <= _maxval) {\
6476 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6477 "BA_%d : beiscsi_"#_name" updated "\
6478 "from 0x%x ==> 0x%x\n",\
6479 phba->attr_##_name, val); \
6480 phba->attr_##_name = val;\
6481 return 0;\
6482 } \
6483 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
6484 "BA_%d beiscsi_"#_name" attribute "\
6485 "cannot be updated to 0x%x, "\
6486 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6487 return -EINVAL;\
6488 }
6489 #define beiscsi_store_param(_name) \
6490 ssize_t \
6491 beiscsi_##_name##_store(struct device *dev,\
6492 struct device_attribute *attr, const char *buf,\
6493 size_t count) \
6494 { \
6495 struct Scsi_Host *shost = class_to_shost(dev);\
6496 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
6497 uint32_t param_val = 0;\
6498 if (!isdigit(buf[0]))\
6499 return -EINVAL;\
6500 if (sscanf(buf, "%i", ¶m_val) != 1)\
6501 return -EINVAL;\
6502 if (beiscsi_##_name##_change(phba, param_val) == 0) \
6503 return strlen(buf);\
6504 else \
6505 return -EINVAL;\
6506 }
6507 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
6508 int \
6509 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
6510 { \
6511 if (val >= _minval && val <= _maxval) {\
6512 phba->attr_##_name = val;\
6513 return 0;\
6514 } \
6515 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6516 "BA_%d beiscsi_"#_name" attribute " \
6517 "cannot be updated to 0x%x, "\
6518 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6519 phba->attr_##_name = _defval;\
6520 return -EINVAL;\
6521 }
6522 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
6523 static uint beiscsi_##_name = _defval;\
6524 module_param(beiscsi_##_name, uint, S_IRUGO);\
6525 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
6526 beiscsi_disp_param(_name)\
6527 beiscsi_change_param(_name, _minval, _maxval, _defval)\
6528 beiscsi_store_param(_name)\
6529 beiscsi_init_param(_name, _minval, _maxval, _defval)\
6530 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
6531 beiscsi_##_name##_disp, beiscsi_##_name##_store)
6532 /* LDV_COMMENT_END_PREP */
6533 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_alloc_pdu" */
6534 uint8_t var_beiscsi_alloc_pdu_95_p1;
6535 /* content: static void beiscsi_parse_pdu(struct iscsi_conn *conn, itt_t itt, int *index, int *age)*/
6536 /* LDV_COMMENT_BEGIN_PREP */
6537 #define beiscsi_disp_param(_name)\
6538 ssize_t \
6539 beiscsi_##_name##_disp(struct device *dev,\
6540 struct device_attribute *attrib, char *buf) \
6541 { \
6542 struct Scsi_Host *shost = class_to_shost(dev);\
6543 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
6544 uint32_t param_val = 0; \
6545 param_val = phba->attr_##_name;\
6546 return snprintf(buf, PAGE_SIZE, "%d\n",\
6547 phba->attr_##_name);\
6548 }
6549 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
6550 int \
6551 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
6552 {\
6553 if (val >= _minval && val <= _maxval) {\
6554 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6555 "BA_%d : beiscsi_"#_name" updated "\
6556 "from 0x%x ==> 0x%x\n",\
6557 phba->attr_##_name, val); \
6558 phba->attr_##_name = val;\
6559 return 0;\
6560 } \
6561 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
6562 "BA_%d beiscsi_"#_name" attribute "\
6563 "cannot be updated to 0x%x, "\
6564 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6565 return -EINVAL;\
6566 }
6567 #define beiscsi_store_param(_name) \
6568 ssize_t \
6569 beiscsi_##_name##_store(struct device *dev,\
6570 struct device_attribute *attr, const char *buf,\
6571 size_t count) \
6572 { \
6573 struct Scsi_Host *shost = class_to_shost(dev);\
6574 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
6575 uint32_t param_val = 0;\
6576 if (!isdigit(buf[0]))\
6577 return -EINVAL;\
6578 if (sscanf(buf, "%i", ¶m_val) != 1)\
6579 return -EINVAL;\
6580 if (beiscsi_##_name##_change(phba, param_val) == 0) \
6581 return strlen(buf);\
6582 else \
6583 return -EINVAL;\
6584 }
6585 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
6586 int \
6587 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
6588 { \
6589 if (val >= _minval && val <= _maxval) {\
6590 phba->attr_##_name = val;\
6591 return 0;\
6592 } \
6593 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6594 "BA_%d beiscsi_"#_name" attribute " \
6595 "cannot be updated to 0x%x, "\
6596 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6597 phba->attr_##_name = _defval;\
6598 return -EINVAL;\
6599 }
6600 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
6601 static uint beiscsi_##_name = _defval;\
6602 module_param(beiscsi_##_name, uint, S_IRUGO);\
6603 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
6604 beiscsi_disp_param(_name)\
6605 beiscsi_change_param(_name, _minval, _maxval, _defval)\
6606 beiscsi_store_param(_name)\
6607 beiscsi_init_param(_name, _minval, _maxval, _defval)\
6608 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
6609 beiscsi_##_name##_disp, beiscsi_##_name##_store)
6610 /* LDV_COMMENT_END_PREP */
6611 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_parse_pdu" */
6612 struct iscsi_conn * var_group5;
6613 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_parse_pdu" */
6614 itt_t var_beiscsi_parse_pdu_94_p1;
6615 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_parse_pdu" */
6616 int * var_beiscsi_parse_pdu_94_p2;
6617 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_parse_pdu" */
6618 int * var_beiscsi_parse_pdu_94_p3;
6619 /* content: static int beiscsi_bsg_request(struct bsg_job *job)*/
6620 /* LDV_COMMENT_BEGIN_PREP */
6621 #define beiscsi_disp_param(_name)\
6622 ssize_t \
6623 beiscsi_##_name##_disp(struct device *dev,\
6624 struct device_attribute *attrib, char *buf) \
6625 { \
6626 struct Scsi_Host *shost = class_to_shost(dev);\
6627 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
6628 uint32_t param_val = 0; \
6629 param_val = phba->attr_##_name;\
6630 return snprintf(buf, PAGE_SIZE, "%d\n",\
6631 phba->attr_##_name);\
6632 }
6633 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
6634 int \
6635 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
6636 {\
6637 if (val >= _minval && val <= _maxval) {\
6638 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6639 "BA_%d : beiscsi_"#_name" updated "\
6640 "from 0x%x ==> 0x%x\n",\
6641 phba->attr_##_name, val); \
6642 phba->attr_##_name = val;\
6643 return 0;\
6644 } \
6645 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
6646 "BA_%d beiscsi_"#_name" attribute "\
6647 "cannot be updated to 0x%x, "\
6648 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6649 return -EINVAL;\
6650 }
6651 #define beiscsi_store_param(_name) \
6652 ssize_t \
6653 beiscsi_##_name##_store(struct device *dev,\
6654 struct device_attribute *attr, const char *buf,\
6655 size_t count) \
6656 { \
6657 struct Scsi_Host *shost = class_to_shost(dev);\
6658 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
6659 uint32_t param_val = 0;\
6660 if (!isdigit(buf[0]))\
6661 return -EINVAL;\
6662 if (sscanf(buf, "%i", ¶m_val) != 1)\
6663 return -EINVAL;\
6664 if (beiscsi_##_name##_change(phba, param_val) == 0) \
6665 return strlen(buf);\
6666 else \
6667 return -EINVAL;\
6668 }
6669 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
6670 int \
6671 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
6672 { \
6673 if (val >= _minval && val <= _maxval) {\
6674 phba->attr_##_name = val;\
6675 return 0;\
6676 } \
6677 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6678 "BA_%d beiscsi_"#_name" attribute " \
6679 "cannot be updated to 0x%x, "\
6680 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6681 phba->attr_##_name = _defval;\
6682 return -EINVAL;\
6683 }
6684 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
6685 static uint beiscsi_##_name = _defval;\
6686 module_param(beiscsi_##_name, uint, S_IRUGO);\
6687 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
6688 beiscsi_disp_param(_name)\
6689 beiscsi_change_param(_name, _minval, _maxval, _defval)\
6690 beiscsi_store_param(_name)\
6691 beiscsi_init_param(_name, _minval, _maxval, _defval)\
6692 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
6693 beiscsi_##_name##_disp, beiscsi_##_name##_store)
6694 /* LDV_COMMENT_END_PREP */
6695 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_bsg_request" */
6696 struct bsg_job * var_group6;
6697
6698 /** STRUCT: struct type: pci_driver, struct name: beiscsi_pci_driver **/
6699 /* content: static int beiscsi_dev_probe(struct pci_dev *pcidev, const struct pci_device_id *id)*/
6700 /* LDV_COMMENT_BEGIN_PREP */
6701 #define beiscsi_disp_param(_name)\
6702 ssize_t \
6703 beiscsi_##_name##_disp(struct device *dev,\
6704 struct device_attribute *attrib, char *buf) \
6705 { \
6706 struct Scsi_Host *shost = class_to_shost(dev);\
6707 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
6708 uint32_t param_val = 0; \
6709 param_val = phba->attr_##_name;\
6710 return snprintf(buf, PAGE_SIZE, "%d\n",\
6711 phba->attr_##_name);\
6712 }
6713 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
6714 int \
6715 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
6716 {\
6717 if (val >= _minval && val <= _maxval) {\
6718 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6719 "BA_%d : beiscsi_"#_name" updated "\
6720 "from 0x%x ==> 0x%x\n",\
6721 phba->attr_##_name, val); \
6722 phba->attr_##_name = val;\
6723 return 0;\
6724 } \
6725 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
6726 "BA_%d beiscsi_"#_name" attribute "\
6727 "cannot be updated to 0x%x, "\
6728 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6729 return -EINVAL;\
6730 }
6731 #define beiscsi_store_param(_name) \
6732 ssize_t \
6733 beiscsi_##_name##_store(struct device *dev,\
6734 struct device_attribute *attr, const char *buf,\
6735 size_t count) \
6736 { \
6737 struct Scsi_Host *shost = class_to_shost(dev);\
6738 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
6739 uint32_t param_val = 0;\
6740 if (!isdigit(buf[0]))\
6741 return -EINVAL;\
6742 if (sscanf(buf, "%i", ¶m_val) != 1)\
6743 return -EINVAL;\
6744 if (beiscsi_##_name##_change(phba, param_val) == 0) \
6745 return strlen(buf);\
6746 else \
6747 return -EINVAL;\
6748 }
6749 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
6750 int \
6751 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
6752 { \
6753 if (val >= _minval && val <= _maxval) {\
6754 phba->attr_##_name = val;\
6755 return 0;\
6756 } \
6757 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6758 "BA_%d beiscsi_"#_name" attribute " \
6759 "cannot be updated to 0x%x, "\
6760 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6761 phba->attr_##_name = _defval;\
6762 return -EINVAL;\
6763 }
6764 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
6765 static uint beiscsi_##_name = _defval;\
6766 module_param(beiscsi_##_name, uint, S_IRUGO);\
6767 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
6768 beiscsi_disp_param(_name)\
6769 beiscsi_change_param(_name, _minval, _maxval, _defval)\
6770 beiscsi_store_param(_name)\
6771 beiscsi_init_param(_name, _minval, _maxval, _defval)\
6772 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
6773 beiscsi_##_name##_disp, beiscsi_##_name##_store)
6774 /* LDV_COMMENT_END_PREP */
6775 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "beiscsi_dev_probe" */
6776 const struct pci_device_id * var_beiscsi_dev_probe_110_p1;
6777 /* LDV_COMMENT_VAR_DECLARE Variable declaration for test return result from function call "beiscsi_dev_probe" */
6778 static int res_beiscsi_dev_probe_110;
6779 /* content: static void beiscsi_remove(struct pci_dev *pcidev)*/
6780 /* LDV_COMMENT_BEGIN_PREP */
6781 #define beiscsi_disp_param(_name)\
6782 ssize_t \
6783 beiscsi_##_name##_disp(struct device *dev,\
6784 struct device_attribute *attrib, char *buf) \
6785 { \
6786 struct Scsi_Host *shost = class_to_shost(dev);\
6787 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
6788 uint32_t param_val = 0; \
6789 param_val = phba->attr_##_name;\
6790 return snprintf(buf, PAGE_SIZE, "%d\n",\
6791 phba->attr_##_name);\
6792 }
6793 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
6794 int \
6795 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
6796 {\
6797 if (val >= _minval && val <= _maxval) {\
6798 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6799 "BA_%d : beiscsi_"#_name" updated "\
6800 "from 0x%x ==> 0x%x\n",\
6801 phba->attr_##_name, val); \
6802 phba->attr_##_name = val;\
6803 return 0;\
6804 } \
6805 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
6806 "BA_%d beiscsi_"#_name" attribute "\
6807 "cannot be updated to 0x%x, "\
6808 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6809 return -EINVAL;\
6810 }
6811 #define beiscsi_store_param(_name) \
6812 ssize_t \
6813 beiscsi_##_name##_store(struct device *dev,\
6814 struct device_attribute *attr, const char *buf,\
6815 size_t count) \
6816 { \
6817 struct Scsi_Host *shost = class_to_shost(dev);\
6818 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
6819 uint32_t param_val = 0;\
6820 if (!isdigit(buf[0]))\
6821 return -EINVAL;\
6822 if (sscanf(buf, "%i", ¶m_val) != 1)\
6823 return -EINVAL;\
6824 if (beiscsi_##_name##_change(phba, param_val) == 0) \
6825 return strlen(buf);\
6826 else \
6827 return -EINVAL;\
6828 }
6829 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
6830 int \
6831 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
6832 { \
6833 if (val >= _minval && val <= _maxval) {\
6834 phba->attr_##_name = val;\
6835 return 0;\
6836 } \
6837 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6838 "BA_%d beiscsi_"#_name" attribute " \
6839 "cannot be updated to 0x%x, "\
6840 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6841 phba->attr_##_name = _defval;\
6842 return -EINVAL;\
6843 }
6844 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
6845 static uint beiscsi_##_name = _defval;\
6846 module_param(beiscsi_##_name, uint, S_IRUGO);\
6847 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
6848 beiscsi_disp_param(_name)\
6849 beiscsi_change_param(_name, _minval, _maxval, _defval)\
6850 beiscsi_store_param(_name)\
6851 beiscsi_init_param(_name, _minval, _maxval, _defval)\
6852 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
6853 beiscsi_##_name##_disp, beiscsi_##_name##_store)
6854 /* LDV_COMMENT_END_PREP */
6855 /* content: static void beiscsi_shutdown(struct pci_dev *pcidev)*/
6856 /* LDV_COMMENT_BEGIN_PREP */
6857 #define beiscsi_disp_param(_name)\
6858 ssize_t \
6859 beiscsi_##_name##_disp(struct device *dev,\
6860 struct device_attribute *attrib, char *buf) \
6861 { \
6862 struct Scsi_Host *shost = class_to_shost(dev);\
6863 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
6864 uint32_t param_val = 0; \
6865 param_val = phba->attr_##_name;\
6866 return snprintf(buf, PAGE_SIZE, "%d\n",\
6867 phba->attr_##_name);\
6868 }
6869 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
6870 int \
6871 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
6872 {\
6873 if (val >= _minval && val <= _maxval) {\
6874 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6875 "BA_%d : beiscsi_"#_name" updated "\
6876 "from 0x%x ==> 0x%x\n",\
6877 phba->attr_##_name, val); \
6878 phba->attr_##_name = val;\
6879 return 0;\
6880 } \
6881 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
6882 "BA_%d beiscsi_"#_name" attribute "\
6883 "cannot be updated to 0x%x, "\
6884 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6885 return -EINVAL;\
6886 }
6887 #define beiscsi_store_param(_name) \
6888 ssize_t \
6889 beiscsi_##_name##_store(struct device *dev,\
6890 struct device_attribute *attr, const char *buf,\
6891 size_t count) \
6892 { \
6893 struct Scsi_Host *shost = class_to_shost(dev);\
6894 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
6895 uint32_t param_val = 0;\
6896 if (!isdigit(buf[0]))\
6897 return -EINVAL;\
6898 if (sscanf(buf, "%i", ¶m_val) != 1)\
6899 return -EINVAL;\
6900 if (beiscsi_##_name##_change(phba, param_val) == 0) \
6901 return strlen(buf);\
6902 else \
6903 return -EINVAL;\
6904 }
6905 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
6906 int \
6907 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
6908 { \
6909 if (val >= _minval && val <= _maxval) {\
6910 phba->attr_##_name = val;\
6911 return 0;\
6912 } \
6913 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6914 "BA_%d beiscsi_"#_name" attribute " \
6915 "cannot be updated to 0x%x, "\
6916 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6917 phba->attr_##_name = _defval;\
6918 return -EINVAL;\
6919 }
6920 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
6921 static uint beiscsi_##_name = _defval;\
6922 module_param(beiscsi_##_name, uint, S_IRUGO);\
6923 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
6924 beiscsi_disp_param(_name)\
6925 beiscsi_change_param(_name, _minval, _maxval, _defval)\
6926 beiscsi_store_param(_name)\
6927 beiscsi_init_param(_name, _minval, _maxval, _defval)\
6928 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
6929 beiscsi_##_name##_disp, beiscsi_##_name##_store)
6930 /* LDV_COMMENT_END_PREP */
6931
6932 /** CALLBACK SECTION request_irq **/
6933 /* content: static irqreturn_t be_isr(int irq, void *dev_id)*/
6934 /* LDV_COMMENT_BEGIN_PREP */
6935 #define beiscsi_disp_param(_name)\
6936 ssize_t \
6937 beiscsi_##_name##_disp(struct device *dev,\
6938 struct device_attribute *attrib, char *buf) \
6939 { \
6940 struct Scsi_Host *shost = class_to_shost(dev);\
6941 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
6942 uint32_t param_val = 0; \
6943 param_val = phba->attr_##_name;\
6944 return snprintf(buf, PAGE_SIZE, "%d\n",\
6945 phba->attr_##_name);\
6946 }
6947 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
6948 int \
6949 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
6950 {\
6951 if (val >= _minval && val <= _maxval) {\
6952 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6953 "BA_%d : beiscsi_"#_name" updated "\
6954 "from 0x%x ==> 0x%x\n",\
6955 phba->attr_##_name, val); \
6956 phba->attr_##_name = val;\
6957 return 0;\
6958 } \
6959 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
6960 "BA_%d beiscsi_"#_name" attribute "\
6961 "cannot be updated to 0x%x, "\
6962 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6963 return -EINVAL;\
6964 }
6965 #define beiscsi_store_param(_name) \
6966 ssize_t \
6967 beiscsi_##_name##_store(struct device *dev,\
6968 struct device_attribute *attr, const char *buf,\
6969 size_t count) \
6970 { \
6971 struct Scsi_Host *shost = class_to_shost(dev);\
6972 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
6973 uint32_t param_val = 0;\
6974 if (!isdigit(buf[0]))\
6975 return -EINVAL;\
6976 if (sscanf(buf, "%i", ¶m_val) != 1)\
6977 return -EINVAL;\
6978 if (beiscsi_##_name##_change(phba, param_val) == 0) \
6979 return strlen(buf);\
6980 else \
6981 return -EINVAL;\
6982 }
6983 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
6984 int \
6985 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
6986 { \
6987 if (val >= _minval && val <= _maxval) {\
6988 phba->attr_##_name = val;\
6989 return 0;\
6990 } \
6991 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
6992 "BA_%d beiscsi_"#_name" attribute " \
6993 "cannot be updated to 0x%x, "\
6994 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
6995 phba->attr_##_name = _defval;\
6996 return -EINVAL;\
6997 }
6998 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
6999 static uint beiscsi_##_name = _defval;\
7000 module_param(beiscsi_##_name, uint, S_IRUGO);\
7001 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
7002 beiscsi_disp_param(_name)\
7003 beiscsi_change_param(_name, _minval, _maxval, _defval)\
7004 beiscsi_store_param(_name)\
7005 beiscsi_init_param(_name, _minval, _maxval, _defval)\
7006 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
7007 beiscsi_##_name##_disp, beiscsi_##_name##_store)
7008 /* LDV_COMMENT_END_PREP */
7009 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "be_isr" */
7010 int var_be_isr_18_p0;
7011 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "be_isr" */
7012 void * var_be_isr_18_p1;
7013 /* content: static irqreturn_t be_isr_mcc(int irq, void *dev_id)*/
7014 /* LDV_COMMENT_BEGIN_PREP */
7015 #define beiscsi_disp_param(_name)\
7016 ssize_t \
7017 beiscsi_##_name##_disp(struct device *dev,\
7018 struct device_attribute *attrib, char *buf) \
7019 { \
7020 struct Scsi_Host *shost = class_to_shost(dev);\
7021 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
7022 uint32_t param_val = 0; \
7023 param_val = phba->attr_##_name;\
7024 return snprintf(buf, PAGE_SIZE, "%d\n",\
7025 phba->attr_##_name);\
7026 }
7027 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
7028 int \
7029 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
7030 {\
7031 if (val >= _minval && val <= _maxval) {\
7032 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7033 "BA_%d : beiscsi_"#_name" updated "\
7034 "from 0x%x ==> 0x%x\n",\
7035 phba->attr_##_name, val); \
7036 phba->attr_##_name = val;\
7037 return 0;\
7038 } \
7039 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
7040 "BA_%d beiscsi_"#_name" attribute "\
7041 "cannot be updated to 0x%x, "\
7042 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7043 return -EINVAL;\
7044 }
7045 #define beiscsi_store_param(_name) \
7046 ssize_t \
7047 beiscsi_##_name##_store(struct device *dev,\
7048 struct device_attribute *attr, const char *buf,\
7049 size_t count) \
7050 { \
7051 struct Scsi_Host *shost = class_to_shost(dev);\
7052 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
7053 uint32_t param_val = 0;\
7054 if (!isdigit(buf[0]))\
7055 return -EINVAL;\
7056 if (sscanf(buf, "%i", ¶m_val) != 1)\
7057 return -EINVAL;\
7058 if (beiscsi_##_name##_change(phba, param_val) == 0) \
7059 return strlen(buf);\
7060 else \
7061 return -EINVAL;\
7062 }
7063 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
7064 int \
7065 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
7066 { \
7067 if (val >= _minval && val <= _maxval) {\
7068 phba->attr_##_name = val;\
7069 return 0;\
7070 } \
7071 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7072 "BA_%d beiscsi_"#_name" attribute " \
7073 "cannot be updated to 0x%x, "\
7074 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7075 phba->attr_##_name = _defval;\
7076 return -EINVAL;\
7077 }
7078 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
7079 static uint beiscsi_##_name = _defval;\
7080 module_param(beiscsi_##_name, uint, S_IRUGO);\
7081 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
7082 beiscsi_disp_param(_name)\
7083 beiscsi_change_param(_name, _minval, _maxval, _defval)\
7084 beiscsi_store_param(_name)\
7085 beiscsi_init_param(_name, _minval, _maxval, _defval)\
7086 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
7087 beiscsi_##_name##_disp, beiscsi_##_name##_store)
7088 /* LDV_COMMENT_END_PREP */
7089 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "be_isr_mcc" */
7090 int var_be_isr_mcc_16_p0;
7091 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "be_isr_mcc" */
7092 void * var_be_isr_mcc_16_p1;
7093 /* content: static irqreturn_t be_isr_msix(int irq, void *dev_id)*/
7094 /* LDV_COMMENT_BEGIN_PREP */
7095 #define beiscsi_disp_param(_name)\
7096 ssize_t \
7097 beiscsi_##_name##_disp(struct device *dev,\
7098 struct device_attribute *attrib, char *buf) \
7099 { \
7100 struct Scsi_Host *shost = class_to_shost(dev);\
7101 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
7102 uint32_t param_val = 0; \
7103 param_val = phba->attr_##_name;\
7104 return snprintf(buf, PAGE_SIZE, "%d\n",\
7105 phba->attr_##_name);\
7106 }
7107 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
7108 int \
7109 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
7110 {\
7111 if (val >= _minval && val <= _maxval) {\
7112 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7113 "BA_%d : beiscsi_"#_name" updated "\
7114 "from 0x%x ==> 0x%x\n",\
7115 phba->attr_##_name, val); \
7116 phba->attr_##_name = val;\
7117 return 0;\
7118 } \
7119 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
7120 "BA_%d beiscsi_"#_name" attribute "\
7121 "cannot be updated to 0x%x, "\
7122 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7123 return -EINVAL;\
7124 }
7125 #define beiscsi_store_param(_name) \
7126 ssize_t \
7127 beiscsi_##_name##_store(struct device *dev,\
7128 struct device_attribute *attr, const char *buf,\
7129 size_t count) \
7130 { \
7131 struct Scsi_Host *shost = class_to_shost(dev);\
7132 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
7133 uint32_t param_val = 0;\
7134 if (!isdigit(buf[0]))\
7135 return -EINVAL;\
7136 if (sscanf(buf, "%i", ¶m_val) != 1)\
7137 return -EINVAL;\
7138 if (beiscsi_##_name##_change(phba, param_val) == 0) \
7139 return strlen(buf);\
7140 else \
7141 return -EINVAL;\
7142 }
7143 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
7144 int \
7145 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
7146 { \
7147 if (val >= _minval && val <= _maxval) {\
7148 phba->attr_##_name = val;\
7149 return 0;\
7150 } \
7151 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7152 "BA_%d beiscsi_"#_name" attribute " \
7153 "cannot be updated to 0x%x, "\
7154 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7155 phba->attr_##_name = _defval;\
7156 return -EINVAL;\
7157 }
7158 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
7159 static uint beiscsi_##_name = _defval;\
7160 module_param(beiscsi_##_name, uint, S_IRUGO);\
7161 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
7162 beiscsi_disp_param(_name)\
7163 beiscsi_change_param(_name, _minval, _maxval, _defval)\
7164 beiscsi_store_param(_name)\
7165 beiscsi_init_param(_name, _minval, _maxval, _defval)\
7166 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
7167 beiscsi_##_name##_disp, beiscsi_##_name##_store)
7168 /* LDV_COMMENT_END_PREP */
7169 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "be_isr_msix" */
7170 int var_be_isr_msix_17_p0;
7171 /* LDV_COMMENT_VAR_DECLARE Variable declaration for function "be_isr_msix" */
7172 void * var_be_isr_msix_17_p1;
7173
7174
7175
7176
7177 /* LDV_COMMENT_END_VARIABLE_DECLARATION_PART */
7178 /* LDV_COMMENT_BEGIN_VARIABLE_INITIALIZING_PART */
7179 /*============================= VARIABLE INITIALIZING PART =============================*/
7180 LDV_IN_INTERRUPT=1;
7181
7182
7183
7184
7185 /* LDV_COMMENT_END_VARIABLE_INITIALIZING_PART */
7186 /* LDV_COMMENT_BEGIN_FUNCTION_CALL_SECTION */
7187 /*============================= FUNCTION CALL SECTION =============================*/
7188 /* LDV_COMMENT_FUNCTION_CALL Initialize LDV model. */
7189 ldv_initialize();
7190
7191 /** INIT: init_type: ST_MODULE_INIT **/
7192 /* content: static int __init beiscsi_module_init(void)*/
7193 /* LDV_COMMENT_BEGIN_PREP */
7194 #define beiscsi_disp_param(_name)\
7195 ssize_t \
7196 beiscsi_##_name##_disp(struct device *dev,\
7197 struct device_attribute *attrib, char *buf) \
7198 { \
7199 struct Scsi_Host *shost = class_to_shost(dev);\
7200 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
7201 uint32_t param_val = 0; \
7202 param_val = phba->attr_##_name;\
7203 return snprintf(buf, PAGE_SIZE, "%d\n",\
7204 phba->attr_##_name);\
7205 }
7206 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
7207 int \
7208 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
7209 {\
7210 if (val >= _minval && val <= _maxval) {\
7211 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7212 "BA_%d : beiscsi_"#_name" updated "\
7213 "from 0x%x ==> 0x%x\n",\
7214 phba->attr_##_name, val); \
7215 phba->attr_##_name = val;\
7216 return 0;\
7217 } \
7218 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
7219 "BA_%d beiscsi_"#_name" attribute "\
7220 "cannot be updated to 0x%x, "\
7221 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7222 return -EINVAL;\
7223 }
7224 #define beiscsi_store_param(_name) \
7225 ssize_t \
7226 beiscsi_##_name##_store(struct device *dev,\
7227 struct device_attribute *attr, const char *buf,\
7228 size_t count) \
7229 { \
7230 struct Scsi_Host *shost = class_to_shost(dev);\
7231 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
7232 uint32_t param_val = 0;\
7233 if (!isdigit(buf[0]))\
7234 return -EINVAL;\
7235 if (sscanf(buf, "%i", ¶m_val) != 1)\
7236 return -EINVAL;\
7237 if (beiscsi_##_name##_change(phba, param_val) == 0) \
7238 return strlen(buf);\
7239 else \
7240 return -EINVAL;\
7241 }
7242 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
7243 int \
7244 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
7245 { \
7246 if (val >= _minval && val <= _maxval) {\
7247 phba->attr_##_name = val;\
7248 return 0;\
7249 } \
7250 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7251 "BA_%d beiscsi_"#_name" attribute " \
7252 "cannot be updated to 0x%x, "\
7253 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7254 phba->attr_##_name = _defval;\
7255 return -EINVAL;\
7256 }
7257 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
7258 static uint beiscsi_##_name = _defval;\
7259 module_param(beiscsi_##_name, uint, S_IRUGO);\
7260 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
7261 beiscsi_disp_param(_name)\
7262 beiscsi_change_param(_name, _minval, _maxval, _defval)\
7263 beiscsi_store_param(_name)\
7264 beiscsi_init_param(_name, _minval, _maxval, _defval)\
7265 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
7266 beiscsi_##_name##_disp, beiscsi_##_name##_store)
7267 /* LDV_COMMENT_END_PREP */
7268 /* LDV_COMMENT_FUNCTION_CALL Kernel calls driver init function after driver loading to kernel. This function declared as "MODULE_INIT(function name)". */
7269 ldv_handler_precall();
7270 if(beiscsi_module_init())
7271 goto ldv_final;
7272
7273
7274
7275
7276
7277
7278 int ldv_s_beiscsi_pci_driver_pci_driver = 0;
7279
7280
7281
7282
7283
7284 while( nondet_int()
7285 || !(ldv_s_beiscsi_pci_driver_pci_driver == 0)
7286 ) {
7287
7288 switch(nondet_int()) {
7289
7290 case 0: {
7291
7292 /** STRUCT: struct type: scsi_host_template, struct name: beiscsi_sht **/
7293
7294
7295 /* content: static int beiscsi_slave_configure(struct scsi_device *sdev)*/
7296 /* LDV_COMMENT_BEGIN_PREP */
7297 #define beiscsi_disp_param(_name)\
7298 ssize_t \
7299 beiscsi_##_name##_disp(struct device *dev,\
7300 struct device_attribute *attrib, char *buf) \
7301 { \
7302 struct Scsi_Host *shost = class_to_shost(dev);\
7303 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
7304 uint32_t param_val = 0; \
7305 param_val = phba->attr_##_name;\
7306 return snprintf(buf, PAGE_SIZE, "%d\n",\
7307 phba->attr_##_name);\
7308 }
7309 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
7310 int \
7311 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
7312 {\
7313 if (val >= _minval && val <= _maxval) {\
7314 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7315 "BA_%d : beiscsi_"#_name" updated "\
7316 "from 0x%x ==> 0x%x\n",\
7317 phba->attr_##_name, val); \
7318 phba->attr_##_name = val;\
7319 return 0;\
7320 } \
7321 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
7322 "BA_%d beiscsi_"#_name" attribute "\
7323 "cannot be updated to 0x%x, "\
7324 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7325 return -EINVAL;\
7326 }
7327 #define beiscsi_store_param(_name) \
7328 ssize_t \
7329 beiscsi_##_name##_store(struct device *dev,\
7330 struct device_attribute *attr, const char *buf,\
7331 size_t count) \
7332 { \
7333 struct Scsi_Host *shost = class_to_shost(dev);\
7334 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
7335 uint32_t param_val = 0;\
7336 if (!isdigit(buf[0]))\
7337 return -EINVAL;\
7338 if (sscanf(buf, "%i", ¶m_val) != 1)\
7339 return -EINVAL;\
7340 if (beiscsi_##_name##_change(phba, param_val) == 0) \
7341 return strlen(buf);\
7342 else \
7343 return -EINVAL;\
7344 }
7345 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
7346 int \
7347 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
7348 { \
7349 if (val >= _minval && val <= _maxval) {\
7350 phba->attr_##_name = val;\
7351 return 0;\
7352 } \
7353 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7354 "BA_%d beiscsi_"#_name" attribute " \
7355 "cannot be updated to 0x%x, "\
7356 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7357 phba->attr_##_name = _defval;\
7358 return -EINVAL;\
7359 }
7360 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
7361 static uint beiscsi_##_name = _defval;\
7362 module_param(beiscsi_##_name, uint, S_IRUGO);\
7363 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
7364 beiscsi_disp_param(_name)\
7365 beiscsi_change_param(_name, _minval, _maxval, _defval)\
7366 beiscsi_store_param(_name)\
7367 beiscsi_init_param(_name, _minval, _maxval, _defval)\
7368 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
7369 beiscsi_##_name##_disp, beiscsi_##_name##_store)
7370 /* LDV_COMMENT_END_PREP */
7371 /* LDV_COMMENT_FUNCTION_CALL Function from field "slave_configure" from driver structure with callbacks "beiscsi_sht" */
7372 ldv_handler_precall();
7373 beiscsi_slave_configure( var_group1);
7374
7375
7376
7377
7378 }
7379
7380 break;
7381 case 1: {
7382
7383 /** STRUCT: struct type: scsi_host_template, struct name: beiscsi_sht **/
7384
7385
7386 /* content: static int beiscsi_eh_abort(struct scsi_cmnd *sc)*/
7387 /* LDV_COMMENT_BEGIN_PREP */
7388 #define beiscsi_disp_param(_name)\
7389 ssize_t \
7390 beiscsi_##_name##_disp(struct device *dev,\
7391 struct device_attribute *attrib, char *buf) \
7392 { \
7393 struct Scsi_Host *shost = class_to_shost(dev);\
7394 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
7395 uint32_t param_val = 0; \
7396 param_val = phba->attr_##_name;\
7397 return snprintf(buf, PAGE_SIZE, "%d\n",\
7398 phba->attr_##_name);\
7399 }
7400 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
7401 int \
7402 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
7403 {\
7404 if (val >= _minval && val <= _maxval) {\
7405 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7406 "BA_%d : beiscsi_"#_name" updated "\
7407 "from 0x%x ==> 0x%x\n",\
7408 phba->attr_##_name, val); \
7409 phba->attr_##_name = val;\
7410 return 0;\
7411 } \
7412 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
7413 "BA_%d beiscsi_"#_name" attribute "\
7414 "cannot be updated to 0x%x, "\
7415 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7416 return -EINVAL;\
7417 }
7418 #define beiscsi_store_param(_name) \
7419 ssize_t \
7420 beiscsi_##_name##_store(struct device *dev,\
7421 struct device_attribute *attr, const char *buf,\
7422 size_t count) \
7423 { \
7424 struct Scsi_Host *shost = class_to_shost(dev);\
7425 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
7426 uint32_t param_val = 0;\
7427 if (!isdigit(buf[0]))\
7428 return -EINVAL;\
7429 if (sscanf(buf, "%i", ¶m_val) != 1)\
7430 return -EINVAL;\
7431 if (beiscsi_##_name##_change(phba, param_val) == 0) \
7432 return strlen(buf);\
7433 else \
7434 return -EINVAL;\
7435 }
7436 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
7437 int \
7438 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
7439 { \
7440 if (val >= _minval && val <= _maxval) {\
7441 phba->attr_##_name = val;\
7442 return 0;\
7443 } \
7444 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7445 "BA_%d beiscsi_"#_name" attribute " \
7446 "cannot be updated to 0x%x, "\
7447 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7448 phba->attr_##_name = _defval;\
7449 return -EINVAL;\
7450 }
7451 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
7452 static uint beiscsi_##_name = _defval;\
7453 module_param(beiscsi_##_name, uint, S_IRUGO);\
7454 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
7455 beiscsi_disp_param(_name)\
7456 beiscsi_change_param(_name, _minval, _maxval, _defval)\
7457 beiscsi_store_param(_name)\
7458 beiscsi_init_param(_name, _minval, _maxval, _defval)\
7459 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
7460 beiscsi_##_name##_disp, beiscsi_##_name##_store)
7461 /* LDV_COMMENT_END_PREP */
7462 /* LDV_COMMENT_FUNCTION_CALL Function from field "eh_abort_handler" from driver structure with callbacks "beiscsi_sht" */
7463 ldv_handler_precall();
7464 beiscsi_eh_abort( var_group2);
7465
7466
7467
7468
7469 }
7470
7471 break;
7472 case 2: {
7473
7474 /** STRUCT: struct type: scsi_host_template, struct name: beiscsi_sht **/
7475
7476
7477 /* content: static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)*/
7478 /* LDV_COMMENT_BEGIN_PREP */
7479 #define beiscsi_disp_param(_name)\
7480 ssize_t \
7481 beiscsi_##_name##_disp(struct device *dev,\
7482 struct device_attribute *attrib, char *buf) \
7483 { \
7484 struct Scsi_Host *shost = class_to_shost(dev);\
7485 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
7486 uint32_t param_val = 0; \
7487 param_val = phba->attr_##_name;\
7488 return snprintf(buf, PAGE_SIZE, "%d\n",\
7489 phba->attr_##_name);\
7490 }
7491 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
7492 int \
7493 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
7494 {\
7495 if (val >= _minval && val <= _maxval) {\
7496 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7497 "BA_%d : beiscsi_"#_name" updated "\
7498 "from 0x%x ==> 0x%x\n",\
7499 phba->attr_##_name, val); \
7500 phba->attr_##_name = val;\
7501 return 0;\
7502 } \
7503 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
7504 "BA_%d beiscsi_"#_name" attribute "\
7505 "cannot be updated to 0x%x, "\
7506 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7507 return -EINVAL;\
7508 }
7509 #define beiscsi_store_param(_name) \
7510 ssize_t \
7511 beiscsi_##_name##_store(struct device *dev,\
7512 struct device_attribute *attr, const char *buf,\
7513 size_t count) \
7514 { \
7515 struct Scsi_Host *shost = class_to_shost(dev);\
7516 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
7517 uint32_t param_val = 0;\
7518 if (!isdigit(buf[0]))\
7519 return -EINVAL;\
7520 if (sscanf(buf, "%i", ¶m_val) != 1)\
7521 return -EINVAL;\
7522 if (beiscsi_##_name##_change(phba, param_val) == 0) \
7523 return strlen(buf);\
7524 else \
7525 return -EINVAL;\
7526 }
7527 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
7528 int \
7529 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
7530 { \
7531 if (val >= _minval && val <= _maxval) {\
7532 phba->attr_##_name = val;\
7533 return 0;\
7534 } \
7535 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7536 "BA_%d beiscsi_"#_name" attribute " \
7537 "cannot be updated to 0x%x, "\
7538 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7539 phba->attr_##_name = _defval;\
7540 return -EINVAL;\
7541 }
7542 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
7543 static uint beiscsi_##_name = _defval;\
7544 module_param(beiscsi_##_name, uint, S_IRUGO);\
7545 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
7546 beiscsi_disp_param(_name)\
7547 beiscsi_change_param(_name, _minval, _maxval, _defval)\
7548 beiscsi_store_param(_name)\
7549 beiscsi_init_param(_name, _minval, _maxval, _defval)\
7550 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
7551 beiscsi_##_name##_disp, beiscsi_##_name##_store)
7552 /* LDV_COMMENT_END_PREP */
7553 /* LDV_COMMENT_FUNCTION_CALL Function from field "eh_device_reset_handler" from driver structure with callbacks "beiscsi_sht" */
7554 ldv_handler_precall();
7555 beiscsi_eh_device_reset( var_group2);
7556
7557
7558
7559
7560 }
7561
7562 break;
7563 case 3: {
7564
7565 /** STRUCT: struct type: pci_error_handlers, struct name: beiscsi_eeh_handlers **/
7566
7567
7568 /* content: static pci_ers_result_t beiscsi_eeh_err_detected(struct pci_dev *pdev, pci_channel_state_t state)*/
7569 /* LDV_COMMENT_BEGIN_PREP */
7570 #define beiscsi_disp_param(_name)\
7571 ssize_t \
7572 beiscsi_##_name##_disp(struct device *dev,\
7573 struct device_attribute *attrib, char *buf) \
7574 { \
7575 struct Scsi_Host *shost = class_to_shost(dev);\
7576 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
7577 uint32_t param_val = 0; \
7578 param_val = phba->attr_##_name;\
7579 return snprintf(buf, PAGE_SIZE, "%d\n",\
7580 phba->attr_##_name);\
7581 }
7582 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
7583 int \
7584 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
7585 {\
7586 if (val >= _minval && val <= _maxval) {\
7587 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7588 "BA_%d : beiscsi_"#_name" updated "\
7589 "from 0x%x ==> 0x%x\n",\
7590 phba->attr_##_name, val); \
7591 phba->attr_##_name = val;\
7592 return 0;\
7593 } \
7594 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
7595 "BA_%d beiscsi_"#_name" attribute "\
7596 "cannot be updated to 0x%x, "\
7597 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7598 return -EINVAL;\
7599 }
7600 #define beiscsi_store_param(_name) \
7601 ssize_t \
7602 beiscsi_##_name##_store(struct device *dev,\
7603 struct device_attribute *attr, const char *buf,\
7604 size_t count) \
7605 { \
7606 struct Scsi_Host *shost = class_to_shost(dev);\
7607 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
7608 uint32_t param_val = 0;\
7609 if (!isdigit(buf[0]))\
7610 return -EINVAL;\
7611 if (sscanf(buf, "%i", ¶m_val) != 1)\
7612 return -EINVAL;\
7613 if (beiscsi_##_name##_change(phba, param_val) == 0) \
7614 return strlen(buf);\
7615 else \
7616 return -EINVAL;\
7617 }
7618 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
7619 int \
7620 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
7621 { \
7622 if (val >= _minval && val <= _maxval) {\
7623 phba->attr_##_name = val;\
7624 return 0;\
7625 } \
7626 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7627 "BA_%d beiscsi_"#_name" attribute " \
7628 "cannot be updated to 0x%x, "\
7629 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7630 phba->attr_##_name = _defval;\
7631 return -EINVAL;\
7632 }
7633 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
7634 static uint beiscsi_##_name = _defval;\
7635 module_param(beiscsi_##_name, uint, S_IRUGO);\
7636 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
7637 beiscsi_disp_param(_name)\
7638 beiscsi_change_param(_name, _minval, _maxval, _defval)\
7639 beiscsi_store_param(_name)\
7640 beiscsi_init_param(_name, _minval, _maxval, _defval)\
7641 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
7642 beiscsi_##_name##_disp, beiscsi_##_name##_store)
7643 /* LDV_COMMENT_END_PREP */
7644 /* LDV_COMMENT_FUNCTION_CALL Function from field "error_detected" from driver structure with callbacks "beiscsi_eeh_handlers" */
7645 ldv_handler_precall();
7646 beiscsi_eeh_err_detected( var_group3, var_beiscsi_eeh_err_detected_107_p1);
7647
7648
7649
7650
7651 }
7652
7653 break;
7654 case 4: {
7655
7656 /** STRUCT: struct type: pci_error_handlers, struct name: beiscsi_eeh_handlers **/
7657
7658
7659 /* content: static pci_ers_result_t beiscsi_eeh_reset(struct pci_dev *pdev)*/
7660 /* LDV_COMMENT_BEGIN_PREP */
7661 #define beiscsi_disp_param(_name)\
7662 ssize_t \
7663 beiscsi_##_name##_disp(struct device *dev,\
7664 struct device_attribute *attrib, char *buf) \
7665 { \
7666 struct Scsi_Host *shost = class_to_shost(dev);\
7667 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
7668 uint32_t param_val = 0; \
7669 param_val = phba->attr_##_name;\
7670 return snprintf(buf, PAGE_SIZE, "%d\n",\
7671 phba->attr_##_name);\
7672 }
7673 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
7674 int \
7675 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
7676 {\
7677 if (val >= _minval && val <= _maxval) {\
7678 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7679 "BA_%d : beiscsi_"#_name" updated "\
7680 "from 0x%x ==> 0x%x\n",\
7681 phba->attr_##_name, val); \
7682 phba->attr_##_name = val;\
7683 return 0;\
7684 } \
7685 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
7686 "BA_%d beiscsi_"#_name" attribute "\
7687 "cannot be updated to 0x%x, "\
7688 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7689 return -EINVAL;\
7690 }
7691 #define beiscsi_store_param(_name) \
7692 ssize_t \
7693 beiscsi_##_name##_store(struct device *dev,\
7694 struct device_attribute *attr, const char *buf,\
7695 size_t count) \
7696 { \
7697 struct Scsi_Host *shost = class_to_shost(dev);\
7698 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
7699 uint32_t param_val = 0;\
7700 if (!isdigit(buf[0]))\
7701 return -EINVAL;\
7702 if (sscanf(buf, "%i", ¶m_val) != 1)\
7703 return -EINVAL;\
7704 if (beiscsi_##_name##_change(phba, param_val) == 0) \
7705 return strlen(buf);\
7706 else \
7707 return -EINVAL;\
7708 }
7709 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
7710 int \
7711 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
7712 { \
7713 if (val >= _minval && val <= _maxval) {\
7714 phba->attr_##_name = val;\
7715 return 0;\
7716 } \
7717 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7718 "BA_%d beiscsi_"#_name" attribute " \
7719 "cannot be updated to 0x%x, "\
7720 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7721 phba->attr_##_name = _defval;\
7722 return -EINVAL;\
7723 }
7724 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
7725 static uint beiscsi_##_name = _defval;\
7726 module_param(beiscsi_##_name, uint, S_IRUGO);\
7727 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
7728 beiscsi_disp_param(_name)\
7729 beiscsi_change_param(_name, _minval, _maxval, _defval)\
7730 beiscsi_store_param(_name)\
7731 beiscsi_init_param(_name, _minval, _maxval, _defval)\
7732 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
7733 beiscsi_##_name##_disp, beiscsi_##_name##_store)
7734 /* LDV_COMMENT_END_PREP */
7735 /* LDV_COMMENT_FUNCTION_CALL Function from field "slot_reset" from driver structure with callbacks "beiscsi_eeh_handlers" */
7736 ldv_handler_precall();
7737 beiscsi_eeh_reset( var_group3);
7738
7739
7740
7741
7742 }
7743
7744 break;
7745 case 5: {
7746
7747 /** STRUCT: struct type: pci_error_handlers, struct name: beiscsi_eeh_handlers **/
7748
7749
7750 /* content: static void beiscsi_eeh_resume(struct pci_dev *pdev)*/
7751 /* LDV_COMMENT_BEGIN_PREP */
7752 #define beiscsi_disp_param(_name)\
7753 ssize_t \
7754 beiscsi_##_name##_disp(struct device *dev,\
7755 struct device_attribute *attrib, char *buf) \
7756 { \
7757 struct Scsi_Host *shost = class_to_shost(dev);\
7758 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
7759 uint32_t param_val = 0; \
7760 param_val = phba->attr_##_name;\
7761 return snprintf(buf, PAGE_SIZE, "%d\n",\
7762 phba->attr_##_name);\
7763 }
7764 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
7765 int \
7766 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
7767 {\
7768 if (val >= _minval && val <= _maxval) {\
7769 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7770 "BA_%d : beiscsi_"#_name" updated "\
7771 "from 0x%x ==> 0x%x\n",\
7772 phba->attr_##_name, val); \
7773 phba->attr_##_name = val;\
7774 return 0;\
7775 } \
7776 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
7777 "BA_%d beiscsi_"#_name" attribute "\
7778 "cannot be updated to 0x%x, "\
7779 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7780 return -EINVAL;\
7781 }
7782 #define beiscsi_store_param(_name) \
7783 ssize_t \
7784 beiscsi_##_name##_store(struct device *dev,\
7785 struct device_attribute *attr, const char *buf,\
7786 size_t count) \
7787 { \
7788 struct Scsi_Host *shost = class_to_shost(dev);\
7789 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
7790 uint32_t param_val = 0;\
7791 if (!isdigit(buf[0]))\
7792 return -EINVAL;\
7793 if (sscanf(buf, "%i", ¶m_val) != 1)\
7794 return -EINVAL;\
7795 if (beiscsi_##_name##_change(phba, param_val) == 0) \
7796 return strlen(buf);\
7797 else \
7798 return -EINVAL;\
7799 }
7800 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
7801 int \
7802 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
7803 { \
7804 if (val >= _minval && val <= _maxval) {\
7805 phba->attr_##_name = val;\
7806 return 0;\
7807 } \
7808 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7809 "BA_%d beiscsi_"#_name" attribute " \
7810 "cannot be updated to 0x%x, "\
7811 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7812 phba->attr_##_name = _defval;\
7813 return -EINVAL;\
7814 }
7815 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
7816 static uint beiscsi_##_name = _defval;\
7817 module_param(beiscsi_##_name, uint, S_IRUGO);\
7818 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
7819 beiscsi_disp_param(_name)\
7820 beiscsi_change_param(_name, _minval, _maxval, _defval)\
7821 beiscsi_store_param(_name)\
7822 beiscsi_init_param(_name, _minval, _maxval, _defval)\
7823 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
7824 beiscsi_##_name##_disp, beiscsi_##_name##_store)
7825 /* LDV_COMMENT_END_PREP */
7826 /* LDV_COMMENT_FUNCTION_CALL Function from field "resume" from driver structure with callbacks "beiscsi_eeh_handlers" */
7827 ldv_handler_precall();
7828 beiscsi_eeh_resume( var_group3);
7829
7830
7831
7832
7833 }
7834
7835 break;
7836 case 6: {
7837
7838 /** STRUCT: struct type: iscsi_transport, struct name: beiscsi_iscsi_transport **/
7839
7840
7841 /* content: static int beiscsi_task_xmit(struct iscsi_task *task)*/
7842 /* LDV_COMMENT_BEGIN_PREP */
7843 #define beiscsi_disp_param(_name)\
7844 ssize_t \
7845 beiscsi_##_name##_disp(struct device *dev,\
7846 struct device_attribute *attrib, char *buf) \
7847 { \
7848 struct Scsi_Host *shost = class_to_shost(dev);\
7849 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
7850 uint32_t param_val = 0; \
7851 param_val = phba->attr_##_name;\
7852 return snprintf(buf, PAGE_SIZE, "%d\n",\
7853 phba->attr_##_name);\
7854 }
7855 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
7856 int \
7857 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
7858 {\
7859 if (val >= _minval && val <= _maxval) {\
7860 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7861 "BA_%d : beiscsi_"#_name" updated "\
7862 "from 0x%x ==> 0x%x\n",\
7863 phba->attr_##_name, val); \
7864 phba->attr_##_name = val;\
7865 return 0;\
7866 } \
7867 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
7868 "BA_%d beiscsi_"#_name" attribute "\
7869 "cannot be updated to 0x%x, "\
7870 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7871 return -EINVAL;\
7872 }
7873 #define beiscsi_store_param(_name) \
7874 ssize_t \
7875 beiscsi_##_name##_store(struct device *dev,\
7876 struct device_attribute *attr, const char *buf,\
7877 size_t count) \
7878 { \
7879 struct Scsi_Host *shost = class_to_shost(dev);\
7880 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
7881 uint32_t param_val = 0;\
7882 if (!isdigit(buf[0]))\
7883 return -EINVAL;\
7884 if (sscanf(buf, "%i", ¶m_val) != 1)\
7885 return -EINVAL;\
7886 if (beiscsi_##_name##_change(phba, param_val) == 0) \
7887 return strlen(buf);\
7888 else \
7889 return -EINVAL;\
7890 }
7891 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
7892 int \
7893 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
7894 { \
7895 if (val >= _minval && val <= _maxval) {\
7896 phba->attr_##_name = val;\
7897 return 0;\
7898 } \
7899 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7900 "BA_%d beiscsi_"#_name" attribute " \
7901 "cannot be updated to 0x%x, "\
7902 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7903 phba->attr_##_name = _defval;\
7904 return -EINVAL;\
7905 }
7906 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
7907 static uint beiscsi_##_name = _defval;\
7908 module_param(beiscsi_##_name, uint, S_IRUGO);\
7909 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
7910 beiscsi_disp_param(_name)\
7911 beiscsi_change_param(_name, _minval, _maxval, _defval)\
7912 beiscsi_store_param(_name)\
7913 beiscsi_init_param(_name, _minval, _maxval, _defval)\
7914 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
7915 beiscsi_##_name##_disp, beiscsi_##_name##_store)
7916 /* LDV_COMMENT_END_PREP */
7917 /* LDV_COMMENT_FUNCTION_CALL Function from field "xmit_task" from driver structure with callbacks "beiscsi_iscsi_transport" */
7918 ldv_handler_precall();
7919 beiscsi_task_xmit( var_group4);
7920
7921
7922
7923
7924 }
7925
7926 break;
7927 case 7: {
7928
7929 /** STRUCT: struct type: iscsi_transport, struct name: beiscsi_iscsi_transport **/
7930
7931
7932 /* content: static void beiscsi_cleanup_task(struct iscsi_task *task)*/
7933 /* LDV_COMMENT_BEGIN_PREP */
7934 #define beiscsi_disp_param(_name)\
7935 ssize_t \
7936 beiscsi_##_name##_disp(struct device *dev,\
7937 struct device_attribute *attrib, char *buf) \
7938 { \
7939 struct Scsi_Host *shost = class_to_shost(dev);\
7940 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
7941 uint32_t param_val = 0; \
7942 param_val = phba->attr_##_name;\
7943 return snprintf(buf, PAGE_SIZE, "%d\n",\
7944 phba->attr_##_name);\
7945 }
7946 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
7947 int \
7948 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
7949 {\
7950 if (val >= _minval && val <= _maxval) {\
7951 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7952 "BA_%d : beiscsi_"#_name" updated "\
7953 "from 0x%x ==> 0x%x\n",\
7954 phba->attr_##_name, val); \
7955 phba->attr_##_name = val;\
7956 return 0;\
7957 } \
7958 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
7959 "BA_%d beiscsi_"#_name" attribute "\
7960 "cannot be updated to 0x%x, "\
7961 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7962 return -EINVAL;\
7963 }
7964 #define beiscsi_store_param(_name) \
7965 ssize_t \
7966 beiscsi_##_name##_store(struct device *dev,\
7967 struct device_attribute *attr, const char *buf,\
7968 size_t count) \
7969 { \
7970 struct Scsi_Host *shost = class_to_shost(dev);\
7971 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
7972 uint32_t param_val = 0;\
7973 if (!isdigit(buf[0]))\
7974 return -EINVAL;\
7975 if (sscanf(buf, "%i", ¶m_val) != 1)\
7976 return -EINVAL;\
7977 if (beiscsi_##_name##_change(phba, param_val) == 0) \
7978 return strlen(buf);\
7979 else \
7980 return -EINVAL;\
7981 }
7982 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
7983 int \
7984 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
7985 { \
7986 if (val >= _minval && val <= _maxval) {\
7987 phba->attr_##_name = val;\
7988 return 0;\
7989 } \
7990 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
7991 "BA_%d beiscsi_"#_name" attribute " \
7992 "cannot be updated to 0x%x, "\
7993 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
7994 phba->attr_##_name = _defval;\
7995 return -EINVAL;\
7996 }
7997 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
7998 static uint beiscsi_##_name = _defval;\
7999 module_param(beiscsi_##_name, uint, S_IRUGO);\
8000 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
8001 beiscsi_disp_param(_name)\
8002 beiscsi_change_param(_name, _minval, _maxval, _defval)\
8003 beiscsi_store_param(_name)\
8004 beiscsi_init_param(_name, _minval, _maxval, _defval)\
8005 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
8006 beiscsi_##_name##_disp, beiscsi_##_name##_store)
8007 /* LDV_COMMENT_END_PREP */
8008 /* LDV_COMMENT_FUNCTION_CALL Function from field "cleanup_task" from driver structure with callbacks "beiscsi_iscsi_transport" */
8009 ldv_handler_precall();
8010 beiscsi_cleanup_task( var_group4);
8011
8012
8013
8014
8015 }
8016
8017 break;
8018 case 8: {
8019
8020 /** STRUCT: struct type: iscsi_transport, struct name: beiscsi_iscsi_transport **/
8021
8022
8023 /* content: static int beiscsi_alloc_pdu(struct iscsi_task *task, uint8_t opcode)*/
8024 /* LDV_COMMENT_BEGIN_PREP */
8025 #define beiscsi_disp_param(_name)\
8026 ssize_t \
8027 beiscsi_##_name##_disp(struct device *dev,\
8028 struct device_attribute *attrib, char *buf) \
8029 { \
8030 struct Scsi_Host *shost = class_to_shost(dev);\
8031 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
8032 uint32_t param_val = 0; \
8033 param_val = phba->attr_##_name;\
8034 return snprintf(buf, PAGE_SIZE, "%d\n",\
8035 phba->attr_##_name);\
8036 }
8037 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
8038 int \
8039 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
8040 {\
8041 if (val >= _minval && val <= _maxval) {\
8042 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8043 "BA_%d : beiscsi_"#_name" updated "\
8044 "from 0x%x ==> 0x%x\n",\
8045 phba->attr_##_name, val); \
8046 phba->attr_##_name = val;\
8047 return 0;\
8048 } \
8049 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
8050 "BA_%d beiscsi_"#_name" attribute "\
8051 "cannot be updated to 0x%x, "\
8052 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8053 return -EINVAL;\
8054 }
8055 #define beiscsi_store_param(_name) \
8056 ssize_t \
8057 beiscsi_##_name##_store(struct device *dev,\
8058 struct device_attribute *attr, const char *buf,\
8059 size_t count) \
8060 { \
8061 struct Scsi_Host *shost = class_to_shost(dev);\
8062 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
8063 uint32_t param_val = 0;\
8064 if (!isdigit(buf[0]))\
8065 return -EINVAL;\
8066 if (sscanf(buf, "%i", ¶m_val) != 1)\
8067 return -EINVAL;\
8068 if (beiscsi_##_name##_change(phba, param_val) == 0) \
8069 return strlen(buf);\
8070 else \
8071 return -EINVAL;\
8072 }
8073 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
8074 int \
8075 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
8076 { \
8077 if (val >= _minval && val <= _maxval) {\
8078 phba->attr_##_name = val;\
8079 return 0;\
8080 } \
8081 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8082 "BA_%d beiscsi_"#_name" attribute " \
8083 "cannot be updated to 0x%x, "\
8084 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8085 phba->attr_##_name = _defval;\
8086 return -EINVAL;\
8087 }
8088 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
8089 static uint beiscsi_##_name = _defval;\
8090 module_param(beiscsi_##_name, uint, S_IRUGO);\
8091 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
8092 beiscsi_disp_param(_name)\
8093 beiscsi_change_param(_name, _minval, _maxval, _defval)\
8094 beiscsi_store_param(_name)\
8095 beiscsi_init_param(_name, _minval, _maxval, _defval)\
8096 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
8097 beiscsi_##_name##_disp, beiscsi_##_name##_store)
8098 /* LDV_COMMENT_END_PREP */
8099 /* LDV_COMMENT_FUNCTION_CALL Function from field "alloc_pdu" from driver structure with callbacks "beiscsi_iscsi_transport" */
8100 ldv_handler_precall();
8101 beiscsi_alloc_pdu( var_group4, var_beiscsi_alloc_pdu_95_p1);
8102
8103
8104
8105
8106 }
8107
8108 break;
8109 case 9: {
8110
8111 /** STRUCT: struct type: iscsi_transport, struct name: beiscsi_iscsi_transport **/
8112
8113
8114 /* content: static void beiscsi_parse_pdu(struct iscsi_conn *conn, itt_t itt, int *index, int *age)*/
8115 /* LDV_COMMENT_BEGIN_PREP */
8116 #define beiscsi_disp_param(_name)\
8117 ssize_t \
8118 beiscsi_##_name##_disp(struct device *dev,\
8119 struct device_attribute *attrib, char *buf) \
8120 { \
8121 struct Scsi_Host *shost = class_to_shost(dev);\
8122 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
8123 uint32_t param_val = 0; \
8124 param_val = phba->attr_##_name;\
8125 return snprintf(buf, PAGE_SIZE, "%d\n",\
8126 phba->attr_##_name);\
8127 }
8128 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
8129 int \
8130 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
8131 {\
8132 if (val >= _minval && val <= _maxval) {\
8133 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8134 "BA_%d : beiscsi_"#_name" updated "\
8135 "from 0x%x ==> 0x%x\n",\
8136 phba->attr_##_name, val); \
8137 phba->attr_##_name = val;\
8138 return 0;\
8139 } \
8140 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
8141 "BA_%d beiscsi_"#_name" attribute "\
8142 "cannot be updated to 0x%x, "\
8143 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8144 return -EINVAL;\
8145 }
8146 #define beiscsi_store_param(_name) \
8147 ssize_t \
8148 beiscsi_##_name##_store(struct device *dev,\
8149 struct device_attribute *attr, const char *buf,\
8150 size_t count) \
8151 { \
8152 struct Scsi_Host *shost = class_to_shost(dev);\
8153 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
8154 uint32_t param_val = 0;\
8155 if (!isdigit(buf[0]))\
8156 return -EINVAL;\
8157 if (sscanf(buf, "%i", ¶m_val) != 1)\
8158 return -EINVAL;\
8159 if (beiscsi_##_name##_change(phba, param_val) == 0) \
8160 return strlen(buf);\
8161 else \
8162 return -EINVAL;\
8163 }
8164 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
8165 int \
8166 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
8167 { \
8168 if (val >= _minval && val <= _maxval) {\
8169 phba->attr_##_name = val;\
8170 return 0;\
8171 } \
8172 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8173 "BA_%d beiscsi_"#_name" attribute " \
8174 "cannot be updated to 0x%x, "\
8175 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8176 phba->attr_##_name = _defval;\
8177 return -EINVAL;\
8178 }
8179 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
8180 static uint beiscsi_##_name = _defval;\
8181 module_param(beiscsi_##_name, uint, S_IRUGO);\
8182 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
8183 beiscsi_disp_param(_name)\
8184 beiscsi_change_param(_name, _minval, _maxval, _defval)\
8185 beiscsi_store_param(_name)\
8186 beiscsi_init_param(_name, _minval, _maxval, _defval)\
8187 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
8188 beiscsi_##_name##_disp, beiscsi_##_name##_store)
8189 /* LDV_COMMENT_END_PREP */
8190 /* LDV_COMMENT_FUNCTION_CALL Function from field "parse_pdu_itt" from driver structure with callbacks "beiscsi_iscsi_transport" */
8191 ldv_handler_precall();
8192 beiscsi_parse_pdu( var_group5, var_beiscsi_parse_pdu_94_p1, var_beiscsi_parse_pdu_94_p2, var_beiscsi_parse_pdu_94_p3);
8193
8194
8195
8196
8197 }
8198
8199 break;
8200 case 10: {
8201
8202 /** STRUCT: struct type: iscsi_transport, struct name: beiscsi_iscsi_transport **/
8203
8204
8205 /* content: static int beiscsi_bsg_request(struct bsg_job *job)*/
8206 /* LDV_COMMENT_BEGIN_PREP */
8207 #define beiscsi_disp_param(_name)\
8208 ssize_t \
8209 beiscsi_##_name##_disp(struct device *dev,\
8210 struct device_attribute *attrib, char *buf) \
8211 { \
8212 struct Scsi_Host *shost = class_to_shost(dev);\
8213 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
8214 uint32_t param_val = 0; \
8215 param_val = phba->attr_##_name;\
8216 return snprintf(buf, PAGE_SIZE, "%d\n",\
8217 phba->attr_##_name);\
8218 }
8219 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
8220 int \
8221 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
8222 {\
8223 if (val >= _minval && val <= _maxval) {\
8224 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8225 "BA_%d : beiscsi_"#_name" updated "\
8226 "from 0x%x ==> 0x%x\n",\
8227 phba->attr_##_name, val); \
8228 phba->attr_##_name = val;\
8229 return 0;\
8230 } \
8231 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
8232 "BA_%d beiscsi_"#_name" attribute "\
8233 "cannot be updated to 0x%x, "\
8234 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8235 return -EINVAL;\
8236 }
8237 #define beiscsi_store_param(_name) \
8238 ssize_t \
8239 beiscsi_##_name##_store(struct device *dev,\
8240 struct device_attribute *attr, const char *buf,\
8241 size_t count) \
8242 { \
8243 struct Scsi_Host *shost = class_to_shost(dev);\
8244 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
8245 uint32_t param_val = 0;\
8246 if (!isdigit(buf[0]))\
8247 return -EINVAL;\
8248 if (sscanf(buf, "%i", ¶m_val) != 1)\
8249 return -EINVAL;\
8250 if (beiscsi_##_name##_change(phba, param_val) == 0) \
8251 return strlen(buf);\
8252 else \
8253 return -EINVAL;\
8254 }
8255 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
8256 int \
8257 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
8258 { \
8259 if (val >= _minval && val <= _maxval) {\
8260 phba->attr_##_name = val;\
8261 return 0;\
8262 } \
8263 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8264 "BA_%d beiscsi_"#_name" attribute " \
8265 "cannot be updated to 0x%x, "\
8266 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8267 phba->attr_##_name = _defval;\
8268 return -EINVAL;\
8269 }
8270 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
8271 static uint beiscsi_##_name = _defval;\
8272 module_param(beiscsi_##_name, uint, S_IRUGO);\
8273 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
8274 beiscsi_disp_param(_name)\
8275 beiscsi_change_param(_name, _minval, _maxval, _defval)\
8276 beiscsi_store_param(_name)\
8277 beiscsi_init_param(_name, _minval, _maxval, _defval)\
8278 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
8279 beiscsi_##_name##_disp, beiscsi_##_name##_store)
8280 /* LDV_COMMENT_END_PREP */
8281 /* LDV_COMMENT_FUNCTION_CALL Function from field "bsg_request" from driver structure with callbacks "beiscsi_iscsi_transport" */
8282 ldv_handler_precall();
8283 beiscsi_bsg_request( var_group6);
8284
8285
8286
8287
8288 }
8289
8290 break;
8291 case 11: {
8292
8293 /** STRUCT: struct type: pci_driver, struct name: beiscsi_pci_driver **/
8294 if(ldv_s_beiscsi_pci_driver_pci_driver==0) {
8295
8296 /* content: static int beiscsi_dev_probe(struct pci_dev *pcidev, const struct pci_device_id *id)*/
8297 /* LDV_COMMENT_BEGIN_PREP */
8298 #define beiscsi_disp_param(_name)\
8299 ssize_t \
8300 beiscsi_##_name##_disp(struct device *dev,\
8301 struct device_attribute *attrib, char *buf) \
8302 { \
8303 struct Scsi_Host *shost = class_to_shost(dev);\
8304 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
8305 uint32_t param_val = 0; \
8306 param_val = phba->attr_##_name;\
8307 return snprintf(buf, PAGE_SIZE, "%d\n",\
8308 phba->attr_##_name);\
8309 }
8310 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
8311 int \
8312 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
8313 {\
8314 if (val >= _minval && val <= _maxval) {\
8315 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8316 "BA_%d : beiscsi_"#_name" updated "\
8317 "from 0x%x ==> 0x%x\n",\
8318 phba->attr_##_name, val); \
8319 phba->attr_##_name = val;\
8320 return 0;\
8321 } \
8322 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
8323 "BA_%d beiscsi_"#_name" attribute "\
8324 "cannot be updated to 0x%x, "\
8325 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8326 return -EINVAL;\
8327 }
8328 #define beiscsi_store_param(_name) \
8329 ssize_t \
8330 beiscsi_##_name##_store(struct device *dev,\
8331 struct device_attribute *attr, const char *buf,\
8332 size_t count) \
8333 { \
8334 struct Scsi_Host *shost = class_to_shost(dev);\
8335 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
8336 uint32_t param_val = 0;\
8337 if (!isdigit(buf[0]))\
8338 return -EINVAL;\
8339 if (sscanf(buf, "%i", ¶m_val) != 1)\
8340 return -EINVAL;\
8341 if (beiscsi_##_name##_change(phba, param_val) == 0) \
8342 return strlen(buf);\
8343 else \
8344 return -EINVAL;\
8345 }
8346 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
8347 int \
8348 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
8349 { \
8350 if (val >= _minval && val <= _maxval) {\
8351 phba->attr_##_name = val;\
8352 return 0;\
8353 } \
8354 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8355 "BA_%d beiscsi_"#_name" attribute " \
8356 "cannot be updated to 0x%x, "\
8357 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8358 phba->attr_##_name = _defval;\
8359 return -EINVAL;\
8360 }
8361 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
8362 static uint beiscsi_##_name = _defval;\
8363 module_param(beiscsi_##_name, uint, S_IRUGO);\
8364 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
8365 beiscsi_disp_param(_name)\
8366 beiscsi_change_param(_name, _minval, _maxval, _defval)\
8367 beiscsi_store_param(_name)\
8368 beiscsi_init_param(_name, _minval, _maxval, _defval)\
8369 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
8370 beiscsi_##_name##_disp, beiscsi_##_name##_store)
8371 /* LDV_COMMENT_END_PREP */
8372 /* LDV_COMMENT_FUNCTION_CALL Function from field "probe" from driver structure with callbacks "beiscsi_pci_driver". Standart function test for correct return result. */
8373 res_beiscsi_dev_probe_110 = beiscsi_dev_probe( var_group3, var_beiscsi_dev_probe_110_p1);
8374 ldv_check_return_value(res_beiscsi_dev_probe_110);
8375 ldv_check_return_value_probe(res_beiscsi_dev_probe_110);
8376 if(res_beiscsi_dev_probe_110)
8377 goto ldv_module_exit;
8378 ldv_s_beiscsi_pci_driver_pci_driver++;
8379
8380 }
8381
8382 }
8383
8384 break;
8385 case 12: {
8386
8387 /** STRUCT: struct type: pci_driver, struct name: beiscsi_pci_driver **/
8388 if(ldv_s_beiscsi_pci_driver_pci_driver==1) {
8389
8390 /* content: static void beiscsi_remove(struct pci_dev *pcidev)*/
8391 /* LDV_COMMENT_BEGIN_PREP */
8392 #define beiscsi_disp_param(_name)\
8393 ssize_t \
8394 beiscsi_##_name##_disp(struct device *dev,\
8395 struct device_attribute *attrib, char *buf) \
8396 { \
8397 struct Scsi_Host *shost = class_to_shost(dev);\
8398 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
8399 uint32_t param_val = 0; \
8400 param_val = phba->attr_##_name;\
8401 return snprintf(buf, PAGE_SIZE, "%d\n",\
8402 phba->attr_##_name);\
8403 }
8404 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
8405 int \
8406 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
8407 {\
8408 if (val >= _minval && val <= _maxval) {\
8409 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8410 "BA_%d : beiscsi_"#_name" updated "\
8411 "from 0x%x ==> 0x%x\n",\
8412 phba->attr_##_name, val); \
8413 phba->attr_##_name = val;\
8414 return 0;\
8415 } \
8416 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
8417 "BA_%d beiscsi_"#_name" attribute "\
8418 "cannot be updated to 0x%x, "\
8419 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8420 return -EINVAL;\
8421 }
8422 #define beiscsi_store_param(_name) \
8423 ssize_t \
8424 beiscsi_##_name##_store(struct device *dev,\
8425 struct device_attribute *attr, const char *buf,\
8426 size_t count) \
8427 { \
8428 struct Scsi_Host *shost = class_to_shost(dev);\
8429 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
8430 uint32_t param_val = 0;\
8431 if (!isdigit(buf[0]))\
8432 return -EINVAL;\
8433 if (sscanf(buf, "%i", ¶m_val) != 1)\
8434 return -EINVAL;\
8435 if (beiscsi_##_name##_change(phba, param_val) == 0) \
8436 return strlen(buf);\
8437 else \
8438 return -EINVAL;\
8439 }
8440 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
8441 int \
8442 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
8443 { \
8444 if (val >= _minval && val <= _maxval) {\
8445 phba->attr_##_name = val;\
8446 return 0;\
8447 } \
8448 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8449 "BA_%d beiscsi_"#_name" attribute " \
8450 "cannot be updated to 0x%x, "\
8451 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8452 phba->attr_##_name = _defval;\
8453 return -EINVAL;\
8454 }
8455 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
8456 static uint beiscsi_##_name = _defval;\
8457 module_param(beiscsi_##_name, uint, S_IRUGO);\
8458 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
8459 beiscsi_disp_param(_name)\
8460 beiscsi_change_param(_name, _minval, _maxval, _defval)\
8461 beiscsi_store_param(_name)\
8462 beiscsi_init_param(_name, _minval, _maxval, _defval)\
8463 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
8464 beiscsi_##_name##_disp, beiscsi_##_name##_store)
8465 /* LDV_COMMENT_END_PREP */
8466 /* LDV_COMMENT_FUNCTION_CALL Function from field "remove" from driver structure with callbacks "beiscsi_pci_driver" */
8467 ldv_handler_precall();
8468 beiscsi_remove( var_group3);
8469 ldv_s_beiscsi_pci_driver_pci_driver=0;
8470
8471 }
8472
8473 }
8474
8475 break;
8476 case 13: {
8477
8478 /** STRUCT: struct type: pci_driver, struct name: beiscsi_pci_driver **/
8479
8480
8481 /* content: static void beiscsi_shutdown(struct pci_dev *pcidev)*/
8482 /* LDV_COMMENT_BEGIN_PREP */
8483 #define beiscsi_disp_param(_name)\
8484 ssize_t \
8485 beiscsi_##_name##_disp(struct device *dev,\
8486 struct device_attribute *attrib, char *buf) \
8487 { \
8488 struct Scsi_Host *shost = class_to_shost(dev);\
8489 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
8490 uint32_t param_val = 0; \
8491 param_val = phba->attr_##_name;\
8492 return snprintf(buf, PAGE_SIZE, "%d\n",\
8493 phba->attr_##_name);\
8494 }
8495 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
8496 int \
8497 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
8498 {\
8499 if (val >= _minval && val <= _maxval) {\
8500 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8501 "BA_%d : beiscsi_"#_name" updated "\
8502 "from 0x%x ==> 0x%x\n",\
8503 phba->attr_##_name, val); \
8504 phba->attr_##_name = val;\
8505 return 0;\
8506 } \
8507 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
8508 "BA_%d beiscsi_"#_name" attribute "\
8509 "cannot be updated to 0x%x, "\
8510 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8511 return -EINVAL;\
8512 }
8513 #define beiscsi_store_param(_name) \
8514 ssize_t \
8515 beiscsi_##_name##_store(struct device *dev,\
8516 struct device_attribute *attr, const char *buf,\
8517 size_t count) \
8518 { \
8519 struct Scsi_Host *shost = class_to_shost(dev);\
8520 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
8521 uint32_t param_val = 0;\
8522 if (!isdigit(buf[0]))\
8523 return -EINVAL;\
8524 if (sscanf(buf, "%i", ¶m_val) != 1)\
8525 return -EINVAL;\
8526 if (beiscsi_##_name##_change(phba, param_val) == 0) \
8527 return strlen(buf);\
8528 else \
8529 return -EINVAL;\
8530 }
8531 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
8532 int \
8533 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
8534 { \
8535 if (val >= _minval && val <= _maxval) {\
8536 phba->attr_##_name = val;\
8537 return 0;\
8538 } \
8539 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8540 "BA_%d beiscsi_"#_name" attribute " \
8541 "cannot be updated to 0x%x, "\
8542 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8543 phba->attr_##_name = _defval;\
8544 return -EINVAL;\
8545 }
8546 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
8547 static uint beiscsi_##_name = _defval;\
8548 module_param(beiscsi_##_name, uint, S_IRUGO);\
8549 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
8550 beiscsi_disp_param(_name)\
8551 beiscsi_change_param(_name, _minval, _maxval, _defval)\
8552 beiscsi_store_param(_name)\
8553 beiscsi_init_param(_name, _minval, _maxval, _defval)\
8554 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
8555 beiscsi_##_name##_disp, beiscsi_##_name##_store)
8556 /* LDV_COMMENT_END_PREP */
8557 /* LDV_COMMENT_FUNCTION_CALL Function from field "shutdown" from driver structure with callbacks "beiscsi_pci_driver" */
8558 ldv_handler_precall();
8559 beiscsi_shutdown( var_group3);
8560
8561
8562
8563
8564 }
8565
8566 break;
8567 case 14: {
8568
8569 /** CALLBACK SECTION request_irq **/
8570 LDV_IN_INTERRUPT=2;
8571
8572 /* content: static irqreturn_t be_isr(int irq, void *dev_id)*/
8573 /* LDV_COMMENT_BEGIN_PREP */
8574 #define beiscsi_disp_param(_name)\
8575 ssize_t \
8576 beiscsi_##_name##_disp(struct device *dev,\
8577 struct device_attribute *attrib, char *buf) \
8578 { \
8579 struct Scsi_Host *shost = class_to_shost(dev);\
8580 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
8581 uint32_t param_val = 0; \
8582 param_val = phba->attr_##_name;\
8583 return snprintf(buf, PAGE_SIZE, "%d\n",\
8584 phba->attr_##_name);\
8585 }
8586 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
8587 int \
8588 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
8589 {\
8590 if (val >= _minval && val <= _maxval) {\
8591 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8592 "BA_%d : beiscsi_"#_name" updated "\
8593 "from 0x%x ==> 0x%x\n",\
8594 phba->attr_##_name, val); \
8595 phba->attr_##_name = val;\
8596 return 0;\
8597 } \
8598 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
8599 "BA_%d beiscsi_"#_name" attribute "\
8600 "cannot be updated to 0x%x, "\
8601 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8602 return -EINVAL;\
8603 }
8604 #define beiscsi_store_param(_name) \
8605 ssize_t \
8606 beiscsi_##_name##_store(struct device *dev,\
8607 struct device_attribute *attr, const char *buf,\
8608 size_t count) \
8609 { \
8610 struct Scsi_Host *shost = class_to_shost(dev);\
8611 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
8612 uint32_t param_val = 0;\
8613 if (!isdigit(buf[0]))\
8614 return -EINVAL;\
8615 if (sscanf(buf, "%i", ¶m_val) != 1)\
8616 return -EINVAL;\
8617 if (beiscsi_##_name##_change(phba, param_val) == 0) \
8618 return strlen(buf);\
8619 else \
8620 return -EINVAL;\
8621 }
8622 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
8623 int \
8624 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
8625 { \
8626 if (val >= _minval && val <= _maxval) {\
8627 phba->attr_##_name = val;\
8628 return 0;\
8629 } \
8630 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8631 "BA_%d beiscsi_"#_name" attribute " \
8632 "cannot be updated to 0x%x, "\
8633 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8634 phba->attr_##_name = _defval;\
8635 return -EINVAL;\
8636 }
8637 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
8638 static uint beiscsi_##_name = _defval;\
8639 module_param(beiscsi_##_name, uint, S_IRUGO);\
8640 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
8641 beiscsi_disp_param(_name)\
8642 beiscsi_change_param(_name, _minval, _maxval, _defval)\
8643 beiscsi_store_param(_name)\
8644 beiscsi_init_param(_name, _minval, _maxval, _defval)\
8645 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
8646 beiscsi_##_name##_disp, beiscsi_##_name##_store)
8647 /* LDV_COMMENT_END_PREP */
8648 /* LDV_COMMENT_FUNCTION_CALL */
8649 ldv_handler_precall();
8650 be_isr( var_be_isr_18_p0, var_be_isr_18_p1);
8651 LDV_IN_INTERRUPT=1;
8652
8653
8654
8655 }
8656
8657 break;
8658 case 15: {
8659
8660 /** CALLBACK SECTION request_irq **/
8661 LDV_IN_INTERRUPT=2;
8662
8663 /* content: static irqreturn_t be_isr_mcc(int irq, void *dev_id)*/
8664 /* LDV_COMMENT_BEGIN_PREP */
8665 #define beiscsi_disp_param(_name)\
8666 ssize_t \
8667 beiscsi_##_name##_disp(struct device *dev,\
8668 struct device_attribute *attrib, char *buf) \
8669 { \
8670 struct Scsi_Host *shost = class_to_shost(dev);\
8671 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
8672 uint32_t param_val = 0; \
8673 param_val = phba->attr_##_name;\
8674 return snprintf(buf, PAGE_SIZE, "%d\n",\
8675 phba->attr_##_name);\
8676 }
8677 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
8678 int \
8679 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
8680 {\
8681 if (val >= _minval && val <= _maxval) {\
8682 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8683 "BA_%d : beiscsi_"#_name" updated "\
8684 "from 0x%x ==> 0x%x\n",\
8685 phba->attr_##_name, val); \
8686 phba->attr_##_name = val;\
8687 return 0;\
8688 } \
8689 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
8690 "BA_%d beiscsi_"#_name" attribute "\
8691 "cannot be updated to 0x%x, "\
8692 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8693 return -EINVAL;\
8694 }
8695 #define beiscsi_store_param(_name) \
8696 ssize_t \
8697 beiscsi_##_name##_store(struct device *dev,\
8698 struct device_attribute *attr, const char *buf,\
8699 size_t count) \
8700 { \
8701 struct Scsi_Host *shost = class_to_shost(dev);\
8702 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
8703 uint32_t param_val = 0;\
8704 if (!isdigit(buf[0]))\
8705 return -EINVAL;\
8706 if (sscanf(buf, "%i", ¶m_val) != 1)\
8707 return -EINVAL;\
8708 if (beiscsi_##_name##_change(phba, param_val) == 0) \
8709 return strlen(buf);\
8710 else \
8711 return -EINVAL;\
8712 }
8713 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
8714 int \
8715 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
8716 { \
8717 if (val >= _minval && val <= _maxval) {\
8718 phba->attr_##_name = val;\
8719 return 0;\
8720 } \
8721 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8722 "BA_%d beiscsi_"#_name" attribute " \
8723 "cannot be updated to 0x%x, "\
8724 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8725 phba->attr_##_name = _defval;\
8726 return -EINVAL;\
8727 }
8728 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
8729 static uint beiscsi_##_name = _defval;\
8730 module_param(beiscsi_##_name, uint, S_IRUGO);\
8731 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
8732 beiscsi_disp_param(_name)\
8733 beiscsi_change_param(_name, _minval, _maxval, _defval)\
8734 beiscsi_store_param(_name)\
8735 beiscsi_init_param(_name, _minval, _maxval, _defval)\
8736 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
8737 beiscsi_##_name##_disp, beiscsi_##_name##_store)
8738 /* LDV_COMMENT_END_PREP */
8739 /* LDV_COMMENT_FUNCTION_CALL */
8740 ldv_handler_precall();
8741 be_isr_mcc( var_be_isr_mcc_16_p0, var_be_isr_mcc_16_p1);
8742 LDV_IN_INTERRUPT=1;
8743
8744
8745
8746 }
8747
8748 break;
8749 case 16: {
8750
8751 /** CALLBACK SECTION request_irq **/
8752 LDV_IN_INTERRUPT=2;
8753
8754 /* content: static irqreturn_t be_isr_msix(int irq, void *dev_id)*/
8755 /* LDV_COMMENT_BEGIN_PREP */
8756 #define beiscsi_disp_param(_name)\
8757 ssize_t \
8758 beiscsi_##_name##_disp(struct device *dev,\
8759 struct device_attribute *attrib, char *buf) \
8760 { \
8761 struct Scsi_Host *shost = class_to_shost(dev);\
8762 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
8763 uint32_t param_val = 0; \
8764 param_val = phba->attr_##_name;\
8765 return snprintf(buf, PAGE_SIZE, "%d\n",\
8766 phba->attr_##_name);\
8767 }
8768 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
8769 int \
8770 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
8771 {\
8772 if (val >= _minval && val <= _maxval) {\
8773 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8774 "BA_%d : beiscsi_"#_name" updated "\
8775 "from 0x%x ==> 0x%x\n",\
8776 phba->attr_##_name, val); \
8777 phba->attr_##_name = val;\
8778 return 0;\
8779 } \
8780 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
8781 "BA_%d beiscsi_"#_name" attribute "\
8782 "cannot be updated to 0x%x, "\
8783 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8784 return -EINVAL;\
8785 }
8786 #define beiscsi_store_param(_name) \
8787 ssize_t \
8788 beiscsi_##_name##_store(struct device *dev,\
8789 struct device_attribute *attr, const char *buf,\
8790 size_t count) \
8791 { \
8792 struct Scsi_Host *shost = class_to_shost(dev);\
8793 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
8794 uint32_t param_val = 0;\
8795 if (!isdigit(buf[0]))\
8796 return -EINVAL;\
8797 if (sscanf(buf, "%i", ¶m_val) != 1)\
8798 return -EINVAL;\
8799 if (beiscsi_##_name##_change(phba, param_val) == 0) \
8800 return strlen(buf);\
8801 else \
8802 return -EINVAL;\
8803 }
8804 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
8805 int \
8806 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
8807 { \
8808 if (val >= _minval && val <= _maxval) {\
8809 phba->attr_##_name = val;\
8810 return 0;\
8811 } \
8812 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8813 "BA_%d beiscsi_"#_name" attribute " \
8814 "cannot be updated to 0x%x, "\
8815 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8816 phba->attr_##_name = _defval;\
8817 return -EINVAL;\
8818 }
8819 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
8820 static uint beiscsi_##_name = _defval;\
8821 module_param(beiscsi_##_name, uint, S_IRUGO);\
8822 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
8823 beiscsi_disp_param(_name)\
8824 beiscsi_change_param(_name, _minval, _maxval, _defval)\
8825 beiscsi_store_param(_name)\
8826 beiscsi_init_param(_name, _minval, _maxval, _defval)\
8827 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
8828 beiscsi_##_name##_disp, beiscsi_##_name##_store)
8829 /* LDV_COMMENT_END_PREP */
8830 /* LDV_COMMENT_FUNCTION_CALL */
8831 ldv_handler_precall();
8832 be_isr_msix( var_be_isr_msix_17_p0, var_be_isr_msix_17_p1);
8833 LDV_IN_INTERRUPT=1;
8834
8835
8836
8837 }
8838
8839 break;
8840 default: break;
8841
8842 }
8843
8844 }
8845
8846 ldv_module_exit:
8847
8848 /** INIT: init_type: ST_MODULE_EXIT **/
8849 /* content: static void __exit beiscsi_module_exit(void)*/
8850 /* LDV_COMMENT_BEGIN_PREP */
8851 #define beiscsi_disp_param(_name)\
8852 ssize_t \
8853 beiscsi_##_name##_disp(struct device *dev,\
8854 struct device_attribute *attrib, char *buf) \
8855 { \
8856 struct Scsi_Host *shost = class_to_shost(dev);\
8857 struct beiscsi_hba *phba = iscsi_host_priv(shost); \
8858 uint32_t param_val = 0; \
8859 param_val = phba->attr_##_name;\
8860 return snprintf(buf, PAGE_SIZE, "%d\n",\
8861 phba->attr_##_name);\
8862 }
8863 #define beiscsi_change_param(_name, _minval, _maxval, _defaval)\
8864 int \
8865 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
8866 {\
8867 if (val >= _minval && val <= _maxval) {\
8868 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8869 "BA_%d : beiscsi_"#_name" updated "\
8870 "from 0x%x ==> 0x%x\n",\
8871 phba->attr_##_name, val); \
8872 phba->attr_##_name = val;\
8873 return 0;\
8874 } \
8875 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
8876 "BA_%d beiscsi_"#_name" attribute "\
8877 "cannot be updated to 0x%x, "\
8878 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8879 return -EINVAL;\
8880 }
8881 #define beiscsi_store_param(_name) \
8882 ssize_t \
8883 beiscsi_##_name##_store(struct device *dev,\
8884 struct device_attribute *attr, const char *buf,\
8885 size_t count) \
8886 { \
8887 struct Scsi_Host *shost = class_to_shost(dev);\
8888 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
8889 uint32_t param_val = 0;\
8890 if (!isdigit(buf[0]))\
8891 return -EINVAL;\
8892 if (sscanf(buf, "%i", ¶m_val) != 1)\
8893 return -EINVAL;\
8894 if (beiscsi_##_name##_change(phba, param_val) == 0) \
8895 return strlen(buf);\
8896 else \
8897 return -EINVAL;\
8898 }
8899 #define beiscsi_init_param(_name, _minval, _maxval, _defval) \
8900 int \
8901 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
8902 { \
8903 if (val >= _minval && val <= _maxval) {\
8904 phba->attr_##_name = val;\
8905 return 0;\
8906 } \
8907 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
8908 "BA_%d beiscsi_"#_name" attribute " \
8909 "cannot be updated to 0x%x, "\
8910 "range allowed is ["#_minval" - "#_maxval"]\n", val);\
8911 phba->attr_##_name = _defval;\
8912 return -EINVAL;\
8913 }
8914 #define BEISCSI_RW_ATTR(_name, _minval, _maxval, _defval, _descp) \
8915 static uint beiscsi_##_name = _defval;\
8916 module_param(beiscsi_##_name, uint, S_IRUGO);\
8917 MODULE_PARM_DESC(beiscsi_##_name, _descp);\
8918 beiscsi_disp_param(_name)\
8919 beiscsi_change_param(_name, _minval, _maxval, _defval)\
8920 beiscsi_store_param(_name)\
8921 beiscsi_init_param(_name, _minval, _maxval, _defval)\
8922 DEVICE_ATTR(beiscsi_##_name, S_IRUGO | S_IWUSR,\
8923 beiscsi_##_name##_disp, beiscsi_##_name##_store)
8924 /* LDV_COMMENT_END_PREP */
8925 /* LDV_COMMENT_FUNCTION_CALL Kernel calls driver release function before driver will be uploaded from kernel. This function declared as "MODULE_EXIT(function name)". */
8926 ldv_handler_precall();
8927 beiscsi_module_exit();
8928
8929 /* LDV_COMMENT_FUNCTION_CALL Checks that all resources and locks are correctly released before the driver will be unloaded. */
8930 ldv_final: ldv_check_final_state();
8931
8932 /* LDV_COMMENT_END_FUNCTION_CALL_SECTION */
8933 return;
8934
8935 }
8936 #endif
8937
8938 /* LDV_COMMENT_END_MAIN */
8939
8940 #line 9 "/home/druidos/temp/331_1a/work/current--X--drivers--X--defaultlinux-3.14.1.tar.xz--X--331_1a--X--cpachecker/linux-3.14.1.tar.xz/csd_deg_dscv/8229/dscv_tempdir/dscv/ri/331_1a/drivers/scsi/be2iscsi/be_main.o.c.prepared" 1
2 #include <linux/types.h>
3 #include <linux/dma-direction.h>
4 #include <verifier/rcv.h>
5 #include <verifier/set.h>
6 #include <verifier/map.h>
7
8 Set LDV_DMA_MAP_CALLS;
9
10 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_dma_map_page') maps page */
11 dma_addr_t ldv_dma_map_page(struct device *dev, struct page *page, size_t offset, size_t size, enum dma_data_direction dir) {
12 dma_addr_t nonedetermined;
13
14 nonedetermined = ldv_undef_ptr();
15
16 /* LDV_COMMENT_ASSERT Check that previos dma_mapping call was checked*/
17 ldv_assert(ldv_set_is_empty(LDV_DMA_MAP_CALLS));
18
19 ldv_set_add(LDV_DMA_MAP_CALLS, nonedetermined);
20
21 return nonedetermined;
22 }
23
24 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_dma_mapping_error') unmaps page */
25 int ldv_dma_mapping_error(struct device *dev, dma_addr_t dma_addr) {
26
27 /* LDV_COMMENT_ASSERT No dma_mapping calls to verify */
28 ldv_assert(ldv_set_contains(LDV_DMA_MAP_CALLS, dma_addr));
29 ldv_set_remove(LDV_DMA_MAP_CALLS, dma_addr);
30
31 int nonedetermined;
32
33 nonedetermined = ldv_undef_int();
34
35 return nonedetermined;
36 }
37
38
39
40 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_dma_map_single') maps pci_dma */
41 dma_addr_t ldv_dma_map_single(struct device *dev, void *cpu_addr, size_t size, enum dma_data_direction dir) {
42 dma_addr_t nonedetermined;
43
44 nonedetermined = ldv_undef_ptr();
45
46 /* LDV_COMMENT_ASSERT Check that previos dma_mapping call was checked*/
47 ldv_assert(ldv_set_is_empty(LDV_DMA_MAP_CALLS));
48
49 ldv_set_add(LDV_DMA_MAP_CALLS, nonedetermined);
50
51 return nonedetermined;
52 }
53
54 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_dma_map_single_attrs') maps pci_dma */
55 dma_addr_t ldv_dma_map_single_attrs(struct device *dev, void *ptr, size_t size, enum dma_data_direction dir, struct dma_attrs *attrs) {
56 dma_addr_t nonedetermined;
57
58 nonedetermined = ldv_undef_ptr();
59
60 /* LDV_COMMENT_ASSERT Check that previos dma_mapping call was checked*/
61 ldv_assert(ldv_set_is_empty(LDV_DMA_MAP_CALLS));
62
63 ldv_set_add(LDV_DMA_MAP_CALLS, nonedetermined);
64
65 return nonedetermined;
66 }
67
68 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_initialize') Initialize all module reference counters at the beginning */
69 void ldv_initialize(void) {
70 /* LDV_COMMENT_CHANGE_STATE All module reference counters have some initial value at the beginning */
71 ldv_set_init(LDV_DMA_MAP_CALLS);
72 }
73
74 /* LDV_COMMENT_MODEL_FUNCTION_DEFINITION(name='ldv_check_final_state') Check that all module reference counters have their initial values at the end */
75 void ldv_check_final_state(void) {
76 /* LDV_COMMENT_ASSERT All incremented module reference counters should be decremented before module unloading*/
77 ldv_assert(ldv_set_is_empty(LDV_DMA_MAP_CALLS));
78 } 1 /* include this file if the platform implements the dma_ DMA Mapping API
2 * and wants to provide the pci_ DMA Mapping API in terms of it */
3
4 #ifndef _ASM_GENERIC_PCI_DMA_COMPAT_H
5 #define _ASM_GENERIC_PCI_DMA_COMPAT_H
6
7 #include <linux/dma-mapping.h>
8
9 static inline int
10 pci_dma_supported(struct pci_dev *hwdev, u64 mask)
11 {
12 return dma_supported(hwdev == NULL ? NULL : &hwdev->dev, mask);
13 }
14
15 static inline void *
16 pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
17 dma_addr_t *dma_handle)
18 {
19 return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC);
20 }
21
22 static inline void
23 pci_free_consistent(struct pci_dev *hwdev, size_t size,
24 void *vaddr, dma_addr_t dma_handle)
25 {
26 dma_free_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, vaddr, dma_handle);
27 }
28
29 static inline dma_addr_t
30 pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
31 {
32 return dma_map_single(hwdev == NULL ? NULL : &hwdev->dev, ptr, size, (enum dma_data_direction)direction);
33 }
34
35 static inline void
36 pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
37 size_t size, int direction)
38 {
39 dma_unmap_single(hwdev == NULL ? NULL : &hwdev->dev, dma_addr, size, (enum dma_data_direction)direction);
40 }
41
42 static inline dma_addr_t
43 pci_map_page(struct pci_dev *hwdev, struct page *page,
44 unsigned long offset, size_t size, int direction)
45 {
46 return dma_map_page(hwdev == NULL ? NULL : &hwdev->dev, page, offset, size, (enum dma_data_direction)direction);
47 }
48
49 static inline void
50 pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address,
51 size_t size, int direction)
52 {
53 dma_unmap_page(hwdev == NULL ? NULL : &hwdev->dev, dma_address, size, (enum dma_data_direction)direction);
54 }
55
56 static inline int
57 pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
58 int nents, int direction)
59 {
60 return dma_map_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
61 }
62
63 static inline void
64 pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
65 int nents, int direction)
66 {
67 dma_unmap_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
68 }
69
70 static inline void
71 pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle,
72 size_t size, int direction)
73 {
74 dma_sync_single_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
75 }
76
77 static inline void
78 pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle,
79 size_t size, int direction)
80 {
81 dma_sync_single_for_device(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
82 }
83
84 static inline void
85 pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg,
86 int nelems, int direction)
87 {
88 dma_sync_sg_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
89 }
90
91 static inline void
92 pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg,
93 int nelems, int direction)
94 {
95 dma_sync_sg_for_device(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
96 }
97
98 static inline int
99 pci_dma_mapping_error(struct pci_dev *pdev, dma_addr_t dma_addr)
100 {
101 return dma_mapping_error(&pdev->dev, dma_addr);
102 }
103
104 #ifdef CONFIG_PCI
105 static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
106 {
107 return dma_set_mask(&dev->dev, mask);
108 }
109
110 static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
111 {
112 return dma_set_coherent_mask(&dev->dev, mask);
113 }
114 #endif
115
116 #endif 1 #ifndef _UAPI_LINUX_SWAB_H
2 #define _UAPI_LINUX_SWAB_H
3
4 #include <linux/types.h>
5 #include <linux/compiler.h>
6 #include <asm/swab.h>
7
8 /*
9 * casts are necessary for constants, because we never know how for sure
10 * how U/UL/ULL map to __u16, __u32, __u64. At least not in a portable way.
11 */
12 #define ___constant_swab16(x) ((__u16)( \
13 (((__u16)(x) & (__u16)0x00ffU) << 8) | \
14 (((__u16)(x) & (__u16)0xff00U) >> 8)))
15
16 #define ___constant_swab32(x) ((__u32)( \
17 (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \
18 (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \
19 (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \
20 (((__u32)(x) & (__u32)0xff000000UL) >> 24)))
21
22 #define ___constant_swab64(x) ((__u64)( \
23 (((__u64)(x) & (__u64)0x00000000000000ffULL) << 56) | \
24 (((__u64)(x) & (__u64)0x000000000000ff00ULL) << 40) | \
25 (((__u64)(x) & (__u64)0x0000000000ff0000ULL) << 24) | \
26 (((__u64)(x) & (__u64)0x00000000ff000000ULL) << 8) | \
27 (((__u64)(x) & (__u64)0x000000ff00000000ULL) >> 8) | \
28 (((__u64)(x) & (__u64)0x0000ff0000000000ULL) >> 24) | \
29 (((__u64)(x) & (__u64)0x00ff000000000000ULL) >> 40) | \
30 (((__u64)(x) & (__u64)0xff00000000000000ULL) >> 56)))
31
32 #define ___constant_swahw32(x) ((__u32)( \
33 (((__u32)(x) & (__u32)0x0000ffffUL) << 16) | \
34 (((__u32)(x) & (__u32)0xffff0000UL) >> 16)))
35
36 #define ___constant_swahb32(x) ((__u32)( \
37 (((__u32)(x) & (__u32)0x00ff00ffUL) << 8) | \
38 (((__u32)(x) & (__u32)0xff00ff00UL) >> 8)))
39
40 /*
41 * Implement the following as inlines, but define the interface using
42 * macros to allow constant folding when possible:
43 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
44 */
45
46 static inline __attribute_const__ __u16 __fswab16(__u16 val)
47 {
48 #ifdef __HAVE_BUILTIN_BSWAP16__
49 return __builtin_bswap16(val);
50 #elif defined (__arch_swab16)
51 return __arch_swab16(val);
52 #else
53 return ___constant_swab16(val);
54 #endif
55 }
56
57 static inline __attribute_const__ __u32 __fswab32(__u32 val)
58 {
59 #ifdef __HAVE_BUILTIN_BSWAP32__
60 return __builtin_bswap32(val);
61 #elif defined(__arch_swab32)
62 return __arch_swab32(val);
63 #else
64 return ___constant_swab32(val);
65 #endif
66 }
67
68 static inline __attribute_const__ __u64 __fswab64(__u64 val)
69 {
70 #ifdef __HAVE_BUILTIN_BSWAP64__
71 return __builtin_bswap64(val);
72 #elif defined (__arch_swab64)
73 return __arch_swab64(val);
74 #elif defined(__SWAB_64_THRU_32__)
75 __u32 h = val >> 32;
76 __u32 l = val & ((1ULL << 32) - 1);
77 return (((__u64)__fswab32(l)) << 32) | ((__u64)(__fswab32(h)));
78 #else
79 return ___constant_swab64(val);
80 #endif
81 }
82
83 static inline __attribute_const__ __u32 __fswahw32(__u32 val)
84 {
85 #ifdef __arch_swahw32
86 return __arch_swahw32(val);
87 #else
88 return ___constant_swahw32(val);
89 #endif
90 }
91
92 static inline __attribute_const__ __u32 __fswahb32(__u32 val)
93 {
94 #ifdef __arch_swahb32
95 return __arch_swahb32(val);
96 #else
97 return ___constant_swahb32(val);
98 #endif
99 }
100
101 /**
102 * __swab16 - return a byteswapped 16-bit value
103 * @x: value to byteswap
104 */
105 #define __swab16(x) \
106 (__builtin_constant_p((__u16)(x)) ? \
107 ___constant_swab16(x) : \
108 __fswab16(x))
109
110 /**
111 * __swab32 - return a byteswapped 32-bit value
112 * @x: value to byteswap
113 */
114 #define __swab32(x) \
115 (__builtin_constant_p((__u32)(x)) ? \
116 ___constant_swab32(x) : \
117 __fswab32(x))
118
119 /**
120 * __swab64 - return a byteswapped 64-bit value
121 * @x: value to byteswap
122 */
123 #define __swab64(x) \
124 (__builtin_constant_p((__u64)(x)) ? \
125 ___constant_swab64(x) : \
126 __fswab64(x))
127
128 /**
129 * __swahw32 - return a word-swapped 32-bit value
130 * @x: value to wordswap
131 *
132 * __swahw32(0x12340000) is 0x00001234
133 */
134 #define __swahw32(x) \
135 (__builtin_constant_p((__u32)(x)) ? \
136 ___constant_swahw32(x) : \
137 __fswahw32(x))
138
139 /**
140 * __swahb32 - return a high and low byte-swapped 32-bit value
141 * @x: value to byteswap
142 *
143 * __swahb32(0x12345678) is 0x34127856
144 */
145 #define __swahb32(x) \
146 (__builtin_constant_p((__u32)(x)) ? \
147 ___constant_swahb32(x) : \
148 __fswahb32(x))
149
150 /**
151 * __swab16p - return a byteswapped 16-bit value from a pointer
152 * @p: pointer to a naturally-aligned 16-bit value
153 */
154 static inline __u16 __swab16p(const __u16 *p)
155 {
156 #ifdef __arch_swab16p
157 return __arch_swab16p(p);
158 #else
159 return __swab16(*p);
160 #endif
161 }
162
163 /**
164 * __swab32p - return a byteswapped 32-bit value from a pointer
165 * @p: pointer to a naturally-aligned 32-bit value
166 */
167 static inline __u32 __swab32p(const __u32 *p)
168 {
169 #ifdef __arch_swab32p
170 return __arch_swab32p(p);
171 #else
172 return __swab32(*p);
173 #endif
174 }
175
176 /**
177 * __swab64p - return a byteswapped 64-bit value from a pointer
178 * @p: pointer to a naturally-aligned 64-bit value
179 */
180 static inline __u64 __swab64p(const __u64 *p)
181 {
182 #ifdef __arch_swab64p
183 return __arch_swab64p(p);
184 #else
185 return __swab64(*p);
186 #endif
187 }
188
189 /**
190 * __swahw32p - return a wordswapped 32-bit value from a pointer
191 * @p: pointer to a naturally-aligned 32-bit value
192 *
193 * See __swahw32() for details of wordswapping.
194 */
195 static inline __u32 __swahw32p(const __u32 *p)
196 {
197 #ifdef __arch_swahw32p
198 return __arch_swahw32p(p);
199 #else
200 return __swahw32(*p);
201 #endif
202 }
203
204 /**
205 * __swahb32p - return a high and low byteswapped 32-bit value from a pointer
206 * @p: pointer to a naturally-aligned 32-bit value
207 *
208 * See __swahb32() for details of high/low byteswapping.
209 */
210 static inline __u32 __swahb32p(const __u32 *p)
211 {
212 #ifdef __arch_swahb32p
213 return __arch_swahb32p(p);
214 #else
215 return __swahb32(*p);
216 #endif
217 }
218
219 /**
220 * __swab16s - byteswap a 16-bit value in-place
221 * @p: pointer to a naturally-aligned 16-bit value
222 */
223 static inline void __swab16s(__u16 *p)
224 {
225 #ifdef __arch_swab16s
226 __arch_swab16s(p);
227 #else
228 *p = __swab16p(p);
229 #endif
230 }
231 /**
232 * __swab32s - byteswap a 32-bit value in-place
233 * @p: pointer to a naturally-aligned 32-bit value
234 */
235 static inline void __swab32s(__u32 *p)
236 {
237 #ifdef __arch_swab32s
238 __arch_swab32s(p);
239 #else
240 *p = __swab32p(p);
241 #endif
242 }
243
244 /**
245 * __swab64s - byteswap a 64-bit value in-place
246 * @p: pointer to a naturally-aligned 64-bit value
247 */
248 static inline void __swab64s(__u64 *p)
249 {
250 #ifdef __arch_swab64s
251 __arch_swab64s(p);
252 #else
253 *p = __swab64p(p);
254 #endif
255 }
256
257 /**
258 * __swahw32s - wordswap a 32-bit value in-place
259 * @p: pointer to a naturally-aligned 32-bit value
260 *
261 * See __swahw32() for details of wordswapping
262 */
263 static inline void __swahw32s(__u32 *p)
264 {
265 #ifdef __arch_swahw32s
266 __arch_swahw32s(p);
267 #else
268 *p = __swahw32p(p);
269 #endif
270 }
271
272 /**
273 * __swahb32s - high and low byteswap a 32-bit value in-place
274 * @p: pointer to a naturally-aligned 32-bit value
275 *
276 * See __swahb32() for details of high and low byte swapping
277 */
278 static inline void __swahb32s(__u32 *p)
279 {
280 #ifdef __arch_swahb32s
281 __arch_swahb32s(p);
282 #else
283 *p = __swahb32p(p);
284 #endif
285 }
286
287
288 #endif /* _UAPI_LINUX_SWAB_H */ 1 #ifndef _LDV_RCV_H_
2 #define _LDV_RCV_H_
3
4 /* If expr evaluates to zero, ldv_assert() causes a program to reach the error
5 label like the standard assert(). */
6 #define ldv_assert(expr) ((expr) ? 0 : ldv_error())
7
8 /* The error label wrapper. It is used because of some static verifiers (like
9 BLAST) don't accept multiple error labels through a program. */
10 static inline void ldv_error(void)
11 {
12 LDV_ERROR: goto LDV_ERROR;
13 }
14
15 /* If expr evaluates to zero, ldv_assume() causes an infinite loop that is
16 avoided by verifiers. */
17 #define ldv_assume(expr) ((expr) ? 0 : ldv_stop())
18
19 /* Infinite loop, that causes verifiers to skip such paths. */
20 static inline void ldv_stop(void) {
21 LDV_STOP: goto LDV_STOP;
22 }
23
24 /* Special nondeterministic functions. */
25 int ldv_undef_int(void);
26 void *ldv_undef_ptr(void);
27 unsigned long ldv_undef_ulong(void);
28 long ldv_undef_long(void);
29 /* Return nondeterministic negative integer number. */
30 static inline int ldv_undef_int_negative(void)
31 {
32 int ret = ldv_undef_int();
33
34 ldv_assume(ret < 0);
35
36 return ret;
37 }
38 /* Return nondeterministic nonpositive integer number. */
39 static inline int ldv_undef_int_nonpositive(void)
40 {
41 int ret = ldv_undef_int();
42
43 ldv_assume(ret <= 0);
44
45 return ret;
46 }
47
48 /* Add explicit model for __builin_expect GCC function. Without the model a
49 return value will be treated as nondetermined by verifiers. */
50 static inline long __builtin_expect(long exp, long c)
51 {
52 return exp;
53 }
54
55 /* This function causes the program to exit abnormally. GCC implements this
56 function by using a target-dependent mechanism (such as intentionally executing
57 an illegal instruction) or by calling abort. The mechanism used may vary from
58 release to release so you should not rely on any particular implementation.
59 http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html */
60 static inline void __builtin_trap(void)
61 {
62 ldv_assert(0);
63 }
64
65 /* The constant is for simulating an error of ldv_undef_ptr() function. */
66 #define LDV_PTR_MAX 2012
67
68 #endif /* _LDV_RCV_H_ */ |
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.
Kernel | Module | Rule | Verifier | Verdict | Status | Timestamp | Bug report |
linux-3.14.1.tar.xz | drivers/scsi/be2iscsi/be2iscsi.ko | 331_1a | CPAchecker | Bug | Fixed | 2016-01-16 00:47:35 | L0219 |
Comment
Reported: 16 Jan 2016
[Home]