From: Jakub Kicinski
> Sent: 29 June 2017 07:48
> On Thu, 29 Jun 2017 14:18:07 +0800, Yunsheng Lin wrote:
> > > + if (mask_basic->n_proto) {
> > cpu_to_be16(mask_basic->n_proto)
Should be be16_to_cpu()
> > remove cpu_to_be16 in case.
>
> Thanks, but this is incorrect. Byte swapping constants is done at
> compilation time - therefore it's preferred.
Except that the 'cpu' values are likely to be dense so the compiler
is likely to generate a jump table for the switch statement instead
of sequence of conditionals.
OTOH the jump table is almost certainly a data cache miss, whereas
the conditionals might be predicted correctly.
The best code might come from an explicitly ordered sequence of
conditionals.
David