diff options
author | Krishna Gudipati <kgudipat@brocade.com> | 2010-09-15 11:50:55 -0700 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-09-16 22:54:24 -0400 |
commit | a36c61f9025b8924f99f54d518763bee7aa84085 (patch) | |
tree | e1d58c382ad31fe1ad3c5f6bccde1b9df1d9fd8c /drivers/scsi/bfa/bfa_port.c | |
parent | edaed859e63aac174fcc3fed81886b91bb124661 (diff) | |
download | linux-a36c61f9025b8924f99f54d518763bee7aa84085.tar.gz linux-a36c61f9025b8924f99f54d518763bee7aa84085.tar.bz2 linux-a36c61f9025b8924f99f54d518763bee7aa84085.zip |
[SCSI] bfa: cleanup driver
We have flattened the BFA hierarchy and also reduced the number of
source and header files we used to have earlier.
Signed-off-by: Krishna Gudipati <kgudipat@brocade.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/bfa/bfa_port.c')
-rw-r--r-- | drivers/scsi/bfa/bfa_port.c | 134 |
1 files changed, 62 insertions, 72 deletions
diff --git a/drivers/scsi/bfa/bfa_port.c b/drivers/scsi/bfa/bfa_port.c index c7e69f1e56e3..b6d170a13bea 100644 --- a/drivers/scsi/bfa/bfa_port.c +++ b/drivers/scsi/bfa/bfa_port.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. + * Copyright (c) 2005-2010 Brocade Communications Systems, Inc. * All rights reserved * www.brocade.com * @@ -15,30 +15,25 @@ * General Public License for more details. */ -#include <defs/bfa_defs_port.h> -#include <cs/bfa_trc.h> -#include <cs/bfa_log.h> -#include <cs/bfa_debug.h> -#include <port/bfa_port.h> -#include <bfi/bfi.h> -#include <bfi/bfi_port.h> -#include <bfa_ioc.h> -#include <cna/bfa_cna_trcmod.h> +#include "bfa_defs_svc.h" +#include "bfa_port.h" +#include "bfi.h" +#include "bfa_ioc.h" + BFA_TRC_FILE(CNA, PORT); #define bfa_ioc_portid(__ioc) ((__ioc)->port_id) -#define bfa_lpuid(__arg) bfa_ioc_portid(&(__arg)->ioc) static void -bfa_port_stats_swap(struct bfa_port_s *port, union bfa_pport_stats_u *stats) +bfa_port_stats_swap(struct bfa_port_s *port, union bfa_port_stats_u *stats) { - u32 *dip = (u32 *) stats; - u32 t0, t1; - int i; + u32 *dip = (u32 *) stats; + u32 t0, t1; + int i; - for (i = 0; i < sizeof(union bfa_pport_stats_u) / sizeof(u32); - i += 2) { + for (i = 0; i < sizeof(union bfa_port_stats_u)/sizeof(u32); + i += 2) { t0 = dip[i]; t1 = dip[i + 1]; #ifdef __BIGENDIAN @@ -49,11 +44,6 @@ bfa_port_stats_swap(struct bfa_port_s *port, union bfa_pport_stats_u *stats) dip[i + 1] = bfa_os_ntohl(t0); #endif } - - /** todo - * QoS stats r also swapped as 64bit; that structure also - * has to use 64 bit counters - */ } /** @@ -68,7 +58,9 @@ bfa_port_stats_swap(struct bfa_port_s *port, union bfa_pport_stats_u *stats) static void bfa_port_enable_isr(struct bfa_port_s *port, bfa_status_t status) { - bfa_assert(0); + bfa_trc(port, status); + port->endis_pending = BFA_FALSE; + port->endis_cbfn(port->endis_cbarg, status); } /** @@ -83,7 +75,9 @@ bfa_port_enable_isr(struct bfa_port_s *port, bfa_status_t status) static void bfa_port_disable_isr(struct bfa_port_s *port, bfa_status_t status) { - bfa_assert(0); + bfa_trc(port, status); + port->endis_pending = BFA_FALSE; + port->endis_cbfn(port->endis_cbarg, status); } /** @@ -105,7 +99,7 @@ bfa_port_get_stats_isr(struct bfa_port_s *port, bfa_status_t status) struct bfa_timeval_s tv; memcpy(port->stats, port->stats_dma.kva, - sizeof(union bfa_pport_stats_u)); + sizeof(union bfa_port_stats_u)); bfa_port_stats_swap(port, port->stats); bfa_os_gettimeofday(&tv); @@ -133,11 +127,11 @@ bfa_port_clear_stats_isr(struct bfa_port_s *port, bfa_status_t status) struct bfa_timeval_s tv; port->stats_status = status; - port->stats_busy = BFA_FALSE; + port->stats_busy = BFA_FALSE; /** - * re-initialize time stamp for stats reset - */ + * re-initialize time stamp for stats reset + */ bfa_os_gettimeofday(&tv); port->stats_reset_time = tv.tv_sec; @@ -158,10 +152,10 @@ bfa_port_clear_stats_isr(struct bfa_port_s *port, bfa_status_t status) static void bfa_port_isr(void *cbarg, struct bfi_mbmsg_s *m) { - struct bfa_port_s *port = (struct bfa_port_s *)cbarg; + struct bfa_port_s *port = (struct bfa_port_s *) cbarg; union bfi_port_i2h_msg_u *i2hmsg; - i2hmsg = (union bfi_port_i2h_msg_u *)m; + i2hmsg = (union bfi_port_i2h_msg_u *) m; bfa_trc(port, m->mh.msg_id); switch (m->mh.msg_id) { @@ -178,9 +172,7 @@ bfa_port_isr(void *cbarg, struct bfi_mbmsg_s *m) break; case BFI_PORT_I2H_GET_STATS_RSP: - /* - * Stats busy flag is still set? (may be cmd timed out) - */ + /* Stats busy flag is still set? (may be cmd timed out) */ if (port->stats_busy == BFA_FALSE) break; bfa_port_get_stats_isr(port, i2hmsg->getstats_rsp.status); @@ -208,7 +200,7 @@ bfa_port_isr(void *cbarg, struct bfi_mbmsg_s *m) u32 bfa_port_meminfo(void) { - return BFA_ROUNDUP(sizeof(union bfa_pport_stats_u), BFA_DMA_ALIGN_SZ); + return BFA_ROUNDUP(sizeof(union bfa_port_stats_u), BFA_DMA_ALIGN_SZ); } /** @@ -216,8 +208,8 @@ bfa_port_meminfo(void) * * * @param[in] port Port module pointer - * dma_kva Kernel Virtual Address of Port DMA Memory - * dma_pa Physical Address of Port DMA Memory + * dma_kva Kernel Virtual Address of Port DMA Memory + * dma_pa Physical Address of Port DMA Memory * * @return void */ @@ -225,7 +217,7 @@ void bfa_port_mem_claim(struct bfa_port_s *port, u8 *dma_kva, u64 dma_pa) { port->stats_dma.kva = dma_kva; - port->stats_dma.pa = dma_pa; + port->stats_dma.pa = dma_pa; } /** @@ -239,12 +231,14 @@ bfa_port_mem_claim(struct bfa_port_s *port, u8 *dma_kva, u64 dma_pa) */ bfa_status_t bfa_port_enable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn, - void *cbarg) + void *cbarg) { struct bfi_port_generic_req_s *m; - /** todo Not implemented */ - bfa_assert(0); + if (bfa_ioc_is_disabled(port->ioc)) { + bfa_trc(port, BFA_STATUS_IOC_DISABLED); + return BFA_STATUS_IOC_DISABLED; + } if (!bfa_ioc_is_operational(port->ioc)) { bfa_trc(port, BFA_STATUS_IOC_FAILURE); @@ -256,11 +250,11 @@ bfa_port_enable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn, return BFA_STATUS_DEVBUSY; } - m = (struct bfi_port_generic_req_s *)port->endis_mb.msg; + m = (struct bfi_port_generic_req_s *) port->endis_mb.msg; port->msgtag++; - port->endis_cbfn = cbfn; - port->endis_cbarg = cbarg; + port->endis_cbfn = cbfn; + port->endis_cbarg = cbarg; port->endis_pending = BFA_TRUE; bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_ENABLE_REQ, @@ -281,12 +275,14 @@ bfa_port_enable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn, */ bfa_status_t bfa_port_disable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn, - void *cbarg) + void *cbarg) { struct bfi_port_generic_req_s *m; - /** todo Not implemented */ - bfa_assert(0); + if (bfa_ioc_is_disabled(port->ioc)) { + bfa_trc(port, BFA_STATUS_IOC_DISABLED); + return BFA_STATUS_IOC_DISABLED; + } if (!bfa_ioc_is_operational(port->ioc)) { bfa_trc(port, BFA_STATUS_IOC_FAILURE); @@ -298,11 +294,11 @@ bfa_port_disable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn, return BFA_STATUS_DEVBUSY; } - m = (struct bfi_port_generic_req_s *)port->endis_mb.msg; + m = (struct bfi_port_generic_req_s *) port->endis_mb.msg; port->msgtag++; - port->endis_cbfn = cbfn; - port->endis_cbarg = cbarg; + port->endis_cbfn = cbfn; + port->endis_cbarg = cbarg; port->endis_pending = BFA_TRUE; bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_DISABLE_REQ, @@ -322,8 +318,8 @@ bfa_port_disable(struct bfa_port_s *port, bfa_port_endis_cbfn_t cbfn, * @return Status */ bfa_status_t -bfa_port_get_stats(struct bfa_port_s *port, union bfa_pport_stats_u *stats, - bfa_port_stats_cbfn_t cbfn, void *cbarg) +bfa_port_get_stats(struct bfa_port_s *port, union bfa_port_stats_u *stats, + bfa_port_stats_cbfn_t cbfn, void *cbarg) { struct bfi_port_get_stats_req_s *m; @@ -337,12 +333,12 @@ bfa_port_get_stats(struct bfa_port_s *port, union bfa_pport_stats_u *stats, return BFA_STATUS_DEVBUSY; } - m = (struct bfi_port_get_stats_req_s *)port->stats_mb.msg; + m = (struct bfi_port_get_stats_req_s *) port->stats_mb.msg; - port->stats = stats; - port->stats_cbfn = cbfn; + port->stats = stats; + port->stats_cbfn = cbfn; port->stats_cbarg = cbarg; - port->stats_busy = BFA_TRUE; + port->stats_busy = BFA_TRUE; bfa_dma_be_addr_set(m->dma_addr, port->stats_dma.pa); bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_GET_STATS_REQ, @@ -362,7 +358,7 @@ bfa_port_get_stats(struct bfa_port_s *port, union bfa_pport_stats_u *stats, */ bfa_status_t bfa_port_clear_stats(struct bfa_port_s *port, bfa_port_stats_cbfn_t cbfn, - void *cbarg) + void *cbarg) { struct bfi_port_generic_req_s *m; @@ -376,11 +372,11 @@ bfa_port_clear_stats(struct bfa_port_s *port, bfa_port_stats_cbfn_t cbfn, return BFA_STATUS_DEVBUSY; } - m = (struct bfi_port_generic_req_s *)port->stats_mb.msg; + m = (struct bfi_port_generic_req_s *) port->stats_mb.msg; - port->stats_cbfn = cbfn; + port->stats_cbfn = cbfn; port->stats_cbarg = cbarg; - port->stats_busy = BFA_TRUE; + port->stats_busy = BFA_TRUE; bfi_h2i_set(m->mh, BFI_MC_PORT, BFI_PORT_H2I_CLEAR_STATS_REQ, bfa_ioc_portid(port->ioc)); @@ -400,11 +396,9 @@ bfa_port_clear_stats(struct bfa_port_s *port, bfa_port_stats_cbfn_t cbfn, void bfa_port_hbfail(void *arg) { - struct bfa_port_s *port = (struct bfa_port_s *)arg; + struct bfa_port_s *port = (struct bfa_port_s *) arg; - /* - * Fail any pending get_stats/clear_stats requests - */ + /* Fail any pending get_stats/clear_stats requests */ if (port->stats_busy) { if (port->stats_cbfn) port->stats_cbfn(port->stats_cbarg, BFA_STATUS_FAILED); @@ -412,9 +406,7 @@ bfa_port_hbfail(void *arg) port->stats_busy = BFA_FALSE; } - /* - * Clear any enable/disable is pending - */ + /* Clear any enable/disable is pending */ if (port->endis_pending) { if (port->endis_cbfn) port->endis_cbfn(port->endis_cbarg, BFA_STATUS_FAILED); @@ -433,22 +425,20 @@ bfa_port_hbfail(void *arg) * The device driver specific mbox ISR functions have * this pointer as one of the parameters. * trcmod - - * logmod - * * @return void */ void -bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc, void *dev, - struct bfa_trc_mod_s *trcmod, struct bfa_log_mod_s *logmod) +bfa_port_attach(struct bfa_port_s *port, struct bfa_ioc_s *ioc, + void *dev, struct bfa_trc_mod_s *trcmod) { struct bfa_timeval_s tv; bfa_assert(port); - port->dev = dev; - port->ioc = ioc; + port->dev = dev; + port->ioc = ioc; port->trcmod = trcmod; - port->logmod = logmod; port->stats_busy = BFA_FALSE; port->endis_pending = BFA_FALSE; |