nusb/rndis: avoid allocation on each transmission

The slack space for outgoing packets set to 44+16 bytes.
This commit is contained in:
ftrvxmtrx 2014-04-23 21:20:11 +02:00
parent 41908149de
commit 70d7f4c32a
2 changed files with 9 additions and 13 deletions

View file

@ -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 */

View file

@ -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);
}