aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bfa
diff options
context:
space:
mode:
authorKrishna Gudipati <kgudipat@brocade.com>2011-06-13 18:39:36 -0400
committerJames Bottomley <JBottomley@Parallels.com>2011-06-29 16:24:46 -0400
commit85ce928dbb87585042e7dfebe513f724eadebd5e (patch)
tree121604b0dfe16ea282b378901e1b00d85f215f97 /drivers/scsi/bfa
parent4d08e731bd6e3c5fd0b65bcfba22dc159fec3487 (diff)
[SCSI] bfa: Introduced generic address len pair to represent DMA memory chunk.
- Avoid the use of hardware defined structure bfi_sge_s for DMA requests in host. - Defined a generic address len pair to represent a DMA memory chunk (bfi_alen_s). Signed-off-by: Krishna Gudipati <kgudipat@brocade.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/bfa')
-rw-r--r--drivers/scsi/bfa/bfa_ioc.h22
-rw-r--r--drivers/scsi/bfa/bfa_svc.c53
-rw-r--r--drivers/scsi/bfa/bfi.h10
-rw-r--r--drivers/scsi/bfa/bfi_ms.h6
4 files changed, 32 insertions, 59 deletions
diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
index c85182a704fb..62318d24f85e 100644
--- a/drivers/scsi/bfa/bfa_ioc.h
+++ b/drivers/scsi/bfa/bfa_ioc.h
@@ -112,18 +112,6 @@ struct bfa_dma_s {
112#define BFI_SMEM_CB_SIZE 0x200000U /* ! 2MB for crossbow */ 112#define BFI_SMEM_CB_SIZE 0x200000U /* ! 2MB for crossbow */
113#define BFI_SMEM_CT_SIZE 0x280000U /* ! 2.5MB for catapult */ 113#define BFI_SMEM_CT_SIZE 0x280000U /* ! 2.5MB for catapult */
114 114
115
116#define bfa_dma_addr_set(dma_addr, pa) \
117 __bfa_dma_addr_set(&dma_addr, (u64)pa)
118
119static inline void
120__bfa_dma_addr_set(union bfi_addr_u *dma_addr, u64 pa)
121{
122 dma_addr->a32.addr_lo = (__be32) pa;
123 dma_addr->a32.addr_hi = (__be32) (pa >> 32);
124}
125
126
127#define bfa_dma_be_addr_set(dma_addr, pa) \ 115#define bfa_dma_be_addr_set(dma_addr, pa) \
128 __bfa_dma_be_addr_set(&dma_addr, (u64)pa) 116 __bfa_dma_be_addr_set(&dma_addr, (u64)pa)
129static inline void 117static inline void
@@ -133,6 +121,16 @@ __bfa_dma_be_addr_set(union bfi_addr_u *dma_addr, u64 pa)
133 dma_addr->a32.addr_hi = cpu_to_be32(pa >> 32); 121 dma_addr->a32.addr_hi = cpu_to_be32(pa >> 32);
134} 122}
135 123
124#define bfa_alen_set(__alen, __len, __pa) \
125 __bfa_alen_set(__alen, __len, (u64)__pa)
126
127static inline void
128__bfa_alen_set(struct bfi_alen_s *alen, u32 len, u64 pa)
129{
130 alen->al_len = cpu_to_be32(len);
131 bfa_dma_be_addr_set(alen->al_addr, pa);
132}
133
136struct bfa_ioc_regs_s { 134struct bfa_ioc_regs_s {
137 void __iomem *hfn_mbox_cmd; 135 void __iomem *hfn_mbox_cmd;
138 void __iomem *hfn_mbox; 136 void __iomem *hfn_mbox;
diff --git a/drivers/scsi/bfa/bfa_svc.c b/drivers/scsi/bfa/bfa_svc.c
index 16d9a5f61c18..d1674c6058ed 100644
--- a/drivers/scsi/bfa/bfa_svc.c
+++ b/drivers/scsi/bfa/bfa_svc.c
@@ -750,23 +750,6 @@ hal_fcxp_send_comp(struct bfa_s *bfa, struct bfi_fcxp_send_rsp_s *fcxp_rsp)
750} 750}
751 751
752static void 752static void
753hal_fcxp_set_local_sges(struct bfi_sge_s *sge, u32 reqlen, u64 req_pa)
754{
755 union bfi_addr_u sga_zero = { {0} };
756
757 sge->sg_len = reqlen;
758 sge->flags = BFI_SGE_DATA_LAST;
759 bfa_dma_addr_set(sge[0].sga, req_pa);
760 bfa_sge_to_be(sge);
761 sge++;
762
763 sge->sga = sga_zero;
764 sge->sg_len = reqlen;
765 sge->flags = BFI_SGE_PGDLEN;
766 bfa_sge_to_be(sge);
767}
768
769static void
770hal_fcxp_tx_plog(struct bfa_s *bfa, u32 reqlen, struct bfa_fcxp_s *fcxp, 753hal_fcxp_tx_plog(struct bfa_s *bfa, u32 reqlen, struct bfa_fcxp_s *fcxp,
771 struct fchs_s *fchs) 754 struct fchs_s *fchs)
772{ 755{
@@ -873,18 +856,16 @@ bfa_fcxp_queue(struct bfa_fcxp_s *fcxp, struct bfi_fcxp_send_req_s *send_req)
873 * setup req sgles 856 * setup req sgles
874 */ 857 */
875 if (fcxp->use_ireqbuf == 1) { 858 if (fcxp->use_ireqbuf == 1) {
876 hal_fcxp_set_local_sges(send_req->req_sge, reqi->req_tot_len, 859 bfa_alen_set(&send_req->req_alen, reqi->req_tot_len,
877 BFA_FCXP_REQ_PLD_PA(fcxp)); 860 BFA_FCXP_REQ_PLD_PA(fcxp));
878 } else { 861 } else {
879 if (fcxp->nreq_sgles > 0) { 862 if (fcxp->nreq_sgles > 0) {
880 WARN_ON(fcxp->nreq_sgles != 1); 863 WARN_ON(fcxp->nreq_sgles != 1);
881 hal_fcxp_set_local_sges(send_req->req_sge, 864 bfa_alen_set(&send_req->req_alen, reqi->req_tot_len,
882 reqi->req_tot_len, 865 fcxp->req_sga_cbfn(fcxp->caller, 0));
883 fcxp->req_sga_cbfn(fcxp->caller,
884 0));
885 } else { 866 } else {
886 WARN_ON(reqi->req_tot_len != 0); 867 WARN_ON(reqi->req_tot_len != 0);
887 hal_fcxp_set_local_sges(send_req->rsp_sge, 0, 0); 868 bfa_alen_set(&send_req->rsp_alen, 0, 0);
888 } 869 }
889 } 870 }
890 871
@@ -894,19 +875,17 @@ bfa_fcxp_queue(struct bfa_fcxp_s *fcxp, struct bfi_fcxp_send_req_s *send_req)
894 if (fcxp->use_irspbuf == 1) { 875 if (fcxp->use_irspbuf == 1) {
895 WARN_ON(rspi->rsp_maxlen > BFA_FCXP_MAX_LBUF_SZ); 876 WARN_ON(rspi->rsp_maxlen > BFA_FCXP_MAX_LBUF_SZ);
896 877
897 hal_fcxp_set_local_sges(send_req->rsp_sge, rspi->rsp_maxlen, 878 bfa_alen_set(&send_req->rsp_alen, rspi->rsp_maxlen,
898 BFA_FCXP_RSP_PLD_PA(fcxp)); 879 BFA_FCXP_RSP_PLD_PA(fcxp));
899
900 } else { 880 } else {
901 if (fcxp->nrsp_sgles > 0) { 881 if (fcxp->nrsp_sgles > 0) {
902 WARN_ON(fcxp->nrsp_sgles != 1); 882 WARN_ON(fcxp->nrsp_sgles != 1);
903 hal_fcxp_set_local_sges(send_req->rsp_sge, 883 bfa_alen_set(&send_req->rsp_alen, rspi->rsp_maxlen,
904 rspi->rsp_maxlen, 884 fcxp->rsp_sga_cbfn(fcxp->caller, 0));
905 fcxp->rsp_sga_cbfn(fcxp->caller, 885
906 0));
907 } else { 886 } else {
908 WARN_ON(rspi->rsp_maxlen != 0); 887 WARN_ON(rspi->rsp_maxlen != 0);
909 hal_fcxp_set_local_sges(send_req->rsp_sge, 0, 0); 888 bfa_alen_set(&send_req->rsp_alen, 0, 0);
910 } 889 }
911 } 890 }
912 891
@@ -4801,8 +4780,6 @@ static void
4801claim_uf_post_msgs(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi) 4780claim_uf_post_msgs(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi)
4802{ 4781{
4803 struct bfi_uf_buf_post_s *uf_bp_msg; 4782 struct bfi_uf_buf_post_s *uf_bp_msg;
4804 struct bfi_sge_s *sge;
4805 union bfi_addr_u sga_zero = { {0} };
4806 u16 i; 4783 u16 i;
4807 u16 buf_len; 4784 u16 buf_len;
4808 4785
@@ -4818,17 +4795,7 @@ claim_uf_post_msgs(struct bfa_uf_mod_s *ufm, struct bfa_meminfo_s *mi)
4818 uf_bp_msg->buf_len = cpu_to_be16(buf_len); 4795 uf_bp_msg->buf_len = cpu_to_be16(buf_len);
4819 bfi_h2i_set(uf_bp_msg->mh, BFI_MC_UF, BFI_UF_H2I_BUF_POST, 4796 bfi_h2i_set(uf_bp_msg->mh, BFI_MC_UF, BFI_UF_H2I_BUF_POST,
4820 bfa_lpuid(ufm->bfa)); 4797 bfa_lpuid(ufm->bfa));
4821 4798 bfa_alen_set(&uf_bp_msg->alen, buf_len, ufm_pbs_pa(ufm, i));
4822 sge = uf_bp_msg->sge;
4823 sge[0].sg_len = buf_len;
4824 sge[0].flags = BFI_SGE_DATA_LAST;
4825 bfa_dma_addr_set(sge[0].sga, ufm_pbs_pa(ufm, i));
4826 bfa_sge_to_be(sge);
4827
4828 sge[1].sg_len = buf_len;
4829 sge[1].flags = BFI_SGE_PGDLEN;
4830 sge[1].sga = sga_zero;
4831 bfa_sge_to_be(&sge[1]);
4832 } 4799 }
4833 4800
4834 /* 4801 /*
diff --git a/drivers/scsi/bfa/bfi.h b/drivers/scsi/bfa/bfi.h
index 72b69a0c3b51..6ef1ba50ecf9 100644
--- a/drivers/scsi/bfa/bfi.h
+++ b/drivers/scsi/bfa/bfi.h
@@ -101,7 +101,7 @@ union bfi_addr_u {
101}; 101};
102 102
103/* 103/*
104 * Scatter Gather Element 104 * Scatter Gather Element used for fast-path IO requests
105 */ 105 */
106struct bfi_sge_s { 106struct bfi_sge_s {
107#ifdef __BIG_ENDIAN 107#ifdef __BIG_ENDIAN
@@ -116,6 +116,14 @@ struct bfi_sge_s {
116 union bfi_addr_u sga; 116 union bfi_addr_u sga;
117}; 117};
118 118
119/**
120 * Generic DMA addr-len pair.
121 */
122struct bfi_alen_s {
123 union bfi_addr_u al_addr; /* DMA addr of buffer */
124 u32 al_len; /* length of buffer */
125};
126
119/* 127/*
120 * Scatter Gather Page 128 * Scatter Gather Page
121 */ 129 */
diff --git a/drivers/scsi/bfa/bfi_ms.h b/drivers/scsi/bfa/bfi_ms.h
index 19e888a57555..a29d905fe8c0 100644
--- a/drivers/scsi/bfa/bfi_ms.h
+++ b/drivers/scsi/bfa/bfi_ms.h
@@ -297,8 +297,8 @@ struct bfi_fcxp_send_req_s {
297 struct fchs_s fchs; /* request FC header structure */ 297 struct fchs_s fchs; /* request FC header structure */
298 __be32 req_len; /* request payload length */ 298 __be32 req_len; /* request payload length */
299 __be32 rsp_maxlen; /* max response length expected */ 299 __be32 rsp_maxlen; /* max response length expected */
300 struct bfi_sge_s req_sge[BFA_FCXP_MAX_SGES]; /* request buf */ 300 struct bfi_alen_s req_alen; /* request buffer */
301 struct bfi_sge_s rsp_sge[BFA_FCXP_MAX_SGES]; /* response buf */ 301 struct bfi_alen_s rsp_alen; /* response buffer */
302}; 302};
303 303
304/* 304/*
@@ -328,7 +328,7 @@ struct bfi_uf_buf_post_s {
328 struct bfi_mhdr_s mh; /* Common msg header */ 328 struct bfi_mhdr_s mh; /* Common msg header */
329 u16 buf_tag; /* buffer tag */ 329 u16 buf_tag; /* buffer tag */
330 __be16 buf_len; /* total buffer length */ 330 __be16 buf_len; /* total buffer length */
331 struct bfi_sge_s sge[BFA_UF_MAX_SGES]; /* buffer DMA SGEs */ 331 struct bfi_alen_s alen; /* buffer address/len pair */
332}; 332};
333 333
334struct bfi_uf_frm_rcvd_s { 334struct bfi_uf_frm_rcvd_s {