This source file includes following definitions.
- set_mgmt_allowed
- add_full_mgmt_pkey
- format_hwmsg
- hfi1_format_hwerrors
- signal_ib_event
- handle_linkup_change
- handle_user_interrupt
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 #include <linux/pci.h>
49 #include <linux/delay.h>
50 #include <linux/bitmap.h>
51
52 #include "hfi.h"
53 #include "common.h"
54 #include "sdma.h"
55
56 #define LINK_UP_DELAY 500
57
58 static void set_mgmt_allowed(struct hfi1_pportdata *ppd)
59 {
60 u32 frame;
61 struct hfi1_devdata *dd = ppd->dd;
62
63 if (ppd->neighbor_type == NEIGHBOR_TYPE_HFI) {
64 ppd->mgmt_allowed = 1;
65 } else {
66 read_8051_config(dd, REMOTE_LNI_INFO, GENERAL_CONFIG, &frame);
67 ppd->mgmt_allowed = (frame >> MGMT_ALLOWED_SHIFT)
68 & MGMT_ALLOWED_MASK;
69 }
70 }
71
72
73
74
75
76
77
78
79 static void add_full_mgmt_pkey(struct hfi1_pportdata *ppd)
80 {
81 struct hfi1_devdata *dd = ppd->dd;
82
83
84 if (!((ppd->pkeys[2] == 0) || (ppd->pkeys[2] == FULL_MGMT_P_KEY)))
85 dd_dev_warn(dd, "%s pkey[2] already set to 0x%x, resetting it to 0x%x\n",
86 __func__, ppd->pkeys[2], FULL_MGMT_P_KEY);
87 ppd->pkeys[2] = FULL_MGMT_P_KEY;
88 (void)hfi1_set_ib_cfg(ppd, HFI1_IB_CFG_PKEYS, 0);
89 hfi1_event_pkey_change(ppd->dd, ppd->port);
90 }
91
92
93
94
95
96
97
98 static void format_hwmsg(char *msg, size_t msgl, const char *hwmsg)
99 {
100 strlcat(msg, "[", msgl);
101 strlcat(msg, hwmsg, msgl);
102 strlcat(msg, "]", msgl);
103 }
104
105
106
107
108
109
110
111
112
113 void hfi1_format_hwerrors(u64 hwerrs, const struct hfi1_hwerror_msgs *hwerrmsgs,
114 size_t nhwerrmsgs, char *msg, size_t msgl)
115 {
116 int i;
117
118 for (i = 0; i < nhwerrmsgs; i++)
119 if (hwerrs & hwerrmsgs[i].mask)
120 format_hwmsg(msg, msgl, hwerrmsgs[i].msg);
121 }
122
123 static void signal_ib_event(struct hfi1_pportdata *ppd, enum ib_event_type ev)
124 {
125 struct ib_event event;
126 struct hfi1_devdata *dd = ppd->dd;
127
128
129
130
131
132
133 if (!(dd->flags & HFI1_INITTED))
134 return;
135 event.device = &dd->verbs_dev.rdi.ibdev;
136 event.element.port_num = ppd->port;
137 event.event = ev;
138 ib_dispatch_event(&event);
139 }
140
141
142
143
144
145
146
147
148
149
150
151
152 void handle_linkup_change(struct hfi1_devdata *dd, u32 linkup)
153 {
154 struct hfi1_pportdata *ppd = &dd->pport[0];
155 enum ib_event_type ev;
156
157 if (!(ppd->linkup ^ !!linkup))
158 return;
159
160 if (linkup) {
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175 if (quick_linkup || dd->icode == ICODE_FUNCTIONAL_SIMULATOR) {
176 set_up_vau(dd, dd->vau);
177 set_up_vl15(dd, dd->vl15_init);
178 assign_remote_cm_au_table(dd, dd->vcu);
179 }
180
181 ppd->neighbor_guid =
182 read_csr(dd, DC_DC8051_STS_REMOTE_GUID);
183 ppd->neighbor_type =
184 read_csr(dd, DC_DC8051_STS_REMOTE_NODE_TYPE) &
185 DC_DC8051_STS_REMOTE_NODE_TYPE_VAL_MASK;
186 ppd->neighbor_port_number =
187 read_csr(dd, DC_DC8051_STS_REMOTE_PORT_NO) &
188 DC_DC8051_STS_REMOTE_PORT_NO_VAL_SMASK;
189 ppd->neighbor_fm_security =
190 read_csr(dd, DC_DC8051_STS_REMOTE_FM_SECURITY) &
191 DC_DC8051_STS_LOCAL_FM_SECURITY_DISABLED_MASK;
192 dd_dev_info(dd,
193 "Neighbor Guid %llx, Type %d, Port Num %d\n",
194 ppd->neighbor_guid, ppd->neighbor_type,
195 ppd->neighbor_port_number);
196
197
198 udelay(LINK_UP_DELAY);
199
200
201
202
203
204 set_mgmt_allowed(ppd);
205
206 if (ppd->mgmt_allowed)
207 add_full_mgmt_pkey(ppd);
208
209
210 ppd->linkup = 1;
211 ppd->offline_disabled_reason =
212 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_NONE);
213
214
215 get_linkup_link_widths(ppd);
216
217 } else {
218
219 ppd->linkup = 0;
220
221
222 ppd->actual_vls_operational = 0;
223 reset_link_credits(dd);
224
225
226 start_freeze_handling(ppd, FREEZE_SELF | FREEZE_LINK_DOWN);
227
228 ev = IB_EVENT_PORT_ERR;
229
230 hfi1_set_uevent_bits(ppd, _HFI1_EVENT_LINKDOWN_BIT);
231
232
233 ppd->neighbor_normal = 0;
234
235
236 signal_ib_event(ppd, ev);
237 }
238 }
239
240
241
242
243
244 void handle_user_interrupt(struct hfi1_ctxtdata *rcd)
245 {
246 struct hfi1_devdata *dd = rcd->dd;
247 unsigned long flags;
248
249 spin_lock_irqsave(&dd->uctxt_lock, flags);
250 if (bitmap_empty(rcd->in_use_ctxts, HFI1_MAX_SHARED_CTXTS))
251 goto done;
252
253 if (test_and_clear_bit(HFI1_CTXT_WAITING_RCV, &rcd->event_flags)) {
254 wake_up_interruptible(&rcd->wait);
255 hfi1_rcvctrl(dd, HFI1_RCVCTRL_INTRAVAIL_DIS, rcd);
256 } else if (test_and_clear_bit(HFI1_CTXT_WAITING_URG,
257 &rcd->event_flags)) {
258 rcd->urgent++;
259 wake_up_interruptible(&rcd->wait);
260 }
261 done:
262 spin_unlock_irqrestore(&dd->uctxt_lock, flags);
263 }