Linux cryptographic layer development
 help / color / mirror / Atom feed
* [HIFN 01/n]: Endianess fixes
@ 2008-05-07 12:14 Patrick McHardy
  2008-05-07 12:15 ` [HIFN 02/n]: Remove printk_ratelimit() for debugging printk Patrick McHardy
                   ` (11 more replies)
  0 siblings, 12 replies; 34+ messages in thread
From: Patrick McHardy @ 2008-05-07 12:14 UTC (permalink / raw)
  To: linux-crypto; +Cc: Evgeniy Polyakov, Herbert Xu

[-- Attachment #1: Type: text/plain, Size: 236 bytes --]

Attached is the first of my fixes for the HIFN driver. I've
got it to a working state with tcrypt, IPsec and dm-crypt, a
few of the patches still need a bit work though, so I'll send
the ones that I already consider ready one by one.



[-- Attachment #2: 01.diff --]
[-- Type: text/x-diff, Size: 4427 bytes --]

commit aa543b1fcddd097b5129a9a3056f888737d88102
Author: Patrick McHardy <kaber@trash.net>
Date:   Wed May 7 12:27:09 2008 +0200

    [HIFN]: Endianess fixes
    
    HIFN uses little-endian by default, move cpu_to_le32 conversion to hifn_write_0/
    hifn_write_1, add sparse annotations and fix an invalid endian conversion in
    hifn_setup_src_desc.
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
index 81f3f95..d7a51ee 100644
--- a/drivers/crypto/hifn_795x.c
+++ b/drivers/crypto/hifn_795x.c
@@ -535,10 +535,10 @@ struct hifn_crypt_command
  */
 struct hifn_mac_command
 {
-	volatile u16 		masks;
-	volatile u16 		header_skip;
-	volatile u16 		source_count;
-	volatile u16 		reserved;
+	volatile __le16 	masks;
+	volatile __le16 	header_skip;
+	volatile __le16 	source_count;
+	volatile __le16 	reserved;
 };
 
 #define	HIFN_MAC_CMD_ALG_MASK		0x0001
@@ -564,10 +564,10 @@ struct hifn_mac_command
 
 struct hifn_comp_command
 {
-	volatile u16 		masks;
-	volatile u16 		header_skip;
-	volatile u16 		source_count;
-	volatile u16 		reserved;
+	volatile __le16 	masks;
+	volatile __le16 	header_skip;
+	volatile __le16 	source_count;
+	volatile __le16 	reserved;
 };
 
 #define	HIFN_COMP_CMD_SRCLEN_M		0xc000
@@ -583,10 +583,10 @@ struct hifn_comp_command
 
 struct hifn_base_result
 {
-	volatile u16 		flags;
-	volatile u16 		session;
-	volatile u16 		src_cnt;		/* 15:0 of source count */
-	volatile u16 		dst_cnt;		/* 15:0 of dest count */
+	volatile __le16 	flags;
+	volatile __le16 	session;
+	volatile __le16 	src_cnt;		/* 15:0 of source count */
+	volatile __le16 	dst_cnt;		/* 15:0 of dest count */
 };
 
 #define	HIFN_BASE_RES_DSTOVERRUN	0x0200	/* destination overrun */
@@ -597,8 +597,8 @@ struct hifn_base_result
 
 struct hifn_comp_result
 {
-	volatile u16 		flags;
-	volatile u16 		crc;
+	volatile __le16		flags;
+	volatile __le16		crc;
 };
 
 #define	HIFN_COMP_RES_LCB_M		0xff00	/* longitudinal check byte */
@@ -609,8 +609,8 @@ struct hifn_comp_result
 
 struct hifn_mac_result
 {
-	volatile u16 		flags;
-	volatile u16 		reserved;
+	volatile __le16 	flags;
+	volatile __le16 	reserved;
 	/* followed by 0, 6, 8, or 10 u16's of the MAC, then crypt */
 };
 
@@ -619,8 +619,8 @@ struct hifn_mac_result
 
 struct hifn_crypt_result
 {
-	volatile u16 		flags;
-	volatile u16 		reserved;
+	volatile __le16		flags;
+	volatile __le16		reserved;
 };
 
 #define	HIFN_CRYPT_RES_SRC_NOTZERO	0x0001	/* source expired */
@@ -686,12 +686,12 @@ static inline u32 hifn_read_1(struct hifn_device *dev, u32 reg)
 
 static inline void hifn_write_0(struct hifn_device *dev, u32 reg, u32 val)
 {
-	writel(val, dev->bar[0] + reg);
+	writel((__force u32)cpu_to_le32(val), dev->bar[0] + reg);
 }
 
 static inline void hifn_write_1(struct hifn_device *dev, u32 reg, u32 val)
 {
-	writel(val, dev->bar[1] + reg);
+	writel((__force u32)cpu_to_le32(val), dev->bar[1] + reg);
 }
 
 static void hifn_wait_puc(struct hifn_device *dev)
@@ -1037,14 +1037,14 @@ static void hifn_init_registers(struct hifn_device *dev)
 	hifn_write_0(dev, HIFN_0_PUIER, HIFN_PUIER_DSTOVER);
 
 	/* write all 4 ring address registers */
-	hifn_write_1(dev, HIFN_1_DMA_CRAR, __cpu_to_le32(dptr +
-				offsetof(struct hifn_dma, cmdr[0])));
-	hifn_write_1(dev, HIFN_1_DMA_SRAR, __cpu_to_le32(dptr +
-				offsetof(struct hifn_dma, srcr[0])));
-	hifn_write_1(dev, HIFN_1_DMA_DRAR, __cpu_to_le32(dptr +
-				offsetof(struct hifn_dma, dstr[0])));
-	hifn_write_1(dev, HIFN_1_DMA_RRAR, __cpu_to_le32(dptr +
-				offsetof(struct hifn_dma, resr[0])));
+	hifn_write_1(dev, HIFN_1_DMA_CRAR, dptr +
+				offsetof(struct hifn_dma, cmdr[0]));
+	hifn_write_1(dev, HIFN_1_DMA_SRAR, dptr +
+				offsetof(struct hifn_dma, srcr[0]));
+	hifn_write_1(dev, HIFN_1_DMA_DRAR, dptr +
+				offsetof(struct hifn_dma, dstr[0]));
+	hifn_write_1(dev, HIFN_1_DMA_RRAR, dptr +
+				offsetof(struct hifn_dma, resr[0]));
 
 	mdelay(2);
 #if 0
@@ -1178,8 +1178,8 @@ static int hifn_setup_src_desc(struct hifn_device *dev, struct page *page,
 	idx = dma->srci;
 
 	dma->srcr[idx].p = __cpu_to_le32(addr);
-	dma->srcr[idx].l = __cpu_to_le32(size) | HIFN_D_VALID |
-			HIFN_D_MASKDONEIRQ | HIFN_D_NOINVALID | HIFN_D_LAST;
+	dma->srcr[idx].l = __cpu_to_le32(size | HIFN_D_VALID |
+			HIFN_D_MASKDONEIRQ | HIFN_D_NOINVALID | HIFN_D_LAST);
 
 	if (++idx == HIFN_D_SRC_RSIZE) {
 		dma->srcr[idx].l = __cpu_to_le32(HIFN_D_VALID |

^ permalink raw reply related	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2008-05-07 14:38 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-07 12:14 [HIFN 01/n]: Endianess fixes Patrick McHardy
2008-05-07 12:15 ` [HIFN 02/n]: Remove printk_ratelimit() for debugging printk Patrick McHardy
2008-05-07 12:23   ` Evgeniy Polyakov
2008-05-07 12:19 ` [HIFN 03/n]: Indicate asynchronous processing to crypto API Patrick McHardy
2008-05-07 12:23   ` Evgeniy Polyakov
2008-05-07 12:29     ` Patrick McHardy
2008-05-07 12:20 ` [HIFN 04/n]: Handle ablkcipher_walk errors Patrick McHardy
2008-05-07 12:44   ` Evgeniy Polyakov
2008-05-07 12:26 ` [HIFN 05/n]: Fix data alignment checks Patrick McHardy
2008-05-07 12:42   ` Evgeniy Polyakov
2008-05-07 12:45     ` Patrick McHardy
2008-05-07 13:04       ` Evgeniy Polyakov
2008-05-07 13:05         ` Patrick McHardy
2008-05-07 13:22           ` Evgeniy Polyakov
2008-05-07 12:48   ` Herbert Xu
2008-05-07 12:51     ` Patrick McHardy
2008-05-07 12:30 ` [HIFN 06/n]: Properly handle requests for less than the full scatterlist Patrick McHardy
2008-05-07 13:01   ` Evgeniy Polyakov
2008-05-07 12:32 ` [HIFN 07/n]: Use unique driver names for different algos Patrick McHardy
2008-05-07 13:07   ` Evgeniy Polyakov
2008-05-07 12:36 ` [HIFN 08/n]: Properly initialize ivsize for CBC modes Patrick McHardy
2008-05-07 12:38 ` [HIFN 09/n]: Fix max queue length value Patrick McHardy
2008-05-07 12:46   ` Evgeniy Polyakov
2008-05-07 12:50 ` [HIFN 10/n]: Move command descriptor setup to seperate function Patrick McHardy
2008-05-07 13:11   ` Evgeniy Polyakov
2008-05-07 12:53 ` [HIFN 11/n]: Have HW invalidate src and dest descriptors after processing Patrick McHardy
2008-05-07 13:14   ` Evgeniy Polyakov
2008-05-07 13:18     ` Patrick McHardy
2008-05-07 13:00 ` [HIFN 01/n]: Endianess fixes Evgeniy Polyakov
2008-05-07 13:01   ` Patrick McHardy
2008-05-07 13:23     ` Evgeniy Polyakov
2008-05-07 13:46       ` Patrick McHardy
2008-05-07 14:04         ` Evgeniy Polyakov
2008-05-07 14:38 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox