diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2008-05-30 12:49:52 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-05-30 22:17:56 -0400 |
commit | 41873e9aff0632d80c74380d58a89e8d420151bd (patch) | |
tree | d34b8add6a9446441b6f320ed3cfd307c4fc9fb0 /drivers/net/tlan.c | |
parent | 981813d8e0a16946f511f4eda17bb4ee4fa2769c (diff) |
tlan: get rid of padding buffer
Use skb_padto to pad frames, this avoid allocation of separate buffer just
for dma of the extra bytes.
Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/tlan.c')
-rw-r--r-- | drivers/net/tlan.c | 37 |
1 files changed, 7 insertions, 30 deletions
diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c index 0166407d7061..d1633fbf46ce 100644 --- a/drivers/net/tlan.c +++ b/drivers/net/tlan.c | |||
@@ -218,8 +218,6 @@ static int bbuf; | |||
218 | module_param(bbuf, int, 0); | 218 | module_param(bbuf, int, 0); |
219 | MODULE_PARM_DESC(bbuf, "ThunderLAN use big buffer (0-1)"); | 219 | MODULE_PARM_DESC(bbuf, "ThunderLAN use big buffer (0-1)"); |
220 | 220 | ||
221 | static u8 *TLanPadBuffer; | ||
222 | static dma_addr_t TLanPadBufferDMA; | ||
223 | static char TLanSignature[] = "TLAN"; | 221 | static char TLanSignature[] = "TLAN"; |
224 | static const char tlan_banner[] = "ThunderLAN driver v1.15\n"; | 222 | static const char tlan_banner[] = "ThunderLAN driver v1.15\n"; |
225 | static int tlan_have_pci; | 223 | static int tlan_have_pci; |
@@ -469,16 +467,6 @@ static int __init tlan_probe(void) | |||
469 | 467 | ||
470 | printk(KERN_INFO "%s", tlan_banner); | 468 | printk(KERN_INFO "%s", tlan_banner); |
471 | 469 | ||
472 | TLanPadBuffer = (u8 *) pci_alloc_consistent(NULL, TLAN_MIN_FRAME_SIZE, &TLanPadBufferDMA); | ||
473 | |||
474 | if (TLanPadBuffer == NULL) { | ||
475 | printk(KERN_ERR "TLAN: Could not allocate memory for pad buffer.\n"); | ||
476 | rc = -ENOMEM; | ||
477 | goto err_out; | ||
478 | } | ||
479 | |||
480 | memset(TLanPadBuffer, 0, TLAN_MIN_FRAME_SIZE); | ||
481 | |||
482 | TLAN_DBG(TLAN_DEBUG_PROBE, "Starting PCI Probe....\n"); | 470 | TLAN_DBG(TLAN_DEBUG_PROBE, "Starting PCI Probe....\n"); |
483 | 471 | ||
484 | /* Use new style PCI probing. Now the kernel will | 472 | /* Use new style PCI probing. Now the kernel will |
@@ -506,8 +494,6 @@ static int __init tlan_probe(void) | |||
506 | err_out_pci_unreg: | 494 | err_out_pci_unreg: |
507 | pci_unregister_driver(&tlan_driver); | 495 | pci_unregister_driver(&tlan_driver); |
508 | err_out_pci_free: | 496 | err_out_pci_free: |
509 | pci_free_consistent(NULL, TLAN_MIN_FRAME_SIZE, TLanPadBuffer, TLanPadBufferDMA); | ||
510 | err_out: | ||
511 | return rc; | 497 | return rc; |
512 | } | 498 | } |
513 | 499 | ||
@@ -724,8 +710,6 @@ static void __exit tlan_exit(void) | |||
724 | if (tlan_have_eisa) | 710 | if (tlan_have_eisa) |
725 | TLan_Eisa_Cleanup(); | 711 | TLan_Eisa_Cleanup(); |
726 | 712 | ||
727 | pci_free_consistent(NULL, TLAN_MIN_FRAME_SIZE, TLanPadBuffer, TLanPadBufferDMA); | ||
728 | |||
729 | } | 713 | } |
730 | 714 | ||
731 | 715 | ||
@@ -1096,7 +1080,6 @@ static int TLan_StartTx( struct sk_buff *skb, struct net_device *dev ) | |||
1096 | TLanList *tail_list; | 1080 | TLanList *tail_list; |
1097 | dma_addr_t tail_list_phys; | 1081 | dma_addr_t tail_list_phys; |
1098 | u8 *tail_buffer; | 1082 | u8 *tail_buffer; |
1099 | int pad; | ||
1100 | unsigned long flags; | 1083 | unsigned long flags; |
1101 | 1084 | ||
1102 | if ( ! priv->phyOnline ) { | 1085 | if ( ! priv->phyOnline ) { |
@@ -1105,6 +1088,9 @@ static int TLan_StartTx( struct sk_buff *skb, struct net_device *dev ) | |||
1105 | return 0; | 1088 | return 0; |
1106 | } | 1089 | } |
1107 | 1090 | ||
1091 | if (skb_padto(skb, TLAN_MIN_FRAME_SIZE)) | ||
1092 | return 0; | ||
1093 | |||
1108 | tail_list = priv->txList + priv->txTail; | 1094 | tail_list = priv->txList + priv->txTail; |
1109 | tail_list_phys = priv->txListDMA + sizeof(TLanList) * priv->txTail; | 1095 | tail_list_phys = priv->txListDMA + sizeof(TLanList) * priv->txTail; |
1110 | 1096 | ||
@@ -1125,19 +1111,10 @@ static int TLan_StartTx( struct sk_buff *skb, struct net_device *dev ) | |||
1125 | TLan_StoreSKB(tail_list, skb); | 1111 | TLan_StoreSKB(tail_list, skb); |
1126 | } | 1112 | } |
1127 | 1113 | ||
1128 | pad = TLAN_MIN_FRAME_SIZE - skb->len; | 1114 | tail_list->frameSize = (u16) skb->len; |
1129 | 1115 | tail_list->buffer[0].count = TLAN_LAST_BUFFER | (u32) skb->len; | |
1130 | if ( pad > 0 ) { | 1116 | tail_list->buffer[1].count = 0; |
1131 | tail_list->frameSize = (u16) skb->len + pad; | 1117 | tail_list->buffer[1].address = 0; |
1132 | tail_list->buffer[0].count = (u32) skb->len; | ||
1133 | tail_list->buffer[1].count = TLAN_LAST_BUFFER | (u32) pad; | ||
1134 | tail_list->buffer[1].address = TLanPadBufferDMA; | ||
1135 | } else { | ||
1136 | tail_list->frameSize = (u16) skb->len; | ||
1137 | tail_list->buffer[0].count = TLAN_LAST_BUFFER | (u32) skb->len; | ||
1138 | tail_list->buffer[1].count = 0; | ||
1139 | tail_list->buffer[1].address = 0; | ||
1140 | } | ||
1141 | 1118 | ||
1142 | spin_lock_irqsave(&priv->lock, flags); | 1119 | spin_lock_irqsave(&priv->lock, flags); |
1143 | tail_list->cStat = TLAN_CSTAT_READY; | 1120 | tail_list->cStat = TLAN_CSTAT_READY; |