xref: /titanic_41/usr/src/uts/common/io/cpqary3/cpqary3_q_mem.h (revision 0b42f15ac52b077791d4ba079e8c163c592c3fda)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright (C) 2013 Hewlett-Packard Development Company, L.P.
14  */
15 
16 #ifndef	_CPQARY3_Q_MEM_H
17 #define	_CPQARY3_Q_MEM_H
18 
19 #ifdef	__cplusplus
20 extern "C" {
21 #endif
22 
23 #define	CPQARY3_GET_MEM_TAG		4
24 
25 #define	CPQARY3_FREE			0
26 #define	CPQARY3_OCCUPIED		1
27 #define	CPQARY3_SELF_OCCUPIED		2
28 #define	CPQARY3_POLL_OCCUPIED		3
29 
30 #define	CPQARY3_PHYCTGS_DONE		0x01
31 #define	CPQARY3_CMDMEM_DONE		0x02
32 #define	CPQARY3_MEMLIST_DONE		0x04
33 
34 #define	CPQARY3_SUBMITTED_Q		0x0100
35 #define	CPQARY3_APPEND_RETRIEVE		1
36 #define	CPQARY3_REMOVE_SUBMITTED	0
37 
38 #define	CPQARY3_Q_UNMASK		0x0300
39 
40 /*
41  * No. of Commands that would be accomodated in each Command Pool
42  * Each command needs a physical contigous memory of 564 Bytes.
43  * The number of blocks to be allocated would be decided at run time
44  * depending upon the maximum outstanding commands supported by that controller.
45  */
46 #define	NO_OF_CMDLIST_IN_A_BLK		3
47 
48 
49 /*
50  * This structure is meant to store the handle of the physically contiguous
51  * memory blcoks that will be allocated during the _meminit().
52  * The no. of blocks that will be allocated will be decide at run time
53  * depending upon the maximum outstanding commands supported by the controller.
54  * each block is physically contiguous & can hold 3 commands.
55  */
56 typedef struct cpqary3_phyctg {
57 	size_t			real_size;
58 	ddi_dma_handle_t	cpqary3_dmahandle;
59 	ddi_acc_handle_t	cpqary3_acchandle;
60 	ddi_dma_cookie_t	cpqary3_dmacookie;
61 } cpqary3_phyctg_t;
62 
63 typedef struct cpqary3_command_private CMDLIST;
64 
65 /* Linked List Structure to hold Command List Details */
66 typedef struct cpqary3_command_private {
67 	uint8_t				occupied;
68 	uint8_t				cmdpvt_flag;
69 	uint32_t			cmdlist_phyaddr;
70 	uint32_t			cmdlist_erraddr;
71 	cpqary3_tag_t 			tag;
72 	ErrorInfo_t			*errorinfop;
73 	CommandList_t			*cmdlist_memaddr;
74 	struct cpqary3_command_private	*next; /* next Command Memory */
75 	struct cpqary3_command_private	*prev; /* previous Command Memory */
76 	struct cpqary3_per_controller	*ctlr; /* to its controller */
77 	struct cpqary3_pkt		*pvt_pkt; /* Driver Private Packet */
78 	struct cpqary3_driver_private	*driverdata; /* command private data */
79 	struct cpqary3_command_private	*snext; /* to maintain Submitted Q & */
80 	struct cpqary3_command_private	*sprev; /* Retrieved Q. */
81 	void				(*complete)(CMDLIST *);
82 } cpqary3_cmdpvt_t;
83 
84 /* structure to maintain a linked list of the memory blocks */
85 typedef struct physical_handle_address {
86 	cpqary3_phyctg_t 		*blk_addr;
87 	struct physical_handle_address  *next;
88 } cpqary3_phys_hdl_addr_t;
89 
90 /* Structure to hold Memory Pool Details */
91 typedef struct cpqary3_cmdmemlist {
92 	uint16_t		max_memcnt;
93 	cpqary3_cmdpvt_t	*pool;
94 	cpqary3_cmdpvt_t	*head;
95 	cpqary3_cmdpvt_t	*tail;
96 	cpqary3_phys_hdl_addr_t *cpqary3_phyctgp; /* list of memory blocks */
97 } cpqary3_cmdmemlist_t;
98 
99 #ifdef	__cplusplus
100 }
101 #endif
102 
103 #endif	/* _CPQARY3_Q_MEM_H */
104