]> git.baikalelectronics.ru Git - kernel.git/commit
net: cdc_ncm: simplify and optimize frame padding
authorBjørn Mork <bjorn@mork.no>
Fri, 1 Nov 2013 10:16:38 +0000 (11:16 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 2 Nov 2013 06:02:01 +0000 (02:02 -0400)
commit79f9bcc7990251f5aac48268d6b27c4cb2196a09
tree65f93c29fdc65bc5992e2c37466f8d8055c8f699
parentb4d564ca78ac3fbb1eb8d7561479d4f458e32f47
net: cdc_ncm: simplify and optimize frame padding

We can avoid the costly division for the common case where
we pad the frame to tx_max size as long as we ensure that
tx_max is either the device specified dwNtbOutMaxSize or not
a multiplum of wMaxPacketSize.

Using the preconverted 'maxpacket' field avoids converting
wMaxPacketSize to CPU endianness for every transmitted frame

And since we only will hit the one byte padding rule for short
frames, we can drop testing the skb for tailroom.

The change means that tx_max now represents the real maximum
skb size, enabling us to allocate the correct size instead of
always making room for one extra byte.

Cc: Alexey Orishko <alexey.orishko@gmail.com>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/cdc_ncm.c