diff options
Diffstat (limited to 'drivers/net/ps3_gelic_net.c')
-rw-r--r-- | drivers/net/ps3_gelic_net.c | 464 |
1 files changed, 228 insertions, 236 deletions
diff --git a/drivers/net/ps3_gelic_net.c b/drivers/net/ps3_gelic_net.c index 81e77d3d7804..c09848cbfb68 100644 --- a/drivers/net/ps3_gelic_net.c +++ b/drivers/net/ps3_gelic_net.c | |||
@@ -54,21 +54,21 @@ MODULE_AUTHOR("SCE Inc."); | |||
54 | MODULE_DESCRIPTION("Gelic Network driver"); | 54 | MODULE_DESCRIPTION("Gelic Network driver"); |
55 | MODULE_LICENSE("GPL"); | 55 | MODULE_LICENSE("GPL"); |
56 | 56 | ||
57 | static inline struct device *ctodev(struct gelic_net_card *card) | 57 | static inline struct device *ctodev(struct gelic_card *card) |
58 | { | 58 | { |
59 | return &card->dev->core; | 59 | return &card->dev->core; |
60 | } | 60 | } |
61 | static inline u64 bus_id(struct gelic_net_card *card) | 61 | static inline u64 bus_id(struct gelic_card *card) |
62 | { | 62 | { |
63 | return card->dev->bus_id; | 63 | return card->dev->bus_id; |
64 | } | 64 | } |
65 | static inline u64 dev_id(struct gelic_net_card *card) | 65 | static inline u64 dev_id(struct gelic_card *card) |
66 | { | 66 | { |
67 | return card->dev->dev_id; | 67 | return card->dev->dev_id; |
68 | } | 68 | } |
69 | 69 | ||
70 | /* set irq_mask */ | 70 | /* set irq_mask */ |
71 | static int gelic_net_set_irq_mask(struct gelic_net_card *card, u64 mask) | 71 | static int gelic_card_set_irq_mask(struct gelic_card *card, u64 mask) |
72 | { | 72 | { |
73 | int status; | 73 | int status; |
74 | 74 | ||
@@ -79,51 +79,40 @@ static int gelic_net_set_irq_mask(struct gelic_net_card *card, u64 mask) | |||
79 | "lv1_net_set_interrupt_mask failed %d\n", status); | 79 | "lv1_net_set_interrupt_mask failed %d\n", status); |
80 | return status; | 80 | return status; |
81 | } | 81 | } |
82 | static inline void gelic_net_rx_irq_on(struct gelic_net_card *card) | 82 | static inline void gelic_card_rx_irq_on(struct gelic_card *card) |
83 | { | 83 | { |
84 | gelic_net_set_irq_mask(card, card->ghiintmask | GELIC_NET_RXINT); | 84 | gelic_card_set_irq_mask(card, card->ghiintmask | GELIC_CARD_RXINT); |
85 | } | 85 | } |
86 | static inline void gelic_net_rx_irq_off(struct gelic_net_card *card) | 86 | static inline void gelic_card_rx_irq_off(struct gelic_card *card) |
87 | { | 87 | { |
88 | gelic_net_set_irq_mask(card, card->ghiintmask & ~GELIC_NET_RXINT); | 88 | gelic_card_set_irq_mask(card, card->ghiintmask & ~GELIC_CARD_RXINT); |
89 | } | 89 | } |
90 | /** | 90 | /** |
91 | * gelic_net_get_descr_status -- returns the status of a descriptor | 91 | * gelic_descr_get_status -- returns the status of a descriptor |
92 | * @descr: descriptor to look at | 92 | * @descr: descriptor to look at |
93 | * | 93 | * |
94 | * returns the status as in the dmac_cmd_status field of the descriptor | 94 | * returns the status as in the dmac_cmd_status field of the descriptor |
95 | */ | 95 | */ |
96 | static enum gelic_net_descr_status | 96 | static enum gelic_descr_dma_status |
97 | gelic_net_get_descr_status(struct gelic_net_descr *descr) | 97 | gelic_descr_get_status(struct gelic_descr *descr) |
98 | { | 98 | { |
99 | u32 cmd_status; | 99 | return be32_to_cpu(descr->dmac_cmd_status) & GELIC_DESCR_DMA_STAT_MASK; |
100 | |||
101 | cmd_status = be32_to_cpu(descr->dmac_cmd_status); | ||
102 | cmd_status >>= GELIC_NET_DESCR_IND_PROC_SHIFT; | ||
103 | return cmd_status; | ||
104 | } | 100 | } |
105 | 101 | ||
106 | /** | 102 | /** |
107 | * gelic_net_set_descr_status -- sets the status of a descriptor | 103 | * gelic_descr_set_status -- sets the status of a descriptor |
108 | * @descr: descriptor to change | 104 | * @descr: descriptor to change |
109 | * @status: status to set in the descriptor | 105 | * @status: status to set in the descriptor |
110 | * | 106 | * |
111 | * changes the status to the specified value. Doesn't change other bits | 107 | * changes the status to the specified value. Doesn't change other bits |
112 | * in the status | 108 | * in the status |
113 | */ | 109 | */ |
114 | static void gelic_net_set_descr_status(struct gelic_net_descr *descr, | 110 | static void gelic_descr_set_status(struct gelic_descr *descr, |
115 | enum gelic_net_descr_status status) | 111 | enum gelic_descr_dma_status status) |
116 | { | 112 | { |
117 | u32 cmd_status; | 113 | descr->dmac_cmd_status = cpu_to_be32(status | |
118 | 114 | (be32_to_cpu(descr->dmac_cmd_status) & | |
119 | /* read the status */ | 115 | ~GELIC_DESCR_DMA_STAT_MASK)); |
120 | cmd_status = be32_to_cpu(descr->dmac_cmd_status); | ||
121 | /* clean the upper 4 bits */ | ||
122 | cmd_status &= GELIC_NET_DESCR_IND_PROC_MASKO; | ||
123 | /* add the status to it */ | ||
124 | cmd_status |= ((u32)status) << GELIC_NET_DESCR_IND_PROC_SHIFT; | ||
125 | /* and write it back */ | ||
126 | descr->dmac_cmd_status = cpu_to_be32(cmd_status); | ||
127 | /* | 116 | /* |
128 | * dma_cmd_status field is used to indicate whether the descriptor | 117 | * dma_cmd_status field is used to indicate whether the descriptor |
129 | * is valid or not. | 118 | * is valid or not. |
@@ -134,24 +123,24 @@ static void gelic_net_set_descr_status(struct gelic_net_descr *descr, | |||
134 | } | 123 | } |
135 | 124 | ||
136 | /** | 125 | /** |
137 | * gelic_net_free_chain - free descriptor chain | 126 | * gelic_card_free_chain - free descriptor chain |
138 | * @card: card structure | 127 | * @card: card structure |
139 | * @descr_in: address of desc | 128 | * @descr_in: address of desc |
140 | */ | 129 | */ |
141 | static void gelic_net_free_chain(struct gelic_net_card *card, | 130 | static void gelic_card_free_chain(struct gelic_card *card, |
142 | struct gelic_net_descr *descr_in) | 131 | struct gelic_descr *descr_in) |
143 | { | 132 | { |
144 | struct gelic_net_descr *descr; | 133 | struct gelic_descr *descr; |
145 | 134 | ||
146 | for (descr = descr_in; descr && descr->bus_addr; descr = descr->next) { | 135 | for (descr = descr_in; descr && descr->bus_addr; descr = descr->next) { |
147 | dma_unmap_single(ctodev(card), descr->bus_addr, | 136 | dma_unmap_single(ctodev(card), descr->bus_addr, |
148 | GELIC_NET_DESCR_SIZE, DMA_BIDIRECTIONAL); | 137 | GELIC_DESCR_SIZE, DMA_BIDIRECTIONAL); |
149 | descr->bus_addr = 0; | 138 | descr->bus_addr = 0; |
150 | } | 139 | } |
151 | } | 140 | } |
152 | 141 | ||
153 | /** | 142 | /** |
154 | * gelic_net_init_chain - links descriptor chain | 143 | * gelic_card_init_chain - links descriptor chain |
155 | * @card: card structure | 144 | * @card: card structure |
156 | * @chain: address of chain | 145 | * @chain: address of chain |
157 | * @start_descr: address of descriptor array | 146 | * @start_descr: address of descriptor array |
@@ -162,22 +151,22 @@ static void gelic_net_free_chain(struct gelic_net_card *card, | |||
162 | * | 151 | * |
163 | * returns 0 on success, <0 on failure | 152 | * returns 0 on success, <0 on failure |
164 | */ | 153 | */ |
165 | static int gelic_net_init_chain(struct gelic_net_card *card, | 154 | static int gelic_card_init_chain(struct gelic_card *card, |
166 | struct gelic_net_descr_chain *chain, | 155 | struct gelic_descr_chain *chain, |
167 | struct gelic_net_descr *start_descr, int no) | 156 | struct gelic_descr *start_descr, int no) |
168 | { | 157 | { |
169 | int i; | 158 | int i; |
170 | struct gelic_net_descr *descr; | 159 | struct gelic_descr *descr; |
171 | 160 | ||
172 | descr = start_descr; | 161 | descr = start_descr; |
173 | memset(descr, 0, sizeof(*descr) * no); | 162 | memset(descr, 0, sizeof(*descr) * no); |
174 | 163 | ||
175 | /* set up the hardware pointers in each descriptor */ | 164 | /* set up the hardware pointers in each descriptor */ |
176 | for (i = 0; i < no; i++, descr++) { | 165 | for (i = 0; i < no; i++, descr++) { |
177 | gelic_net_set_descr_status(descr, GELIC_NET_DESCR_NOT_IN_USE); | 166 | gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE); |
178 | descr->bus_addr = | 167 | descr->bus_addr = |
179 | dma_map_single(ctodev(card), descr, | 168 | dma_map_single(ctodev(card), descr, |
180 | GELIC_NET_DESCR_SIZE, | 169 | GELIC_DESCR_SIZE, |
181 | DMA_BIDIRECTIONAL); | 170 | DMA_BIDIRECTIONAL); |
182 | 171 | ||
183 | if (!descr->bus_addr) | 172 | if (!descr->bus_addr) |
@@ -208,13 +197,13 @@ iommu_error: | |||
208 | for (i--, descr--; 0 <= i; i--, descr--) | 197 | for (i--, descr--; 0 <= i; i--, descr--) |
209 | if (descr->bus_addr) | 198 | if (descr->bus_addr) |
210 | dma_unmap_single(ctodev(card), descr->bus_addr, | 199 | dma_unmap_single(ctodev(card), descr->bus_addr, |
211 | GELIC_NET_DESCR_SIZE, | 200 | GELIC_DESCR_SIZE, |
212 | DMA_BIDIRECTIONAL); | 201 | DMA_BIDIRECTIONAL); |
213 | return -ENOMEM; | 202 | return -ENOMEM; |
214 | } | 203 | } |
215 | 204 | ||
216 | /** | 205 | /** |
217 | * gelic_net_prepare_rx_descr - reinitializes a rx descriptor | 206 | * gelic_descr_prepare_rx - reinitializes a rx descriptor |
218 | * @card: card structure | 207 | * @card: card structure |
219 | * @descr: descriptor to re-init | 208 | * @descr: descriptor to re-init |
220 | * | 209 | * |
@@ -223,15 +212,15 @@ iommu_error: | |||
223 | * allocates a new rx skb, iommu-maps it and attaches it to the descriptor. | 212 | * allocates a new rx skb, iommu-maps it and attaches it to the descriptor. |
224 | * Activate the descriptor state-wise | 213 | * Activate the descriptor state-wise |
225 | */ | 214 | */ |
226 | static int gelic_net_prepare_rx_descr(struct gelic_net_card *card, | 215 | static int gelic_descr_prepare_rx(struct gelic_card *card, |
227 | struct gelic_net_descr *descr) | 216 | struct gelic_descr *descr) |
228 | { | 217 | { |
229 | int offset; | 218 | int offset; |
230 | unsigned int bufsize; | 219 | unsigned int bufsize; |
231 | 220 | ||
232 | if (gelic_net_get_descr_status(descr) != GELIC_NET_DESCR_NOT_IN_USE) { | 221 | if (gelic_descr_get_status(descr) != GELIC_DESCR_DMA_NOT_IN_USE) |
233 | dev_info(ctodev(card), "%s: ERROR status \n", __func__); | 222 | dev_info(ctodev(card), "%s: ERROR status \n", __func__); |
234 | } | 223 | |
235 | /* we need to round up the buffer size to a multiple of 128 */ | 224 | /* we need to round up the buffer size to a multiple of 128 */ |
236 | bufsize = ALIGN(GELIC_NET_MAX_MTU, GELIC_NET_RXBUF_ALIGN); | 225 | bufsize = ALIGN(GELIC_NET_MAX_MTU, GELIC_NET_RXBUF_ALIGN); |
237 | 226 | ||
@@ -265,22 +254,22 @@ static int gelic_net_prepare_rx_descr(struct gelic_net_card *card, | |||
265 | descr->skb = NULL; | 254 | descr->skb = NULL; |
266 | dev_info(ctodev(card), | 255 | dev_info(ctodev(card), |
267 | "%s:Could not iommu-map rx buffer\n", __func__); | 256 | "%s:Could not iommu-map rx buffer\n", __func__); |
268 | gelic_net_set_descr_status(descr, GELIC_NET_DESCR_NOT_IN_USE); | 257 | gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE); |
269 | return -ENOMEM; | 258 | return -ENOMEM; |
270 | } else { | 259 | } else { |
271 | gelic_net_set_descr_status(descr, GELIC_NET_DESCR_CARDOWNED); | 260 | gelic_descr_set_status(descr, GELIC_DESCR_DMA_CARDOWNED); |
272 | return 0; | 261 | return 0; |
273 | } | 262 | } |
274 | } | 263 | } |
275 | 264 | ||
276 | /** | 265 | /** |
277 | * gelic_net_release_rx_chain - free all skb of rx descr | 266 | * gelic_card_release_rx_chain - free all skb of rx descr |
278 | * @card: card structure | 267 | * @card: card structure |
279 | * | 268 | * |
280 | */ | 269 | */ |
281 | static void gelic_net_release_rx_chain(struct gelic_net_card *card) | 270 | static void gelic_card_release_rx_chain(struct gelic_card *card) |
282 | { | 271 | { |
283 | struct gelic_net_descr *descr = card->rx_chain.head; | 272 | struct gelic_descr *descr = card->rx_chain.head; |
284 | 273 | ||
285 | do { | 274 | do { |
286 | if (descr->skb) { | 275 | if (descr->skb) { |
@@ -291,29 +280,29 @@ static void gelic_net_release_rx_chain(struct gelic_net_card *card) | |||
291 | descr->buf_addr = 0; | 280 | descr->buf_addr = 0; |
292 | dev_kfree_skb_any(descr->skb); | 281 | dev_kfree_skb_any(descr->skb); |
293 | descr->skb = NULL; | 282 | descr->skb = NULL; |
294 | gelic_net_set_descr_status(descr, | 283 | gelic_descr_set_status(descr, |
295 | GELIC_NET_DESCR_NOT_IN_USE); | 284 | GELIC_DESCR_DMA_NOT_IN_USE); |
296 | } | 285 | } |
297 | descr = descr->next; | 286 | descr = descr->next; |
298 | } while (descr != card->rx_chain.head); | 287 | } while (descr != card->rx_chain.head); |
299 | } | 288 | } |
300 | 289 | ||
301 | /** | 290 | /** |
302 | * gelic_net_fill_rx_chain - fills descriptors/skbs in the rx chains | 291 | * gelic_card_fill_rx_chain - fills descriptors/skbs in the rx chains |
303 | * @card: card structure | 292 | * @card: card structure |
304 | * | 293 | * |
305 | * fills all descriptors in the rx chain: allocates skbs | 294 | * fills all descriptors in the rx chain: allocates skbs |
306 | * and iommu-maps them. | 295 | * and iommu-maps them. |
307 | * returns 0 on success, <0 on failure | 296 | * returns 0 on success, < 0 on failure |
308 | */ | 297 | */ |
309 | static int gelic_net_fill_rx_chain(struct gelic_net_card *card) | 298 | static int gelic_card_fill_rx_chain(struct gelic_card *card) |
310 | { | 299 | { |
311 | struct gelic_net_descr *descr = card->rx_chain.head; | 300 | struct gelic_descr *descr = card->rx_chain.head; |
312 | int ret; | 301 | int ret; |
313 | 302 | ||
314 | do { | 303 | do { |
315 | if (!descr->skb) { | 304 | if (!descr->skb) { |
316 | ret = gelic_net_prepare_rx_descr(card, descr); | 305 | ret = gelic_descr_prepare_rx(card, descr); |
317 | if (ret) | 306 | if (ret) |
318 | goto rewind; | 307 | goto rewind; |
319 | } | 308 | } |
@@ -322,41 +311,42 @@ static int gelic_net_fill_rx_chain(struct gelic_net_card *card) | |||
322 | 311 | ||
323 | return 0; | 312 | return 0; |
324 | rewind: | 313 | rewind: |
325 | gelic_net_release_rx_chain(card); | 314 | gelic_card_release_rx_chain(card); |
326 | return ret; | 315 | return ret; |
327 | } | 316 | } |
328 | 317 | ||
329 | /** | 318 | /** |
330 | * gelic_net_alloc_rx_skbs - allocates rx skbs in rx descriptor chains | 319 | * gelic_card_alloc_rx_skbs - allocates rx skbs in rx descriptor chains |
331 | * @card: card structure | 320 | * @card: card structure |
332 | * | 321 | * |
333 | * returns 0 on success, <0 on failure | 322 | * returns 0 on success, < 0 on failure |
334 | */ | 323 | */ |
335 | static int gelic_net_alloc_rx_skbs(struct gelic_net_card *card) | 324 | static int gelic_card_alloc_rx_skbs(struct gelic_card *card) |
336 | { | 325 | { |
337 | struct gelic_net_descr_chain *chain; | 326 | struct gelic_descr_chain *chain; |
338 | int ret; | 327 | int ret; |
339 | chain = &card->rx_chain; | 328 | chain = &card->rx_chain; |
340 | ret = gelic_net_fill_rx_chain(card); | 329 | ret = gelic_card_fill_rx_chain(card); |
341 | chain->head = card->rx_top->prev; /* point to the last */ | 330 | chain->head = card->rx_top->prev; /* point to the last */ |
342 | return ret; | 331 | return ret; |
343 | } | 332 | } |
344 | 333 | ||
345 | /** | 334 | /** |
346 | * gelic_net_release_tx_descr - processes a used tx descriptor | 335 | * gelic_descr_release_tx - processes a used tx descriptor |
347 | * @card: card structure | 336 | * @card: card structure |
348 | * @descr: descriptor to release | 337 | * @descr: descriptor to release |
349 | * | 338 | * |
350 | * releases a used tx descriptor (unmapping, freeing of skb) | 339 | * releases a used tx descriptor (unmapping, freeing of skb) |
351 | */ | 340 | */ |
352 | static void gelic_net_release_tx_descr(struct gelic_net_card *card, | 341 | static void gelic_descr_release_tx(struct gelic_card *card, |
353 | struct gelic_net_descr *descr) | 342 | struct gelic_descr *descr) |
354 | { | 343 | { |
355 | struct sk_buff *skb = descr->skb; | 344 | struct sk_buff *skb = descr->skb; |
356 | 345 | ||
346 | #ifdef DEBUG | ||
357 | BUG_ON(!(be32_to_cpu(descr->data_status) & | 347 | BUG_ON(!(be32_to_cpu(descr->data_status) & |
358 | (1 << GELIC_NET_TXDESC_TAIL))); | 348 | (1 << GELIC_DESCR_TX_DMA_FRAME_TAIL))); |
359 | 349 | #endif | |
360 | dma_unmap_single(ctodev(card), | 350 | dma_unmap_single(ctodev(card), |
361 | be32_to_cpu(descr->buf_addr), skb->len, DMA_TO_DEVICE); | 351 | be32_to_cpu(descr->buf_addr), skb->len, DMA_TO_DEVICE); |
362 | dev_kfree_skb_any(skb); | 352 | dev_kfree_skb_any(skb); |
@@ -371,30 +361,30 @@ static void gelic_net_release_tx_descr(struct gelic_net_card *card, | |||
371 | descr->skb = NULL; | 361 | descr->skb = NULL; |
372 | 362 | ||
373 | /* set descr status */ | 363 | /* set descr status */ |
374 | gelic_net_set_descr_status(descr, GELIC_NET_DESCR_NOT_IN_USE); | 364 | gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE); |
375 | } | 365 | } |
376 | 366 | ||
377 | /** | 367 | /** |
378 | * gelic_net_release_tx_chain - processes sent tx descriptors | 368 | * gelic_card_release_tx_chain - processes sent tx descriptors |
379 | * @card: adapter structure | 369 | * @card: adapter structure |
380 | * @stop: net_stop sequence | 370 | * @stop: net_stop sequence |
381 | * | 371 | * |
382 | * releases the tx descriptors that gelic has finished with | 372 | * releases the tx descriptors that gelic has finished with |
383 | */ | 373 | */ |
384 | static void gelic_net_release_tx_chain(struct gelic_net_card *card, int stop) | 374 | static void gelic_card_release_tx_chain(struct gelic_card *card, int stop) |
385 | { | 375 | { |
386 | struct gelic_net_descr_chain *tx_chain; | 376 | struct gelic_descr_chain *tx_chain; |
387 | enum gelic_net_descr_status status; | 377 | enum gelic_descr_dma_status status; |
388 | int release = 0; | 378 | int release = 0; |
389 | 379 | ||
390 | for (tx_chain = &card->tx_chain; | 380 | for (tx_chain = &card->tx_chain; |
391 | tx_chain->head != tx_chain->tail && tx_chain->tail; | 381 | tx_chain->head != tx_chain->tail && tx_chain->tail; |
392 | tx_chain->tail = tx_chain->tail->next) { | 382 | tx_chain->tail = tx_chain->tail->next) { |
393 | status = gelic_net_get_descr_status(tx_chain->tail); | 383 | status = gelic_descr_get_status(tx_chain->tail); |
394 | switch (status) { | 384 | switch (status) { |
395 | case GELIC_NET_DESCR_RESPONSE_ERROR: | 385 | case GELIC_DESCR_DMA_RESPONSE_ERROR: |
396 | case GELIC_NET_DESCR_PROTECTION_ERROR: | 386 | case GELIC_DESCR_DMA_PROTECTION_ERROR: |
397 | case GELIC_NET_DESCR_FORCE_END: | 387 | case GELIC_DESCR_DMA_FORCE_END: |
398 | if (printk_ratelimit()) | 388 | if (printk_ratelimit()) |
399 | dev_info(ctodev(card), | 389 | dev_info(ctodev(card), |
400 | "%s: forcing end of tx descriptor " \ | 390 | "%s: forcing end of tx descriptor " \ |
@@ -403,7 +393,7 @@ static void gelic_net_release_tx_chain(struct gelic_net_card *card, int stop) | |||
403 | card->netdev->stats.tx_dropped++; | 393 | card->netdev->stats.tx_dropped++; |
404 | break; | 394 | break; |
405 | 395 | ||
406 | case GELIC_NET_DESCR_COMPLETE: | 396 | case GELIC_DESCR_DMA_COMPLETE: |
407 | if (tx_chain->tail->skb) { | 397 | if (tx_chain->tail->skb) { |
408 | card->netdev->stats.tx_packets++; | 398 | card->netdev->stats.tx_packets++; |
409 | card->netdev->stats.tx_bytes += | 399 | card->netdev->stats.tx_bytes += |
@@ -411,14 +401,14 @@ static void gelic_net_release_tx_chain(struct gelic_net_card *card, int stop) | |||
411 | } | 401 | } |
412 | break; | 402 | break; |
413 | 403 | ||
414 | case GELIC_NET_DESCR_CARDOWNED: | 404 | case GELIC_DESCR_DMA_CARDOWNED: |
415 | /* pending tx request */ | 405 | /* pending tx request */ |
416 | default: | 406 | default: |
417 | /* any other value (== GELIC_NET_DESCR_NOT_IN_USE) */ | 407 | /* any other value (== GELIC_DESCR_DMA_NOT_IN_USE) */ |
418 | if (!stop) | 408 | if (!stop) |
419 | goto out; | 409 | goto out; |
420 | } | 410 | } |
421 | gelic_net_release_tx_descr(card, tx_chain->tail); | 411 | gelic_descr_release_tx(card, tx_chain->tail); |
422 | release ++; | 412 | release ++; |
423 | } | 413 | } |
424 | out: | 414 | out: |
@@ -436,7 +426,7 @@ out: | |||
436 | */ | 426 | */ |
437 | static void gelic_net_set_multi(struct net_device *netdev) | 427 | static void gelic_net_set_multi(struct net_device *netdev) |
438 | { | 428 | { |
439 | struct gelic_net_card *card = netdev_priv(netdev); | 429 | struct gelic_card *card = netdev_priv(netdev); |
440 | struct dev_mc_list *mc; | 430 | struct dev_mc_list *mc; |
441 | unsigned int i; | 431 | unsigned int i; |
442 | uint8_t *p; | 432 | uint8_t *p; |
@@ -489,13 +479,13 @@ static void gelic_net_set_multi(struct net_device *netdev) | |||
489 | } | 479 | } |
490 | 480 | ||
491 | /** | 481 | /** |
492 | * gelic_net_enable_rxdmac - enables the receive DMA controller | 482 | * gelic_card_enable_rxdmac - enables the receive DMA controller |
493 | * @card: card structure | 483 | * @card: card structure |
494 | * | 484 | * |
495 | * gelic_net_enable_rxdmac enables the DMA controller by setting RX_DMA_EN | 485 | * gelic_card_enable_rxdmac enables the DMA controller by setting RX_DMA_EN |
496 | * in the GDADMACCNTR register | 486 | * in the GDADMACCNTR register |
497 | */ | 487 | */ |
498 | static inline void gelic_net_enable_rxdmac(struct gelic_net_card *card) | 488 | static inline void gelic_card_enable_rxdmac(struct gelic_card *card) |
499 | { | 489 | { |
500 | int status; | 490 | int status; |
501 | 491 | ||
@@ -507,13 +497,13 @@ static inline void gelic_net_enable_rxdmac(struct gelic_net_card *card) | |||
507 | } | 497 | } |
508 | 498 | ||
509 | /** | 499 | /** |
510 | * gelic_net_disable_rxdmac - disables the receive DMA controller | 500 | * gelic_card_disable_rxdmac - disables the receive DMA controller |
511 | * @card: card structure | 501 | * @card: card structure |
512 | * | 502 | * |
513 | * gelic_net_disable_rxdmac terminates processing on the DMA controller by | 503 | * gelic_card_disable_rxdmac terminates processing on the DMA controller by |
514 | * turing off DMA and issueing a force end | 504 | * turing off DMA and issueing a force end |
515 | */ | 505 | */ |
516 | static inline void gelic_net_disable_rxdmac(struct gelic_net_card *card) | 506 | static inline void gelic_card_disable_rxdmac(struct gelic_card *card) |
517 | { | 507 | { |
518 | int status; | 508 | int status; |
519 | 509 | ||
@@ -525,13 +515,13 @@ static inline void gelic_net_disable_rxdmac(struct gelic_net_card *card) | |||
525 | } | 515 | } |
526 | 516 | ||
527 | /** | 517 | /** |
528 | * gelic_net_disable_txdmac - disables the transmit DMA controller | 518 | * gelic_card_disable_txdmac - disables the transmit DMA controller |
529 | * @card: card structure | 519 | * @card: card structure |
530 | * | 520 | * |
531 | * gelic_net_disable_txdmac terminates processing on the DMA controller by | 521 | * gelic_card_disable_txdmac terminates processing on the DMA controller by |
532 | * turing off DMA and issueing a force end | 522 | * turing off DMA and issueing a force end |
533 | */ | 523 | */ |
534 | static inline void gelic_net_disable_txdmac(struct gelic_net_card *card) | 524 | static inline void gelic_card_disable_txdmac(struct gelic_card *card) |
535 | { | 525 | { |
536 | int status; | 526 | int status; |
537 | 527 | ||
@@ -550,16 +540,16 @@ static inline void gelic_net_disable_txdmac(struct gelic_net_card *card) | |||
550 | */ | 540 | */ |
551 | static int gelic_net_stop(struct net_device *netdev) | 541 | static int gelic_net_stop(struct net_device *netdev) |
552 | { | 542 | { |
553 | struct gelic_net_card *card = netdev_priv(netdev); | 543 | struct gelic_card *card = netdev_priv(netdev); |
554 | 544 | ||
555 | napi_disable(&card->napi); | 545 | napi_disable(&card->napi); |
556 | netif_stop_queue(netdev); | 546 | netif_stop_queue(netdev); |
557 | 547 | ||
558 | /* turn off DMA, force end */ | 548 | /* turn off DMA, force end */ |
559 | gelic_net_disable_rxdmac(card); | 549 | gelic_card_disable_rxdmac(card); |
560 | gelic_net_disable_txdmac(card); | 550 | gelic_card_disable_txdmac(card); |
561 | 551 | ||
562 | gelic_net_set_irq_mask(card, 0); | 552 | gelic_card_set_irq_mask(card, 0); |
563 | 553 | ||
564 | /* disconnect event port */ | 554 | /* disconnect event port */ |
565 | free_irq(card->netdev->irq, card->netdev); | 555 | free_irq(card->netdev->irq, card->netdev); |
@@ -569,30 +559,30 @@ static int gelic_net_stop(struct net_device *netdev) | |||
569 | netif_carrier_off(netdev); | 559 | netif_carrier_off(netdev); |
570 | 560 | ||
571 | /* release chains */ | 561 | /* release chains */ |
572 | gelic_net_release_tx_chain(card, 1); | 562 | gelic_card_release_tx_chain(card, 1); |
573 | gelic_net_release_rx_chain(card); | 563 | gelic_card_release_rx_chain(card); |
574 | 564 | ||
575 | gelic_net_free_chain(card, card->tx_top); | 565 | gelic_card_free_chain(card, card->tx_top); |
576 | gelic_net_free_chain(card, card->rx_top); | 566 | gelic_card_free_chain(card, card->rx_top); |
577 | 567 | ||
578 | return 0; | 568 | return 0; |
579 | } | 569 | } |
580 | 570 | ||
581 | /** | 571 | /** |
582 | * gelic_net_get_next_tx_descr - returns the next available tx descriptor | 572 | * gelic_card_get_next_tx_descr - returns the next available tx descriptor |
583 | * @card: device structure to get descriptor from | 573 | * @card: device structure to get descriptor from |
584 | * | 574 | * |
585 | * returns the address of the next descriptor, or NULL if not available. | 575 | * returns the address of the next descriptor, or NULL if not available. |
586 | */ | 576 | */ |
587 | static struct gelic_net_descr * | 577 | static struct gelic_descr * |
588 | gelic_net_get_next_tx_descr(struct gelic_net_card *card) | 578 | gelic_card_get_next_tx_descr(struct gelic_card *card) |
589 | { | 579 | { |
590 | if (!card->tx_chain.head) | 580 | if (!card->tx_chain.head) |
591 | return NULL; | 581 | return NULL; |
592 | /* see if the next descriptor is free */ | 582 | /* see if the next descriptor is free */ |
593 | if (card->tx_chain.tail != card->tx_chain.head->next && | 583 | if (card->tx_chain.tail != card->tx_chain.head->next && |
594 | gelic_net_get_descr_status(card->tx_chain.head) == | 584 | gelic_descr_get_status(card->tx_chain.head) == |
595 | GELIC_NET_DESCR_NOT_IN_USE) | 585 | GELIC_DESCR_DMA_NOT_IN_USE) |
596 | return card->tx_chain.head; | 586 | return card->tx_chain.head; |
597 | else | 587 | else |
598 | return NULL; | 588 | return NULL; |
@@ -600,7 +590,7 @@ gelic_net_get_next_tx_descr(struct gelic_net_card *card) | |||
600 | } | 590 | } |
601 | 591 | ||
602 | /** | 592 | /** |
603 | * gelic_net_set_txdescr_cmdstat - sets the tx descriptor command field | 593 | * gelic_descr_set_tx_cmdstat - sets the tx descriptor command field |
604 | * @descr: descriptor structure to fill out | 594 | * @descr: descriptor structure to fill out |
605 | * @skb: packet to consider | 595 | * @skb: packet to consider |
606 | * | 596 | * |
@@ -608,33 +598,33 @@ gelic_net_get_next_tx_descr(struct gelic_net_card *card) | |||
608 | * depending on hardware checksum settings. This function assumes a wmb() | 598 | * depending on hardware checksum settings. This function assumes a wmb() |
609 | * has executed before. | 599 | * has executed before. |
610 | */ | 600 | */ |
611 | static void gelic_net_set_txdescr_cmdstat(struct gelic_net_descr *descr, | 601 | static void gelic_descr_set_tx_cmdstat(struct gelic_descr *descr, |
612 | struct sk_buff *skb) | 602 | struct sk_buff *skb) |
613 | { | 603 | { |
614 | if (skb->ip_summed != CHECKSUM_PARTIAL) | 604 | if (skb->ip_summed != CHECKSUM_PARTIAL) |
615 | descr->dmac_cmd_status = | 605 | descr->dmac_cmd_status = |
616 | cpu_to_be32(GELIC_NET_DMAC_CMDSTAT_NOCS | | 606 | cpu_to_be32(GELIC_DESCR_DMA_CMD_NO_CHKSUM | |
617 | GELIC_NET_DMAC_CMDSTAT_END_FRAME); | 607 | GELIC_DESCR_TX_DMA_FRAME_TAIL); |
618 | else { | 608 | else { |
619 | /* is packet ip? | 609 | /* is packet ip? |
620 | * if yes: tcp? udp? */ | 610 | * if yes: tcp? udp? */ |
621 | if (skb->protocol == htons(ETH_P_IP)) { | 611 | if (skb->protocol == htons(ETH_P_IP)) { |
622 | if (ip_hdr(skb)->protocol == IPPROTO_TCP) | 612 | if (ip_hdr(skb)->protocol == IPPROTO_TCP) |
623 | descr->dmac_cmd_status = | 613 | descr->dmac_cmd_status = |
624 | cpu_to_be32(GELIC_NET_DMAC_CMDSTAT_TCPCS | | 614 | cpu_to_be32(GELIC_DESCR_DMA_CMD_TCP_CHKSUM | |
625 | GELIC_NET_DMAC_CMDSTAT_END_FRAME); | 615 | GELIC_DESCR_TX_DMA_FRAME_TAIL); |
626 | 616 | ||
627 | else if (ip_hdr(skb)->protocol == IPPROTO_UDP) | 617 | else if (ip_hdr(skb)->protocol == IPPROTO_UDP) |
628 | descr->dmac_cmd_status = | 618 | descr->dmac_cmd_status = |
629 | cpu_to_be32(GELIC_NET_DMAC_CMDSTAT_UDPCS | | 619 | cpu_to_be32(GELIC_DESCR_DMA_CMD_UDP_CHKSUM | |
630 | GELIC_NET_DMAC_CMDSTAT_END_FRAME); | 620 | GELIC_DESCR_TX_DMA_FRAME_TAIL); |
631 | else /* | 621 | else /* |
632 | * the stack should checksum non-tcp and non-udp | 622 | * the stack should checksum non-tcp and non-udp |
633 | * packets on his own: NETIF_F_IP_CSUM | 623 | * packets on his own: NETIF_F_IP_CSUM |
634 | */ | 624 | */ |
635 | descr->dmac_cmd_status = | 625 | descr->dmac_cmd_status = |
636 | cpu_to_be32(GELIC_NET_DMAC_CMDSTAT_NOCS | | 626 | cpu_to_be32(GELIC_DESCR_DMA_CMD_NO_CHKSUM | |
637 | GELIC_NET_DMAC_CMDSTAT_END_FRAME); | 627 | GELIC_DESCR_TX_DMA_FRAME_TAIL); |
638 | } | 628 | } |
639 | } | 629 | } |
640 | } | 630 | } |
@@ -665,7 +655,7 @@ static inline struct sk_buff *gelic_put_vlan_tag(struct sk_buff *skb, | |||
665 | } | 655 | } |
666 | 656 | ||
667 | /** | 657 | /** |
668 | * gelic_net_prepare_tx_descr_v - get dma address of skb_data | 658 | * gelic_descr_prepare_tx - get dma address of skb_data |
669 | * @card: card structure | 659 | * @card: card structure |
670 | * @descr: descriptor structure | 660 | * @descr: descriptor structure |
671 | * @skb: packet to use | 661 | * @skb: packet to use |
@@ -673,9 +663,9 @@ static inline struct sk_buff *gelic_put_vlan_tag(struct sk_buff *skb, | |||
673 | * returns 0 on success, <0 on failure. | 663 | * returns 0 on success, <0 on failure. |
674 | * | 664 | * |
675 | */ | 665 | */ |
676 | static int gelic_net_prepare_tx_descr_v(struct gelic_net_card *card, | 666 | static int gelic_descr_prepare_tx(struct gelic_card *card, |
677 | struct gelic_net_descr *descr, | 667 | struct gelic_descr *descr, |
678 | struct sk_buff *skb) | 668 | struct sk_buff *skb) |
679 | { | 669 | { |
680 | dma_addr_t buf; | 670 | dma_addr_t buf; |
681 | 671 | ||
@@ -702,7 +692,7 @@ static int gelic_net_prepare_tx_descr_v(struct gelic_net_card *card, | |||
702 | descr->skb = skb; | 692 | descr->skb = skb; |
703 | descr->data_status = 0; | 693 | descr->data_status = 0; |
704 | descr->next_descr_addr = 0; /* terminate hw descr */ | 694 | descr->next_descr_addr = 0; /* terminate hw descr */ |
705 | gelic_net_set_txdescr_cmdstat(descr, skb); | 695 | gelic_descr_set_tx_cmdstat(descr, skb); |
706 | 696 | ||
707 | /* bump free descriptor pointer */ | 697 | /* bump free descriptor pointer */ |
708 | card->tx_chain.head = descr->next; | 698 | card->tx_chain.head = descr->next; |
@@ -710,20 +700,20 @@ static int gelic_net_prepare_tx_descr_v(struct gelic_net_card *card, | |||
710 | } | 700 | } |
711 | 701 | ||
712 | /** | 702 | /** |
713 | * gelic_net_kick_txdma - enables TX DMA processing | 703 | * gelic_card_kick_txdma - enables TX DMA processing |
714 | * @card: card structure | 704 | * @card: card structure |
715 | * @descr: descriptor address to enable TX processing at | 705 | * @descr: descriptor address to enable TX processing at |
716 | * | 706 | * |
717 | */ | 707 | */ |
718 | static int gelic_net_kick_txdma(struct gelic_net_card *card, | 708 | static int gelic_card_kick_txdma(struct gelic_card *card, |
719 | struct gelic_net_descr *descr) | 709 | struct gelic_descr *descr) |
720 | { | 710 | { |
721 | int status = 0; | 711 | int status = 0; |
722 | 712 | ||
723 | if (card->tx_dma_progress) | 713 | if (card->tx_dma_progress) |
724 | return 0; | 714 | return 0; |
725 | 715 | ||
726 | if (gelic_net_get_descr_status(descr) == GELIC_NET_DESCR_CARDOWNED) { | 716 | if (gelic_descr_get_status(descr) == GELIC_DESCR_DMA_CARDOWNED) { |
727 | card->tx_dma_progress = 1; | 717 | card->tx_dma_progress = 1; |
728 | status = lv1_net_start_tx_dma(bus_id(card), dev_id(card), | 718 | status = lv1_net_start_tx_dma(bus_id(card), dev_id(card), |
729 | descr->bus_addr, 0); | 719 | descr->bus_addr, 0); |
@@ -743,16 +733,16 @@ static int gelic_net_kick_txdma(struct gelic_net_card *card, | |||
743 | */ | 733 | */ |
744 | static int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev) | 734 | static int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev) |
745 | { | 735 | { |
746 | struct gelic_net_card *card = netdev_priv(netdev); | 736 | struct gelic_card *card = netdev_priv(netdev); |
747 | struct gelic_net_descr *descr; | 737 | struct gelic_descr *descr; |
748 | int result; | 738 | int result; |
749 | unsigned long flags; | 739 | unsigned long flags; |
750 | 740 | ||
751 | spin_lock_irqsave(&card->tx_dma_lock, flags); | 741 | spin_lock_irqsave(&card->tx_dma_lock, flags); |
752 | 742 | ||
753 | gelic_net_release_tx_chain(card, 0); | 743 | gelic_card_release_tx_chain(card, 0); |
754 | 744 | ||
755 | descr = gelic_net_get_next_tx_descr(card); | 745 | descr = gelic_card_get_next_tx_descr(card); |
756 | if (!descr) { | 746 | if (!descr) { |
757 | /* | 747 | /* |
758 | * no more descriptors free | 748 | * no more descriptors free |
@@ -762,7 +752,7 @@ static int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev) | |||
762 | return NETDEV_TX_BUSY; | 752 | return NETDEV_TX_BUSY; |
763 | } | 753 | } |
764 | 754 | ||
765 | result = gelic_net_prepare_tx_descr_v(card, descr, skb); | 755 | result = gelic_descr_prepare_tx(card, descr, skb); |
766 | if (result) { | 756 | if (result) { |
767 | /* | 757 | /* |
768 | * DMA map failed. As chanses are that failure | 758 | * DMA map failed. As chanses are that failure |
@@ -783,14 +773,14 @@ static int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev) | |||
783 | * ensure that the hardware sees it | 773 | * ensure that the hardware sees it |
784 | */ | 774 | */ |
785 | wmb(); | 775 | wmb(); |
786 | if (gelic_net_kick_txdma(card, descr)) { | 776 | if (gelic_card_kick_txdma(card, descr)) { |
787 | /* | 777 | /* |
788 | * kick failed. | 778 | * kick failed. |
789 | * release descriptors which were just prepared | 779 | * release descriptors which were just prepared |
790 | */ | 780 | */ |
791 | card->netdev->stats.tx_dropped++; | 781 | card->netdev->stats.tx_dropped++; |
792 | gelic_net_release_tx_descr(card, descr); | 782 | gelic_descr_release_tx(card, descr); |
793 | gelic_net_release_tx_descr(card, descr->next); | 783 | gelic_descr_release_tx(card, descr->next); |
794 | card->tx_chain.tail = descr->next->next; | 784 | card->tx_chain.tail = descr->next->next; |
795 | dev_info(ctodev(card), "%s: kick failure\n", __func__); | 785 | dev_info(ctodev(card), "%s: kick failure\n", __func__); |
796 | } else { | 786 | } else { |
@@ -810,8 +800,8 @@ static int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev) | |||
810 | * iommu-unmaps the skb, fills out skb structure and passes the data to the | 800 | * iommu-unmaps the skb, fills out skb structure and passes the data to the |
811 | * stack. The descriptor state is not changed. | 801 | * stack. The descriptor state is not changed. |
812 | */ | 802 | */ |
813 | static void gelic_net_pass_skb_up(struct gelic_net_descr *descr, | 803 | static void gelic_net_pass_skb_up(struct gelic_descr *descr, |
814 | struct gelic_net_card *card) | 804 | struct gelic_card *card) |
815 | { | 805 | { |
816 | struct sk_buff *skb; | 806 | struct sk_buff *skb; |
817 | struct net_device *netdev; | 807 | struct net_device *netdev; |
@@ -845,8 +835,8 @@ static void gelic_net_pass_skb_up(struct gelic_net_descr *descr, | |||
845 | 835 | ||
846 | /* checksum offload */ | 836 | /* checksum offload */ |
847 | if (card->rx_csum) { | 837 | if (card->rx_csum) { |
848 | if ((data_status & GELIC_NET_DATA_STATUS_CHK_MASK) && | 838 | if ((data_status & GELIC_DESCR_DATA_STATUS_CHK_MASK) && |
849 | (!(data_error & GELIC_NET_DATA_ERROR_CHK_MASK))) | 839 | (!(data_error & GELIC_DESCR_DATA_ERROR_CHK_MASK))) |
850 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 840 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
851 | else | 841 | else |
852 | skb->ip_summed = CHECKSUM_NONE; | 842 | skb->ip_summed = CHECKSUM_NONE; |
@@ -862,7 +852,7 @@ static void gelic_net_pass_skb_up(struct gelic_net_descr *descr, | |||
862 | } | 852 | } |
863 | 853 | ||
864 | /** | 854 | /** |
865 | * gelic_net_decode_one_descr - processes an rx descriptor | 855 | * gelic_card_decode_one_descr - processes an rx descriptor |
866 | * @card: card structure | 856 | * @card: card structure |
867 | * | 857 | * |
868 | * returns 1 if a packet has been sent to the stack, otherwise 0 | 858 | * returns 1 if a packet has been sent to the stack, otherwise 0 |
@@ -870,37 +860,37 @@ static void gelic_net_pass_skb_up(struct gelic_net_descr *descr, | |||
870 | * processes an rx descriptor by iommu-unmapping the data buffer and passing | 860 | * processes an rx descriptor by iommu-unmapping the data buffer and passing |
871 | * the packet up to the stack | 861 | * the packet up to the stack |
872 | */ | 862 | */ |
873 | static int gelic_net_decode_one_descr(struct gelic_net_card *card) | 863 | static int gelic_card_decode_one_descr(struct gelic_card *card) |
874 | { | 864 | { |
875 | enum gelic_net_descr_status status; | 865 | enum gelic_descr_dma_status status; |
876 | struct gelic_net_descr_chain *chain = &card->rx_chain; | 866 | struct gelic_descr_chain *chain = &card->rx_chain; |
877 | struct gelic_net_descr *descr = chain->tail; | 867 | struct gelic_descr *descr = chain->tail; |
878 | int dmac_chain_ended; | 868 | int dmac_chain_ended; |
879 | 869 | ||
880 | status = gelic_net_get_descr_status(descr); | 870 | status = gelic_descr_get_status(descr); |
881 | /* is this descriptor terminated with next_descr == NULL? */ | 871 | /* is this descriptor terminated with next_descr == NULL? */ |
882 | dmac_chain_ended = | 872 | dmac_chain_ended = |
883 | be32_to_cpu(descr->dmac_cmd_status) & | 873 | be32_to_cpu(descr->dmac_cmd_status) & |
884 | GELIC_NET_DMAC_CMDSTAT_RXDCEIS; | 874 | GELIC_DESCR_RX_DMA_CHAIN_END; |
885 | 875 | ||
886 | if (status == GELIC_NET_DESCR_CARDOWNED) | 876 | if (status == GELIC_DESCR_DMA_CARDOWNED) |
887 | return 0; | 877 | return 0; |
888 | 878 | ||
889 | if (status == GELIC_NET_DESCR_NOT_IN_USE) { | 879 | if (status == GELIC_DESCR_DMA_NOT_IN_USE) { |
890 | dev_dbg(ctodev(card), "dormant descr? %p\n", descr); | 880 | dev_dbg(ctodev(card), "dormant descr? %p\n", descr); |
891 | return 0; | 881 | return 0; |
892 | } | 882 | } |
893 | 883 | ||
894 | if ((status == GELIC_NET_DESCR_RESPONSE_ERROR) || | 884 | if ((status == GELIC_DESCR_DMA_RESPONSE_ERROR) || |
895 | (status == GELIC_NET_DESCR_PROTECTION_ERROR) || | 885 | (status == GELIC_DESCR_DMA_PROTECTION_ERROR) || |
896 | (status == GELIC_NET_DESCR_FORCE_END)) { | 886 | (status == GELIC_DESCR_DMA_FORCE_END)) { |
897 | dev_info(ctodev(card), "dropping RX descriptor with state %x\n", | 887 | dev_info(ctodev(card), "dropping RX descriptor with state %x\n", |
898 | status); | 888 | status); |
899 | card->netdev->stats.rx_dropped++; | 889 | card->netdev->stats.rx_dropped++; |
900 | goto refill; | 890 | goto refill; |
901 | } | 891 | } |
902 | 892 | ||
903 | if (status == GELIC_NET_DESCR_BUFFER_FULL) { | 893 | if (status == GELIC_DESCR_DMA_BUFFER_FULL) { |
904 | /* | 894 | /* |
905 | * Buffer full would occur if and only if | 895 | * Buffer full would occur if and only if |
906 | * the frame length was longer than the size of this | 896 | * the frame length was longer than the size of this |
@@ -917,7 +907,7 @@ static int gelic_net_decode_one_descr(struct gelic_net_card *card) | |||
917 | * descriptoers any other than FRAME_END here should | 907 | * descriptoers any other than FRAME_END here should |
918 | * be treated as error. | 908 | * be treated as error. |
919 | */ | 909 | */ |
920 | if (status != GELIC_NET_DESCR_FRAME_END) { | 910 | if (status != GELIC_DESCR_DMA_FRAME_END) { |
921 | dev_dbg(ctodev(card), "RX descriptor with state %x\n", | 911 | dev_dbg(ctodev(card), "RX descriptor with state %x\n", |
922 | status); | 912 | status); |
923 | goto refill; | 913 | goto refill; |
@@ -934,13 +924,13 @@ refill: | |||
934 | descr->next_descr_addr = 0; | 924 | descr->next_descr_addr = 0; |
935 | 925 | ||
936 | /* change the descriptor state: */ | 926 | /* change the descriptor state: */ |
937 | gelic_net_set_descr_status(descr, GELIC_NET_DESCR_NOT_IN_USE); | 927 | gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE); |
938 | 928 | ||
939 | /* | 929 | /* |
940 | * this call can fail, but for now, just leave this | 930 | * this call can fail, but for now, just leave this |
941 | * decriptor without skb | 931 | * decriptor without skb |
942 | */ | 932 | */ |
943 | gelic_net_prepare_rx_descr(card, descr); | 933 | gelic_descr_prepare_rx(card, descr); |
944 | 934 | ||
945 | chain->head = descr; | 935 | chain->head = descr; |
946 | chain->tail = descr->next; | 936 | chain->tail = descr->next; |
@@ -973,12 +963,12 @@ refill: | |||
973 | */ | 963 | */ |
974 | static int gelic_net_poll(struct napi_struct *napi, int budget) | 964 | static int gelic_net_poll(struct napi_struct *napi, int budget) |
975 | { | 965 | { |
976 | struct gelic_net_card *card = container_of(napi, struct gelic_net_card, napi); | 966 | struct gelic_card *card = container_of(napi, struct gelic_card, napi); |
977 | struct net_device *netdev = card->netdev; | 967 | struct net_device *netdev = card->netdev; |
978 | int packets_done = 0; | 968 | int packets_done = 0; |
979 | 969 | ||
980 | while (packets_done < budget) { | 970 | while (packets_done < budget) { |
981 | if (!gelic_net_decode_one_descr(card)) | 971 | if (!gelic_card_decode_one_descr(card)) |
982 | break; | 972 | break; |
983 | 973 | ||
984 | packets_done++; | 974 | packets_done++; |
@@ -986,7 +976,7 @@ static int gelic_net_poll(struct napi_struct *napi, int budget) | |||
986 | 976 | ||
987 | if (packets_done < budget) { | 977 | if (packets_done < budget) { |
988 | netif_rx_complete(netdev, napi); | 978 | netif_rx_complete(netdev, napi); |
989 | gelic_net_rx_irq_on(card); | 979 | gelic_card_rx_irq_on(card); |
990 | } | 980 | } |
991 | return packets_done; | 981 | return packets_done; |
992 | } | 982 | } |
@@ -1010,13 +1000,13 @@ static int gelic_net_change_mtu(struct net_device *netdev, int new_mtu) | |||
1010 | } | 1000 | } |
1011 | 1001 | ||
1012 | /** | 1002 | /** |
1013 | * gelic_net_interrupt - event handler for gelic_net | 1003 | * gelic_card_interrupt - event handler for gelic_net |
1014 | */ | 1004 | */ |
1015 | static irqreturn_t gelic_net_interrupt(int irq, void *ptr) | 1005 | static irqreturn_t gelic_card_interrupt(int irq, void *ptr) |
1016 | { | 1006 | { |
1017 | unsigned long flags; | 1007 | unsigned long flags; |
1018 | struct net_device *netdev = ptr; | 1008 | struct net_device *netdev = ptr; |
1019 | struct gelic_net_card *card = netdev_priv(netdev); | 1009 | struct gelic_card *card = netdev_priv(netdev); |
1020 | u64 status; | 1010 | u64 status; |
1021 | 1011 | ||
1022 | status = card->irq_status; | 1012 | status = card->irq_status; |
@@ -1026,20 +1016,20 @@ static irqreturn_t gelic_net_interrupt(int irq, void *ptr) | |||
1026 | 1016 | ||
1027 | if (card->rx_dma_restart_required) { | 1017 | if (card->rx_dma_restart_required) { |
1028 | card->rx_dma_restart_required = 0; | 1018 | card->rx_dma_restart_required = 0; |
1029 | gelic_net_enable_rxdmac(card); | 1019 | gelic_card_enable_rxdmac(card); |
1030 | } | 1020 | } |
1031 | 1021 | ||
1032 | if (status & GELIC_NET_RXINT) { | 1022 | if (status & GELIC_CARD_RXINT) { |
1033 | gelic_net_rx_irq_off(card); | 1023 | gelic_card_rx_irq_off(card); |
1034 | netif_rx_schedule(netdev, &card->napi); | 1024 | netif_rx_schedule(netdev, &card->napi); |
1035 | } | 1025 | } |
1036 | 1026 | ||
1037 | if (status & GELIC_NET_TXINT) { | 1027 | if (status & GELIC_CARD_TXINT) { |
1038 | spin_lock_irqsave(&card->tx_dma_lock, flags); | 1028 | spin_lock_irqsave(&card->tx_dma_lock, flags); |
1039 | card->tx_dma_progress = 0; | 1029 | card->tx_dma_progress = 0; |
1040 | gelic_net_release_tx_chain(card, 0); | 1030 | gelic_card_release_tx_chain(card, 0); |
1041 | /* kick outstanding tx descriptor if any */ | 1031 | /* kick outstanding tx descriptor if any */ |
1042 | gelic_net_kick_txdma(card, card->tx_chain.tail); | 1032 | gelic_card_kick_txdma(card, card->tx_chain.tail); |
1043 | spin_unlock_irqrestore(&card->tx_dma_lock, flags); | 1033 | spin_unlock_irqrestore(&card->tx_dma_lock, flags); |
1044 | } | 1034 | } |
1045 | return IRQ_HANDLED; | 1035 | return IRQ_HANDLED; |
@@ -1054,19 +1044,19 @@ static irqreturn_t gelic_net_interrupt(int irq, void *ptr) | |||
1054 | */ | 1044 | */ |
1055 | static void gelic_net_poll_controller(struct net_device *netdev) | 1045 | static void gelic_net_poll_controller(struct net_device *netdev) |
1056 | { | 1046 | { |
1057 | struct gelic_net_card *card = netdev_priv(netdev); | 1047 | struct gelic_card *card = netdev_priv(netdev); |
1058 | 1048 | ||
1059 | gelic_net_set_irq_mask(card, 0); | 1049 | gelic_card_set_irq_mask(card, 0); |
1060 | gelic_net_interrupt(netdev->irq, netdev); | 1050 | gelic_card_interrupt(netdev->irq, netdev); |
1061 | gelic_net_set_irq_mask(card, card->ghiintmask); | 1051 | gelic_card_set_irq_mask(card, card->ghiintmask); |
1062 | } | 1052 | } |
1063 | #endif /* CONFIG_NET_POLL_CONTROLLER */ | 1053 | #endif /* CONFIG_NET_POLL_CONTROLLER */ |
1064 | 1054 | ||
1065 | /** | 1055 | /** |
1066 | * gelic_net_open_device - open device and map dma region | 1056 | * gelic_card_open - open device and map dma region |
1067 | * @card: card structure | 1057 | * @card: card structure |
1068 | */ | 1058 | */ |
1069 | static int gelic_net_open_device(struct gelic_net_card *card) | 1059 | static int gelic_card_open(struct gelic_card *card) |
1070 | { | 1060 | { |
1071 | int result; | 1061 | int result; |
1072 | 1062 | ||
@@ -1075,13 +1065,13 @@ static int gelic_net_open_device(struct gelic_net_card *card) | |||
1075 | 1065 | ||
1076 | if (result) { | 1066 | if (result) { |
1077 | dev_info(ctodev(card), | 1067 | dev_info(ctodev(card), |
1078 | "%s:%d: gelic_net_open_device failed (%d)\n", | 1068 | "%s:%d: recieve_port_setup failed (%d)\n", |
1079 | __func__, __LINE__, result); | 1069 | __func__, __LINE__, result); |
1080 | result = -EPERM; | 1070 | result = -EPERM; |
1081 | goto fail_alloc_irq; | 1071 | goto fail_alloc_irq; |
1082 | } | 1072 | } |
1083 | 1073 | ||
1084 | result = request_irq(card->netdev->irq, gelic_net_interrupt, | 1074 | result = request_irq(card->netdev->irq, gelic_card_interrupt, |
1085 | IRQF_DISABLED, card->netdev->name, card->netdev); | 1075 | IRQF_DISABLED, card->netdev->name, card->netdev); |
1086 | 1076 | ||
1087 | if (result) { | 1077 | if (result) { |
@@ -1111,37 +1101,37 @@ fail_alloc_irq: | |||
1111 | */ | 1101 | */ |
1112 | static int gelic_net_open(struct net_device *netdev) | 1102 | static int gelic_net_open(struct net_device *netdev) |
1113 | { | 1103 | { |
1114 | struct gelic_net_card *card = netdev_priv(netdev); | 1104 | struct gelic_card *card = netdev_priv(netdev); |
1115 | 1105 | ||
1116 | dev_dbg(ctodev(card), " -> %s:%d\n", __func__, __LINE__); | 1106 | dev_dbg(ctodev(card), " -> %s:%d\n", __func__, __LINE__); |
1117 | 1107 | ||
1118 | gelic_net_open_device(card); | 1108 | gelic_card_open(card); |
1119 | 1109 | ||
1120 | if (gelic_net_init_chain(card, &card->tx_chain, | 1110 | if (gelic_card_init_chain(card, &card->tx_chain, |
1121 | card->descr, GELIC_NET_TX_DESCRIPTORS)) | 1111 | card->descr, GELIC_NET_TX_DESCRIPTORS)) |
1122 | goto alloc_tx_failed; | 1112 | goto alloc_tx_failed; |
1123 | if (gelic_net_init_chain(card, &card->rx_chain, | 1113 | if (gelic_card_init_chain(card, &card->rx_chain, |
1124 | card->descr + GELIC_NET_TX_DESCRIPTORS, | 1114 | card->descr + GELIC_NET_TX_DESCRIPTORS, |
1125 | GELIC_NET_RX_DESCRIPTORS)) | 1115 | GELIC_NET_RX_DESCRIPTORS)) |
1126 | goto alloc_rx_failed; | 1116 | goto alloc_rx_failed; |
1127 | 1117 | ||
1128 | /* head of chain */ | 1118 | /* head of chain */ |
1129 | card->tx_top = card->tx_chain.head; | 1119 | card->tx_top = card->tx_chain.head; |
1130 | card->rx_top = card->rx_chain.head; | 1120 | card->rx_top = card->rx_chain.head; |
1131 | dev_dbg(ctodev(card), "descr rx %p, tx %p, size %#lx, num %#x\n", | 1121 | dev_dbg(ctodev(card), "descr rx %p, tx %p, size %#lx, num %#x\n", |
1132 | card->rx_top, card->tx_top, sizeof(struct gelic_net_descr), | 1122 | card->rx_top, card->tx_top, sizeof(struct gelic_descr), |
1133 | GELIC_NET_RX_DESCRIPTORS); | 1123 | GELIC_NET_RX_DESCRIPTORS); |
1134 | /* allocate rx skbs */ | 1124 | /* allocate rx skbs */ |
1135 | if (gelic_net_alloc_rx_skbs(card)) | 1125 | if (gelic_card_alloc_rx_skbs(card)) |
1136 | goto alloc_skbs_failed; | 1126 | goto alloc_skbs_failed; |
1137 | 1127 | ||
1138 | napi_enable(&card->napi); | 1128 | napi_enable(&card->napi); |
1139 | 1129 | ||
1140 | card->tx_dma_progress = 0; | 1130 | card->tx_dma_progress = 0; |
1141 | card->ghiintmask = GELIC_NET_RXINT | GELIC_NET_TXINT; | 1131 | card->ghiintmask = GELIC_CARD_RXINT | GELIC_CARD_TXINT; |
1142 | 1132 | ||
1143 | gelic_net_set_irq_mask(card, card->ghiintmask); | 1133 | gelic_card_set_irq_mask(card, card->ghiintmask); |
1144 | gelic_net_enable_rxdmac(card); | 1134 | gelic_card_enable_rxdmac(card); |
1145 | 1135 | ||
1146 | netif_start_queue(netdev); | 1136 | netif_start_queue(netdev); |
1147 | netif_carrier_on(netdev); | 1137 | netif_carrier_on(netdev); |
@@ -1149,46 +1139,47 @@ static int gelic_net_open(struct net_device *netdev) | |||
1149 | return 0; | 1139 | return 0; |
1150 | 1140 | ||
1151 | alloc_skbs_failed: | 1141 | alloc_skbs_failed: |
1152 | gelic_net_free_chain(card, card->rx_top); | 1142 | gelic_card_free_chain(card, card->rx_top); |
1153 | alloc_rx_failed: | 1143 | alloc_rx_failed: |
1154 | gelic_net_free_chain(card, card->tx_top); | 1144 | gelic_card_free_chain(card, card->tx_top); |
1155 | alloc_tx_failed: | 1145 | alloc_tx_failed: |
1156 | return -ENOMEM; | 1146 | return -ENOMEM; |
1157 | } | 1147 | } |
1158 | 1148 | ||
1159 | static void gelic_net_get_drvinfo (struct net_device *netdev, | 1149 | static void gelic_net_get_drvinfo(struct net_device *netdev, |
1160 | struct ethtool_drvinfo *info) | 1150 | struct ethtool_drvinfo *info) |
1161 | { | 1151 | { |
1162 | strncpy(info->driver, DRV_NAME, sizeof(info->driver) - 1); | 1152 | strncpy(info->driver, DRV_NAME, sizeof(info->driver) - 1); |
1163 | strncpy(info->version, DRV_VERSION, sizeof(info->version) - 1); | 1153 | strncpy(info->version, DRV_VERSION, sizeof(info->version) - 1); |
1164 | } | 1154 | } |
1165 | 1155 | ||
1166 | static int gelic_net_get_settings(struct net_device *netdev, | 1156 | static int gelic_ether_get_settings(struct net_device *netdev, |
1167 | struct ethtool_cmd *cmd) | 1157 | struct ethtool_cmd *cmd) |
1168 | { | 1158 | { |
1169 | struct gelic_net_card *card = netdev_priv(netdev); | 1159 | struct gelic_card *card = netdev_priv(netdev); |
1170 | int status; | 1160 | int status; |
1171 | u64 v1, v2; | 1161 | u64 v1, v2; |
1172 | int speed, duplex; | 1162 | int speed, duplex; |
1173 | 1163 | ||
1174 | speed = duplex = -1; | 1164 | speed = duplex = -1; |
1175 | status = lv1_net_control(bus_id(card), dev_id(card), | 1165 | status = lv1_net_control(bus_id(card), dev_id(card), |
1176 | GELIC_NET_GET_ETH_PORT_STATUS, GELIC_NET_PORT, 0, 0, | 1166 | GELIC_LV1_GET_ETH_PORT_STATUS, |
1177 | &v1, &v2); | 1167 | GELIC_LV1_VLAN_TX_ETHERNET, 0, 0, |
1168 | &v1, &v2); | ||
1178 | if (status) { | 1169 | if (status) { |
1179 | /* link down */ | 1170 | /* link down */ |
1180 | } else { | 1171 | } else { |
1181 | if (v1 & GELIC_NET_FULL_DUPLEX) { | 1172 | if (v1 & GELIC_LV1_ETHER_FULL_DUPLEX) { |
1182 | duplex = DUPLEX_FULL; | 1173 | duplex = DUPLEX_FULL; |
1183 | } else { | 1174 | } else { |
1184 | duplex = DUPLEX_HALF; | 1175 | duplex = DUPLEX_HALF; |
1185 | } | 1176 | } |
1186 | 1177 | ||
1187 | if (v1 & GELIC_NET_SPEED_10 ) { | 1178 | if (v1 & GELIC_LV1_ETHER_SPEED_10) { |
1188 | speed = SPEED_10; | 1179 | speed = SPEED_10; |
1189 | } else if (v1 & GELIC_NET_SPEED_100) { | 1180 | } else if (v1 & GELIC_LV1_ETHER_SPEED_100) { |
1190 | speed = SPEED_100; | 1181 | speed = SPEED_100; |
1191 | } else if (v1 & GELIC_NET_SPEED_1000) { | 1182 | } else if (v1 & GELIC_LV1_ETHER_SPEED_1000) { |
1192 | speed = SPEED_1000; | 1183 | speed = SPEED_1000; |
1193 | } | 1184 | } |
1194 | } | 1185 | } |
@@ -1205,20 +1196,21 @@ static int gelic_net_get_settings(struct net_device *netdev, | |||
1205 | return 0; | 1196 | return 0; |
1206 | } | 1197 | } |
1207 | 1198 | ||
1208 | static u32 gelic_net_get_link(struct net_device *netdev) | 1199 | static u32 gelic_ether_get_link(struct net_device *netdev) |
1209 | { | 1200 | { |
1210 | struct gelic_net_card *card = netdev_priv(netdev); | 1201 | struct gelic_card *card = netdev_priv(netdev); |
1211 | int status; | 1202 | int status; |
1212 | u64 v1, v2; | 1203 | u64 v1, v2; |
1213 | int link; | 1204 | int link; |
1214 | 1205 | ||
1215 | status = lv1_net_control(bus_id(card), dev_id(card), | 1206 | status = lv1_net_control(bus_id(card), dev_id(card), |
1216 | GELIC_NET_GET_ETH_PORT_STATUS, GELIC_NET_PORT, 0, 0, | 1207 | GELIC_LV1_GET_ETH_PORT_STATUS, |
1217 | &v1, &v2); | 1208 | GELIC_LV1_VLAN_TX_ETHERNET, 0, 0, |
1209 | &v1, &v2); | ||
1218 | if (status) | 1210 | if (status) |
1219 | return 0; /* link down */ | 1211 | return 0; /* link down */ |
1220 | 1212 | ||
1221 | if (v1 & GELIC_NET_LINK_UP) | 1213 | if (v1 & GELIC_LV1_ETHER_LINK_UP) |
1222 | link = 1; | 1214 | link = 1; |
1223 | else | 1215 | else |
1224 | link = 0; | 1216 | link = 0; |
@@ -1252,14 +1244,14 @@ static int gelic_net_set_tx_csum(struct net_device *netdev, u32 data) | |||
1252 | 1244 | ||
1253 | static u32 gelic_net_get_rx_csum(struct net_device *netdev) | 1245 | static u32 gelic_net_get_rx_csum(struct net_device *netdev) |
1254 | { | 1246 | { |
1255 | struct gelic_net_card *card = netdev_priv(netdev); | 1247 | struct gelic_card *card = netdev_priv(netdev); |
1256 | 1248 | ||
1257 | return card->rx_csum; | 1249 | return card->rx_csum; |
1258 | } | 1250 | } |
1259 | 1251 | ||
1260 | static int gelic_net_set_rx_csum(struct net_device *netdev, u32 data) | 1252 | static int gelic_net_set_rx_csum(struct net_device *netdev, u32 data) |
1261 | { | 1253 | { |
1262 | struct gelic_net_card *card = netdev_priv(netdev); | 1254 | struct gelic_card *card = netdev_priv(netdev); |
1263 | 1255 | ||
1264 | card->rx_csum = data; | 1256 | card->rx_csum = data; |
1265 | return 0; | 1257 | return 0; |
@@ -1267,8 +1259,8 @@ static int gelic_net_set_rx_csum(struct net_device *netdev, u32 data) | |||
1267 | 1259 | ||
1268 | static struct ethtool_ops gelic_net_ethtool_ops = { | 1260 | static struct ethtool_ops gelic_net_ethtool_ops = { |
1269 | .get_drvinfo = gelic_net_get_drvinfo, | 1261 | .get_drvinfo = gelic_net_get_drvinfo, |
1270 | .get_settings = gelic_net_get_settings, | 1262 | .get_settings = gelic_ether_get_settings, |
1271 | .get_link = gelic_net_get_link, | 1263 | .get_link = gelic_ether_get_link, |
1272 | .nway_reset = gelic_net_nway_reset, | 1264 | .nway_reset = gelic_net_nway_reset, |
1273 | .get_tx_csum = gelic_net_get_tx_csum, | 1265 | .get_tx_csum = gelic_net_get_tx_csum, |
1274 | .set_tx_csum = gelic_net_set_tx_csum, | 1266 | .set_tx_csum = gelic_net_set_tx_csum, |
@@ -1285,8 +1277,8 @@ static struct ethtool_ops gelic_net_ethtool_ops = { | |||
1285 | */ | 1277 | */ |
1286 | static void gelic_net_tx_timeout_task(struct work_struct *work) | 1278 | static void gelic_net_tx_timeout_task(struct work_struct *work) |
1287 | { | 1279 | { |
1288 | struct gelic_net_card *card = | 1280 | struct gelic_card *card = |
1289 | container_of(work, struct gelic_net_card, tx_timeout_task); | 1281 | container_of(work, struct gelic_card, tx_timeout_task); |
1290 | struct net_device *netdev = card->netdev; | 1282 | struct net_device *netdev = card->netdev; |
1291 | 1283 | ||
1292 | dev_info(ctodev(card), "%s:Timed out. Restarting... \n", __func__); | 1284 | dev_info(ctodev(card), "%s:Timed out. Restarting... \n", __func__); |
@@ -1312,7 +1304,7 @@ out: | |||
1312 | */ | 1304 | */ |
1313 | static void gelic_net_tx_timeout(struct net_device *netdev) | 1305 | static void gelic_net_tx_timeout(struct net_device *netdev) |
1314 | { | 1306 | { |
1315 | struct gelic_net_card *card; | 1307 | struct gelic_card *card; |
1316 | 1308 | ||
1317 | card = netdev_priv(netdev); | 1309 | card = netdev_priv(netdev); |
1318 | atomic_inc(&card->tx_timeout_task_counter); | 1310 | atomic_inc(&card->tx_timeout_task_counter); |
@@ -1323,12 +1315,12 @@ static void gelic_net_tx_timeout(struct net_device *netdev) | |||
1323 | } | 1315 | } |
1324 | 1316 | ||
1325 | /** | 1317 | /** |
1326 | * gelic_net_setup_netdev_ops - initialization of net_device operations | 1318 | * gelic_ether_setup_netdev_ops - initialization of net_device operations |
1327 | * @netdev: net_device structure | 1319 | * @netdev: net_device structure |
1328 | * | 1320 | * |
1329 | * fills out function pointers in the net_device structure | 1321 | * fills out function pointers in the net_device structure |
1330 | */ | 1322 | */ |
1331 | static void gelic_net_setup_netdev_ops(struct net_device *netdev) | 1323 | static void gelic_ether_setup_netdev_ops(struct net_device *netdev) |
1332 | { | 1324 | { |
1333 | netdev->open = &gelic_net_open; | 1325 | netdev->open = &gelic_net_open; |
1334 | netdev->stop = &gelic_net_stop; | 1326 | netdev->stop = &gelic_net_stop; |
@@ -1349,7 +1341,7 @@ static void gelic_net_setup_netdev_ops(struct net_device *netdev) | |||
1349 | * | 1341 | * |
1350 | * gelic_net_setup_netdev initializes the net_device structure | 1342 | * gelic_net_setup_netdev initializes the net_device structure |
1351 | **/ | 1343 | **/ |
1352 | static int gelic_net_setup_netdev(struct gelic_net_card *card) | 1344 | static int gelic_net_setup_netdev(struct gelic_card *card) |
1353 | { | 1345 | { |
1354 | struct net_device *netdev = card->netdev; | 1346 | struct net_device *netdev = card->netdev; |
1355 | struct sockaddr addr; | 1347 | struct sockaddr addr; |
@@ -1363,7 +1355,7 @@ static int gelic_net_setup_netdev(struct gelic_net_card *card) | |||
1363 | 1355 | ||
1364 | card->rx_csum = GELIC_NET_RX_CSUM_DEFAULT; | 1356 | card->rx_csum = GELIC_NET_RX_CSUM_DEFAULT; |
1365 | 1357 | ||
1366 | gelic_net_setup_netdev_ops(netdev); | 1358 | gelic_ether_setup_netdev_ops(netdev); |
1367 | 1359 | ||
1368 | netif_napi_add(netdev, &card->napi, | 1360 | netif_napi_add(netdev, &card->napi, |
1369 | gelic_net_poll, GELIC_NET_NAPI_WEIGHT); | 1361 | gelic_net_poll, GELIC_NET_NAPI_WEIGHT); |
@@ -1371,7 +1363,7 @@ static int gelic_net_setup_netdev(struct gelic_net_card *card) | |||
1371 | netdev->features = NETIF_F_IP_CSUM; | 1363 | netdev->features = NETIF_F_IP_CSUM; |
1372 | 1364 | ||
1373 | status = lv1_net_control(bus_id(card), dev_id(card), | 1365 | status = lv1_net_control(bus_id(card), dev_id(card), |
1374 | GELIC_NET_GET_MAC_ADDRESS, | 1366 | GELIC_LV1_GET_MAC_ADDRESS, |
1375 | 0, 0, 0, &v1, &v2); | 1367 | 0, 0, 0, &v1, &v2); |
1376 | if (status || !is_valid_ether_addr((u8 *)&v1)) { | 1368 | if (status || !is_valid_ether_addr((u8 *)&v1)) { |
1377 | dev_info(ctodev(card), | 1369 | dev_info(ctodev(card), |
@@ -1388,17 +1380,17 @@ static int gelic_net_setup_netdev(struct gelic_net_card *card) | |||
1388 | card->vlan_index = -1; /* no vlan */ | 1380 | card->vlan_index = -1; /* no vlan */ |
1389 | for (i = 0; i < GELIC_NET_VLAN_MAX; i++) { | 1381 | for (i = 0; i < GELIC_NET_VLAN_MAX; i++) { |
1390 | status = lv1_net_control(bus_id(card), dev_id(card), | 1382 | status = lv1_net_control(bus_id(card), dev_id(card), |
1391 | GELIC_NET_GET_VLAN_ID, | 1383 | GELIC_LV1_GET_VLAN_ID, |
1392 | i + 1, /* index; one based */ | 1384 | i + 1, /* index; one based */ |
1393 | 0, 0, &v1, &v2); | 1385 | 0, 0, &v1, &v2); |
1394 | if (status == GELIC_NET_VLAN_NO_ENTRY) { | 1386 | if (status == LV1_NO_ENTRY) { |
1395 | dev_dbg(ctodev(card), | 1387 | dev_dbg(ctodev(card), |
1396 | "GELIC_VLAN_ID no entry:%d, VLAN disabled\n", | 1388 | "GELIC_VLAN_ID no entry:%d, VLAN disabled\n", |
1397 | status); | 1389 | status); |
1398 | card->vlan_id[i] = 0; | 1390 | card->vlan_id[i] = 0; |
1399 | } else if (status) { | 1391 | } else if (status) { |
1400 | dev_dbg(ctodev(card), | 1392 | dev_dbg(ctodev(card), |
1401 | "%s:GELIC_NET_VLAN_ID faild, status=%d\n", | 1393 | "%s:get vlan id faild, status=%d\n", |
1402 | __func__, status); | 1394 | __func__, status); |
1403 | card->vlan_id[i] = 0; | 1395 | card->vlan_id[i] = 0; |
1404 | } else { | 1396 | } else { |
@@ -1407,8 +1399,8 @@ static int gelic_net_setup_netdev(struct gelic_net_card *card) | |||
1407 | } | 1399 | } |
1408 | } | 1400 | } |
1409 | 1401 | ||
1410 | if (card->vlan_id[GELIC_NET_VLAN_WIRED - 1]) { | 1402 | if (card->vlan_id[GELIC_LV1_VLAN_TX_ETHERNET - 1]) { |
1411 | card->vlan_index = GELIC_NET_VLAN_WIRED - 1; | 1403 | card->vlan_index = GELIC_LV1_VLAN_TX_ETHERNET - 1; |
1412 | netdev->hard_header_len += VLAN_HLEN; | 1404 | netdev->hard_header_len += VLAN_HLEN; |
1413 | } | 1405 | } |
1414 | 1406 | ||
@@ -1423,31 +1415,31 @@ static int gelic_net_setup_netdev(struct gelic_net_card *card) | |||
1423 | } | 1415 | } |
1424 | 1416 | ||
1425 | /** | 1417 | /** |
1426 | * gelic_net_alloc_card - allocates net_device and card structure | 1418 | * gelic_alloc_card_net - allocates net_device and card structure |
1427 | * | 1419 | * |
1428 | * returns the card structure or NULL in case of errors | 1420 | * returns the card structure or NULL in case of errors |
1429 | * | 1421 | * |
1430 | * the card and net_device structures are linked to each other | 1422 | * the card and net_device structures are linked to each other |
1431 | */ | 1423 | */ |
1432 | static struct gelic_net_card *gelic_net_alloc_card(void) | 1424 | static struct gelic_card *gelic_alloc_card_net(void) |
1433 | { | 1425 | { |
1434 | struct net_device *netdev; | 1426 | struct net_device *netdev; |
1435 | struct gelic_net_card *card; | 1427 | struct gelic_card *card; |
1436 | size_t alloc_size; | 1428 | size_t alloc_size; |
1437 | 1429 | ||
1438 | alloc_size = sizeof (*card) + | 1430 | alloc_size = sizeof(*card) + |
1439 | sizeof (struct gelic_net_descr) * GELIC_NET_RX_DESCRIPTORS + | 1431 | sizeof(struct gelic_descr) * GELIC_NET_RX_DESCRIPTORS + |
1440 | sizeof (struct gelic_net_descr) * GELIC_NET_TX_DESCRIPTORS; | 1432 | sizeof(struct gelic_descr) * GELIC_NET_TX_DESCRIPTORS; |
1441 | /* | 1433 | /* |
1442 | * we assume private data is allocated 32 bytes (or more) aligned | 1434 | * we assume private data is allocated 32 bytes (or more) aligned |
1443 | * so that gelic_net_descr should be 32 bytes aligned. | 1435 | * so that gelic_descr should be 32 bytes aligned. |
1444 | * Current alloc_etherdev() does do it because NETDEV_ALIGN | 1436 | * Current alloc_etherdev() does do it because NETDEV_ALIGN |
1445 | * is 32. | 1437 | * is 32. |
1446 | * check this assumption here. | 1438 | * check this assumption here. |
1447 | */ | 1439 | */ |
1448 | BUILD_BUG_ON(NETDEV_ALIGN < 32); | 1440 | BUILD_BUG_ON(NETDEV_ALIGN < 32); |
1449 | BUILD_BUG_ON(offsetof(struct gelic_net_card, irq_status) % 8); | 1441 | BUILD_BUG_ON(offsetof(struct gelic_card, irq_status) % 8); |
1450 | BUILD_BUG_ON(offsetof(struct gelic_net_card, descr) % 32); | 1442 | BUILD_BUG_ON(offsetof(struct gelic_card, descr) % 32); |
1451 | 1443 | ||
1452 | netdev = alloc_etherdev(alloc_size); | 1444 | netdev = alloc_etherdev(alloc_size); |
1453 | if (!netdev) | 1445 | if (!netdev) |
@@ -1465,9 +1457,9 @@ static struct gelic_net_card *gelic_net_alloc_card(void) | |||
1465 | /** | 1457 | /** |
1466 | * ps3_gelic_driver_probe - add a device to the control of this driver | 1458 | * ps3_gelic_driver_probe - add a device to the control of this driver |
1467 | */ | 1459 | */ |
1468 | static int ps3_gelic_driver_probe (struct ps3_system_bus_device *dev) | 1460 | static int ps3_gelic_driver_probe(struct ps3_system_bus_device *dev) |
1469 | { | 1461 | { |
1470 | struct gelic_net_card *card = gelic_net_alloc_card(); | 1462 | struct gelic_card *card = gelic_alloc_card_net(); |
1471 | int result; | 1463 | int result; |
1472 | 1464 | ||
1473 | if (!card) { | 1465 | if (!card) { |
@@ -1537,9 +1529,9 @@ fail_alloc_card: | |||
1537 | * ps3_gelic_driver_remove - remove a device from the control of this driver | 1529 | * ps3_gelic_driver_remove - remove a device from the control of this driver |
1538 | */ | 1530 | */ |
1539 | 1531 | ||
1540 | static int ps3_gelic_driver_remove (struct ps3_system_bus_device *dev) | 1532 | static int ps3_gelic_driver_remove(struct ps3_system_bus_device *dev) |
1541 | { | 1533 | { |
1542 | struct gelic_net_card *card = ps3_system_bus_get_driver_data(dev); | 1534 | struct gelic_card *card = ps3_system_bus_get_driver_data(dev); |
1543 | 1535 | ||
1544 | wait_event(card->waitq, | 1536 | wait_event(card->waitq, |
1545 | atomic_read(&card->tx_timeout_task_counter) == 0); | 1537 | atomic_read(&card->tx_timeout_task_counter) == 0); |
@@ -1580,8 +1572,8 @@ static void __exit ps3_gelic_driver_exit (void) | |||
1580 | ps3_system_bus_driver_unregister(&ps3_gelic_driver); | 1572 | ps3_system_bus_driver_unregister(&ps3_gelic_driver); |
1581 | } | 1573 | } |
1582 | 1574 | ||
1583 | module_init (ps3_gelic_driver_init); | 1575 | module_init(ps3_gelic_driver_init); |
1584 | module_exit (ps3_gelic_driver_exit); | 1576 | module_exit(ps3_gelic_driver_exit); |
1585 | 1577 | ||
1586 | MODULE_ALIAS(PS3_MODULE_ALIAS_GELIC); | 1578 | MODULE_ALIAS(PS3_MODULE_ALIAS_GELIC); |
1587 | 1579 | ||