summaryrefslogtreecommitdiff
path: root/sys/src
diff options
context:
space:
mode:
authorftrvxmtrx <devnull@localhost>2014-04-23 21:20:11 +0200
committerftrvxmtrx <devnull@localhost>2014-04-23 21:20:11 +0200
commit70d7f4c32ad5b334840bd986315b58f04e9cd102 (patch)
treebd4c4a7cd2cad88aeec94446ce6bafe6be873d3f /sys/src
parent41908149de00ab5830c5c72ef3a300a050b2b3bf (diff)
nusb/rndis: avoid allocation on each transmission
The slack space for outgoing packets set to 44+16 bytes.
Diffstat (limited to 'sys/src')
-rw-r--r--sys/src/cmd/nusb/ether/ether.c4
-rw-r--r--sys/src/cmd/nusb/ether/rndis.c18
2 files changed, 9 insertions, 13 deletions
diff --git a/sys/src/cmd/nusb/ether/ether.c b/sys/src/cmd/nusb/ether/ether.c
index 4b8b61845..cc3116911 100644
--- a/sys/src/cmd/nusb/ether/ether.c
+++ b/sys/src/cmd/nusb/ether/ether.c
@@ -290,12 +290,12 @@ writeconndata(Req *r)
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 */
diff --git a/sys/src/cmd/nusb/ether/rndis.c b/sys/src/cmd/nusb/ether/rndis.c
index 88e91a725..bc688d9b7 100644
--- a/sys/src/cmd/nusb/ether/rndis.c
+++ b/sys/src/cmd/nusb/ether/rndis.c
@@ -95,19 +95,15 @@ static void
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);
}