Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] orinoco: don't use any padding for Tx frames

hermes_bap_pwrite() supports odd-sized packets now. There is no
minimal packet size for 802.11. Also, hermes_bap_pwrite() supports
odd-sized packets now. This removes all reasons to pad the Tx data.

Signed-off-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Pavel Roskin and committed by
John W. Linville
8d5be088 6b616262

+7 -58
-38
drivers/net/wireless/hermes.c
··· 424 424 return err; 425 425 } 426 426 427 - /* Write a block of data to the chip's buffer with padding if 428 - * neccessary, via the BAP. Synchronization/serialization is the 429 - * caller's problem. 430 - * 431 - * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware 432 - */ 433 - int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf, unsigned data_len, int len, 434 - u16 id, u16 offset) 435 - { 436 - int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 437 - int err = 0; 438 - 439 - if (len < 0 || data_len > len) 440 - return -EINVAL; 441 - 442 - err = hermes_bap_seek(hw, bap, id, offset); 443 - if (err) 444 - goto out; 445 - 446 - /* Transfer all the complete words of data */ 447 - hermes_write_bytes(hw, dreg, buf, data_len); 448 - /* If there is an odd byte left over pad and transfer it */ 449 - if (data_len & 1) { 450 - u8 end[2]; 451 - end[1] = 0; 452 - end[0] = ((unsigned char *)buf)[data_len - 1]; 453 - hermes_write_bytes(hw, dreg, end, 2); 454 - data_len ++; 455 - } 456 - /* Now send zeros for the padding */ 457 - if (data_len < len) 458 - hermes_clear_words(hw, dreg, (len - data_len) / 2); 459 - /* Complete */ 460 - out: 461 - return err; 462 - } 463 - 464 427 /* Read a Length-Type-Value record from the card. 465 428 * 466 429 * If length is NULL, we ignore the length read from the card, and ··· 511 548 512 549 EXPORT_SYMBOL(hermes_bap_pread); 513 550 EXPORT_SYMBOL(hermes_bap_pwrite); 514 - EXPORT_SYMBOL(hermes_bap_pwrite_pad); 515 551 EXPORT_SYMBOL(hermes_read_ltv); 516 552 EXPORT_SYMBOL(hermes_write_ltv); 517 553
-2
drivers/net/wireless/hermes.h
··· 359 359 u16 id, u16 offset); 360 360 int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len, 361 361 u16 id, u16 offset); 362 - int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf, 363 - unsigned data_len, int len, u16 id, u16 offset); 364 362 int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned buflen, 365 363 u16 *length, void *buf); 366 364 int hermes_write_ltv(hermes_t *hw, int bap, u16 rid,
+7 -18
drivers/net/wireless/orinoco.c
··· 423 423 u16 txfid = priv->txfid; 424 424 char *p; 425 425 struct ethhdr *eh; 426 - int len, data_len, data_off; 426 + int data_len, data_off; 427 427 struct hermes_tx_descriptor desc; 428 428 unsigned long flags; 429 429 ··· 455 455 return NETDEV_TX_OK; 456 456 } 457 457 458 - /* Length of the packet body */ 459 - /* FIXME: what if the skb is smaller than this? */ 460 - len = max_t(int, ALIGN(skb->len, 2), ETH_ZLEN); 461 - skb = skb_padto(skb, len); 462 - if (skb == NULL) 458 + /* Check packet length */ 459 + data_len = skb->len; 460 + if (data_len < ETH_HLEN) 463 461 goto fail; 464 - len -= ETH_HLEN; 465 462 466 463 eh = (struct ethhdr *)skb->data; 467 464 ··· 482 485 /* Encapsulate Ethernet-II frames */ 483 486 if (ntohs(eh->h_proto) > ETH_DATA_LEN) { /* Ethernet-II frame */ 484 487 struct header_struct hdr; 485 - data_len = len; 488 + data_len = skb->len - ETH_HLEN; 486 489 data_off = HERMES_802_3_OFFSET + sizeof(hdr); 487 490 p = skb->data + ETH_HLEN; 488 491 ··· 504 507 stats->tx_errors++; 505 508 goto fail; 506 509 } 507 - /* Actual xfer length - allow for padding */ 508 - len = ALIGN(data_len, 2); 509 - if (len < ETH_ZLEN - ETH_HLEN) 510 - len = ETH_ZLEN - ETH_HLEN; 511 510 } else { /* IEEE 802.3 frame */ 512 - data_len = len + ETH_HLEN; 511 + data_len = skb->len; 513 512 data_off = HERMES_802_3_OFFSET; 514 513 p = skb->data; 515 - /* Actual xfer length - round up for odd length packets */ 516 - len = ALIGN(data_len, 2); 517 - if (len < ETH_ZLEN) 518 - len = ETH_ZLEN; 519 514 } 520 515 521 - err = hermes_bap_pwrite_pad(hw, USER_BAP, p, data_len, len, 516 + err = hermes_bap_pwrite(hw, USER_BAP, p, data_len, 522 517 txfid, data_off); 523 518 if (err) { 524 519 printk(KERN_ERR "%s: Error %d writing packet to BAP\n",