Commit 2993cc71 authored by Krishna Gudipati's avatar Krishna Gudipati Committed by James Bottomley

[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: default avatarKrishna Gudipati <kgudipat@brocade.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 9693e7df
...@@ -142,6 +142,7 @@ bfa_pport_aen_post(struct bfa_pport_s *pport, enum bfa_port_aen_event event) ...@@ -142,6 +142,7 @@ bfa_pport_aen_post(struct bfa_pport_s *pport, enum bfa_port_aen_event event)
char pwwn_ptr[BFA_STRING_32]; char pwwn_ptr[BFA_STRING_32];
struct bfa_ioc_attr_s ioc_attr; struct bfa_ioc_attr_s ioc_attr;
memset(&aen_data, 0, sizeof(aen_data));
wwn2str(pwwn_ptr, pwwn); wwn2str(pwwn_ptr, pwwn);
switch (event) { switch (event) {
case BFA_PORT_AEN_ONLINE: case BFA_PORT_AEN_ONLINE:
......
...@@ -1731,6 +1731,21 @@ bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc, ...@@ -1731,6 +1731,21 @@ bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc,
ad_attr->cna_capable = ioc->cna; ad_attr->cna_capable = ioc->cna;
} }
enum bfa_ioc_type_e
bfa_ioc_get_type(struct bfa_ioc_s *ioc)
{
if (!ioc->ctdev || ioc->fcmode)
return BFA_IOC_TYPE_FC;
else if (ioc->ioc_mc == BFI_MC_IOCFC)
return BFA_IOC_TYPE_FCoE;
else if (ioc->ioc_mc == BFI_MC_LL)
return BFA_IOC_TYPE_LL;
else {
bfa_assert(ioc->ioc_mc == BFI_MC_LL);
return BFA_IOC_TYPE_LL;
}
}
void void
bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr) bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr)
{ {
...@@ -1739,12 +1754,7 @@ bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr) ...@@ -1739,12 +1754,7 @@ bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr)
ioc_attr->state = bfa_sm_to_state(ioc_sm_table, ioc->fsm); ioc_attr->state = bfa_sm_to_state(ioc_sm_table, ioc->fsm);
ioc_attr->port_id = ioc->port_id; ioc_attr->port_id = ioc->port_id;
if (!ioc->ctdev || ioc->fcmode) ioc_attr->ioc_type = bfa_ioc_get_type(ioc);
ioc_attr->ioc_type = BFA_IOC_TYPE_FC;
else if (ioc->ioc_mc == BFI_MC_IOCFC)
ioc_attr->ioc_type = BFA_IOC_TYPE_FCoE;
else if (ioc->ioc_mc == BFI_MC_LL)
ioc_attr->ioc_type = BFA_IOC_TYPE_LL;
bfa_ioc_get_adapter_attr(ioc, &ioc_attr->adapter_attr); bfa_ioc_get_adapter_attr(ioc, &ioc_attr->adapter_attr);
...@@ -1860,7 +1870,7 @@ bfa_ioc_aen_post(struct bfa_ioc_s *ioc, enum bfa_ioc_aen_event event) ...@@ -1860,7 +1870,7 @@ bfa_ioc_aen_post(struct bfa_ioc_s *ioc, enum bfa_ioc_aen_event event)
union bfa_aen_data_u aen_data; union bfa_aen_data_u aen_data;
struct bfa_log_mod_s *logmod = ioc->logm; struct bfa_log_mod_s *logmod = ioc->logm;
s32 inst_num = 0; s32 inst_num = 0;
struct bfa_ioc_attr_s ioc_attr; enum bfa_ioc_type_e ioc_type;
switch (event) { switch (event) {
case BFA_IOC_AEN_HBGOOD: 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,8 +1894,8 @@ bfa_ioc_aen_post(struct bfa_ioc_s *ioc, enum bfa_ioc_aen_event event)
memset(&aen_data.ioc.pwwn, 0, sizeof(aen_data.ioc.pwwn)); memset(&aen_data.ioc.pwwn, 0, sizeof(aen_data.ioc.pwwn));
memset(&aen_data.ioc.mac, 0, sizeof(aen_data.ioc.mac)); memset(&aen_data.ioc.mac, 0, sizeof(aen_data.ioc.mac));
bfa_ioc_get_attr(ioc, &ioc_attr); ioc_type = bfa_ioc_get_type(ioc);
switch (ioc_attr.ioc_type) { switch (ioc_type) {
case BFA_IOC_TYPE_FC: case BFA_IOC_TYPE_FC:
aen_data.ioc.pwwn = bfa_ioc_get_pwwn(ioc); aen_data.ioc.pwwn = bfa_ioc_get_pwwn(ioc);
break; break;
...@@ -1897,10 +1907,10 @@ bfa_ioc_aen_post(struct bfa_ioc_s *ioc, enum bfa_ioc_aen_event event) ...@@ -1897,10 +1907,10 @@ bfa_ioc_aen_post(struct bfa_ioc_s *ioc, enum bfa_ioc_aen_event event)
aen_data.ioc.mac = bfa_ioc_get_mac(ioc); aen_data.ioc.mac = bfa_ioc_get_mac(ioc);
break; break;
default: default:
bfa_assert(ioc_attr.ioc_type == BFA_IOC_TYPE_FC); bfa_assert(ioc_type == BFA_IOC_TYPE_FC);
break; break;
} }
aen_data.ioc.ioc_type = ioc_attr.ioc_type; aen_data.ioc.ioc_type = ioc_type;
} }
/** /**
......
...@@ -677,7 +677,6 @@ bfad_drv_init(struct bfad_s *bfad) ...@@ -677,7 +677,6 @@ bfad_drv_init(struct bfad_s *bfad)
bfa_status_t rc; bfa_status_t rc;
unsigned long flags; unsigned long flags;
struct bfa_fcs_driver_info_s driver_info; struct bfa_fcs_driver_info_s driver_info;
int i;
bfad->cfg_data.rport_del_timeout = rport_del_timeout; bfad->cfg_data.rport_del_timeout = rport_del_timeout;
bfad->cfg_data.lun_queue_depth = bfa_lun_queue_depth; bfad->cfg_data.lun_queue_depth = bfa_lun_queue_depth;
...@@ -697,12 +696,7 @@ bfad_drv_init(struct bfad_s *bfad) ...@@ -697,12 +696,7 @@ bfad_drv_init(struct bfad_s *bfad)
bfa_init_log(&bfad->bfa, bfad->logmod); bfa_init_log(&bfad->bfa, bfad->logmod);
bfa_init_trc(&bfad->bfa, bfad->trcmod); bfa_init_trc(&bfad->bfa, bfad->trcmod);
bfa_init_aen(&bfad->bfa, bfad->aen); bfa_init_aen(&bfad->bfa, bfad->aen);
INIT_LIST_HEAD(&bfad->file_q); memset(bfad->file_map, 0, sizeof(bfad->file_map));
INIT_LIST_HEAD(&bfad->file_free_q);
for (i = 0; i < BFAD_AEN_MAX_APPS; i++) {
bfa_q_qe_init(&bfad->file_buf[i].qe);
list_add_tail(&bfad->file_buf[i].qe, &bfad->file_free_q);
}
bfa_init_plog(&bfad->bfa, &bfad->plog_buf); bfa_init_plog(&bfad->bfa, &bfad->plog_buf);
bfa_plog_init(&bfad->plog_buf); bfa_plog_init(&bfad->plog_buf);
bfa_plog_str(&bfad->plog_buf, BFA_PL_MID_DRVR, BFA_PL_EID_DRIVER_START, 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,7 +793,6 @@ bfad_drv_uninit(struct bfad_s *bfad)
bfa_isr_disable(&bfad->bfa); bfa_isr_disable(&bfad->bfa);
bfa_detach(&bfad->bfa); bfa_detach(&bfad->bfa);
bfad_remove_intr(bfad); bfad_remove_intr(bfad);
bfa_assert(list_empty(&bfad->file_q));
bfad_hal_mem_release(bfad); bfad_hal_mem_release(bfad);
bfad->bfad_flags &= ~BFAD_DRV_INIT_DONE; bfad->bfad_flags &= ~BFAD_DRV_INIT_DONE;
......
...@@ -139,14 +139,6 @@ struct bfad_cfg_param_s { ...@@ -139,14 +139,6 @@ struct bfad_cfg_param_s {
u32 binding_method; u32 binding_method;
}; };
#define BFAD_AEN_MAX_APPS 8
struct bfad_aen_file_s {
struct list_head qe;
struct bfad_s *bfad;
s32 ri;
s32 app_id;
};
/* /*
* BFAD (PCI function) data structure * BFAD (PCI function) data structure
*/ */
...@@ -186,9 +178,7 @@ struct bfad_s { ...@@ -186,9 +178,7 @@ struct bfad_s {
struct bfa_log_mod_s *logmod; struct bfa_log_mod_s *logmod;
struct bfa_aen_s *aen; struct bfa_aen_s *aen;
struct bfa_aen_s aen_buf; struct bfa_aen_s aen_buf;
struct bfad_aen_file_s file_buf[BFAD_AEN_MAX_APPS]; void *file_map[BFA_AEN_MAX_APP];
struct list_head file_q;
struct list_head file_free_q;
struct bfa_plog_s plog_buf; struct bfa_plog_s plog_buf;
int ref_count; int ref_count;
bfa_boolean_t ipfc_enabled; bfa_boolean_t ipfc_enabled;
......
...@@ -18,21 +18,24 @@ ...@@ -18,21 +18,24 @@
#define __BFA_AEN_H__ #define __BFA_AEN_H__
#include "defs/bfa_defs_aen.h" #include "defs/bfa_defs_aen.h"
#include "defs/bfa_defs_status.h"
#include "cs/bfa_debug.h"
#define BFA_AEN_MAX_ENTRY 512 #define BFA_AEN_MAX_ENTRY 512
extern s32 bfa_aen_max_cfg_entry; extern int bfa_aen_max_cfg_entry;
struct bfa_aen_s { struct bfa_aen_s {
void *bfad; void *bfad;
s32 max_entry; int max_entry;
s32 write_index; int write_index;
s32 read_index; int read_index;
u32 bfad_num; int bfad_num;
u32 seq_num; int seq_num;
void (*aen_cb_notify)(void *bfad); void (*aen_cb_notify)(void *bfad);
void (*gettimeofday)(struct bfa_timeval_s *tv); void (*gettimeofday)(struct bfa_timeval_s *tv);
struct bfa_trc_mod_s *trcmod; struct bfa_trc_mod_s *trcmod;
struct bfa_aen_entry_s list[BFA_AEN_MAX_ENTRY]; /* Must be the last */ int app_ri[BFA_AEN_MAX_APP]; /* For multiclient support */
struct bfa_aen_entry_s list[BFA_AEN_MAX_ENTRY]; /* Must be the last */
}; };
...@@ -45,48 +48,49 @@ bfa_aen_set_max_cfg_entry(int max_entry) ...@@ -45,48 +48,49 @@ bfa_aen_set_max_cfg_entry(int max_entry)
bfa_aen_max_cfg_entry = max_entry; bfa_aen_max_cfg_entry = max_entry;
} }
static inline s32 static inline int
bfa_aen_get_max_cfg_entry(void) bfa_aen_get_max_cfg_entry(void)
{ {
return bfa_aen_max_cfg_entry; return bfa_aen_max_cfg_entry;
} }
static inline s32 static inline int
bfa_aen_get_meminfo(void) bfa_aen_get_meminfo(void)
{ {
return sizeof(struct bfa_aen_entry_s) * bfa_aen_get_max_cfg_entry(); return sizeof(struct bfa_aen_entry_s) * bfa_aen_get_max_cfg_entry();
} }
static inline s32 static inline int
bfa_aen_get_wi(struct bfa_aen_s *aen) bfa_aen_get_wi(struct bfa_aen_s *aen)
{ {
return aen->write_index; return aen->write_index;
} }
static inline s32 static inline int
bfa_aen_get_ri(struct bfa_aen_s *aen) bfa_aen_get_ri(struct bfa_aen_s *aen)
{ {
return aen->read_index; return aen->read_index;
} }
static inline s32 static inline int
bfa_aen_fetch_count(struct bfa_aen_s *aen, s32 read_index) bfa_aen_fetch_count(struct bfa_aen_s *aen, enum bfa_aen_app app_id)
{ {
return ((aen->write_index + aen->max_entry) - read_index) bfa_assert((app_id < BFA_AEN_MAX_APP) && (app_id >= bfa_aen_app_bcu));
return ((aen->write_index + aen->max_entry) - aen->app_ri[app_id])
% aen->max_entry; % aen->max_entry;
} }
s32 bfa_aen_init(struct bfa_aen_s *aen, struct bfa_trc_mod_s *trcmod, int bfa_aen_init(struct bfa_aen_s *aen, struct bfa_trc_mod_s *trcmod,
void *bfad, u32 inst_id, void (*aen_cb_notify)(void *), void *bfad, int bfad_num, void (*aen_cb_notify)(void *),
void (*gettimeofday)(struct bfa_timeval_s *)); void (*gettimeofday)(struct bfa_timeval_s *));
s32 bfa_aen_post(struct bfa_aen_s *aen, enum bfa_aen_category aen_category, void bfa_aen_post(struct bfa_aen_s *aen, enum bfa_aen_category aen_category,
int aen_type, union bfa_aen_data_u *aen_data); int aen_type, union bfa_aen_data_u *aen_data);
s32 bfa_aen_fetch(struct bfa_aen_s *aen, struct bfa_aen_entry_s *aen_entry, bfa_status_t bfa_aen_fetch(struct bfa_aen_s *aen,
s32 entry_space, s32 rii, s32 *ri_arr, struct bfa_aen_entry_s *aen_entry,
s32 ri_arr_cnt); int entry_req, enum bfa_aen_app app_id, int *entry_ret);
s32 bfa_aen_get_inst(struct bfa_aen_s *aen); int bfa_aen_get_inst(struct bfa_aen_s *aen);
#endif /* __BFA_AEN_H__ */ #endif /* __BFA_AEN_H__ */
...@@ -30,6 +30,16 @@ ...@@ -30,6 +30,16 @@
#include <defs/bfa_defs_audit.h> #include <defs/bfa_defs_audit.h>
#include <defs/bfa_defs_ethport.h> #include <defs/bfa_defs_ethport.h>
#define BFA_AEN_MAX_APP 5
enum bfa_aen_app {
bfa_aen_app_bcu = 0, /* No thread for bcu */
bfa_aen_app_hcm = 1,
bfa_aen_app_cim = 2,
bfa_aen_app_snia = 3,
bfa_aen_app_test = 4, /* To be removed after unit test */
};
enum bfa_aen_category { enum bfa_aen_category {
BFA_AEN_CAT_ADAPTER = 1, BFA_AEN_CAT_ADAPTER = 1,
BFA_AEN_CAT_PORT = 2, BFA_AEN_CAT_PORT = 2,
......
...@@ -144,8 +144,8 @@ enum bfa_ioc_aen_event { ...@@ -144,8 +144,8 @@ enum bfa_ioc_aen_event {
* BFA IOC level event data, now just a place holder * BFA IOC level event data, now just a place holder
*/ */
struct bfa_ioc_aen_data_s { struct bfa_ioc_aen_data_s {
enum bfa_ioc_type_e ioc_type;
wwn_t pwwn; wwn_t pwwn;
s16 ioc_type;
mac_t mac; mac_t mac;
}; };
......
...@@ -59,8 +59,8 @@ enum bfa_lport_aen_event { ...@@ -59,8 +59,8 @@ enum bfa_lport_aen_event {
*/ */
struct bfa_lport_aen_data_s { struct bfa_lport_aen_data_s {
u16 vf_id; /* vf_id of this logical port */ u16 vf_id; /* vf_id of this logical port */
u16 rsvd; s16 roles; /* Logical port mode,IM/TM/IP etc */
enum bfa_port_role roles; /* Logical port mode,IM/TM/IP etc */ u32 rsvd;
wwn_t ppwwn; /* WWN of its physical port */ wwn_t ppwwn; /* WWN of its physical port */
wwn_t lpwwn; /* WWN of this logical port */ wwn_t lpwwn; /* WWN of this logical port */
}; };
......
...@@ -234,14 +234,15 @@ enum bfa_port_aen_sfp_pom { ...@@ -234,14 +234,15 @@ enum bfa_port_aen_sfp_pom {
}; };
struct bfa_port_aen_data_s { struct bfa_port_aen_data_s {
enum bfa_ioc_type_e ioc_type; wwn_t pwwn; /* WWN of the physical port */
wwn_t pwwn; /* WWN of the physical port */ wwn_t fwwn; /* WWN of the fabric port */
wwn_t fwwn; /* WWN of the fabric port */ s32 phy_port_num; /*! For SFP related events */
mac_t mac; /* MAC address of the ethernet port, s16 ioc_type;
* applicable to CNA port only */ s16 level; /* Only transitions will
int phy_port_num; /*! For SFP related events */ * be informed */
enum bfa_port_aen_sfp_pom level; /* Only transitions will struct mac_s mac; /* MAC address of the ethernet port,
* be informed */ * applicable to CNA port only */
s16 rsvd;
}; };
#endif /* __BFA_DEFS_PORT_H__ */ #endif /* __BFA_DEFS_PORT_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment