From: Dmitry Eremin-Solenikov <dmitry.ereminsoleni...@linaro.org> Use odp_chksum_ones_comp16 which may be platform-optimized. This removes now unnecessary odph_cksum() function.
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsoleni...@linaro.org> --- /** Email created from pull request 280 (lumag:chksum) ** https://github.com/Linaro/odp/pull/280 ** Patch: https://github.com/Linaro/odp/pull/280.patch ** Base sha: d4b364849c4abb4c71e0c5260e1a793ebb8dc97d ** Merge commit sha: 9fda6f107cef0c4074880995a90b30cbeac27ce8 **/ helper/include/odp/helper/chksum.h | 27 --------------------------- helper/include/odp/helper/ip.h | 2 +- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/helper/include/odp/helper/chksum.h b/helper/include/odp/helper/chksum.h index 1bf950c8b..ed2de91fb 100644 --- a/helper/include/odp/helper/chksum.h +++ b/helper/include/odp/helper/chksum.h @@ -34,33 +34,6 @@ typedef enum { ODPH_CHKSUM_RETURN /**< Don't generate or verify chksum */ } odph_chksum_op_t; -/** - * Checksum - * - * @param buffer calculate chksum for buffer - * @param len buffer length - * - * @return checksum value in network order - */ -static inline odp_u16sum_t odph_chksum(void *buffer, int len) -{ - uint16_t *buf = (uint16_t *)buffer; - uint32_t sum = 0; - uint16_t result; - - for (sum = 0; len > 1; len -= 2) - sum += *buf++; - - if (len == 1) - sum += *(unsigned char *)buf; - - sum = (sum >> 16) + (sum & 0xFFFF); - sum += (sum >> 16); - result = ~sum; - - return (__odp_force odp_u16sum_t) result; -} - /** * General Purpose TCP/UDP checksum function * diff --git a/helper/include/odp/helper/ip.h b/helper/include/odp/helper/ip.h index c6eb9d767..b96aab280 100644 --- a/helper/include/odp/helper/ip.h +++ b/helper/include/odp/helper/ip.h @@ -125,7 +125,7 @@ static inline int odph_ipv4_csum(odp_packet_t pkt, if (odp_unlikely(res < 0)) return res; - *chksum = odph_chksum(buf, nleft); + *chksum = ~odp_chksum_ones_comp16(buf, nleft); return 0; }