<div dir="ltr">Got it. Will fix. Thanks!</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Feb 20, 2023 at 12:10 PM Medvedkin, Vladimir <<a href="mailto:vladimir.medvedkin@intel.com">vladimir.medvedkin@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Bill,<br>
<br>
On 15/02/2023 11:06, Bili Dong wrote:<br>
> An XOR32 hash is needed in the Software Switch (SWX) Pipeline for its<br>
> use case in P4. We implement it in this patch so it could be easily<br>
> registered in the pipeline later.<br>
><br>
> Signed-off-by: Bili Dong <<a href="mailto:qobilidop@gmail.com" target="_blank">qobilidop@gmail.com</a>><br>
> ---<br>
> +static inline uint32_t<br>
> +rte_hash_xor(const void *data, uint32_t data_len, uint32_t init_val)<br>
> +{<br>
> + uint32_t i;<br>
> + uintptr_t pd = (uintptr_t) data;<br>
> + init_val = rte_cpu_to_be_32(init_val);<br>
> +<br>
> + for (i = 0; i < data_len / 4; i++) {<br>
> + init_val ^= *(const uint32_t *)pd;<br>
> + pd += 4;<br>
> + }<br>
> +<br>
> + if (data_len & 0x2) {<br>
> + init_val ^= *(const uint32_t *)pd & LEFT16b_MASK;<br>
<br>
Here you are reading 2 bytes after the data buffer, which can sometimes <br>
lead to segfault. I think it would be better just to:<br>
<br>
init_val ^= *(const uint16_t *)pd << 16;<br>
<br>
The same with the section bellow<br>
<br>
> + pd += 2;<br>
> + }<br>
> +<br>
> + if (data_len & 0x1)<br>
> + init_val ^= *(const uint32_t *)pd & LEFT8b_MASK;<br>
> +<br>
> + init_val = rte_be_to_cpu_32(init_val);<br>
> + return init_val;<br>
> +}<br>
> +<br>
> +#ifdef __cplusplus<br>
> +}<br>
> +#endif<br>
> +<br>
> +#endif /* _RTE_HASH_XOR_H_ */<br>
<br>
-- <br>
Regards,<br>
Vladimir<br>
<br>
</blockquote></div>