@@ -317,15 +317,17 @@ static int gelic_card_init_chain(struct gelic_card *card,
317
317
318
318
/* set up the hardware pointers in each descriptor */
319
319
for (i = 0 ; i < no ; i ++ , descr ++ ) {
320
+ dma_addr_t cpu_addr ;
321
+
320
322
gelic_descr_set_status (descr , GELIC_DESCR_DMA_NOT_IN_USE );
321
- descr -> bus_addr =
322
- dma_map_single (ctodev (card ), descr ,
323
- GELIC_DESCR_SIZE ,
324
- DMA_BIDIRECTIONAL );
325
323
326
- if (!descr -> bus_addr )
324
+ cpu_addr = dma_map_single (ctodev (card ), descr ,
325
+ GELIC_DESCR_SIZE , DMA_BIDIRECTIONAL );
326
+
327
+ if (dma_mapping_error (ctodev (card ), cpu_addr ))
327
328
goto iommu_error ;
328
329
330
+ descr -> bus_addr = cpu_to_be32 (cpu_addr );
329
331
descr -> next = descr + 1 ;
330
332
descr -> prev = descr - 1 ;
331
333
}
@@ -365,26 +367,28 @@ static int gelic_card_init_chain(struct gelic_card *card,
365
367
*
366
368
* allocates a new rx skb, iommu-maps it and attaches it to the descriptor.
367
369
* Activate the descriptor state-wise
370
+ *
371
+ * Gelic RX sk_buffs must be aligned to GELIC_NET_RXBUF_ALIGN and the length
372
+ * must be a multiple of GELIC_NET_RXBUF_ALIGN.
368
373
*/
369
374
static int gelic_descr_prepare_rx (struct gelic_card * card ,
370
375
struct gelic_descr * descr )
371
376
{
377
+ static const unsigned int rx_skb_size =
378
+ ALIGN (GELIC_NET_MAX_FRAME , GELIC_NET_RXBUF_ALIGN ) +
379
+ GELIC_NET_RXBUF_ALIGN - 1 ;
380
+ dma_addr_t cpu_addr ;
372
381
int offset ;
373
- unsigned int bufsize ;
374
382
375
383
if (gelic_descr_get_status (descr ) != GELIC_DESCR_DMA_NOT_IN_USE )
376
384
dev_info (ctodev (card ), "%s: ERROR status\n" , __func__ );
377
- /* we need to round up the buffer size to a multiple of 128 */
378
- bufsize = ALIGN (GELIC_NET_MAX_MTU , GELIC_NET_RXBUF_ALIGN );
379
385
380
- /* and we need to have it 128 byte aligned, therefore we allocate a
381
- * bit more */
382
- descr -> skb = dev_alloc_skb (bufsize + GELIC_NET_RXBUF_ALIGN - 1 );
386
+ descr -> skb = netdev_alloc_skb (* card -> netdev , rx_skb_size );
383
387
if (!descr -> skb ) {
384
388
descr -> buf_addr = 0 ; /* tell DMAC don't touch memory */
385
389
return - ENOMEM ;
386
390
}
387
- descr -> buf_size = cpu_to_be32 (bufsize );
391
+ descr -> buf_size = cpu_to_be32 (rx_skb_size );
388
392
descr -> dmac_cmd_status = 0 ;
389
393
descr -> result_size = 0 ;
390
394
descr -> valid_size = 0 ;
@@ -395,11 +399,10 @@ static int gelic_descr_prepare_rx(struct gelic_card *card,
395
399
if (offset )
396
400
skb_reserve (descr -> skb , GELIC_NET_RXBUF_ALIGN - offset );
397
401
/* io-mmu-map the skb */
398
- descr -> buf_addr = cpu_to_be32 (dma_map_single (ctodev (card ),
399
- descr -> skb -> data ,
400
- GELIC_NET_MAX_MTU ,
401
- DMA_FROM_DEVICE ));
402
- if (!descr -> buf_addr ) {
402
+ cpu_addr = dma_map_single (ctodev (card ), descr -> skb -> data ,
403
+ GELIC_NET_MAX_FRAME , DMA_FROM_DEVICE );
404
+ descr -> buf_addr = cpu_to_be32 (cpu_addr );
405
+ if (dma_mapping_error (ctodev (card ), cpu_addr )) {
403
406
dev_kfree_skb_any (descr -> skb );
404
407
descr -> skb = NULL ;
405
408
dev_info (ctodev (card ),
@@ -779,7 +782,7 @@ static int gelic_descr_prepare_tx(struct gelic_card *card,
779
782
780
783
buf = dma_map_single (ctodev (card ), skb -> data , skb -> len , DMA_TO_DEVICE );
781
784
782
- if (! buf ) {
785
+ if (dma_mapping_error ( ctodev ( card ), buf ) ) {
783
786
dev_err (ctodev (card ),
784
787
"dma map 2 failed (%p, %i). Dropping packet\n" ,
785
788
skb -> data , skb -> len );
@@ -915,7 +918,7 @@ static void gelic_net_pass_skb_up(struct gelic_descr *descr,
915
918
data_error = be32_to_cpu (descr -> data_error );
916
919
/* unmap skb buffer */
917
920
dma_unmap_single (ctodev (card ), be32_to_cpu (descr -> buf_addr ),
918
- GELIC_NET_MAX_MTU ,
921
+ GELIC_NET_MAX_FRAME ,
919
922
DMA_FROM_DEVICE );
920
923
921
924
skb_put (skb , be32_to_cpu (descr -> valid_size )?
0 commit comments