ref: 70d7f4c32ad5b334840bd986315b58f04e9cd102
parent: 41908149de00ab5830c5c72ef3a300a050b2b3bf
author: ftrvxmtrx <devnull@localhost>
date: Wed Apr 23 17:20:11 EDT 2014
nusb/rndis: avoid allocation on each transmission The slack space for outgoing packets set to 44+16 bytes.
--- a/sys/src/cmd/nusb/ether/ether.c
+++ b/sys/src/cmd/nusb/ether/ether.c
@@ -290,12 +290,12 @@
n = 60;
/* slack space for header and trailers */
- n += 2*16;
+ n += 44+16;
b = allocb(n);
/* header space */
- b->wp += 16;
+ b->wp += 44;
b->rp = b->wp;
/* copy in the ethernet packet */
--- a/sys/src/cmd/nusb/ether/rndis.c
+++ b/sys/src/cmd/nusb/ether/rndis.c
@@ -95,19 +95,15 @@
rndistransmit(Dev *ep, Block *b)
{
int n;
- uchar *req;
n = BLEN(b);
- if((req = malloc(44 + n)) != nil){
- PUT4(req, 1); /* type = 1 (packet) */
- PUT4(req+4, 44+n); /* len */
- PUT4(req+8, 44-8); /* data offset */
- PUT4(req+12, n); /* data length */
- memset(req+16, 0, 7*4);
- memcpy(req+44, b->rp, n);
- write(ep->dfd, req, 44+n);
- free(req);
- }
+ b->rp -= 44;
+ PUT4(b->rp, 1); /* type = 1 (packet) */
+ PUT4(b->rp+4, 44+n); /* len */
+ PUT4(b->rp+8, 44-8); /* data offset */
+ PUT4(b->rp+12, n); /* data length */
+ memset(b->rp+16, 0, 7*4);
+ write(ep->dfd, b->rp, 44+n);
freeb(b);
}