Skip to contentSkip to conversation

bfa: remove os wrapper functions and macros

PATCH In review Jing Huang 4 participants 7 messages Oct 19, 2010 – Oct 20, 2010

Subsystems (2)
lore
Share & tools
lore

Jing Huang

author
#0 lore raw

PATCH 3/6 bfa: remove os wrapper functions and macros

This patch replaces register access functions and macros with the the ones provided by linux.

---
 drivers/scsi/bfa/bfa.h          |   24 ++++----
 drivers/scsi/bfa/bfa_core.c     |   32 +++++-----
 drivers/scsi/bfa/bfa_hw_cb.c    |   10 ++--
 drivers/scsi/bfa/bfa_hw_ct.c    |   16 +++---
 drivers/scsi/bfa/bfa_ioc.c      |  117 ++++++++++++++++++--------------------
 drivers/scsi/bfa/bfa_ioc.h      |   66 ++++++++++-----------
 drivers/scsi/bfa/bfa_ioc_cb.c   |   64 ++++++++++-----------
 drivers/scsi/bfa/bfa_ioc_ct.c   |  119 +++++++++++++++++++--------------------
 drivers/scsi/bfa/bfa_os_inc.h   |   32 +++--------
 drivers/scsi/bfa/bfad_debugfs.c |    4 +-
 10 files changed, 226 insertions(+), 258 deletions(-)
drivers/scsi/bfa/bfa.h +12 -12
index ceaac65..c3981df 100644
@@ -59,8 +59,8 @@ void bfa_isr_bind(enum bfi_mclass mc, bfa_isr_func_t isr_func);
 		(__bfa)->iocfc.req_cq_pi[__reqq]++;			\
 		(__bfa)->iocfc.req_cq_pi[__reqq] &=			\
 			((__bfa)->iocfc.cfg.drvcfg.num_reqq_elems - 1);      \
-		bfa_reg_write((__bfa)->iocfc.bfa_regs.cpe_q_pi[__reqq],	\
-			      (__bfa)->iocfc.req_cq_pi[__reqq]);      \
+		writel((__bfa)->iocfc.req_cq_pi[__reqq], 		\
+			(__bfa)->iocfc.bfa_regs.cpe_q_pi[__reqq]);	\
 		mmiowb();      \
 	} while (0)
 
@@ -202,16 +202,16 @@ struct bfa_meminfo_s {
 	((_m)->meminfo[BFA_MEM_TYPE_DMA - 1].dma_curp)
 
 struct bfa_iocfc_regs_s {
-	bfa_os_addr_t   intr_status;
-	bfa_os_addr_t   intr_mask;
-	bfa_os_addr_t   cpe_q_pi[BFI_IOC_MAX_CQS];
-	bfa_os_addr_t   cpe_q_ci[BFI_IOC_MAX_CQS];
-	bfa_os_addr_t   cpe_q_depth[BFI_IOC_MAX_CQS];
-	bfa_os_addr_t   cpe_q_ctrl[BFI_IOC_MAX_CQS];
-	bfa_os_addr_t   rme_q_ci[BFI_IOC_MAX_CQS];
-	bfa_os_addr_t   rme_q_pi[BFI_IOC_MAX_CQS];
-	bfa_os_addr_t   rme_q_depth[BFI_IOC_MAX_CQS];
-	bfa_os_addr_t   rme_q_ctrl[BFI_IOC_MAX_CQS];
+	void __iomem	*intr_status;
+	void __iomem 	*intr_mask;
+	void __iomem	*cpe_q_pi[BFI_IOC_MAX_CQS];
+	void __iomem	*cpe_q_ci[BFI_IOC_MAX_CQS];
+	void __iomem	*cpe_q_depth[BFI_IOC_MAX_CQS];
+	void __iomem	*cpe_q_ctrl[BFI_IOC_MAX_CQS];
+	void __iomem	*rme_q_ci[BFI_IOC_MAX_CQS];
+	void __iomem	*rme_q_pi[BFI_IOC_MAX_CQS];
+	void __iomem	*rme_q_depth[BFI_IOC_MAX_CQS];
+	void __iomem	*rme_q_ctrl[BFI_IOC_MAX_CQS];
 };
 
 /**
drivers/scsi/bfa/bfa_core.c +16 -16
index 7366924..f75c6be 100644
@@ -113,7 +113,7 @@ bfa_intx(struct bfa_s *bfa)
 	u32 intr, qintr;
 	int queue;
 
-	intr = bfa_reg_read(bfa->iocfc.bfa_regs.intr_status);
+	intr = readl(bfa->iocfc.bfa_regs.intr_status);
 	if (!intr)
 		return BFA_FALSE;
 
@@ -121,7 +121,7 @@ bfa_intx(struct bfa_s *bfa)
 	 * RME completion queue interrupt
 	 */
 	qintr = intr & __HFN_INT_RME_MASK;
-	bfa_reg_write(bfa->iocfc.bfa_regs.intr_status, qintr);
+	writel(qintr, bfa->iocfc.bfa_regs.intr_status);
 
 	for (queue = 0; queue < BFI_IOC_MAX_CQS_ASIC; queue++) {
 		if (intr & (__HFN_INT_RME_Q0 << queue))
@@ -135,7 +135,7 @@ bfa_intx(struct bfa_s *bfa)
 	 * CPE completion queue interrupt
 	 */
 	qintr = intr & __HFN_INT_CPE_MASK;
-	bfa_reg_write(bfa->iocfc.bfa_regs.intr_status, qintr);
+	writel(qintr, bfa->iocfc.bfa_regs.intr_status);
 
 	for (queue = 0; queue < BFI_IOC_MAX_CQS_ASIC; queue++) {
 		if (intr & (__HFN_INT_CPE_Q0 << queue))
@@ -153,13 +153,13 @@ bfa_intx(struct bfa_s *bfa)
 void
 bfa_intx_enable(struct bfa_s *bfa)
 {
-	bfa_reg_write(bfa->iocfc.bfa_regs.intr_mask, bfa->iocfc.intr_mask);
+	writel(bfa->iocfc.intr_mask, bfa->iocfc.bfa_regs.intr_mask);
 }
 
 void
 bfa_intx_disable(struct bfa_s *bfa)
 {
-	bfa_reg_write(bfa->iocfc.bfa_regs.intr_mask, -1L);
+	writel(-1L, bfa->iocfc.bfa_regs.intr_mask);
 }
 
 void
@@ -188,8 +188,8 @@ bfa_isr_enable(struct bfa_s *bfa)
 				__HFN_INT_RME_Q6 | __HFN_INT_RME_Q7 |
 				__HFN_INT_MBOX_LPU1);
 
-	bfa_reg_write(bfa->iocfc.bfa_regs.intr_status, intr_unmask);
-	bfa_reg_write(bfa->iocfc.bfa_regs.intr_mask, ~intr_unmask);
+	writel(intr_unmask, bfa->iocfc.bfa_regs.intr_status);
+	writel(~intr_unmask, bfa->iocfc.bfa_regs.intr_mask);
 	bfa->iocfc.intr_mask = ~intr_unmask;
 	bfa_isr_mode_set(bfa, bfa->msix.nvecs != 0);
 }
@@ -198,7 +198,7 @@ void
 bfa_isr_disable(struct bfa_s *bfa)
 {
 	bfa_isr_mode_set(bfa, BFA_FALSE);
-	bfa_reg_write(bfa->iocfc.bfa_regs.intr_mask, -1L);
+	writel(-1L, bfa->iocfc.bfa_regs.intr_mask);
 	bfa_msix_uninstall(bfa);
 }
 
@@ -263,7 +263,7 @@ bfa_msix_rspq(struct bfa_s *bfa, int qid)
 	 * update CI
 	 */
 	bfa_rspq_ci(bfa, qid) = pi;
-	bfa_reg_write(bfa->iocfc.bfa_regs.rme_q_ci[qid], pi);
+	writel(pi, bfa->iocfc.bfa_regs.rme_q_ci[qid]);
 	mmiowb();
 
 	/**
@@ -279,7 +279,7 @@ bfa_msix_lpu_err(struct bfa_s *bfa, int vec)
 {
 	u32 intr, curr_value;
 
-	intr = bfa_reg_read(bfa->iocfc.bfa_regs.intr_status);
+	intr = readl(bfa->iocfc.bfa_regs.intr_status);
 
 	if (intr & (__HFN_INT_MBOX_LPU0 | __HFN_INT_MBOX_LPU1))
 		bfa_msix_lpu(bfa);
@@ -294,9 +294,9 @@ bfa_msix_lpu_err(struct bfa_s *bfa, int vec)
 			 * Register needs to be cleared as well so Interrupt
 			 * Status Register will be cleared.
 			 */
-			curr_value = bfa_reg_read(bfa->ioc.ioc_regs.ll_halt);
+			curr_value = readl(bfa->ioc.ioc_regs.ll_halt);
 			curr_value &= ~__FW_INIT_HALT_P;
-			bfa_reg_write(bfa->ioc.ioc_regs.ll_halt, curr_value);
+			writel(curr_value, bfa->ioc.ioc_regs.ll_halt);
 		}
 
 		if (intr & __HFN_INT_ERR_PSS) {
@@ -305,14 +305,14 @@ bfa_msix_lpu_err(struct bfa_s *bfa, int vec)
 			 * interrups are shared so driver's interrupt handler is
 			 * still called eventhough it is already masked out.
 			 */
-			curr_value = bfa_reg_read(
+			curr_value = readl(
 					bfa->ioc.ioc_regs.pss_err_status_reg);
 			curr_value &= __PSS_ERR_STATUS_SET;
-			bfa_reg_write(bfa->ioc.ioc_regs.pss_err_status_reg,
-					curr_value);
+			writel(curr_value,
+				bfa->ioc.ioc_regs.pss_err_status_reg);
 		}
 
-		bfa_reg_write(bfa->iocfc.bfa_regs.intr_status, intr);
+		writel(intr, bfa->iocfc.bfa_regs.intr_status);
 		bfa_msix_errint(bfa, intr);
 	}
 }
drivers/scsi/bfa/bfa_hw_cb.c +5 -5
index c787d3a..422e44c 100644
@@ -22,7 +22,7 @@ void
 bfa_hwcb_reginit(struct bfa_s *bfa)
 {
 	struct bfa_iocfc_regs_s	*bfa_regs = &bfa->iocfc.bfa_regs;
-	bfa_os_addr_t		kva = bfa_ioc_bar0(&bfa->ioc);
+	void __iomem *kva = bfa_ioc_bar0(&bfa->ioc);
 	int			i, q, fn = bfa_ioc_pcifn(&bfa->ioc);
 
 	if (fn == 0) {
@@ -60,8 +60,8 @@ bfa_hwcb_reqq_ack(struct bfa_s *bfa, int reqq)
 static void
 bfa_hwcb_reqq_ack_msix(struct bfa_s *bfa, int reqq)
 {
-	bfa_reg_write(bfa->iocfc.bfa_regs.intr_status,
-		__HFN_INT_CPE_Q0 << CPE_Q_NUM(bfa_ioc_pcifn(&bfa->ioc), reqq));
+	writel(__HFN_INT_CPE_Q0 << CPE_Q_NUM(bfa_ioc_pcifn(&bfa->ioc), reqq),
+			bfa->iocfc.bfa_regs.intr_status);
 }
 
 void
@@ -72,8 +72,8 @@ bfa_hwcb_rspq_ack(struct bfa_s *bfa, int rspq)
 static void
 bfa_hwcb_rspq_ack_msix(struct bfa_s *bfa, int rspq)
 {
-	bfa_reg_write(bfa->iocfc.bfa_regs.intr_status,
-		__HFN_INT_RME_Q0 << RME_Q_NUM(bfa_ioc_pcifn(&bfa->ioc), rspq));
+	writel(__HFN_INT_RME_Q0 << RME_Q_NUM(bfa_ioc_pcifn(&bfa->ioc), rspq),
+			bfa->iocfc.bfa_regs.intr_status);
 }
 
 void
drivers/scsi/bfa/bfa_hw_ct.c +8 -8
index c97ebaf..81e670e 100644
@@ -31,12 +31,12 @@ static void
 bfa_hwct_msix_lpu_err_set(struct bfa_s *bfa, bfa_boolean_t msix, int vec)
 {
 	int fn = bfa_ioc_pcifn(&bfa->ioc);
-	bfa_os_addr_t kva = bfa_ioc_bar0(&bfa->ioc);
+	void __iomem *kva = bfa_ioc_bar0(&bfa->ioc);
 
 	if (msix)
-		bfa_reg_write(kva + __ct_msix_err_vec_reg[fn], vec);
+		writel(vec, kva + __ct_msix_err_vec_reg[fn]);
 	else
-		bfa_reg_write(kva + __ct_msix_err_vec_reg[fn], 0);
+		writel(0, kva + __ct_msix_err_vec_reg[fn]);
 }
 
 /**
@@ -51,7 +51,7 @@ void
 bfa_hwct_reginit(struct bfa_s *bfa)
 {
 	struct bfa_iocfc_regs_s	*bfa_regs = &bfa->iocfc.bfa_regs;
-	bfa_os_addr_t		kva = bfa_ioc_bar0(&bfa->ioc);
+	void __iomem *kva = bfa_ioc_bar0(&bfa->ioc);
 	int			i, q, fn = bfa_ioc_pcifn(&bfa->ioc);
 
 	if (fn == 0) {
@@ -88,8 +88,8 @@ bfa_hwct_reqq_ack(struct bfa_s *bfa, int reqq)
 {
 	u32	r32;
 
-	r32 = bfa_reg_read(bfa->iocfc.bfa_regs.cpe_q_ctrl[reqq]);
-	bfa_reg_write(bfa->iocfc.bfa_regs.cpe_q_ctrl[reqq], r32);
+	r32 = readl(bfa->iocfc.bfa_regs.cpe_q_ctrl[reqq]);
+	writel(r32, bfa->iocfc.bfa_regs.cpe_q_ctrl[reqq]);
 }
 
 void
@@ -97,8 +97,8 @@ bfa_hwct_rspq_ack(struct bfa_s *bfa, int rspq)
 {
 	u32	r32;
 
-	r32 = bfa_reg_read(bfa->iocfc.bfa_regs.rme_q_ctrl[rspq]);
-	bfa_reg_write(bfa->iocfc.bfa_regs.rme_q_ctrl[rspq], r32);
+	r32 = readl(bfa->iocfc.bfa_regs.rme_q_ctrl[rspq]);
+	writel(r32, bfa->iocfc.bfa_regs.rme_q_ctrl[rspq]);
 }
 
 void
drivers/scsi/bfa/bfa_ioc.c +56 -61

370 lines not on this page · raw message

drivers/scsi/bfa/bfa_ioc.h +32 -34

106 lines not on this page · raw message

drivers/scsi/bfa/bfa_ioc_cb.c +29 -35

96 lines not on this page · raw message

drivers/scsi/bfa/bfa_ioc_ct.c +57 -62

230 lines not on this page · raw message

drivers/scsi/bfa/bfa_os_inc.h +9 -23
index d928dca..f9edc75 100644
@@ -65,12 +65,6 @@ do {									\
 	((_x) & 0x00ff00) |			\
 	(((_x) & 0xff0000) >> 16))
 
-#define bfa_os_swap32(_x)			\
-	((((_x) & 0xff) << 24)		|	\
-	(((_x) & 0x0000ff00) << 8)	|	\
-	(((_x) & 0x00ff0000) >> 8)	|	\
-	(((_x) & 0xff000000) >> 24))
-
 #define bfa_os_swap_sgaddr(_x)  ((u64)(                                 \
 	(((u64)(_x) & (u64)0x00000000000000ffull) << 32)        |       \
 	(((u64)(_x) & (u64)0x000000000000ff00ull) << 32)        |       \
@@ -82,7 +76,7 @@ do {									\
 	(((u64)(_x) & (u64)0xff00000000000000ull) >> 32)))
 
 #ifndef __BIGENDIAN
-#define bfa_os_hton3b(_x)	bfa_swap_3b(_x)
+#define bfa_os_hton3b(_x)  bfa_swap_3b(_x)
 #define bfa_os_sgaddr(_x)  (_x)
 #else
 #define bfa_os_hton3b(_x)  (_x)
@@ -91,22 +85,14 @@ do {									\
 
 #define bfa_os_ntoh3b(_x)  bfa_os_hton3b(_x)
 #define bfa_os_u32(__pa64) ((__pa64) >> 32)
-#define bfa_os_addr_t void __iomem *
-
-#define bfa_os_reg_read(_raddr) readl(_raddr)
-#define bfa_os_reg_write(_raddr, _val) writel((_val), (_raddr))
-#define bfa_os_mem_read(_raddr, _off)					\
-	bfa_os_swap32(readl(((_raddr) + (_off))))
-#define bfa_os_mem_write(_raddr, _off, _val)				\
-	writel(bfa_os_swap32((_val)), ((_raddr) + (_off)))
-
-#define BFA_TRC_TS(_trcm)						\
-			({						\
-				struct timeval tv;			\
-									\
-				do_gettimeofday(&tv);      \
-				(tv.tv_sec*1000000+tv.tv_usec);      \
-			 })
+
+#define BFA_TRC_TS(_trcm)				\
+	({						\
+		struct timeval tv;			\
+							\
+		do_gettimeofday(&tv);      		\
+		(tv.tv_sec*1000000+tv.tv_usec);		\
+	 })
 
 #define boolean_t int
 
drivers/scsi/bfa/bfad_debugfs.c +2 -2
index 69ed1c4..1fedeeb 100644
@@ -318,7 +318,7 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
 	regbuf =  (u32 *)bfad->regdata;
 	spin_lock_irqsave(&bfad->bfad_lock, flags);
 	for (i = 0; i < len; i++) {
-		*regbuf = bfa_reg_read(reg_addr);
+		*regbuf = readl(reg_addr);
 		regbuf++;
 		reg_addr += sizeof(u32);
 	}
@@ -361,7 +361,7 @@ bfad_debugfs_write_regwr(struct file *file, const char __user *buf,
 
 	reg_addr = (u32 *) ((u8 *) bfa_ioc_bar0(ioc) + addr);
 	spin_lock_irqsave(&bfad->bfad_lock, flags);
-	bfa_reg_write(reg_addr, val);
+	writel(val, reg_addr);
 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);
 
 	return nbytes;
Signature · 1 line
1.6.5.2
#1 lore raw

Hi Jing,

A few more potential issues I noticed after looking through this patch. These are not necessarily problems with this patch, but are highlighted by the patch. Perhaps these could be addressed in a subsequent patch or patch set?

Rob

Quoted 6 lines
drivers/scsi/bfa/bfa_ioc.h +0 -0
index 71c0b5a..d60e472 100644
@@ -62,9 +62,9 @@ struct bfa_sge_s {
 };

drivers/scsi/bfa/bfa_ioc.h struct bfa_sge_s { · line 69

Quoted 10 lines
drivers/scsi/bfa/bfa_ioc.h +3 -3
 
 #define bfa_sge_word_swap(__sge) do {					     \
-	((u32 *)(__sge))[0] = bfa_os_swap32(((u32 *)(__sge))[0]);      \
-	((u32 *)(__sge))[1] = bfa_os_swap32(((u32 *)(__sge))[1]);      \
-	((u32 *)(__sge))[2] = bfa_os_swap32(((u32 *)(__sge))[2]);      \
+	((u32 *)(__sge))[0] = swab32(((u32 *)(__sge))[0]);      \
+	((u32 *)(__sge))[1] = swab32(((u32 *)(__sge))[1]);      \
+	((u32 *)(__sge))[2] = swab32(((u32 *)(__sge))[2]);      \
 } while (0)
 

Is bfa_sge_word_swap used anywhere? I didn't see it.

snip

drivers/scsi/bfa/bfa_ioc.h __bfa_dma_be_addr_set(union bfi_addr_u *dma_addr, u64 pa) · line 158

Quoted 6 lines
drivers/scsi/bfa/bfa_ioc.h +2 -1
+#define bfa_mem_read(_raddr, _off)	swab32(readl(((_raddr) + (_off))))
 
 #define bfa_mem_write(_raddr, _off, _val)	\
-					bfa_os_mem_write(_raddr, _off, _val)
+			writel(swab32((_val)), ((_raddr) + (_off)))

Do bfa_mem_read/write() belong here after your cleanup? Could you explain these a bit if they are required?

snip

Quoted 18 lines
drivers/scsi/bfa/bfa_os_inc.h +0 -6
index d928dca..f9edc75 100644
@@ -65,12 +65,6 @@ do {									\
 	((_x) & 0x00ff00) |			\
 	(((_x) & 0xff0000) >> 16))
 
-#define bfa_os_swap32(_x)			\
-	((((_x) & 0xff) << 24)		|	\
-	(((_x) & 0x0000ff00) << 8)	|	\
-	(((_x) & 0x00ff0000) >> 8)	|	\
-	(((_x) & 0xff000000) >> 24))
-
 #define bfa_os_swap_sgaddr(_x)  ((u64)(                                 \
 	(((u64)(_x) & (u64)0x00000000000000ffull) << 32)        |       \
 	(((u64)(_x) & (u64)0x000000000000ff00ull) << 32)        |       \

drivers/scsi/bfa/bfa_os_inc.h do { \ · line 77

Quoted 2 lines
drivers/scsi/bfa/bfa_os_inc.h +0 -0
@@ -82,7 +76,7 @@ do {									\
 	(((u64)(_x) & (u64)0xff00000000000000ull) >> 32)))
 

The sg byte swapping code above lead me to look at the sg code in the bfa driver and I saw that bfa doesn't use scsi_for_each_sg() from what I can tell.

Is scsi_for_each_sg() use pretty standard for mass storage drivers these days?

Is the byte swapping required if the more traditional sg implementation is used?

drivers/scsi/bfa/bfa_os_inc.h do { \

Quoted 5 lines
drivers/scsi/bfa/bfa_os_inc.h +1 -1
 #ifndef __BIGENDIAN
-#define bfa_os_hton3b(_x)	bfa_swap_3b(_x)
+#define bfa_os_hton3b(_x)  bfa_swap_3b(_x)
 

Should bfa_os_hton3b and related functionality be relocated appropriately and implemented in common form to the other common byte swapping code?

#2 lore raw
Quoted 2 lines · Rob Evers

Is scsi_for_each_sg() use pretty standard for mass storage drivers these days?

Yes, the driver should be using it.

Quoted 5 lines

Is the byte swapping required if the more traditional sg implementation is used?

Quoted 1 line
Quoted 8 lines

drivers/scsi/bfa/bfa_os_inc.h do { \ · line 79

Quoted 3 lines

#ifndef __BIGENDIAN

drivers/scsi/bfa/bfa_os_inc.h +1 -1
-#define bfa_os_hton3b(_x) bfa_swap_3b(_x)
+#define bfa_os_hton3b(_x) bfa_swap_3b(_x)

Should bfa_os_hton3b and related functionality be relocated appropriately and implemented in common form to the other common byte swapping code?

Yes. I think intel was working on that for fcoe. Someone should dig up the patches and finish pushing.

#3 lore raw
Quoted 20 lines · Mike Christie
Quoted 2 lines · Rob Evers

Is scsi_for_each_sg() use pretty standard for mass storage drivers these days?

Yes, the driver should be using it.

Quoted 5 lines

Is the byte swapping required if the more traditional sg implementation is used?

Quoted 1 line
Quoted 8 lines

drivers/scsi/bfa/bfa_os_inc.h do { \ · line 79

Quoted 3 lines

#ifndef __BIGENDIAN

drivers/scsi/bfa/bfa_os_inc.h +1 -1
-#define bfa_os_hton3b(_x) bfa_swap_3b(_x)
+#define bfa_os_hton3b(_x) bfa_swap_3b(_x)

Should bfa_os_hton3b and related functionality be relocated appropriately and implemented in common form to the other common byte swapping code?

Quoted 1 line

Yes. I think intel was working on that for fcoe. Someone should dig up the patches and finish pushing.

It's in <scsi/fc_frame.h> as hton24() / ntoh24(). It's written in
an endian-independent way. I don't know of patches to move them to
a better place.

Joe

author
#4 lore raw
Quoted 5 lines

It's in <scsi/fc_frame.h> as hton24() / ntoh24(). It's written in
an endian-independent way. I don't know of patches to move them to
a better place.

Joe

Yes I noticed these two functions for this round of cleanup, but they cannot be used directly to replace the macros we are currently using in bfa driver without changing the parameters passed in.

Thanks
Jing

#5 lore raw
In reply to Joe Eykholt
Quoted 9 lines · Joe Eykholt
Quoted 9 lines
Quoted 8 lines

drivers/scsi/bfa/bfa_os_inc.h do { \ · line 79

Quoted 3 lines

#ifndef __BIGENDIAN

drivers/scsi/bfa/bfa_os_inc.h +1 -1
-#define bfa_os_hton3b(_x) bfa_swap_3b(_x)
+#define bfa_os_hton3b(_x) bfa_swap_3b(_x)

Should bfa_os_hton3b and related functionality be relocated appropriately and implemented in common form to the other common byte swapping code?

Quoted 5 lines
Quoted 1 line

Yes. I think intel was working on that for fcoe. Someone should dig up the patches and finish pushing.

It's in<scsi/fc_frame.h> as hton24() / ntoh24(). It's written in
an endian-independent way. I don't know of patches to move them to
a better place.

iscsi and some other code has it too. Chris Leech was working on it in this patchset "24-bit types: typedef and functions for accessing 3-byte arrays as integers". I think this was the latest:

http://www.mail-archive.com/[email protected]/msg01330.html

author
#6 lore raw
In reply to Mike Christie
Quoted 6 lines · Rob Evers
Quoted 2 lines

Is scsi_for_each_sg() use pretty standard for mass storage drivers these days?

Yes, the driver should be using it.

We are not using the scsi_for_each_sg because currently we setup the scsi data buffers in two separate steps. The reason of doing that is we allow one buffer being inlined in the IO request, while the remaining buffers in sg pages. The sg elements in the IO request and sgpg have different format per ASIC spec, we hence think It is logically clearer to set them up in two different functions.