2015-07-31 03:17:43 +08:00
|
|
|
/*
|
IB/hfi1: Rework fault injection machinery
The packet fault injection code present in the HFI1 driver had some
issues which not only fragment the code but also created user
confusion. Furthermore, it suffered from the following issues:
1. The fault_packet method only worked for received packets. This
meant that the only fault injection mode available for sent
packets is fault_opcode, which did not allow for random packet
drops on all egressing packets.
2. The mask available for the fault_opcode mode did not really work
due to the fact that the opcode values are not bits in a bitmask but
rather sequential integer values. Creating a opcode/mask pair that
would successfully capture a set of packets was nearly impossible.
3. The code was fragmented and used too many debugfs entries to
operate and control. This was confusing to users.
4. It did not allow filtering fault injection on a per direction basis -
egress vs. ingress.
In order to improve or fix the above issues, the following changes have
been made:
1. The fault injection methods have been combined into a single fault
injection facility. As such, the fault injection has been plugged
into both the send and receive code paths. Regardless of method used
the fault injection will operate on both egress and ingress packets.
2. The type of fault injection - by packet or by opcode - is now controlled
by changing the boolean value of the file "opcode_mode". When the value
is set to True, fault injection is done by opcode. Otherwise, by
packet.
2. The masking ability has been removed in favor of a bitmap that holds
opcodes of interest (one bit per opcode, a total of 256 bits). This
works in tandem with the "opcode_mode" value. When the value of
"opcode_mode" is False, this bitmap is ignored. When the value is
True, the bitmap lists all opcodes to be considered for fault injection.
By default, the bitmap is empty. When the user wants to filter by opcode,
the user sets the corresponding bit in the bitmap by echo'ing the bit
position into the 'opcodes' file. This gets around the issue that the set
of opcodes does not lend itself to effective masks and allow for extremely
fine-grained filtering by opcode.
4. fault_packet and fault_opcode methods have been combined. Hence, there
is only one debugfs directory controlling the entire operation of the
fault injection machinery. This reduces the number of debugfs entries
and provides a more unified user experience.
5. A new control files - "direction" - is provided to allow the user to
control the direction of packets, which are subject to fault injection.
6. A new control file - "skip_usec" - is added that would allow the user
to specify a "timeout" during which no fault injection will occur.
In addition, the following bug fixes have been applied:
1. The fault injection code has been split into its own header and source
files. This was done to better organize the code and support conditional
compilation without littering the code with #ifdef's.
2. The method by which the TX PIO packets were being marked for drop
conflicted with the way send contexts were being setup. As a result,
the send context was repeatedly being reset.
3. The fault injection only makes sense when the user can control it
through the debugfs entries. However, a kernel configuration can
enable fault injection but keep fault injection debugfs entries
disabled. Therefore, it makes sense that the HFI fault injection
code depends on both.
4. Error suppression did not take into account the method by which PIO
packets were being dropped. Therefore, even with error suppression
turned on, errors would still be displayed to the screen. A larger
enough packet drop percentage would case the kernel to crash because
the driver would be stuck printing errors.
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Reviewed-by: Don Hiatt <don.hiatt@intel.com>
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Mitko Haralanov <mitko.haralanov@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2018-05-02 21:43:24 +08:00
|
|
|
* Copyright(c) 2015-2018 Intel Corporation.
|
2015-07-31 03:17:43 +08:00
|
|
|
*
|
|
|
|
* This file is provided under a dual BSD/GPLv2 license. When using or
|
|
|
|
* redistributing this file, you may do so under either license.
|
|
|
|
*
|
|
|
|
* GPL LICENSE SUMMARY
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* BSD LICENSE
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* - Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* - Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* - Neither the name of Intel Corporation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/prefetch.h>
|
2016-01-20 06:42:11 +08:00
|
|
|
#include <rdma/ib_verbs.h>
|
2015-07-31 03:17:43 +08:00
|
|
|
|
|
|
|
#include "hfi.h"
|
|
|
|
#include "trace.h"
|
|
|
|
#include "qp.h"
|
|
|
|
#include "sdma.h"
|
2017-03-21 08:26:14 +08:00
|
|
|
#include "debugfs.h"
|
2017-04-13 11:29:28 +08:00
|
|
|
#include "vnic.h"
|
IB/hfi1: Rework fault injection machinery
The packet fault injection code present in the HFI1 driver had some
issues which not only fragment the code but also created user
confusion. Furthermore, it suffered from the following issues:
1. The fault_packet method only worked for received packets. This
meant that the only fault injection mode available for sent
packets is fault_opcode, which did not allow for random packet
drops on all egressing packets.
2. The mask available for the fault_opcode mode did not really work
due to the fact that the opcode values are not bits in a bitmask but
rather sequential integer values. Creating a opcode/mask pair that
would successfully capture a set of packets was nearly impossible.
3. The code was fragmented and used too many debugfs entries to
operate and control. This was confusing to users.
4. It did not allow filtering fault injection on a per direction basis -
egress vs. ingress.
In order to improve or fix the above issues, the following changes have
been made:
1. The fault injection methods have been combined into a single fault
injection facility. As such, the fault injection has been plugged
into both the send and receive code paths. Regardless of method used
the fault injection will operate on both egress and ingress packets.
2. The type of fault injection - by packet or by opcode - is now controlled
by changing the boolean value of the file "opcode_mode". When the value
is set to True, fault injection is done by opcode. Otherwise, by
packet.
2. The masking ability has been removed in favor of a bitmap that holds
opcodes of interest (one bit per opcode, a total of 256 bits). This
works in tandem with the "opcode_mode" value. When the value of
"opcode_mode" is False, this bitmap is ignored. When the value is
True, the bitmap lists all opcodes to be considered for fault injection.
By default, the bitmap is empty. When the user wants to filter by opcode,
the user sets the corresponding bit in the bitmap by echo'ing the bit
position into the 'opcodes' file. This gets around the issue that the set
of opcodes does not lend itself to effective masks and allow for extremely
fine-grained filtering by opcode.
4. fault_packet and fault_opcode methods have been combined. Hence, there
is only one debugfs directory controlling the entire operation of the
fault injection machinery. This reduces the number of debugfs entries
and provides a more unified user experience.
5. A new control files - "direction" - is provided to allow the user to
control the direction of packets, which are subject to fault injection.
6. A new control file - "skip_usec" - is added that would allow the user
to specify a "timeout" during which no fault injection will occur.
In addition, the following bug fixes have been applied:
1. The fault injection code has been split into its own header and source
files. This was done to better organize the code and support conditional
compilation without littering the code with #ifdef's.
2. The method by which the TX PIO packets were being marked for drop
conflicted with the way send contexts were being setup. As a result,
the send context was repeatedly being reset.
3. The fault injection only makes sense when the user can control it
through the debugfs entries. However, a kernel configuration can
enable fault injection but keep fault injection debugfs entries
disabled. Therefore, it makes sense that the HFI fault injection
code depends on both.
4. Error suppression did not take into account the method by which PIO
packets were being dropped. Therefore, even with error suppression
turned on, errors would still be displayed to the screen. A larger
enough packet drop percentage would case the kernel to crash because
the driver would be stuck printing errors.
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Reviewed-by: Don Hiatt <don.hiatt@intel.com>
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Mitko Haralanov <mitko.haralanov@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2018-05-02 21:43:24 +08:00
|
|
|
#include "fault.h"
|
2015-07-31 03:17:43 +08:00
|
|
|
|
|
|
|
#undef pr_fmt
|
|
|
|
#define pr_fmt(fmt) DRIVER_NAME ": " fmt
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The size has to be longer than this string, so we can append
|
|
|
|
* board/chip information to it in the initialization code.
|
|
|
|
*/
|
|
|
|
const char ib_hfi1_version[] = HFI1_DRIVER_VERSION "\n";
|
|
|
|
|
|
|
|
DEFINE_MUTEX(hfi1_mutex); /* general driver use */
|
|
|
|
|
|
|
|
unsigned int hfi1_max_mtu = HFI1_DEFAULT_MAX_MTU;
|
|
|
|
module_param_named(max_mtu, hfi1_max_mtu, uint, S_IRUGO);
|
2016-04-13 02:17:09 +08:00
|
|
|
MODULE_PARM_DESC(max_mtu, "Set max MTU bytes, default is " __stringify(
|
|
|
|
HFI1_DEFAULT_MAX_MTU));
|
2015-07-31 03:17:43 +08:00
|
|
|
|
|
|
|
unsigned int hfi1_cu = 1;
|
|
|
|
module_param_named(cu, hfi1_cu, uint, S_IRUGO);
|
|
|
|
MODULE_PARM_DESC(cu, "Credit return units");
|
|
|
|
|
|
|
|
unsigned long hfi1_cap_mask = HFI1_CAP_MASK_DEFAULT;
|
2017-05-04 20:14:39 +08:00
|
|
|
static int hfi1_caps_set(const char *val, const struct kernel_param *kp);
|
|
|
|
static int hfi1_caps_get(char *buffer, const struct kernel_param *kp);
|
2015-07-31 03:17:43 +08:00
|
|
|
static const struct kernel_param_ops cap_ops = {
|
|
|
|
.set = hfi1_caps_set,
|
|
|
|
.get = hfi1_caps_get
|
|
|
|
};
|
|
|
|
module_param_cb(cap_mask, &cap_ops, &hfi1_cap_mask, S_IWUSR | S_IRUGO);
|
|
|
|
MODULE_PARM_DESC(cap_mask, "Bit mask of enabled/disabled HW features");
|
|
|
|
|
|
|
|
MODULE_LICENSE("Dual BSD/GPL");
|
|
|
|
MODULE_DESCRIPTION("Intel Omni-Path Architecture driver");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MAX_PKT_RCV is the max # if packets processed per receive interrupt.
|
|
|
|
*/
|
|
|
|
#define MAX_PKT_RECV 64
|
2017-02-08 21:26:02 +08:00
|
|
|
/*
|
|
|
|
* MAX_PKT_THREAD_RCV is the max # of packets processed before
|
|
|
|
* the qp_wait_list queue is flushed.
|
|
|
|
*/
|
|
|
|
#define MAX_PKT_RECV_THREAD (MAX_PKT_RECV * 4)
|
2015-07-31 03:17:43 +08:00
|
|
|
#define EGR_HEAD_UPDATE_THRESHOLD 16
|
|
|
|
|
|
|
|
struct hfi1_ib_stats hfi1_stats;
|
|
|
|
|
|
|
|
static int hfi1_caps_set(const char *val, const struct kernel_param *kp)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
unsigned long *cap_mask_ptr = (unsigned long *)kp->arg,
|
|
|
|
cap_mask = *cap_mask_ptr, value, diff,
|
|
|
|
write_mask = ((HFI1_CAP_WRITABLE_MASK << HFI1_CAP_USER_SHIFT) |
|
|
|
|
HFI1_CAP_WRITABLE_MASK);
|
|
|
|
|
|
|
|
ret = kstrtoul(val, 0, &value);
|
|
|
|
if (ret) {
|
|
|
|
pr_warn("Invalid module parameter value for 'cap_mask'\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
/* Get the changed bits (except the locked bit) */
|
|
|
|
diff = value ^ (cap_mask & ~HFI1_CAP_LOCKED_SMASK);
|
|
|
|
|
|
|
|
/* Remove any bits that are not allowed to change after driver load */
|
|
|
|
if (HFI1_CAP_LOCKED() && (diff & ~write_mask)) {
|
|
|
|
pr_warn("Ignoring non-writable capability bits %#lx\n",
|
|
|
|
diff & ~write_mask);
|
|
|
|
diff &= write_mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mask off any reserved bits */
|
|
|
|
diff &= ~HFI1_CAP_RESERVED_MASK;
|
|
|
|
/* Clear any previously set and changing bits */
|
|
|
|
cap_mask &= ~diff;
|
|
|
|
/* Update the bits with the new capability */
|
|
|
|
cap_mask |= (value & diff);
|
|
|
|
/* Check for any kernel/user restrictions */
|
|
|
|
diff = (cap_mask & (HFI1_CAP_MUST_HAVE_KERN << HFI1_CAP_USER_SHIFT)) ^
|
|
|
|
((cap_mask & HFI1_CAP_MUST_HAVE_KERN) << HFI1_CAP_USER_SHIFT);
|
|
|
|
cap_mask &= ~diff;
|
|
|
|
/* Set the bitmask to the final set */
|
|
|
|
*cap_mask_ptr = cap_mask;
|
|
|
|
done:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hfi1_caps_get(char *buffer, const struct kernel_param *kp)
|
|
|
|
{
|
|
|
|
unsigned long cap_mask = *(unsigned long *)kp->arg;
|
|
|
|
|
|
|
|
cap_mask &= ~HFI1_CAP_LOCKED_SMASK;
|
|
|
|
cap_mask |= ((cap_mask & HFI1_CAP_K2U) << HFI1_CAP_USER_SHIFT);
|
|
|
|
|
|
|
|
return scnprintf(buffer, PAGE_SIZE, "0x%lx", cap_mask);
|
|
|
|
}
|
|
|
|
|
2016-01-20 06:42:06 +08:00
|
|
|
struct pci_dev *get_pci_dev(struct rvt_dev_info *rdi)
|
|
|
|
{
|
|
|
|
struct hfi1_ibdev *ibdev = container_of(rdi, struct hfi1_ibdev, rdi);
|
|
|
|
struct hfi1_devdata *dd = container_of(ibdev,
|
|
|
|
struct hfi1_devdata, verbs_dev);
|
|
|
|
return dd->pcidev;
|
|
|
|
}
|
|
|
|
|
2015-07-31 03:17:43 +08:00
|
|
|
/*
|
|
|
|
* Return count of units with at least one port ACTIVE.
|
|
|
|
*/
|
|
|
|
int hfi1_count_active_units(void)
|
|
|
|
{
|
|
|
|
struct hfi1_devdata *dd;
|
|
|
|
struct hfi1_pportdata *ppd;
|
2019-02-09 04:41:29 +08:00
|
|
|
unsigned long index, flags;
|
2015-07-31 03:17:43 +08:00
|
|
|
int pidx, nunits_active = 0;
|
|
|
|
|
2019-02-09 04:41:29 +08:00
|
|
|
xa_lock_irqsave(&hfi1_dev_table, flags);
|
|
|
|
xa_for_each(&hfi1_dev_table, index, dd) {
|
IB/hfi1: Fix bar0 mapping to use write combining
When the debugpat kernel boot flag is turned on the following
traces are printed:
[ 1884.793168] x86/PAT: Overlap at 0x90000000-0x92000000
[ 1884.803510] x86/PAT: reserve_memtype added [mem 0x91200000-0x9127ffff],
track uncached-minus, req write-combining, ret uncached-minus
[ 1884.818167] hfi1 0000:05:00.0: hfi1_0: WC Remapped RcvArray:
ffffc9000a980000
The ioremap_wc() clearly is not returning a write combining mapping due
to an overlap where the RcvArray is mapped in a uncached mapping prior
to creating the proposed write combining mapping.
The patch replaces the single base register for uncached CSRs that
used to overlap the RcvArray with two mappings. One, kregbase1, from the
bar0 up to the RcvArray and another, kregbase2, from the end of the
RcvArray to the pio send buffer space. A new dd field, base2_start,
is used to convert the zero-based offset in the CSR routines to the
correct kregbase1/kregbase2 mapping. A single direct write of the
RcvArray CSRs is replaced with hfi1_put_tid() to insure correct access
using the new disjoint mapping.
Additionally, the kregend field is deleted since it is only ever written.
patdebug now shows the RcvArray as write combining:
[ 35.688990] x86/PAT: reserve_memtype added [mem 0x91200000-0x9127ffff],
track write-combining, req write-combining, ret write-combining
To insulate from any potential issues with write combining, all
writeq are now flushed in hfi1_put_tid() and rcv_array_wc_fill().
Reviewed-by: Mitko Haralanov <mitko.haralanov@intel.com>
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2017-07-24 22:45:31 +08:00
|
|
|
if (!(dd->flags & HFI1_PRESENT) || !dd->kregbase1)
|
2015-07-31 03:17:43 +08:00
|
|
|
continue;
|
|
|
|
for (pidx = 0; pidx < dd->num_pports; ++pidx) {
|
|
|
|
ppd = dd->pport + pidx;
|
|
|
|
if (ppd->lid && ppd->linkup) {
|
|
|
|
nunits_active++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-02-09 04:41:29 +08:00
|
|
|
xa_unlock_irqrestore(&hfi1_dev_table, flags);
|
2015-07-31 03:17:43 +08:00
|
|
|
return nunits_active;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get address of eager buffer from it's index (allocated in chunks, not
|
|
|
|
* contiguous).
|
|
|
|
*/
|
|
|
|
static inline void *get_egrbuf(const struct hfi1_ctxtdata *rcd, u64 rhf,
|
|
|
|
u8 *update)
|
|
|
|
{
|
|
|
|
u32 idx = rhf_egr_index(rhf), offset = rhf_egr_buf_offset(rhf);
|
|
|
|
|
|
|
|
*update |= !(idx & (rcd->egrbufs.threshold - 1)) && !offset;
|
|
|
|
return (void *)(((u64)(rcd->egrbufs.rcvtids[idx].addr)) +
|
|
|
|
(offset * RCV_BUF_BLOCK_SIZE));
|
|
|
|
}
|
|
|
|
|
2018-06-05 02:43:37 +08:00
|
|
|
static inline void *hfi1_get_header(struct hfi1_ctxtdata *rcd,
|
2017-05-13 00:20:20 +08:00
|
|
|
__le32 *rhf_addr)
|
|
|
|
{
|
|
|
|
u32 offset = rhf_hdrq_offset(rhf_to_cpu(rhf_addr));
|
|
|
|
|
2018-06-05 02:43:37 +08:00
|
|
|
return (void *)(rhf_addr - rcd->rhf_offset + offset);
|
2017-05-13 00:20:20 +08:00
|
|
|
}
|
|
|
|
|
2018-06-05 02:43:37 +08:00
|
|
|
static inline struct ib_header *hfi1_get_msgheader(struct hfi1_ctxtdata *rcd,
|
2017-05-13 00:20:20 +08:00
|
|
|
__le32 *rhf_addr)
|
|
|
|
{
|
2018-06-05 02:43:37 +08:00
|
|
|
return (struct ib_header *)hfi1_get_header(rcd, rhf_addr);
|
2017-05-13 00:20:20 +08:00
|
|
|
}
|
|
|
|
|
2017-08-05 04:53:58 +08:00
|
|
|
static inline struct hfi1_16b_header
|
2018-06-05 02:43:37 +08:00
|
|
|
*hfi1_get_16B_header(struct hfi1_ctxtdata *rcd,
|
2017-08-05 04:53:58 +08:00
|
|
|
__le32 *rhf_addr)
|
|
|
|
{
|
2018-06-05 02:43:37 +08:00
|
|
|
return (struct hfi1_16b_header *)hfi1_get_header(rcd, rhf_addr);
|
2017-08-05 04:53:58 +08:00
|
|
|
}
|
|
|
|
|
2015-07-31 03:17:43 +08:00
|
|
|
/*
|
|
|
|
* Validate and encode the a given RcvArray Buffer size.
|
|
|
|
* The function will check whether the given size falls within
|
|
|
|
* allowed size ranges for the respective type and, optionally,
|
|
|
|
* return the proper encoding.
|
|
|
|
*/
|
2017-02-08 21:26:02 +08:00
|
|
|
int hfi1_rcvbuf_validate(u32 size, u8 type, u16 *encoded)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
2016-03-05 01:10:17 +08:00
|
|
|
if (unlikely(!PAGE_ALIGNED(size)))
|
2015-07-31 03:17:43 +08:00
|
|
|
return 0;
|
|
|
|
if (unlikely(size < MIN_EAGER_BUFFER))
|
|
|
|
return 0;
|
|
|
|
if (size >
|
|
|
|
(type == PT_EAGER ? MAX_EAGER_BUFFER : MAX_EXPECTED_BUFFER))
|
|
|
|
return 0;
|
|
|
|
if (encoded)
|
|
|
|
*encoded = ilog2(size / PAGE_SIZE) + 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rcv_hdrerr(struct hfi1_ctxtdata *rcd, struct hfi1_pportdata *ppd,
|
|
|
|
struct hfi1_packet *packet)
|
|
|
|
{
|
2016-09-06 19:35:05 +08:00
|
|
|
struct ib_header *rhdr = packet->hdr;
|
2015-07-31 03:17:43 +08:00
|
|
|
u32 rte = rhf_rcv_type_err(packet->rhf);
|
2017-08-05 04:54:10 +08:00
|
|
|
u32 mlid_base;
|
2017-02-08 21:26:25 +08:00
|
|
|
struct hfi1_ibport *ibp = rcd_to_iport(rcd);
|
2016-01-20 06:43:44 +08:00
|
|
|
struct hfi1_devdata *dd = ppd->dd;
|
2018-02-02 02:46:46 +08:00
|
|
|
struct hfi1_ibdev *verbs_dev = &dd->verbs_dev;
|
|
|
|
struct rvt_dev_info *rdi = &verbs_dev->rdi;
|
|
|
|
|
|
|
|
if ((packet->rhf & RHF_DC_ERR) &&
|
|
|
|
hfi1_dbg_fault_suppress_err(verbs_dev))
|
|
|
|
return;
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2019-04-11 22:17:21 +08:00
|
|
|
if (packet->rhf & RHF_ICRC_ERR)
|
2015-07-31 03:17:43 +08:00
|
|
|
return;
|
|
|
|
|
2017-08-05 04:54:10 +08:00
|
|
|
if (packet->etype == RHF_RCV_TYPE_BYPASS) {
|
2017-05-13 00:20:20 +08:00
|
|
|
goto drop;
|
2017-08-05 04:54:10 +08:00
|
|
|
} else {
|
|
|
|
u8 lnh = ib_get_lnh(rhdr);
|
|
|
|
|
|
|
|
mlid_base = be16_to_cpu(IB_MULTICAST_LID_BASE);
|
|
|
|
if (lnh == HFI1_LRH_BTH) {
|
|
|
|
packet->ohdr = &rhdr->u.oth;
|
|
|
|
} else if (lnh == HFI1_LRH_GRH) {
|
|
|
|
packet->ohdr = &rhdr->u.l.oth;
|
|
|
|
packet->grh = &rhdr->u.l.grh;
|
|
|
|
} else {
|
|
|
|
goto drop;
|
|
|
|
}
|
2017-05-13 00:20:20 +08:00
|
|
|
}
|
|
|
|
|
2015-07-31 03:17:43 +08:00
|
|
|
if (packet->rhf & RHF_TID_ERR) {
|
|
|
|
/* For TIDERR and RC QPs preemptively schedule a NAK */
|
|
|
|
u32 tlen = rhf_pkt_len(packet->rhf); /* in bytes */
|
2017-05-13 00:20:20 +08:00
|
|
|
u32 dlid = ib_get_dlid(rhdr);
|
2015-07-31 03:17:43 +08:00
|
|
|
u32 qp_num;
|
|
|
|
|
|
|
|
/* Sanity check packet */
|
|
|
|
if (tlen < 24)
|
|
|
|
goto drop;
|
|
|
|
|
|
|
|
/* Check for GRH */
|
2017-08-05 04:54:10 +08:00
|
|
|
if (packet->grh) {
|
2015-07-31 03:17:43 +08:00
|
|
|
u32 vtf;
|
2017-05-13 00:20:20 +08:00
|
|
|
struct ib_grh *grh = packet->grh;
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2017-05-13 00:20:20 +08:00
|
|
|
if (grh->next_hdr != IB_GRH_NEXT_HDR)
|
2015-07-31 03:17:43 +08:00
|
|
|
goto drop;
|
2017-05-13 00:20:20 +08:00
|
|
|
vtf = be32_to_cpu(grh->version_tclass_flow);
|
2015-07-31 03:17:43 +08:00
|
|
|
if ((vtf >> IB_GRH_VERSION_SHIFT) != IB_GRH_VERSION)
|
|
|
|
goto drop;
|
2016-02-15 12:22:00 +08:00
|
|
|
}
|
2017-05-13 00:20:20 +08:00
|
|
|
|
2015-07-31 03:17:43 +08:00
|
|
|
/* Get the destination QP number. */
|
2017-05-13 00:20:20 +08:00
|
|
|
qp_num = ib_bth_get_qpn(packet->ohdr);
|
|
|
|
if (dlid < mlid_base) {
|
2016-01-20 06:42:28 +08:00
|
|
|
struct rvt_qp *qp;
|
2015-10-26 22:28:43 +08:00
|
|
|
unsigned long flags;
|
2015-07-31 03:17:43 +08:00
|
|
|
|
|
|
|
rcu_read_lock();
|
2016-01-20 06:43:44 +08:00
|
|
|
qp = rvt_lookup_qpn(rdi, &ibp->rvp, qp_num);
|
2015-07-31 03:17:43 +08:00
|
|
|
if (!qp) {
|
|
|
|
rcu_read_unlock();
|
|
|
|
goto drop;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle only RC QPs - for other QP types drop error
|
|
|
|
* packet.
|
|
|
|
*/
|
2015-10-26 22:28:43 +08:00
|
|
|
spin_lock_irqsave(&qp->r_lock, flags);
|
2015-07-31 03:17:43 +08:00
|
|
|
|
|
|
|
/* Check for valid receive state. */
|
2016-01-20 06:43:33 +08:00
|
|
|
if (!(ib_rvt_state_ops[qp->state] &
|
|
|
|
RVT_PROCESS_RECV_OK)) {
|
2016-01-20 06:42:39 +08:00
|
|
|
ibp->rvp.n_pkt_drops++;
|
2015-07-31 03:17:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (qp->ibqp.qp_type) {
|
|
|
|
case IB_QPT_RC:
|
2017-05-13 00:20:20 +08:00
|
|
|
hfi1_rc_hdrerr(rcd, packet, qp);
|
2015-07-31 03:17:43 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* For now don't handle any other QP types */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-10-26 22:28:43 +08:00
|
|
|
spin_unlock_irqrestore(&qp->r_lock, flags);
|
2015-07-31 03:17:43 +08:00
|
|
|
rcu_read_unlock();
|
|
|
|
} /* Unicast QP */
|
|
|
|
} /* Valid packet with TIDErr */
|
|
|
|
|
|
|
|
/* handle "RcvTypeErr" flags */
|
|
|
|
switch (rte) {
|
|
|
|
case RHF_RTE_ERROR_OP_CODE_ERR:
|
|
|
|
{
|
|
|
|
void *ebuf = NULL;
|
2017-05-13 00:20:20 +08:00
|
|
|
u8 opcode;
|
2015-07-31 03:17:43 +08:00
|
|
|
|
|
|
|
if (rhf_use_egr_bfr(packet->rhf))
|
|
|
|
ebuf = packet->ebuf;
|
|
|
|
|
2016-02-15 12:19:49 +08:00
|
|
|
if (!ebuf)
|
2015-07-31 03:17:43 +08:00
|
|
|
goto drop; /* this should never happen */
|
|
|
|
|
2017-05-13 00:20:20 +08:00
|
|
|
opcode = ib_bth_get_opcode(packet->ohdr);
|
2015-07-31 03:17:43 +08:00
|
|
|
if (opcode == IB_OPCODE_CNP) {
|
|
|
|
/*
|
|
|
|
* Only in pre-B0 h/w is the CNP_OPCODE handled
|
2015-12-22 10:57:44 +08:00
|
|
|
* via this code path.
|
2015-07-31 03:17:43 +08:00
|
|
|
*/
|
2016-01-20 06:42:28 +08:00
|
|
|
struct rvt_qp *qp = NULL;
|
2015-07-31 03:17:43 +08:00
|
|
|
u32 lqpn, rqpn;
|
|
|
|
u16 rlid;
|
|
|
|
u8 svc_type, sl, sc5;
|
|
|
|
|
2017-04-10 01:16:15 +08:00
|
|
|
sc5 = hfi1_9B_get_sc5(rhdr, packet->rhf);
|
2015-07-31 03:17:43 +08:00
|
|
|
sl = ibp->sc_to_sl[sc5];
|
|
|
|
|
2017-05-13 00:20:20 +08:00
|
|
|
lqpn = ib_bth_get_qpn(packet->ohdr);
|
2015-07-31 03:17:43 +08:00
|
|
|
rcu_read_lock();
|
2016-01-20 06:43:44 +08:00
|
|
|
qp = rvt_lookup_qpn(rdi, &ibp->rvp, lqpn);
|
2016-02-15 12:19:49 +08:00
|
|
|
if (!qp) {
|
2015-07-31 03:17:43 +08:00
|
|
|
rcu_read_unlock();
|
|
|
|
goto drop;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (qp->ibqp.qp_type) {
|
|
|
|
case IB_QPT_UD:
|
|
|
|
rlid = 0;
|
|
|
|
rqpn = 0;
|
|
|
|
svc_type = IB_CC_SVCTYPE_UD;
|
|
|
|
break;
|
|
|
|
case IB_QPT_UC:
|
2017-04-10 01:16:22 +08:00
|
|
|
rlid = ib_get_slid(rhdr);
|
2015-07-31 03:17:43 +08:00
|
|
|
rqpn = qp->remote_qpn;
|
|
|
|
svc_type = IB_CC_SVCTYPE_UC;
|
|
|
|
break;
|
|
|
|
default:
|
2018-03-06 01:58:33 +08:00
|
|
|
rcu_read_unlock();
|
2015-07-31 03:17:43 +08:00
|
|
|
goto drop;
|
|
|
|
}
|
|
|
|
|
|
|
|
process_becn(ppd, sl, rlid, lqpn, rqpn, svc_type);
|
|
|
|
rcu_read_unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
packet->rhf &= ~RHF_RCV_TYPE_ERR_SMASK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
drop:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void init_packet(struct hfi1_ctxtdata *rcd,
|
2016-02-15 12:21:52 +08:00
|
|
|
struct hfi1_packet *packet)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
|
|
|
packet->rsize = rcd->rcvhdrqentsize; /* words */
|
|
|
|
packet->maxcnt = rcd->rcvhdrq_cnt * packet->rsize; /* words */
|
|
|
|
packet->rcd = rcd;
|
|
|
|
packet->updegr = 0;
|
|
|
|
packet->etail = -1;
|
2015-10-26 22:28:44 +08:00
|
|
|
packet->rhf_addr = get_rhf_addr(rcd);
|
2015-07-31 03:17:43 +08:00
|
|
|
packet->rhf = rhf_to_cpu(packet->rhf_addr);
|
|
|
|
packet->rhqoff = rcd->head;
|
|
|
|
packet->numpkt = 0;
|
|
|
|
}
|
|
|
|
|
2017-10-12 01:48:59 +08:00
|
|
|
/* We support only two types - 9B and 16B for now */
|
|
|
|
static const hfi1_handle_cnp hfi1_handle_cnp_tbl[2] = {
|
|
|
|
[HFI1_PKT_TYPE_9B] = &return_cnp,
|
|
|
|
[HFI1_PKT_TYPE_16B] = &return_cnp_16B
|
|
|
|
};
|
|
|
|
|
2018-11-29 02:19:15 +08:00
|
|
|
/**
|
|
|
|
* hfi1_process_ecn_slowpath - Process FECN or BECN bits
|
|
|
|
* @qp: The packet's destination QP
|
|
|
|
* @pkt: The packet itself.
|
|
|
|
* @prescan: Is the caller the RXQ prescan
|
|
|
|
*
|
|
|
|
* Process the packet's FECN or BECN bits. By now, the packet
|
|
|
|
* has already been evaluated whether processing of those bit should
|
|
|
|
* be done.
|
|
|
|
* The significance of the @prescan argument is that if the caller
|
|
|
|
* is the RXQ prescan, a CNP will be send out instead of waiting for the
|
|
|
|
* normal packet processing to send an ACK with BECN set (or a CNP).
|
|
|
|
*/
|
|
|
|
bool hfi1_process_ecn_slowpath(struct rvt_qp *qp, struct hfi1_packet *pkt,
|
|
|
|
bool prescan)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
|
|
|
struct hfi1_ibport *ibp = to_iport(qp->ibqp.device, qp->port_num);
|
2018-05-01 20:35:36 +08:00
|
|
|
struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
|
2016-09-06 19:35:05 +08:00
|
|
|
struct ib_other_headers *ohdr = pkt->ohdr;
|
2017-05-13 00:20:20 +08:00
|
|
|
struct ib_grh *grh = pkt->grh;
|
2018-11-29 02:19:15 +08:00
|
|
|
u32 rqpn = 0;
|
2018-05-01 20:35:36 +08:00
|
|
|
u16 pkey;
|
|
|
|
u32 rlid, slid, dlid = 0;
|
2018-11-29 02:19:15 +08:00
|
|
|
u8 hdr_type, sc, svc_type, opcode;
|
|
|
|
bool is_mcast = false, ignore_fecn = false, do_cnp = false,
|
|
|
|
fecn, becn;
|
2016-07-26 04:38:07 +08:00
|
|
|
|
2018-05-01 20:35:36 +08:00
|
|
|
/* can be called from prescan */
|
2017-08-05 04:54:23 +08:00
|
|
|
if (pkt->etype == RHF_RCV_TYPE_BYPASS) {
|
|
|
|
pkey = hfi1_16B_get_pkey(pkt->hdr);
|
|
|
|
sc = hfi1_16B_get_sc(pkt->hdr);
|
2018-05-01 20:35:36 +08:00
|
|
|
dlid = hfi1_16B_get_dlid(pkt->hdr);
|
|
|
|
slid = hfi1_16B_get_slid(pkt->hdr);
|
2018-11-29 02:19:15 +08:00
|
|
|
is_mcast = hfi1_is_16B_mcast(dlid);
|
|
|
|
opcode = ib_bth_get_opcode(ohdr);
|
2017-08-05 04:54:23 +08:00
|
|
|
hdr_type = HFI1_PKT_TYPE_16B;
|
2018-11-29 02:19:15 +08:00
|
|
|
fecn = hfi1_16B_get_fecn(pkt->hdr);
|
|
|
|
becn = hfi1_16B_get_becn(pkt->hdr);
|
2017-08-05 04:54:23 +08:00
|
|
|
} else {
|
|
|
|
pkey = ib_bth_get_pkey(ohdr);
|
|
|
|
sc = hfi1_9B_get_sc5(pkt->hdr, pkt->rhf);
|
2018-11-29 02:19:15 +08:00
|
|
|
dlid = qp->ibqp.qp_type != IB_QPT_UD ? ib_get_dlid(pkt->hdr) :
|
|
|
|
ppd->lid;
|
2018-05-01 20:35:36 +08:00
|
|
|
slid = ib_get_slid(pkt->hdr);
|
2018-11-29 02:19:15 +08:00
|
|
|
is_mcast = (dlid > be16_to_cpu(IB_MULTICAST_LID_BASE)) &&
|
|
|
|
(dlid != be16_to_cpu(IB_LID_PERMISSIVE));
|
|
|
|
opcode = ib_bth_get_opcode(ohdr);
|
2017-08-05 04:54:23 +08:00
|
|
|
hdr_type = HFI1_PKT_TYPE_9B;
|
2018-11-29 02:19:15 +08:00
|
|
|
fecn = ib_bth_get_fecn(ohdr);
|
|
|
|
becn = ib_bth_get_becn(ohdr);
|
2017-08-05 04:54:23 +08:00
|
|
|
}
|
|
|
|
|
2015-07-31 03:17:43 +08:00
|
|
|
switch (qp->ibqp.qp_type) {
|
2018-05-01 20:35:36 +08:00
|
|
|
case IB_QPT_UD:
|
|
|
|
rlid = slid;
|
|
|
|
rqpn = ib_get_sqpn(pkt->ohdr);
|
|
|
|
svc_type = IB_CC_SVCTYPE_UD;
|
|
|
|
break;
|
staging/rdma/hfi1: optionally prescan rx queue for {B, F}ECNs - UC, RC
To more rapidly respond to Explicit Congestion Notifications, prescan the
receive queue, and process FECNs, and BECNs first. When a UC, or RC packet
containing a FECN, or BECN is found, immediately react to the ECN (either by
returning a CNP, or adjusting the injection rate). Afterward, the packet will
be processed normally.
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Arthur Kepner <arthur.kepner@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-11-05 10:10:10 +08:00
|
|
|
case IB_QPT_SMI:
|
|
|
|
case IB_QPT_GSI:
|
2018-05-01 20:35:36 +08:00
|
|
|
rlid = slid;
|
2017-08-05 04:54:23 +08:00
|
|
|
rqpn = ib_get_sqpn(pkt->ohdr);
|
2015-07-31 03:17:43 +08:00
|
|
|
svc_type = IB_CC_SVCTYPE_UD;
|
|
|
|
break;
|
staging/rdma/hfi1: optionally prescan rx queue for {B, F}ECNs - UC, RC
To more rapidly respond to Explicit Congestion Notifications, prescan the
receive queue, and process FECNs, and BECNs first. When a UC, or RC packet
containing a FECN, or BECN is found, immediately react to the ECN (either by
returning a CNP, or adjusting the injection rate). Afterward, the packet will
be processed normally.
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Arthur Kepner <arthur.kepner@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-11-05 10:10:10 +08:00
|
|
|
case IB_QPT_UC:
|
2017-04-30 02:41:28 +08:00
|
|
|
rlid = rdma_ah_get_dlid(&qp->remote_ah_attr);
|
staging/rdma/hfi1: optionally prescan rx queue for {B, F}ECNs - UC, RC
To more rapidly respond to Explicit Congestion Notifications, prescan the
receive queue, and process FECNs, and BECNs first. When a UC, or RC packet
containing a FECN, or BECN is found, immediately react to the ECN (either by
returning a CNP, or adjusting the injection rate). Afterward, the packet will
be processed normally.
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Arthur Kepner <arthur.kepner@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-11-05 10:10:10 +08:00
|
|
|
rqpn = qp->remote_qpn;
|
|
|
|
svc_type = IB_CC_SVCTYPE_UC;
|
|
|
|
break;
|
|
|
|
case IB_QPT_RC:
|
2017-04-30 02:41:28 +08:00
|
|
|
rlid = rdma_ah_get_dlid(&qp->remote_ah_attr);
|
staging/rdma/hfi1: optionally prescan rx queue for {B, F}ECNs - UC, RC
To more rapidly respond to Explicit Congestion Notifications, prescan the
receive queue, and process FECNs, and BECNs first. When a UC, or RC packet
containing a FECN, or BECN is found, immediately react to the ECN (either by
returning a CNP, or adjusting the injection rate). Afterward, the packet will
be processed normally.
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Arthur Kepner <arthur.kepner@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-11-05 10:10:10 +08:00
|
|
|
rqpn = qp->remote_qpn;
|
|
|
|
svc_type = IB_CC_SVCTYPE_RC;
|
|
|
|
break;
|
2015-07-31 03:17:43 +08:00
|
|
|
default:
|
2018-11-29 02:19:15 +08:00
|
|
|
return false;
|
2015-07-31 03:17:43 +08:00
|
|
|
}
|
|
|
|
|
2018-11-29 02:19:15 +08:00
|
|
|
ignore_fecn = is_mcast || (opcode == IB_OPCODE_CNP) ||
|
|
|
|
(opcode == IB_OPCODE_RC_ACKNOWLEDGE);
|
|
|
|
/*
|
|
|
|
* ACKNOWLEDGE packets do not get a CNP but this will be
|
|
|
|
* guarded by ignore_fecn above.
|
|
|
|
*/
|
|
|
|
do_cnp = prescan ||
|
|
|
|
(opcode >= IB_OPCODE_RC_RDMA_READ_RESPONSE_FIRST &&
|
2019-03-19 03:20:59 +08:00
|
|
|
opcode <= IB_OPCODE_RC_ATOMIC_ACKNOWLEDGE) ||
|
|
|
|
opcode == TID_OP(READ_RESP) ||
|
|
|
|
opcode == TID_OP(ACK);
|
2018-11-29 02:19:15 +08:00
|
|
|
|
2017-08-05 04:54:23 +08:00
|
|
|
/* Call appropriate CNP handler */
|
2018-11-29 02:19:15 +08:00
|
|
|
if (!ignore_fecn && do_cnp && fecn)
|
2017-08-05 04:54:23 +08:00
|
|
|
hfi1_handle_cnp_tbl[hdr_type](ibp, qp, rqpn, pkey,
|
|
|
|
dlid, rlid, sc, grh);
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2018-11-29 02:19:15 +08:00
|
|
|
if (becn) {
|
|
|
|
u32 lqpn = be32_to_cpu(ohdr->bth[1]) & RVT_QPN_MASK;
|
2016-07-26 04:38:07 +08:00
|
|
|
u8 sl = ibp->sc_to_sl[sc];
|
2015-07-31 03:17:43 +08:00
|
|
|
|
staging/rdma/hfi1: optionally prescan rx queue for {B, F}ECNs - UC, RC
To more rapidly respond to Explicit Congestion Notifications, prescan the
receive queue, and process FECNs, and BECNs first. When a UC, or RC packet
containing a FECN, or BECN is found, immediately react to the ECN (either by
returning a CNP, or adjusting the injection rate). Afterward, the packet will
be processed normally.
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Arthur Kepner <arthur.kepner@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-11-05 10:10:10 +08:00
|
|
|
process_becn(ppd, sl, rlid, lqpn, rqpn, svc_type);
|
2015-07-31 03:17:43 +08:00
|
|
|
}
|
2018-11-29 02:19:15 +08:00
|
|
|
return !ignore_fecn && fecn;
|
2015-07-31 03:17:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
struct ps_mdata {
|
|
|
|
struct hfi1_ctxtdata *rcd;
|
|
|
|
u32 rsize;
|
|
|
|
u32 maxcnt;
|
|
|
|
u32 ps_head;
|
|
|
|
u32 ps_tail;
|
|
|
|
u32 ps_seq;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void init_ps_mdata(struct ps_mdata *mdata,
|
|
|
|
struct hfi1_packet *packet)
|
|
|
|
{
|
|
|
|
struct hfi1_ctxtdata *rcd = packet->rcd;
|
|
|
|
|
|
|
|
mdata->rcd = rcd;
|
|
|
|
mdata->rsize = packet->rsize;
|
|
|
|
mdata->maxcnt = packet->maxcnt;
|
2015-11-05 10:10:09 +08:00
|
|
|
mdata->ps_head = packet->rhqoff;
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2015-11-11 13:35:19 +08:00
|
|
|
if (HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL)) {
|
2015-11-05 10:10:09 +08:00
|
|
|
mdata->ps_tail = get_rcvhdrtail(rcd);
|
2015-11-11 13:35:19 +08:00
|
|
|
if (rcd->ctxt == HFI1_CTRL_CTXT)
|
|
|
|
mdata->ps_seq = rcd->seq_cnt;
|
|
|
|
else
|
|
|
|
mdata->ps_seq = 0; /* not used with DMA_RTAIL */
|
2015-07-31 03:17:43 +08:00
|
|
|
} else {
|
|
|
|
mdata->ps_tail = 0; /* used only with DMA_RTAIL*/
|
|
|
|
mdata->ps_seq = rcd->seq_cnt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-11 13:35:19 +08:00
|
|
|
static inline int ps_done(struct ps_mdata *mdata, u64 rhf,
|
|
|
|
struct hfi1_ctxtdata *rcd)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
2015-11-11 13:35:19 +08:00
|
|
|
if (HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL))
|
2015-07-31 03:17:43 +08:00
|
|
|
return mdata->ps_head == mdata->ps_tail;
|
|
|
|
return mdata->ps_seq != rhf_rcv_seq(rhf);
|
|
|
|
}
|
|
|
|
|
2015-11-11 13:35:19 +08:00
|
|
|
static inline int ps_skip(struct ps_mdata *mdata, u64 rhf,
|
|
|
|
struct hfi1_ctxtdata *rcd)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Control context can potentially receive an invalid rhf.
|
|
|
|
* Drop such packets.
|
|
|
|
*/
|
|
|
|
if ((rcd->ctxt == HFI1_CTRL_CTXT) && (mdata->ps_head != mdata->ps_tail))
|
|
|
|
return mdata->ps_seq != rhf_rcv_seq(rhf);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void update_ps_mdata(struct ps_mdata *mdata,
|
|
|
|
struct hfi1_ctxtdata *rcd)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
|
|
|
mdata->ps_head += mdata->rsize;
|
2015-11-05 10:10:09 +08:00
|
|
|
if (mdata->ps_head >= mdata->maxcnt)
|
2015-07-31 03:17:43 +08:00
|
|
|
mdata->ps_head = 0;
|
2015-11-11 13:35:19 +08:00
|
|
|
|
|
|
|
/* Control context must do seq counting */
|
|
|
|
if (!HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL) ||
|
|
|
|
(rcd->ctxt == HFI1_CTRL_CTXT)) {
|
2015-07-31 03:17:43 +08:00
|
|
|
if (++mdata->ps_seq > 13)
|
|
|
|
mdata->ps_seq = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* prescan_rxq - search through the receive queue looking for packets
|
|
|
|
* containing Excplicit Congestion Notifications (FECNs, or BECNs).
|
|
|
|
* When an ECN is found, process the Congestion Notification, and toggle
|
|
|
|
* it off.
|
2016-02-04 06:32:57 +08:00
|
|
|
* This is declared as a macro to allow quick checking of the port to avoid
|
|
|
|
* the overhead of a function call if not enabled.
|
2015-07-31 03:17:43 +08:00
|
|
|
*/
|
2016-02-04 06:32:57 +08:00
|
|
|
#define prescan_rxq(rcd, packet) \
|
|
|
|
do { \
|
|
|
|
if (rcd->ppd->cc_prescan) \
|
|
|
|
__prescan_rxq(packet); \
|
|
|
|
} while (0)
|
|
|
|
static void __prescan_rxq(struct hfi1_packet *packet)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
|
|
|
struct hfi1_ctxtdata *rcd = packet->rcd;
|
|
|
|
struct ps_mdata mdata;
|
|
|
|
|
|
|
|
init_ps_mdata(&mdata, packet);
|
|
|
|
|
|
|
|
while (1) {
|
2017-02-08 21:26:25 +08:00
|
|
|
struct hfi1_ibport *ibp = rcd_to_iport(rcd);
|
2016-02-15 12:19:41 +08:00
|
|
|
__le32 *rhf_addr = (__le32 *)rcd->rcvhdrq + mdata.ps_head +
|
2018-06-05 02:43:37 +08:00
|
|
|
packet->rcd->rhf_offset;
|
2016-01-20 06:42:28 +08:00
|
|
|
struct rvt_qp *qp;
|
2016-09-06 19:35:05 +08:00
|
|
|
struct ib_header *hdr;
|
2018-06-05 02:43:37 +08:00
|
|
|
struct rvt_dev_info *rdi = &rcd->dd->verbs_dev.rdi;
|
2015-07-31 03:17:43 +08:00
|
|
|
u64 rhf = rhf_to_cpu(rhf_addr);
|
staging/rdma/hfi1: optionally prescan rx queue for {B, F}ECNs - UC, RC
To more rapidly respond to Explicit Congestion Notifications, prescan the
receive queue, and process FECNs, and BECNs first. When a UC, or RC packet
containing a FECN, or BECN is found, immediately react to the ECN (either by
returning a CNP, or adjusting the injection rate). Afterward, the packet will
be processed normally.
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Arthur Kepner <arthur.kepner@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-11-05 10:10:10 +08:00
|
|
|
u32 etype = rhf_rcv_type(rhf), qpn, bth1;
|
2015-07-31 03:17:43 +08:00
|
|
|
u8 lnh;
|
|
|
|
|
2015-11-11 13:35:19 +08:00
|
|
|
if (ps_done(&mdata, rhf, rcd))
|
2015-07-31 03:17:43 +08:00
|
|
|
break;
|
|
|
|
|
2015-11-11 13:35:19 +08:00
|
|
|
if (ps_skip(&mdata, rhf, rcd))
|
|
|
|
goto next;
|
|
|
|
|
2015-07-31 03:17:43 +08:00
|
|
|
if (etype != RHF_RCV_TYPE_IB)
|
|
|
|
goto next;
|
|
|
|
|
2018-06-05 02:43:37 +08:00
|
|
|
packet->hdr = hfi1_get_msgheader(packet->rcd, rhf_addr);
|
2016-10-26 04:12:23 +08:00
|
|
|
hdr = packet->hdr;
|
2017-04-10 01:16:22 +08:00
|
|
|
lnh = ib_get_lnh(hdr);
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2016-10-26 04:12:23 +08:00
|
|
|
if (lnh == HFI1_LRH_BTH) {
|
|
|
|
packet->ohdr = &hdr->u.oth;
|
2017-05-13 00:20:20 +08:00
|
|
|
packet->grh = NULL;
|
2016-10-26 04:12:23 +08:00
|
|
|
} else if (lnh == HFI1_LRH_GRH) {
|
|
|
|
packet->ohdr = &hdr->u.l.oth;
|
2017-05-13 00:20:20 +08:00
|
|
|
packet->grh = &hdr->u.l.grh;
|
2016-10-26 04:12:23 +08:00
|
|
|
} else {
|
2015-07-31 03:17:43 +08:00
|
|
|
goto next; /* just in case */
|
2016-10-26 04:12:23 +08:00
|
|
|
}
|
2016-07-26 04:38:07 +08:00
|
|
|
|
2018-11-29 02:19:15 +08:00
|
|
|
if (!hfi1_may_ecn(packet))
|
2015-07-31 03:17:43 +08:00
|
|
|
goto next;
|
|
|
|
|
2018-11-29 02:19:15 +08:00
|
|
|
bth1 = be32_to_cpu(packet->ohdr->bth[1]);
|
2016-01-20 06:43:44 +08:00
|
|
|
qpn = bth1 & RVT_QPN_MASK;
|
2015-07-31 03:17:43 +08:00
|
|
|
rcu_read_lock();
|
2016-01-20 06:43:44 +08:00
|
|
|
qp = rvt_lookup_qpn(rdi, &ibp->rvp, qpn);
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2016-02-15 12:19:49 +08:00
|
|
|
if (!qp) {
|
2015-07-31 03:17:43 +08:00
|
|
|
rcu_read_unlock();
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
|
2018-11-29 02:19:15 +08:00
|
|
|
hfi1_process_ecn_slowpath(qp, packet, true);
|
2015-07-31 03:17:43 +08:00
|
|
|
rcu_read_unlock();
|
staging/rdma/hfi1: optionally prescan rx queue for {B, F}ECNs - UC, RC
To more rapidly respond to Explicit Congestion Notifications, prescan the
receive queue, and process FECNs, and BECNs first. When a UC, or RC packet
containing a FECN, or BECN is found, immediately react to the ECN (either by
returning a CNP, or adjusting the injection rate). Afterward, the packet will
be processed normally.
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Arthur Kepner <arthur.kepner@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-11-05 10:10:10 +08:00
|
|
|
|
|
|
|
/* turn off BECN, FECN */
|
2017-04-10 01:16:28 +08:00
|
|
|
bth1 &= ~(IB_FECN_SMASK | IB_BECN_SMASK);
|
2016-10-26 04:12:23 +08:00
|
|
|
packet->ohdr->bth[1] = cpu_to_be32(bth1);
|
2015-07-31 03:17:43 +08:00
|
|
|
next:
|
2015-11-11 13:35:19 +08:00
|
|
|
update_ps_mdata(&mdata, rcd);
|
2015-07-31 03:17:43 +08:00
|
|
|
}
|
|
|
|
}
|
2015-11-11 13:35:19 +08:00
|
|
|
|
2018-02-02 02:46:31 +08:00
|
|
|
static void process_rcv_qp_work(struct hfi1_packet *packet)
|
2017-02-08 21:26:02 +08:00
|
|
|
{
|
|
|
|
struct rvt_qp *qp, *nqp;
|
2018-02-02 02:46:31 +08:00
|
|
|
struct hfi1_ctxtdata *rcd = packet->rcd;
|
2017-02-08 21:26:02 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Iterate over all QPs waiting to respond.
|
|
|
|
* The list won't change since the IRQ is only run on one CPU.
|
|
|
|
*/
|
|
|
|
list_for_each_entry_safe(qp, nqp, &rcd->qp_wait_list, rspwait) {
|
|
|
|
list_del_init(&qp->rspwait);
|
|
|
|
if (qp->r_flags & RVT_R_RSP_NAK) {
|
|
|
|
qp->r_flags &= ~RVT_R_RSP_NAK;
|
2018-02-02 02:46:31 +08:00
|
|
|
packet->qp = qp;
|
|
|
|
hfi1_send_rc_ack(packet, 0);
|
2017-02-08 21:26:02 +08:00
|
|
|
}
|
|
|
|
if (qp->r_flags & RVT_R_RSP_SEND) {
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
qp->r_flags &= ~RVT_R_RSP_SEND;
|
|
|
|
spin_lock_irqsave(&qp->s_lock, flags);
|
|
|
|
if (ib_rvt_state_ops[qp->state] &
|
|
|
|
RVT_PROCESS_OR_FLUSH_SEND)
|
|
|
|
hfi1_schedule_send(qp);
|
|
|
|
spin_unlock_irqrestore(&qp->s_lock, flags);
|
|
|
|
}
|
|
|
|
rvt_put_qp(qp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static noinline int max_packet_exceeded(struct hfi1_packet *packet, int thread)
|
|
|
|
{
|
|
|
|
if (thread) {
|
|
|
|
if ((packet->numpkt & (MAX_PKT_RECV_THREAD - 1)) == 0)
|
|
|
|
/* allow defered processing */
|
2018-02-02 02:46:31 +08:00
|
|
|
process_rcv_qp_work(packet);
|
2017-02-08 21:26:02 +08:00
|
|
|
cond_resched();
|
|
|
|
return RCV_PKT_OK;
|
|
|
|
} else {
|
|
|
|
this_cpu_inc(*packet->rcd->dd->rcv_limit);
|
|
|
|
return RCV_PKT_LIMIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int check_max_packet(struct hfi1_packet *packet, int thread)
|
2015-11-11 13:35:19 +08:00
|
|
|
{
|
|
|
|
int ret = RCV_PKT_OK;
|
|
|
|
|
2017-02-08 21:26:02 +08:00
|
|
|
if (unlikely((packet->numpkt & (MAX_PKT_RECV - 1)) == 0))
|
|
|
|
ret = max_packet_exceeded(packet, thread);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static noinline int skip_rcv_packet(struct hfi1_packet *packet, int thread)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2024-06-11 20:08:33 +08:00
|
|
|
packet->rcd->dd->ctx0_seq_drop++;
|
2015-11-11 13:35:19 +08:00
|
|
|
/* Set up for the next packet */
|
|
|
|
packet->rhqoff += packet->rsize;
|
|
|
|
if (packet->rhqoff >= packet->maxcnt)
|
|
|
|
packet->rhqoff = 0;
|
|
|
|
|
|
|
|
packet->numpkt++;
|
2017-02-08 21:26:02 +08:00
|
|
|
ret = check_max_packet(packet, thread);
|
2015-11-11 13:35:19 +08:00
|
|
|
|
|
|
|
packet->rhf_addr = (__le32 *)packet->rcd->rcvhdrq + packet->rhqoff +
|
2018-06-05 02:43:37 +08:00
|
|
|
packet->rcd->rhf_offset;
|
2015-11-11 13:35:19 +08:00
|
|
|
packet->rhf = rhf_to_cpu(packet->rhf_addr);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2015-10-26 22:28:44 +08:00
|
|
|
static inline int process_rcv_packet(struct hfi1_packet *packet, int thread)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
2017-02-08 21:26:02 +08:00
|
|
|
int ret;
|
2015-07-31 03:17:43 +08:00
|
|
|
|
|
|
|
packet->etype = rhf_rcv_type(packet->rhf);
|
2017-05-13 00:20:20 +08:00
|
|
|
|
2015-07-31 03:17:43 +08:00
|
|
|
/* total length */
|
|
|
|
packet->tlen = rhf_pkt_len(packet->rhf); /* in bytes */
|
|
|
|
/* retrieve eager buffer details */
|
|
|
|
packet->ebuf = NULL;
|
|
|
|
if (rhf_use_egr_bfr(packet->rhf)) {
|
|
|
|
packet->etail = rhf_egr_index(packet->rhf);
|
|
|
|
packet->ebuf = get_egrbuf(packet->rcd, packet->rhf,
|
|
|
|
&packet->updegr);
|
|
|
|
/*
|
|
|
|
* Prefetch the contents of the eager buffer. It is
|
|
|
|
* OK to send a negative length to prefetch_range().
|
|
|
|
* The +2 is the size of the RHF.
|
|
|
|
*/
|
|
|
|
prefetch_range(packet->ebuf,
|
2016-02-15 12:21:52 +08:00
|
|
|
packet->tlen - ((packet->rcd->rcvhdrqentsize -
|
|
|
|
(rhf_hdrq_offset(packet->rhf)
|
|
|
|
+ 2)) * 4));
|
2015-07-31 03:17:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Call a type specific handler for the packet. We
|
|
|
|
* should be able to trust that etype won't be beyond
|
|
|
|
* the range of valid indexes. If so something is really
|
|
|
|
* wrong and we can probably just let things come
|
|
|
|
* crashing down. There is no need to eat another
|
|
|
|
* comparison in this performance critical code.
|
|
|
|
*/
|
2018-06-05 02:43:29 +08:00
|
|
|
packet->rcd->rhf_rcv_function_map[packet->etype](packet);
|
2015-07-31 03:17:43 +08:00
|
|
|
packet->numpkt++;
|
|
|
|
|
|
|
|
/* Set up for the next packet */
|
|
|
|
packet->rhqoff += packet->rsize;
|
|
|
|
if (packet->rhqoff >= packet->maxcnt)
|
|
|
|
packet->rhqoff = 0;
|
|
|
|
|
2017-02-08 21:26:02 +08:00
|
|
|
ret = check_max_packet(packet, thread);
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2016-02-15 12:19:41 +08:00
|
|
|
packet->rhf_addr = (__le32 *)packet->rcd->rcvhdrq + packet->rhqoff +
|
2018-06-05 02:43:37 +08:00
|
|
|
packet->rcd->rhf_offset;
|
2015-07-31 03:17:43 +08:00
|
|
|
packet->rhf = rhf_to_cpu(packet->rhf_addr);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void process_rcv_update(int last, struct hfi1_packet *packet)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Update head regs etc., every 16 packets, if not last pkt,
|
|
|
|
* to help prevent rcvhdrq overflows, when many packets
|
|
|
|
* are processed and queue is nearly full.
|
|
|
|
* Don't request an interrupt for intermediate updates.
|
|
|
|
*/
|
|
|
|
if (!last && !(packet->numpkt & 0xf)) {
|
|
|
|
update_usrhead(packet->rcd, packet->rhqoff, packet->updegr,
|
|
|
|
packet->etail, 0, 0);
|
|
|
|
packet->updegr = 0;
|
|
|
|
}
|
2017-05-13 00:20:20 +08:00
|
|
|
packet->grh = NULL;
|
2015-07-31 03:17:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void finish_packet(struct hfi1_packet *packet)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Nothing we need to free for the packet.
|
|
|
|
*
|
|
|
|
* The only thing we need to do is a final update and call for an
|
|
|
|
* interrupt
|
|
|
|
*/
|
|
|
|
update_usrhead(packet->rcd, packet->rcd->head, packet->updegr,
|
|
|
|
packet->etail, rcv_intr_dynamic, packet->numpkt);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle receive interrupts when using the no dma rtail option.
|
|
|
|
*/
|
2015-10-26 22:28:44 +08:00
|
|
|
int handle_receive_interrupt_nodma_rtail(struct hfi1_ctxtdata *rcd, int thread)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
|
|
|
u32 seq;
|
2015-10-26 22:28:44 +08:00
|
|
|
int last = RCV_PKT_OK;
|
2015-07-31 03:17:43 +08:00
|
|
|
struct hfi1_packet packet;
|
|
|
|
|
|
|
|
init_packet(rcd, &packet);
|
|
|
|
seq = rhf_rcv_seq(packet.rhf);
|
2015-10-26 22:28:44 +08:00
|
|
|
if (seq != rcd->seq_cnt) {
|
|
|
|
last = RCV_PKT_DONE;
|
2015-07-31 03:17:43 +08:00
|
|
|
goto bail;
|
2015-10-26 22:28:44 +08:00
|
|
|
}
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2016-02-04 06:32:57 +08:00
|
|
|
prescan_rxq(rcd, &packet);
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2015-10-26 22:28:44 +08:00
|
|
|
while (last == RCV_PKT_OK) {
|
|
|
|
last = process_rcv_packet(&packet, thread);
|
2015-07-31 03:17:43 +08:00
|
|
|
seq = rhf_rcv_seq(packet.rhf);
|
|
|
|
if (++rcd->seq_cnt > 13)
|
|
|
|
rcd->seq_cnt = 1;
|
|
|
|
if (seq != rcd->seq_cnt)
|
2015-10-26 22:28:44 +08:00
|
|
|
last = RCV_PKT_DONE;
|
2015-07-31 03:17:43 +08:00
|
|
|
process_rcv_update(last, &packet);
|
|
|
|
}
|
2018-02-02 02:46:31 +08:00
|
|
|
process_rcv_qp_work(&packet);
|
2017-02-08 21:26:02 +08:00
|
|
|
rcd->head = packet.rhqoff;
|
2015-07-31 03:17:43 +08:00
|
|
|
bail:
|
|
|
|
finish_packet(&packet);
|
2015-10-26 22:28:44 +08:00
|
|
|
return last;
|
2015-07-31 03:17:43 +08:00
|
|
|
}
|
|
|
|
|
2015-10-26 22:28:44 +08:00
|
|
|
int handle_receive_interrupt_dma_rtail(struct hfi1_ctxtdata *rcd, int thread)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
|
|
|
u32 hdrqtail;
|
2015-10-26 22:28:44 +08:00
|
|
|
int last = RCV_PKT_OK;
|
2015-07-31 03:17:43 +08:00
|
|
|
struct hfi1_packet packet;
|
|
|
|
|
|
|
|
init_packet(rcd, &packet);
|
|
|
|
hdrqtail = get_rcvhdrtail(rcd);
|
2015-10-26 22:28:44 +08:00
|
|
|
if (packet.rhqoff == hdrqtail) {
|
|
|
|
last = RCV_PKT_DONE;
|
2015-07-31 03:17:43 +08:00
|
|
|
goto bail;
|
2015-10-26 22:28:44 +08:00
|
|
|
}
|
2015-07-31 03:17:43 +08:00
|
|
|
smp_rmb(); /* prevent speculative reads of dma'ed hdrq */
|
|
|
|
|
2016-02-04 06:32:57 +08:00
|
|
|
prescan_rxq(rcd, &packet);
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2015-10-26 22:28:44 +08:00
|
|
|
while (last == RCV_PKT_OK) {
|
|
|
|
last = process_rcv_packet(&packet, thread);
|
2015-07-31 03:17:43 +08:00
|
|
|
if (packet.rhqoff == hdrqtail)
|
2015-10-26 22:28:44 +08:00
|
|
|
last = RCV_PKT_DONE;
|
2015-07-31 03:17:43 +08:00
|
|
|
process_rcv_update(last, &packet);
|
|
|
|
}
|
2018-02-02 02:46:31 +08:00
|
|
|
process_rcv_qp_work(&packet);
|
2017-02-08 21:26:02 +08:00
|
|
|
rcd->head = packet.rhqoff;
|
2015-07-31 03:17:43 +08:00
|
|
|
bail:
|
|
|
|
finish_packet(&packet);
|
2015-10-26 22:28:44 +08:00
|
|
|
return last;
|
2015-07-31 03:17:43 +08:00
|
|
|
}
|
|
|
|
|
2017-07-24 22:45:55 +08:00
|
|
|
static inline void set_nodma_rtail(struct hfi1_devdata *dd, u16 ctxt)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
2017-08-05 04:52:44 +08:00
|
|
|
struct hfi1_ctxtdata *rcd;
|
2017-07-24 22:45:55 +08:00
|
|
|
u16 i;
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2017-04-13 11:29:29 +08:00
|
|
|
/*
|
|
|
|
* For dynamically allocated kernel contexts (like vnic) switch
|
|
|
|
* interrupt handler only for that context. Otherwise, switch
|
|
|
|
* interrupt handler for all statically allocated kernel contexts.
|
|
|
|
*/
|
|
|
|
if (ctxt >= dd->first_dyn_alloc_ctxt) {
|
2017-09-26 22:01:16 +08:00
|
|
|
rcd = hfi1_rcd_get_by_index_safe(dd, ctxt);
|
2017-08-05 04:52:44 +08:00
|
|
|
if (rcd) {
|
|
|
|
rcd->do_interrupt =
|
|
|
|
&handle_receive_interrupt_nodma_rtail;
|
|
|
|
hfi1_rcd_put(rcd);
|
|
|
|
}
|
2017-04-13 11:29:29 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-08-05 04:52:44 +08:00
|
|
|
for (i = HFI1_CTRL_CTXT + 1; i < dd->first_dyn_alloc_ctxt; i++) {
|
|
|
|
rcd = hfi1_rcd_get_by_index(dd, i);
|
|
|
|
if (rcd)
|
|
|
|
rcd->do_interrupt =
|
|
|
|
&handle_receive_interrupt_nodma_rtail;
|
|
|
|
hfi1_rcd_put(rcd);
|
|
|
|
}
|
2015-07-31 03:17:43 +08:00
|
|
|
}
|
|
|
|
|
2017-07-24 22:45:55 +08:00
|
|
|
static inline void set_dma_rtail(struct hfi1_devdata *dd, u16 ctxt)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
2017-08-05 04:52:44 +08:00
|
|
|
struct hfi1_ctxtdata *rcd;
|
2017-07-24 22:45:55 +08:00
|
|
|
u16 i;
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2017-04-13 11:29:29 +08:00
|
|
|
/*
|
|
|
|
* For dynamically allocated kernel contexts (like vnic) switch
|
|
|
|
* interrupt handler only for that context. Otherwise, switch
|
|
|
|
* interrupt handler for all statically allocated kernel contexts.
|
|
|
|
*/
|
|
|
|
if (ctxt >= dd->first_dyn_alloc_ctxt) {
|
2017-09-26 22:01:16 +08:00
|
|
|
rcd = hfi1_rcd_get_by_index_safe(dd, ctxt);
|
2017-08-05 04:52:44 +08:00
|
|
|
if (rcd) {
|
|
|
|
rcd->do_interrupt =
|
|
|
|
&handle_receive_interrupt_dma_rtail;
|
|
|
|
hfi1_rcd_put(rcd);
|
|
|
|
}
|
2017-04-13 11:29:29 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-08-05 04:52:44 +08:00
|
|
|
for (i = HFI1_CTRL_CTXT + 1; i < dd->first_dyn_alloc_ctxt; i++) {
|
|
|
|
rcd = hfi1_rcd_get_by_index(dd, i);
|
|
|
|
if (rcd)
|
|
|
|
rcd->do_interrupt =
|
|
|
|
&handle_receive_interrupt_dma_rtail;
|
|
|
|
hfi1_rcd_put(rcd);
|
|
|
|
}
|
2015-07-31 03:17:43 +08:00
|
|
|
}
|
|
|
|
|
2016-01-12 07:32:21 +08:00
|
|
|
void set_all_slowpath(struct hfi1_devdata *dd)
|
|
|
|
{
|
2017-08-05 04:52:44 +08:00
|
|
|
struct hfi1_ctxtdata *rcd;
|
2017-07-24 22:45:55 +08:00
|
|
|
u16 i;
|
2016-01-12 07:32:21 +08:00
|
|
|
|
|
|
|
/* HFI1_CTRL_CTXT must always use the slow path interrupt handler */
|
2017-04-13 11:29:29 +08:00
|
|
|
for (i = HFI1_CTRL_CTXT + 1; i < dd->num_rcv_contexts; i++) {
|
2017-08-05 04:52:44 +08:00
|
|
|
rcd = hfi1_rcd_get_by_index(dd, i);
|
|
|
|
if (!rcd)
|
|
|
|
continue;
|
2017-11-06 22:38:52 +08:00
|
|
|
if (i < dd->first_dyn_alloc_ctxt || rcd->is_vnic)
|
2017-04-13 11:29:29 +08:00
|
|
|
rcd->do_interrupt = &handle_receive_interrupt;
|
2017-11-06 22:38:52 +08:00
|
|
|
|
2017-08-05 04:52:44 +08:00
|
|
|
hfi1_rcd_put(rcd);
|
2017-04-13 11:29:29 +08:00
|
|
|
}
|
2016-01-12 07:32:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int set_armed_to_active(struct hfi1_ctxtdata *rcd,
|
2016-08-09 23:19:55 +08:00
|
|
|
struct hfi1_packet *packet,
|
2016-01-12 07:32:21 +08:00
|
|
|
struct hfi1_devdata *dd)
|
|
|
|
{
|
|
|
|
struct work_struct *lsaw = &rcd->ppd->linkstate_active_work;
|
2016-08-09 23:19:56 +08:00
|
|
|
u8 etype = rhf_rcv_type(packet->rhf);
|
2017-05-13 00:20:20 +08:00
|
|
|
u8 sc = SC15_PACKET;
|
2016-01-12 07:32:21 +08:00
|
|
|
|
2017-05-13 00:20:20 +08:00
|
|
|
if (etype == RHF_RCV_TYPE_IB) {
|
2018-06-05 02:43:37 +08:00
|
|
|
struct ib_header *hdr = hfi1_get_msgheader(packet->rcd,
|
2017-05-13 00:20:20 +08:00
|
|
|
packet->rhf_addr);
|
|
|
|
sc = hfi1_9B_get_sc5(hdr, packet->rhf);
|
2017-08-05 04:53:58 +08:00
|
|
|
} else if (etype == RHF_RCV_TYPE_BYPASS) {
|
|
|
|
struct hfi1_16b_header *hdr = hfi1_get_16B_header(
|
2018-06-05 02:43:37 +08:00
|
|
|
packet->rcd,
|
2017-08-05 04:53:58 +08:00
|
|
|
packet->rhf_addr);
|
|
|
|
sc = hfi1_16B_get_sc(hdr);
|
2017-05-13 00:20:20 +08:00
|
|
|
}
|
|
|
|
if (sc != SC15_PACKET) {
|
2017-05-30 08:21:32 +08:00
|
|
|
int hwstate = driver_lstate(rcd->ppd);
|
2016-01-12 07:32:21 +08:00
|
|
|
|
2017-05-30 08:21:32 +08:00
|
|
|
if (hwstate != IB_PORT_ACTIVE) {
|
|
|
|
dd_dev_info(dd,
|
|
|
|
"Unexpected link state %s\n",
|
|
|
|
opa_lstate_name(hwstate));
|
2016-01-12 07:32:21 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-07-29 23:43:49 +08:00
|
|
|
queue_work(rcd->ppd->link_wq, lsaw);
|
2016-01-12 07:32:21 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-07-31 03:17:43 +08:00
|
|
|
/*
|
|
|
|
* handle_receive_interrupt - receive a packet
|
|
|
|
* @rcd: the context
|
|
|
|
*
|
|
|
|
* Called from interrupt handler for errors or receive interrupt.
|
|
|
|
* This is the slow path interrupt handler.
|
|
|
|
*/
|
2015-10-26 22:28:44 +08:00
|
|
|
int handle_receive_interrupt(struct hfi1_ctxtdata *rcd, int thread)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
|
|
|
struct hfi1_devdata *dd = rcd->dd;
|
|
|
|
u32 hdrqtail;
|
2015-11-11 13:35:19 +08:00
|
|
|
int needset, last = RCV_PKT_OK;
|
2015-07-31 03:17:43 +08:00
|
|
|
struct hfi1_packet packet;
|
2015-11-11 13:35:19 +08:00
|
|
|
int skip_pkt = 0;
|
|
|
|
|
|
|
|
/* Control context will always use the slow path interrupt handler */
|
|
|
|
needset = (rcd->ctxt == HFI1_CTRL_CTXT) ? 0 : 1;
|
2015-07-31 03:17:43 +08:00
|
|
|
|
|
|
|
init_packet(rcd, &packet);
|
|
|
|
|
2015-11-11 13:35:19 +08:00
|
|
|
if (!HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL)) {
|
2015-07-31 03:17:43 +08:00
|
|
|
u32 seq = rhf_rcv_seq(packet.rhf);
|
|
|
|
|
2015-10-26 22:28:44 +08:00
|
|
|
if (seq != rcd->seq_cnt) {
|
|
|
|
last = RCV_PKT_DONE;
|
2015-07-31 03:17:43 +08:00
|
|
|
goto bail;
|
2015-10-26 22:28:44 +08:00
|
|
|
}
|
2015-07-31 03:17:43 +08:00
|
|
|
hdrqtail = 0;
|
|
|
|
} else {
|
|
|
|
hdrqtail = get_rcvhdrtail(rcd);
|
2015-10-26 22:28:44 +08:00
|
|
|
if (packet.rhqoff == hdrqtail) {
|
|
|
|
last = RCV_PKT_DONE;
|
2015-07-31 03:17:43 +08:00
|
|
|
goto bail;
|
2015-10-26 22:28:44 +08:00
|
|
|
}
|
2015-07-31 03:17:43 +08:00
|
|
|
smp_rmb(); /* prevent speculative reads of dma'ed hdrq */
|
2015-11-11 13:35:19 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Control context can potentially receive an invalid
|
|
|
|
* rhf. Drop such packets.
|
|
|
|
*/
|
|
|
|
if (rcd->ctxt == HFI1_CTRL_CTXT) {
|
|
|
|
u32 seq = rhf_rcv_seq(packet.rhf);
|
|
|
|
|
|
|
|
if (seq != rcd->seq_cnt)
|
|
|
|
skip_pkt = 1;
|
|
|
|
}
|
2015-07-31 03:17:43 +08:00
|
|
|
}
|
|
|
|
|
2016-02-04 06:32:57 +08:00
|
|
|
prescan_rxq(rcd, &packet);
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2015-10-26 22:28:44 +08:00
|
|
|
while (last == RCV_PKT_OK) {
|
2016-02-15 12:21:52 +08:00
|
|
|
if (unlikely(dd->do_drop &&
|
|
|
|
atomic_xchg(&dd->drop_packet, DROP_PACKET_OFF) ==
|
|
|
|
DROP_PACKET_ON)) {
|
2015-07-31 03:17:43 +08:00
|
|
|
dd->do_drop = 0;
|
|
|
|
|
|
|
|
/* On to the next packet */
|
|
|
|
packet.rhqoff += packet.rsize;
|
2016-02-15 12:19:41 +08:00
|
|
|
packet.rhf_addr = (__le32 *)rcd->rcvhdrq +
|
2015-07-31 03:17:43 +08:00
|
|
|
packet.rhqoff +
|
2018-06-05 02:43:37 +08:00
|
|
|
rcd->rhf_offset;
|
2015-07-31 03:17:43 +08:00
|
|
|
packet.rhf = rhf_to_cpu(packet.rhf_addr);
|
|
|
|
|
2015-11-11 13:35:19 +08:00
|
|
|
} else if (skip_pkt) {
|
|
|
|
last = skip_rcv_packet(&packet, thread);
|
|
|
|
skip_pkt = 0;
|
2015-07-31 03:17:43 +08:00
|
|
|
} else {
|
2016-01-12 07:32:21 +08:00
|
|
|
/* Auto activate link on non-SC15 packet receive */
|
|
|
|
if (unlikely(rcd->ppd->host_link_state ==
|
|
|
|
HLS_UP_ARMED) &&
|
2016-08-09 23:19:55 +08:00
|
|
|
set_armed_to_active(rcd, &packet, dd))
|
2016-01-12 07:32:21 +08:00
|
|
|
goto bail;
|
2015-10-26 22:28:44 +08:00
|
|
|
last = process_rcv_packet(&packet, thread);
|
2015-07-31 03:17:43 +08:00
|
|
|
}
|
|
|
|
|
2015-11-11 13:35:19 +08:00
|
|
|
if (!HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL)) {
|
2015-07-31 03:17:43 +08:00
|
|
|
u32 seq = rhf_rcv_seq(packet.rhf);
|
|
|
|
|
|
|
|
if (++rcd->seq_cnt > 13)
|
|
|
|
rcd->seq_cnt = 1;
|
|
|
|
if (seq != rcd->seq_cnt)
|
2015-10-26 22:28:44 +08:00
|
|
|
last = RCV_PKT_DONE;
|
2015-07-31 03:17:43 +08:00
|
|
|
if (needset) {
|
2016-02-15 12:21:52 +08:00
|
|
|
dd_dev_info(dd, "Switching to NO_DMA_RTAIL\n");
|
2017-04-13 11:29:29 +08:00
|
|
|
set_nodma_rtail(dd, rcd->ctxt);
|
2015-07-31 03:17:43 +08:00
|
|
|
needset = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (packet.rhqoff == hdrqtail)
|
2015-10-26 22:28:44 +08:00
|
|
|
last = RCV_PKT_DONE;
|
2015-11-11 13:35:19 +08:00
|
|
|
/*
|
|
|
|
* Control context can potentially receive an invalid
|
|
|
|
* rhf. Drop such packets.
|
|
|
|
*/
|
|
|
|
if (rcd->ctxt == HFI1_CTRL_CTXT) {
|
|
|
|
u32 seq = rhf_rcv_seq(packet.rhf);
|
|
|
|
|
|
|
|
if (++rcd->seq_cnt > 13)
|
|
|
|
rcd->seq_cnt = 1;
|
|
|
|
if (!last && (seq != rcd->seq_cnt))
|
|
|
|
skip_pkt = 1;
|
|
|
|
}
|
|
|
|
|
2015-07-31 03:17:43 +08:00
|
|
|
if (needset) {
|
|
|
|
dd_dev_info(dd,
|
|
|
|
"Switching to DMA_RTAIL\n");
|
2017-04-13 11:29:29 +08:00
|
|
|
set_dma_rtail(dd, rcd->ctxt);
|
2015-07-31 03:17:43 +08:00
|
|
|
needset = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
process_rcv_update(last, &packet);
|
|
|
|
}
|
|
|
|
|
2018-02-02 02:46:31 +08:00
|
|
|
process_rcv_qp_work(&packet);
|
2017-02-08 21:26:02 +08:00
|
|
|
rcd->head = packet.rhqoff;
|
2015-07-31 03:17:43 +08:00
|
|
|
|
|
|
|
bail:
|
|
|
|
/*
|
|
|
|
* Always write head at end, and setup rcv interrupt, even
|
|
|
|
* if no packets were processed.
|
|
|
|
*/
|
|
|
|
finish_packet(&packet);
|
2015-10-26 22:28:44 +08:00
|
|
|
return last;
|
2015-07-31 03:17:43 +08:00
|
|
|
}
|
|
|
|
|
2016-01-12 07:32:21 +08:00
|
|
|
/*
|
|
|
|
* We may discover in the interrupt that the hardware link state has
|
|
|
|
* changed from ARMED to ACTIVE (due to the arrival of a non-SC15 packet),
|
|
|
|
* and we need to update the driver's notion of the link state. We cannot
|
|
|
|
* run set_link_state from interrupt context, so we queue this function on
|
|
|
|
* a workqueue.
|
|
|
|
*
|
|
|
|
* We delay the regular interrupt processing until after the state changes
|
|
|
|
* so that the link will be in the correct state by the time any application
|
|
|
|
* we wake up attempts to send a reply to any message it received.
|
|
|
|
* (Subsequent receive interrupts may possibly force the wakeup before we
|
|
|
|
* update the link state.)
|
|
|
|
*
|
|
|
|
* The rcd is freed in hfi1_free_ctxtdata after hfi1_postinit_cleanup invokes
|
|
|
|
* dd->f_cleanup(dd) to disable the interrupt handler and flush workqueues,
|
|
|
|
* so we're safe from use-after-free of the rcd.
|
|
|
|
*/
|
|
|
|
void receive_interrupt_work(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
|
|
|
|
linkstate_active_work);
|
|
|
|
struct hfi1_devdata *dd = ppd->dd;
|
2017-08-05 04:52:44 +08:00
|
|
|
struct hfi1_ctxtdata *rcd;
|
2017-07-24 22:45:55 +08:00
|
|
|
u16 i;
|
2016-01-12 07:32:21 +08:00
|
|
|
|
|
|
|
/* Received non-SC15 packet implies neighbor_normal */
|
|
|
|
ppd->neighbor_normal = 1;
|
|
|
|
set_link_state(ppd, HLS_UP_ACTIVE);
|
|
|
|
|
|
|
|
/*
|
2017-04-13 11:29:29 +08:00
|
|
|
* Interrupt all statically allocated kernel contexts that could
|
|
|
|
* have had an interrupt during auto activation.
|
2016-01-12 07:32:21 +08:00
|
|
|
*/
|
2017-08-05 04:52:44 +08:00
|
|
|
for (i = HFI1_CTRL_CTXT; i < dd->first_dyn_alloc_ctxt; i++) {
|
|
|
|
rcd = hfi1_rcd_get_by_index(dd, i);
|
|
|
|
if (rcd)
|
|
|
|
force_recv_intr(rcd);
|
|
|
|
hfi1_rcd_put(rcd);
|
|
|
|
}
|
2016-01-12 07:32:21 +08:00
|
|
|
}
|
|
|
|
|
2015-07-31 03:17:43 +08:00
|
|
|
/*
|
|
|
|
* Convert a given MTU size to the on-wire MAD packet enumeration.
|
|
|
|
* Return -1 if the size is invalid.
|
|
|
|
*/
|
|
|
|
int mtu_to_enum(u32 mtu, int default_if_bad)
|
|
|
|
{
|
|
|
|
switch (mtu) {
|
|
|
|
case 0: return OPA_MTU_0;
|
|
|
|
case 256: return OPA_MTU_256;
|
|
|
|
case 512: return OPA_MTU_512;
|
|
|
|
case 1024: return OPA_MTU_1024;
|
|
|
|
case 2048: return OPA_MTU_2048;
|
|
|
|
case 4096: return OPA_MTU_4096;
|
|
|
|
case 8192: return OPA_MTU_8192;
|
|
|
|
case 10240: return OPA_MTU_10240;
|
|
|
|
}
|
|
|
|
return default_if_bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
u16 enum_to_mtu(int mtu)
|
|
|
|
{
|
|
|
|
switch (mtu) {
|
|
|
|
case OPA_MTU_0: return 0;
|
|
|
|
case OPA_MTU_256: return 256;
|
|
|
|
case OPA_MTU_512: return 512;
|
|
|
|
case OPA_MTU_1024: return 1024;
|
|
|
|
case OPA_MTU_2048: return 2048;
|
|
|
|
case OPA_MTU_4096: return 4096;
|
|
|
|
case OPA_MTU_8192: return 8192;
|
|
|
|
case OPA_MTU_10240: return 10240;
|
|
|
|
default: return 0xffff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* set_mtu - set the MTU
|
|
|
|
* @ppd: the per port data
|
|
|
|
*
|
|
|
|
* We can handle "any" incoming size, the issue here is whether we
|
|
|
|
* need to restrict our outgoing size. We do not deal with what happens
|
|
|
|
* to programs that are already running when the size changes.
|
|
|
|
*/
|
|
|
|
int set_mtu(struct hfi1_pportdata *ppd)
|
|
|
|
{
|
|
|
|
struct hfi1_devdata *dd = ppd->dd;
|
|
|
|
int i, drain, ret = 0, is_up = 0;
|
|
|
|
|
|
|
|
ppd->ibmtu = 0;
|
|
|
|
for (i = 0; i < ppd->vls_supported; i++)
|
|
|
|
if (ppd->ibmtu < dd->vld[i].mtu)
|
|
|
|
ppd->ibmtu = dd->vld[i].mtu;
|
|
|
|
ppd->ibmaxlen = ppd->ibmtu + lrh_max_header_bytes(ppd->dd);
|
|
|
|
|
|
|
|
mutex_lock(&ppd->hls_lock);
|
2016-02-15 12:20:15 +08:00
|
|
|
if (ppd->host_link_state == HLS_UP_INIT ||
|
|
|
|
ppd->host_link_state == HLS_UP_ARMED ||
|
|
|
|
ppd->host_link_state == HLS_UP_ACTIVE)
|
2015-07-31 03:17:43 +08:00
|
|
|
is_up = 1;
|
|
|
|
|
|
|
|
drain = !is_ax(dd) && is_up;
|
|
|
|
|
|
|
|
if (drain)
|
|
|
|
/*
|
|
|
|
* MTU is specified per-VL. To ensure that no packet gets
|
|
|
|
* stuck (due, e.g., to the MTU for the packet's VL being
|
|
|
|
* reduced), empty the per-VL FIFOs before adjusting MTU.
|
|
|
|
*/
|
|
|
|
ret = stop_drain_data_vls(dd);
|
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
dd_dev_err(dd, "%s: cannot stop/drain VLs - refusing to change per-VL MTUs\n",
|
|
|
|
__func__);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
hfi1_set_ib_cfg(ppd, HFI1_IB_CFG_MTU, 0);
|
|
|
|
|
|
|
|
if (drain)
|
|
|
|
open_fill_data_vls(dd); /* reopen all VLs */
|
|
|
|
|
|
|
|
err:
|
|
|
|
mutex_unlock(&ppd->hls_lock);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int hfi1_set_lid(struct hfi1_pportdata *ppd, u32 lid, u8 lmc)
|
|
|
|
{
|
|
|
|
struct hfi1_devdata *dd = ppd->dd;
|
|
|
|
|
|
|
|
ppd->lid = lid;
|
|
|
|
ppd->lmc = lmc;
|
|
|
|
hfi1_set_ib_cfg(ppd, HFI1_IB_CFG_LIDLMC, 0);
|
|
|
|
|
2016-05-13 01:23:35 +08:00
|
|
|
dd_dev_info(dd, "port %u: got a lid: 0x%x\n", ppd->port, lid);
|
2015-07-31 03:17:43 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-02-04 06:35:57 +08:00
|
|
|
void shutdown_led_override(struct hfi1_pportdata *ppd)
|
|
|
|
{
|
|
|
|
struct hfi1_devdata *dd = ppd->dd;
|
|
|
|
|
2016-02-27 05:33:28 +08:00
|
|
|
/*
|
2016-03-08 03:35:03 +08:00
|
|
|
* This pairs with the memory barrier in hfi1_start_led_override to
|
|
|
|
* ensure that we read the correct state of LED beaconing represented
|
|
|
|
* by led_override_timer_active
|
2016-02-27 05:33:28 +08:00
|
|
|
*/
|
2016-03-08 03:35:03 +08:00
|
|
|
smp_rmb();
|
2016-02-04 06:35:57 +08:00
|
|
|
if (atomic_read(&ppd->led_override_timer_active)) {
|
|
|
|
del_timer_sync(&ppd->led_override_timer);
|
|
|
|
atomic_set(&ppd->led_override_timer_active, 0);
|
2016-03-08 03:35:03 +08:00
|
|
|
/* Ensure the atomic_set is visible to all CPUs */
|
|
|
|
smp_wmb();
|
2016-02-04 06:35:57 +08:00
|
|
|
}
|
|
|
|
|
2016-03-08 03:35:03 +08:00
|
|
|
/* Hand control of the LED to the DC for normal operation */
|
|
|
|
write_csr(dd, DCC_CFG_LED_CNTRL, 0);
|
2016-02-04 06:35:57 +08:00
|
|
|
}
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2017-10-17 06:51:54 +08:00
|
|
|
static void run_led_override(struct timer_list *t)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
2017-10-17 06:51:54 +08:00
|
|
|
struct hfi1_pportdata *ppd = from_timer(ppd, t, led_override_timer);
|
2015-07-31 03:17:43 +08:00
|
|
|
struct hfi1_devdata *dd = ppd->dd;
|
2016-02-04 06:35:57 +08:00
|
|
|
unsigned long timeout;
|
|
|
|
int phase_idx;
|
2015-07-31 03:17:43 +08:00
|
|
|
|
|
|
|
if (!(dd->flags & HFI1_INITTED))
|
|
|
|
return;
|
|
|
|
|
2016-02-04 06:35:57 +08:00
|
|
|
phase_idx = ppd->led_override_phase & 1;
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2016-02-04 06:35:57 +08:00
|
|
|
setextled(dd, phase_idx);
|
|
|
|
|
|
|
|
timeout = ppd->led_override_vals[phase_idx];
|
2016-03-08 03:35:03 +08:00
|
|
|
|
2016-02-04 06:35:57 +08:00
|
|
|
/* Set up for next phase */
|
|
|
|
ppd->led_override_phase = !ppd->led_override_phase;
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2016-03-08 03:35:03 +08:00
|
|
|
mod_timer(&ppd->led_override_timer, jiffies + timeout);
|
2015-07-31 03:17:43 +08:00
|
|
|
}
|
|
|
|
|
2016-02-04 06:35:57 +08:00
|
|
|
/*
|
|
|
|
* To have the LED blink in a particular pattern, provide timeon and timeoff
|
2016-03-08 03:35:03 +08:00
|
|
|
* in milliseconds.
|
|
|
|
* To turn off custom blinking and return to normal operation, use
|
|
|
|
* shutdown_led_override()
|
2016-02-04 06:35:57 +08:00
|
|
|
*/
|
2016-03-08 03:35:03 +08:00
|
|
|
void hfi1_start_led_override(struct hfi1_pportdata *ppd, unsigned int timeon,
|
|
|
|
unsigned int timeoff)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
2016-03-08 03:35:03 +08:00
|
|
|
if (!(ppd->dd->flags & HFI1_INITTED))
|
2015-07-31 03:17:43 +08:00
|
|
|
return;
|
|
|
|
|
2016-02-04 06:35:57 +08:00
|
|
|
/* Convert to jiffies for direct use in timer */
|
|
|
|
ppd->led_override_vals[0] = msecs_to_jiffies(timeoff);
|
|
|
|
ppd->led_override_vals[1] = msecs_to_jiffies(timeon);
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2016-03-08 03:35:03 +08:00
|
|
|
/* Arbitrarily start from LED on phase */
|
|
|
|
ppd->led_override_phase = 1;
|
2015-07-31 03:17:43 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the timer has not already been started, do so. Use a "quick"
|
2016-03-08 03:35:03 +08:00
|
|
|
* timeout so the handler will be called soon to look at our request.
|
2015-07-31 03:17:43 +08:00
|
|
|
*/
|
2016-03-08 03:35:03 +08:00
|
|
|
if (!timer_pending(&ppd->led_override_timer)) {
|
2017-10-17 06:51:54 +08:00
|
|
|
timer_setup(&ppd->led_override_timer, run_led_override, 0);
|
2015-07-31 03:17:43 +08:00
|
|
|
ppd->led_override_timer.expires = jiffies + 1;
|
|
|
|
add_timer(&ppd->led_override_timer);
|
2016-03-08 03:35:03 +08:00
|
|
|
atomic_set(&ppd->led_override_timer_active, 1);
|
|
|
|
/* Ensure the atomic_set is visible to all CPUs */
|
|
|
|
smp_wmb();
|
2015-07-31 03:17:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* hfi1_reset_device - reset the chip if possible
|
|
|
|
* @unit: the device to reset
|
|
|
|
*
|
|
|
|
* Whether or not reset is successful, we attempt to re-initialize the chip
|
|
|
|
* (that is, much like a driver unload/reload). We clear the INITTED flag
|
|
|
|
* so that the various entry points will fail until we reinitialize. For
|
|
|
|
* now, we only allow this if no user contexts are open that use chip resources
|
|
|
|
*/
|
|
|
|
int hfi1_reset_device(int unit)
|
|
|
|
{
|
2017-07-24 22:45:55 +08:00
|
|
|
int ret;
|
2015-07-31 03:17:43 +08:00
|
|
|
struct hfi1_devdata *dd = hfi1_lookup(unit);
|
|
|
|
struct hfi1_pportdata *ppd;
|
|
|
|
int pidx;
|
|
|
|
|
|
|
|
if (!dd) {
|
|
|
|
ret = -ENODEV;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
dd_dev_info(dd, "Reset on unit %u requested\n", unit);
|
|
|
|
|
IB/hfi1: Fix bar0 mapping to use write combining
When the debugpat kernel boot flag is turned on the following
traces are printed:
[ 1884.793168] x86/PAT: Overlap at 0x90000000-0x92000000
[ 1884.803510] x86/PAT: reserve_memtype added [mem 0x91200000-0x9127ffff],
track uncached-minus, req write-combining, ret uncached-minus
[ 1884.818167] hfi1 0000:05:00.0: hfi1_0: WC Remapped RcvArray:
ffffc9000a980000
The ioremap_wc() clearly is not returning a write combining mapping due
to an overlap where the RcvArray is mapped in a uncached mapping prior
to creating the proposed write combining mapping.
The patch replaces the single base register for uncached CSRs that
used to overlap the RcvArray with two mappings. One, kregbase1, from the
bar0 up to the RcvArray and another, kregbase2, from the end of the
RcvArray to the pio send buffer space. A new dd field, base2_start,
is used to convert the zero-based offset in the CSR routines to the
correct kregbase1/kregbase2 mapping. A single direct write of the
RcvArray CSRs is replaced with hfi1_put_tid() to insure correct access
using the new disjoint mapping.
Additionally, the kregend field is deleted since it is only ever written.
patdebug now shows the RcvArray as write combining:
[ 35.688990] x86/PAT: reserve_memtype added [mem 0x91200000-0x9127ffff],
track write-combining, req write-combining, ret write-combining
To insulate from any potential issues with write combining, all
writeq are now flushed in hfi1_put_tid() and rcv_array_wc_fill().
Reviewed-by: Mitko Haralanov <mitko.haralanov@intel.com>
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2017-07-24 22:45:31 +08:00
|
|
|
if (!dd->kregbase1 || !(dd->flags & HFI1_PRESENT)) {
|
2015-07-31 03:17:43 +08:00
|
|
|
dd_dev_info(dd,
|
2016-02-15 12:21:52 +08:00
|
|
|
"Invalid unit number %u or not initialized or not present\n",
|
|
|
|
unit);
|
2015-07-31 03:17:43 +08:00
|
|
|
ret = -ENXIO;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
2017-08-05 04:52:44 +08:00
|
|
|
/* If there are any user/vnic contexts, we cannot reset */
|
|
|
|
mutex_lock(&hfi1_mutex);
|
2015-07-31 03:17:43 +08:00
|
|
|
if (dd->rcd)
|
2017-08-05 04:52:44 +08:00
|
|
|
if (hfi1_stats.sps_ctxts) {
|
|
|
|
mutex_unlock(&hfi1_mutex);
|
2015-07-31 03:17:43 +08:00
|
|
|
ret = -EBUSY;
|
|
|
|
goto bail;
|
|
|
|
}
|
2017-08-05 04:52:44 +08:00
|
|
|
mutex_unlock(&hfi1_mutex);
|
2015-07-31 03:17:43 +08:00
|
|
|
|
|
|
|
for (pidx = 0; pidx < dd->num_pports; ++pidx) {
|
|
|
|
ppd = dd->pport + pidx;
|
|
|
|
|
2016-02-04 06:35:57 +08:00
|
|
|
shutdown_led_override(ppd);
|
2015-07-31 03:17:43 +08:00
|
|
|
}
|
|
|
|
if (dd->flags & HFI1_HAS_SEND_DMA)
|
|
|
|
sdma_exit(dd);
|
|
|
|
|
|
|
|
hfi1_reset_cpu_counters(dd);
|
|
|
|
|
|
|
|
ret = hfi1_init(dd, 1);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
dd_dev_err(dd,
|
2016-02-15 12:21:52 +08:00
|
|
|
"Reinitialize unit %u after reset failed with %d\n",
|
|
|
|
unit, ret);
|
2015-07-31 03:17:43 +08:00
|
|
|
else
|
|
|
|
dd_dev_info(dd, "Reinitialized unit %u after resetting\n",
|
2016-02-15 12:21:52 +08:00
|
|
|
unit);
|
2015-07-31 03:17:43 +08:00
|
|
|
|
|
|
|
bail:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-05-13 00:20:20 +08:00
|
|
|
static inline void hfi1_setup_ib_header(struct hfi1_packet *packet)
|
|
|
|
{
|
|
|
|
packet->hdr = (struct hfi1_ib_message_header *)
|
2018-06-05 02:43:37 +08:00
|
|
|
hfi1_get_msgheader(packet->rcd,
|
2017-05-13 00:20:20 +08:00
|
|
|
packet->rhf_addr);
|
|
|
|
packet->hlen = (u8 *)packet->rhf_addr - (u8 *)packet->hdr;
|
|
|
|
}
|
|
|
|
|
2017-08-05 04:54:10 +08:00
|
|
|
static int hfi1_bypass_ingress_pkt_check(struct hfi1_packet *packet)
|
|
|
|
{
|
|
|
|
struct hfi1_pportdata *ppd = packet->rcd->ppd;
|
|
|
|
|
|
|
|
/* slid and dlid cannot be 0 */
|
|
|
|
if ((!packet->slid) || (!packet->dlid))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Compare port lid with incoming packet dlid */
|
|
|
|
if ((!(hfi1_is_16B_mcast(packet->dlid))) &&
|
|
|
|
(packet->dlid !=
|
|
|
|
opa_get_lid(be32_to_cpu(OPA_LID_PERMISSIVE), 16B))) {
|
2018-11-29 02:19:47 +08:00
|
|
|
if ((packet->dlid & ~((1 << ppd->lmc) - 1)) != ppd->lid)
|
2017-08-05 04:54:10 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No multicast packets with SC15 */
|
|
|
|
if ((hfi1_is_16B_mcast(packet->dlid)) && (packet->sc == 0xF))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Packets with permissive DLID always on SC15 */
|
|
|
|
if ((packet->dlid == opa_get_lid(be32_to_cpu(OPA_LID_PERMISSIVE),
|
|
|
|
16B)) &&
|
|
|
|
(packet->sc != 0xF))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-05-13 00:20:20 +08:00
|
|
|
static int hfi1_setup_9B_packet(struct hfi1_packet *packet)
|
|
|
|
{
|
|
|
|
struct hfi1_ibport *ibp = rcd_to_iport(packet->rcd);
|
|
|
|
struct ib_header *hdr;
|
|
|
|
u8 lnh;
|
|
|
|
|
|
|
|
hfi1_setup_ib_header(packet);
|
|
|
|
hdr = packet->hdr;
|
|
|
|
|
|
|
|
lnh = ib_get_lnh(hdr);
|
|
|
|
if (lnh == HFI1_LRH_BTH) {
|
|
|
|
packet->ohdr = &hdr->u.oth;
|
|
|
|
packet->grh = NULL;
|
|
|
|
} else if (lnh == HFI1_LRH_GRH) {
|
|
|
|
u32 vtf;
|
|
|
|
|
|
|
|
packet->ohdr = &hdr->u.l.oth;
|
|
|
|
packet->grh = &hdr->u.l.grh;
|
|
|
|
if (packet->grh->next_hdr != IB_GRH_NEXT_HDR)
|
|
|
|
goto drop;
|
|
|
|
vtf = be32_to_cpu(packet->grh->version_tclass_flow);
|
|
|
|
if ((vtf >> IB_GRH_VERSION_SHIFT) != IB_GRH_VERSION)
|
|
|
|
goto drop;
|
|
|
|
} else {
|
|
|
|
goto drop;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Query commonly used fields from packet header */
|
2017-08-05 04:53:58 +08:00
|
|
|
packet->payload = packet->ebuf;
|
2017-05-13 00:20:20 +08:00
|
|
|
packet->opcode = ib_bth_get_opcode(packet->ohdr);
|
|
|
|
packet->slid = ib_get_slid(hdr);
|
|
|
|
packet->dlid = ib_get_dlid(hdr);
|
2017-08-05 04:53:58 +08:00
|
|
|
if (unlikely((packet->dlid >= be16_to_cpu(IB_MULTICAST_LID_BASE)) &&
|
|
|
|
(packet->dlid != be16_to_cpu(IB_LID_PERMISSIVE))))
|
|
|
|
packet->dlid += opa_get_mcast_base(OPA_MCAST_NR) -
|
|
|
|
be16_to_cpu(IB_MULTICAST_LID_BASE);
|
2017-05-13 00:20:20 +08:00
|
|
|
packet->sl = ib_get_sl(hdr);
|
|
|
|
packet->sc = hfi1_9B_get_sc5(hdr, packet->rhf);
|
|
|
|
packet->pad = ib_bth_get_pad(packet->ohdr);
|
|
|
|
packet->extra_byte = 0;
|
2018-02-02 02:46:23 +08:00
|
|
|
packet->pkey = ib_bth_get_pkey(packet->ohdr);
|
|
|
|
packet->migrated = ib_bth_is_migration(packet->ohdr);
|
2017-05-13 00:20:20 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
drop:
|
|
|
|
ibp->rvp.n_pkt_drops++;
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2017-08-05 04:53:58 +08:00
|
|
|
static int hfi1_setup_bypass_packet(struct hfi1_packet *packet)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Bypass packets have a different header/payload split
|
|
|
|
* compared to an IB packet.
|
|
|
|
* Current split is set such that 16 bytes of the actual
|
|
|
|
* header is in the header buffer and the remining is in
|
|
|
|
* the eager buffer. We chose 16 since hfi1 driver only
|
|
|
|
* supports 16B bypass packets and we will be able to
|
|
|
|
* receive the entire LRH with such a split.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct hfi1_ctxtdata *rcd = packet->rcd;
|
|
|
|
struct hfi1_pportdata *ppd = rcd->ppd;
|
|
|
|
struct hfi1_ibport *ibp = &ppd->ibport_data;
|
|
|
|
u8 l4;
|
|
|
|
|
|
|
|
packet->hdr = (struct hfi1_16b_header *)
|
2018-06-05 02:43:37 +08:00
|
|
|
hfi1_get_16B_header(packet->rcd,
|
2017-08-05 04:53:58 +08:00
|
|
|
packet->rhf_addr);
|
|
|
|
l4 = hfi1_16B_get_l4(packet->hdr);
|
|
|
|
if (l4 == OPA_16B_L4_IB_LOCAL) {
|
|
|
|
packet->ohdr = packet->ebuf;
|
|
|
|
packet->grh = NULL;
|
2018-05-16 09:28:15 +08:00
|
|
|
packet->opcode = ib_bth_get_opcode(packet->ohdr);
|
|
|
|
packet->pad = hfi1_16B_bth_get_pad(packet->ohdr);
|
|
|
|
/* hdr_len_by_opcode already has an IB LRH factored in */
|
|
|
|
packet->hlen = hdr_len_by_opcode[packet->opcode] +
|
|
|
|
(LRH_16B_BYTES - LRH_9B_BYTES);
|
|
|
|
packet->migrated = opa_bth_is_migration(packet->ohdr);
|
2017-08-05 04:53:58 +08:00
|
|
|
} else if (l4 == OPA_16B_L4_IB_GLOBAL) {
|
|
|
|
u32 vtf;
|
2018-05-16 09:28:15 +08:00
|
|
|
u8 grh_len = sizeof(struct ib_grh);
|
2017-08-05 04:53:58 +08:00
|
|
|
|
|
|
|
packet->ohdr = packet->ebuf + grh_len;
|
|
|
|
packet->grh = packet->ebuf;
|
2018-05-16 09:28:15 +08:00
|
|
|
packet->opcode = ib_bth_get_opcode(packet->ohdr);
|
|
|
|
packet->pad = hfi1_16B_bth_get_pad(packet->ohdr);
|
|
|
|
/* hdr_len_by_opcode already has an IB LRH factored in */
|
|
|
|
packet->hlen = hdr_len_by_opcode[packet->opcode] +
|
|
|
|
(LRH_16B_BYTES - LRH_9B_BYTES) + grh_len;
|
|
|
|
packet->migrated = opa_bth_is_migration(packet->ohdr);
|
|
|
|
|
2017-08-05 04:53:58 +08:00
|
|
|
if (packet->grh->next_hdr != IB_GRH_NEXT_HDR)
|
|
|
|
goto drop;
|
|
|
|
vtf = be32_to_cpu(packet->grh->version_tclass_flow);
|
|
|
|
if ((vtf >> IB_GRH_VERSION_SHIFT) != IB_GRH_VERSION)
|
|
|
|
goto drop;
|
2018-05-16 09:28:15 +08:00
|
|
|
} else if (l4 == OPA_16B_L4_FM) {
|
|
|
|
packet->mgmt = packet->ebuf;
|
|
|
|
packet->ohdr = NULL;
|
|
|
|
packet->grh = NULL;
|
|
|
|
packet->opcode = IB_OPCODE_UD_SEND_ONLY;
|
|
|
|
packet->pad = OPA_16B_L4_FM_PAD;
|
|
|
|
packet->hlen = OPA_16B_L4_FM_HLEN;
|
|
|
|
packet->migrated = false;
|
2017-08-05 04:53:58 +08:00
|
|
|
} else {
|
|
|
|
goto drop;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Query commonly used fields from packet header */
|
2018-02-02 02:52:35 +08:00
|
|
|
packet->payload = packet->ebuf + packet->hlen - LRH_16B_BYTES;
|
2017-08-05 04:53:58 +08:00
|
|
|
packet->slid = hfi1_16B_get_slid(packet->hdr);
|
|
|
|
packet->dlid = hfi1_16B_get_dlid(packet->hdr);
|
|
|
|
if (unlikely(hfi1_is_16B_mcast(packet->dlid)))
|
|
|
|
packet->dlid += opa_get_mcast_base(OPA_MCAST_NR) -
|
|
|
|
opa_get_lid(opa_get_mcast_base(OPA_MCAST_NR),
|
|
|
|
16B);
|
|
|
|
packet->sc = hfi1_16B_get_sc(packet->hdr);
|
|
|
|
packet->sl = ibp->sc_to_sl[packet->sc];
|
|
|
|
packet->extra_byte = SIZE_OF_LT;
|
2018-02-02 02:46:23 +08:00
|
|
|
packet->pkey = hfi1_16B_get_pkey(packet->hdr);
|
2017-08-05 04:53:58 +08:00
|
|
|
|
2017-08-05 04:54:10 +08:00
|
|
|
if (hfi1_bypass_ingress_pkt_check(packet))
|
|
|
|
goto drop;
|
|
|
|
|
2017-08-05 04:53:58 +08:00
|
|
|
return 0;
|
|
|
|
drop:
|
|
|
|
hfi1_cdbg(PKT, "%s: packet dropped\n", __func__);
|
|
|
|
ibp->rvp.n_pkt_drops++;
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2019-01-24 22:36:34 +08:00
|
|
|
static void show_eflags_errs(struct hfi1_packet *packet)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
|
|
|
struct hfi1_ctxtdata *rcd = packet->rcd;
|
|
|
|
u32 rte = rhf_rcv_type_err(packet->rhf);
|
|
|
|
|
2019-01-24 22:36:34 +08:00
|
|
|
dd_dev_err(rcd->dd,
|
2019-04-11 22:17:21 +08:00
|
|
|
"receive context %d: rhf 0x%016llx, errs [ %s%s%s%s%s%s%s] rte 0x%x\n",
|
2019-01-24 22:36:34 +08:00
|
|
|
rcd->ctxt, packet->rhf,
|
|
|
|
packet->rhf & RHF_K_HDR_LEN_ERR ? "k_hdr_len " : "",
|
|
|
|
packet->rhf & RHF_DC_UNC_ERR ? "dc_unc " : "",
|
|
|
|
packet->rhf & RHF_DC_ERR ? "dc " : "",
|
|
|
|
packet->rhf & RHF_TID_ERR ? "tid " : "",
|
|
|
|
packet->rhf & RHF_LEN_ERR ? "len " : "",
|
|
|
|
packet->rhf & RHF_ECC_ERR ? "ecc " : "",
|
|
|
|
packet->rhf & RHF_ICRC_ERR ? "icrc " : "",
|
|
|
|
rte);
|
|
|
|
}
|
|
|
|
|
|
|
|
void handle_eflags(struct hfi1_packet *packet)
|
|
|
|
{
|
|
|
|
struct hfi1_ctxtdata *rcd = packet->rcd;
|
|
|
|
|
2015-07-31 03:17:43 +08:00
|
|
|
rcv_hdrerr(rcd, rcd->ppd, packet);
|
2015-11-07 09:07:03 +08:00
|
|
|
if (rhf_err_flags(packet->rhf))
|
2019-01-24 22:36:34 +08:00
|
|
|
show_eflags_errs(packet);
|
2015-07-31 03:17:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following functions are called by the interrupt handler. They are type
|
|
|
|
* specific handlers for each packet type.
|
|
|
|
*/
|
2018-06-05 02:43:29 +08:00
|
|
|
static int process_receive_ib(struct hfi1_packet *packet)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
IB/hfi1: Rework fault injection machinery
The packet fault injection code present in the HFI1 driver had some
issues which not only fragment the code but also created user
confusion. Furthermore, it suffered from the following issues:
1. The fault_packet method only worked for received packets. This
meant that the only fault injection mode available for sent
packets is fault_opcode, which did not allow for random packet
drops on all egressing packets.
2. The mask available for the fault_opcode mode did not really work
due to the fact that the opcode values are not bits in a bitmask but
rather sequential integer values. Creating a opcode/mask pair that
would successfully capture a set of packets was nearly impossible.
3. The code was fragmented and used too many debugfs entries to
operate and control. This was confusing to users.
4. It did not allow filtering fault injection on a per direction basis -
egress vs. ingress.
In order to improve or fix the above issues, the following changes have
been made:
1. The fault injection methods have been combined into a single fault
injection facility. As such, the fault injection has been plugged
into both the send and receive code paths. Regardless of method used
the fault injection will operate on both egress and ingress packets.
2. The type of fault injection - by packet or by opcode - is now controlled
by changing the boolean value of the file "opcode_mode". When the value
is set to True, fault injection is done by opcode. Otherwise, by
packet.
2. The masking ability has been removed in favor of a bitmap that holds
opcodes of interest (one bit per opcode, a total of 256 bits). This
works in tandem with the "opcode_mode" value. When the value of
"opcode_mode" is False, this bitmap is ignored. When the value is
True, the bitmap lists all opcodes to be considered for fault injection.
By default, the bitmap is empty. When the user wants to filter by opcode,
the user sets the corresponding bit in the bitmap by echo'ing the bit
position into the 'opcodes' file. This gets around the issue that the set
of opcodes does not lend itself to effective masks and allow for extremely
fine-grained filtering by opcode.
4. fault_packet and fault_opcode methods have been combined. Hence, there
is only one debugfs directory controlling the entire operation of the
fault injection machinery. This reduces the number of debugfs entries
and provides a more unified user experience.
5. A new control files - "direction" - is provided to allow the user to
control the direction of packets, which are subject to fault injection.
6. A new control file - "skip_usec" - is added that would allow the user
to specify a "timeout" during which no fault injection will occur.
In addition, the following bug fixes have been applied:
1. The fault injection code has been split into its own header and source
files. This was done to better organize the code and support conditional
compilation without littering the code with #ifdef's.
2. The method by which the TX PIO packets were being marked for drop
conflicted with the way send contexts were being setup. As a result,
the send context was repeatedly being reset.
3. The fault injection only makes sense when the user can control it
through the debugfs entries. However, a kernel configuration can
enable fault injection but keep fault injection debugfs entries
disabled. Therefore, it makes sense that the HFI fault injection
code depends on both.
4. Error suppression did not take into account the method by which PIO
packets were being dropped. Therefore, even with error suppression
turned on, errors would still be displayed to the screen. A larger
enough packet drop percentage would case the kernel to crash because
the driver would be stuck printing errors.
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Reviewed-by: Don Hiatt <don.hiatt@intel.com>
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Mitko Haralanov <mitko.haralanov@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2018-05-02 21:43:24 +08:00
|
|
|
if (hfi1_setup_9B_packet(packet))
|
2017-03-21 08:26:14 +08:00
|
|
|
return RHF_RCV_CONTINUE;
|
|
|
|
|
IB/hfi1: Rework fault injection machinery
The packet fault injection code present in the HFI1 driver had some
issues which not only fragment the code but also created user
confusion. Furthermore, it suffered from the following issues:
1. The fault_packet method only worked for received packets. This
meant that the only fault injection mode available for sent
packets is fault_opcode, which did not allow for random packet
drops on all egressing packets.
2. The mask available for the fault_opcode mode did not really work
due to the fact that the opcode values are not bits in a bitmask but
rather sequential integer values. Creating a opcode/mask pair that
would successfully capture a set of packets was nearly impossible.
3. The code was fragmented and used too many debugfs entries to
operate and control. This was confusing to users.
4. It did not allow filtering fault injection on a per direction basis -
egress vs. ingress.
In order to improve or fix the above issues, the following changes have
been made:
1. The fault injection methods have been combined into a single fault
injection facility. As such, the fault injection has been plugged
into both the send and receive code paths. Regardless of method used
the fault injection will operate on both egress and ingress packets.
2. The type of fault injection - by packet or by opcode - is now controlled
by changing the boolean value of the file "opcode_mode". When the value
is set to True, fault injection is done by opcode. Otherwise, by
packet.
2. The masking ability has been removed in favor of a bitmap that holds
opcodes of interest (one bit per opcode, a total of 256 bits). This
works in tandem with the "opcode_mode" value. When the value of
"opcode_mode" is False, this bitmap is ignored. When the value is
True, the bitmap lists all opcodes to be considered for fault injection.
By default, the bitmap is empty. When the user wants to filter by opcode,
the user sets the corresponding bit in the bitmap by echo'ing the bit
position into the 'opcodes' file. This gets around the issue that the set
of opcodes does not lend itself to effective masks and allow for extremely
fine-grained filtering by opcode.
4. fault_packet and fault_opcode methods have been combined. Hence, there
is only one debugfs directory controlling the entire operation of the
fault injection machinery. This reduces the number of debugfs entries
and provides a more unified user experience.
5. A new control files - "direction" - is provided to allow the user to
control the direction of packets, which are subject to fault injection.
6. A new control file - "skip_usec" - is added that would allow the user
to specify a "timeout" during which no fault injection will occur.
In addition, the following bug fixes have been applied:
1. The fault injection code has been split into its own header and source
files. This was done to better organize the code and support conditional
compilation without littering the code with #ifdef's.
2. The method by which the TX PIO packets were being marked for drop
conflicted with the way send contexts were being setup. As a result,
the send context was repeatedly being reset.
3. The fault injection only makes sense when the user can control it
through the debugfs entries. However, a kernel configuration can
enable fault injection but keep fault injection debugfs entries
disabled. Therefore, it makes sense that the HFI fault injection
code depends on both.
4. Error suppression did not take into account the method by which PIO
packets were being dropped. Therefore, even with error suppression
turned on, errors would still be displayed to the screen. A larger
enough packet drop percentage would case the kernel to crash because
the driver would be stuck printing errors.
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Reviewed-by: Don Hiatt <don.hiatt@intel.com>
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Mitko Haralanov <mitko.haralanov@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2018-05-02 21:43:24 +08:00
|
|
|
if (unlikely(hfi1_dbg_should_fault_rx(packet)))
|
2017-05-13 00:20:20 +08:00
|
|
|
return RHF_RCV_CONTINUE;
|
|
|
|
|
2018-02-02 04:38:48 +08:00
|
|
|
trace_hfi1_rcvhdr(packet);
|
2017-03-21 08:26:20 +08:00
|
|
|
|
2015-07-31 03:17:43 +08:00
|
|
|
if (unlikely(rhf_err_flags(packet->rhf))) {
|
|
|
|
handle_eflags(packet);
|
|
|
|
return RHF_RCV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
hfi1_ib_rcv(packet);
|
|
|
|
return RHF_RCV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2017-04-13 11:29:28 +08:00
|
|
|
static inline bool hfi1_is_vnic_packet(struct hfi1_packet *packet)
|
|
|
|
{
|
|
|
|
/* Packet received in VNIC context via RSM */
|
|
|
|
if (packet->rcd->is_vnic)
|
|
|
|
return true;
|
|
|
|
|
2017-08-05 04:53:58 +08:00
|
|
|
if ((hfi1_16B_get_l2(packet->ebuf) == OPA_16B_L2_TYPE) &&
|
|
|
|
(hfi1_16B_get_l4(packet->ebuf) == OPA_16B_L4_ETHR))
|
2017-04-13 11:29:28 +08:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-06-05 02:43:29 +08:00
|
|
|
static int process_receive_bypass(struct hfi1_packet *packet)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
2016-10-26 04:12:17 +08:00
|
|
|
struct hfi1_devdata *dd = packet->rcd->dd;
|
|
|
|
|
2017-08-05 04:53:58 +08:00
|
|
|
if (hfi1_is_vnic_packet(packet)) {
|
2017-04-13 11:29:28 +08:00
|
|
|
hfi1_vnic_bypass_rcv(packet);
|
|
|
|
return RHF_RCV_CONTINUE;
|
|
|
|
}
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2017-08-05 04:53:58 +08:00
|
|
|
if (hfi1_setup_bypass_packet(packet))
|
|
|
|
return RHF_RCV_CONTINUE;
|
|
|
|
|
2018-02-02 04:38:48 +08:00
|
|
|
trace_hfi1_rcvhdr(packet);
|
|
|
|
|
2017-08-05 04:53:58 +08:00
|
|
|
if (unlikely(rhf_err_flags(packet->rhf))) {
|
|
|
|
handle_eflags(packet);
|
|
|
|
return RHF_RCV_CONTINUE;
|
|
|
|
}
|
2016-10-26 04:12:17 +08:00
|
|
|
|
2017-08-05 04:53:58 +08:00
|
|
|
if (hfi1_16B_get_l2(packet->hdr) == 0x2) {
|
|
|
|
hfi1_16B_rcv(packet);
|
|
|
|
} else {
|
|
|
|
dd_dev_err(dd,
|
|
|
|
"Bypass packets other than 16B are not supported in normal operation. Dropping\n");
|
|
|
|
incr_cntr64(&dd->sw_rcv_bypass_packet_errors);
|
|
|
|
if (!(dd->err_info_rcvport.status_and_code &
|
|
|
|
OPA_EI_STATUS_SMASK)) {
|
|
|
|
u64 *flits = packet->ebuf;
|
|
|
|
|
|
|
|
if (flits && !(packet->rhf & RHF_LEN_ERR)) {
|
|
|
|
dd->err_info_rcvport.packet_flit1 = flits[0];
|
|
|
|
dd->err_info_rcvport.packet_flit2 =
|
|
|
|
packet->tlen > sizeof(flits[0]) ?
|
|
|
|
flits[1] : 0;
|
|
|
|
}
|
|
|
|
dd->err_info_rcvport.status_and_code |=
|
|
|
|
(OPA_EI_STATUS_SMASK | BAD_L2_ERR);
|
2016-10-26 04:12:17 +08:00
|
|
|
}
|
|
|
|
}
|
2015-07-31 03:17:43 +08:00
|
|
|
return RHF_RCV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2018-06-05 02:43:29 +08:00
|
|
|
static int process_receive_error(struct hfi1_packet *packet)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
2017-03-21 08:26:20 +08:00
|
|
|
/* KHdrHCRCErr -- KDETH packet with a bad HCRC */
|
|
|
|
if (unlikely(
|
|
|
|
hfi1_dbg_fault_suppress_err(&packet->rcd->dd->verbs_dev) &&
|
IB/hfi1: Rework fault injection machinery
The packet fault injection code present in the HFI1 driver had some
issues which not only fragment the code but also created user
confusion. Furthermore, it suffered from the following issues:
1. The fault_packet method only worked for received packets. This
meant that the only fault injection mode available for sent
packets is fault_opcode, which did not allow for random packet
drops on all egressing packets.
2. The mask available for the fault_opcode mode did not really work
due to the fact that the opcode values are not bits in a bitmask but
rather sequential integer values. Creating a opcode/mask pair that
would successfully capture a set of packets was nearly impossible.
3. The code was fragmented and used too many debugfs entries to
operate and control. This was confusing to users.
4. It did not allow filtering fault injection on a per direction basis -
egress vs. ingress.
In order to improve or fix the above issues, the following changes have
been made:
1. The fault injection methods have been combined into a single fault
injection facility. As such, the fault injection has been plugged
into both the send and receive code paths. Regardless of method used
the fault injection will operate on both egress and ingress packets.
2. The type of fault injection - by packet or by opcode - is now controlled
by changing the boolean value of the file "opcode_mode". When the value
is set to True, fault injection is done by opcode. Otherwise, by
packet.
2. The masking ability has been removed in favor of a bitmap that holds
opcodes of interest (one bit per opcode, a total of 256 bits). This
works in tandem with the "opcode_mode" value. When the value of
"opcode_mode" is False, this bitmap is ignored. When the value is
True, the bitmap lists all opcodes to be considered for fault injection.
By default, the bitmap is empty. When the user wants to filter by opcode,
the user sets the corresponding bit in the bitmap by echo'ing the bit
position into the 'opcodes' file. This gets around the issue that the set
of opcodes does not lend itself to effective masks and allow for extremely
fine-grained filtering by opcode.
4. fault_packet and fault_opcode methods have been combined. Hence, there
is only one debugfs directory controlling the entire operation of the
fault injection machinery. This reduces the number of debugfs entries
and provides a more unified user experience.
5. A new control files - "direction" - is provided to allow the user to
control the direction of packets, which are subject to fault injection.
6. A new control file - "skip_usec" - is added that would allow the user
to specify a "timeout" during which no fault injection will occur.
In addition, the following bug fixes have been applied:
1. The fault injection code has been split into its own header and source
files. This was done to better organize the code and support conditional
compilation without littering the code with #ifdef's.
2. The method by which the TX PIO packets were being marked for drop
conflicted with the way send contexts were being setup. As a result,
the send context was repeatedly being reset.
3. The fault injection only makes sense when the user can control it
through the debugfs entries. However, a kernel configuration can
enable fault injection but keep fault injection debugfs entries
disabled. Therefore, it makes sense that the HFI fault injection
code depends on both.
4. Error suppression did not take into account the method by which PIO
packets were being dropped. Therefore, even with error suppression
turned on, errors would still be displayed to the screen. A larger
enough packet drop percentage would case the kernel to crash because
the driver would be stuck printing errors.
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Reviewed-by: Don Hiatt <don.hiatt@intel.com>
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Mitko Haralanov <mitko.haralanov@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2018-05-02 21:43:24 +08:00
|
|
|
(rhf_rcv_type_err(packet->rhf) == RHF_RCV_TYPE_ERROR ||
|
|
|
|
packet->rhf & RHF_DC_ERR)))
|
2017-03-21 08:26:20 +08:00
|
|
|
return RHF_RCV_CONTINUE;
|
|
|
|
|
2017-05-13 00:20:20 +08:00
|
|
|
hfi1_setup_ib_header(packet);
|
2015-07-31 03:17:43 +08:00
|
|
|
handle_eflags(packet);
|
|
|
|
|
|
|
|
if (unlikely(rhf_err_flags(packet->rhf)))
|
|
|
|
dd_dev_err(packet->rcd->dd,
|
|
|
|
"Unhandled error packet received. Dropping.\n");
|
|
|
|
|
|
|
|
return RHF_RCV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2018-06-05 02:43:29 +08:00
|
|
|
static int kdeth_process_expected(struct hfi1_packet *packet)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
IB/hfi1: Rework fault injection machinery
The packet fault injection code present in the HFI1 driver had some
issues which not only fragment the code but also created user
confusion. Furthermore, it suffered from the following issues:
1. The fault_packet method only worked for received packets. This
meant that the only fault injection mode available for sent
packets is fault_opcode, which did not allow for random packet
drops on all egressing packets.
2. The mask available for the fault_opcode mode did not really work
due to the fact that the opcode values are not bits in a bitmask but
rather sequential integer values. Creating a opcode/mask pair that
would successfully capture a set of packets was nearly impossible.
3. The code was fragmented and used too many debugfs entries to
operate and control. This was confusing to users.
4. It did not allow filtering fault injection on a per direction basis -
egress vs. ingress.
In order to improve or fix the above issues, the following changes have
been made:
1. The fault injection methods have been combined into a single fault
injection facility. As such, the fault injection has been plugged
into both the send and receive code paths. Regardless of method used
the fault injection will operate on both egress and ingress packets.
2. The type of fault injection - by packet or by opcode - is now controlled
by changing the boolean value of the file "opcode_mode". When the value
is set to True, fault injection is done by opcode. Otherwise, by
packet.
2. The masking ability has been removed in favor of a bitmap that holds
opcodes of interest (one bit per opcode, a total of 256 bits). This
works in tandem with the "opcode_mode" value. When the value of
"opcode_mode" is False, this bitmap is ignored. When the value is
True, the bitmap lists all opcodes to be considered for fault injection.
By default, the bitmap is empty. When the user wants to filter by opcode,
the user sets the corresponding bit in the bitmap by echo'ing the bit
position into the 'opcodes' file. This gets around the issue that the set
of opcodes does not lend itself to effective masks and allow for extremely
fine-grained filtering by opcode.
4. fault_packet and fault_opcode methods have been combined. Hence, there
is only one debugfs directory controlling the entire operation of the
fault injection machinery. This reduces the number of debugfs entries
and provides a more unified user experience.
5. A new control files - "direction" - is provided to allow the user to
control the direction of packets, which are subject to fault injection.
6. A new control file - "skip_usec" - is added that would allow the user
to specify a "timeout" during which no fault injection will occur.
In addition, the following bug fixes have been applied:
1. The fault injection code has been split into its own header and source
files. This was done to better organize the code and support conditional
compilation without littering the code with #ifdef's.
2. The method by which the TX PIO packets were being marked for drop
conflicted with the way send contexts were being setup. As a result,
the send context was repeatedly being reset.
3. The fault injection only makes sense when the user can control it
through the debugfs entries. However, a kernel configuration can
enable fault injection but keep fault injection debugfs entries
disabled. Therefore, it makes sense that the HFI fault injection
code depends on both.
4. Error suppression did not take into account the method by which PIO
packets were being dropped. Therefore, even with error suppression
turned on, errors would still be displayed to the screen. A larger
enough packet drop percentage would case the kernel to crash because
the driver would be stuck printing errors.
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Reviewed-by: Don Hiatt <don.hiatt@intel.com>
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Mitko Haralanov <mitko.haralanov@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2018-05-02 21:43:24 +08:00
|
|
|
hfi1_setup_9B_packet(packet);
|
|
|
|
if (unlikely(hfi1_dbg_should_fault_rx(packet)))
|
2017-03-21 08:26:14 +08:00
|
|
|
return RHF_RCV_CONTINUE;
|
2017-05-13 00:20:20 +08:00
|
|
|
|
2019-01-24 22:36:34 +08:00
|
|
|
if (unlikely(rhf_err_flags(packet->rhf))) {
|
|
|
|
struct hfi1_ctxtdata *rcd = packet->rcd;
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2019-01-24 22:36:34 +08:00
|
|
|
if (hfi1_handle_kdeth_eflags(rcd, rcd->ppd, packet))
|
|
|
|
return RHF_RCV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
hfi1_kdeth_expected_rcv(packet);
|
2015-07-31 03:17:43 +08:00
|
|
|
return RHF_RCV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2018-06-05 02:43:29 +08:00
|
|
|
static int kdeth_process_eager(struct hfi1_packet *packet)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
IB/hfi1: Rework fault injection machinery
The packet fault injection code present in the HFI1 driver had some
issues which not only fragment the code but also created user
confusion. Furthermore, it suffered from the following issues:
1. The fault_packet method only worked for received packets. This
meant that the only fault injection mode available for sent
packets is fault_opcode, which did not allow for random packet
drops on all egressing packets.
2. The mask available for the fault_opcode mode did not really work
due to the fact that the opcode values are not bits in a bitmask but
rather sequential integer values. Creating a opcode/mask pair that
would successfully capture a set of packets was nearly impossible.
3. The code was fragmented and used too many debugfs entries to
operate and control. This was confusing to users.
4. It did not allow filtering fault injection on a per direction basis -
egress vs. ingress.
In order to improve or fix the above issues, the following changes have
been made:
1. The fault injection methods have been combined into a single fault
injection facility. As such, the fault injection has been plugged
into both the send and receive code paths. Regardless of method used
the fault injection will operate on both egress and ingress packets.
2. The type of fault injection - by packet or by opcode - is now controlled
by changing the boolean value of the file "opcode_mode". When the value
is set to True, fault injection is done by opcode. Otherwise, by
packet.
2. The masking ability has been removed in favor of a bitmap that holds
opcodes of interest (one bit per opcode, a total of 256 bits). This
works in tandem with the "opcode_mode" value. When the value of
"opcode_mode" is False, this bitmap is ignored. When the value is
True, the bitmap lists all opcodes to be considered for fault injection.
By default, the bitmap is empty. When the user wants to filter by opcode,
the user sets the corresponding bit in the bitmap by echo'ing the bit
position into the 'opcodes' file. This gets around the issue that the set
of opcodes does not lend itself to effective masks and allow for extremely
fine-grained filtering by opcode.
4. fault_packet and fault_opcode methods have been combined. Hence, there
is only one debugfs directory controlling the entire operation of the
fault injection machinery. This reduces the number of debugfs entries
and provides a more unified user experience.
5. A new control files - "direction" - is provided to allow the user to
control the direction of packets, which are subject to fault injection.
6. A new control file - "skip_usec" - is added that would allow the user
to specify a "timeout" during which no fault injection will occur.
In addition, the following bug fixes have been applied:
1. The fault injection code has been split into its own header and source
files. This was done to better organize the code and support conditional
compilation without littering the code with #ifdef's.
2. The method by which the TX PIO packets were being marked for drop
conflicted with the way send contexts were being setup. As a result,
the send context was repeatedly being reset.
3. The fault injection only makes sense when the user can control it
through the debugfs entries. However, a kernel configuration can
enable fault injection but keep fault injection debugfs entries
disabled. Therefore, it makes sense that the HFI fault injection
code depends on both.
4. Error suppression did not take into account the method by which PIO
packets were being dropped. Therefore, even with error suppression
turned on, errors would still be displayed to the screen. A larger
enough packet drop percentage would case the kernel to crash because
the driver would be stuck printing errors.
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Reviewed-by: Don Hiatt <don.hiatt@intel.com>
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Mitko Haralanov <mitko.haralanov@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2018-05-02 21:43:24 +08:00
|
|
|
hfi1_setup_9B_packet(packet);
|
|
|
|
if (unlikely(hfi1_dbg_should_fault_rx(packet)))
|
|
|
|
return RHF_RCV_CONTINUE;
|
2015-07-31 03:17:43 +08:00
|
|
|
|
2019-01-24 22:36:34 +08:00
|
|
|
trace_hfi1_rcvhdr(packet);
|
|
|
|
if (unlikely(rhf_err_flags(packet->rhf))) {
|
|
|
|
struct hfi1_ctxtdata *rcd = packet->rcd;
|
|
|
|
|
|
|
|
show_eflags_errs(packet);
|
|
|
|
if (hfi1_handle_kdeth_eflags(rcd, rcd->ppd, packet))
|
|
|
|
return RHF_RCV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
hfi1_kdeth_eager_rcv(packet);
|
2015-07-31 03:17:43 +08:00
|
|
|
return RHF_RCV_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2018-06-05 02:43:29 +08:00
|
|
|
static int process_receive_invalid(struct hfi1_packet *packet)
|
2015-07-31 03:17:43 +08:00
|
|
|
{
|
|
|
|
dd_dev_err(packet->rcd->dd, "Invalid packet type %d. Dropping\n",
|
2016-02-15 12:21:52 +08:00
|
|
|
rhf_rcv_type(packet->rhf));
|
2015-07-31 03:17:43 +08:00
|
|
|
return RHF_RCV_CONTINUE;
|
|
|
|
}
|
2017-08-13 23:09:04 +08:00
|
|
|
|
|
|
|
void seqfile_dump_rcd(struct seq_file *s, struct hfi1_ctxtdata *rcd)
|
|
|
|
{
|
|
|
|
struct hfi1_packet packet;
|
|
|
|
struct ps_mdata mdata;
|
|
|
|
|
|
|
|
seq_printf(s, "Rcd %u: RcvHdr cnt %u entsize %u %s head %llu tail %llu\n",
|
|
|
|
rcd->ctxt, rcd->rcvhdrq_cnt, rcd->rcvhdrqentsize,
|
|
|
|
HFI1_CAP_KGET_MASK(rcd->flags, DMA_RTAIL) ?
|
|
|
|
"dma_rtail" : "nodma_rtail",
|
|
|
|
read_uctxt_csr(rcd->dd, rcd->ctxt, RCV_HDR_HEAD) &
|
|
|
|
RCV_HDR_HEAD_HEAD_MASK,
|
|
|
|
read_uctxt_csr(rcd->dd, rcd->ctxt, RCV_HDR_TAIL));
|
|
|
|
|
|
|
|
init_packet(rcd, &packet);
|
|
|
|
init_ps_mdata(&mdata, &packet);
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
__le32 *rhf_addr = (__le32 *)rcd->rcvhdrq + mdata.ps_head +
|
2018-06-05 02:43:37 +08:00
|
|
|
rcd->rhf_offset;
|
2017-08-13 23:09:04 +08:00
|
|
|
struct ib_header *hdr;
|
|
|
|
u64 rhf = rhf_to_cpu(rhf_addr);
|
|
|
|
u32 etype = rhf_rcv_type(rhf), qpn;
|
|
|
|
u8 opcode;
|
|
|
|
u32 psn;
|
|
|
|
u8 lnh;
|
|
|
|
|
|
|
|
if (ps_done(&mdata, rhf, rcd))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (ps_skip(&mdata, rhf, rcd))
|
|
|
|
goto next;
|
|
|
|
|
|
|
|
if (etype > RHF_RCV_TYPE_IB)
|
|
|
|
goto next;
|
|
|
|
|
2018-06-05 02:43:37 +08:00
|
|
|
packet.hdr = hfi1_get_msgheader(rcd, rhf_addr);
|
2017-08-13 23:09:04 +08:00
|
|
|
hdr = packet.hdr;
|
|
|
|
|
|
|
|
lnh = be16_to_cpu(hdr->lrh[0]) & 3;
|
|
|
|
|
|
|
|
if (lnh == HFI1_LRH_BTH)
|
|
|
|
packet.ohdr = &hdr->u.oth;
|
|
|
|
else if (lnh == HFI1_LRH_GRH)
|
|
|
|
packet.ohdr = &hdr->u.l.oth;
|
|
|
|
else
|
|
|
|
goto next; /* just in case */
|
|
|
|
|
|
|
|
opcode = (be32_to_cpu(packet.ohdr->bth[0]) >> 24);
|
|
|
|
qpn = be32_to_cpu(packet.ohdr->bth[1]) & RVT_QPN_MASK;
|
|
|
|
psn = mask_psn(be32_to_cpu(packet.ohdr->bth[2]));
|
|
|
|
|
|
|
|
seq_printf(s, "\tEnt %u: opcode 0x%x, qpn 0x%x, psn 0x%x\n",
|
|
|
|
mdata.ps_head, opcode, qpn, psn);
|
|
|
|
next:
|
|
|
|
update_ps_mdata(&mdata, rcd);
|
|
|
|
}
|
|
|
|
}
|
2018-06-05 02:43:29 +08:00
|
|
|
|
|
|
|
const rhf_rcv_function_ptr normal_rhf_rcv_functions[] = {
|
|
|
|
[RHF_RCV_TYPE_EXPECTED] = kdeth_process_expected,
|
|
|
|
[RHF_RCV_TYPE_EAGER] = kdeth_process_eager,
|
|
|
|
[RHF_RCV_TYPE_IB] = process_receive_ib,
|
|
|
|
[RHF_RCV_TYPE_ERROR] = process_receive_error,
|
|
|
|
[RHF_RCV_TYPE_BYPASS] = process_receive_bypass,
|
|
|
|
[RHF_RCV_TYPE_INVALID5] = process_receive_invalid,
|
|
|
|
[RHF_RCV_TYPE_INVALID6] = process_receive_invalid,
|
|
|
|
[RHF_RCV_TYPE_INVALID7] = process_receive_invalid,
|
|
|
|
};
|