diff options
| -rw-r--r-- | drivers/net/via-velocity.c | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c index fce2dfd0e9e6..86b256cbeaf3 100644 --- a/drivers/net/via-velocity.c +++ b/drivers/net/via-velocity.c | |||
| @@ -1102,47 +1102,41 @@ static int __devinit velocity_get_pci_info(struct velocity_info *vptr, struct pc | |||
| 1102 | 1102 | ||
| 1103 | static int velocity_init_rings(struct velocity_info *vptr) | 1103 | static int velocity_init_rings(struct velocity_info *vptr) |
| 1104 | { | 1104 | { |
| 1105 | int i; | 1105 | struct velocity_opt *opt = &vptr->options; |
| 1106 | unsigned int psize; | 1106 | const unsigned int rx_ring_size = opt->numrx * sizeof(struct rx_desc); |
| 1107 | const unsigned int tx_ring_size = opt->numtx * sizeof(struct tx_desc); | ||
| 1108 | struct pci_dev *pdev = vptr->pdev; | ||
| 1107 | dma_addr_t pool_dma; | 1109 | dma_addr_t pool_dma; |
| 1108 | u8 *pool; | 1110 | void *pool; |
| 1109 | 1111 | unsigned int i; | |
| 1110 | /* | ||
| 1111 | * Allocate all RD/TD rings a single pool | ||
| 1112 | */ | ||
| 1113 | |||
| 1114 | psize = vptr->options.numrx * sizeof(struct rx_desc) + | ||
| 1115 | vptr->options.numtx * sizeof(struct tx_desc) * vptr->num_txq; | ||
| 1116 | 1112 | ||
| 1117 | /* | 1113 | /* |
| 1114 | * Allocate all RD/TD rings a single pool. | ||
| 1115 | * | ||
| 1118 | * pci_alloc_consistent() fulfills the requirement for 64 bytes | 1116 | * pci_alloc_consistent() fulfills the requirement for 64 bytes |
| 1119 | * alignment | 1117 | * alignment |
| 1120 | */ | 1118 | */ |
| 1121 | pool = pci_alloc_consistent(vptr->pdev, psize, &pool_dma); | 1119 | pool = pci_alloc_consistent(pdev, tx_ring_size * vptr->num_txq + |
| 1122 | 1120 | rx_ring_size, &pool_dma); | |
| 1123 | if (pool == NULL) { | 1121 | if (!pool) { |
| 1124 | printk(KERN_ERR "%s : DMA memory allocation failed.\n", | 1122 | dev_err(&pdev->dev, "%s : DMA memory allocation failed.\n", |
| 1125 | vptr->dev->name); | 1123 | vptr->dev->name); |
| 1126 | return -ENOMEM; | 1124 | return -ENOMEM; |
| 1127 | } | 1125 | } |
| 1128 | 1126 | ||
| 1129 | memset(pool, 0, psize); | 1127 | vptr->rd_ring = pool; |
| 1130 | |||
| 1131 | vptr->rd_ring = (struct rx_desc *) pool; | ||
| 1132 | |||
| 1133 | vptr->rd_pool_dma = pool_dma; | 1128 | vptr->rd_pool_dma = pool_dma; |
| 1134 | 1129 | ||
| 1135 | i = vptr->options.numrx * sizeof(struct rx_desc); | 1130 | pool += rx_ring_size; |
| 1136 | pool += i; | 1131 | pool_dma += rx_ring_size; |
| 1137 | pool_dma += i; | ||
| 1138 | for (i = 0; i < vptr->num_txq; i++) { | ||
| 1139 | int offset = vptr->options.numtx * sizeof(struct tx_desc); | ||
| 1140 | 1132 | ||
| 1133 | for (i = 0; i < vptr->num_txq; i++) { | ||
| 1134 | vptr->td_rings[i] = pool; | ||
| 1141 | vptr->td_pool_dma[i] = pool_dma; | 1135 | vptr->td_pool_dma[i] = pool_dma; |
| 1142 | vptr->td_rings[i] = (struct tx_desc *) pool; | 1136 | pool += tx_ring_size; |
| 1143 | pool += offset; | 1137 | pool_dma += tx_ring_size; |
| 1144 | pool_dma += offset; | ||
| 1145 | } | 1138 | } |
| 1139 | |||
| 1146 | return 0; | 1140 | return 0; |
| 1147 | } | 1141 | } |
| 1148 | 1142 | ||
