Commit dda56df0 authored by Olof Johansson's avatar Olof Johansson

[POWERPC] pasemi: Add function engine management functions to dma_lib

Used to allocate functions for crypto/checksum offload.
Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
Acked-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent f37203b5
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#define MAX_TXCH 64 #define MAX_TXCH 64
#define MAX_RXCH 64 #define MAX_RXCH 64
#define MAX_FLAGS 64 #define MAX_FLAGS 64
#define MAX_FUN 8
static struct pasdma_status *dma_status; static struct pasdma_status *dma_status;
...@@ -46,6 +47,7 @@ static struct pci_dev *dma_pdev; ...@@ -46,6 +47,7 @@ static struct pci_dev *dma_pdev;
static DECLARE_BITMAP(txch_free, MAX_TXCH); static DECLARE_BITMAP(txch_free, MAX_TXCH);
static DECLARE_BITMAP(rxch_free, MAX_RXCH); static DECLARE_BITMAP(rxch_free, MAX_RXCH);
static DECLARE_BITMAP(flags_free, MAX_FLAGS); static DECLARE_BITMAP(flags_free, MAX_FLAGS);
static DECLARE_BITMAP(fun_free, MAX_FUN);
/* pasemi_read_iob_reg - read IOB register /* pasemi_read_iob_reg - read IOB register
* @reg: Register to read (offset into PCI CFG space) * @reg: Register to read (offset into PCI CFG space)
...@@ -441,6 +443,41 @@ void pasemi_dma_clear_flag(int flag) ...@@ -441,6 +443,41 @@ void pasemi_dma_clear_flag(int flag)
} }
EXPORT_SYMBOL(pasemi_dma_clear_flag); EXPORT_SYMBOL(pasemi_dma_clear_flag);
/* pasemi_dma_alloc_fun - Allocate a function engine
*
* Allocates a function engine to use for crypto/checksum offload
* Returns allocated engine (0-8), < 0 on error.
*/
int pasemi_dma_alloc_fun(void)
{
int bit;
retry:
bit = find_next_bit(fun_free, MAX_FLAGS, 0);
if (bit >= MAX_FLAGS)
return -ENOSPC;
if (!test_and_clear_bit(bit, fun_free))
goto retry;
return bit;
}
EXPORT_SYMBOL(pasemi_dma_alloc_fun);
/* pasemi_dma_free_fun - Deallocates a function engine
* @flag: Engine number to deallocate
*
* Frees up a function engine so it can be used for other purposes.
*/
void pasemi_dma_free_fun(int fun)
{
BUG_ON(test_bit(fun, fun_free));
BUG_ON(fun >= MAX_FLAGS);
set_bit(fun, fun_free);
}
EXPORT_SYMBOL(pasemi_dma_free_fun);
static void *map_onedev(struct pci_dev *p, int index) static void *map_onedev(struct pci_dev *p, int index)
{ {
struct device_node *dn; struct device_node *dn;
...@@ -578,6 +615,9 @@ int pasemi_dma_init(void) ...@@ -578,6 +615,9 @@ int pasemi_dma_init(void)
for (i = 0; i < MAX_FLAGS; i++) for (i = 0; i < MAX_FLAGS; i++)
__set_bit(i, flags_free); __set_bit(i, flags_free);
for (i = 0; i < MAX_FUN; i++)
__set_bit(i, fun_free);
/* clear all status flags */ /* clear all status flags */
pasemi_write_dma_reg(PAS_DMA_TXF_CFLG0, 0xffffffff); pasemi_write_dma_reg(PAS_DMA_TXF_CFLG0, 0xffffffff);
pasemi_write_dma_reg(PAS_DMA_TXF_CFLG1, 0xffffffff); pasemi_write_dma_reg(PAS_DMA_TXF_CFLG1, 0xffffffff);
......
...@@ -472,6 +472,10 @@ extern void pasemi_dma_free_flag(int flag); ...@@ -472,6 +472,10 @@ extern void pasemi_dma_free_flag(int flag);
extern void pasemi_dma_set_flag(int flag); extern void pasemi_dma_set_flag(int flag);
extern void pasemi_dma_clear_flag(int flag); extern void pasemi_dma_clear_flag(int flag);
/* Routines to allocate function engines */
extern int pasemi_dma_alloc_fun(void);
extern void pasemi_dma_free_fun(int fun);
/* Initialize the library, must be called before any other functions */ /* Initialize the library, must be called before any other functions */
extern int pasemi_dma_init(void); extern int pasemi_dma_init(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment