2 * Part of Intel(R) Manageability Engine Interface Linux driver
4 * Copyright (c) 2003 - 2008 Intel Corp.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, and the following disclaimer,
12 * without modification.
13 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
14 * substantially similar to the "NO WARRANTY" disclaimer below
15 * ("Disclaimer") and any redistribution must be conditioned upon
16 * including a substantially similar Disclaimer requirement for further
17 * binary redistribution.
18 * 3. Neither the names of the above-listed copyright holders nor the names
19 * of any contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * Alternatively, this software may be distributed under the terms of the
23 * GNU General Public License ("GPL") version 2 as published by the Free
24 * Software Foundation.
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
30 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
35 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
36 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGES.
41 #ifndef _HECI_DATA_STRUCTURES_H_
42 #define _HECI_DATA_STRUCTURES_H_
44 #include <linux/version.h>
45 #include <linux/spinlock.h>
46 #include <linux/list.h>
47 #include <linux/pci.h>
48 #include <linux/timer.h>
49 #include <linux/interrupt.h>
50 #include <linux/workqueue.h>
51 #include <linux/module.h>
52 #include <linux/aio.h>
53 #include <linux/types.h>
56 * error code definition
58 #define ESLOTS_OVERFLOW 1
59 #define ECORRUPTED_MESSAGE_HEADER 1000
60 #define ECOMPLETE_MESSAGE 1001
62 #define HECI_FC_MESSAGE_RESERVED_LENGTH 5
65 * Number of queue lists used by this driver
67 #define HECI_IO_LISTS_NUMBER 7
70 * Maximum transmission unit (MTU) of heci messages
72 #define IAMTHIF_MTU 4160
80 /* H_CB_WW - Host Circular Buffer (CB) Write Window register */
82 /* H_CSR - Host Control Status register */
84 /* ME_CB_RW - ME Circular Buffer Read Window register (read only) */
86 /* ME_CSR_HA - ME Control Status Host Access register (read only) */
90 /* register bits of H_CSR (Host Control Status register) */
91 /* Host Circular Buffer Depth - maximum number of 32-bit entries in CB */
92 #define H_CBD 0xFF000000
93 /* Host Circular Buffer Write Pointer */
94 #define H_CBWP 0x00FF0000
95 /* Host Circular Buffer Read Pointer */
96 #define H_CBRP 0x0000FF00
98 #define H_RST 0x00000010
100 #define H_RDY 0x00000008
101 /* Host Interrupt Generate */
102 #define H_IG 0x00000004
103 /* Host Interrupt Status */
104 #define H_IS 0x00000002
105 /* Host Interrupt Enable */
106 #define H_IE 0x00000001
109 /* register bits of ME_CSR_HA (ME Control Status Host Access register) */
110 /* ME CB (Circular Buffer) Depth HRA (Host Read Access)
111 * - host read only access to ME_CBD */
112 #define ME_CBD_HRA 0xFF000000
113 /* ME CB Write Pointer HRA - host read only access to ME_CBWP */
114 #define ME_CBWP_HRA 0x00FF0000
115 /* ME CB Read Pointer HRA - host read only access to ME_CBRP */
116 #define ME_CBRP_HRA 0x0000FF00
117 /* ME Reset HRA - host read only access to ME_RST */
118 #define ME_RST_HRA 0x00000010
119 /* ME Ready HRA - host read only access to ME_RDY */
120 #define ME_RDY_HRA 0x00000008
121 /* ME Interrupt Generate HRA - host read only access to ME_IG */
122 #define ME_IG_HRA 0x00000004
123 /* ME Interrupt Status HRA - host read only access to ME_IS */
124 #define ME_IS_HRA 0x00000002
125 /* ME Interrupt Enable HRA - host read only access to ME_IE */
126 #define ME_IE_HRA 0x00000001
128 #define HECI_MINORS_BASE 1
129 #define HECI_MINORS_COUNT 1
131 #define HECI_MINOR_NUMBER 1
132 #define HECI_MAX_OPEN_HANDLE_COUNT 253
135 * debug kernel print macro define
137 extern int heci_debug
;
139 #define DBG(format, arg...) do { \
141 printk(KERN_INFO "heci: %s: " format, __func__, ## arg); \
146 * time to wait HECI become ready after init
148 #define HECI_INTEROP_TIMEOUT (HZ * 7)
151 * watch dog definition
153 #define HECI_WATCHDOG_DATA_SIZE 16
154 #define HECI_START_WD_DATA_SIZE 20
155 #define HECI_WD_PARAMS_SIZE 4
156 #define HECI_WD_STATE_INDEPENDENCE_MSG_SENT (1 << 0)
158 #define HECI_WD_HOST_CLIENT_ID 1
159 #define HECI_IAMTHIF_HOST_CLIENT_ID 2
170 HECI_FILE_INITIALIZING
= 0,
171 HECI_FILE_CONNECTING
,
173 HECI_FILE_DISCONNECTING
,
174 HECI_FILE_DISCONNECTED
177 /* HECI device states */
179 HECI_INITIALIZING
= 0,
183 HECI_RECOVERING_FROM_RESET
,
188 enum iamthif_states
{
190 HECI_IAMTHIF_WRITING
,
191 HECI_IAMTHIF_FLOW_CONTROL
,
192 HECI_IAMTHIF_READING
,
193 HECI_IAMTHIF_READ_COMPLETE
196 enum heci_file_transaction_states
{
206 enum heci_cb_major_types
{
214 /* HECI user data struct */
215 struct heci_message_data
{
218 } __attribute__((packed
));
220 #define HECI_CONNECT_TIMEOUT 3 /* at least 2 seconds */
222 #define IAMTHIF_STALL_TIMER 12 /* seconds */
223 #define IAMTHIF_READ_TIMER 15 /* seconds */
225 struct heci_cb_private
{
226 struct list_head cb_list
;
227 enum heci_cb_major_types major_file_operations
;
229 struct heci_message_data request_buffer
;
230 struct heci_message_data response_buffer
;
231 unsigned long information
;
232 unsigned long read_time
;
233 struct file
*file_object
;
236 /* Private file struct */
237 struct heci_file_private
{
238 struct list_head link
;
240 enum file_state state
;
241 wait_queue_head_t tx_wait
;
242 wait_queue_head_t rx_wait
;
243 wait_queue_head_t wait
;
244 spinlock_t file_lock
; /* file lock */
245 spinlock_t read_io_lock
; /* read lock */
246 spinlock_t write_io_lock
; /* write lock */
249 /* ID of client connected */
252 __u8 flow_ctrl_creds
;
254 enum heci_file_transaction_states reading_state
;
255 enum heci_file_transaction_states writing_state
;
257 struct heci_cb_private
*read_cb
;
260 struct io_heci_list
{
261 struct heci_cb_private heci_cb
;
263 struct iamt_heci_device
*device_extension
;
266 struct heci_driver_version
{
271 } __attribute__((packed
));
275 __u32 max_msg_length
;
276 __u8 protocol_version
;
277 } __attribute__((packed
));
280 * HECI BUS Interface Section
282 struct heci_msg_hdr
{
287 __u32 msg_complete
:1;
288 } __attribute__((packed
));
294 } __attribute__((packed
));
297 struct heci_bus_message
{
299 __u8 command_specific_data
[];
300 } __attribute__((packed
));
305 } __attribute__((packed
));
307 struct hbm_host_version_request
{
310 struct hbm_version host_version
;
311 } __attribute__((packed
));
313 struct hbm_host_version_response
{
315 int host_version_supported
;
316 struct hbm_version me_max_version
;
317 } __attribute__((packed
));
319 struct hbm_host_stop_request
{
323 } __attribute__((packed
));
325 struct hbm_host_stop_response
{
328 } __attribute__((packed
));
330 struct hbm_me_stop_request
{
334 } __attribute__((packed
));
336 struct hbm_host_enum_request
{
339 } __attribute__((packed
));
341 struct hbm_host_enum_response
{
344 __u8 valid_addresses
[32];
345 } __attribute__((packed
));
347 struct heci_client_properties
{
348 struct guid protocol_name
;
349 __u8 protocol_version
;
350 __u8 max_number_of_connections
;
352 __u8 single_recv_buf
;
353 __u32 max_msg_length
;
354 } __attribute__((packed
));
356 struct hbm_props_request
{
360 } __attribute__((packed
));
363 struct hbm_props_response
{
368 struct heci_client_properties client_properties
;
369 } __attribute__((packed
));
371 struct hbm_client_connect_request
{
376 } __attribute__((packed
));
378 struct hbm_client_connect_response
{
383 } __attribute__((packed
));
385 struct hbm_client_disconnect_request
{
390 } __attribute__((packed
));
392 struct hbm_flow_control
{
396 __u8 reserved
[HECI_FC_MESSAGE_RESERVED_LENGTH
];
397 } __attribute__((packed
));
399 struct heci_me_client
{
400 struct heci_client_properties props
;
402 __u8 flow_ctrl_creds
;
403 } __attribute__((packed
));
405 /* private device struct */
406 struct iamt_heci_device
{
407 struct pci_dev
*pdev
; /* pointer to pci device struct */
411 /* array of pointers to aio lists */
412 struct io_heci_list
*io_list_array
[HECI_IO_LISTS_NUMBER
];
413 struct io_heci_list read_list
; /* driver read queue */
414 struct io_heci_list write_list
; /* driver write queue */
415 struct io_heci_list write_waiting_list
; /* write waiting queue */
416 struct io_heci_list ctrl_wr_list
; /* managed write IOCTL list */
417 struct io_heci_list ctrl_rd_list
; /* managed read IOCTL list */
418 struct io_heci_list pthi_cmd_list
; /* PTHI list for cmd waiting */
420 /* driver managed PTHI list for reading completed pthi cmd data */
421 struct io_heci_list pthi_read_complete_list
;
425 struct list_head file_list
;
429 unsigned int mem_base
;
430 unsigned int mem_length
;
431 void __iomem
*mem_addr
;
433 * lock for the device
435 spinlock_t device_lock
; /* device lock*/
436 struct work_struct work
;
439 struct task_struct
*reinit_tsk
;
441 struct timer_list wd_timer
;
443 * hw states of host and fw(ME)
448 * waiting queue for receive message from FW
450 wait_queue_head_t wait_recvd_msg
;
451 wait_queue_head_t wait_stop_wd
;
455 enum heci_states heci_state
;
458 __u32 extra_write_index
;
459 __u32 rd_msg_buf
[128]; /* used for control messages */
460 __u32 wr_msg_buf
[128]; /* used for control messages */
461 __u32 ext_msg_buf
[8]; /* for control responses */
464 struct hbm_version version
;
466 int host_buffer_is_empty
;
467 struct heci_file_private wd_file_ext
;
468 struct heci_me_client
*me_clients
; /* Note: memory has to be allocated*/
469 __u8 heci_me_clients
[32]; /* list of existing clients */
470 __u8 num_heci_me_clients
;
471 __u8 heci_host_clients
[32]; /* list of existing clients */
472 __u8 current_host_client_id
;
476 __u16 wd_timeout
; /* seconds ((wd_data[1] << 8) + wd_data[0]) */
477 unsigned char wd_data
[HECI_START_WD_DATA_SIZE
];
480 __u16 wd_due_counter
;
482 int wd_bypass
; /* if 1, don't refresh watchdog ME client */
484 struct file
*iamthif_file_object
;
485 struct heci_file_private iamthif_file_ext
;
487 int iamthif_canceled
;
489 __u32 iamthif_stall_timer
;
490 unsigned char iamthif_msg_buf
[IAMTHIF_MTU
];
491 __u32 iamthif_msg_buf_size
;
492 __u32 iamthif_msg_buf_index
;
493 int iamthif_flow_control_pending
;
494 enum iamthif_states iamthif_state
;
496 struct heci_cb_private
*iamthif_current_cb
;
499 long open_handle_count
;
504 * read_heci_register - Read a byte from the heci device
506 * @dev: the device structure
507 * @offset: offset from which to read the data
509 * returns the byte read.
511 static inline __u32
read_heci_register(struct iamt_heci_device
*dev
,
512 unsigned long offset
)
514 return readl(dev
->mem_addr
+ offset
);
518 * write_heci_register - Write 4 bytes to the heci device
520 * @dev: the device structure
521 * @offset: offset from which to write the data
522 * @value: the byte to write
524 static inline void write_heci_register(struct iamt_heci_device
*dev
,
525 unsigned long offset
, __u32 value
)
527 writel(value
, dev
->mem_addr
+ offset
);
530 #endif /* _HECI_DATA_STRUCTURES_H_ */