aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorKrishna Gudipati <kgudipat@brocade.com>2010-03-05 22:36:47 -0500
committerJames Bottomley <James.Bottomley@suse.de>2010-03-07 02:31:23 -0500
commit2993cc71d1bff61999ade7f2b6b3ea2dd1e2c8d9 (patch)
treed4efc1c68195a0cbf4d30abcc891a78b76439755 /drivers/scsi
parent9693e7dff5c2911b4e445f5f656ef57b3a5bffac (diff)
[SCSI] bfa: AEN and byte alignment fixes.
Replace enum types with int and rearrange the fields to fix some alignment issue. Local var ioc_attr is causing the stack to overflow, so removed the usage of the local ioc_attr var and now invoking an API to return the ioc_type. Fix some AEN issues. Signed-off-by: Krishna Gudipati <kgudipat@brocade.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/bfa/bfa_fcport.c1
-rw-r--r--drivers/scsi/bfa/bfa_ioc.c32
-rw-r--r--drivers/scsi/bfa/bfad.c9
-rw-r--r--drivers/scsi/bfa/bfad_drv.h12
-rw-r--r--drivers/scsi/bfa/include/aen/bfa_aen.h50
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_aen.h10
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_ioc.h2
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_lport.h4
-rw-r--r--drivers/scsi/bfa/include/defs/bfa_defs_port.h17
9 files changed, 73 insertions, 64 deletions
diff --git a/drivers/scsi/bfa/bfa_fcport.c b/drivers/scsi/bfa/bfa_fcport.c
index 4ed048bf45cb..bdea7f0eb6bd 100644
--- a/drivers/scsi/bfa/bfa_fcport.c
+++ b/drivers/scsi/bfa/bfa_fcport.c
@@ -142,6 +142,7 @@ bfa_pport_aen_post(struct bfa_pport_s *pport, enum bfa_port_aen_event event)
142 char pwwn_ptr[BFA_STRING_32]; 142 char pwwn_ptr[BFA_STRING_32];
143 struct bfa_ioc_attr_s ioc_attr; 143 struct bfa_ioc_attr_s ioc_attr;
144 144
145 memset(&aen_data, 0, sizeof(aen_data));
145 wwn2str(pwwn_ptr, pwwn); 146 wwn2str(pwwn_ptr, pwwn);
146 switch (event) { 147 switch (event) {
147 case BFA_PORT_AEN_ONLINE: 148 case BFA_PORT_AEN_ONLINE:
diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
index 0019ff7359db..2f09d17730cc 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -1731,6 +1731,21 @@ bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc,
1731 ad_attr->cna_capable = ioc->cna; 1731 ad_attr->cna_capable = ioc->cna;
1732} 1732}
1733 1733
1734enum bfa_ioc_type_e
1735bfa_ioc_get_type(struct bfa_ioc_s *ioc)
1736{
1737 if (!ioc->ctdev || ioc->fcmode)
1738 return BFA_IOC_TYPE_FC;
1739 else if (ioc->ioc_mc == BFI_MC_IOCFC)
1740 return BFA_IOC_TYPE_FCoE;
1741 else if (ioc->ioc_mc == BFI_MC_LL)
1742 return BFA_IOC_TYPE_LL;
1743 else {
1744 bfa_assert(ioc->ioc_mc == BFI_MC_LL);
1745 return BFA_IOC_TYPE_LL;
1746 }
1747}
1748
1734void 1749void
1735bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr) 1750bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr)
1736{ 1751{
@@ -1739,12 +1754,7 @@ bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr)
1739 ioc_attr->state = bfa_sm_to_state(ioc_sm_table, ioc->fsm); 1754 ioc_attr->state = bfa_sm_to_state(ioc_sm_table, ioc->fsm);
1740 ioc_attr->port_id = ioc->port_id; 1755 ioc_attr->port_id = ioc->port_id;
1741 1756
1742 if (!ioc->ctdev || ioc->fcmode) 1757 ioc_attr->ioc_type = bfa_ioc_get_type(ioc);
1743 ioc_attr->ioc_type = BFA_IOC_TYPE_FC;
1744 else if (ioc->ioc_mc == BFI_MC_IOCFC)
1745 ioc_attr->ioc_type = BFA_IOC_TYPE_FCoE;
1746 else if (ioc->ioc_mc == BFI_MC_LL)
1747 ioc_attr->ioc_type = BFA_IOC_TYPE_LL;
1748 1758
1749 bfa_ioc_get_adapter_attr(ioc, &ioc_attr->adapter_attr); 1759 bfa_ioc_get_adapter_attr(ioc, &ioc_attr->adapter_attr);
1750 1760
@@ -1860,7 +1870,7 @@ bfa_ioc_aen_post(struct bfa_ioc_s *ioc, enum bfa_ioc_aen_event event)
1860 union bfa_aen_data_u aen_data; 1870 union bfa_aen_data_u aen_data;
1861 struct bfa_log_mod_s *logmod = ioc->logm; 1871 struct bfa_log_mod_s *logmod = ioc->logm;
1862 s32 inst_num = 0; 1872 s32 inst_num = 0;
1863 struct bfa_ioc_attr_s ioc_attr; 1873 enum bfa_ioc_type_e ioc_type;
1864 1874
1865 switch (event) { 1875 switch (event) {
1866 case BFA_IOC_AEN_HBGOOD: 1876 case BFA_IOC_AEN_HBGOOD:
@@ -1884,8 +1894,8 @@ bfa_ioc_aen_post(struct bfa_ioc_s *ioc, enum bfa_ioc_aen_event event)
1884 1894
1885 memset(&aen_data.ioc.pwwn, 0, sizeof(aen_data.ioc.pwwn)); 1895 memset(&aen_data.ioc.pwwn, 0, sizeof(aen_data.ioc.pwwn));
1886 memset(&aen_data.ioc.mac, 0, sizeof(aen_data.ioc.mac)); 1896 memset(&aen_data.ioc.mac, 0, sizeof(aen_data.ioc.mac));
1887 bfa_ioc_get_attr(ioc, &ioc_attr); 1897 ioc_type = bfa_ioc_get_type(ioc);
1888 switch (ioc_attr.ioc_type) { 1898 switch (ioc_type) {
1889 case BFA_IOC_TYPE_FC: 1899 case BFA_IOC_TYPE_FC:
1890 aen_data.ioc.pwwn = bfa_ioc_get_pwwn(ioc); 1900 aen_data.ioc.pwwn = bfa_ioc_get_pwwn(ioc);
1891 break; 1901 break;
@@ -1897,10 +1907,10 @@ bfa_ioc_aen_post(struct bfa_ioc_s *ioc, enum bfa_ioc_aen_event event)
1897 aen_data.ioc.mac = bfa_ioc_get_mac(ioc); 1907 aen_data.ioc.mac = bfa_ioc_get_mac(ioc);
1898 break; 1908 break;
1899 default: 1909 default:
1900 bfa_assert(ioc_attr.ioc_type == BFA_IOC_TYPE_FC); 1910 bfa_assert(ioc_type == BFA_IOC_TYPE_FC);
1901 break; 1911 break;
1902 } 1912 }
1903 aen_data.ioc.ioc_type = ioc_attr.ioc_type; 1913 aen_data.ioc.ioc_type = ioc_type;
1904} 1914}
1905 1915
1906/** 1916/**
diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
index 4ccaeaecd14c..79956c152af9 100644
--- a/drivers/scsi/bfa/bfad.c
+++ b/drivers/scsi/bfa/bfad.c
@@ -677,7 +677,6 @@ bfad_drv_init(struct bfad_s *bfad)
677 bfa_status_t rc; 677 bfa_status_t rc;
678 unsigned long flags; 678 unsigned long flags;
679 struct bfa_fcs_driver_info_s driver_info; 679 struct bfa_fcs_driver_info_s driver_info;
680 int i;
681 680
682 bfad->cfg_data.rport_del_timeout = rport_del_timeout; 681 bfad->cfg_data.rport_del_timeout = rport_del_timeout;
683 bfad->cfg_data.lun_queue_depth = bfa_lun_queue_depth; 682 bfad->cfg_data.lun_queue_depth = bfa_lun_queue_depth;
@@ -697,12 +696,7 @@ bfad_drv_init(struct bfad_s *bfad)
697 bfa_init_log(&bfad->bfa, bfad->logmod); 696 bfa_init_log(&bfad->bfa, bfad->logmod);
698 bfa_init_trc(&bfad->bfa, bfad->trcmod); 697 bfa_init_trc(&bfad->bfa, bfad->trcmod);
699 bfa_init_aen(&bfad->bfa, bfad->aen); 698 bfa_init_aen(&bfad->bfa, bfad->aen);
700 INIT_LIST_HEAD(&bfad->file_q); 699 memset(bfad->file_map, 0, sizeof(bfad->file_map));
701 INIT_LIST_HEAD(&bfad->file_free_q);
702 for (i = 0; i < BFAD_AEN_MAX_APPS; i++) {
703 bfa_q_qe_init(&bfad->file_buf[i].qe);
704 list_add_tail(&bfad->file_buf[i].qe, &bfad->file_free_q);
705 }
706 bfa_init_plog(&bfad->bfa, &bfad->plog_buf); 700 bfa_init_plog(&bfad->bfa, &bfad->plog_buf);
707 bfa_plog_init(&bfad->plog_buf); 701 bfa_plog_init(&bfad->plog_buf);
708 bfa_plog_str(&bfad->plog_buf, BFA_PL_MID_DRVR, BFA_PL_EID_DRIVER_START, 702 bfa_plog_str(&bfad->plog_buf, BFA_PL_MID_DRVR, BFA_PL_EID_DRIVER_START,
@@ -799,7 +793,6 @@ bfad_drv_uninit(struct bfad_s *bfad)
799 bfa_isr_disable(&bfad->bfa); 793 bfa_isr_disable(&bfad->bfa);
800 bfa_detach(&bfad->bfa); 794 bfa_detach(&bfad->bfa);
801 bfad_remove_intr(bfad); 795 bfad_remove_intr(bfad);
802 bfa_assert(list_empty(&bfad->file_q));
803 bfad_hal_mem_release(bfad); 796 bfad_hal_mem_release(bfad);
804 797
805 bfad->bfad_flags &= ~BFAD_DRV_INIT_DONE; 798 bfad->bfad_flags &= ~BFAD_DRV_INIT_DONE;
diff --git a/drivers/scsi/bfa/bfad_drv.h b/drivers/scsi/bfa/bfad_drv.h
index 9fa801a50250..94f4d84c71c9 100644
--- a/drivers/scsi/bfa/bfad_drv.h
+++ b/drivers/scsi/bfa/bfad_drv.h
@@ -139,14 +139,6 @@ struct bfad_cfg_param_s {
139 u32 binding_method; 139 u32 binding_method;
140}; 140};
141 141
142#define BFAD_AEN_MAX_APPS 8
143struct bfad_aen_file_s {
144 struct list_head qe;
145 struct bfad_s *bfad;
146 s32 ri;
147 s32 app_id;
148};
149
150/* 142/*
151 * BFAD (PCI function) data structure 143 * BFAD (PCI function) data structure
152 */ 144 */
@@ -186,9 +178,7 @@ struct bfad_s {
186 struct bfa_log_mod_s *logmod; 178 struct bfa_log_mod_s *logmod;
187 struct bfa_aen_s *aen; 179 struct bfa_aen_s *aen;
188 struct bfa_aen_s aen_buf; 180 struct bfa_aen_s aen_buf;
189 struct bfad_aen_file_s file_buf[BFAD_AEN_MAX_APPS]; 181 void *file_map[BFA_AEN_MAX_APP];
190 struct list_head file_q;
191 struct list_head file_free_q;
192 struct bfa_plog_s plog_buf; 182 struct bfa_plog_s plog_buf;
193 int ref_count; 183 int ref_count;
194 bfa_boolean_t ipfc_enabled; 184 bfa_boolean_t ipfc_enabled;
diff --git a/drivers/scsi/bfa/include/aen/bfa_aen.h b/drivers/scsi/bfa/include/aen/bfa_aen.h
index d9cbc2a783d4..6abbab005db6 100644
--- a/drivers/scsi/bfa/include/aen/bfa_aen.h
+++ b/drivers/scsi/bfa/include/aen/bfa_aen.h
@@ -18,21 +18,24 @@
18#define __BFA_AEN_H__ 18#define __BFA_AEN_H__
19 19
20#include "defs/bfa_defs_aen.h" 20#include "defs/bfa_defs_aen.h"
21#include "defs/bfa_defs_status.h"
22#include "cs/bfa_debug.h"
21 23
22#define BFA_AEN_MAX_ENTRY 512 24#define BFA_AEN_MAX_ENTRY 512
23 25
24extern s32 bfa_aen_max_cfg_entry; 26extern int bfa_aen_max_cfg_entry;
25struct bfa_aen_s { 27struct bfa_aen_s {
26 void *bfad; 28 void *bfad;
27 s32 max_entry; 29 int max_entry;
28 s32 write_index; 30 int write_index;
29 s32 read_index; 31 int read_index;
30 u32 bfad_num; 32 int bfad_num;
31 u32 seq_num; 33 int seq_num;
32 void (*aen_cb_notify)(void *bfad); 34 void (*aen_cb_notify)(void *bfad);
33 void (*gettimeofday)(struct bfa_timeval_s *tv); 35 void (*gettimeofday)(struct bfa_timeval_s *tv);
34 struct bfa_trc_mod_s *trcmod; 36 struct bfa_trc_mod_s *trcmod;
35 struct bfa_aen_entry_s list[BFA_AEN_MAX_ENTRY]; /* Must be the last */ 37 int app_ri[BFA_AEN_MAX_APP]; /* For multiclient support */
38 struct bfa_aen_entry_s list[BFA_AEN_MAX_ENTRY]; /* Must be the last */
36}; 39};
37 40
38 41
@@ -45,48 +48,49 @@ bfa_aen_set_max_cfg_entry(int max_entry)
45 bfa_aen_max_cfg_entry = max_entry; 48 bfa_aen_max_cfg_entry = max_entry;
46} 49}
47 50
48static inline s32 51static inline int
49bfa_aen_get_max_cfg_entry(void) 52bfa_aen_get_max_cfg_entry(void)
50{ 53{
51 return bfa_aen_max_cfg_entry; 54 return bfa_aen_max_cfg_entry;
52} 55}
53 56
54static inline s32 57static inline int
55bfa_aen_get_meminfo(void) 58bfa_aen_get_meminfo(void)
56{ 59{
57 return sizeof(struct bfa_aen_entry_s) * bfa_aen_get_max_cfg_entry(); 60 return sizeof(struct bfa_aen_entry_s) * bfa_aen_get_max_cfg_entry();
58} 61}
59 62
60static inline s32 63static inline int
61bfa_aen_get_wi(struct bfa_aen_s *aen) 64bfa_aen_get_wi(struct bfa_aen_s *aen)
62{ 65{
63 return aen->write_index; 66 return aen->write_index;
64} 67}
65 68
66static inline s32 69static inline int
67bfa_aen_get_ri(struct bfa_aen_s *aen) 70bfa_aen_get_ri(struct bfa_aen_s *aen)
68{ 71{
69 return aen->read_index; 72 return aen->read_index;
70} 73}
71 74
72static inline s32 75static inline int
73bfa_aen_fetch_count(struct bfa_aen_s *aen, s32 read_index) 76bfa_aen_fetch_count(struct bfa_aen_s *aen, enum bfa_aen_app app_id)
74{ 77{
75 return ((aen->write_index + aen->max_entry) - read_index) 78 bfa_assert((app_id < BFA_AEN_MAX_APP) && (app_id >= bfa_aen_app_bcu));
79 return ((aen->write_index + aen->max_entry) - aen->app_ri[app_id])
76 % aen->max_entry; 80 % aen->max_entry;
77} 81}
78 82
79s32 bfa_aen_init(struct bfa_aen_s *aen, struct bfa_trc_mod_s *trcmod, 83int bfa_aen_init(struct bfa_aen_s *aen, struct bfa_trc_mod_s *trcmod,
80 void *bfad, u32 inst_id, void (*aen_cb_notify)(void *), 84 void *bfad, int bfad_num, void (*aen_cb_notify)(void *),
81 void (*gettimeofday)(struct bfa_timeval_s *)); 85 void (*gettimeofday)(struct bfa_timeval_s *));
82 86
83s32 bfa_aen_post(struct bfa_aen_s *aen, enum bfa_aen_category aen_category, 87void bfa_aen_post(struct bfa_aen_s *aen, enum bfa_aen_category aen_category,
84 int aen_type, union bfa_aen_data_u *aen_data); 88 int aen_type, union bfa_aen_data_u *aen_data);
85 89
86s32 bfa_aen_fetch(struct bfa_aen_s *aen, struct bfa_aen_entry_s *aen_entry, 90bfa_status_t bfa_aen_fetch(struct bfa_aen_s *aen,
87 s32 entry_space, s32 rii, s32 *ri_arr, 91 struct bfa_aen_entry_s *aen_entry,
88 s32 ri_arr_cnt); 92 int entry_req, enum bfa_aen_app app_id, int *entry_ret);
89 93
90s32 bfa_aen_get_inst(struct bfa_aen_s *aen); 94int bfa_aen_get_inst(struct bfa_aen_s *aen);
91 95
92#endif /* __BFA_AEN_H__ */ 96#endif /* __BFA_AEN_H__ */
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_aen.h b/drivers/scsi/bfa/include/defs/bfa_defs_aen.h
index 4c81a613db3d..35244698fcdc 100644
--- a/drivers/scsi/bfa/include/defs/bfa_defs_aen.h
+++ b/drivers/scsi/bfa/include/defs/bfa_defs_aen.h
@@ -30,6 +30,16 @@
30#include <defs/bfa_defs_audit.h> 30#include <defs/bfa_defs_audit.h>
31#include <defs/bfa_defs_ethport.h> 31#include <defs/bfa_defs_ethport.h>
32 32
33#define BFA_AEN_MAX_APP 5
34
35enum bfa_aen_app {
36 bfa_aen_app_bcu = 0, /* No thread for bcu */
37 bfa_aen_app_hcm = 1,
38 bfa_aen_app_cim = 2,
39 bfa_aen_app_snia = 3,
40 bfa_aen_app_test = 4, /* To be removed after unit test */
41};
42
33enum bfa_aen_category { 43enum bfa_aen_category {
34 BFA_AEN_CAT_ADAPTER = 1, 44 BFA_AEN_CAT_ADAPTER = 1,
35 BFA_AEN_CAT_PORT = 2, 45 BFA_AEN_CAT_PORT = 2,
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_ioc.h b/drivers/scsi/bfa/include/defs/bfa_defs_ioc.h
index 6c721b13aca4..8d8e6a966537 100644
--- a/drivers/scsi/bfa/include/defs/bfa_defs_ioc.h
+++ b/drivers/scsi/bfa/include/defs/bfa_defs_ioc.h
@@ -144,8 +144,8 @@ enum bfa_ioc_aen_event {
144 * BFA IOC level event data, now just a place holder 144 * BFA IOC level event data, now just a place holder
145 */ 145 */
146struct bfa_ioc_aen_data_s { 146struct bfa_ioc_aen_data_s {
147 enum bfa_ioc_type_e ioc_type;
148 wwn_t pwwn; 147 wwn_t pwwn;
148 s16 ioc_type;
149 mac_t mac; 149 mac_t mac;
150}; 150};
151 151
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_lport.h b/drivers/scsi/bfa/include/defs/bfa_defs_lport.h
index 7359f82aacfc..0952a139c47c 100644
--- a/drivers/scsi/bfa/include/defs/bfa_defs_lport.h
+++ b/drivers/scsi/bfa/include/defs/bfa_defs_lport.h
@@ -59,8 +59,8 @@ enum bfa_lport_aen_event {
59 */ 59 */
60struct bfa_lport_aen_data_s { 60struct bfa_lport_aen_data_s {
61 u16 vf_id; /* vf_id of this logical port */ 61 u16 vf_id; /* vf_id of this logical port */
62 u16 rsvd; 62 s16 roles; /* Logical port mode,IM/TM/IP etc */
63 enum bfa_port_role roles; /* Logical port mode,IM/TM/IP etc */ 63 u32 rsvd;
64 wwn_t ppwwn; /* WWN of its physical port */ 64 wwn_t ppwwn; /* WWN of its physical port */
65 wwn_t lpwwn; /* WWN of this logical port */ 65 wwn_t lpwwn; /* WWN of this logical port */
66}; 66};
diff --git a/drivers/scsi/bfa/include/defs/bfa_defs_port.h b/drivers/scsi/bfa/include/defs/bfa_defs_port.h
index 1c74a8b94aad..501bc9739d9d 100644
--- a/drivers/scsi/bfa/include/defs/bfa_defs_port.h
+++ b/drivers/scsi/bfa/include/defs/bfa_defs_port.h
@@ -234,14 +234,15 @@ enum bfa_port_aen_sfp_pom {
234}; 234};
235 235
236struct bfa_port_aen_data_s { 236struct bfa_port_aen_data_s {
237 enum bfa_ioc_type_e ioc_type; 237 wwn_t pwwn; /* WWN of the physical port */
238 wwn_t pwwn; /* WWN of the physical port */ 238 wwn_t fwwn; /* WWN of the fabric port */
239 wwn_t fwwn; /* WWN of the fabric port */ 239 s32 phy_port_num; /*! For SFP related events */
240 mac_t mac; /* MAC address of the ethernet port, 240 s16 ioc_type;
241 * applicable to CNA port only */ 241 s16 level; /* Only transitions will
242 int phy_port_num; /*! For SFP related events */ 242 * be informed */
243 enum bfa_port_aen_sfp_pom level; /* Only transitions will 243 struct mac_s mac; /* MAC address of the ethernet port,
244 * be informed */ 244 * applicable to CNA port only */
245 s16 rsvd;
245}; 246};
246 247
247#endif /* __BFA_DEFS_PORT_H__ */ 248#endif /* __BFA_DEFS_PORT_H__ */