diff options
author | Olof Johansson <olof@lixom.net> | 2008-03-05 13:25:59 -0500 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2008-03-05 13:26:50 -0500 |
commit | dda56df08a28404004bca313d2a1ba1597acd755 (patch) | |
tree | 4bc1d1c4b052c0de0f5f4a5a5ae51232ea5c23a1 | |
parent | f37203b5ccaf6d58cb5ca6b1840e40f3b587109c (diff) |
[POWERPC] pasemi: Add function engine management functions to dma_lib
Used to allocate functions for crypto/checksum offload.
Signed-off-by: Olof Johansson <olof@lixom.net>
Acked-by: Jeff Garzik <jgarzik@pobox.com>
-rw-r--r-- | arch/powerpc/platforms/pasemi/dma_lib.c | 40 | ||||
-rw-r--r-- | include/asm-powerpc/pasemi_dma.h | 4 |
2 files changed, 44 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/pasemi/dma_lib.c b/arch/powerpc/platforms/pasemi/dma_lib.c index 07e4e25ef625..217af321b0ca 100644 --- a/arch/powerpc/platforms/pasemi/dma_lib.c +++ b/arch/powerpc/platforms/pasemi/dma_lib.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #define MAX_TXCH 64 | 28 | #define MAX_TXCH 64 |
29 | #define MAX_RXCH 64 | 29 | #define MAX_RXCH 64 |
30 | #define MAX_FLAGS 64 | 30 | #define MAX_FLAGS 64 |
31 | #define MAX_FUN 8 | ||
31 | 32 | ||
32 | static struct pasdma_status *dma_status; | 33 | static struct pasdma_status *dma_status; |
33 | 34 | ||
@@ -46,6 +47,7 @@ static struct pci_dev *dma_pdev; | |||
46 | static DECLARE_BITMAP(txch_free, MAX_TXCH); | 47 | static DECLARE_BITMAP(txch_free, MAX_TXCH); |
47 | static DECLARE_BITMAP(rxch_free, MAX_RXCH); | 48 | static DECLARE_BITMAP(rxch_free, MAX_RXCH); |
48 | static DECLARE_BITMAP(flags_free, MAX_FLAGS); | 49 | static DECLARE_BITMAP(flags_free, MAX_FLAGS); |
50 | static DECLARE_BITMAP(fun_free, MAX_FUN); | ||
49 | 51 | ||
50 | /* pasemi_read_iob_reg - read IOB register | 52 | /* pasemi_read_iob_reg - read IOB register |
51 | * @reg: Register to read (offset into PCI CFG space) | 53 | * @reg: Register to read (offset into PCI CFG space) |
@@ -441,6 +443,41 @@ void pasemi_dma_clear_flag(int flag) | |||
441 | } | 443 | } |
442 | EXPORT_SYMBOL(pasemi_dma_clear_flag); | 444 | EXPORT_SYMBOL(pasemi_dma_clear_flag); |
443 | 445 | ||
446 | /* pasemi_dma_alloc_fun - Allocate a function engine | ||
447 | * | ||
448 | * Allocates a function engine to use for crypto/checksum offload | ||
449 | * Returns allocated engine (0-8), < 0 on error. | ||
450 | */ | ||
451 | int pasemi_dma_alloc_fun(void) | ||
452 | { | ||
453 | int bit; | ||
454 | |||
455 | retry: | ||
456 | bit = find_next_bit(fun_free, MAX_FLAGS, 0); | ||
457 | if (bit >= MAX_FLAGS) | ||
458 | return -ENOSPC; | ||
459 | if (!test_and_clear_bit(bit, fun_free)) | ||
460 | goto retry; | ||
461 | |||
462 | return bit; | ||
463 | } | ||
464 | EXPORT_SYMBOL(pasemi_dma_alloc_fun); | ||
465 | |||
466 | |||
467 | /* pasemi_dma_free_fun - Deallocates a function engine | ||
468 | * @flag: Engine number to deallocate | ||
469 | * | ||
470 | * Frees up a function engine so it can be used for other purposes. | ||
471 | */ | ||
472 | void pasemi_dma_free_fun(int fun) | ||
473 | { | ||
474 | BUG_ON(test_bit(fun, fun_free)); | ||
475 | BUG_ON(fun >= MAX_FLAGS); | ||
476 | set_bit(fun, fun_free); | ||
477 | } | ||
478 | EXPORT_SYMBOL(pasemi_dma_free_fun); | ||
479 | |||
480 | |||
444 | static void *map_onedev(struct pci_dev *p, int index) | 481 | static void *map_onedev(struct pci_dev *p, int index) |
445 | { | 482 | { |
446 | struct device_node *dn; | 483 | struct device_node *dn; |
@@ -578,6 +615,9 @@ int pasemi_dma_init(void) | |||
578 | for (i = 0; i < MAX_FLAGS; i++) | 615 | for (i = 0; i < MAX_FLAGS; i++) |
579 | __set_bit(i, flags_free); | 616 | __set_bit(i, flags_free); |
580 | 617 | ||
618 | for (i = 0; i < MAX_FUN; i++) | ||
619 | __set_bit(i, fun_free); | ||
620 | |||
581 | /* clear all status flags */ | 621 | /* clear all status flags */ |
582 | pasemi_write_dma_reg(PAS_DMA_TXF_CFLG0, 0xffffffff); | 622 | pasemi_write_dma_reg(PAS_DMA_TXF_CFLG0, 0xffffffff); |
583 | pasemi_write_dma_reg(PAS_DMA_TXF_CFLG1, 0xffffffff); | 623 | pasemi_write_dma_reg(PAS_DMA_TXF_CFLG1, 0xffffffff); |
diff --git a/include/asm-powerpc/pasemi_dma.h b/include/asm-powerpc/pasemi_dma.h index ffd413d7dfb0..facb2bdea45c 100644 --- a/include/asm-powerpc/pasemi_dma.h +++ b/include/asm-powerpc/pasemi_dma.h | |||
@@ -472,6 +472,10 @@ extern void pasemi_dma_free_flag(int flag); | |||
472 | extern void pasemi_dma_set_flag(int flag); | 472 | extern void pasemi_dma_set_flag(int flag); |
473 | extern void pasemi_dma_clear_flag(int flag); | 473 | extern void pasemi_dma_clear_flag(int flag); |
474 | 474 | ||
475 | /* Routines to allocate function engines */ | ||
476 | extern int pasemi_dma_alloc_fun(void); | ||
477 | extern void pasemi_dma_free_fun(int fun); | ||
478 | |||
475 | /* Initialize the library, must be called before any other functions */ | 479 | /* Initialize the library, must be called before any other functions */ |
476 | extern int pasemi_dma_init(void); | 480 | extern int pasemi_dma_init(void); |
477 | 481 | ||