[image] Allow for zero embedded images
[people/asdlkf/gpxe.git] / src / drivers / net / mlx_ipoib / cmdif_mt23108.c
1 /*
2   This software is available to you under a choice of one of two
3   licenses.  You may choose to be licensed under the terms of the GNU
4   General Public License (GPL) Version 2, available at
5   <http://www.fsf.org/copyleft/gpl.html>, or the OpenIB.org BSD
6   license, available in the LICENSE.TXT file accompanying this
7   software.  These details are also available at
8   <http://openib.org/license.html>.
9
10   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
11   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
12   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
13   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
14   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
15   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   SOFTWARE.
18
19   Copyright (c) 2004 Mellanox Technologies Ltd.  All rights reserved.
20 */
21 #include "cmdif.h"
22 #include "cmdif_priv.h"
23 #include "mt23108.h"
24
25 /*
26  *  cmd_sys_en
27  */
28 static int cmd_sys_en(void)
29 {
30         int rc;
31         command_fields_t cmd_desc;
32
33         memset(&cmd_desc, 0, sizeof cmd_desc);
34         cmd_desc.opcode = TAVOR_CMD_SYS_EN;
35         rc = cmd_invoke(&cmd_desc);
36
37         return rc;
38 }
39
40 /*
41  *  cmd_sys_dis
42  */
43 static int cmd_sys_dis(void)
44 {
45         int rc;
46         command_fields_t cmd_desc;
47
48         memset(&cmd_desc, 0, sizeof cmd_desc);
49         cmd_desc.in_trans = TRANS_NA;
50         cmd_desc.out_trans = TRANS_NA;
51         cmd_desc.opcode = TAVOR_CMD_SYS_DIS;
52         rc = cmd_invoke(&cmd_desc);
53
54         return rc;
55 }
56
57 /*
58  *  cmd_query_dev_lim
59  */
60 static int cmd_query_dev_lim(struct dev_lim_st *dev_lim_p)
61 {
62         int rc;
63         command_fields_t cmd_desc;
64
65         memset(&cmd_desc, 0, sizeof cmd_desc);
66
67         cmd_desc.opcode = TAVOR_CMD_QUERY_DEV_LIM;
68         cmd_desc.out_trans = TRANS_MAILBOX;
69         cmd_desc.out_param = get_outprm_buf();
70         cmd_desc.out_param_size = MT_STRUCT_SIZE(tavorprm_query_dev_lim_st);
71
72         rc = cmd_invoke(&cmd_desc);
73         if (!rc) {
74                 dev_lim_p->log2_rsvd_qps =
75                     EX_FLD(cmd_desc.out_param, tavorprm_query_dev_lim_st,
76                            log2_rsvd_qps);
77                 dev_lim_p->qpc_entry_sz =
78                     EX_FLD(cmd_desc.out_param, tavorprm_query_dev_lim_st,
79                            qpc_entry_sz);
80
81                 dev_lim_p->log2_rsvd_srqs =
82                     EX_FLD(cmd_desc.out_param, tavorprm_query_dev_lim_st,
83                            log2_rsvd_srqs);
84                 dev_lim_p->srq_entry_sz =
85                     EX_FLD(cmd_desc.out_param, tavorprm_query_dev_lim_st,
86                            srq_entry_sz);
87
88                 dev_lim_p->log2_rsvd_ees =
89                     EX_FLD(cmd_desc.out_param, tavorprm_query_dev_lim_st,
90                            log2_rsvd_ees);
91                 dev_lim_p->eec_entry_sz =
92                     EX_FLD(cmd_desc.out_param, tavorprm_query_dev_lim_st,
93                            eec_entry_sz);
94
95                 dev_lim_p->log2_rsvd_cqs =
96                     EX_FLD(cmd_desc.out_param, tavorprm_query_dev_lim_st,
97                            log2_rsvd_cqs);
98                 dev_lim_p->cqc_entry_sz =
99                     EX_FLD(cmd_desc.out_param, tavorprm_query_dev_lim_st,
100                            cqc_entry_sz);
101
102                 dev_lim_p->log2_rsvd_mtts =
103                     EX_FLD(cmd_desc.out_param, tavorprm_query_dev_lim_st,
104                            log2_rsvd_mtts);
105                 dev_lim_p->mtt_entry_sz = 64;   /* segment size is set to zero in init_hca */
106
107                 dev_lim_p->log2_rsvd_mrws =
108                     EX_FLD(cmd_desc.out_param, tavorprm_query_dev_lim_st,
109                            log2_rsvd_mrws);
110                 dev_lim_p->mpt_entry_sz = MT_STRUCT_SIZE(tavorprm_mpt_st);
111
112                 dev_lim_p->eqc_entry_sz =
113                     EX_FLD(cmd_desc.out_param, tavorprm_query_dev_lim_st,
114                            eqc_entry_sz);
115         }
116
117         return rc;
118 }
119
120 /*
121  *  cmd_write_mgm
122  */
123 static int cmd_write_mgm(void *mg, __u16 index)
124 {
125         int rc;
126         command_fields_t cmd_desc;
127
128         memset(&cmd_desc, 0, sizeof cmd_desc);
129         cmd_desc.opcode = TAVOR_CMD_WRITE_MGM;
130         cmd_desc.in_trans = TRANS_MAILBOX;
131         cmd_desc.in_param_size = MT_STRUCT_SIZE(tavorprm_mgm_entry_st);
132         cmd_desc.in_param = (__u32 *) mg;
133         cmd_desc.input_modifier = index;
134
135         rc = cmd_invoke(&cmd_desc);
136
137         return rc;
138 }
139
140 /*
141  *  cmd_mod_stat_cfg
142  */
143 static int cmd_mod_stat_cfg(void *cfg)
144 {
145         int rc;
146         command_fields_t cmd_desc;
147
148         memset(&cmd_desc, 0, sizeof cmd_desc);
149         cmd_desc.opcode = TAVOR_CMD_MOD_STAT_CFG;
150         cmd_desc.in_trans = TRANS_MAILBOX;
151         cmd_desc.in_param_size = MT_STRUCT_SIZE(tavorprm_mod_stat_cfg_st);
152         cmd_desc.in_param = (__u32 *) cfg;
153
154         rc = cmd_invoke(&cmd_desc);
155
156         return rc;
157 }
158
159
160 /*
161  *  cmd_query_fw
162  */
163 static int cmd_query_fw(struct query_fw_st *qfw)
164 {
165         int rc;
166         command_fields_t cmd_desc;
167
168         memset(&cmd_desc, 0, sizeof cmd_desc);
169
170         cmd_desc.opcode = TAVOR_CMD_QUERY_FW;
171         cmd_desc.out_trans = TRANS_MAILBOX;
172         cmd_desc.out_param = get_outprm_buf();
173         cmd_desc.out_param_size = MT_STRUCT_SIZE(tavorprm_query_fw_st);
174
175         rc = cmd_invoke(&cmd_desc);
176         if (!rc) {
177                 qfw->fw_rev_major =
178                     EX_FLD(cmd_desc.out_param, tavorprm_query_fw_st, fw_rev_major);
179                 qfw->fw_rev_minor =
180                     EX_FLD(cmd_desc.out_param, tavorprm_query_fw_st, fw_rev_minor);
181                 qfw->fw_rev_subminor =
182                     EX_FLD(cmd_desc.out_param, tavorprm_query_fw_st, fw_rev_subminor);
183
184                 qfw->error_buf_start_h =
185                     EX_FLD(cmd_desc.out_param, tavorprm_query_fw_st, error_buf_start_h);
186                 qfw->error_buf_start_l =
187                     EX_FLD(cmd_desc.out_param, tavorprm_query_fw_st, error_buf_start_l);
188                 qfw->error_buf_size =
189                     EX_FLD(cmd_desc.out_param, tavorprm_query_fw_st, error_buf_size);
190         }
191
192         return rc;
193 }