diff options
Diffstat (limited to 'drivers/net/netxen/netxen_nic_init.c')
-rw-r--r-- | drivers/net/netxen/netxen_nic_init.c | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index 8893a973399a..363ef701e71e 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c | |||
@@ -137,7 +137,7 @@ void netxen_release_tx_buffers(struct netxen_adapter *adapter) | |||
137 | struct netxen_cmd_buffer *cmd_buf; | 137 | struct netxen_cmd_buffer *cmd_buf; |
138 | struct netxen_skb_frag *buffrag; | 138 | struct netxen_skb_frag *buffrag; |
139 | int i, j; | 139 | int i, j; |
140 | struct nx_host_tx_ring *tx_ring = &adapter->tx_ring; | 140 | struct nx_host_tx_ring *tx_ring = adapter->tx_ring; |
141 | 141 | ||
142 | cmd_buf = tx_ring->cmd_buf_arr; | 142 | cmd_buf = tx_ring->cmd_buf_arr; |
143 | for (i = 0; i < tx_ring->num_desc; i++) { | 143 | for (i = 0; i < tx_ring->num_desc; i++) { |
@@ -172,6 +172,10 @@ void netxen_free_sw_resources(struct netxen_adapter *adapter) | |||
172 | int ring; | 172 | int ring; |
173 | 173 | ||
174 | recv_ctx = &adapter->recv_ctx; | 174 | recv_ctx = &adapter->recv_ctx; |
175 | |||
176 | if (recv_ctx->rds_rings == NULL) | ||
177 | goto skip_rds; | ||
178 | |||
175 | for (ring = 0; ring < adapter->max_rds_rings; ring++) { | 179 | for (ring = 0; ring < adapter->max_rds_rings; ring++) { |
176 | rds_ring = &recv_ctx->rds_rings[ring]; | 180 | rds_ring = &recv_ctx->rds_rings[ring]; |
177 | if (rds_ring->rx_buf_arr) { | 181 | if (rds_ring->rx_buf_arr) { |
@@ -179,11 +183,15 @@ void netxen_free_sw_resources(struct netxen_adapter *adapter) | |||
179 | rds_ring->rx_buf_arr = NULL; | 183 | rds_ring->rx_buf_arr = NULL; |
180 | } | 184 | } |
181 | } | 185 | } |
186 | kfree(recv_ctx->rds_rings); | ||
187 | |||
188 | skip_rds: | ||
189 | if (adapter->tx_ring == NULL) | ||
190 | return; | ||
182 | 191 | ||
183 | tx_ring = &adapter->tx_ring; | 192 | tx_ring = adapter->tx_ring; |
184 | if (tx_ring->cmd_buf_arr) | 193 | if (tx_ring->cmd_buf_arr) |
185 | vfree(tx_ring->cmd_buf_arr); | 194 | vfree(tx_ring->cmd_buf_arr); |
186 | return; | ||
187 | } | 195 | } |
188 | 196 | ||
189 | int netxen_alloc_sw_resources(struct netxen_adapter *adapter) | 197 | int netxen_alloc_sw_resources(struct netxen_adapter *adapter) |
@@ -191,17 +199,26 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter) | |||
191 | struct netxen_recv_context *recv_ctx; | 199 | struct netxen_recv_context *recv_ctx; |
192 | struct nx_host_rds_ring *rds_ring; | 200 | struct nx_host_rds_ring *rds_ring; |
193 | struct nx_host_sds_ring *sds_ring; | 201 | struct nx_host_sds_ring *sds_ring; |
194 | struct nx_host_tx_ring *tx_ring = &adapter->tx_ring; | 202 | struct nx_host_tx_ring *tx_ring; |
195 | struct netxen_rx_buffer *rx_buf; | 203 | struct netxen_rx_buffer *rx_buf; |
196 | int ring, i, num_rx_bufs; | 204 | int ring, i, size; |
197 | 205 | ||
198 | struct netxen_cmd_buffer *cmd_buf_arr; | 206 | struct netxen_cmd_buffer *cmd_buf_arr; |
199 | struct net_device *netdev = adapter->netdev; | 207 | struct net_device *netdev = adapter->netdev; |
200 | struct pci_dev *pdev = adapter->pdev; | 208 | struct pci_dev *pdev = adapter->pdev; |
201 | 209 | ||
210 | size = sizeof(struct nx_host_tx_ring); | ||
211 | tx_ring = kzalloc(size, GFP_KERNEL); | ||
212 | if (tx_ring == NULL) { | ||
213 | dev_err(&pdev->dev, "%s: failed to allocate tx ring struct\n", | ||
214 | netdev->name); | ||
215 | return -ENOMEM; | ||
216 | } | ||
217 | adapter->tx_ring = tx_ring; | ||
218 | |||
202 | tx_ring->num_desc = adapter->num_txd; | 219 | tx_ring->num_desc = adapter->num_txd; |
203 | cmd_buf_arr = | 220 | |
204 | (struct netxen_cmd_buffer *)vmalloc(TX_BUFF_RINGSIZE(tx_ring)); | 221 | cmd_buf_arr = vmalloc(TX_BUFF_RINGSIZE(tx_ring)); |
205 | if (cmd_buf_arr == NULL) { | 222 | if (cmd_buf_arr == NULL) { |
206 | dev_err(&pdev->dev, "%s: failed to allocate cmd buffer ring\n", | 223 | dev_err(&pdev->dev, "%s: failed to allocate cmd buffer ring\n", |
207 | netdev->name); | 224 | netdev->name); |
@@ -211,6 +228,16 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter) | |||
211 | tx_ring->cmd_buf_arr = cmd_buf_arr; | 228 | tx_ring->cmd_buf_arr = cmd_buf_arr; |
212 | 229 | ||
213 | recv_ctx = &adapter->recv_ctx; | 230 | recv_ctx = &adapter->recv_ctx; |
231 | |||
232 | size = adapter->max_rds_rings * sizeof (struct nx_host_rds_ring); | ||
233 | rds_ring = kzalloc(size, GFP_KERNEL); | ||
234 | if (rds_ring == NULL) { | ||
235 | dev_err(&pdev->dev, "%s: failed to allocate rds ring struct\n", | ||
236 | netdev->name); | ||
237 | return -ENOMEM; | ||
238 | } | ||
239 | recv_ctx->rds_rings = rds_ring; | ||
240 | |||
214 | for (ring = 0; ring < adapter->max_rds_rings; ring++) { | 241 | for (ring = 0; ring < adapter->max_rds_rings; ring++) { |
215 | rds_ring = &recv_ctx->rds_rings[ring]; | 242 | rds_ring = &recv_ctx->rds_rings[ring]; |
216 | switch (ring) { | 243 | switch (ring) { |
@@ -262,9 +289,8 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter) | |||
262 | * Now go through all of them, set reference handles | 289 | * Now go through all of them, set reference handles |
263 | * and put them in the queues. | 290 | * and put them in the queues. |
264 | */ | 291 | */ |
265 | num_rx_bufs = rds_ring->num_desc; | ||
266 | rx_buf = rds_ring->rx_buf_arr; | 292 | rx_buf = rds_ring->rx_buf_arr; |
267 | for (i = 0; i < num_rx_bufs; i++) { | 293 | for (i = 0; i < rds_ring->num_desc; i++) { |
268 | list_add_tail(&rx_buf->list, | 294 | list_add_tail(&rx_buf->list, |
269 | &rds_ring->free_list); | 295 | &rds_ring->free_list); |
270 | rx_buf->ref_handle = i; | 296 | rx_buf->ref_handle = i; |
@@ -1064,7 +1090,7 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter) | |||
1064 | struct net_device *netdev = adapter->netdev; | 1090 | struct net_device *netdev = adapter->netdev; |
1065 | struct netxen_skb_frag *frag; | 1091 | struct netxen_skb_frag *frag; |
1066 | int done = 0; | 1092 | int done = 0; |
1067 | struct nx_host_tx_ring *tx_ring = &adapter->tx_ring; | 1093 | struct nx_host_tx_ring *tx_ring = adapter->tx_ring; |
1068 | 1094 | ||
1069 | if (!spin_trylock(&adapter->tx_clean_lock)) | 1095 | if (!spin_trylock(&adapter->tx_clean_lock)) |
1070 | return 1; | 1096 | return 1; |