diff options
author | James Smart <James.Smart@Emulex.Com> | 2008-08-24 21:49:00 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-10-13 09:28:53 -0400 |
commit | e59058c44025d71c9b7f260076a932935d3bba95 (patch) | |
tree | 36cd4b31ac3b130849c5ad4d2c0cef035a7389dd /drivers/scsi/lpfc/lpfc_mem.c | |
parent | 4a27446f3e39b06c28d1c8e31d33a5340826ed5c (diff) |
[SCSI] lpfc 8.2.8 : Add kernel-doc function headers
Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_mem.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_mem.c | 115 |
1 files changed, 110 insertions, 5 deletions
diff --git a/drivers/scsi/lpfc/lpfc_mem.c b/drivers/scsi/lpfc/lpfc_mem.c index 3c0cebc71800..50d9136a6e04 100644 --- a/drivers/scsi/lpfc/lpfc_mem.c +++ b/drivers/scsi/lpfc/lpfc_mem.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2006 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2008 Emulex. All rights reserved. * |
5 | * EMULEX and SLI are trademarks of Emulex. * | 5 | * EMULEX and SLI are trademarks of Emulex. * |
6 | * www.emulex.com * | 6 | * www.emulex.com * |
7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
@@ -39,7 +39,21 @@ | |||
39 | #define LPFC_MEM_POOL_SIZE 64 /* max elem in non-DMA safety pool */ | 39 | #define LPFC_MEM_POOL_SIZE 64 /* max elem in non-DMA safety pool */ |
40 | 40 | ||
41 | 41 | ||
42 | 42 | /** | |
43 | * lpfc_mem_alloc: create and allocate all PCI and memory pools | ||
44 | * @phba: HBA to allocate pools for | ||
45 | * | ||
46 | * Description: Creates and allocates PCI pools lpfc_scsi_dma_buf_pool, | ||
47 | * lpfc_mbuf_pool, lpfc_hbq_pool. Creates and allocates kmalloc-backed mempools | ||
48 | * for LPFC_MBOXQ_t and lpfc_nodelist. Also allocates the VPI bitmask. | ||
49 | * | ||
50 | * Notes: Not interrupt-safe. Must be called with no locks held. If any | ||
51 | * allocation fails, frees all successfully allocated memory before returning. | ||
52 | * | ||
53 | * Returns: | ||
54 | * 0 on success | ||
55 | * -ENOMEM on failure (if any memory allocations fail) | ||
56 | **/ | ||
43 | int | 57 | int |
44 | lpfc_mem_alloc(struct lpfc_hba * phba) | 58 | lpfc_mem_alloc(struct lpfc_hba * phba) |
45 | { | 59 | { |
@@ -120,6 +134,16 @@ lpfc_mem_alloc(struct lpfc_hba * phba) | |||
120 | return -ENOMEM; | 134 | return -ENOMEM; |
121 | } | 135 | } |
122 | 136 | ||
137 | /** | ||
138 | * lpfc_mem_free: Frees all PCI and memory allocated by lpfc_mem_alloc | ||
139 | * @phba: HBA to free memory for | ||
140 | * | ||
141 | * Description: Frees PCI pools lpfc_scsi_dma_buf_pool, lpfc_mbuf_pool, | ||
142 | * lpfc_hbq_pool. Frees kmalloc-backed mempools for LPFC_MBOXQ_t and | ||
143 | * lpfc_nodelist. Also frees the VPI bitmask. | ||
144 | * | ||
145 | * Returns: None | ||
146 | **/ | ||
123 | void | 147 | void |
124 | lpfc_mem_free(struct lpfc_hba * phba) | 148 | lpfc_mem_free(struct lpfc_hba * phba) |
125 | { | 149 | { |
@@ -181,12 +205,29 @@ lpfc_mem_free(struct lpfc_hba * phba) | |||
181 | phba->lpfc_scsi_dma_buf_pool = NULL; | 205 | phba->lpfc_scsi_dma_buf_pool = NULL; |
182 | phba->lpfc_mbuf_pool = NULL; | 206 | phba->lpfc_mbuf_pool = NULL; |
183 | 207 | ||
184 | /* Free the iocb lookup array */ | 208 | /* Free the iocb lookup array */ |
185 | kfree(psli->iocbq_lookup); | 209 | kfree(psli->iocbq_lookup); |
186 | psli->iocbq_lookup = NULL; | 210 | psli->iocbq_lookup = NULL; |
187 | |||
188 | } | 211 | } |
189 | 212 | ||
213 | /** | ||
214 | * lpfc_mbuf_alloc: Allocate an mbuf from the lpfc_mbuf_pool PCI pool | ||
215 | * @phba: HBA which owns the pool to allocate from | ||
216 | * @mem_flags: indicates if this is a priority (MEM_PRI) allocation | ||
217 | * @handle: used to return the DMA-mapped address of the mbuf | ||
218 | * | ||
219 | * Description: Allocates a DMA-mapped buffer from the lpfc_mbuf_pool PCI pool. | ||
220 | * Allocates from generic pci_pool_alloc function first and if that fails and | ||
221 | * mem_flags has MEM_PRI set (the only defined flag), returns an mbuf from the | ||
222 | * HBA's pool. | ||
223 | * | ||
224 | * Notes: Not interrupt-safe. Must be called with no locks held. Takes | ||
225 | * phba->hbalock. | ||
226 | * | ||
227 | * Returns: | ||
228 | * pointer to the allocated mbuf on success | ||
229 | * NULL on failure | ||
230 | **/ | ||
190 | void * | 231 | void * |
191 | lpfc_mbuf_alloc(struct lpfc_hba *phba, int mem_flags, dma_addr_t *handle) | 232 | lpfc_mbuf_alloc(struct lpfc_hba *phba, int mem_flags, dma_addr_t *handle) |
192 | { | 233 | { |
@@ -206,6 +247,20 @@ lpfc_mbuf_alloc(struct lpfc_hba *phba, int mem_flags, dma_addr_t *handle) | |||
206 | return ret; | 247 | return ret; |
207 | } | 248 | } |
208 | 249 | ||
250 | /** | ||
251 | * __lpfc_mem_free: Free an mbuf from the lpfc_mbuf_pool PCI pool (locked) | ||
252 | * @phba: HBA which owns the pool to return to | ||
253 | * @virt: mbuf to free | ||
254 | * @dma: the DMA-mapped address of the lpfc_mbuf_pool to be freed | ||
255 | * | ||
256 | * Description: Returns an mbuf lpfc_mbuf_pool to the lpfc_mbuf_safety_pool if | ||
257 | * it is below its max_count, frees the mbuf otherwise. | ||
258 | * | ||
259 | * Notes: Must be called with phba->hbalock held to synchronize access to | ||
260 | * lpfc_mbuf_safety_pool. | ||
261 | * | ||
262 | * Returns: None | ||
263 | **/ | ||
209 | void | 264 | void |
210 | __lpfc_mbuf_free(struct lpfc_hba * phba, void *virt, dma_addr_t dma) | 265 | __lpfc_mbuf_free(struct lpfc_hba * phba, void *virt, dma_addr_t dma) |
211 | { | 266 | { |
@@ -221,7 +276,21 @@ __lpfc_mbuf_free(struct lpfc_hba * phba, void *virt, dma_addr_t dma) | |||
221 | return; | 276 | return; |
222 | } | 277 | } |
223 | 278 | ||
279 | /** | ||
280 | * lpfc_mem_free: Free an mbuf from the lpfc_mbuf_pool PCI pool (unlocked) | ||
281 | * @phba: HBA which owns the pool to return to | ||
282 | * @virt: mbuf to free | ||
283 | * @dma: the DMA-mapped address of the lpfc_mbuf_pool to be freed | ||
284 | * | ||
285 | * Description: Returns an mbuf lpfc_mbuf_pool to the lpfc_mbuf_safety_pool if | ||
286 | * it is below its max_count, frees the mbuf otherwise. | ||
287 | * | ||
288 | * Notes: Takes phba->hbalock. Can be called with or without other locks held. | ||
289 | * | ||
290 | * Returns: None | ||
291 | **/ | ||
224 | void | 292 | void |
293 | |||
225 | lpfc_mbuf_free(struct lpfc_hba * phba, void *virt, dma_addr_t dma) | 294 | lpfc_mbuf_free(struct lpfc_hba * phba, void *virt, dma_addr_t dma) |
226 | { | 295 | { |
227 | unsigned long iflags; | 296 | unsigned long iflags; |
@@ -232,6 +301,19 @@ lpfc_mbuf_free(struct lpfc_hba * phba, void *virt, dma_addr_t dma) | |||
232 | return; | 301 | return; |
233 | } | 302 | } |
234 | 303 | ||
304 | /** | ||
305 | * lpfc_els_hbq_alloc: Allocate an HBQ buffer | ||
306 | * @phba: HBA to allocate HBQ buffer for | ||
307 | * | ||
308 | * Description: Allocates a DMA-mapped HBQ buffer from the lpfc_hbq_pool PCI | ||
309 | * pool along a non-DMA-mapped container for it. | ||
310 | * | ||
311 | * Notes: Not interrupt-safe. Must be called with no locks held. | ||
312 | * | ||
313 | * Returns: | ||
314 | * pointer to HBQ on success | ||
315 | * NULL on failure | ||
316 | **/ | ||
235 | struct hbq_dmabuf * | 317 | struct hbq_dmabuf * |
236 | lpfc_els_hbq_alloc(struct lpfc_hba *phba) | 318 | lpfc_els_hbq_alloc(struct lpfc_hba *phba) |
237 | { | 319 | { |
@@ -251,6 +333,18 @@ lpfc_els_hbq_alloc(struct lpfc_hba *phba) | |||
251 | return hbqbp; | 333 | return hbqbp; |
252 | } | 334 | } |
253 | 335 | ||
336 | /** | ||
337 | * lpfc_mem_hbq_free: Frees an HBQ buffer allocated with lpfc_els_hbq_alloc | ||
338 | * @phba: HBA buffer was allocated for | ||
339 | * @hbqbp: HBQ container returned by lpfc_els_hbq_alloc | ||
340 | * | ||
341 | * Description: Frees both the container and the DMA-mapped buffer returned by | ||
342 | * lpfc_els_hbq_alloc. | ||
343 | * | ||
344 | * Notes: Can be called with or without locks held. | ||
345 | * | ||
346 | * Returns: None | ||
347 | **/ | ||
254 | void | 348 | void |
255 | lpfc_els_hbq_free(struct lpfc_hba *phba, struct hbq_dmabuf *hbqbp) | 349 | lpfc_els_hbq_free(struct lpfc_hba *phba, struct hbq_dmabuf *hbqbp) |
256 | { | 350 | { |
@@ -259,7 +353,18 @@ lpfc_els_hbq_free(struct lpfc_hba *phba, struct hbq_dmabuf *hbqbp) | |||
259 | return; | 353 | return; |
260 | } | 354 | } |
261 | 355 | ||
262 | /* This is ONLY called for the LPFC_ELS_HBQ */ | 356 | /** |
357 | * lpfc_in_buf_free: Free a DMA buffer | ||
358 | * @phba: HBA buffer is associated with | ||
359 | * @mp: Buffer to free | ||
360 | * | ||
361 | * Description: Frees the given DMA buffer in the appropriate way given if the | ||
362 | * HBA is running in SLI3 mode with HBQs enabled. | ||
363 | * | ||
364 | * Notes: Takes phba->hbalock. Can be called with or without other locks held. | ||
365 | * | ||
366 | * Returns: None | ||
367 | **/ | ||
263 | void | 368 | void |
264 | lpfc_in_buf_free(struct lpfc_hba *phba, struct lpfc_dmabuf *mp) | 369 | lpfc_in_buf_free(struct lpfc_hba *phba, struct lpfc_dmabuf *mp) |
265 | { | 370 | { |