RT-AC56 3.0.0.4.374.37 core
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / scsi / bfa / include / cs / bfa_checksum.h
blob650f8d0aaff978eea4f1aa6b8a141b8e6858a475
1 /*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
18 /**
19 * bfa_checksum.h BFA checksum utilities
22 #ifndef __BFA_CHECKSUM_H__
23 #define __BFA_CHECKSUM_H__
25 static inline u32
26 bfa_checksum_u32(u32 *buf, int sz)
28 int i, m = sz >> 2;
29 u32 sum = 0;
31 for (i = 0; i < m; i++)
32 sum ^= buf[i];
34 return sum;
37 static inline u16
38 bfa_checksum_u16(u16 *buf, int sz)
40 int i, m = sz >> 1;
41 u16 sum = 0;
43 for (i = 0; i < m; i++)
44 sum ^= buf[i];
46 return sum;
49 static inline u8
50 bfa_checksum_u8(u8 *buf, int sz)
52 int i;
53 u8 sum = 0;
55 for (i = 0; i < sz; i++)
56 sum ^= buf[i];
58 return sum;
60 #endif