diff options
author | Avinash Patil <patila@marvell.com> | 2013-02-08 21:18:08 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2013-02-11 15:34:57 -0500 |
commit | e05dc3e93c136ecd329ed2d57d4eb2e82f530304 (patch) | |
tree | dd1fca715955c8670939780871d1aa398222882d /drivers/net/wireless | |
parent | 0732484b47b57ef90bb08408d60fddbad0262d82 (diff) |
mwifiex: define generic data type for PCIe ring buffers
This patch defines PCIe ring buffer array pointer as void instead
of mwifiex_pcie_buf_desc. This will enable us to use same pointers
for ring operations instead of new structures if buffer descriptor
structure changes.
Also split out event buffer descriptor structure from struct
mwifiex_pcie_buf_desc. For PCIe8766 TX/RX buffer descriptor is
same as evevt buffer descriptor. Newer chips could use different
TX/RX buffer descriptor while event descriptor remains the same.
Signed-off-by: Avinash Patil <patila@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/mwifiex/pcie.c | 49 | ||||
-rw-r--r-- | drivers/net/wireless/mwifiex/pcie.h | 12 |
2 files changed, 35 insertions, 26 deletions
diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c index 06aae55485e5..6c15969efd55 100644 --- a/drivers/net/wireless/mwifiex/pcie.c +++ b/drivers/net/wireless/mwifiex/pcie.c | |||
@@ -444,7 +444,7 @@ static int mwifiex_init_rxq_ring(struct mwifiex_adapter *adapter) | |||
444 | static int mwifiex_pcie_init_evt_ring(struct mwifiex_adapter *adapter) | 444 | static int mwifiex_pcie_init_evt_ring(struct mwifiex_adapter *adapter) |
445 | { | 445 | { |
446 | struct pcie_service_card *card = adapter->card; | 446 | struct pcie_service_card *card = adapter->card; |
447 | struct mwifiex_pcie_buf_desc *desc; | 447 | struct mwifiex_evt_buf_desc *desc; |
448 | struct sk_buff *skb; | 448 | struct sk_buff *skb; |
449 | dma_addr_t buf_pa; | 449 | dma_addr_t buf_pa; |
450 | int i; | 450 | int i; |
@@ -474,7 +474,6 @@ static int mwifiex_pcie_init_evt_ring(struct mwifiex_adapter *adapter) | |||
474 | card->evt_buf_list[i] = skb; | 474 | card->evt_buf_list[i] = skb; |
475 | card->evtbd_ring[i] = (void *)(card->evtbd_ring_vbase + | 475 | card->evtbd_ring[i] = (void *)(card->evtbd_ring_vbase + |
476 | (sizeof(*desc) * i)); | 476 | (sizeof(*desc) * i)); |
477 | |||
478 | desc = card->evtbd_ring[i]; | 477 | desc = card->evtbd_ring[i]; |
479 | desc->paddr = buf_pa; | 478 | desc->paddr = buf_pa; |
480 | desc->len = (u16)skb->len; | 479 | desc->len = (u16)skb->len; |
@@ -540,7 +539,7 @@ static void mwifiex_cleanup_rxq_ring(struct mwifiex_adapter *adapter) | |||
540 | static void mwifiex_cleanup_evt_ring(struct mwifiex_adapter *adapter) | 539 | static void mwifiex_cleanup_evt_ring(struct mwifiex_adapter *adapter) |
541 | { | 540 | { |
542 | struct pcie_service_card *card = adapter->card; | 541 | struct pcie_service_card *card = adapter->card; |
543 | struct mwifiex_pcie_buf_desc *desc; | 542 | struct mwifiex_evt_buf_desc *desc; |
544 | struct sk_buff *skb; | 543 | struct sk_buff *skb; |
545 | int i; | 544 | int i; |
546 | 545 | ||
@@ -695,7 +694,7 @@ static int mwifiex_pcie_create_evtbd_ring(struct mwifiex_adapter *adapter) | |||
695 | card->evtbd_wrptr = 0; | 694 | card->evtbd_wrptr = 0; |
696 | card->evtbd_rdptr = reg->evt_rollover_ind; | 695 | card->evtbd_rdptr = reg->evt_rollover_ind; |
697 | 696 | ||
698 | card->evtbd_ring_size = sizeof(struct mwifiex_pcie_buf_desc) * | 697 | card->evtbd_ring_size = sizeof(struct mwifiex_evt_buf_desc) * |
699 | MWIFIEX_MAX_EVT_BD; | 698 | MWIFIEX_MAX_EVT_BD; |
700 | dev_dbg(adapter->dev, "info: evtbd_ring: Allocating %d bytes\n", | 699 | dev_dbg(adapter->dev, "info: evtbd_ring: Allocating %d bytes\n", |
701 | card->evtbd_ring_size); | 700 | card->evtbd_ring_size); |
@@ -880,6 +879,7 @@ static int mwifiex_pcie_send_data_complete(struct mwifiex_adapter *adapter) | |||
880 | struct sk_buff *skb; | 879 | struct sk_buff *skb; |
881 | dma_addr_t buf_pa; | 880 | dma_addr_t buf_pa; |
882 | u32 wrdoneidx, rdptr, unmap_count = 0; | 881 | u32 wrdoneidx, rdptr, unmap_count = 0; |
882 | struct mwifiex_pcie_buf_desc *desc; | ||
883 | struct pcie_service_card *card = adapter->card; | 883 | struct pcie_service_card *card = adapter->card; |
884 | const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; | 884 | const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; |
885 | 885 | ||
@@ -922,9 +922,8 @@ static int mwifiex_pcie_send_data_complete(struct mwifiex_adapter *adapter) | |||
922 | } | 922 | } |
923 | 923 | ||
924 | card->tx_buf_list[wrdoneidx] = NULL; | 924 | card->tx_buf_list[wrdoneidx] = NULL; |
925 | card->txbd_ring[wrdoneidx]->paddr = 0; | 925 | desc = card->txbd_ring[wrdoneidx]; |
926 | card->txbd_ring[wrdoneidx]->len = 0; | 926 | memset(desc, 0, sizeof(*desc)); |
927 | card->txbd_ring[wrdoneidx]->flags = 0; | ||
928 | card->txbd_rdptr++; | 927 | card->txbd_rdptr++; |
929 | 928 | ||
930 | if ((card->txbd_rdptr & reg->tx_mask) == num_tx_buffs) | 929 | if ((card->txbd_rdptr & reg->tx_mask) == num_tx_buffs) |
@@ -964,6 +963,7 @@ mwifiex_pcie_send_data(struct mwifiex_adapter *adapter, struct sk_buff *skb, | |||
964 | u32 wrindx; | 963 | u32 wrindx; |
965 | int ret; | 964 | int ret; |
966 | dma_addr_t buf_pa; | 965 | dma_addr_t buf_pa; |
966 | struct mwifiex_pcie_buf_desc *desc; | ||
967 | __le16 *tmp; | 967 | __le16 *tmp; |
968 | 968 | ||
969 | if (!(skb->data && skb->len)) { | 969 | if (!(skb->data && skb->len)) { |
@@ -994,10 +994,11 @@ mwifiex_pcie_send_data(struct mwifiex_adapter *adapter, struct sk_buff *skb, | |||
994 | wrindx = card->txbd_wrptr & reg->tx_mask; | 994 | wrindx = card->txbd_wrptr & reg->tx_mask; |
995 | MWIFIEX_SKB_PACB(skb, &buf_pa); | 995 | MWIFIEX_SKB_PACB(skb, &buf_pa); |
996 | card->tx_buf_list[wrindx] = skb; | 996 | card->tx_buf_list[wrindx] = skb; |
997 | card->txbd_ring[wrindx]->paddr = buf_pa; | 997 | desc = card->txbd_ring[wrindx]; |
998 | card->txbd_ring[wrindx]->len = (u16)skb->len; | 998 | desc->paddr = buf_pa; |
999 | card->txbd_ring[wrindx]->flags = MWIFIEX_BD_FLAG_FIRST_DESC | | 999 | desc->len = (u16)skb->len; |
1000 | MWIFIEX_BD_FLAG_LAST_DESC; | 1000 | desc->flags = MWIFIEX_BD_FLAG_FIRST_DESC | |
1001 | MWIFIEX_BD_FLAG_LAST_DESC; | ||
1001 | 1002 | ||
1002 | if ((++card->txbd_wrptr & reg->tx_mask) == | 1003 | if ((++card->txbd_wrptr & reg->tx_mask) == |
1003 | MWIFIEX_MAX_TXRX_BD) | 1004 | MWIFIEX_MAX_TXRX_BD) |
@@ -1049,9 +1050,7 @@ done_unmap: | |||
1049 | MWIFIEX_SKB_PACB(skb, &buf_pa); | 1050 | MWIFIEX_SKB_PACB(skb, &buf_pa); |
1050 | pci_unmap_single(card->dev, buf_pa, skb->len, PCI_DMA_TODEVICE); | 1051 | pci_unmap_single(card->dev, buf_pa, skb->len, PCI_DMA_TODEVICE); |
1051 | card->tx_buf_list[wrindx] = NULL; | 1052 | card->tx_buf_list[wrindx] = NULL; |
1052 | card->txbd_ring[wrindx]->paddr = 0; | 1053 | memset(desc, 0, sizeof(*desc)); |
1053 | card->txbd_ring[wrindx]->len = 0; | ||
1054 | card->txbd_ring[wrindx]->flags = 0; | ||
1055 | return ret; | 1054 | return ret; |
1056 | } | 1055 | } |
1057 | 1056 | ||
@@ -1067,6 +1066,7 @@ static int mwifiex_pcie_process_recv_data(struct mwifiex_adapter *adapter) | |||
1067 | dma_addr_t buf_pa; | 1066 | dma_addr_t buf_pa; |
1068 | int ret = 0; | 1067 | int ret = 0; |
1069 | struct sk_buff *skb_tmp = NULL; | 1068 | struct sk_buff *skb_tmp = NULL; |
1069 | struct mwifiex_pcie_buf_desc *desc; | ||
1070 | 1070 | ||
1071 | if (!mwifiex_pcie_ok_to_access_hw(adapter)) | 1071 | if (!mwifiex_pcie_ok_to_access_hw(adapter)) |
1072 | mwifiex_pm_wakeup_card(adapter); | 1072 | mwifiex_pm_wakeup_card(adapter); |
@@ -1126,9 +1126,10 @@ static int mwifiex_pcie_process_recv_data(struct mwifiex_adapter *adapter) | |||
1126 | "RECV DATA: Attach new sk_buff %p at rxbd_rdidx=%d\n", | 1126 | "RECV DATA: Attach new sk_buff %p at rxbd_rdidx=%d\n", |
1127 | skb_tmp, rd_index); | 1127 | skb_tmp, rd_index); |
1128 | card->rx_buf_list[rd_index] = skb_tmp; | 1128 | card->rx_buf_list[rd_index] = skb_tmp; |
1129 | card->rxbd_ring[rd_index]->paddr = buf_pa; | 1129 | desc = card->rxbd_ring[rd_index]; |
1130 | card->rxbd_ring[rd_index]->len = skb_tmp->len; | 1130 | desc->paddr = buf_pa; |
1131 | card->rxbd_ring[rd_index]->flags = 0; | 1131 | desc->len = skb_tmp->len; |
1132 | desc->flags = 0; | ||
1132 | 1133 | ||
1133 | if ((++card->rxbd_rdptr & reg->rx_mask) == | 1134 | if ((++card->rxbd_rdptr & reg->rx_mask) == |
1134 | MWIFIEX_MAX_TXRX_BD) { | 1135 | MWIFIEX_MAX_TXRX_BD) { |
@@ -1471,6 +1472,7 @@ static int mwifiex_pcie_process_event_ready(struct mwifiex_adapter *adapter) | |||
1471 | u32 rdptr = card->evtbd_rdptr & MWIFIEX_EVTBD_MASK; | 1472 | u32 rdptr = card->evtbd_rdptr & MWIFIEX_EVTBD_MASK; |
1472 | u32 wrptr, event; | 1473 | u32 wrptr, event; |
1473 | dma_addr_t buf_pa; | 1474 | dma_addr_t buf_pa; |
1475 | struct mwifiex_evt_buf_desc *desc; | ||
1474 | 1476 | ||
1475 | if (!mwifiex_pcie_ok_to_access_hw(adapter)) | 1477 | if (!mwifiex_pcie_ok_to_access_hw(adapter)) |
1476 | mwifiex_pm_wakeup_card(adapter); | 1478 | mwifiex_pm_wakeup_card(adapter); |
@@ -1512,9 +1514,8 @@ static int mwifiex_pcie_process_event_ready(struct mwifiex_adapter *adapter) | |||
1512 | /* Take the pointer and set it to event pointer in adapter | 1514 | /* Take the pointer and set it to event pointer in adapter |
1513 | and will return back after event handling callback */ | 1515 | and will return back after event handling callback */ |
1514 | card->evt_buf_list[rdptr] = NULL; | 1516 | card->evt_buf_list[rdptr] = NULL; |
1515 | card->evtbd_ring[rdptr]->paddr = 0; | 1517 | desc = card->evtbd_ring[rdptr]; |
1516 | card->evtbd_ring[rdptr]->len = 0; | 1518 | memset(desc, 0, sizeof(*desc)); |
1517 | card->evtbd_ring[rdptr]->flags = 0; | ||
1518 | 1519 | ||
1519 | event = *(u32 *) &skb_cmd->data[INTF_HEADER_LEN]; | 1520 | event = *(u32 *) &skb_cmd->data[INTF_HEADER_LEN]; |
1520 | adapter->event_cause = event; | 1521 | adapter->event_cause = event; |
@@ -1555,6 +1556,7 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter, | |||
1555 | u32 rdptr = card->evtbd_rdptr & MWIFIEX_EVTBD_MASK; | 1556 | u32 rdptr = card->evtbd_rdptr & MWIFIEX_EVTBD_MASK; |
1556 | u32 wrptr; | 1557 | u32 wrptr; |
1557 | dma_addr_t buf_pa; | 1558 | dma_addr_t buf_pa; |
1559 | struct mwifiex_evt_buf_desc *desc; | ||
1558 | 1560 | ||
1559 | if (!skb) | 1561 | if (!skb) |
1560 | return 0; | 1562 | return 0; |
@@ -1581,9 +1583,10 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter, | |||
1581 | MWIFIEX_SKB_PACB(skb, &buf_pa); | 1583 | MWIFIEX_SKB_PACB(skb, &buf_pa); |
1582 | card->evt_buf_list[rdptr] = skb; | 1584 | card->evt_buf_list[rdptr] = skb; |
1583 | MWIFIEX_SKB_PACB(skb, &buf_pa); | 1585 | MWIFIEX_SKB_PACB(skb, &buf_pa); |
1584 | card->evtbd_ring[rdptr]->paddr = buf_pa; | 1586 | desc = card->evtbd_ring[rdptr]; |
1585 | card->evtbd_ring[rdptr]->len = (u16)skb->len; | 1587 | desc->paddr = buf_pa; |
1586 | card->evtbd_ring[rdptr]->flags = 0; | 1588 | desc->len = (u16)skb->len; |
1589 | desc->flags = 0; | ||
1587 | skb = NULL; | 1590 | skb = NULL; |
1588 | } else { | 1591 | } else { |
1589 | dev_dbg(adapter->dev, | 1592 | dev_dbg(adapter->dev, |
diff --git a/drivers/net/wireless/mwifiex/pcie.h b/drivers/net/wireless/mwifiex/pcie.h index 7ef660ec058e..7ebdc74f2bbf 100644 --- a/drivers/net/wireless/mwifiex/pcie.h +++ b/drivers/net/wireless/mwifiex/pcie.h | |||
@@ -155,6 +155,12 @@ static const struct mwifiex_pcie_device mwifiex_pcie8766 = { | |||
155 | .blksz_fw_dl = MWIFIEX_PCIE_BLOCK_SIZE_FW_DNLD, | 155 | .blksz_fw_dl = MWIFIEX_PCIE_BLOCK_SIZE_FW_DNLD, |
156 | }; | 156 | }; |
157 | 157 | ||
158 | struct mwifiex_evt_buf_desc { | ||
159 | u64 paddr; | ||
160 | u16 len; | ||
161 | u16 flags; | ||
162 | } __packed; | ||
163 | |||
158 | struct mwifiex_pcie_buf_desc { | 164 | struct mwifiex_pcie_buf_desc { |
159 | u64 paddr; | 165 | u64 paddr; |
160 | u16 len; | 166 | u16 len; |
@@ -172,7 +178,7 @@ struct pcie_service_card { | |||
172 | u32 txbd_ring_size; | 178 | u32 txbd_ring_size; |
173 | u8 *txbd_ring_vbase; | 179 | u8 *txbd_ring_vbase; |
174 | dma_addr_t txbd_ring_pbase; | 180 | dma_addr_t txbd_ring_pbase; |
175 | struct mwifiex_pcie_buf_desc *txbd_ring[MWIFIEX_MAX_TXRX_BD]; | 181 | void *txbd_ring[MWIFIEX_MAX_TXRX_BD]; |
176 | struct sk_buff *tx_buf_list[MWIFIEX_MAX_TXRX_BD]; | 182 | struct sk_buff *tx_buf_list[MWIFIEX_MAX_TXRX_BD]; |
177 | 183 | ||
178 | u32 rxbd_wrptr; | 184 | u32 rxbd_wrptr; |
@@ -180,7 +186,7 @@ struct pcie_service_card { | |||
180 | u32 rxbd_ring_size; | 186 | u32 rxbd_ring_size; |
181 | u8 *rxbd_ring_vbase; | 187 | u8 *rxbd_ring_vbase; |
182 | dma_addr_t rxbd_ring_pbase; | 188 | dma_addr_t rxbd_ring_pbase; |
183 | struct mwifiex_pcie_buf_desc *rxbd_ring[MWIFIEX_MAX_TXRX_BD]; | 189 | void *rxbd_ring[MWIFIEX_MAX_TXRX_BD]; |
184 | struct sk_buff *rx_buf_list[MWIFIEX_MAX_TXRX_BD]; | 190 | struct sk_buff *rx_buf_list[MWIFIEX_MAX_TXRX_BD]; |
185 | 191 | ||
186 | u32 evtbd_wrptr; | 192 | u32 evtbd_wrptr; |
@@ -188,7 +194,7 @@ struct pcie_service_card { | |||
188 | u32 evtbd_ring_size; | 194 | u32 evtbd_ring_size; |
189 | u8 *evtbd_ring_vbase; | 195 | u8 *evtbd_ring_vbase; |
190 | dma_addr_t evtbd_ring_pbase; | 196 | dma_addr_t evtbd_ring_pbase; |
191 | struct mwifiex_pcie_buf_desc *evtbd_ring[MWIFIEX_MAX_EVT_BD]; | 197 | void *evtbd_ring[MWIFIEX_MAX_EVT_BD]; |
192 | struct sk_buff *evt_buf_list[MWIFIEX_MAX_EVT_BD]; | 198 | struct sk_buff *evt_buf_list[MWIFIEX_MAX_EVT_BD]; |
193 | 199 | ||
194 | struct sk_buff *cmd_buf; | 200 | struct sk_buff *cmd_buf; |