]> git.karo-electronics.de Git - linux-beck.git/log
linux-beck.git
7 years agoMerge branch 'hfi1' into merge-test
Doug Ledford [Wed, 14 Dec 2016 19:44:08 +0000 (14:44 -0500)]
Merge branch 'hfi1' into merge-test

7 years agoMerge branches 'chelsio', 'debug-cleanup', 'hns' and 'i40iw' into merge-test
Doug Ledford [Wed, 14 Dec 2016 19:43:14 +0000 (14:43 -0500)]
Merge branches 'chelsio', 'debug-cleanup', 'hns' and 'i40iw' into merge-test

7 years agoIB/rdmavt: Only put mmap_info ref if it exists
Jim Foraker [Tue, 1 Nov 2016 20:44:12 +0000 (13:44 -0700)]
IB/rdmavt: Only put mmap_info ref if it exists

rvt_create_qp() creates qp->ip only when a qp creation request comes from
userspace (udata is not NULL).  If we exceed the number of available
queue pairs however, the error path always attempts to put a kref to this
structure.  If the requestor is inside the kernel, this leads to a crash.

We fix this by checking that qp->ip is not NULL before caling kref_put().

Signed-off-by: Jim Foraker <foraker1@llnl.gov>
Acked-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Acked-by: Jonathan Toppins <jtoppins@redhat.com>
Acked-by: Alex Estrin <alex.estrin@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/rdmavt: Handle the kthread worker using the new API
Petr Mladek [Wed, 19 Oct 2016 12:07:20 +0000 (14:07 +0200)]
IB/rdmavt: Handle the kthread worker using the new API

Use the new API to create and destroy the cq kthread worker.
The API hides some implementation details.

In particular, kthread_create_worker() allocates and initializes
struct kthread_worker. It runs the kthread the right way and stores
task_struct into the worker structure. In addition, the *on_cpu()
variant binds the kthread to the given cpu and the related memory
node.

kthread_destroy_worker() flushes all pending works, stops
the kthread and frees the structure.

This patch does not change the existing behavior. Note that we must
use the on_cpu() variant because the function starts the kthread
and it must bind it to the right CPU before waking. The numa node
is associated for given CPU as well.

Signed-off-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/rdmavt: Avoid queuing work into a destroyed cq kthread worker
Petr Mladek [Wed, 19 Oct 2016 12:07:19 +0000 (14:07 +0200)]
IB/rdmavt: Avoid queuing work into a destroyed cq kthread worker

The memory barrier is not enough to protect queuing works into
a destroyed cq kthread. Just imagine the following situation:

CPU1 CPU2

rvt_cq_enter()
  worker =  cq->rdi->worker;

rvt_cq_exit()
  rdi->worker = NULL;
  smp_wmb();
  kthread_flush_worker(worker);
  kthread_stop(worker->task);
  kfree(worker);

  // nothing queued yet =>
  // nothing flushed and
  // happily stopped and freed

  if (likely(worker)) {
     // true => read before CPU2 acted
     cq->notify = RVT_CQ_NONE;
     cq->triggered++;
     kthread_queue_work(worker, &cq->comptask);

  BANG: worker has been flushed/stopped/freed in the meantime.

This patch solves this by protecting the critical sections by
rdi->n_cqs_lock. It seems that this lock is not much contended
and looks reasonable for this purpose.

One catch is that rvt_cq_enter() might be called from IRQ context.
Therefore we must always take the lock with IRQs disabled to avoid
a possible deadlock.

Signed-off-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Reorganize structures to align with HW capabilities
Henry Orosco [Tue, 6 Dec 2016 22:16:20 +0000 (16:16 -0600)]
i40iw: Reorganize structures to align with HW capabilities

Some resources are incorrectly organized and at odds with
HW capabilities. Specifically, ILQ, IEQ, QPs, MSS, QOS
and statistics belong in a VSI.

Signed-off-by: Faisal Latif <faisal.latif@intel.com>
Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Fix incorrect check for error
Mustafa Ismail [Tue, 6 Dec 2016 21:49:35 +0000 (15:49 -0600)]
i40iw: Fix incorrect check for error

In i40iw_ieq_handle_partial() the check for !status is incorrect.

Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Assign MSS only when it is a new MTU
Mustafa Ismail [Tue, 6 Dec 2016 21:49:34 +0000 (15:49 -0600)]
i40iw: Assign MSS only when it is a new MTU

Currently we are changing the MSS regardless of whether
there is a change or not in MTU. Fix to make the
assignment of MSS dependent on an MTU change.

Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Fix race condition in terminate timer's handler
Shiraz Saleem [Tue, 6 Dec 2016 21:49:33 +0000 (15:49 -0600)]
i40iw: Fix race condition in terminate timer's handler

Add a QP reference when terminate timer is started to ensure
the destroy QP doesn't race ahead to free the QP while it is being
referenced in the terminate timer's handler.

Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Fix memory leak in CQP destroy when in reset
Mustafa Ismail [Tue, 6 Dec 2016 21:49:32 +0000 (15:49 -0600)]
i40iw: Fix memory leak in CQP destroy when in reset

On a device close, the control QP (CQP) is destroyed by calling
cqp_destroy which destroys the CQP and frees its SD buffer memory.
However, if the reset flag is true, cqp_destroy is never called and
leads to a memory leak on SD buffer memory. Fix this by always calling
cqp_destroy, on device close, regardless of reset. The exception to this
when CQP create fails. In this case, the SD buffer memory is already
freed on an error check and there is no need to call cqp_destroy.

Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Fix QP flush to not hang on empty queues or failure
Shiraz Saleem [Tue, 6 Dec 2016 21:49:31 +0000 (15:49 -0600)]
i40iw: Fix QP flush to not hang on empty queues or failure

When flush QP and there are no pending work requests, signal completion
to unblock i40iw_drain_sq and i40iw_drain_rq which are waiting on
completion for iwqp->sq_drained and iwqp->sq_drained respectively.
Also, signal completion if flush QP fails to prevent the drain SQ or RQ
from being blocked indefintely.

Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Fix double free of QP
Mustafa Ismail [Tue, 6 Dec 2016 21:49:30 +0000 (15:49 -0600)]
i40iw: Fix double free of QP

A QP can be double freed if i40iw_cm_disconn() is
called while it is currently being freed by
i40iw_rem_ref(). The fix in i40iw_cm_disconn() will
first check if the QP is already freed before
making another request for the QP to be freed.

Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Use correct src address in memcpy to rdma stats counters
Shiraz Saleem [Fri, 11 Nov 2016 16:55:41 +0000 (10:55 -0600)]
i40iw: Use correct src address in memcpy to rdma stats counters

hw_stats is a pointer to i40_iw_dev_stats struct in i40iw_get_hw_stats().
Use hw_stats and not &hw_stats in the memcpy to copy the i40iw device stats
data into rdma_hw_stats counters.

Fixes: b40f4757daa1 ("IB/core: Make device counter infrastructure dynamic")
Cc: stable@vger.kernel.org # 4.7+
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Faisal Latif <faisal.latif@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Remove macros I40IW_STAG_KEY_FROM_STAG and I40IW_STAG_INDEX_FROM_STAG
Thomas Huth [Wed, 5 Oct 2016 11:55:38 +0000 (13:55 +0200)]
i40iw: Remove macros I40IW_STAG_KEY_FROM_STAG and I40IW_STAG_INDEX_FROM_STAG

The macros I40IW_STAG_KEY_FROM_STAG and I40IW_STAG_INDEX_FROM_STAG are
apparently bad - they are using the logical "&&" operation which
does not make sense here. It should have been a bitwise "&" instead.
Since the macros seem to be completely unused, let's simply remove
them so that nobody accidentially uses them in the future. And while
we're at it, also remove the unused macro I40IW_CREATE_STAG.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Acked-by: Faisal Latif <faisal.latif@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hfi1: Define platform_config_table_limits once
Bart Van Assche [Tue, 6 Dec 2016 00:48:11 +0000 (16:48 -0800)]
IB/hfi1: Define platform_config_table_limits once

Defining static data structures in a header file is wrong because
this causes the data structure to be instantiated once in every .c
file it is included in. Hence move the definition of a static
array from a header file into the only .c file in which it is used.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Dennis Dalessandro <dennis.dalessandro@intel.com>
Cc: Dean Luick <dean.luick@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hfi1: constify mmu_notifier_ops structure
Bhumika Goyal [Sat, 19 Nov 2016 09:47:48 +0000 (15:17 +0530)]
IB/hfi1: constify mmu_notifier_ops structure

Declare the structure mmu_notifier_ops as const as it is only stored in
the ops field of a mmu_notifier structure. The ops field is of type
const struct mmu_notifier_ops *, so mmu_notifier_ops structures having
this property can be declared as const.
Done using coccinelle:
@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct mmu_notifier_ops i@p = {...};

@ok1@
identifier r1.i;
position p;
struct mmu_rb_handler handler;
@@
handler.mn.ops=&i@p

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct mmu_notifier_ops i={...};

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct mmu_notifier_ops i;

File size before:
   text    data     bss     dec     hex filename
   3566      72      16    3654     e46
drivers/infiniband/hw/hfi1/mmu_rb.o

File size after:
   text    data     bss     dec     hex filename
   3658       0      16    3674     e5a
drivers/infiniband/hw/hfi1/mmu_rb.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/rdmavt, IB/hfi1, IB/qib: Add inlines for mtu division
Mike Marciniszyn [Thu, 8 Dec 2016 03:34:37 +0000 (19:34 -0800)]
IB/rdmavt, IB/hfi1, IB/qib: Add inlines for mtu division

Add rvt_div_round_up_mtu() and rvt_div_mtu() routines to
do the computation based on the pmtu and the log_pmtu.

Change divides in qib, hfi1 to use the new inlines.

Reviewed-by: Kaike Wan <kaike.wan@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>
7 years agoIB/hfi1,IB/qib: use rvt swqe mr deref helper
Mike Marciniszyn [Thu, 8 Dec 2016 03:34:31 +0000 (19:34 -0800)]
IB/hfi1,IB/qib: use rvt swqe mr deref helper

Convert to use new swqe put routine.

Reviewed-by: Brian Welty <brian.welty@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>
7 years agoIB/rdmavt: Add swqe mr deref helper
Mike Marciniszyn [Thu, 8 Dec 2016 03:34:25 +0000 (19:34 -0800)]
IB/rdmavt: Add swqe mr deref helper

Add a helper to release mr references held by
an swqe.

Reviewed-by: Brian Welty <brian.welty@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>
7 years agoIB/hfi1: Avoid credit return allocation for cpu-less NUMA nodes
Harish Chegondi [Thu, 8 Dec 2016 03:34:19 +0000 (19:34 -0800)]
IB/hfi1: Avoid credit return allocation for cpu-less NUMA nodes

Do not allocate credit return base and DMA memory for
NUMA nodes without CPUs.

Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Harish Chegondi <harish.chegondi@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hfi1,IB/qib: Use new send completion helper
Mike Marciniszyn [Thu, 8 Dec 2016 03:34:12 +0000 (19:34 -0800)]
IB/hfi1,IB/qib: Use new send completion helper

Convert cq completion returns in both rdmavt drivers
to use the new helper.

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>
7 years agoIB/rdmavt: Add a send completion helper
Mike Marciniszyn [Thu, 8 Dec 2016 03:34:06 +0000 (19:34 -0800)]
IB/rdmavt: Add a send completion helper

This is for use by client drivers to drive
send completions into a CQ.

A new exported table allows for the mapping
of ib_wr_opcode into a ib_wc_opcode.

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>
7 years agoIB/qib: Use standard refcount wrapper for QPs
Sebastian Sanchez [Thu, 8 Dec 2016 03:34:00 +0000 (19:34 -0800)]
IB/qib: Use standard refcount wrapper for QPs

Use the standard driver wrapper for QP reference counters.
This makes the code more maintainable.

Fixes: Commit 4d6f85c3fa55 ("IB/rdmavt, IB/qib, IB/hfi1: Use new QP put get routines")
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Sebastian Sanchez <sebastian.sanchez@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hfi1: Use reference count wrapper for MRs
Sebastian Sanchez [Thu, 8 Dec 2016 03:33:53 +0000 (19:33 -0800)]
IB/hfi1: Use reference count wrapper for MRs

Some parts of the code don't use the standard driver
wrapper for memory region reference counters. Use the
standard driver wrapper throughout the code.

Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Sebastian Sanchez <sebastian.sanchez@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hfi1: Replace qp->refcount release code with standard driver wrapper
Sebastian Sanchez [Thu, 8 Dec 2016 03:33:46 +0000 (19:33 -0800)]
IB/hfi1: Replace qp->refcount release code with standard driver wrapper

Some parts of the code don't use the standard release
wrapper rvt_put_qp() for decrementing and testing
the refcount to then try to use a resource.
Replace this code with the standard driver wrapper.

Fixes: Commit 4d6f85c3fa55 ("IB/rdmavt, IB/qib, IB/hfi1: Use new QP put get routines")
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Sebastian Sanchez <sebastian.sanchez@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hfi1: Preserve external device completed bit
Dean Luick [Thu, 8 Dec 2016 03:33:40 +0000 (19:33 -0800)]
IB/hfi1: Preserve external device completed bit

The driver should not change the external device request
completed bit when not actually doing an external device
request.

Reviewed-by: Easwar Hariharan <easwar.hariharan@intel.com>
Signed-off-by: Dean Luick <dean.luick@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hfi1: Remove critical section gap in sc_buffer_alloc()
Sebastian Sanchez [Thu, 8 Dec 2016 03:33:33 +0000 (19:33 -0800)]
IB/hfi1: Remove critical section gap in sc_buffer_alloc()

In sc_buffer_alloc(), the sc->alloc_lock is released
before calling sc_release_update(), and it is reacquired
after the function call. This causes CPU lock trading.
Fix it by not dropping the lock before calling
sc_release_update().

Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Sebastian Sanchez <sebastian.sanchez@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hfi1: Remove usage of qp->s_cur_sge
Mitko Haralanov [Thu, 8 Dec 2016 03:33:27 +0000 (19:33 -0800)]
IB/hfi1: Remove usage of qp->s_cur_sge

The s_cur_sge field in the qp structure holds a pointer to the
SGE of the currently processed WQE. It assumes the protection
of the RVT_S_BUSY flag to prevent the changing of this field
while the send engine is using it. This scheme works as long
as there is only one instance of the send engine running at a
time.

Scaling of the send engine to multiple cores would break this
assumption as there could be multiple instances of the send engine
running on different CPUs. This opens a window where the QP's
RVT_S_BUSY flag is not set but the send engine is still running.

To prevent accidental changing of the s_cur_sge pointer, the QP's
dependence on it is removed. The SGE pointer is now stored in the
verbs_txreq, which is a per-packet data structure. This ensures
that each individual packet has it's own pointer, which is setup
while the RVT_S_BUSY flag is set.

Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@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>
7 years agoIB/rdmavt: Add trace of MR segs
Mike Marciniszyn [Thu, 8 Dec 2016 03:33:20 +0000 (19:33 -0800)]
IB/rdmavt: Add trace of MR segs

Add tracing of MR segment information.

Reviewed-by: Dennis Dalessandro <dennis.dalessandro@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>
7 years agoIB/hfi1: Add special setting for low power AOC
Dean Luick [Thu, 8 Dec 2016 03:33:13 +0000 (19:33 -0800)]
IB/hfi1: Add special setting for low power AOC

Low power QSFP AOC cables require a different SerDes
Tx PLL bandwidth setting than the default.  The
8051 firmware does not know the details, so the driver
needs to tell the firmware through a special setting.

Reviewed-by: Easwar Hariharan <easwar.hariharan@intel.com>
Signed-off-by: Dean Luick <dean.luick@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hfi1: Remove definition of unused hfi1_affinity struct
Tadeusz Struk [Thu, 8 Dec 2016 03:33:06 +0000 (19:33 -0800)]
IB/hfi1: Remove definition of unused hfi1_affinity struct

The struct hfi1_affinity is not used anymore.
We use the struct hfi1_affinity_node and hfi1_affinity_node_list
instead.

Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hfi1: Remove dependence on qp->s_cur_size
Don Hiatt [Thu, 8 Dec 2016 03:33:00 +0000 (19:33 -0800)]
IB/hfi1: Remove dependence on qp->s_cur_size

The qp->s_cur_size field assumes that the S_BUSY bit protects
the field from modification after the slock is dropped. Scaling the
send engine to multiple cores would break that assumption.

Correct the issue by carrying the payload size in the txreq structure.

Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Don Hiatt <don.hiatt@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hfi1: Show statistics counters under IB stats interface
Jianxin Xiong [Thu, 8 Dec 2016 03:32:53 +0000 (19:32 -0800)]
IB/hfi1: Show statistics counters under IB stats interface

Previously tools like hfi1stats had to access these counters through
debugfs, which often caused permission issue for non-root users. It is
not always acceptable to change the debugfs mounting permission due
to security concerns. When exposed under the IB stats interface, the
counters are universally readable by default.

Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Jianxin Xiong <jianxin.xiong@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/rdmavt: Fix trace hierarchy
Dennis Dalessandro [Thu, 8 Dec 2016 03:32:47 +0000 (19:32 -0800)]
IB/rdmavt: Fix trace hierarchy

Split rdmavt traces into separate files to preserve the original
hierarchy since only one trace sub system may now be defined per header
file.

Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hfi1: Disable header suppression for short packets
Jakub Pawlak [Thu, 8 Dec 2016 03:32:41 +0000 (19:32 -0800)]
IB/hfi1: Disable header suppression for short packets

For the received packets with payload less or equal 8DWS
RxDmaDataFifoRdUncErr is not reported. There is set RHF.EccErr
if the header is not suppressed. When such packet is detected
on the send side the header suppression mechanism is disabled
by clearing SH bit in the packet header.

Reviewed-by: Mitko Haralanov <mitko.haralanov@intel.com>
Signed-off-by: Jakub Pawlak <jakub.pawlak@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hfi1: Export 8051 memory and LCB registers via debugfs
Dean Luick [Thu, 8 Dec 2016 03:32:34 +0000 (19:32 -0800)]
IB/hfi1: Export 8051 memory and LCB registers via debugfs

Both the 8051 memory and LCB register access require multiple
steps and coordination with the driver.  This cannot be safely
done with resource0 alone.

The 8051 memory is exported read-only.  LCB is exported read/write.

Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Dean Luick <dean.luick@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hfi1: Use non-atomic __test_and_clear_bit in hot path
Sebastian Sanchez [Thu, 8 Dec 2016 03:32:28 +0000 (19:32 -0800)]
IB/hfi1: Use non-atomic __test_and_clear_bit in hot path

qp->r_aflags is already protected by qp->r_lock, therefore,
test_and_clear_bit() doesn't need to be atomic. Profile
shows this function call is costly.

Change the test_and_clear_bit() call to use the non-atomic
variant.

Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Sebastian Sanchez <sebastian.sanchez@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hfi1: Fix dc8051 multiple qword memory reads
Dean Luick [Thu, 8 Dec 2016 03:32:22 +0000 (19:32 -0800)]
IB/hfi1: Fix dc8051 multiple qword memory reads

When reading multiple dc8051 data memory locations
at once, the read enabled field must be toggled
at every address change.  Do that by writing only
the address first, then writing the enable.

Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Dean Luick <dean.luick@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hfi1: Read new EPROM format
Dean Luick [Thu, 8 Dec 2016 03:32:15 +0000 (19:32 -0800)]
IB/hfi1: Read new EPROM format

Add the ability to read the new EPROM format.

Reviewed-by: Easwar Hariharan <easwar.hariharan@intel.com>
Signed-off-by: Dean Luick <dean.luick@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoiw_cxgb4: Fix error return code in c4iw_rdev_open()
Wei Yongjun [Sat, 17 Sep 2016 00:41:37 +0000 (00:41 +0000)]
iw_cxgb4: Fix error return code in c4iw_rdev_open()

Fix to return error code -ENOMEM from the __get_free_page() error
handling case instead of 0, as done elsewhere in this function.

Fixes: 05eb23893c2c ("cxgb4/iw_cxgb4: Doorbell Drop Avoidance Bug Fixes")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Acked-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Add request for reset on CQP timeout
Henry Orosco [Wed, 30 Nov 2016 21:14:15 +0000 (15:14 -0600)]
i40iw: Add request for reset on CQP timeout

When CQP times out, send a request to LAN driver for reset.

Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Code cleanup, remove check of PBLE pages
Henry Orosco [Wed, 30 Nov 2016 21:13:47 +0000 (15:13 -0600)]
i40iw: Code cleanup, remove check of PBLE pages

Remove check for zero 'pages' of unallocated pbles calculated in
add_pble_pool(); as it can never be true.

Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Correctly fail loopback connection if no listener
Shiraz Saleem [Wed, 30 Nov 2016 21:12:35 +0000 (15:12 -0600)]
i40iw: Correctly fail loopback connection if no listener

Fail the connect and return the proper error code if a client
is started with local IP address and there is no corresponding
loopback listener.

Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Faisal Latif <faisal.latif@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Fill in IRD value when on connect request
Shiraz Saleem [Wed, 30 Nov 2016 21:12:11 +0000 (15:12 -0600)]
i40iw: Fill in IRD value when on connect request

IRD is not populated on connect request and application is
getting 0 for the value. Fill in the correct value on
connect request.

Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Faisal Latif <faisal.latif@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Set TOS field in IP header
Shiraz Saleem [Wed, 30 Nov 2016 21:09:34 +0000 (15:09 -0600)]
i40iw: Set TOS field in IP header

Set the TOS field in IP header with the value passed in
from application. If there is mismatch between the remote
client's TOS and listener, set the listener Tos to the higher
of the two values.

Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Faisal Latif <faisal.latif@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Add NULL check for ibqp event handler
Shiraz Saleem [Wed, 30 Nov 2016 21:09:07 +0000 (15:09 -0600)]
i40iw: Add NULL check for ibqp event handler

Add NULL check for ibqp event handler before calling it to report
QP events, as it might not initialized.

Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Faisal Latif <faisal.latif@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Replace list_for_each_entry macro with safe version
Mustafa Ismail [Wed, 30 Nov 2016 21:08:34 +0000 (15:08 -0600)]
i40iw: Replace list_for_each_entry macro with safe version

Use list_for_each_entry_safe macro for the IPv6 addr list
as IPv6 addresses can be deleted while going through the
list.

Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Add IP addr handling on netdev events
Mustafa Ismail [Wed, 30 Nov 2016 21:07:30 +0000 (15:07 -0600)]
i40iw: Add IP addr handling on netdev events

Disable listeners and disconnect all connected QPs on
a netdev interface down event. On an interface up event,
the listeners are re-enabled.

Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Add missing cleanup on device close
Mustafa Ismail [Wed, 30 Nov 2016 20:59:26 +0000 (14:59 -0600)]
i40iw: Add missing cleanup on device close

On i40iw device close, disconnect all connected QPs by moving
them to error state; and block further QPs, PDs and CQs from
being created. Additionally, make sure all resources have been
freed before deallocating the ibdev as part of the device close.

Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Add 2MB page support
Henry Orosco [Wed, 30 Nov 2016 20:57:40 +0000 (14:57 -0600)]
i40iw: Add 2MB page support

Add support to allow each independent memory region to
be configured for 2MB page size in addition to 4KB
page size.

Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Utilize physically mapped memory regions
Henry Orosco [Wed, 30 Nov 2016 20:56:14 +0000 (14:56 -0600)]
i40iw: Utilize physically mapped memory regions

Add support to use physically mapped WQ's and MR's if determined
that the OS registered user-memory for the region is physically
contiguous. This feature will eliminate the need for unnecessarily
setting up and using PBL's when not required.

Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Fix incorrect assignment of SQ head
Henry Orosco [Tue, 22 Nov 2016 15:44:20 +0000 (09:44 -0600)]
i40iw: Fix incorrect assignment of SQ head

The SQ head is incorrectly incremented when the number
of WQEs required is greater than the number available.
The fix is to use the I40IW_RING_MOV_HEAD_BY_COUNT
macro. This checks for the SQ full condition first and
only if SQ has room for the request, then we move the
head appropriately.

Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Remove variable flush_code and check to set qp->sq_flush
Henry Orosco [Thu, 10 Nov 2016 04:20:31 +0000 (22:20 -0600)]
i40iw: Remove variable flush_code and check to set qp->sq_flush

The flush_code variable in i40iw_bld_terminate_hdr() is obsolete and
the check to set qp->sq_flush is unreachable. Currently flush code is
populated in setup_term_hdr() and both SQ and RQ are flushed always
as part of the tear down flow.

Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Remove check on return from device_init_pestat()
Henry Orosco [Thu, 10 Nov 2016 03:42:26 +0000 (21:42 -0600)]
i40iw: Remove check on return from device_init_pestat()

Remove unnecessary check for return code from
device_init_pestat() and change func to void.

Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Use runtime check for IS_ENABLED(CONFIG_IPV6)
Henry Orosco [Thu, 10 Nov 2016 03:34:02 +0000 (21:34 -0600)]
i40iw: Use runtime check for IS_ENABLED(CONFIG_IPV6)

To be consistent, use the runtime check instead of
conditional compile.

Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Use actual page size
Henry Orosco [Thu, 10 Nov 2016 03:33:32 +0000 (21:33 -0600)]
i40iw: Use actual page size

In i40iw_post_send, use the actual page size instead of
encoded page size. This is to be consistent with the
rest of the file.

Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Remove NULL check for cm_node->iwdev
Henry Orosco [Thu, 10 Nov 2016 03:32:25 +0000 (21:32 -0600)]
i40iw: Remove NULL check for cm_node->iwdev

It is not necessary to check cm_node->iwdev in
i40iw_rem_ref_cm_node() as it can never be NULL after
a successful call out of i40iw_make_cm_node().

Signed-off-by: Chien Tin Tung <chien.tin.tung@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Remove checks for more than 48 bytes inline data
Henry Orosco [Thu, 10 Nov 2016 03:32:03 +0000 (21:32 -0600)]
i40iw: Remove checks for more than 48 bytes inline data

Remove dead code, which isn't executed because we
return error if the data size is greater than 48 bytes.

Inline data size greater than 48 bytes isn't supported
and the maximum WQE size is 64 bytes.

Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Query device accounts for internal rsrc
Henry Orosco [Thu, 10 Nov 2016 03:30:28 +0000 (21:30 -0600)]
i40iw: Query device accounts for internal rsrc

Some resources are consumed internally and not available to the user.
After hw is initialized, figure out how many resources are consumed
and subtract those numbers from the initial max device capability in
i40iw_query_device().

Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Optimize inline data copy
Henry Orosco [Thu, 10 Nov 2016 03:28:02 +0000 (21:28 -0600)]
i40iw: Optimize inline data copy

Use memcpy for inline data copy in sends
and writes instead of byte by byte copy.

Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Fix for LAN handler removal
Henry Orosco [Thu, 10 Nov 2016 03:27:02 +0000 (21:27 -0600)]
i40iw: Fix for LAN handler removal

If i40iw_open() fails for any reason, the LAN handler
is not being removed. Modify i40iw_deinit_device()
to always remove the handler.

Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Correct values for max_recv_sge, max_send_sge
Henry Orosco [Thu, 10 Nov 2016 03:26:39 +0000 (21:26 -0600)]
i40iw: Correct values for max_recv_sge, max_send_sge

When creating QPs, ensure init_attr->cap.max_recv_sge
is clipped to MAX_FRAG_COUNT.

Expose MAX_FRAG_COUNT for max_recv_sge and max_send_sge in
i40iw_query_qp().

Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Reviewed-By: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Use vector when creating CQs
Henry Orosco [Thu, 10 Nov 2016 03:24:48 +0000 (21:24 -0600)]
i40iw: Use vector when creating CQs

Assign each CEQ vector to a different CPU when possible, then
when creating a CQ, use the vector for the CEQ id. This
allows completion work to be distributed over multiple cores.

Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Convert page_size to encoded value
Henry Orosco [Sun, 20 Nov 2016 02:26:25 +0000 (20:26 -0600)]
i40iw: Convert page_size to encoded value

Passed in page_size was used as encoded value for writing
the WQE and passed in value was usually 4096. This was
working out since bit 0 was 0 and implies 4KB pages,
but would not work for other page sizes.

Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Set MAX IRD, MAX ORD size to max supported value
Henry Orosco [Wed, 19 Oct 2016 20:33:58 +0000 (15:33 -0500)]
i40iw: Set MAX IRD, MAX ORD size to max supported value

Set the MAX_IRD and MAX_ORD size negotiated to the maximum
supported values.

Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Remove workaround for pre-production errata
Henry Orosco [Wed, 19 Oct 2016 20:33:32 +0000 (15:33 -0500)]
i40iw: Remove workaround for pre-production errata

Pre-production silicon incorrectly truncates 4 bytes of the MPA
packet in UDP loopback case. Remove the workaround as it is no
longer necessary.

Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Enable message packing
Henry Orosco [Wed, 19 Oct 2016 20:32:53 +0000 (15:32 -0500)]
i40iw: Enable message packing

Remove the parameter to disable message packing and
always enable it.

Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoi40iw: Add Quality of Service support
Henry Orosco [Tue, 11 Oct 2016 02:12:10 +0000 (21:12 -0500)]
i40iw: Add Quality of Service support

Add support for QoS on QPs. Upon device initialization,
a map is created from user priority to queue set
handles. On QP creation, use ToS to look up the queue
set handle for use with the QP.

Signed-off-by: Faisal Latif <faisal.latif@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hns: Move HNS RoCE user vendor structures
Leon Romanovsky [Wed, 19 Oct 2016 17:13:07 +0000 (20:13 +0300)]
IB/hns: Move HNS RoCE user vendor structures

This patch moves HNS vendor's specific structures to
common UAPI folder which will be visible to all consumers.

Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hns: Fix the IB device name
Lijun Ou [Tue, 29 Nov 2016 23:10:30 +0000 (23:10 +0000)]
IB/hns: Fix the IB device name

This patch mainly fix the name for IB device in order
to match with libhns.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hns: Fix the bug when free cq
Shaobo Xu [Tue, 29 Nov 2016 23:10:29 +0000 (23:10 +0000)]
IB/hns: Fix the bug when free cq

If the resources of cq are freed while executing the user case, hardware
can not been notified in hip06 SoC. Then hardware will hold on when it
writes the cq buffer which has been released.

In order to slove this problem, RoCE driver checks the CQE counter, and
ensure that the outstanding CQE have been written. Then the cq buffer
can be released.

Signed-off-by: Shaobo Xu <xushaobo2@huawei.com>
Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hns: Delete the redundant memset operation
Wei Hu (Xavier) [Tue, 29 Nov 2016 23:10:28 +0000 (23:10 +0000)]
IB/hns: Delete the redundant memset operation

It deleted the redundant memset operation because the memory allocated
by ib_alloc_device has been set zero.

Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hns: Fix the bug of setting port mtu
Wei Hu (Xavier) [Tue, 29 Nov 2016 23:10:27 +0000 (23:10 +0000)]
IB/hns: Fix the bug of setting port mtu

In hns_roce driver, we need not call iboe_get_mtu to reduce
IB headers from effective IBoE MTU because hr_dev->caps.max_mtu
has already been reduced.

Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hns: Fix the bug when free mr
Shaobo Xu [Tue, 29 Nov 2016 23:10:26 +0000 (23:10 +0000)]
IB/hns: Fix the bug when free mr

If the resources of mr are freed while executing the user case, hardware
can not been notified in hip06 SoC. Then hardware will hold on when it
reads the payload by the PA which has been released.

In order to slove this problem, RoCE driver creates 8 reserved loopback
QPs to ensure zero wqe when free mr. When the mac address is reset, in
order to avoid loopback failure, we need to release the reserved loopback
QPs and recreate them.

Signed-off-by: Shaobo Xu <xushaobo2@huawei.com>
Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hns: Fix the bug when destroy qp
Wei Hu (Xavier) [Tue, 29 Nov 2016 23:10:25 +0000 (23:10 +0000)]
IB/hns: Fix the bug when destroy qp

If send queue is still working when qp is in reset state by modify qp
in destroy qp function, hardware will hold on and don't work in hip06
SoC. In current codes, RoCE driver check hardware pointer of sending and
hardware pointer of processing to ensure that hardware has processed all
the dbs of this qp. But while the environment of wire becomes not good,
The checking time maybe too long.

In order to solve this problem, RoCE driver created a workqueue at probe
function. If there is a timeout when checking the status of qp, driver
initialize work entry and push it into the workqueue, Work function will
finish checking and release the related resources later.

Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Dongdong Huang(Donald) <hdd.huang@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hns: Fix for Checkpatch.pl comment style errors
Salil [Wed, 23 Nov 2016 19:41:09 +0000 (19:41 +0000)]
IB/hns: Fix for Checkpatch.pl comment style errors

This patch correct the comment style errors caught by
checkpatch.pl script

Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hns: Implement the add_gid/del_gid and optimize the GIDs management
Shaobo Xu [Wed, 23 Nov 2016 19:41:08 +0000 (19:41 +0000)]
IB/hns: Implement the add_gid/del_gid and optimize the GIDs management

IB core has implemented the calculation of GIDs and the management
of GID tables, and it is now responsible to supply query function
for GIDs. So the calculation of GIDs and the management of GID
tables in the RoCE driver is redundant.

The patch is to implement the add_gid/del_gid to set the GIDs in
the RoCE driver, remove the redundant calculation and management of
GIDs in the notifier call of the net device and the inet, and
update the query_gid.

Signed-off-by: Shaobo Xu <xushaobo2@huawei.com>
Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hns: Change qpn allocation to round-robin mode.
Wei Hu (Xavier) [Wed, 23 Nov 2016 19:41:07 +0000 (19:41 +0000)]
IB/hns: Change qpn allocation to round-robin mode.

When using CM to establish connections, qp number that was freed
just now will be rejected by ib core. To fix these problem, We
change qpn allocation to round-robin mode. We added the round-robin
mode for allocating resources using bitmap. We use round-robin mode
for qp number and non round-robing mode for other resources like
cq number, pd number etc.

Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hns: Modify query info named port_num when querying RC QP
Wei Hu (Xavier) [Wed, 23 Nov 2016 19:41:06 +0000 (19:41 +0000)]
IB/hns: Modify query info named port_num when querying RC QP

This patch modified the output query info qp_attr->port_num
to fix bug in hip06.

Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hns: Modify the macro for the timeout when cmd process
Wei Hu (Xavier) [Wed, 23 Nov 2016 19:41:05 +0000 (19:41 +0000)]
IB/hns: Modify the macro for the timeout when cmd process

This patch modified the macro for the timeout when cmd is
processing as follows:
Before modification:
 enum {
HNS_ROCE_CMD_TIME_CLASS_A       = 10000,
HNS_ROCE_CMD_TIME_CLASS_B       = 10000,
HNS_ROCE_CMD_TIME_CLASS_C       = 10000,
 };
After modification:
 #define HNS_ROCE_CMD_TIMEOUT_MSECS 10000

Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hns: Fix the bug for qp state in hns_roce_v1_m_qp()
Lijun Ou [Wed, 23 Nov 2016 19:41:04 +0000 (19:41 +0000)]
IB/hns: Fix the bug for qp state in hns_roce_v1_m_qp()

In old code, the value of qp state from qpc was assigned for
attr->qp_state. The value may be an error while attr_mask &
IB_QP_STATE is zero.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hns: Modify the condition of notifying hardware loopback
Lijun Ou [Wed, 23 Nov 2016 19:41:03 +0000 (19:41 +0000)]
IB/hns: Modify the condition of notifying hardware loopback

This patch modified the condition of notifying hardware loopback.

In hip06, RoCE Engine has several ports, one QP is related
to one port. hardware only support loopback in the same port,
not in the different ports.

So, If QP related to port N, the dmac in the QP context equals
the smac of the local port N or the loop_idc is 1, we should
set loopback bit in QP context to notify hardware.

Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hns: add self loopback for CM
Lijun Ou [Wed, 23 Nov 2016 19:41:02 +0000 (19:41 +0000)]
IB/hns: add self loopback for CM

This patch mainly adds self loopback support for CM.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Peter Chen <luck.chen@huawei.com>
Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hns: Optimize the logic of allocating memory using APIs
Wei Hu (Xavier) [Wed, 23 Nov 2016 19:41:01 +0000 (19:41 +0000)]
IB/hns: Optimize the logic of allocating memory using APIs

This patch modified the logic of allocating memory using APIs in
hns RoCE driver. We used kcalloc instead of kmalloc_array and
bitmap_zero. And When kcalloc failed, call vzalloc to alloc
memory.

Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Ping Zhang <zhangping5@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hns: Add code for refreshing CQ CI using TPTR
Wei Hu (Xavier) [Wed, 23 Nov 2016 19:41:00 +0000 (19:41 +0000)]
IB/hns: Add code for refreshing CQ CI using TPTR

This patch added the code for refreshing CQ CI using TPTR in hip06
SoC.

We will send a doorbell to hardware for refreshing CQ CI when user
succeed to poll a cqe. But it will be failed if the doorbell has
been blocked. So hardware will read a special buffer called TPTR
to get the lastest CI value when the cq is almost full.

This patch support the special CI buffer as follows:
a) Alloc the memory for TPTR in the hns_roce_tptr_init function and
   free it in hns_roce_tptr_free function, these two functions will
   be called in probe function and in the remove function.
b) Add the code for computing offset(every cq need 2 bytes) and
   write the dma addr to every cq context to notice hardware in the
   function named hns_roce_v1_write_cqc.
c) Add code for mapping TPTR buffer to user space in function named
   hns_roce_mmap. The mapping distinguish TPTR and UAR of user mode
   by vm_pgoff(0: UAR, 1: TPTR, others:invaild) in hip06.
d) Alloc the code for refreshing CQ CI using TPTR in the function
   named hns_roce_v1_poll_cq.
e) Add some variable definitions to the related structure.

Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Dongdong Huang(Donald) <hdd.huang@huawei.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hns: Add the interface for querying QP1
Lijun Ou [Wed, 23 Nov 2016 19:40:59 +0000 (19:40 +0000)]
IB/hns: Add the interface for querying QP1

In old code, It only added the interface for querying non-specific
QP. This patch mainly adds an interface for querying QP1.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoinfiniband: remove WARN that is not kernel bug
Leon Romanovsky [Mon, 21 Nov 2016 17:38:20 +0000 (19:38 +0200)]
infiniband: remove WARN that is not kernel bug

On Mon, Nov 21, 2016 at 09:52:53AM -0700, Jason Gunthorpe wrote:
> On Mon, Nov 21, 2016 at 02:14:08PM +0200, Leon Romanovsky wrote:
> > >
> > > In ib_ucm_write function there is a wrong prefix:
> > >
> > > + pr_err_once("ucm_write: process %d (%s) tried to do something hinky\n",
> >
> > I did it intentionally to have the same errors for all flows.
>
> Lets actually use a good message too please?
>
>  pr_err_once("ucm_write: process %d (%s) changed security contexts after opening FD, this is not allowed.\n",
>
> Jason

>From 70f95b2d35aea42e5b97e7d27ab2f4e8effcbe67 Mon Sep 17 00:00:00 2001
From: Leon Romanovsky <leonro@mellanox.com>
Date: Mon, 21 Nov 2016 13:30:59 +0200
Subject: [PATCH rdma-next V2] IB/{core, qib}: Remove WARN that is not kernel bug

WARNINGs mean kernel bugs, in this case, they are placed
to mark programming errors and/or malicious attempts.

BUG/WARNs that are not kernel bugs hinder automated testing efforts.

Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/ipoib: Remove and fix debug prints after allocation failure
Leon Romanovsky [Thu, 3 Nov 2016 14:44:25 +0000 (16:44 +0200)]
IB/ipoib: Remove and fix debug prints after allocation failure

The prints after [k|v][m|z|c]alloc() functions are not needed,
because in case of failure, allocator will print their internal
error prints anyway.

Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/isert: Remove and fix debug prints after allocation failure
Leon Romanovsky [Thu, 3 Nov 2016 14:44:24 +0000 (16:44 +0200)]
IB/isert: Remove and fix debug prints after allocation failure

The prints after [k|v][m|z|c]alloc() functions are not needed,
because in case of failure, allocator will print their internal
error prints anyway.

Signed-off-by: Leon Romanovsky <leon@kernel.org>
Acked-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/rxe: Remove and fix debug prints after allocation failure
Leon Romanovsky [Thu, 3 Nov 2016 14:44:23 +0000 (16:44 +0200)]
IB/rxe: Remove and fix debug prints after allocation failure

The prints after [k|v][m|z|c]alloc() functions are not needed,
because in case of failure, allocator will print their internal
error prints anyway.

Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/ocrdma: Remove and fix debug prints after allocation failure
Leon Romanovsky [Thu, 3 Nov 2016 14:44:22 +0000 (16:44 +0200)]
IB/ocrdma: Remove and fix debug prints after allocation failure

The prints after [k|v][m|z|c]alloc() functions are not needed,
because in case of failure, allocator will print their internal
error prints anyway.

Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/usninc: Remove and fix debug prints after allocation failure
Leon Romanovsky [Thu, 3 Nov 2016 14:44:21 +0000 (16:44 +0200)]
IB/usninc: Remove and fix debug prints after allocation failure

This patch removes unneeded prints after allocation failure
and moves one debug print into the appropriate place.

Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/mthca: Remove debug prints after allocation failure
Leon Romanovsky [Thu, 3 Nov 2016 14:44:20 +0000 (16:44 +0200)]
IB/mthca: Remove debug prints after allocation failure

The prints after [k|v][m|z|c]alloc() functions are not needed,
because in case of failure, allocator will print their internal
error prints anyway.

Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/nes: Remove debug prints after allocation failure
Leon Romanovsky [Thu, 3 Nov 2016 14:44:19 +0000 (16:44 +0200)]
IB/nes: Remove debug prints after allocation failure

The prints after [k|v][m|z|c]alloc() functions are not needed,
because in case of failure, allocator will print their internal
error prints anyway.

Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/qib: Remove debug prints after allocation failure
Leon Romanovsky [Thu, 3 Nov 2016 14:44:18 +0000 (16:44 +0200)]
IB/qib: Remove debug prints after allocation failure

The prints after [k|v][m|z|c]alloc() functions are not needed,
because in case of failure, allocator will print their internal
error prints anyway.

Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/i40iw: Remove debug prints after allocation failure
Leon Romanovsky [Thu, 3 Nov 2016 14:44:17 +0000 (16:44 +0200)]
IB/i40iw: Remove debug prints after allocation failure

The prints after [k|v][m|z|c]alloc() functions are not needed,
because in case of failure, allocator will print their internal
error prints anyway.

Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/cxgb4: Remove debug prints after allocation failure
Leon Romanovsky [Thu, 3 Nov 2016 14:44:16 +0000 (16:44 +0200)]
IB/cxgb4: Remove debug prints after allocation failure

The prints after [k|v][m|z|c]alloc() functions are not needed,
because in case of failure, allocator will print their internal
error prints anyway.

Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/cxgb3: Remove debug prints after allocation failure
Leon Romanovsky [Thu, 3 Nov 2016 14:44:15 +0000 (16:44 +0200)]
IB/cxgb3: Remove debug prints after allocation failure

The prints after [k|v][m|z|c]alloc() functions are not needed,
because in case of failure, allocator will print their internal
error prints anyway.

Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/hfi1: Remove debug prints after allocation failure
Leon Romanovsky [Thu, 3 Nov 2016 14:44:14 +0000 (16:44 +0200)]
IB/hfi1: Remove debug prints after allocation failure

The prints after [k|v][m|z|c]alloc() functions are not needed,
because in case of failure, allocator will print their internal
error prints anyway.

Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
7 years agoIB/mlx5: Remove debug prints after allocation failure
Leon Romanovsky [Thu, 3 Nov 2016 14:44:13 +0000 (16:44 +0200)]
IB/mlx5: Remove debug prints after allocation failure

The prints after [k|v][m|z|c]alloc() functions are not needed,
because in case of failure, allocator will print their internal
error prints anyway.

Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>