This repository has been archived by the owner on Nov 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpfu.c
114 lines (100 loc) · 3.18 KB
/
pfu.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
* Copyright (C) 2018-2020 Laird Connectivity
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
#include "sysadpt.h"
#include "dev.h"
#include "pcie.h"
int wlan_pcie_create_txbd_ring(struct ieee80211_hw *hw)
{
int ret = 0;
unsigned int i;
struct mwl_priv *priv = hw->priv;
struct mwl_pcie_card *card = priv->intf;
/*
* driver maintaines the write pointer and firmware maintaines the read
* pointer.
*/
priv->txbd_wrptr = 0;
priv->txbd_rdptr = 0;
/* allocate shared memory for the BD ring and divide the same in to
* several descriptors
*/
priv->txbd_ring_size =
sizeof(struct _mlan_pcie_data_buf) * MLAN_MAX_TXRX_BD;
wiphy_info(hw->wiphy, "TX ring: allocating %d bytes\n",
priv->txbd_ring_size);
priv->txbd_ring_vbase = pci_alloc_consistent(card->pdev,
priv->txbd_ring_size, (dma_addr_t *)&priv->txbd_ring_pbase);
if (!priv->txbd_ring_vbase) {
wiphy_err(hw->wiphy,
"%s: No free moal_malloc_consistent\n", __func__);
return MLAN_STATUS_FAILURE;
}
wiphy_info(hw->wiphy,
"TX ring: - base: %p, pbase: %#x:%x,len: %x\n",
priv->txbd_ring_vbase,
(unsigned int)((unsigned long long)priv->txbd_ring_pbase >> 32),
(unsigned int)priv->txbd_ring_pbase,
priv->txbd_ring_size);
for (i = 0; i < MLAN_MAX_TXRX_BD; i++) {
priv->txbd_ring[i] = (struct _mlan_pcie_data_buf *)
(priv->txbd_ring_vbase +
(sizeof(struct _mlan_pcie_data_buf) * i));
priv->tx_buf_list[i] = MNULL;
priv->txbd_ring[i]->paddr = 0;
priv->txbd_ring[i]->len = 0;
priv->txbd_ring[i]->flags = 0;
priv->txbd_ring[i]->frag_len = 0;
priv->txbd_ring[i]->offset = 0;
}
return ret;
}
int wlan_pcie_delete_txbd_ring(struct ieee80211_hw *hw)
{
unsigned int i;
struct sk_buff *skb;
struct mwl_tx_desc *tx_desc;
struct mwl_priv *priv = hw->priv;
struct mwl_pcie_card *card = priv->intf;
for (i = 0; i < MLAN_MAX_TXRX_BD; i++) {
if (priv->tx_buf_list[i]) {
skb = priv->tx_buf_list[i];
tx_desc = (struct mwl_tx_desc *)skb->data;
pci_unmap_single(card->pdev,
le32_to_cpu(tx_desc->pkt_ptr),
le16_to_cpu(tx_desc->pkt_len),
PCI_DMA_TODEVICE);
dev_kfree_skb_any(skb);
}
priv->tx_buf_list[i] = MNULL;
priv->txbd_ring[i]->paddr = 0;
priv->txbd_ring[i]->len = 0;
priv->txbd_ring[i]->flags = 0;
priv->txbd_ring[i]->frag_len = 0;
priv->txbd_ring[i]->offset = 0;
priv->txbd_ring[i] = MNULL;
}
if (priv->txbd_ring_vbase) {
pci_free_consistent(card->pdev,
priv->txbd_ring_size,
priv->txbd_ring_vbase,
priv->txbd_ring_pbase);
}
priv->txbd_ring_size = 0;
priv->txbd_wrptr = 0;
priv->txbd_rdptr = 0;
priv->txbd_ring_vbase = MNULL;
priv->txbd_ring_pbase = 0;
return MLAN_STATUS_SUCCESS;
}