1/* 2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc. 3 * All rights reserved 4 * www.brocade.com 5 * 6 * Linux driver for Brocade Fibre Channel Host Bus Adapter. 7 * 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 11 * 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. 16 */ 17 18/** 19 * bfa_checksum.h BFA checksum utilities 20 */ 21 22#ifndef __BFA_CHECKSUM_H__ 23#define __BFA_CHECKSUM_H__ 24 25static inline u32 26bfa_checksum_u32(u32 *buf, int sz) 27{ 28 int i, m = sz >> 2; 29 u32 sum = 0; 30 31 for (i = 0; i < m; i++) 32 sum ^= buf[i]; 33 34 return sum; 35} 36 37static inline u16 38bfa_checksum_u16(u16 *buf, int sz) 39{ 40 int i, m = sz >> 1; 41 u16 sum = 0; 42 43 for (i = 0; i < m; i++) 44 sum ^= buf[i]; 45 46 return sum; 47} 48 49static inline u8 50bfa_checksum_u8(u8 *buf, int sz) 51{ 52 int i; 53 u8 sum = 0; 54 55 for (i = 0; i < sz; i++) 56 sum ^= buf[i]; 57 58 return sum; 59} 60#endif 61