-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathsysfuncproto.h
258 lines (232 loc) · 8.25 KB
/
sysfuncproto.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
/*
* NVM Express Compliance Suite
* Copyright (c) 2011, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _SYSFUNCPROTO_H_
#define _SYSFUNCPROTO_H_
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/blkdev.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/fs.h>
#include "dnvme_ds.h"
#include "dnvme_reg.h"
#include "sysdnvme.h"
/**
* driver_generic_read is a function that is called from
* driver IOCTL when user want to read data from the
* NVME card. The read parameter like offset and length
* etc are specified from the struct rw_generic
* @param nvme_data pointer to the device opened.
* @param pmetrics_device
* @return read success or failure.
*/
int driver_generic_read(struct rw_generic *nvme_data,
struct metrics_device_list *pmetrics_device);
/**
* driver_generic_write is a function that is called from
* driver IOCTL when user want to write data to the
* NVME card. The write parameters offset and length
* etc are specified from the struct nvme_write_generic
* @param nvme_data pointer to the device opened.
* @param pmetrics_device
* @return write success or failure.
*/
int driver_generic_write(struct rw_generic *nvme_data,
struct metrics_device_list *pmetrics_device);
/**
* device_status_chk - Generic error checking function
* which checks error registers and set kernel
* alert if a error is detected.
* @param pmetrics_device
* @param status
* @return device status fail or success.
*/
int device_status_chk(struct metrics_device_list *pmetrics_device,
int *status);
/**
* driver_create_asq - Driver Admin Submission Queue creation routine
* @param create_admn_q
* @param pmetrics_device
* @return ASQ creation SUCCESS or FAIL
*/
int driver_create_asq(struct nvme_create_admn_q *create_admn_q,
struct metrics_device_list *pmetrics_device);
/*
* driver_iotcl_init - Driver Initialization routine before starting to
* issue ioctls.
* @param pdev
* @param pmetrics_device_list
* @return init SUCCESS or FAIL
*/
int driver_ioctl_init(struct pci_dev *pdev, void __iomem *bar0,
void __iomem *bar1, void __iomem *bar2,
struct metrics_device_list *pmetrics_device_list);
/**
* driver_create_acq - Driver Admin completion Queue creation routine
* @param create_admn_q
* @param pmetrics_device_list
* @return ACQ creation SUCCESS or FAIL
*/
int driver_create_acq(struct nvme_create_admn_q *create_admn_q,
struct metrics_device_list *pmetrics_device_list);
/**
* driver_nvme_prep_sq - Driver routine to set up user parameters into metrics
* for prepating the IO SQ.
* @param prep_sq
* @param pmetrics_device
* @return allocation of contig mem SUCCESS or FAIL.
*/
int driver_nvme_prep_sq(struct nvme_prep_sq *prep_sq,
struct metrics_device_list *pmetrics_device);
/**
* driver_nvme_prep_cq - Driver routine to set up user parameters into metrics
* for prepating the IO CQ.
* @param prep_cq
* @param pmetrics_device
* @return allocation of contig mem SUCCESS or FAIL.
*/
int driver_nvme_prep_cq(struct nvme_prep_cq *prep_cq,
struct metrics_device_list *pmetrics_device);
/**
* driver_send_64b - Routine for sending 64 bytes command into
* admin/IO SQ/CQ's
* @param pmetrics_device
* @param nvme_64b_send
* @return Error Codes
*/
int driver_send_64b(struct metrics_device_list *pmetrics_device,
struct nvme_64b_send *cmd_request);
/**
* driver_toxic_dword - Please refer to the header file comment for
* NVME_IOCTL_TOXIC_64B_CMD.
* @param pmetrics_device
* @param err_inject Pass ptr to the user space buffer describing the error
* to inject.
* @return Error Codes
*/
int driver_toxic_dword(struct metrics_device_list *pmetrics_device,
struct backdoor_inject *err_inject);
/**
* driver_log - Driver routine to log data into file from metrics
* @param n_file
* @return allocation of contig mem SUCCESS or FAIL.
*/
int driver_log(struct nvme_file *n_file);
/**
* driver_logstr - Driver routine to log a custom string to the system log
* @param logStr
* @return SUCCESS or FAIL.
*/
int driver_logstr(struct nvme_logstr *logStr);
/**
* deallocate_all_queues - This function will start freeing up the memory for
* the queues (SQ and CQ) allocated during the prepare queues. This function
* takes a parameter, ST_DISABLE or ST_DISABLE_COMPLETELY, which identifies if
* you need to clear Admin or not. Also while driver exit call this function
* with ST_DISABLE_COMPLETELY.
* @param pmetrics_device
* @param nstate
*/
void deallocate_all_queues(struct metrics_device_list *pmetrics_device,
enum nvme_state nstate);
/**
* driver_reap_inquiry - This function will traverse the metrics device list
* for the given cq_id and return the number of commands that are to be reaped.
* This is only function apart from initializations, that will modify tail_ptr
* for the corresponding CQ.
* @param pmetrics_device
* @param usr_reap_inq
* @return success or failure based on reap_inquiry
*/
int driver_reap_inquiry(struct metrics_device_list *pmetrics_device,
struct nvme_reap_inquiry *usr_reap_inq);
/**
* dnvme_device_open - This operation is always the first operation performed
* on the device file.
* @param inode
* @param filp
* @return success or failure based on device open
*/
int dnvme_device_open(struct inode *inode, struct file *filp);
/**
* dnvme_device_release - This operation is invoked when the file structure
* is being released.
* @param inode
* @param filp
* @return success or failure based on device clean up.
*/
int dnvme_device_release(struct inode *inode, struct file *filp);
/**
* dnvme_device_mmap - This mmap will do the linear mapping to device memory
* into user space.
* The parameter vma holds all the required mapping and return the caller with
* virtual address.
* @param filp
* @param vma
* @return success or failure depending on mapping.
*/
int dnvme_device_mmap(struct file *filp, struct vm_area_struct *vma);
/**
* driver_reap_cq - Reap the number of elements specified for the given CQ id.
* Return the CQ entry data in the buffer specified.
* @param pmetrics_device
* @param usr_reap_data
* @return Success of Failure based on Reap Success or failure.
*/
int driver_reap_cq(struct metrics_device_list *pmetrics_device,
struct nvme_reap *usr_reap_data);
/**
* Create a dma pool for the requested size. Initialize the DMA pool pointer
* with DWORD alignment and associate it with the active device.
* @param pmetrics_device
* @param alloc_size
* @return SUCCESS or FAIL based on dma pool creation.
*/
int metabuff_create(struct metrics_device_list *pmetrics_device,
u32 alloc_size);
/**
* Create a meta buffer node when user request and allocate a consistent
* dma memory from the meta dma pool. Add this node into the meta data
* linked list.
* @param pmetrics_device
* @param meta_id
* @return Success of Failure based on dma alloc Success or failure.
*/
int metabuff_alloc(struct metrics_device_list *pmetrics_device,
u32 meta_id);
/**
* Delete a meta buffer node when user requests and deallocate a consistent
* dma memory. Delete this node from the meta data linked list.
* @param pmetrics_device
* @param meta_id
* @return Success of Failure based on metabuff delete
*/
int metabuff_del(struct metrics_device_list *pmetrics_device,
u32 meta_id);
/*
* deallocate_mb will free up the memory and nodes for the meta buffers
* that were allocated during the alloc and create meta. Finally
* destroys the dma pool and free up the metrics meta node.
* @param pmetrics_device
*/
void deallocate_mb(struct metrics_device_list *pmetrics_device);
int check_cntlr_cap(struct pci_dev *pdev, enum nvme_irq_type cap_type,
u16 *offset);
#endif