xref: /openbmc/linux/drivers/misc/genwqe/genwqe_driver.h (revision 12eb4683251ebfb12afba9c56556fade7a3d7372)
1*12eb4683SFrank Haverkamp #ifndef __GENWQE_DRIVER_H__
2*12eb4683SFrank Haverkamp #define __GENWQE_DRIVER_H__
3*12eb4683SFrank Haverkamp 
4*12eb4683SFrank Haverkamp /**
5*12eb4683SFrank Haverkamp  * IBM Accelerator Family 'GenWQE'
6*12eb4683SFrank Haverkamp  *
7*12eb4683SFrank Haverkamp  * (C) Copyright IBM Corp. 2013
8*12eb4683SFrank Haverkamp  *
9*12eb4683SFrank Haverkamp  * Author: Frank Haverkamp <haver@linux.vnet.ibm.com>
10*12eb4683SFrank Haverkamp  * Author: Joerg-Stephan Vogt <jsvogt@de.ibm.com>
11*12eb4683SFrank Haverkamp  * Author: Michael Jung <mijung@de.ibm.com>
12*12eb4683SFrank Haverkamp  * Author: Michael Ruettger <michael@ibmra.de>
13*12eb4683SFrank Haverkamp  *
14*12eb4683SFrank Haverkamp  * This program is free software; you can redistribute it and/or modify
15*12eb4683SFrank Haverkamp  * it under the terms of the GNU General Public License (version 2 only)
16*12eb4683SFrank Haverkamp  * as published by the Free Software Foundation.
17*12eb4683SFrank Haverkamp  *
18*12eb4683SFrank Haverkamp  * This program is distributed in the hope that it will be useful,
19*12eb4683SFrank Haverkamp  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20*12eb4683SFrank Haverkamp  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21*12eb4683SFrank Haverkamp  * GNU General Public License for more details.
22*12eb4683SFrank Haverkamp  */
23*12eb4683SFrank Haverkamp 
24*12eb4683SFrank Haverkamp #include <linux/types.h>
25*12eb4683SFrank Haverkamp #include <linux/stddef.h>
26*12eb4683SFrank Haverkamp #include <linux/cdev.h>
27*12eb4683SFrank Haverkamp #include <linux/list.h>
28*12eb4683SFrank Haverkamp #include <linux/kthread.h>
29*12eb4683SFrank Haverkamp #include <linux/scatterlist.h>
30*12eb4683SFrank Haverkamp #include <linux/iommu.h>
31*12eb4683SFrank Haverkamp #include <linux/spinlock.h>
32*12eb4683SFrank Haverkamp #include <linux/mutex.h>
33*12eb4683SFrank Haverkamp #include <linux/platform_device.h>
34*12eb4683SFrank Haverkamp #include <asm/byteorder.h>
35*12eb4683SFrank Haverkamp 
36*12eb4683SFrank Haverkamp #include <linux/genwqe/genwqe_card.h>
37*12eb4683SFrank Haverkamp 
38*12eb4683SFrank Haverkamp #define DRV_VERS_STRING		"2.0.0"
39*12eb4683SFrank Haverkamp 
40*12eb4683SFrank Haverkamp /*
41*12eb4683SFrank Haverkamp  * Static minor number assignement, until we decide/implement
42*12eb4683SFrank Haverkamp  * something dynamic.
43*12eb4683SFrank Haverkamp  */
44*12eb4683SFrank Haverkamp #define GENWQE_MAX_MINOR	128 /* up to 128 possible genwqe devices */
45*12eb4683SFrank Haverkamp 
46*12eb4683SFrank Haverkamp /**
47*12eb4683SFrank Haverkamp  * genwqe_requ_alloc() - Allocate a new DDCB execution request
48*12eb4683SFrank Haverkamp  *
49*12eb4683SFrank Haverkamp  * This data structure contains the user visiable fields of the DDCB
50*12eb4683SFrank Haverkamp  * to be executed.
51*12eb4683SFrank Haverkamp  *
52*12eb4683SFrank Haverkamp  * Return: ptr to genwqe_ddcb_cmd data structure
53*12eb4683SFrank Haverkamp  */
54*12eb4683SFrank Haverkamp struct genwqe_ddcb_cmd *ddcb_requ_alloc(void);
55*12eb4683SFrank Haverkamp 
56*12eb4683SFrank Haverkamp /**
57*12eb4683SFrank Haverkamp  * ddcb_requ_free() - Free DDCB execution request.
58*12eb4683SFrank Haverkamp  * @req:       ptr to genwqe_ddcb_cmd data structure.
59*12eb4683SFrank Haverkamp  */
60*12eb4683SFrank Haverkamp void ddcb_requ_free(struct genwqe_ddcb_cmd *req);
61*12eb4683SFrank Haverkamp 
62*12eb4683SFrank Haverkamp u32  genwqe_crc32(u8 *buff, size_t len, u32 init);
63*12eb4683SFrank Haverkamp 
64*12eb4683SFrank Haverkamp static inline void genwqe_hexdump(struct pci_dev *pci_dev,
65*12eb4683SFrank Haverkamp 				  const void *buff, unsigned int size)
66*12eb4683SFrank Haverkamp {
67*12eb4683SFrank Haverkamp 	char prefix[32];
68*12eb4683SFrank Haverkamp 
69*12eb4683SFrank Haverkamp 	scnprintf(prefix, sizeof(prefix), "%s %s: ",
70*12eb4683SFrank Haverkamp 		  GENWQE_DEVNAME, pci_name(pci_dev));
71*12eb4683SFrank Haverkamp 	dynamic_hex_dump(prefix, DUMP_PREFIX_OFFSET, 16, 1, buff, size, true);
72*12eb4683SFrank Haverkamp }
73*12eb4683SFrank Haverkamp 
74*12eb4683SFrank Haverkamp #endif	/* __GENWQE_DRIVER_H__ */
75