xref: /titanic_50/usr/src/uts/common/io/bnxe/577xx/hsi/mcp/multi_thread_def.h (revision d14abf155341d55053c76eeec58b787a456b753b)
1 /****************************************************************************
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  *
21  * Copyright 2014 QLogic Corporation
22  * The contents of this file are subject to the terms of the
23  * QLogic End User License (the "License").
24  * You may not use this file except in compliance with the License.
25  *
26  * You can obtain a copy of the License at
27  * http://www.qlogic.com/Resources/Documents/DriverDownloadHelp/
28  * QLogic_End_User_Software_License.txt
29  * See the License for the specific language governing permissions
30  * and limitations under the License.
31  *
32  *
33  * Name:        mcp_multi_thread.h
34  *
35  * Description: Multi-thread definition and structures
36  *
37  * Created:     10 Oct 2011 yanivr
38  ****************************************************************************/
39 
40 /****************************************************************************
41  * Include                                                                  *
42  ****************************************************************************/
43 #ifndef MULTI_THREAD_DEF_H
44 #define MULTI_THREAD_DEF_H
45 
46 #define MAX_THREAD_QUEUE 16
47 #define THREAD_STACK_SIZE 1500
48 #define STACK_FILL 0xbadbeef
49 
50 typedef enum  {
51 	MISC_THREAD,
52 	LINK_THREAD,
53 	NET_THREAD,
54 	OCSD_THREAD,
55 	NUM_THREADS
56 }thread_name_e;
57 
58 // This enum is  just for the complete picture.
59 // The running thread knows it is running so the only interesting state is the SLEEPING one
60 
61 typedef enum {
62 	IDLE,
63 	RUNNING,
64 	SLEEPING
65 }thread_state_e;
66 
67 typedef struct papo_arg_t {
68 	u16 path;
69 	u16 port;
70 } papo_t;
71 
72 struct eeprom_arg_t {
73 	u16 pf_num;
74 	u16 is_specific_phy;
75        u32 io_rsp; /* The response to write */
76 };
77 
78 struct task_t {
79 	u16 op_id;
80 	u16 entry_count;
81 	union {
82 		struct papo_arg_t	papo;
83 		struct eeprom_arg_t	eeprom;
84 	}args;
85 };
86 
87 struct tasks_queue_t {
88 	struct 	task_t task[MAX_THREAD_QUEUE]; /* The request queue. */
89 	u32 front;            /* For de-queue */
90 	u32 rear;             /* For queuing */
91 	u32 attributes;
92 #define TASK_ALWAYS_QUEUED 	(1<<0)
93 };
94 
95 #ifdef MFW
96 typedef u8 (* THREAD_FUNC_PTR)    (struct task_t *i_task);
97 #else
98 #define THREAD_FUNC_PTR u32
99 #endif
100 
101 struct mt_thread_stat {
102 	u32 total_cpu_time;
103 	u32 times_in_cpu;
104 	u32 going_to_sleep_count;
105 	u32 waking_up_count;
106 	u32 swim_failure_cnt;
107 	u32 swim_failure_timeout_cnt;
108 };
109 
110 struct thread_t {
111 	u32 current_SP;            /* Current_SP will be initialized as the start of stack */
112 	u32 stack_guard_addr;
113 	THREAD_FUNC_PTR main_func; /* Entry point to the thread. */
114 	u32 start_time;            /* The time that the thread started to run */
115 	u32 time_slice_ticks;      /* Const value initialized once during compilation (only for the Network Manager) */
116 	u32 /* thread_state_e*/  state;
117 	u32 sleep_time;            /* In ticks */
118 	u32 sleep_length;          /* In ticks */
119 	u32 swim_load_fail_time;
120 	struct tasks_queue_t queue;
121 	struct mt_thread_stat stat;
122 };
123 
124 struct scheduler_stat_t {
125 	u32 times_called;
126 };
127 
128 struct scheduler_t {
129 	u32 cur_thread;
130 	struct scheduler_stat_t stat;
131 };
132 
133 // Main structure
134 struct multi_thread_t {
135 	struct thread_t thread[NUM_THREADS];
136 	struct scheduler_t sched;
137 };
138 
139 #endif // MULTI_THREAD_DEF_H
140