MCPcopy Create free account
hub / github.com/F-Stack/f-stack / __rte_raw_cksum

Function __rte_raw_cksum

dpdk/lib/net/rte_ip.h:160–182  ·  view source on GitHub ↗

* @internal Calculate a sum of all words in the buffer. * Helper routine for the rte_raw_cksum(). * * @param buf * Pointer to the buffer. * @param len * Length of the buffer. * @param sum * Initial value of the sum. * @return * sum += Sum of all words in the buffer. */

Source from the content-addressed store, hash-verified

158 * sum += Sum of all words in the buffer.
159 */
160static inline uint32_t
161__rte_raw_cksum(const void *buf, size_t len, uint32_t sum)
162{
163 const void *end;
164
165 for (end = RTE_PTR_ADD(buf, RTE_ALIGN_FLOOR(len, sizeof(uint16_t)));
166 buf != end; buf = RTE_PTR_ADD(buf, sizeof(uint16_t))) {
167 uint16_t v;
168
169 memcpy(&v, buf, sizeof(uint16_t));
170 sum += v;
171 }
172
173 /* if length is odd, keeping it byte order independent */
174 if (unlikely(len % 2)) {
175 uint16_t left = 0;
176
177 memcpy(&left, end, 1);
178 sum += left;
179 }
180
181 return sum;
182}
183
184/**
185 * @internal Reduce a sum to the non-complemented checksum.

Callers 7

rte_raw_cksumFunction · 0.85
rte_raw_cksum_mbufFunction · 0.85
rte_ipv6_phdr_cksumFunction · 0.85
mlx5_crypto_dek_prepareFunction · 0.85
hinic_ipv6_phdr_cksumFunction · 0.85

Calls 1

memcpyFunction · 0.50

Tested by

no test coverage detected