diff options
author | Jie Yang <jie.yang@atheros.com> | 2009-12-06 17:56:59 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-08 23:48:06 -0500 |
commit | 4b45e3424e7210688f95039b8cdffb11d2e48934 (patch) | |
tree | bb9327eb5a537815dbfd1c8f1e9657095584bbf8 /drivers/net/atl1c | |
parent | b38310e99ed09163062902285edd6d7b3fc136d6 (diff) |
atl1c:add pci map direction in atl1c_buffer flags
add pci map direction in atl1c_buffer flags, it is used when call pci_unmap
apis.
Signed-off-by: Jie Yang <jie.yang@atheros.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/atl1c')
-rw-r--r-- | drivers/net/atl1c/atl1c.h | 11 | ||||
-rw-r--r-- | drivers/net/atl1c/atl1c_main.c | 22 |
2 files changed, 24 insertions, 9 deletions
diff --git a/drivers/net/atl1c/atl1c.h b/drivers/net/atl1c/atl1c.h index a348a22551d9..7e09084f75a9 100644 --- a/drivers/net/atl1c/atl1c.h +++ b/drivers/net/atl1c/atl1c.h | |||
@@ -479,6 +479,9 @@ struct atl1c_buffer { | |||
479 | #define ATL1C_PCIMAP_PAGE 0x0008 | 479 | #define ATL1C_PCIMAP_PAGE 0x0008 |
480 | #define ATL1C_PCIMAP_TYPE_MASK 0x000C | 480 | #define ATL1C_PCIMAP_TYPE_MASK 0x000C |
481 | 481 | ||
482 | #define ATL1C_PCIMAP_TODEVICE 0x0010 | ||
483 | #define ATL1C_PCIMAP_FROMDEVICE 0x0020 | ||
484 | #define ATL1C_PCIMAP_DIRECTION_MASK 0x0030 | ||
482 | dma_addr_t dma; | 485 | dma_addr_t dma; |
483 | }; | 486 | }; |
484 | 487 | ||
@@ -487,9 +490,11 @@ struct atl1c_buffer { | |||
487 | ((buff)->flags) |= (state); \ | 490 | ((buff)->flags) |= (state); \ |
488 | } while (0) | 491 | } while (0) |
489 | 492 | ||
490 | #define ATL1C_SET_PCIMAP_TYPE(buff, type) do { \ | 493 | #define ATL1C_SET_PCIMAP_TYPE(buff, type, direction) do { \ |
491 | ((buff)->flags) &= ~ATL1C_PCIMAP_TYPE_MASK; \ | 494 | ((buff)->flags) &= ~ATL1C_PCIMAP_TYPE_MASK; \ |
492 | ((buff)->flags) |= (type); \ | 495 | ((buff)->flags) |= (type); \ |
496 | ((buff)->flags) &= ~ATL1C_PCIMAP_DIRECTION_MASK; \ | ||
497 | ((buff)->flags) |= (direction); \ | ||
493 | } while (0) | 498 | } while (0) |
494 | 499 | ||
495 | /* transimit packet descriptor (tpd) ring */ | 500 | /* transimit packet descriptor (tpd) ring */ |
diff --git a/drivers/net/atl1c/atl1c_main.c b/drivers/net/atl1c/atl1c_main.c index 1e2f57d4c367..1098dad3d381 100644 --- a/drivers/net/atl1c/atl1c_main.c +++ b/drivers/net/atl1c/atl1c_main.c | |||
@@ -713,15 +713,21 @@ static int __devinit atl1c_sw_init(struct atl1c_adapter *adapter) | |||
713 | static inline void atl1c_clean_buffer(struct pci_dev *pdev, | 713 | static inline void atl1c_clean_buffer(struct pci_dev *pdev, |
714 | struct atl1c_buffer *buffer_info, int in_irq) | 714 | struct atl1c_buffer *buffer_info, int in_irq) |
715 | { | 715 | { |
716 | u16 pci_driection; | ||
716 | if (buffer_info->flags & ATL1C_BUFFER_FREE) | 717 | if (buffer_info->flags & ATL1C_BUFFER_FREE) |
717 | return; | 718 | return; |
718 | if (buffer_info->dma) { | 719 | if (buffer_info->dma) { |
720 | if (buffer_info->flags & ATL1C_PCIMAP_FROMDEVICE) | ||
721 | pci_driection = PCI_DMA_FROMDEVICE; | ||
722 | else | ||
723 | pci_driection = PCI_DMA_TODEVICE; | ||
724 | |||
719 | if (buffer_info->flags & ATL1C_PCIMAP_SINGLE) | 725 | if (buffer_info->flags & ATL1C_PCIMAP_SINGLE) |
720 | pci_unmap_single(pdev, buffer_info->dma, | 726 | pci_unmap_single(pdev, buffer_info->dma, |
721 | buffer_info->length, PCI_DMA_TODEVICE); | 727 | buffer_info->length, pci_driection); |
722 | else if (buffer_info->flags & ATL1C_PCIMAP_PAGE) | 728 | else if (buffer_info->flags & ATL1C_PCIMAP_PAGE) |
723 | pci_unmap_page(pdev, buffer_info->dma, | 729 | pci_unmap_page(pdev, buffer_info->dma, |
724 | buffer_info->length, PCI_DMA_TODEVICE); | 730 | buffer_info->length, pci_driection); |
725 | } | 731 | } |
726 | if (buffer_info->skb) { | 732 | if (buffer_info->skb) { |
727 | if (in_irq) | 733 | if (in_irq) |
@@ -1606,7 +1612,8 @@ static int atl1c_alloc_rx_buffer(struct atl1c_adapter *adapter, const int ringid | |||
1606 | buffer_info->dma = pci_map_single(pdev, vir_addr, | 1612 | buffer_info->dma = pci_map_single(pdev, vir_addr, |
1607 | buffer_info->length, | 1613 | buffer_info->length, |
1608 | PCI_DMA_FROMDEVICE); | 1614 | PCI_DMA_FROMDEVICE); |
1609 | ATL1C_SET_PCIMAP_TYPE(buffer_info, ATL1C_PCIMAP_SINGLE); | 1615 | ATL1C_SET_PCIMAP_TYPE(buffer_info, ATL1C_PCIMAP_SINGLE, |
1616 | ATL1C_PCIMAP_FROMDEVICE); | ||
1610 | rfd_desc->buffer_addr = cpu_to_le64(buffer_info->dma); | 1617 | rfd_desc->buffer_addr = cpu_to_le64(buffer_info->dma); |
1611 | rfd_next_to_use = next_next; | 1618 | rfd_next_to_use = next_next; |
1612 | if (++next_next == rfd_ring->count) | 1619 | if (++next_next == rfd_ring->count) |
@@ -1967,7 +1974,8 @@ static void atl1c_tx_map(struct atl1c_adapter *adapter, | |||
1967 | buffer_info->dma = pci_map_single(adapter->pdev, | 1974 | buffer_info->dma = pci_map_single(adapter->pdev, |
1968 | skb->data, hdr_len, PCI_DMA_TODEVICE); | 1975 | skb->data, hdr_len, PCI_DMA_TODEVICE); |
1969 | ATL1C_SET_BUFFER_STATE(buffer_info, ATL1C_BUFFER_BUSY); | 1976 | ATL1C_SET_BUFFER_STATE(buffer_info, ATL1C_BUFFER_BUSY); |
1970 | ATL1C_SET_PCIMAP_TYPE(buffer_info, ATL1C_PCIMAP_SINGLE); | 1977 | ATL1C_SET_PCIMAP_TYPE(buffer_info, ATL1C_PCIMAP_SINGLE, |
1978 | ATL1C_PCIMAP_TODEVICE); | ||
1971 | mapped_len += map_len; | 1979 | mapped_len += map_len; |
1972 | use_tpd->buffer_addr = cpu_to_le64(buffer_info->dma); | 1980 | use_tpd->buffer_addr = cpu_to_le64(buffer_info->dma); |
1973 | use_tpd->buffer_len = cpu_to_le16(buffer_info->length); | 1981 | use_tpd->buffer_len = cpu_to_le16(buffer_info->length); |
@@ -1988,7 +1996,8 @@ static void atl1c_tx_map(struct atl1c_adapter *adapter, | |||
1988 | pci_map_single(adapter->pdev, skb->data + mapped_len, | 1996 | pci_map_single(adapter->pdev, skb->data + mapped_len, |
1989 | buffer_info->length, PCI_DMA_TODEVICE); | 1997 | buffer_info->length, PCI_DMA_TODEVICE); |
1990 | ATL1C_SET_BUFFER_STATE(buffer_info, ATL1C_BUFFER_BUSY); | 1998 | ATL1C_SET_BUFFER_STATE(buffer_info, ATL1C_BUFFER_BUSY); |
1991 | ATL1C_SET_PCIMAP_TYPE(buffer_info, ATL1C_PCIMAP_SINGLE); | 1999 | ATL1C_SET_PCIMAP_TYPE(buffer_info, ATL1C_PCIMAP_SINGLE, |
2000 | ATL1C_PCIMAP_TODEVICE); | ||
1992 | use_tpd->buffer_addr = cpu_to_le64(buffer_info->dma); | 2001 | use_tpd->buffer_addr = cpu_to_le64(buffer_info->dma); |
1993 | use_tpd->buffer_len = cpu_to_le16(buffer_info->length); | 2002 | use_tpd->buffer_len = cpu_to_le16(buffer_info->length); |
1994 | } | 2003 | } |
@@ -2009,7 +2018,8 @@ static void atl1c_tx_map(struct atl1c_adapter *adapter, | |||
2009 | buffer_info->length, | 2018 | buffer_info->length, |
2010 | PCI_DMA_TODEVICE); | 2019 | PCI_DMA_TODEVICE); |
2011 | ATL1C_SET_BUFFER_STATE(buffer_info, ATL1C_BUFFER_BUSY); | 2020 | ATL1C_SET_BUFFER_STATE(buffer_info, ATL1C_BUFFER_BUSY); |
2012 | ATL1C_SET_PCIMAP_TYPE(buffer_info, ATL1C_PCIMAP_PAGE); | 2021 | ATL1C_SET_PCIMAP_TYPE(buffer_info, ATL1C_PCIMAP_PAGE, |
2022 | ATL1C_PCIMAP_TODEVICE); | ||
2013 | use_tpd->buffer_addr = cpu_to_le64(buffer_info->dma); | 2023 | use_tpd->buffer_addr = cpu_to_le64(buffer_info->dma); |
2014 | use_tpd->buffer_len = cpu_to_le16(buffer_info->length); | 2024 | use_tpd->buffer_len = cpu_to_le16(buffer_info->length); |
2015 | } | 2025 | } |