On Thu, Feb 2, 2017 at 4:22 PM, Jakub Kicinski <kubak...@wp.pl> wrote: > On Thu, 2 Feb 2017 15:40:19 -0800, Michael Chan wrote: >> On Thu, Feb 2, 2017 at 2:56 PM, Jakub Kicinski <kubak...@wp.pl> wrote: >> > (b) why >> > do you encode the two parameters in a single u32? It's the seventh >> > parameter so it's going on the stack anyway, no? >> >> Both the length and the offset come from the hardware's rx completion >> record. Both are u16. The offset happens to be in the upper 16-bit >> in the hardware record. So it is convenient to encode it like this >> and I chose to do it like this. Of course, using a separate parameter >> will also work. > > Yes, I initially thought you read them out this way straight from the > descriptor but you actually combine them into this form: > > + unsigned int payload_len; > + > + payload_len = (le32_to_cpu(rxcmp->rx_cmp_misc_v1) & > + RX_CMP_PAYLOAD_OFFSET) | len; > + skb = bp->rx_skb_func(bp, rxr, cons, prod, data, dma_addr, >
Yes they are combined because they come from 2 different words. But I don't have to do the shift for the offset because it is already in the upper 16-bit. > I don't mind though, I was just hoping this is some clever optimization > technique I could learn :)