blob: 4dbadf77f01d533d07df63145c9174e35f7325e7 [file] [log] [blame]
Mike Marciniszyn77241052015-07-30 15:17:43 -04001/*
Jubin John05d6ac12016-02-14 20:22:17 -08002 * Copyright(c) 2015, 2016 Intel Corporation.
Mike Marciniszyn77241052015-07-30 15:17:43 -04003 *
4 * This file is provided under a dual BSD/GPLv2 license. When using or
5 * redistributing this file, you may do so under either license.
6 *
7 * GPL LICENSE SUMMARY
8 *
Mike Marciniszyn77241052015-07-30 15:17:43 -04009 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * BSD LICENSE
19 *
Mike Marciniszyn77241052015-07-30 15:17:43 -040020 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions
22 * are met:
23 *
24 * - Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * - Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in
28 * the documentation and/or other materials provided with the
29 * distribution.
30 * - Neither the name of Intel Corporation nor the names of its
31 * contributors may be used to endorse or promote products derived
32 * from this software without specific prior written permission.
33 *
34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
37 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
38 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
41 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
42 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
43 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
44 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 *
46 */
47
48#include <linux/spinlock.h>
49#include <linux/pci.h>
50#include <linux/io.h>
51#include <linux/delay.h>
52#include <linux/netdevice.h>
53#include <linux/vmalloc.h>
54#include <linux/module.h>
55#include <linux/prefetch.h>
Dennis Dalessandro8859b4a2016-01-19 14:42:11 -080056#include <rdma/ib_verbs.h>
Mike Marciniszyn77241052015-07-30 15:17:43 -040057
58#include "hfi.h"
59#include "trace.h"
60#include "qp.h"
61#include "sdma.h"
62
63#undef pr_fmt
64#define pr_fmt(fmt) DRIVER_NAME ": " fmt
65
66/*
67 * The size has to be longer than this string, so we can append
68 * board/chip information to it in the initialization code.
69 */
70const char ib_hfi1_version[] = HFI1_DRIVER_VERSION "\n";
71
72DEFINE_SPINLOCK(hfi1_devs_lock);
73LIST_HEAD(hfi1_dev_list);
74DEFINE_MUTEX(hfi1_mutex); /* general driver use */
75
76unsigned int hfi1_max_mtu = HFI1_DEFAULT_MAX_MTU;
77module_param_named(max_mtu, hfi1_max_mtu, uint, S_IRUGO);
Sebastian Sanchezef699e82016-04-12 11:17:09 -070078MODULE_PARM_DESC(max_mtu, "Set max MTU bytes, default is " __stringify(
79 HFI1_DEFAULT_MAX_MTU));
Mike Marciniszyn77241052015-07-30 15:17:43 -040080
81unsigned int hfi1_cu = 1;
82module_param_named(cu, hfi1_cu, uint, S_IRUGO);
83MODULE_PARM_DESC(cu, "Credit return units");
84
85unsigned long hfi1_cap_mask = HFI1_CAP_MASK_DEFAULT;
86static int hfi1_caps_set(const char *, const struct kernel_param *);
87static int hfi1_caps_get(char *, const struct kernel_param *);
88static const struct kernel_param_ops cap_ops = {
89 .set = hfi1_caps_set,
90 .get = hfi1_caps_get
91};
92module_param_cb(cap_mask, &cap_ops, &hfi1_cap_mask, S_IWUSR | S_IRUGO);
93MODULE_PARM_DESC(cap_mask, "Bit mask of enabled/disabled HW features");
94
95MODULE_LICENSE("Dual BSD/GPL");
96MODULE_DESCRIPTION("Intel Omni-Path Architecture driver");
97MODULE_VERSION(HFI1_DRIVER_VERSION);
98
99/*
100 * MAX_PKT_RCV is the max # if packets processed per receive interrupt.
101 */
102#define MAX_PKT_RECV 64
103#define EGR_HEAD_UPDATE_THRESHOLD 16
104
105struct hfi1_ib_stats hfi1_stats;
106
107static int hfi1_caps_set(const char *val, const struct kernel_param *kp)
108{
109 int ret = 0;
110 unsigned long *cap_mask_ptr = (unsigned long *)kp->arg,
111 cap_mask = *cap_mask_ptr, value, diff,
112 write_mask = ((HFI1_CAP_WRITABLE_MASK << HFI1_CAP_USER_SHIFT) |
113 HFI1_CAP_WRITABLE_MASK);
114
115 ret = kstrtoul(val, 0, &value);
116 if (ret) {
117 pr_warn("Invalid module parameter value for 'cap_mask'\n");
118 goto done;
119 }
120 /* Get the changed bits (except the locked bit) */
121 diff = value ^ (cap_mask & ~HFI1_CAP_LOCKED_SMASK);
122
123 /* Remove any bits that are not allowed to change after driver load */
124 if (HFI1_CAP_LOCKED() && (diff & ~write_mask)) {
125 pr_warn("Ignoring non-writable capability bits %#lx\n",
126 diff & ~write_mask);
127 diff &= write_mask;
128 }
129
130 /* Mask off any reserved bits */
131 diff &= ~HFI1_CAP_RESERVED_MASK;
132 /* Clear any previously set and changing bits */
133 cap_mask &= ~diff;
134 /* Update the bits with the new capability */
135 cap_mask |= (value & diff);
136 /* Check for any kernel/user restrictions */
137 diff = (cap_mask & (HFI1_CAP_MUST_HAVE_KERN << HFI1_CAP_USER_SHIFT)) ^
138 ((cap_mask & HFI1_CAP_MUST_HAVE_KERN) << HFI1_CAP_USER_SHIFT);
139 cap_mask &= ~diff;
140 /* Set the bitmask to the final set */
141 *cap_mask_ptr = cap_mask;
142done:
143 return ret;
144}
145
146static int hfi1_caps_get(char *buffer, const struct kernel_param *kp)
147{
148 unsigned long cap_mask = *(unsigned long *)kp->arg;
149
150 cap_mask &= ~HFI1_CAP_LOCKED_SMASK;
151 cap_mask |= ((cap_mask & HFI1_CAP_K2U) << HFI1_CAP_USER_SHIFT);
152
153 return scnprintf(buffer, PAGE_SIZE, "0x%lx", cap_mask);
154}
155
156const char *get_unit_name(int unit)
157{
158 static char iname[16];
159
Jubin John98050712015-11-16 21:59:27 -0500160 snprintf(iname, sizeof(iname), DRIVER_NAME "_%u", unit);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400161 return iname;
162}
163
Dennis Dalessandro49dbb6c2016-01-19 14:42:06 -0800164const char *get_card_name(struct rvt_dev_info *rdi)
165{
166 struct hfi1_ibdev *ibdev = container_of(rdi, struct hfi1_ibdev, rdi);
167 struct hfi1_devdata *dd = container_of(ibdev,
168 struct hfi1_devdata, verbs_dev);
169 return get_unit_name(dd->unit);
170}
171
172struct pci_dev *get_pci_dev(struct rvt_dev_info *rdi)
173{
174 struct hfi1_ibdev *ibdev = container_of(rdi, struct hfi1_ibdev, rdi);
175 struct hfi1_devdata *dd = container_of(ibdev,
176 struct hfi1_devdata, verbs_dev);
177 return dd->pcidev;
178}
179
Mike Marciniszyn77241052015-07-30 15:17:43 -0400180/*
181 * Return count of units with at least one port ACTIVE.
182 */
183int hfi1_count_active_units(void)
184{
185 struct hfi1_devdata *dd;
186 struct hfi1_pportdata *ppd;
187 unsigned long flags;
188 int pidx, nunits_active = 0;
189
190 spin_lock_irqsave(&hfi1_devs_lock, flags);
191 list_for_each_entry(dd, &hfi1_dev_list, list) {
192 if (!(dd->flags & HFI1_PRESENT) || !dd->kregbase)
193 continue;
194 for (pidx = 0; pidx < dd->num_pports; ++pidx) {
195 ppd = dd->pport + pidx;
196 if (ppd->lid && ppd->linkup) {
197 nunits_active++;
198 break;
199 }
200 }
201 }
202 spin_unlock_irqrestore(&hfi1_devs_lock, flags);
203 return nunits_active;
204}
205
206/*
207 * Return count of all units, optionally return in arguments
208 * the number of usable (present) units, and the number of
209 * ports that are up.
210 */
211int hfi1_count_units(int *npresentp, int *nupp)
212{
213 int nunits = 0, npresent = 0, nup = 0;
214 struct hfi1_devdata *dd;
215 unsigned long flags;
216 int pidx;
217 struct hfi1_pportdata *ppd;
218
219 spin_lock_irqsave(&hfi1_devs_lock, flags);
220
221 list_for_each_entry(dd, &hfi1_dev_list, list) {
222 nunits++;
223 if ((dd->flags & HFI1_PRESENT) && dd->kregbase)
224 npresent++;
225 for (pidx = 0; pidx < dd->num_pports; ++pidx) {
226 ppd = dd->pport + pidx;
227 if (ppd->lid && ppd->linkup)
228 nup++;
229 }
230 }
231
232 spin_unlock_irqrestore(&hfi1_devs_lock, flags);
233
234 if (npresentp)
235 *npresentp = npresent;
236 if (nupp)
237 *nupp = nup;
238
239 return nunits;
240}
241
242/*
243 * Get address of eager buffer from it's index (allocated in chunks, not
244 * contiguous).
245 */
246static inline void *get_egrbuf(const struct hfi1_ctxtdata *rcd, u64 rhf,
247 u8 *update)
248{
249 u32 idx = rhf_egr_index(rhf), offset = rhf_egr_buf_offset(rhf);
250
251 *update |= !(idx & (rcd->egrbufs.threshold - 1)) && !offset;
252 return (void *)(((u64)(rcd->egrbufs.rcvtids[idx].addr)) +
253 (offset * RCV_BUF_BLOCK_SIZE));
254}
255
256/*
257 * Validate and encode the a given RcvArray Buffer size.
258 * The function will check whether the given size falls within
259 * allowed size ranges for the respective type and, optionally,
260 * return the proper encoding.
261 */
262inline int hfi1_rcvbuf_validate(u32 size, u8 type, u16 *encoded)
263{
Amitoj Kaur Chawlaf5389662016-03-04 22:40:17 +0530264 if (unlikely(!PAGE_ALIGNED(size)))
Mike Marciniszyn77241052015-07-30 15:17:43 -0400265 return 0;
266 if (unlikely(size < MIN_EAGER_BUFFER))
267 return 0;
268 if (size >
269 (type == PT_EAGER ? MAX_EAGER_BUFFER : MAX_EXPECTED_BUFFER))
270 return 0;
271 if (encoded)
272 *encoded = ilog2(size / PAGE_SIZE) + 1;
273 return 1;
274}
275
276static void rcv_hdrerr(struct hfi1_ctxtdata *rcd, struct hfi1_pportdata *ppd,
277 struct hfi1_packet *packet)
278{
279 struct hfi1_message_header *rhdr = packet->hdr;
280 u32 rte = rhf_rcv_type_err(packet->rhf);
281 int lnh = be16_to_cpu(rhdr->lrh[0]) & 3;
282 struct hfi1_ibport *ibp = &ppd->ibport_data;
Dennis Dalessandroec4274f2016-01-19 14:43:44 -0800283 struct hfi1_devdata *dd = ppd->dd;
284 struct rvt_dev_info *rdi = &dd->verbs_dev.rdi;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400285
286 if (packet->rhf & (RHF_VCRC_ERR | RHF_ICRC_ERR))
287 return;
288
289 if (packet->rhf & RHF_TID_ERR) {
290 /* For TIDERR and RC QPs preemptively schedule a NAK */
291 struct hfi1_ib_header *hdr = (struct hfi1_ib_header *)rhdr;
292 struct hfi1_other_headers *ohdr = NULL;
293 u32 tlen = rhf_pkt_len(packet->rhf); /* in bytes */
294 u16 lid = be16_to_cpu(hdr->lrh[1]);
295 u32 qp_num;
296 u32 rcv_flags = 0;
297
298 /* Sanity check packet */
299 if (tlen < 24)
300 goto drop;
301
302 /* Check for GRH */
Jubin Johne4909742016-02-14 20:22:00 -0800303 if (lnh == HFI1_LRH_BTH) {
Mike Marciniszyn77241052015-07-30 15:17:43 -0400304 ohdr = &hdr->u.oth;
Jubin Johne4909742016-02-14 20:22:00 -0800305 } else if (lnh == HFI1_LRH_GRH) {
Mike Marciniszyn77241052015-07-30 15:17:43 -0400306 u32 vtf;
307
308 ohdr = &hdr->u.l.oth;
309 if (hdr->u.l.grh.next_hdr != IB_GRH_NEXT_HDR)
310 goto drop;
311 vtf = be32_to_cpu(hdr->u.l.grh.version_tclass_flow);
312 if ((vtf >> IB_GRH_VERSION_SHIFT) != IB_GRH_VERSION)
313 goto drop;
314 rcv_flags |= HFI1_HAS_GRH;
Jubin Johne4909742016-02-14 20:22:00 -0800315 } else {
Mike Marciniszyn77241052015-07-30 15:17:43 -0400316 goto drop;
Jubin Johne4909742016-02-14 20:22:00 -0800317 }
Mike Marciniszyn77241052015-07-30 15:17:43 -0400318 /* Get the destination QP number. */
Dennis Dalessandroec4274f2016-01-19 14:43:44 -0800319 qp_num = be32_to_cpu(ohdr->bth[1]) & RVT_QPN_MASK;
Dennis Dalessandro8859b4a2016-01-19 14:42:11 -0800320 if (lid < be16_to_cpu(IB_MULTICAST_LID_BASE)) {
Dennis Dalessandro895420d2016-01-19 14:42:28 -0800321 struct rvt_qp *qp;
Dean Luickb77d7132015-10-26 10:28:43 -0400322 unsigned long flags;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400323
324 rcu_read_lock();
Dennis Dalessandroec4274f2016-01-19 14:43:44 -0800325 qp = rvt_lookup_qpn(rdi, &ibp->rvp, qp_num);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400326 if (!qp) {
327 rcu_read_unlock();
328 goto drop;
329 }
330
331 /*
332 * Handle only RC QPs - for other QP types drop error
333 * packet.
334 */
Dean Luickb77d7132015-10-26 10:28:43 -0400335 spin_lock_irqsave(&qp->r_lock, flags);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400336
337 /* Check for valid receive state. */
Dennis Dalessandro83693bd2016-01-19 14:43:33 -0800338 if (!(ib_rvt_state_ops[qp->state] &
339 RVT_PROCESS_RECV_OK)) {
Dennis Dalessandro4eb06882016-01-19 14:42:39 -0800340 ibp->rvp.n_pkt_drops++;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400341 }
342
343 switch (qp->ibqp.qp_type) {
344 case IB_QPT_RC:
345 hfi1_rc_hdrerr(
346 rcd,
347 hdr,
348 rcv_flags,
349 qp);
350 break;
351 default:
352 /* For now don't handle any other QP types */
353 break;
354 }
355
Dean Luickb77d7132015-10-26 10:28:43 -0400356 spin_unlock_irqrestore(&qp->r_lock, flags);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400357 rcu_read_unlock();
358 } /* Unicast QP */
359 } /* Valid packet with TIDErr */
360
361 /* handle "RcvTypeErr" flags */
362 switch (rte) {
363 case RHF_RTE_ERROR_OP_CODE_ERR:
364 {
365 u32 opcode;
366 void *ebuf = NULL;
367 __be32 *bth = NULL;
368
369 if (rhf_use_egr_bfr(packet->rhf))
370 ebuf = packet->ebuf;
371
Jubin Johnd125a6c2016-02-14 20:19:49 -0800372 if (!ebuf)
Mike Marciniszyn77241052015-07-30 15:17:43 -0400373 goto drop; /* this should never happen */
374
375 if (lnh == HFI1_LRH_BTH)
376 bth = (__be32 *)ebuf;
377 else if (lnh == HFI1_LRH_GRH)
378 bth = (__be32 *)((char *)ebuf + sizeof(struct ib_grh));
379 else
380 goto drop;
381
382 opcode = be32_to_cpu(bth[0]) >> 24;
383 opcode &= 0xff;
384
385 if (opcode == IB_OPCODE_CNP) {
386 /*
387 * Only in pre-B0 h/w is the CNP_OPCODE handled
Edward Mascarenhas80e48982015-12-21 21:57:44 -0500388 * via this code path.
Mike Marciniszyn77241052015-07-30 15:17:43 -0400389 */
Dennis Dalessandro895420d2016-01-19 14:42:28 -0800390 struct rvt_qp *qp = NULL;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400391 u32 lqpn, rqpn;
392 u16 rlid;
393 u8 svc_type, sl, sc5;
394
395 sc5 = (be16_to_cpu(rhdr->lrh[0]) >> 12) & 0xf;
396 if (rhf_dc_info(packet->rhf))
397 sc5 |= 0x10;
398 sl = ibp->sc_to_sl[sc5];
399
Dennis Dalessandroec4274f2016-01-19 14:43:44 -0800400 lqpn = be32_to_cpu(bth[1]) & RVT_QPN_MASK;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400401 rcu_read_lock();
Dennis Dalessandroec4274f2016-01-19 14:43:44 -0800402 qp = rvt_lookup_qpn(rdi, &ibp->rvp, lqpn);
Jubin Johnd125a6c2016-02-14 20:19:49 -0800403 if (!qp) {
Mike Marciniszyn77241052015-07-30 15:17:43 -0400404 rcu_read_unlock();
405 goto drop;
406 }
407
408 switch (qp->ibqp.qp_type) {
409 case IB_QPT_UD:
410 rlid = 0;
411 rqpn = 0;
412 svc_type = IB_CC_SVCTYPE_UD;
413 break;
414 case IB_QPT_UC:
415 rlid = be16_to_cpu(rhdr->lrh[3]);
416 rqpn = qp->remote_qpn;
417 svc_type = IB_CC_SVCTYPE_UC;
418 break;
419 default:
420 goto drop;
421 }
422
423 process_becn(ppd, sl, rlid, lqpn, rqpn, svc_type);
424 rcu_read_unlock();
425 }
426
427 packet->rhf &= ~RHF_RCV_TYPE_ERR_SMASK;
428 break;
429 }
430 default:
431 break;
432 }
433
434drop:
435 return;
436}
437
438static inline void init_packet(struct hfi1_ctxtdata *rcd,
Jubin John17fb4f22016-02-14 20:21:52 -0800439 struct hfi1_packet *packet)
Mike Marciniszyn77241052015-07-30 15:17:43 -0400440{
Mike Marciniszyn77241052015-07-30 15:17:43 -0400441 packet->rsize = rcd->rcvhdrqentsize; /* words */
442 packet->maxcnt = rcd->rcvhdrq_cnt * packet->rsize; /* words */
443 packet->rcd = rcd;
444 packet->updegr = 0;
445 packet->etail = -1;
Dean Luickf4f30031c2015-10-26 10:28:44 -0400446 packet->rhf_addr = get_rhf_addr(rcd);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400447 packet->rhf = rhf_to_cpu(packet->rhf_addr);
448 packet->rhqoff = rcd->head;
449 packet->numpkt = 0;
450 packet->rcv_flags = 0;
451}
452
Mitko Haralanov5fd2b562016-07-25 13:38:07 -0700453void hfi1_process_ecn_slowpath(struct rvt_qp *qp, struct hfi1_packet *pkt,
454 bool do_cnp)
Mike Marciniszyn77241052015-07-30 15:17:43 -0400455{
456 struct hfi1_ibport *ibp = to_iport(qp->ibqp.device, qp->port_num);
Mitko Haralanov5fd2b562016-07-25 13:38:07 -0700457 struct hfi1_ib_header *hdr = pkt->hdr;
458 struct hfi1_other_headers *ohdr = pkt->ohdr;
459 struct ib_grh *grh = NULL;
460 u32 rqpn = 0, bth1;
461 u16 rlid, dlid = be16_to_cpu(hdr->lrh[1]);
462 u8 sc, svc_type;
463 bool is_mcast = false;
464
465 if (pkt->rcv_flags & HFI1_HAS_GRH)
466 grh = &hdr->u.l.grh;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400467
468 switch (qp->ibqp.qp_type) {
Arthur Kepner977940b2015-11-04 21:10:10 -0500469 case IB_QPT_SMI:
470 case IB_QPT_GSI:
Mike Marciniszyn77241052015-07-30 15:17:43 -0400471 case IB_QPT_UD:
Arthur Kepner977940b2015-11-04 21:10:10 -0500472 rlid = be16_to_cpu(hdr->lrh[3]);
Dennis Dalessandroec4274f2016-01-19 14:43:44 -0800473 rqpn = be32_to_cpu(ohdr->u.ud.deth[1]) & RVT_QPN_MASK;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400474 svc_type = IB_CC_SVCTYPE_UD;
Mitko Haralanov5fd2b562016-07-25 13:38:07 -0700475 is_mcast = (dlid > be16_to_cpu(IB_MULTICAST_LID_BASE)) &&
476 (dlid != be16_to_cpu(IB_LID_PERMISSIVE));
Mike Marciniszyn77241052015-07-30 15:17:43 -0400477 break;
Arthur Kepner977940b2015-11-04 21:10:10 -0500478 case IB_QPT_UC:
479 rlid = qp->remote_ah_attr.dlid;
480 rqpn = qp->remote_qpn;
481 svc_type = IB_CC_SVCTYPE_UC;
482 break;
483 case IB_QPT_RC:
484 rlid = qp->remote_ah_attr.dlid;
485 rqpn = qp->remote_qpn;
486 svc_type = IB_CC_SVCTYPE_RC;
487 break;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400488 default:
489 return;
490 }
491
Mitko Haralanov5fd2b562016-07-25 13:38:07 -0700492 sc = hdr2sc((struct hfi1_message_header *)hdr, pkt->rhf);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400493
Mitko Haralanov5fd2b562016-07-25 13:38:07 -0700494 bth1 = be32_to_cpu(ohdr->bth[1]);
495 if (do_cnp && (bth1 & HFI1_FECN_SMASK)) {
Mike Marciniszyn77241052015-07-30 15:17:43 -0400496 u16 pkey = (u16)be32_to_cpu(ohdr->bth[0]);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400497
Mitko Haralanov5fd2b562016-07-25 13:38:07 -0700498 return_cnp(ibp, qp, rqpn, pkey, dlid, rlid, sc, grh);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400499 }
500
Mitko Haralanov5fd2b562016-07-25 13:38:07 -0700501 if (!is_mcast && (bth1 & HFI1_BECN_SMASK)) {
Mike Marciniszyn77241052015-07-30 15:17:43 -0400502 struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
Dennis Dalessandroec4274f2016-01-19 14:43:44 -0800503 u32 lqpn = bth1 & RVT_QPN_MASK;
Mitko Haralanov5fd2b562016-07-25 13:38:07 -0700504 u8 sl = ibp->sc_to_sl[sc];
Mike Marciniszyn77241052015-07-30 15:17:43 -0400505
Arthur Kepner977940b2015-11-04 21:10:10 -0500506 process_becn(ppd, sl, rlid, lqpn, rqpn, svc_type);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400507 }
Mitko Haralanov5fd2b562016-07-25 13:38:07 -0700508
Mike Marciniszyn77241052015-07-30 15:17:43 -0400509}
510
511struct ps_mdata {
512 struct hfi1_ctxtdata *rcd;
513 u32 rsize;
514 u32 maxcnt;
515 u32 ps_head;
516 u32 ps_tail;
517 u32 ps_seq;
518};
519
520static inline void init_ps_mdata(struct ps_mdata *mdata,
521 struct hfi1_packet *packet)
522{
523 struct hfi1_ctxtdata *rcd = packet->rcd;
524
525 mdata->rcd = rcd;
526 mdata->rsize = packet->rsize;
527 mdata->maxcnt = packet->maxcnt;
Arthur Kepner3e7ccca2015-11-04 21:10:09 -0500528 mdata->ps_head = packet->rhqoff;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400529
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -0500530 if (HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL)) {
Arthur Kepner3e7ccca2015-11-04 21:10:09 -0500531 mdata->ps_tail = get_rcvhdrtail(rcd);
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -0500532 if (rcd->ctxt == HFI1_CTRL_CTXT)
533 mdata->ps_seq = rcd->seq_cnt;
534 else
535 mdata->ps_seq = 0; /* not used with DMA_RTAIL */
Mike Marciniszyn77241052015-07-30 15:17:43 -0400536 } else {
537 mdata->ps_tail = 0; /* used only with DMA_RTAIL*/
538 mdata->ps_seq = rcd->seq_cnt;
539 }
540}
541
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -0500542static inline int ps_done(struct ps_mdata *mdata, u64 rhf,
543 struct hfi1_ctxtdata *rcd)
Mike Marciniszyn77241052015-07-30 15:17:43 -0400544{
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -0500545 if (HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL))
Mike Marciniszyn77241052015-07-30 15:17:43 -0400546 return mdata->ps_head == mdata->ps_tail;
547 return mdata->ps_seq != rhf_rcv_seq(rhf);
548}
549
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -0500550static inline int ps_skip(struct ps_mdata *mdata, u64 rhf,
551 struct hfi1_ctxtdata *rcd)
552{
553 /*
554 * Control context can potentially receive an invalid rhf.
555 * Drop such packets.
556 */
557 if ((rcd->ctxt == HFI1_CTRL_CTXT) && (mdata->ps_head != mdata->ps_tail))
558 return mdata->ps_seq != rhf_rcv_seq(rhf);
559
560 return 0;
561}
562
563static inline void update_ps_mdata(struct ps_mdata *mdata,
564 struct hfi1_ctxtdata *rcd)
Mike Marciniszyn77241052015-07-30 15:17:43 -0400565{
Mike Marciniszyn77241052015-07-30 15:17:43 -0400566 mdata->ps_head += mdata->rsize;
Arthur Kepner3e7ccca2015-11-04 21:10:09 -0500567 if (mdata->ps_head >= mdata->maxcnt)
Mike Marciniszyn77241052015-07-30 15:17:43 -0400568 mdata->ps_head = 0;
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -0500569
570 /* Control context must do seq counting */
571 if (!HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL) ||
572 (rcd->ctxt == HFI1_CTRL_CTXT)) {
Mike Marciniszyn77241052015-07-30 15:17:43 -0400573 if (++mdata->ps_seq > 13)
574 mdata->ps_seq = 1;
575 }
576}
577
578/*
579 * prescan_rxq - search through the receive queue looking for packets
580 * containing Excplicit Congestion Notifications (FECNs, or BECNs).
581 * When an ECN is found, process the Congestion Notification, and toggle
582 * it off.
Vennila Megavannan6c9e50f2016-02-03 14:32:57 -0800583 * This is declared as a macro to allow quick checking of the port to avoid
584 * the overhead of a function call if not enabled.
Mike Marciniszyn77241052015-07-30 15:17:43 -0400585 */
Vennila Megavannan6c9e50f2016-02-03 14:32:57 -0800586#define prescan_rxq(rcd, packet) \
587 do { \
588 if (rcd->ppd->cc_prescan) \
589 __prescan_rxq(packet); \
590 } while (0)
591static void __prescan_rxq(struct hfi1_packet *packet)
Mike Marciniszyn77241052015-07-30 15:17:43 -0400592{
593 struct hfi1_ctxtdata *rcd = packet->rcd;
594 struct ps_mdata mdata;
595
Mike Marciniszyn77241052015-07-30 15:17:43 -0400596 init_ps_mdata(&mdata, packet);
597
598 while (1) {
599 struct hfi1_devdata *dd = rcd->dd;
600 struct hfi1_ibport *ibp = &rcd->ppd->ibport_data;
Jubin John50e5dcb2016-02-14 20:19:41 -0800601 __le32 *rhf_addr = (__le32 *)rcd->rcvhdrq + mdata.ps_head +
Mike Marciniszyn77241052015-07-30 15:17:43 -0400602 dd->rhf_offset;
Dennis Dalessandro895420d2016-01-19 14:42:28 -0800603 struct rvt_qp *qp;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400604 struct hfi1_ib_header *hdr;
605 struct hfi1_other_headers *ohdr;
Dennis Dalessandroec4274f2016-01-19 14:43:44 -0800606 struct rvt_dev_info *rdi = &dd->verbs_dev.rdi;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400607 u64 rhf = rhf_to_cpu(rhf_addr);
Arthur Kepner977940b2015-11-04 21:10:10 -0500608 u32 etype = rhf_rcv_type(rhf), qpn, bth1;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400609 int is_ecn = 0;
610 u8 lnh;
611
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -0500612 if (ps_done(&mdata, rhf, rcd))
Mike Marciniszyn77241052015-07-30 15:17:43 -0400613 break;
614
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -0500615 if (ps_skip(&mdata, rhf, rcd))
616 goto next;
617
Mike Marciniszyn77241052015-07-30 15:17:43 -0400618 if (etype != RHF_RCV_TYPE_IB)
619 goto next;
620
621 hdr = (struct hfi1_ib_header *)
622 hfi1_get_msgheader(dd, rhf_addr);
623 lnh = be16_to_cpu(hdr->lrh[0]) & 3;
624
Mitko Haralanov5fd2b562016-07-25 13:38:07 -0700625 if (lnh == HFI1_LRH_BTH)
Mike Marciniszyn77241052015-07-30 15:17:43 -0400626 ohdr = &hdr->u.oth;
Mitko Haralanov5fd2b562016-07-25 13:38:07 -0700627 else if (lnh == HFI1_LRH_GRH)
Mike Marciniszyn77241052015-07-30 15:17:43 -0400628 ohdr = &hdr->u.l.oth;
Mitko Haralanov5fd2b562016-07-25 13:38:07 -0700629 else
Mike Marciniszyn77241052015-07-30 15:17:43 -0400630 goto next; /* just in case */
Mitko Haralanov5fd2b562016-07-25 13:38:07 -0700631
Arthur Kepner977940b2015-11-04 21:10:10 -0500632 bth1 = be32_to_cpu(ohdr->bth[1]);
633 is_ecn = !!(bth1 & (HFI1_FECN_SMASK | HFI1_BECN_SMASK));
Mike Marciniszyn77241052015-07-30 15:17:43 -0400634
635 if (!is_ecn)
636 goto next;
637
Dennis Dalessandroec4274f2016-01-19 14:43:44 -0800638 qpn = bth1 & RVT_QPN_MASK;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400639 rcu_read_lock();
Dennis Dalessandroec4274f2016-01-19 14:43:44 -0800640 qp = rvt_lookup_qpn(rdi, &ibp->rvp, qpn);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400641
Jubin Johnd125a6c2016-02-14 20:19:49 -0800642 if (!qp) {
Mike Marciniszyn77241052015-07-30 15:17:43 -0400643 rcu_read_unlock();
644 goto next;
645 }
646
Mitko Haralanov5fd2b562016-07-25 13:38:07 -0700647 process_ecn(qp, packet, true);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400648 rcu_read_unlock();
Arthur Kepner977940b2015-11-04 21:10:10 -0500649
650 /* turn off BECN, FECN */
651 bth1 &= ~(HFI1_FECN_SMASK | HFI1_BECN_SMASK);
652 ohdr->bth[1] = cpu_to_be32(bth1);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400653next:
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -0500654 update_ps_mdata(&mdata, rcd);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400655 }
656}
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -0500657
658static inline int skip_rcv_packet(struct hfi1_packet *packet, int thread)
659{
660 int ret = RCV_PKT_OK;
661
662 /* Set up for the next packet */
663 packet->rhqoff += packet->rsize;
664 if (packet->rhqoff >= packet->maxcnt)
665 packet->rhqoff = 0;
666
667 packet->numpkt++;
668 if (unlikely((packet->numpkt & (MAX_PKT_RECV - 1)) == 0)) {
669 if (thread) {
670 cond_resched();
671 } else {
672 ret = RCV_PKT_LIMIT;
673 this_cpu_inc(*packet->rcd->dd->rcv_limit);
674 }
675 }
676
677 packet->rhf_addr = (__le32 *)packet->rcd->rcvhdrq + packet->rhqoff +
678 packet->rcd->dd->rhf_offset;
679 packet->rhf = rhf_to_cpu(packet->rhf_addr);
680
681 return ret;
682}
Mike Marciniszyn77241052015-07-30 15:17:43 -0400683
Dean Luickf4f30031c2015-10-26 10:28:44 -0400684static inline int process_rcv_packet(struct hfi1_packet *packet, int thread)
Mike Marciniszyn77241052015-07-30 15:17:43 -0400685{
686 int ret = RCV_PKT_OK;
687
688 packet->hdr = hfi1_get_msgheader(packet->rcd->dd,
689 packet->rhf_addr);
690 packet->hlen = (u8 *)packet->rhf_addr - (u8 *)packet->hdr;
691 packet->etype = rhf_rcv_type(packet->rhf);
692 /* total length */
693 packet->tlen = rhf_pkt_len(packet->rhf); /* in bytes */
694 /* retrieve eager buffer details */
695 packet->ebuf = NULL;
696 if (rhf_use_egr_bfr(packet->rhf)) {
697 packet->etail = rhf_egr_index(packet->rhf);
698 packet->ebuf = get_egrbuf(packet->rcd, packet->rhf,
699 &packet->updegr);
700 /*
701 * Prefetch the contents of the eager buffer. It is
702 * OK to send a negative length to prefetch_range().
703 * The +2 is the size of the RHF.
704 */
705 prefetch_range(packet->ebuf,
Jubin John17fb4f22016-02-14 20:21:52 -0800706 packet->tlen - ((packet->rcd->rcvhdrqentsize -
707 (rhf_hdrq_offset(packet->rhf)
708 + 2)) * 4));
Mike Marciniszyn77241052015-07-30 15:17:43 -0400709 }
710
711 /*
712 * Call a type specific handler for the packet. We
713 * should be able to trust that etype won't be beyond
714 * the range of valid indexes. If so something is really
715 * wrong and we can probably just let things come
716 * crashing down. There is no need to eat another
717 * comparison in this performance critical code.
718 */
719 packet->rcd->dd->rhf_rcv_function_map[packet->etype](packet);
720 packet->numpkt++;
721
722 /* Set up for the next packet */
723 packet->rhqoff += packet->rsize;
724 if (packet->rhqoff >= packet->maxcnt)
725 packet->rhqoff = 0;
726
Dean Luickf4f30031c2015-10-26 10:28:44 -0400727 if (unlikely((packet->numpkt & (MAX_PKT_RECV - 1)) == 0)) {
728 if (thread) {
729 cond_resched();
730 } else {
731 ret = RCV_PKT_LIMIT;
732 this_cpu_inc(*packet->rcd->dd->rcv_limit);
733 }
Mike Marciniszyn77241052015-07-30 15:17:43 -0400734 }
735
Jubin John50e5dcb2016-02-14 20:19:41 -0800736 packet->rhf_addr = (__le32 *)packet->rcd->rcvhdrq + packet->rhqoff +
Mike Marciniszyn77241052015-07-30 15:17:43 -0400737 packet->rcd->dd->rhf_offset;
738 packet->rhf = rhf_to_cpu(packet->rhf_addr);
739
740 return ret;
741}
742
743static inline void process_rcv_update(int last, struct hfi1_packet *packet)
744{
745 /*
746 * Update head regs etc., every 16 packets, if not last pkt,
747 * to help prevent rcvhdrq overflows, when many packets
748 * are processed and queue is nearly full.
749 * Don't request an interrupt for intermediate updates.
750 */
751 if (!last && !(packet->numpkt & 0xf)) {
752 update_usrhead(packet->rcd, packet->rhqoff, packet->updegr,
753 packet->etail, 0, 0);
754 packet->updegr = 0;
755 }
756 packet->rcv_flags = 0;
757}
758
759static inline void finish_packet(struct hfi1_packet *packet)
760{
Mike Marciniszyn77241052015-07-30 15:17:43 -0400761 /*
762 * Nothing we need to free for the packet.
763 *
764 * The only thing we need to do is a final update and call for an
765 * interrupt
766 */
767 update_usrhead(packet->rcd, packet->rcd->head, packet->updegr,
768 packet->etail, rcv_intr_dynamic, packet->numpkt);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400769}
770
771static inline void process_rcv_qp_work(struct hfi1_packet *packet)
772{
Mike Marciniszyn77241052015-07-30 15:17:43 -0400773 struct hfi1_ctxtdata *rcd;
Dennis Dalessandro895420d2016-01-19 14:42:28 -0800774 struct rvt_qp *qp, *nqp;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400775
776 rcd = packet->rcd;
777 rcd->head = packet->rhqoff;
778
779 /*
780 * Iterate over all QPs waiting to respond.
781 * The list won't change since the IRQ is only run on one CPU.
782 */
783 list_for_each_entry_safe(qp, nqp, &rcd->qp_wait_list, rspwait) {
784 list_del_init(&qp->rspwait);
Dennis Dalessandro54d10c12016-01-19 14:43:01 -0800785 if (qp->r_flags & RVT_R_RSP_NAK) {
786 qp->r_flags &= ~RVT_R_RSP_NAK;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400787 hfi1_send_rc_ack(rcd, qp, 0);
788 }
Dennis Dalessandro54d10c12016-01-19 14:43:01 -0800789 if (qp->r_flags & RVT_R_RSP_SEND) {
Mike Marciniszyn77241052015-07-30 15:17:43 -0400790 unsigned long flags;
791
Dennis Dalessandro54d10c12016-01-19 14:43:01 -0800792 qp->r_flags &= ~RVT_R_RSP_SEND;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400793 spin_lock_irqsave(&qp->s_lock, flags);
Dennis Dalessandro83693bd2016-01-19 14:43:33 -0800794 if (ib_rvt_state_ops[qp->state] &
795 RVT_PROCESS_OR_FLUSH_SEND)
Mike Marciniszyn77241052015-07-30 15:17:43 -0400796 hfi1_schedule_send(qp);
797 spin_unlock_irqrestore(&qp->s_lock, flags);
798 }
799 if (atomic_dec_and_test(&qp->refcount))
800 wake_up(&qp->wait);
801 }
802}
803
804/*
805 * Handle receive interrupts when using the no dma rtail option.
806 */
Dean Luickf4f30031c2015-10-26 10:28:44 -0400807int handle_receive_interrupt_nodma_rtail(struct hfi1_ctxtdata *rcd, int thread)
Mike Marciniszyn77241052015-07-30 15:17:43 -0400808{
809 u32 seq;
Dean Luickf4f30031c2015-10-26 10:28:44 -0400810 int last = RCV_PKT_OK;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400811 struct hfi1_packet packet;
812
813 init_packet(rcd, &packet);
814 seq = rhf_rcv_seq(packet.rhf);
Dean Luickf4f30031c2015-10-26 10:28:44 -0400815 if (seq != rcd->seq_cnt) {
816 last = RCV_PKT_DONE;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400817 goto bail;
Dean Luickf4f30031c2015-10-26 10:28:44 -0400818 }
Mike Marciniszyn77241052015-07-30 15:17:43 -0400819
Vennila Megavannan6c9e50f2016-02-03 14:32:57 -0800820 prescan_rxq(rcd, &packet);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400821
Dean Luickf4f30031c2015-10-26 10:28:44 -0400822 while (last == RCV_PKT_OK) {
823 last = process_rcv_packet(&packet, thread);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400824 seq = rhf_rcv_seq(packet.rhf);
825 if (++rcd->seq_cnt > 13)
826 rcd->seq_cnt = 1;
827 if (seq != rcd->seq_cnt)
Dean Luickf4f30031c2015-10-26 10:28:44 -0400828 last = RCV_PKT_DONE;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400829 process_rcv_update(last, &packet);
830 }
831 process_rcv_qp_work(&packet);
832bail:
833 finish_packet(&packet);
Dean Luickf4f30031c2015-10-26 10:28:44 -0400834 return last;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400835}
836
Dean Luickf4f30031c2015-10-26 10:28:44 -0400837int handle_receive_interrupt_dma_rtail(struct hfi1_ctxtdata *rcd, int thread)
Mike Marciniszyn77241052015-07-30 15:17:43 -0400838{
839 u32 hdrqtail;
Dean Luickf4f30031c2015-10-26 10:28:44 -0400840 int last = RCV_PKT_OK;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400841 struct hfi1_packet packet;
842
843 init_packet(rcd, &packet);
844 hdrqtail = get_rcvhdrtail(rcd);
Dean Luickf4f30031c2015-10-26 10:28:44 -0400845 if (packet.rhqoff == hdrqtail) {
846 last = RCV_PKT_DONE;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400847 goto bail;
Dean Luickf4f30031c2015-10-26 10:28:44 -0400848 }
Mike Marciniszyn77241052015-07-30 15:17:43 -0400849 smp_rmb(); /* prevent speculative reads of dma'ed hdrq */
850
Vennila Megavannan6c9e50f2016-02-03 14:32:57 -0800851 prescan_rxq(rcd, &packet);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400852
Dean Luickf4f30031c2015-10-26 10:28:44 -0400853 while (last == RCV_PKT_OK) {
854 last = process_rcv_packet(&packet, thread);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400855 if (packet.rhqoff == hdrqtail)
Dean Luickf4f30031c2015-10-26 10:28:44 -0400856 last = RCV_PKT_DONE;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400857 process_rcv_update(last, &packet);
858 }
859 process_rcv_qp_work(&packet);
860bail:
861 finish_packet(&packet);
Dean Luickf4f30031c2015-10-26 10:28:44 -0400862 return last;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400863}
864
865static inline void set_all_nodma_rtail(struct hfi1_devdata *dd)
866{
867 int i;
868
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -0500869 for (i = HFI1_CTRL_CTXT + 1; i < dd->first_user_ctxt; i++)
Mike Marciniszyn77241052015-07-30 15:17:43 -0400870 dd->rcd[i]->do_interrupt =
871 &handle_receive_interrupt_nodma_rtail;
872}
873
874static inline void set_all_dma_rtail(struct hfi1_devdata *dd)
875{
876 int i;
877
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -0500878 for (i = HFI1_CTRL_CTXT + 1; i < dd->first_user_ctxt; i++)
Mike Marciniszyn77241052015-07-30 15:17:43 -0400879 dd->rcd[i]->do_interrupt =
880 &handle_receive_interrupt_dma_rtail;
881}
882
Jim Snowfb9036d2016-01-11 18:32:21 -0500883void set_all_slowpath(struct hfi1_devdata *dd)
884{
885 int i;
886
887 /* HFI1_CTRL_CTXT must always use the slow path interrupt handler */
888 for (i = HFI1_CTRL_CTXT + 1; i < dd->first_user_ctxt; i++)
889 dd->rcd[i]->do_interrupt = &handle_receive_interrupt;
890}
891
892static inline int set_armed_to_active(struct hfi1_ctxtdata *rcd,
893 struct hfi1_packet packet,
894 struct hfi1_devdata *dd)
895{
896 struct work_struct *lsaw = &rcd->ppd->linkstate_active_work;
897 struct hfi1_message_header *hdr = hfi1_get_msgheader(packet.rcd->dd,
898 packet.rhf_addr);
899
900 if (hdr2sc(hdr, packet.rhf) != 0xf) {
901 int hwstate = read_logical_state(dd);
902
903 if (hwstate != LSTATE_ACTIVE) {
904 dd_dev_info(dd, "Unexpected link state %d\n", hwstate);
905 return 0;
906 }
907
908 queue_work(rcd->ppd->hfi1_wq, lsaw);
909 return 1;
910 }
911 return 0;
912}
913
Mike Marciniszyn77241052015-07-30 15:17:43 -0400914/*
915 * handle_receive_interrupt - receive a packet
916 * @rcd: the context
917 *
918 * Called from interrupt handler for errors or receive interrupt.
919 * This is the slow path interrupt handler.
920 */
Dean Luickf4f30031c2015-10-26 10:28:44 -0400921int handle_receive_interrupt(struct hfi1_ctxtdata *rcd, int thread)
Mike Marciniszyn77241052015-07-30 15:17:43 -0400922{
Mike Marciniszyn77241052015-07-30 15:17:43 -0400923 struct hfi1_devdata *dd = rcd->dd;
924 u32 hdrqtail;
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -0500925 int needset, last = RCV_PKT_OK;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400926 struct hfi1_packet packet;
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -0500927 int skip_pkt = 0;
928
929 /* Control context will always use the slow path interrupt handler */
930 needset = (rcd->ctxt == HFI1_CTRL_CTXT) ? 0 : 1;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400931
932 init_packet(rcd, &packet);
933
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -0500934 if (!HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL)) {
Mike Marciniszyn77241052015-07-30 15:17:43 -0400935 u32 seq = rhf_rcv_seq(packet.rhf);
936
Dean Luickf4f30031c2015-10-26 10:28:44 -0400937 if (seq != rcd->seq_cnt) {
938 last = RCV_PKT_DONE;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400939 goto bail;
Dean Luickf4f30031c2015-10-26 10:28:44 -0400940 }
Mike Marciniszyn77241052015-07-30 15:17:43 -0400941 hdrqtail = 0;
942 } else {
943 hdrqtail = get_rcvhdrtail(rcd);
Dean Luickf4f30031c2015-10-26 10:28:44 -0400944 if (packet.rhqoff == hdrqtail) {
945 last = RCV_PKT_DONE;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400946 goto bail;
Dean Luickf4f30031c2015-10-26 10:28:44 -0400947 }
Mike Marciniszyn77241052015-07-30 15:17:43 -0400948 smp_rmb(); /* prevent speculative reads of dma'ed hdrq */
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -0500949
950 /*
951 * Control context can potentially receive an invalid
952 * rhf. Drop such packets.
953 */
954 if (rcd->ctxt == HFI1_CTRL_CTXT) {
955 u32 seq = rhf_rcv_seq(packet.rhf);
956
957 if (seq != rcd->seq_cnt)
958 skip_pkt = 1;
959 }
Mike Marciniszyn77241052015-07-30 15:17:43 -0400960 }
961
Vennila Megavannan6c9e50f2016-02-03 14:32:57 -0800962 prescan_rxq(rcd, &packet);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400963
Dean Luickf4f30031c2015-10-26 10:28:44 -0400964 while (last == RCV_PKT_OK) {
Jubin John17fb4f22016-02-14 20:21:52 -0800965 if (unlikely(dd->do_drop &&
966 atomic_xchg(&dd->drop_packet, DROP_PACKET_OFF) ==
967 DROP_PACKET_ON)) {
Mike Marciniszyn77241052015-07-30 15:17:43 -0400968 dd->do_drop = 0;
969
970 /* On to the next packet */
971 packet.rhqoff += packet.rsize;
Jubin John50e5dcb2016-02-14 20:19:41 -0800972 packet.rhf_addr = (__le32 *)rcd->rcvhdrq +
Mike Marciniszyn77241052015-07-30 15:17:43 -0400973 packet.rhqoff +
974 dd->rhf_offset;
975 packet.rhf = rhf_to_cpu(packet.rhf_addr);
976
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -0500977 } else if (skip_pkt) {
978 last = skip_rcv_packet(&packet, thread);
979 skip_pkt = 0;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400980 } else {
Jim Snowfb9036d2016-01-11 18:32:21 -0500981 /* Auto activate link on non-SC15 packet receive */
982 if (unlikely(rcd->ppd->host_link_state ==
983 HLS_UP_ARMED) &&
984 set_armed_to_active(rcd, packet, dd))
985 goto bail;
Dean Luickf4f30031c2015-10-26 10:28:44 -0400986 last = process_rcv_packet(&packet, thread);
Mike Marciniszyn77241052015-07-30 15:17:43 -0400987 }
988
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -0500989 if (!HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL)) {
Mike Marciniszyn77241052015-07-30 15:17:43 -0400990 u32 seq = rhf_rcv_seq(packet.rhf);
991
992 if (++rcd->seq_cnt > 13)
993 rcd->seq_cnt = 1;
994 if (seq != rcd->seq_cnt)
Dean Luickf4f30031c2015-10-26 10:28:44 -0400995 last = RCV_PKT_DONE;
Mike Marciniszyn77241052015-07-30 15:17:43 -0400996 if (needset) {
Jubin John17fb4f22016-02-14 20:21:52 -0800997 dd_dev_info(dd, "Switching to NO_DMA_RTAIL\n");
Mike Marciniszyn77241052015-07-30 15:17:43 -0400998 set_all_nodma_rtail(dd);
999 needset = 0;
1000 }
1001 } else {
1002 if (packet.rhqoff == hdrqtail)
Dean Luickf4f30031c2015-10-26 10:28:44 -04001003 last = RCV_PKT_DONE;
Niranjana Vishwanathapura82c26112015-11-11 00:35:19 -05001004 /*
1005 * Control context can potentially receive an invalid
1006 * rhf. Drop such packets.
1007 */
1008 if (rcd->ctxt == HFI1_CTRL_CTXT) {
1009 u32 seq = rhf_rcv_seq(packet.rhf);
1010
1011 if (++rcd->seq_cnt > 13)
1012 rcd->seq_cnt = 1;
1013 if (!last && (seq != rcd->seq_cnt))
1014 skip_pkt = 1;
1015 }
1016
Mike Marciniszyn77241052015-07-30 15:17:43 -04001017 if (needset) {
1018 dd_dev_info(dd,
1019 "Switching to DMA_RTAIL\n");
1020 set_all_dma_rtail(dd);
1021 needset = 0;
1022 }
1023 }
1024
1025 process_rcv_update(last, &packet);
1026 }
1027
1028 process_rcv_qp_work(&packet);
1029
1030bail:
1031 /*
1032 * Always write head at end, and setup rcv interrupt, even
1033 * if no packets were processed.
1034 */
1035 finish_packet(&packet);
Dean Luickf4f30031c2015-10-26 10:28:44 -04001036 return last;
Mike Marciniszyn77241052015-07-30 15:17:43 -04001037}
1038
1039/*
Jim Snowfb9036d2016-01-11 18:32:21 -05001040 * We may discover in the interrupt that the hardware link state has
1041 * changed from ARMED to ACTIVE (due to the arrival of a non-SC15 packet),
1042 * and we need to update the driver's notion of the link state. We cannot
1043 * run set_link_state from interrupt context, so we queue this function on
1044 * a workqueue.
1045 *
1046 * We delay the regular interrupt processing until after the state changes
1047 * so that the link will be in the correct state by the time any application
1048 * we wake up attempts to send a reply to any message it received.
1049 * (Subsequent receive interrupts may possibly force the wakeup before we
1050 * update the link state.)
1051 *
1052 * The rcd is freed in hfi1_free_ctxtdata after hfi1_postinit_cleanup invokes
1053 * dd->f_cleanup(dd) to disable the interrupt handler and flush workqueues,
1054 * so we're safe from use-after-free of the rcd.
1055 */
1056void receive_interrupt_work(struct work_struct *work)
1057{
1058 struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
1059 linkstate_active_work);
1060 struct hfi1_devdata *dd = ppd->dd;
1061 int i;
1062
1063 /* Received non-SC15 packet implies neighbor_normal */
1064 ppd->neighbor_normal = 1;
1065 set_link_state(ppd, HLS_UP_ACTIVE);
1066
1067 /*
1068 * Interrupt all kernel contexts that could have had an
1069 * interrupt during auto activation.
1070 */
1071 for (i = HFI1_CTRL_CTXT; i < dd->first_user_ctxt; i++)
1072 force_recv_intr(dd->rcd[i]);
1073}
1074
1075/*
Mike Marciniszyn77241052015-07-30 15:17:43 -04001076 * Convert a given MTU size to the on-wire MAD packet enumeration.
1077 * Return -1 if the size is invalid.
1078 */
1079int mtu_to_enum(u32 mtu, int default_if_bad)
1080{
1081 switch (mtu) {
1082 case 0: return OPA_MTU_0;
1083 case 256: return OPA_MTU_256;
1084 case 512: return OPA_MTU_512;
1085 case 1024: return OPA_MTU_1024;
1086 case 2048: return OPA_MTU_2048;
1087 case 4096: return OPA_MTU_4096;
1088 case 8192: return OPA_MTU_8192;
1089 case 10240: return OPA_MTU_10240;
1090 }
1091 return default_if_bad;
1092}
1093
1094u16 enum_to_mtu(int mtu)
1095{
1096 switch (mtu) {
1097 case OPA_MTU_0: return 0;
1098 case OPA_MTU_256: return 256;
1099 case OPA_MTU_512: return 512;
1100 case OPA_MTU_1024: return 1024;
1101 case OPA_MTU_2048: return 2048;
1102 case OPA_MTU_4096: return 4096;
1103 case OPA_MTU_8192: return 8192;
1104 case OPA_MTU_10240: return 10240;
1105 default: return 0xffff;
1106 }
1107}
1108
1109/*
1110 * set_mtu - set the MTU
1111 * @ppd: the per port data
1112 *
1113 * We can handle "any" incoming size, the issue here is whether we
1114 * need to restrict our outgoing size. We do not deal with what happens
1115 * to programs that are already running when the size changes.
1116 */
1117int set_mtu(struct hfi1_pportdata *ppd)
1118{
1119 struct hfi1_devdata *dd = ppd->dd;
1120 int i, drain, ret = 0, is_up = 0;
1121
1122 ppd->ibmtu = 0;
1123 for (i = 0; i < ppd->vls_supported; i++)
1124 if (ppd->ibmtu < dd->vld[i].mtu)
1125 ppd->ibmtu = dd->vld[i].mtu;
1126 ppd->ibmaxlen = ppd->ibmtu + lrh_max_header_bytes(ppd->dd);
1127
1128 mutex_lock(&ppd->hls_lock);
Jubin Johnd0d236e2016-02-14 20:20:15 -08001129 if (ppd->host_link_state == HLS_UP_INIT ||
1130 ppd->host_link_state == HLS_UP_ARMED ||
1131 ppd->host_link_state == HLS_UP_ACTIVE)
Mike Marciniszyn77241052015-07-30 15:17:43 -04001132 is_up = 1;
1133
1134 drain = !is_ax(dd) && is_up;
1135
1136 if (drain)
1137 /*
1138 * MTU is specified per-VL. To ensure that no packet gets
1139 * stuck (due, e.g., to the MTU for the packet's VL being
1140 * reduced), empty the per-VL FIFOs before adjusting MTU.
1141 */
1142 ret = stop_drain_data_vls(dd);
1143
1144 if (ret) {
1145 dd_dev_err(dd, "%s: cannot stop/drain VLs - refusing to change per-VL MTUs\n",
1146 __func__);
1147 goto err;
1148 }
1149
1150 hfi1_set_ib_cfg(ppd, HFI1_IB_CFG_MTU, 0);
1151
1152 if (drain)
1153 open_fill_data_vls(dd); /* reopen all VLs */
1154
1155err:
1156 mutex_unlock(&ppd->hls_lock);
1157
1158 return ret;
1159}
1160
1161int hfi1_set_lid(struct hfi1_pportdata *ppd, u32 lid, u8 lmc)
1162{
1163 struct hfi1_devdata *dd = ppd->dd;
1164
1165 ppd->lid = lid;
1166 ppd->lmc = lmc;
1167 hfi1_set_ib_cfg(ppd, HFI1_IB_CFG_LIDLMC, 0);
1168
Jakub Pawlakcde10af2016-05-12 10:23:35 -07001169 dd_dev_info(dd, "port %u: got a lid: 0x%x\n", ppd->port, lid);
Mike Marciniszyn77241052015-07-30 15:17:43 -04001170
1171 return 0;
1172}
1173
Easwar Hariharan91ab4ed2016-02-03 14:35:57 -08001174void shutdown_led_override(struct hfi1_pportdata *ppd)
1175{
1176 struct hfi1_devdata *dd = ppd->dd;
1177
Easwar Hariharan409b1462016-02-26 13:33:28 -08001178 /*
Easwar Hariharan22434722016-03-07 11:35:03 -08001179 * This pairs with the memory barrier in hfi1_start_led_override to
1180 * ensure that we read the correct state of LED beaconing represented
1181 * by led_override_timer_active
Easwar Hariharan409b1462016-02-26 13:33:28 -08001182 */
Easwar Hariharan22434722016-03-07 11:35:03 -08001183 smp_rmb();
Easwar Hariharan91ab4ed2016-02-03 14:35:57 -08001184 if (atomic_read(&ppd->led_override_timer_active)) {
1185 del_timer_sync(&ppd->led_override_timer);
1186 atomic_set(&ppd->led_override_timer_active, 0);
Easwar Hariharan22434722016-03-07 11:35:03 -08001187 /* Ensure the atomic_set is visible to all CPUs */
1188 smp_wmb();
Easwar Hariharan91ab4ed2016-02-03 14:35:57 -08001189 }
1190
Easwar Hariharan22434722016-03-07 11:35:03 -08001191 /* Hand control of the LED to the DC for normal operation */
1192 write_csr(dd, DCC_CFG_LED_CNTRL, 0);
Easwar Hariharan91ab4ed2016-02-03 14:35:57 -08001193}
Mike Marciniszyn77241052015-07-30 15:17:43 -04001194
1195static void run_led_override(unsigned long opaque)
1196{
1197 struct hfi1_pportdata *ppd = (struct hfi1_pportdata *)opaque;
1198 struct hfi1_devdata *dd = ppd->dd;
Easwar Hariharan91ab4ed2016-02-03 14:35:57 -08001199 unsigned long timeout;
1200 int phase_idx;
Mike Marciniszyn77241052015-07-30 15:17:43 -04001201
1202 if (!(dd->flags & HFI1_INITTED))
1203 return;
1204
Easwar Hariharan91ab4ed2016-02-03 14:35:57 -08001205 phase_idx = ppd->led_override_phase & 1;
Mike Marciniszyn77241052015-07-30 15:17:43 -04001206
Easwar Hariharan91ab4ed2016-02-03 14:35:57 -08001207 setextled(dd, phase_idx);
1208
1209 timeout = ppd->led_override_vals[phase_idx];
Easwar Hariharan22434722016-03-07 11:35:03 -08001210
Easwar Hariharan91ab4ed2016-02-03 14:35:57 -08001211 /* Set up for next phase */
1212 ppd->led_override_phase = !ppd->led_override_phase;
Mike Marciniszyn77241052015-07-30 15:17:43 -04001213
Easwar Hariharan22434722016-03-07 11:35:03 -08001214 mod_timer(&ppd->led_override_timer, jiffies + timeout);
Mike Marciniszyn77241052015-07-30 15:17:43 -04001215}
1216
Easwar Hariharan91ab4ed2016-02-03 14:35:57 -08001217/*
1218 * To have the LED blink in a particular pattern, provide timeon and timeoff
Easwar Hariharan22434722016-03-07 11:35:03 -08001219 * in milliseconds.
1220 * To turn off custom blinking and return to normal operation, use
1221 * shutdown_led_override()
Easwar Hariharan91ab4ed2016-02-03 14:35:57 -08001222 */
Easwar Hariharan22434722016-03-07 11:35:03 -08001223void hfi1_start_led_override(struct hfi1_pportdata *ppd, unsigned int timeon,
1224 unsigned int timeoff)
Mike Marciniszyn77241052015-07-30 15:17:43 -04001225{
Easwar Hariharan22434722016-03-07 11:35:03 -08001226 if (!(ppd->dd->flags & HFI1_INITTED))
Mike Marciniszyn77241052015-07-30 15:17:43 -04001227 return;
1228
Easwar Hariharan91ab4ed2016-02-03 14:35:57 -08001229 /* Convert to jiffies for direct use in timer */
1230 ppd->led_override_vals[0] = msecs_to_jiffies(timeoff);
1231 ppd->led_override_vals[1] = msecs_to_jiffies(timeon);
Mike Marciniszyn77241052015-07-30 15:17:43 -04001232
Easwar Hariharan22434722016-03-07 11:35:03 -08001233 /* Arbitrarily start from LED on phase */
1234 ppd->led_override_phase = 1;
Mike Marciniszyn77241052015-07-30 15:17:43 -04001235
1236 /*
1237 * If the timer has not already been started, do so. Use a "quick"
Easwar Hariharan22434722016-03-07 11:35:03 -08001238 * timeout so the handler will be called soon to look at our request.
Mike Marciniszyn77241052015-07-30 15:17:43 -04001239 */
Easwar Hariharan22434722016-03-07 11:35:03 -08001240 if (!timer_pending(&ppd->led_override_timer)) {
Muhammad Falak R Wania3faf6062015-10-25 16:13:24 +05301241 setup_timer(&ppd->led_override_timer, run_led_override,
Jubin John17fb4f22016-02-14 20:21:52 -08001242 (unsigned long)ppd);
Mike Marciniszyn77241052015-07-30 15:17:43 -04001243 ppd->led_override_timer.expires = jiffies + 1;
1244 add_timer(&ppd->led_override_timer);
Easwar Hariharan22434722016-03-07 11:35:03 -08001245 atomic_set(&ppd->led_override_timer_active, 1);
1246 /* Ensure the atomic_set is visible to all CPUs */
1247 smp_wmb();
Mike Marciniszyn77241052015-07-30 15:17:43 -04001248 }
1249}
1250
1251/**
1252 * hfi1_reset_device - reset the chip if possible
1253 * @unit: the device to reset
1254 *
1255 * Whether or not reset is successful, we attempt to re-initialize the chip
1256 * (that is, much like a driver unload/reload). We clear the INITTED flag
1257 * so that the various entry points will fail until we reinitialize. For
1258 * now, we only allow this if no user contexts are open that use chip resources
1259 */
1260int hfi1_reset_device(int unit)
1261{
1262 int ret, i;
1263 struct hfi1_devdata *dd = hfi1_lookup(unit);
1264 struct hfi1_pportdata *ppd;
1265 unsigned long flags;
1266 int pidx;
1267
1268 if (!dd) {
1269 ret = -ENODEV;
1270 goto bail;
1271 }
1272
1273 dd_dev_info(dd, "Reset on unit %u requested\n", unit);
1274
1275 if (!dd->kregbase || !(dd->flags & HFI1_PRESENT)) {
1276 dd_dev_info(dd,
Jubin John17fb4f22016-02-14 20:21:52 -08001277 "Invalid unit number %u or not initialized or not present\n",
1278 unit);
Mike Marciniszyn77241052015-07-30 15:17:43 -04001279 ret = -ENXIO;
1280 goto bail;
1281 }
1282
1283 spin_lock_irqsave(&dd->uctxt_lock, flags);
1284 if (dd->rcd)
1285 for (i = dd->first_user_ctxt; i < dd->num_rcv_contexts; i++) {
1286 if (!dd->rcd[i] || !dd->rcd[i]->cnt)
1287 continue;
1288 spin_unlock_irqrestore(&dd->uctxt_lock, flags);
1289 ret = -EBUSY;
1290 goto bail;
1291 }
1292 spin_unlock_irqrestore(&dd->uctxt_lock, flags);
1293
1294 for (pidx = 0; pidx < dd->num_pports; ++pidx) {
1295 ppd = dd->pport + pidx;
Mike Marciniszyn77241052015-07-30 15:17:43 -04001296
Easwar Hariharan91ab4ed2016-02-03 14:35:57 -08001297 shutdown_led_override(ppd);
Mike Marciniszyn77241052015-07-30 15:17:43 -04001298 }
1299 if (dd->flags & HFI1_HAS_SEND_DMA)
1300 sdma_exit(dd);
1301
1302 hfi1_reset_cpu_counters(dd);
1303
1304 ret = hfi1_init(dd, 1);
1305
1306 if (ret)
1307 dd_dev_err(dd,
Jubin John17fb4f22016-02-14 20:21:52 -08001308 "Reinitialize unit %u after reset failed with %d\n",
1309 unit, ret);
Mike Marciniszyn77241052015-07-30 15:17:43 -04001310 else
1311 dd_dev_info(dd, "Reinitialized unit %u after resetting\n",
Jubin John17fb4f22016-02-14 20:21:52 -08001312 unit);
Mike Marciniszyn77241052015-07-30 15:17:43 -04001313
1314bail:
1315 return ret;
1316}
1317
1318void handle_eflags(struct hfi1_packet *packet)
1319{
1320 struct hfi1_ctxtdata *rcd = packet->rcd;
1321 u32 rte = rhf_rcv_type_err(packet->rhf);
1322
Mike Marciniszyn77241052015-07-30 15:17:43 -04001323 rcv_hdrerr(rcd, rcd->ppd, packet);
Ignacio Hernandeza03a03e2015-11-06 20:07:03 -05001324 if (rhf_err_flags(packet->rhf))
1325 dd_dev_err(rcd->dd,
1326 "receive context %d: rhf 0x%016llx, errs [ %s%s%s%s%s%s%s%s] rte 0x%x\n",
1327 rcd->ctxt, packet->rhf,
1328 packet->rhf & RHF_K_HDR_LEN_ERR ? "k_hdr_len " : "",
1329 packet->rhf & RHF_DC_UNC_ERR ? "dc_unc " : "",
1330 packet->rhf & RHF_DC_ERR ? "dc " : "",
1331 packet->rhf & RHF_TID_ERR ? "tid " : "",
1332 packet->rhf & RHF_LEN_ERR ? "len " : "",
1333 packet->rhf & RHF_ECC_ERR ? "ecc " : "",
1334 packet->rhf & RHF_VCRC_ERR ? "vcrc " : "",
1335 packet->rhf & RHF_ICRC_ERR ? "icrc " : "",
1336 rte);
Mike Marciniszyn77241052015-07-30 15:17:43 -04001337}
1338
1339/*
1340 * The following functions are called by the interrupt handler. They are type
1341 * specific handlers for each packet type.
1342 */
1343int process_receive_ib(struct hfi1_packet *packet)
1344{
1345 trace_hfi1_rcvhdr(packet->rcd->ppd->dd,
1346 packet->rcd->ctxt,
1347 rhf_err_flags(packet->rhf),
1348 RHF_RCV_TYPE_IB,
1349 packet->hlen,
1350 packet->tlen,
1351 packet->updegr,
1352 rhf_egr_index(packet->rhf));
1353
1354 if (unlikely(rhf_err_flags(packet->rhf))) {
1355 handle_eflags(packet);
1356 return RHF_RCV_CONTINUE;
1357 }
1358
1359 hfi1_ib_rcv(packet);
1360 return RHF_RCV_CONTINUE;
1361}
1362
1363int process_receive_bypass(struct hfi1_packet *packet)
1364{
1365 if (unlikely(rhf_err_flags(packet->rhf)))
1366 handle_eflags(packet);
1367
1368 dd_dev_err(packet->rcd->dd,
Jubin John17fb4f22016-02-14 20:21:52 -08001369 "Bypass packets are not supported in normal operation. Dropping\n");
Jakub Pawlak2b719042016-07-01 16:01:22 -07001370 incr_cntr64(&packet->rcd->dd->sw_rcv_bypass_packet_errors);
Mike Marciniszyn77241052015-07-30 15:17:43 -04001371 return RHF_RCV_CONTINUE;
1372}
1373
1374int process_receive_error(struct hfi1_packet *packet)
1375{
1376 handle_eflags(packet);
1377
1378 if (unlikely(rhf_err_flags(packet->rhf)))
1379 dd_dev_err(packet->rcd->dd,
1380 "Unhandled error packet received. Dropping.\n");
1381
1382 return RHF_RCV_CONTINUE;
1383}
1384
1385int kdeth_process_expected(struct hfi1_packet *packet)
1386{
1387 if (unlikely(rhf_err_flags(packet->rhf)))
1388 handle_eflags(packet);
1389
1390 dd_dev_err(packet->rcd->dd,
1391 "Unhandled expected packet received. Dropping.\n");
1392 return RHF_RCV_CONTINUE;
1393}
1394
1395int kdeth_process_eager(struct hfi1_packet *packet)
1396{
1397 if (unlikely(rhf_err_flags(packet->rhf)))
1398 handle_eflags(packet);
1399
1400 dd_dev_err(packet->rcd->dd,
1401 "Unhandled eager packet received. Dropping.\n");
1402 return RHF_RCV_CONTINUE;
1403}
1404
1405int process_receive_invalid(struct hfi1_packet *packet)
1406{
1407 dd_dev_err(packet->rcd->dd, "Invalid packet type %d. Dropping\n",
Jubin John17fb4f22016-02-14 20:21:52 -08001408 rhf_rcv_type(packet->rhf));
Mike Marciniszyn77241052015-07-30 15:17:43 -04001409 return RHF_RCV_CONTINUE;
1410}