Re: [PATCH RESEND 11/11] staging/rdma/hfi1: Workaround to prevent corruption during packet delivery

2015-11-09 Thread Jubin John
On Fri, Nov 06, 2015 at 07:25:31PM -0800, Greg KH wrote:
> On Fri, Nov 06, 2015 at 08:07:06PM -0500, Jubin John wrote:
> > --- a/drivers/staging/rdma/hfi1/hfi.h
> > +++ b/drivers/staging/rdma/hfi1/hfi.h
> > @@ -1084,6 +1084,10 @@ struct hfi1_devdata {
> > /* Save the enabled LCB error bits */
> > u64 lcb_err_en;
> > u8 dc_shutdown;
> > +
> > +   /* receive context tail dummy address */
> > +   volatile __le64 *rcvhdrtail_dummy_kvaddr;
> 
> There's no way that volatile here is actually correct, please fix.
> 
You're right. Will fix in v2.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RESEND 10/11] staging/rdma/hfi1: Eliminate WARN_ON when VL is invalid

2015-11-09 Thread Jubin John
> > -   if (WARN_ON(vl > 8))
> > -   return NULL;
> > +   /* NOTE This should only happen if SC->VL changed after the initial
> > +*  checks on the QP/AH
> > +*  Default will return engine 0 below
> > +*/
> > +   if (unlikely(vl >= num_vls)) {
> 
> Can you prove that unlikely() makes a measured difference here?  If not,
> please remove it.  If you can, please provide the proof in the changelog
> when you resend it.

Unfortunately, I can't prove this so will remove in v2.

Thanks,
Jubin John
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 0/2] staging/rdma/hfi1: Miscellaneous Fixes

2015-11-09 Thread Jubin John
Updated these 2 patches based on feedback received.

Changes in v2:
- Removed volatile for receive context tail dummy address
- Removed unlikely() in sdma_select_engine_vl()

Ira Weiny (1):
  staging/rdma/hfi1: Eliminate WARN_ON when VL is invalid

Mark F. Brown (1):
  staging/rdma/hfi1: Workaround to prevent corruption during packet
delivery

 drivers/staging/rdma/hfi1/chip.c |   18 +++---
 drivers/staging/rdma/hfi1/hfi.h  |4 
 drivers/staging/rdma/hfi1/init.c |   28 
 drivers/staging/rdma/hfi1/sdma.c |   12 ++--
 4 files changed, 57 insertions(+), 5 deletions(-)

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 2/2] staging/rdma/hfi1: Eliminate WARN_ON when VL is invalid

2015-11-09 Thread Jubin John
From: Ira Weiny 

sdma_select_engine_vl only needs to protect itself from an invalid VL.
Something higher up the stack should be warning the user when they try
to use an SL which maps to an invalid VL.

Reviewed-by: Dean Luick 
Reviewed-by: Mike Marciniszyn 
Reviewed-by: Kaike Wan 
Signed-off-by: Ira Weiny 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/sdma.c |   12 ++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/sdma.c b/drivers/staging/rdma/hfi1/sdma.c
index 2a1da21..d7982a7 100644
--- a/drivers/staging/rdma/hfi1/sdma.c
+++ b/drivers/staging/rdma/hfi1/sdma.c
@@ -777,8 +777,14 @@ struct sdma_engine *sdma_select_engine_vl(
struct sdma_map_elem *e;
struct sdma_engine *rval;
 
-   if (WARN_ON(vl > 8))
-   return NULL;
+   /* NOTE This should only happen if SC->VL changed after the initial
+*  checks on the QP/AH
+*  Default will return engine 0 below
+*/
+   if (vl >= num_vls) {
+   rval = NULL;
+   goto done;
+   }
 
rcu_read_lock();
m = rcu_dereference(dd->sdma_map);
@@ -790,6 +796,8 @@ struct sdma_engine *sdma_select_engine_vl(
rval = e->sde[selector & e->mask];
rcu_read_unlock();
 
+done:
+   rval =  !rval ? &dd->per_sdma[0] : rval;
trace_hfi1_sdma_engine_select(dd, selector, vl, rval->this_idx);
return rval;
 }
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 1/2] staging/rdma/hfi1: Workaround to prevent corruption during packet delivery

2015-11-09 Thread Jubin John
From: Mark F. Brown 

Disabling one receive context when RX_DMA is receiving a packet can cause
incorrect packet delivery for a subsequent packet on another receive
context.

This is resolved by doing the following:
1. Programming dummy tail address for every receive context
   before enabling it
2. While deallocating receive context resetting tail address
   to dummy address
3. Leaving the dummy address in when disabling tail update
4. When disabling receive context leaving tail update enabled

Reviewed-by: Dennis Dalessandro 
Reviewed-by: Mike Marciniszyn 
Reviewed-by: Mitko Haralanov 
Signed-off-by: Mark F. Brown 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c |   18 +++---
 drivers/staging/rdma/hfi1/hfi.h  |4 
 drivers/staging/rdma/hfi1/init.c |   28 
 3 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index e489819..3c3ba52 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -7753,6 +7753,17 @@ void hfi1_rcvctrl(struct hfi1_devdata *dd, unsigned int 
op, int ctxt)
}
if (op & HFI1_RCVCTRL_CTXT_DIS) {
write_csr(dd, RCV_VL15, 0);
+   /*
+* When receive context is being disabled turn on tail
+* update with a dummy tail address and then disable
+* receive context.
+*/
+   if (dd->rcvhdrtail_dummy_physaddr) {
+   write_kctxt_csr(dd, ctxt, RCV_HDR_TAIL_ADDR,
+   dd->rcvhdrtail_dummy_physaddr);
+   rcvctrl |= RCV_CTXT_CTRL_TAIL_UPD_SMASK;
+   }
+
rcvctrl &= ~RCV_CTXT_CTRL_ENABLE_SMASK;
}
if (op & HFI1_RCVCTRL_INTRAVAIL_ENB)
@@ -7822,10 +7833,11 @@ void hfi1_rcvctrl(struct hfi1_devdata *dd, unsigned int 
op, int ctxt)
if (op & (HFI1_RCVCTRL_TAILUPD_DIS | HFI1_RCVCTRL_CTXT_DIS))
/*
 * If the context has been disabled and the Tail Update has
-* been cleared, clear the RCV_HDR_TAIL_ADDR CSR so
-* it doesn't contain an address that is invalid.
+* been cleared, set the RCV_HDR_TAIL_ADDR CSR to dummy address
+* so it doesn't contain an address that is invalid.
 */
-   write_kctxt_csr(dd, ctxt, RCV_HDR_TAIL_ADDR, 0);
+   write_kctxt_csr(dd, ctxt, RCV_HDR_TAIL_ADDR,
+   dd->rcvhdrtail_dummy_physaddr);
 }
 
 u32 hfi1_read_cntrs(struct hfi1_devdata *dd, loff_t pos, char **namep,
diff --git a/drivers/staging/rdma/hfi1/hfi.h b/drivers/staging/rdma/hfi1/hfi.h
index 190f7a2..10b227c 100644
--- a/drivers/staging/rdma/hfi1/hfi.h
+++ b/drivers/staging/rdma/hfi1/hfi.h
@@ -1084,6 +1084,10 @@ struct hfi1_devdata {
/* Save the enabled LCB error bits */
u64 lcb_err_en;
u8 dc_shutdown;
+
+   /* receive context tail dummy address */
+   __le64 *rcvhdrtail_dummy_kvaddr;
+   dma_addr_t rcvhdrtail_dummy_physaddr;
 };
 
 /* 8051 firmware version helper */
diff --git a/drivers/staging/rdma/hfi1/init.c b/drivers/staging/rdma/hfi1/init.c
index 8666f3a..3879d80 100644
--- a/drivers/staging/rdma/hfi1/init.c
+++ b/drivers/staging/rdma/hfi1/init.c
@@ -691,6 +691,18 @@ int hfi1_init(struct hfi1_devdata *dd, int reinit)
if (ret)
goto done;
 
+   /* allocate dummy tail memory for all receive contexts */
+   dd->rcvhdrtail_dummy_kvaddr = dma_zalloc_coherent(
+   &dd->pcidev->dev, sizeof(u64),
+   &dd->rcvhdrtail_dummy_physaddr,
+   GFP_KERNEL);
+
+   if (!dd->rcvhdrtail_dummy_kvaddr) {
+   dd_dev_err(dd, "cannot allocate dummy tail memory\n");
+   ret = -ENOMEM;
+   goto done;
+   }
+
/* dd->rcd can be NULL if early initialization failed */
for (i = 0; dd->rcd && i < dd->first_user_ctxt; ++i) {
/*
@@ -1266,6 +1278,14 @@ static void cleanup_device_data(struct hfi1_devdata *dd)
tmp = dd->rcd;
dd->rcd = NULL;
spin_unlock_irqrestore(&dd->uctxt_lock, flags);
+
+   if (dd->rcvhdrtail_dummy_kvaddr) {
+   dma_free_coherent(&dd->pcidev->dev, sizeof(u64),
+ (void *)dd->rcvhdrtail_dummy_kvaddr,
+ dd->rcvhdrtail_dummy_physaddr);
+ dd->rcvhdrtail_dummy_kvaddr = NULL;
+   }
+
for (ctxt = 0; tmp && ctxt < dd->num_rcv_contexts; ctxt++) {
struct hfi1_ctxtdata *rcd = tmp[ctxt];
 
@@ -1521,6 +1541,14 @@ int hfi1_create_rcvhdrq(struct hfi1_devdata *dd, struct 
hfi1_ctxtdata *rcd)
reg = (dd->rcvhd

[PATCH 01/13] staging/rdma/hfi1: Use BIT macro

2015-11-10 Thread Jubin John
This patch fixes the checkpatch issue:
CHECK: Prefer using the BIT macro

Reviewed-by: Dean Luick 
Reviewed-by: Ira Weiny 
Reviewed-by: Mike Marciniszyn 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.h   |   48 ++--
 drivers/staging/rdma/hfi1/common.h |4 +-
 drivers/staging/rdma/hfi1/diag.c   |4 +-
 drivers/staging/rdma/hfi1/hfi.h|   22 
 drivers/staging/rdma/hfi1/init.c   |2 +-
 drivers/staging/rdma/hfi1/mad.c|4 +-
 drivers/staging/rdma/hfi1/qp.h |2 +-
 drivers/staging/rdma/hfi1/qsfp.h   |   10 +++---
 drivers/staging/rdma/hfi1/sdma.c   |8 +++---
 drivers/staging/rdma/hfi1/verbs.h  |6 ++--
 10 files changed, 55 insertions(+), 55 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.h b/drivers/staging/rdma/hfi1/chip.h
index ebf9041..ccfaf6d 100644
--- a/drivers/staging/rdma/hfi1/chip.h
+++ b/drivers/staging/rdma/hfi1/chip.h
@@ -241,18 +241,18 @@
 #define HCMD_SUCCESS 2
 
 /* DC_DC8051_DBG_ERR_INFO_SET_BY_8051.ERROR - error flags */
-#define SPICO_ROM_FAILED   (1 <<  0)
-#define UNKNOWN_FRAME  (1 <<  1)
-#define TARGET_BER_NOT_MET (1 <<  2)
-#define FAILED_SERDES_INTERNAL_LOOPBACK (1 <<  3)
-#define FAILED_SERDES_INIT (1 <<  4)
-#define FAILED_LNI_POLLING (1 <<  5)
-#define FAILED_LNI_DEBOUNCE(1 <<  6)
-#define FAILED_LNI_ESTBCOMM(1 <<  7)
-#define FAILED_LNI_OPTEQ   (1 <<  8)
-#define FAILED_LNI_VERIFY_CAP1 (1 <<  9)
-#define FAILED_LNI_VERIFY_CAP2 (1 << 10)
-#define FAILED_LNI_CONFIGLT(1 << 11)
+#define SPICO_ROM_FAILED   BIT(0)
+#define UNKNOWN_FRAME  BIT(1)
+#define TARGET_BER_NOT_MET BIT(2)
+#define FAILED_SERDES_INTERNAL_LOOPBACKBIT(3)
+#define FAILED_SERDES_INIT BIT(4)
+#define FAILED_LNI_POLLING BIT(5)
+#define FAILED_LNI_DEBOUNCEBIT(6)
+#define FAILED_LNI_ESTBCOMMBIT(7)
+#define FAILED_LNI_OPTEQ   BIT(8)
+#define FAILED_LNI_VERIFY_CAP1 BIT(9)
+#define FAILED_LNI_VERIFY_CAP2 BIT(10)
+#define FAILED_LNI_CONFIGLTBIT(11)
 
 #define FAILED_LNI (FAILED_LNI_POLLING | FAILED_LNI_DEBOUNCE \
| FAILED_LNI_ESTBCOMM | FAILED_LNI_OPTEQ \
@@ -261,16 +261,16 @@
| FAILED_LNI_CONFIGLT)
 
 /* DC_DC8051_DBG_ERR_INFO_SET_BY_8051.HOST_MSG - host message flags */
-#define HOST_REQ_DONE (1 << 0)
-#define BC_PWR_MGM_MSG(1 << 1)
-#define BC_SMA_MSG(1 << 2)
-#define BC_BCC_UNKOWN_MSG (1 << 3)
-#define BC_IDLE_UNKNOWN_MSG   (1 << 4)
-#define EXT_DEVICE_CFG_REQ(1 << 5)
-#define VERIFY_CAP_FRAME  (1 << 6)
-#define LINKUP_ACHIEVED   (1 << 7)
-#define LINK_GOING_DOWN   (1 << 8)
-#define LINK_WIDTH_DOWNGRADED  (1 << 9)
+#define HOST_REQ_DONE  BIT(0)
+#define BC_PWR_MGM_MSG BIT(1)
+#define BC_SMA_MSG BIT(2)
+#define BC_BCC_UNKNOWN_MSG BIT(3)
+#define BC_IDLE_UNKNOWN_MSGBIT(4)
+#define EXT_DEVICE_CFG_REQ BIT(5)
+#define VERIFY_CAP_FRAME   BIT(6)
+#define LINKUP_ACHIEVEDBIT(7)
+#define LINK_GOING_DOWNBIT(8)
+#define LINK_WIDTH_DOWNGRADED  BIT(9)
 
 /* DC_DC8051_CFG_EXT_DEV_1.REQ_TYPE - 8051 host requests */
 #define HREQ_LOAD_CONFIG   0x01
@@ -334,14 +334,14 @@
  * the CSR fields hold multiples of this value.
  */
 #define RCV_SHIFT 3
-#define RCV_INCREMENT (1 << RCV_SHIFT)
+#define RCV_INCREMENT BIT(RCV_SHIFT)
 
 /*
  * Receive header queue entry increment - the CSR holds multiples of
  * this value.
  */
 #define HDRQ_SIZE_SHIFT 5
-#define HDRQ_INCREMENT (1 << HDRQ_SIZE_SHIFT)
+#define HDRQ_INCREMENT BIT(HDRQ_SIZE_SHIFT)
 
 /*
  * Freeze handling flags
diff --git a/drivers/staging/rdma/hfi1/common.h 
b/drivers/staging/rdma/hfi1/common.h
index 5e20323..e7616fb 100644
--- a/drivers/staging/rdma/hfi1/common.h
+++ b/drivers/staging/rdma/hfi1/common.h
@@ -348,10 +348,10 @@ struct hfi1_message_header {
 #define HFI1_QPN_MASK 0xFF
 #define HFI1_FECN_SHIFT 31
 #define HFI1_FECN_MASK 1
-#define HFI1_FECN_SMASK (1 << HFI1_FECN_SHIFT)
+#define HFI1_FECN_SMASK BIT(HFI1_FECN_SHIFT)
 #define HFI1_BECN_SHIFT 30
 #define HFI1_BECN_MASK 1
-#define HFI1_BECN_SMASK (1 << HFI1_BECN_SHIFT)
+#define HFI1_BECN_SMASK BIT(HFI1_BECN_SHIFT)
 #define HFI1_MULTICAST_LID_BASE 0xC000
 
 static inline __u64 rhf_to_cpu(const __le32 *rbuf)
diff --git a/drivers/staging/rdma/hfi1/diag.c b/drivers/staging/rdma/hfi1/diag.c
index 88414d7..076a419 100644
--- a/drivers/staging/rdma/hfi1/diag.c
+++ b/drivers/staging/rdma/hfi1/diag.c
@@ -78,8 +78,8 @@
hfi1_cdbg(SNOOP, fmt, ##__VA_ARGS__)
 
 /* Snoop option mask */
-#define S

[PATCH 08/13] staging/rdma/hfi1: change krcvqs module parameter type from byte to uint

2015-11-10 Thread Jubin John
From: Mark F. Brown 

The krcvqs parameter is displayed incorrectly in sysfs.
The workaround is to set the param type as uint.

Reviewed-by: Mike Marciniszyn 
Reviewed-by: Mitko Haralanov 
Signed-off-by: Mark F. Brown 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/hfi.h  |2 +-
 drivers/staging/rdma/hfi1/init.c |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/hfi.h b/drivers/staging/rdma/hfi1/hfi.h
index fa2a284..a17fc87 100644
--- a/drivers/staging/rdma/hfi1/hfi.h
+++ b/drivers/staging/rdma/hfi1/hfi.h
@@ -1651,7 +1651,7 @@ extern unsigned int hfi1_cu;
 extern unsigned int user_credit_return_threshold;
 extern uint num_rcv_contexts;
 extern unsigned n_krcvqs;
-extern u8 krcvqs[];
+extern uint krcvqs[];
 extern int krcvqsset;
 extern uint kdeth_qp;
 extern uint loopback;
diff --git a/drivers/staging/rdma/hfi1/init.c b/drivers/staging/rdma/hfi1/init.c
index 0385a17..e65b999 100644
--- a/drivers/staging/rdma/hfi1/init.c
+++ b/drivers/staging/rdma/hfi1/init.c
@@ -86,9 +86,9 @@ module_param_named(num_rcv_contexts, num_rcv_contexts, uint, 
S_IRUGO);
 MODULE_PARM_DESC(
num_rcv_contexts, "Set max number of user receive contexts to use");
 
-u8 krcvqs[RXE_NUM_DATA_VL];
+uint krcvqs[RXE_NUM_DATA_VL];
 int krcvqsset;
-module_param_array(krcvqs, byte, &krcvqsset, S_IRUGO);
+module_param_array(krcvqs, uint, &krcvqsset, S_IRUGO);
 MODULE_PARM_DESC(krcvqs, "Array of the number of kernel receive queues by VL");
 
 /* computed based on above array */
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/13] staging/rdma/hfi1: Change default krcvqs

2015-11-10 Thread Jubin John
Change the default number of krcvqs to number of numa nodes + 1
based on the performance data collected.

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 75416d8..aac47ad 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -9174,7 +9174,7 @@ static int set_up_context_variables(struct hfi1_devdata 
*dd)
if (n_krcvqs)
num_kernel_contexts = n_krcvqs + MIN_KERNEL_KCTXTS;
else
-   num_kernel_contexts = num_online_nodes();
+   num_kernel_contexts = num_online_nodes() + 1;
num_kernel_contexts =
max_t(int, MIN_KERNEL_KCTXTS, num_kernel_contexts);
/*
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/13] staging/rdma/hfi1: Fix downgrade race

2015-11-10 Thread Jubin John
From: Dean Luick 

A link downgrade can race with link up. Avoid the race
in two ways. First, by having the downgrade application logic
take the link state mutex for all of its checking. Second, by
waiting for the link to move out of the going up state.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c |   31 ---
 1 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index e489819..16302d6 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -3907,18 +3907,32 @@ void handle_verify_cap(struct work_struct *work)
  */
 void apply_link_downgrade_policy(struct hfi1_pportdata *ppd, int 
refresh_widths)
 {
-   int skip = 1;
int do_bounce = 0;
-   u16 lwde = ppd->link_width_downgrade_enabled;
+   int tries;
+   u16 lwde;
u16 tx, rx;
 
+   /* use the hls lock to avoid a race with actual link up */
+   tries = 0;
+retry:
mutex_lock(&ppd->hls_lock);
/* only apply if the link is up */
-   if (ppd->host_link_state & HLS_UP)
-   skip = 0;
-   mutex_unlock(&ppd->hls_lock);
-   if (skip)
-   return;
+   if (!(ppd->host_link_state & HLS_UP)) {
+   /* still going up..wait and retry */
+   if (ppd->host_link_state & HLS_GOING_UP) {
+   if (++tries < 1000) {
+   mutex_unlock(&ppd->hls_lock);
+   usleep_range(100, 120); /* arbitrary */
+   goto retry;
+   }
+   dd_dev_err(ppd->dd,
+  "%s: giving up waiting for link state 
change\n",
+  __func__);
+   }
+   goto done;
+   }
+
+   lwde = ppd->link_width_downgrade_enabled;
 
if (refresh_widths) {
get_link_widths(ppd->dd, &tx, &rx);
@@ -3956,6 +3970,9 @@ void apply_link_downgrade_policy(struct hfi1_pportdata 
*ppd, int refresh_widths)
do_bounce = 1;
}
 
+done:
+   mutex_unlock(&ppd->hls_lock);
+
if (do_bounce) {
set_link_down_reason(ppd, OPA_LINKDOWN_REASON_WIDTH_POLICY, 0,
  OPA_LINKDOWN_REASON_WIDTH_POLICY);
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/13] staging/rdma/hfi1: Add space between concatenated string elements

2015-11-10 Thread Jubin John
Space between concantenated string elements is more human
readable and fixes the checkpatch issue:
CHECK: Concatenated strings should use spaces between elements

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c   |   10 +-
 drivers/staging/rdma/hfi1/driver.c |2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 9db141d..eb281e9 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -8865,8 +8865,8 @@ static int request_intx_irq(struct hfi1_devdata *dd)
 {
int ret;
 
-   snprintf(dd->intx_name, sizeof(dd->intx_name), DRIVER_NAME"_%d",
-   dd->unit);
+   snprintf(dd->intx_name, sizeof(dd->intx_name), DRIVER_NAME "_%d",
+dd->unit);
ret = request_irq(dd->pcidev->irq, general_interrupt,
  IRQF_SHARED, dd->intx_name, dd);
if (ret)
@@ -8968,7 +8968,7 @@ static int request_msix_irqs(struct hfi1_devdata *dd)
handler = general_interrupt;
arg = dd;
snprintf(me->name, sizeof(me->name),
-   DRIVER_NAME"_%d", dd->unit);
+DRIVER_NAME "_%d", dd->unit);
err_info = "general";
} else if (first_sdma <= i && i < last_sdma) {
idx = i - first_sdma;
@@ -8976,7 +8976,7 @@ static int request_msix_irqs(struct hfi1_devdata *dd)
handler = sdma_interrupt;
arg = sde;
snprintf(me->name, sizeof(me->name),
-   DRIVER_NAME"_%d sdma%d", dd->unit, idx);
+DRIVER_NAME "_%d sdma%d", dd->unit, idx);
err_info = "sdma";
remap_sdma_interrupts(dd, idx, i);
} else if (first_rx <= i && i < last_rx) {
@@ -8996,7 +8996,7 @@ static int request_msix_irqs(struct hfi1_devdata *dd)
thread = receive_context_thread;
arg = rcd;
snprintf(me->name, sizeof(me->name),
-   DRIVER_NAME"_%d kctxt%d", dd->unit, idx);
+DRIVER_NAME "_%d kctxt%d", dd->unit, idx);
err_info = "receive context";
remap_receive_available_interrupt(dd, idx, i);
} else {
diff --git a/drivers/staging/rdma/hfi1/driver.c 
b/drivers/staging/rdma/hfi1/driver.c
index ce69141..e0cc196 100644
--- a/drivers/staging/rdma/hfi1/driver.c
+++ b/drivers/staging/rdma/hfi1/driver.c
@@ -158,7 +158,7 @@ const char *get_unit_name(int unit)
 {
static char iname[16];
 
-   snprintf(iname, sizeof(iname), DRIVER_NAME"_%u", unit);
+   snprintf(iname, sizeof(iname), DRIVER_NAME "_%u", unit);
return iname;
 }
 
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/13] staging/rdma/hfi1: Move s_sde to the read mostly portion of the hfi1_qp structure

2015-11-10 Thread Jubin John
From: Harish Chegondi 

This would reduce L2 cache misses on s_sde in the _hfi1_schedule_send
function when invoked from post_send thereby improving performance of
post_send.

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Harish Chegondi 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/verbs.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/verbs.h 
b/drivers/staging/rdma/hfi1/verbs.h
index 600bd1b..638094d 100644
--- a/drivers/staging/rdma/hfi1/verbs.h
+++ b/drivers/staging/rdma/hfi1/verbs.h
@@ -441,6 +441,7 @@ struct hfi1_qp {
struct hfi1_swqe *s_wq;  /* send work queue */
struct hfi1_mmap_info *ip;
struct ahg_ib_header *s_hdr; /* next packet header to send */
+   struct sdma_engine *s_sde; /* current sde */
u8 s_sc;/* SC[0..4] for next packet */
unsigned long timeout_jiffies;  /* computed from timeout */
 
@@ -504,7 +505,6 @@ struct hfi1_qp {
struct hfi1_swqe *s_wqe;
struct hfi1_sge_state s_sge; /* current send request data */
struct hfi1_mregion *s_rdma_mr;
-   struct sdma_engine *s_sde; /* current sde */
u32 s_cur_size; /* size of send packet in bytes */
u32 s_len;  /* total length of s_sge */
u32 s_rdma_read_len;/* total length of s_rdma_read_sge */
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/13] staging/rdma/hfi1: adding per SDMA engine stats to hfistats

2015-11-10 Thread Jubin John
From: Vennila Megavannan 

Added the following per sdma engine stats:
  - SendDmaDescFetchedCnt
  - software maintained count of SDMA interrupts
 (SDmaInt, SDmaIdleInt, SDmaProgressInt)
  - software maintained counts of SDMA error cases

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Mike Marciniszyn 
Signed-off-by: Vennila Megavannan 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c   |  110 +++-
 drivers/staging/rdma/hfi1/chip.h   |5 +
 drivers/staging/rdma/hfi1/chip_registers.h |1 +
 drivers/staging/rdma/hfi1/hfi.h|1 +
 drivers/staging/rdma/hfi1/sdma.c   |9 ++-
 drivers/staging/rdma/hfi1/sdma.h   |7 ++
 6 files changed, 129 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index aac47ad..5bd4841 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -1296,10 +1296,58 @@ static u64 dev_access_u32_csr(const struct cntr_entry 
*entry,
void *context, int vl, int mode, u64 data)
 {
struct hfi1_devdata *dd = context;
+   u64 csr = entry->csr;
 
-   if (vl != CNTR_INVALID_VL)
-   return 0;
-   return read_write_csr(dd, entry->csr, mode, data);
+   if (entry->flags & CNTR_SDMA) {
+   if (vl == CNTR_INVALID_VL)
+   return 0;
+   csr += 0x100 * vl;
+   } else {
+   if (vl != CNTR_INVALID_VL)
+   return 0;
+   }
+   return read_write_csr(dd, csr, mode, data);
+}
+
+static u64 access_sde_err_cnt(const struct cntr_entry *entry,
+ void *context, int idx, int mode, u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   if (dd->per_sdma && idx < dd->num_sdma)
+   return dd->per_sdma[idx].err_cnt;
+   return 0;
+}
+
+static u64 access_sde_int_cnt(const struct cntr_entry *entry,
+ void *context, int idx, int mode, u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   if (dd->per_sdma && idx < dd->num_sdma)
+   return dd->per_sdma[idx].sdma_int_cnt;
+   return 0;
+}
+
+static u64 access_sde_idle_int_cnt(const struct cntr_entry *entry,
+  void *context, int idx, int mode, u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   if (dd->per_sdma && idx < dd->num_sdma)
+   return dd->per_sdma[idx].idle_int_cnt;
+   return 0;
+}
+
+static u64 access_sde_progress_int_cnt(const struct cntr_entry *entry,
+  void *context, int idx, int mode,
+  u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   if (dd->per_sdma && idx < dd->num_sdma)
+   return dd->per_sdma[idx].progress_int_cnt;
+   return 0;
 }
 
 static u64 dev_access_u64_csr(const struct cntr_entry *entry, void *context,
@@ -1728,6 +1776,22 @@ static struct cntr_entry dev_cntrs[DEV_CNTR_LAST] = {
access_sw_kmem_wait),
 [C_SW_SEND_SCHED] = CNTR_ELEM("SendSched", 0, 0, CNTR_NORMAL,
access_sw_send_schedule),
+[C_SDMA_DESC_FETCHED_CNT] = CNTR_ELEM("SDEDscFdCn",
+ SEND_DMA_DESC_FETCHED_CNT, 0,
+ CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
+ dev_access_u32_csr),
+[C_SDMA_INT_CNT] = CNTR_ELEM("SDMAInt", 0, 0,
+CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
+access_sde_int_cnt),
+[C_SDMA_ERR_CNT] = CNTR_ELEM("SDMAErrCt", 0, 0,
+CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
+access_sde_err_cnt),
+[C_SDMA_IDLE_INT_CNT] = CNTR_ELEM("SDMAIdInt", 0, 0,
+ CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
+ access_sde_idle_int_cnt),
+[C_SDMA_PROGRESS_INT_CNT] = CNTR_ELEM("SDMAPrIntCn", 0, 0,
+ CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
+ access_sde_progress_int_cnt)
 };
 
 static struct cntr_entry port_cntrs[PORT_CNTR_LAST] = {
@@ -2520,6 +2584,7 @@ static void handle_sdma_eng_err(struct hfi1_devdata *dd,
dd_dev_err(sde->dd, "CONFIG SDMA(%u) source: %u status 0x%llx\n",
   sde->this_idx, source, (unsigned long long)status);
 #endif
+   sde->err_cnt++;
sdma_engine_error(sde, status);
 }
 
@@ -7885,6 +7950,20 @@ u32 hfi1_read_cntrs(struct hfi1_devdata *dd, loff_t pos, 

[PATCH 12/13] staging/rdma/hfi1: Read EFI variable for device description

2015-11-10 Thread Jubin John
From: Dean Luick 

Read an EFI variable for the device description.  Create the
infrastructure for additional variable reads.

Reviewed-by: Easwar Hariharan 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/Makefile |2 +-
 drivers/staging/rdma/hfi1/chip.c   |   38 ++--
 drivers/staging/rdma/hfi1/efivar.c |  176 
 drivers/staging/rdma/hfi1/efivar.h |   60 
 4 files changed, 267 insertions(+), 9 deletions(-)
 create mode 100644 drivers/staging/rdma/hfi1/efivar.c
 create mode 100644 drivers/staging/rdma/hfi1/efivar.h

diff --git a/drivers/staging/rdma/hfi1/Makefile 
b/drivers/staging/rdma/hfi1/Makefile
index 2e5daa6..68c5a31 100644
--- a/drivers/staging/rdma/hfi1/Makefile
+++ b/drivers/staging/rdma/hfi1/Makefile
@@ -7,7 +7,7 @@
 #
 obj-$(CONFIG_INFINIBAND_HFI1) += hfi1.o
 
-hfi1-y := chip.o cq.o device.o diag.o dma.o driver.o eprom.o file_ops.o 
firmware.o \
+hfi1-y := chip.o cq.o device.o diag.o dma.o driver.o efivar.o eprom.o 
file_ops.o firmware.o \
init.o intr.o keys.o mad.o mmap.o mr.o pcie.o pio.o pio_copy.o \
qp.o qsfp.o rc.o ruc.o sdma.o srq.o sysfs.o trace.o twsi.o \
uc.o ud.o user_pages.o user_sdma.o verbs_mcast.o verbs.o
diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 15ae4c9..dcaa61c 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -63,6 +63,7 @@
 #include "pio.h"
 #include "sdma.h"
 #include "eprom.h"
+#include "efivar.h"
 
 #define NUM_IB_PORTS 1
 
@@ -10524,6 +10525,32 @@ static void asic_should_init(struct hfi1_devdata *dd)
spin_unlock_irqrestore(&hfi1_devs_lock, flags);
 }
 
+/*
+ * Set dd->boardname.  Use a generic name if a name is not returned from
+ * EFI variable space.
+ *
+ * Return 0 on success, -ENOMEM if space could not be allocated.
+ */
+static int obtain_boardname(struct hfi1_devdata *dd)
+{
+   /* generic board description */
+   const char generic[] =
+   "Intel Omni-Path Host Fabric Interface Adapter 100 Series";
+   unsigned long size;
+   int ret;
+
+   ret = read_hfi1_efi_var(dd, "description", &size,
+   (void **)&dd->boardname);
+   if (ret) {
+   dd_dev_err(dd, "Board description not found\n");
+   /* use generic description */
+   dd->boardname = kstrdup(generic, GFP_KERNEL);
+   if (!dd->boardname)
+   return -ENOMEM;
+   }
+   return 0;
+}
+
 /**
  * Allocate and initialize the device structure for the hfi.
  * @dev: the pci_dev for hfi1_ib device
@@ -10721,18 +10748,13 @@ struct hfi1_devdata *hfi1_init_dd(struct pci_dev 
*pdev,
 
parse_platform_config(dd);
 
-   /* add board names as they are defined */
-   dd->boardname = kmalloc(64, GFP_KERNEL);
-   if (!dd->boardname)
+   ret = obtain_boardname(dd);
+   if (ret)
goto bail_cleanup;
-   snprintf(dd->boardname, 64, "Board ID 0x%llx",
-dd->revision >> CCE_REVISION_BOARD_ID_LOWER_NIBBLE_SHIFT
-   & CCE_REVISION_BOARD_ID_LOWER_NIBBLE_MASK);
 
snprintf(dd->boardversion, BOARD_VERS_MAX,
-"ChipABI %u.%u, %s, ChipRev %u.%u, SW Compat %llu\n",
+"ChipABI %u.%u, ChipRev %u.%u, SW Compat %llu\n",
 HFI1_CHIP_VERS_MAJ, HFI1_CHIP_VERS_MIN,
-dd->boardname,
 (u32)dd->majrev,
 (u32)dd->minrev,
 (dd->revision >> CCE_REVISION_SW_SHIFT)
diff --git a/drivers/staging/rdma/hfi1/efivar.c 
b/drivers/staging/rdma/hfi1/efivar.c
new file mode 100644
index 000..476391d
--- /dev/null
+++ b/drivers/staging/rdma/hfi1/efivar.c
@@ -0,0 +1,176 @@
+/*
+ *
+ * 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
+ *
+ * Copyright(c) 2015 Intel Corporation.
+ *
+ * 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
+ *
+ * Copyright(c) 2015 Intel Corporation.
+ *
+ * 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 th

[PATCH 11/13] staging/rdma/hfi1: Remove unneeded variable index

2015-11-10 Thread Jubin John
From: Dean Luick 

The variable "index" increments the same as dd->ndevcntrs.
Just use the later.  Remove uneeded usage of "index" in the
fill loop - it is not used there or later in the function.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c |   19 +++
 1 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 5bd4841..15ae4c9 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -8327,7 +8327,7 @@ mod_timer(&dd->synth_stats_timer, jiffies + HZ * 
SYNTH_CNT_TIME);
 #define C_MAX_NAME 13 /* 12 chars + one for /0 */
 static int init_cntrs(struct hfi1_devdata *dd)
 {
-   int i, rcv_ctxts, index, j;
+   int i, rcv_ctxts, j;
size_t sz;
char *p;
char name[C_MAX_NAME];
@@ -8344,7 +8344,6 @@ static int init_cntrs(struct hfi1_devdata *dd)
/* size names and determine how many we have*/
dd->ndevcntrs = 0;
sz = 0;
-   index = 0;
 
for (i = 0; i < DEV_CNTR_LAST; i++) {
hfi1_dbg_early("Init cntr %s\n", dev_cntrs[i].name);
@@ -8355,7 +8354,7 @@ static int init_cntrs(struct hfi1_devdata *dd)
 
if (dev_cntrs[i].flags & CNTR_VL) {
hfi1_dbg_early("\tProcessing VL cntr\n");
-   dev_cntrs[i].offset = index;
+   dev_cntrs[i].offset = dd->ndevcntrs;
for (j = 0; j < C_VL_COUNT; j++) {
memset(name, '\0', C_MAX_NAME);
snprintf(name, C_MAX_NAME, "%s%d",
@@ -8365,13 +8364,12 @@ static int init_cntrs(struct hfi1_devdata *dd)
sz++;
hfi1_dbg_early("\t\t%s\n", name);
dd->ndevcntrs++;
-   index++;
}
} else if (dev_cntrs[i].flags & CNTR_SDMA) {
hfi1_dbg_early(
   "\tProcessing per SDE counters chip 
enginers %u\n",
   dd->chip_sdma_engines);
-   dev_cntrs[i].offset = index;
+   dev_cntrs[i].offset = dd->ndevcntrs;
for (j = 0; j < dd->chip_sdma_engines; j++) {
memset(name, '\0', C_MAX_NAME);
snprintf(name, C_MAX_NAME, "%s%d",
@@ -8380,24 +8378,22 @@ static int init_cntrs(struct hfi1_devdata *dd)
sz++;
hfi1_dbg_early("\t\t%s\n", name);
dd->ndevcntrs++;
-   index++;
}
} else {
/* +1 for newline  */
sz += strlen(dev_cntrs[i].name) + 1;
+   dev_cntrs[i].offset = dd->ndevcntrs;
dd->ndevcntrs++;
-   dev_cntrs[i].offset = index;
-   index++;
hfi1_dbg_early("\tAdding %s\n", dev_cntrs[i].name);
}
}
 
/* allocate space for the counter values */
-   dd->cntrs = kcalloc(index, sizeof(u64), GFP_KERNEL);
+   dd->cntrs = kcalloc(dd->ndevcntrs, sizeof(u64), GFP_KERNEL);
if (!dd->cntrs)
goto bail;
 
-   dd->scntrs = kcalloc(index, sizeof(u64), GFP_KERNEL);
+   dd->scntrs = kcalloc(dd->ndevcntrs, sizeof(u64), GFP_KERNEL);
if (!dd->scntrs)
goto bail;
 
@@ -8409,7 +8405,7 @@ static int init_cntrs(struct hfi1_devdata *dd)
goto bail;
 
/* fill in the names */
-   for (p = dd->cntrnames, i = 0, index = 0; i < DEV_CNTR_LAST; i++) {
+   for (p = dd->cntrnames, i = 0; i < DEV_CNTR_LAST; i++) {
if (dev_cntrs[i].flags & CNTR_DISABLED) {
/* Nothing */
} else {
@@ -8439,7 +8435,6 @@ static int init_cntrs(struct hfi1_devdata *dd)
p += strlen(dev_cntrs[i].name);
*p++ = '\n';
}
-   index++;
}
}
 
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 13/13] staging/rdma/hfi1: Adjust EPROM partitions, add EPROM commands

2015-11-10 Thread Jubin John
From: Dean Luick 

Add a new EPROM partition, adjusting partition placement.

Add EPROM range commands as a supserset of the partition
commands.  Remove old partition commands.

Enhance EPROM erase, creating a range function and using the
largest erase (sub) commands when possible.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/eprom.c|  119 +++---
 drivers/staging/rdma/hfi1/file_ops.c |   18 ++
 include/uapi/rdma/hfi/hfi1_user.h|   10 +--
 3 files changed, 77 insertions(+), 70 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/eprom.c 
b/drivers/staging/rdma/hfi1/eprom.c
index b61d3ae..fb620c9 100644
--- a/drivers/staging/rdma/hfi1/eprom.c
+++ b/drivers/staging/rdma/hfi1/eprom.c
@@ -53,17 +53,26 @@
 #include "eprom.h"
 
 /*
- * The EPROM is logically divided into two partitions:
+ * The EPROM is logically divided into three partitions:
  * partition 0: the first 128K, visible from PCI ROM BAR
- * partition 1: the rest
+ * partition 1: 4K config file (sector size)
+ * partition 2: the rest
  */
 #define P0_SIZE (128 * 1024)
+#define P1_SIZE   (4 * 1024)
 #define P1_START P0_SIZE
+#define P2_START (P0_SIZE + P1_SIZE)
+
+/* erase sizes supported by the controller */
+#define SIZE_4KB (4 * 1024)
+#define MASK_4KB (SIZE_4KB - 1)
 
-/* largest erase size supported by the controller */
 #define SIZE_32KB (32 * 1024)
 #define MASK_32KB (SIZE_32KB - 1)
 
+#define SIZE_64KB (64 * 1024)
+#define MASK_64KB (SIZE_64KB - 1)
+
 /* controller page size, in bytes */
 #define EP_PAGE_SIZE 256
 #define EEP_PAGE_MASK (EP_PAGE_SIZE - 1)
@@ -75,10 +84,12 @@
 #define CMD_READ_DATA(addr)((0x03 << CMD_SHIFT) | addr)
 #define CMD_READ_SR1   ((0x05 << CMD_SHIFT))
 #define CMD_WRITE_ENABLE   ((0x06 << CMD_SHIFT))
+#define CMD_SECTOR_ERASE_4KB(addr)  ((0x20 << CMD_SHIFT) | addr)
 #define CMD_SECTOR_ERASE_32KB(addr) ((0x52 << CMD_SHIFT) | addr)
 #define CMD_CHIP_ERASE ((0x60 << CMD_SHIFT))
 #define CMD_READ_MANUF_DEV_ID  ((0x90 << CMD_SHIFT))
 #define CMD_RELEASE_POWERDOWN_NOID  ((0xab << CMD_SHIFT))
+#define CMD_SECTOR_ERASE_64KB(addr) ((0xd8 << CMD_SHIFT) | addr)
 
 /* controller interface speeds */
 #define EP_SPEED_FULL 0x2  /* full speed */
@@ -188,28 +199,43 @@ static int erase_chip(struct hfi1_devdata *dd)
 }
 
 /*
- * Erase a range using the 32KB erase command.
+ * Erase a range.
  */
-static int erase_32kb_range(struct hfi1_devdata *dd, u32 start, u32 end)
+static int erase_range(struct hfi1_devdata *dd, u32 start, u32 len)
 {
+   u32 end = start + len;
int ret = 0;
 
if (end < start)
return -EINVAL;
 
-   if ((start & MASK_32KB) || (end & MASK_32KB)) {
+   /* check the end points for the minimum erase */
+   if ((start & MASK_4KB) || (end & MASK_4KB)) {
dd_dev_err(dd,
-   "%s: non-aligned range (0x%x,0x%x) for a 32KB erase\n",
+   "%s: non-aligned range (0x%x,0x%x) for a 4KB erase\n",
__func__, start, end);
return -EINVAL;
}
 
write_enable(dd);
 
-   for (; start < end; start += SIZE_32KB) {
+   while (start < end) {
write_csr(dd, ASIC_EEP_ADDR_CMD, CMD_WRITE_ENABLE);
-   write_csr(dd, ASIC_EEP_ADDR_CMD,
-   CMD_SECTOR_ERASE_32KB(start));
+   /* check in order of largest to smallest */
+   if (((start & MASK_64KB) == 0) && (start + SIZE_64KB <= end)) {
+   write_csr(dd, ASIC_EEP_ADDR_CMD,
+ CMD_SECTOR_ERASE_64KB(start));
+   start += SIZE_64KB;
+   } else if (((start & MASK_32KB) == 0) &&
+  (start + SIZE_32KB <= end)) {
+   write_csr(dd, ASIC_EEP_ADDR_CMD,
+ CMD_SECTOR_ERASE_32KB(start));
+   start += SIZE_32KB;
+   } else {/* 4KB will work */
+   write_csr(dd, ASIC_EEP_ADDR_CMD,
+ CMD_SECTOR_ERASE_4KB(start));
+   start += SIZE_4KB;
+   }
ret = wait_for_not_busy(dd);
if (ret)
goto done;
@@ -309,6 +335,18 @@ done:
return ret;
 }
 
+/* convert an range composite to a length, in bytes */
+static inline u32 extract_rlen(u32 composite)
+{
+   return (composite & 0x) * EP_PAGE_SIZE;
+}
+
+/* convert an range composite to a start, in bytes */
+static inline u32 extract_rstart(u32 composite)
+{
+   return (composite >> 16) * EP_PAGE_SIZE;
+}
+
 /*
  * Perform the given operation on the EPROM. 

[PATCH 04/13] staging/rdma/hfi: Remove rcv bubbles code

2015-11-10 Thread Jubin John
From: Ira Weiny 

Rcv bubbles were improperly calculated for HFIs, fix that here.

Reviewed-by: Mike Marciniszyn 
Reviewed-by: Arthur Kepner 
Signed-off-by: Ira Weiny 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/mad.c |   64 +-
 1 files changed, 2 insertions(+), 62 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/mad.c b/drivers/staging/rdma/hfi1/mad.c
index a4b7033..a23ddc4 100644
--- a/drivers/staging/rdma/hfi1/mad.c
+++ b/drivers/staging/rdma/hfi1/mad.c
@@ -2271,34 +2271,8 @@ static void a0_portstatus(struct hfi1_pportdata *ppd,
 {
if (!is_bx(ppd->dd)) {
unsigned long vl;
-   int vfi = 0;
u64 max_vl_xmit_wait = 0, tmp;
u32 vl_all_mask = VL_MASK_ALL;
-   u64 rcv_data, rcv_bubble;
-
-   rcv_data = be64_to_cpu(rsp->port_rcv_data);
-   rcv_bubble = be64_to_cpu(rsp->port_rcv_bubble);
-   /* In the measured time period, calculate the total number
-* of flits that were received. Subtract out one false
-* rcv_bubble increment for every 32 received flits but
-* don't let the number go negative.
-*/
-   if (rcv_bubble >= (rcv_data>>5)) {
-   rcv_bubble -= (rcv_data>>5);
-   rsp->port_rcv_bubble = cpu_to_be64(rcv_bubble);
-   }
-   for_each_set_bit(vl, (unsigned long *)&(vl_select_mask),
-8 * sizeof(vl_select_mask)) {
-   rcv_data = be64_to_cpu(rsp->vls[vfi].port_vl_rcv_data);
-   rcv_bubble =
-   be64_to_cpu(rsp->vls[vfi].port_vl_rcv_bubble);
-   if (rcv_bubble >= (rcv_data>>5)) {
-   rcv_bubble -= (rcv_data>>5);
-   rsp->vls[vfi].port_vl_rcv_bubble =
-   cpu_to_be64(rcv_bubble);
-   }
-   vfi++;
-   }
 
for_each_set_bit(vl, (unsigned long *)&(vl_all_mask),
 8 * sizeof(vl_all_mask)) {
@@ -2363,8 +2337,6 @@ static int pma_get_opa_portstatus(struct opa_pma_mad *pmp,
  CNTR_INVALID_VL));
rsp->port_rcv_data = cpu_to_be64(read_dev_cntr(dd, C_DC_RCV_FLITS,
 CNTR_INVALID_VL));
-   rsp->port_rcv_bubble =
-   cpu_to_be64(read_dev_cntr(dd, C_DC_RCV_BBL, CNTR_INVALID_VL));
rsp->port_xmit_pkts = cpu_to_be64(read_dev_cntr(dd, C_DC_XMIT_PKTS,
  CNTR_INVALID_VL));
rsp->port_rcv_pkts = cpu_to_be64(read_dev_cntr(dd, C_DC_RCV_PKTS,
@@ -2434,9 +2406,6 @@ static int pma_get_opa_portstatus(struct opa_pma_mad *pmp,
 
tmp = read_dev_cntr(dd, C_DC_RX_FLIT_VL, idx_from_vl(vl));
rsp->vls[vfi].port_vl_rcv_data = cpu_to_be64(tmp);
-   rsp->vls[vfi].port_vl_rcv_bubble =
-   cpu_to_be64(read_dev_cntr(dd, C_DC_RCV_BBL_VL,
-   idx_from_vl(vl)));
 
rsp->vls[vfi].port_vl_rcv_pkts =
cpu_to_be64(read_dev_cntr(dd, C_DC_RX_PKT_VL,
@@ -2519,32 +2488,8 @@ static void a0_datacounters(struct hfi1_devdata *dd, 
struct _port_dctrs *rsp,
if (!is_bx(dd)) {
unsigned long vl;
int vfi = 0;
-   u64 rcv_data, rcv_bubble, sum_vl_xmit_wait = 0;
-
-   rcv_data = be64_to_cpu(rsp->port_rcv_data);
-   rcv_bubble = be64_to_cpu(rsp->port_rcv_bubble);
-   /* In the measured time period, calculate the total number
-* of flits that were received. Subtract out one false
-* rcv_bubble increment for every 32 received flits but
-* don't let the number go negative.
-*/
-   if (rcv_bubble >= (rcv_data>>5)) {
-   rcv_bubble -= (rcv_data>>5);
-   rsp->port_rcv_bubble = cpu_to_be64(rcv_bubble);
-   }
-   for_each_set_bit(vl, (unsigned long *)&(vl_select_mask),
-   8 * sizeof(vl_select_mask)) {
-   rcv_data = be64_to_cpu(rsp->vls[vfi].port_vl_rcv_data);
-   rcv_bubble =
-   be64_to_cpu(rsp->vls[vfi].port_vl_rcv_bubble);
-   if (rcv_bubble >= (rcv_data>>5)) {
-   rcv_bubble -= (rcv_data>>5);
-   rsp->vls[vfi].port_vl_rcv_bubble =
-   cpu_to_be64(rcv_bubble)

[PATCH 03/13] staging/rdma/hfi1: remove RxCtxRHQS from hfi1stats

2015-11-10 Thread Jubin John
From: Vennila Megavannan 

Removed the RxCtxRHQS counter being dumped into dev_cntrs

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Vennila Megavannan 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c   |2 --
 drivers/staging/rdma/hfi1/chip.h   |1 -
 drivers/staging/rdma/hfi1/chip_registers.h |1 -
 3 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 16302d6..9db141d 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -1587,8 +1587,6 @@ static struct cntr_entry dev_cntrs[DEV_CNTR_LAST] = {
 [C_RX_TID_FLGMS] = RXE32_DEV_CNTR_ELEM(RxTidFLGMs,
RCV_TID_FLOW_GEN_MISMATCH_CNT,
CNTR_NORMAL),
-[C_RX_CTX_RHQS] = RXE32_DEV_CNTR_ELEM(RxCtxRHQS, RCV_CONTEXT_RHQ_STALL,
-   CNTR_NORMAL),
 [C_RX_CTX_EGRS] = RXE32_DEV_CNTR_ELEM(RxCtxEgrS, RCV_CONTEXT_EGR_STALL,
CNTR_NORMAL),
 [C_RCV_TID_FLSMS] = RXE32_DEV_CNTR_ELEM(RxTidFLSMs,
diff --git a/drivers/staging/rdma/hfi1/chip.h b/drivers/staging/rdma/hfi1/chip.h
index ccfaf6d..6946fae 100644
--- a/drivers/staging/rdma/hfi1/chip.h
+++ b/drivers/staging/rdma/hfi1/chip.h
@@ -721,7 +721,6 @@ enum {
C_RX_TID_FULL,
C_RX_TID_INVALID,
C_RX_TID_FLGMS,
-   C_RX_CTX_RHQS,
C_RX_CTX_EGRS,
C_RCV_TID_FLSMS,
C_CCE_PCI_CR_ST,
diff --git a/drivers/staging/rdma/hfi1/chip_registers.h 
b/drivers/staging/rdma/hfi1/chip_registers.h
index bf45de2..5056c84 100644
--- a/drivers/staging/rdma/hfi1/chip_registers.h
+++ b/drivers/staging/rdma/hfi1/chip_registers.h
@@ -379,7 +379,6 @@
 #define DC_LCB_STS_ROUND_TRIP_LTP_CNT (DC_LCB_CSRS + 0x04B0)
 #define RCV_BUF_OVFL_CNT 10
 #define RCV_CONTEXT_EGR_STALL 22
-#define RCV_CONTEXT_RHQ_STALL 21
 #define RCV_DATA_PKT_CNT 0
 #define RCV_DWORD_CNT 1
 #define RCV_TID_FLOW_GEN_MISMATCH_CNT 20
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/13] staging/rdma/hfi1: rework is_a0() and is_bx()

2015-11-10 Thread Jubin John
From: Mike Marciniszyn 

The current is_bx() will incorrectly match on other steppings.

is_a0() is removed in favor of is_ax().

Reviewed-by: Mark Debbage 
Signed-off-by: Mike Marciniszyn 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c |   46 ++
 drivers/staging/rdma/hfi1/chip.h |1 -
 drivers/staging/rdma/hfi1/firmware.c |2 +-
 drivers/staging/rdma/hfi1/hfi.h  |4 +-
 drivers/staging/rdma/hfi1/init.c |2 +-
 drivers/staging/rdma/hfi1/pcie.c |4 +-
 6 files changed, 25 insertions(+), 34 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index eb281e9..75416d8 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -1871,13 +1871,6 @@ static struct cntr_entry port_cntrs[PORT_CNTR_LAST] = {
 
 /*  */
 
-/* return true if this is chip revision revision a0 */
-int is_a0(struct hfi1_devdata *dd)
-{
-   return ((dd->revision >> CCE_REVISION_CHIP_REV_MINOR_SHIFT)
-   & CCE_REVISION_CHIP_REV_MINOR_MASK) == 0;
-}
-
 /* return true if this is chip revision revision a */
 int is_ax(struct hfi1_devdata *dd)
 {
@@ -1893,7 +1886,7 @@ int is_bx(struct hfi1_devdata *dd)
u8 chip_rev_minor =
dd->revision >> CCE_REVISION_CHIP_REV_MINOR_SHIFT
& CCE_REVISION_CHIP_REV_MINOR_MASK;
-   return !!(chip_rev_minor & 0x10);
+   return (chip_rev_minor & 0xF0) == 0x10;
 }
 
 /*
@@ -2188,9 +2181,8 @@ static void handle_cce_err(struct hfi1_devdata *dd, u32 
unused, u64 reg)
dd_dev_info(dd, "CCE Error: %s\n",
cce_err_status_string(buf, sizeof(buf), reg));
 
-   if ((reg & CCE_ERR_STATUS_CCE_CLI2_ASYNC_FIFO_PARITY_ERR_SMASK)
-   && is_a0(dd)
-   && (dd->icode != ICODE_FUNCTIONAL_SIMULATOR)) {
+   if ((reg & CCE_ERR_STATUS_CCE_CLI2_ASYNC_FIFO_PARITY_ERR_SMASK) &&
+   is_ax(dd) && (dd->icode != ICODE_FUNCTIONAL_SIMULATOR)) {
/* this error requires a manual drop into SPC freeze mode */
/* then a fix up */
start_freeze_handling(dd->pport, FREEZE_SELF);
@@ -2250,7 +2242,7 @@ static void handle_rxe_err(struct hfi1_devdata *dd, u32 
unused, u64 reg)
 * Freeze mode recovery is disabled for the errors
 * in RXE_FREEZE_ABORT_MASK
 */
-   if (is_a0(dd) && (reg & RXE_FREEZE_ABORT_MASK))
+   if (is_ax(dd) && (reg & RXE_FREEZE_ABORT_MASK))
flags = FREEZE_ABORT;
 
start_freeze_handling(dd->pport, flags);
@@ -2353,7 +2345,7 @@ static void handle_egress_err(struct hfi1_devdata *dd, 
u32 unused, u64 reg)
 
if (reg & ALL_TXE_EGRESS_FREEZE_ERR)
start_freeze_handling(dd->pport, 0);
-   if (is_a0(dd) && (reg &
+   if (is_ax(dd) && (reg &
SEND_EGRESS_ERR_STATUS_TX_CREDIT_RETURN_VL_ERR_SMASK)
&& (dd->icode != ICODE_FUNCTIONAL_SIMULATOR))
start_freeze_handling(dd->pport, 0);
@@ -3048,7 +3040,7 @@ static void adjust_lcb_for_fpga_serdes(struct 
hfi1_devdata *dd)
/* else this is _p */
 
version = emulator_rev(dd);
-   if (!is_a0(dd))
+   if (!is_ax(dd))
version = 0x2d; /* all B0 use 0x2d or higher settings */
 
if (version <= 0x12) {
@@ -3334,7 +3326,7 @@ void handle_freeze(struct work_struct *work)
write_csr(dd, CCE_CTRL, CCE_CTRL_SPC_UNFREEZE_SMASK);
wait_for_freeze_status(dd, 0);
 
-   if (is_a0(dd)) {
+   if (is_ax(dd)) {
write_csr(dd, CCE_CTRL, CCE_CTRL_SPC_FREEZE_SMASK);
wait_for_freeze_status(dd, 1);
write_csr(dd, CCE_CTRL, CCE_CTRL_SPC_UNFREEZE_SMASK);
@@ -3862,7 +3854,7 @@ void handle_verify_cap(struct work_struct *work)
 *  REPLAY_BUF_MBE_SMASK
 *  FLIT_INPUT_BUF_MBE_SMASK
 */
-   if (is_a0(dd)) {/* fixed in B0 */
+   if (is_ax(dd)) {/* fixed in B0 */
reg = read_csr(dd, DC_LCB_CFG_LINK_KILL_EN);
reg |= DC_LCB_CFG_LINK_KILL_EN_REPLAY_BUF_MBE_SMASK
| DC_LCB_CFG_LINK_KILL_EN_FLIT_INPUT_BUF_MBE_SMASK;
@@ -7297,8 +7289,8 @@ static int set_buffer_control(struct hfi1_devdata *dd,
 */
use_all_mask = 0;
if ((be16_to_cpu(new_bc->overall_shared_limit) <
-   be16_to_cpu(cur_bc.overall_shared_limit))
-   || (is_a0(dd) && any_shared_limit_changing)) {
+be16_to_cpu(cur_bc.overall_shared_limit)) ||
+   (is_ax(dd) &

Re: [PATCH 01/13] staging/rdma/hfi1: Use BIT macro

2015-11-13 Thread Jubin John
On Fri, Nov 13, 2015 at 06:45:58PM +0530, Sudip Mukherjee wrote:
> On Wed, Nov 11, 2015 at 02:33:21AM -0500, Jubin John wrote:
> > This patch fixes the checkpatch issue:
> > CHECK: Prefer using the BIT macro
> > 
> > Reviewed-by: Dean Luick 
> > Reviewed-by: Ira Weiny 
> > Reviewed-by: Mike Marciniszyn 
> > Signed-off-by: Jubin John 
> > ---
> 
> >  
> > diff --git a/drivers/staging/rdma/hfi1/init.c 
> > b/drivers/staging/rdma/hfi1/init.c
> > index 8666f3a..680f877 100644
> > --- a/drivers/staging/rdma/hfi1/init.c
> > +++ b/drivers/staging/rdma/hfi1/init.c
> > @@ -252,7 +252,7 @@ struct hfi1_ctxtdata *hfi1_create_ctxtdata(struct 
> > hfi1_pportdata *ppd, u32 ctxt)
> > /* Validate and initialize Rcv Hdr Q variables */
> > if (rcvhdrcnt % HDRQ_INCREMENT) {
> > dd_dev_err(dd,
> > -  "ctxt%u: header queue count %d must be 
> > divisible by %d\n",
> > +  "ctxt%u: header queue count %d must be 
> > divisible by %lud\n",
> 
> This is an unrelated change. If you are sending the series based on
> Dan's comment on 12/13 then please remove this also.
> 
This is not an unrelated change. This was needed due to the use of the
BIT macro for HDRQ_INCREMENT in chip.h.
Otherwise, the following warning is shown during the build:
drivers/staging/rdma/hfi1/init.c: In function ‘hfi1_create_ctxtdata’:
drivers/staging/rdma/hfi1/init.c:254:4: warning: format ‘%u’ expects
argument of type ‘unsigned int’, but argument 6 has type
‘long unsigned int’ [-Wformat=]
dd_dev_err(dd,

Thanks,
Jubin John
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 01/13] staging/rdma/hfi1: Use BIT macro

2015-11-13 Thread Jubin John
On Fri, Nov 13, 2015 at 11:09:22AM -0500, Jubin John wrote:
> On Fri, Nov 13, 2015 at 06:45:58PM +0530, Sudip Mukherjee wrote:
> > On Wed, Nov 11, 2015 at 02:33:21AM -0500, Jubin John wrote:
> > > This patch fixes the checkpatch issue:
> > > CHECK: Prefer using the BIT macro
> > > 
> > > Reviewed-by: Dean Luick 
> > > Reviewed-by: Ira Weiny 
> > > Reviewed-by: Mike Marciniszyn 
> > > Signed-off-by: Jubin John 
> > > ---
> > 
> > >  
> > > diff --git a/drivers/staging/rdma/hfi1/init.c 
> > > b/drivers/staging/rdma/hfi1/init.c
> > > index 8666f3a..680f877 100644
> > > --- a/drivers/staging/rdma/hfi1/init.c
> > > +++ b/drivers/staging/rdma/hfi1/init.c
> > > @@ -252,7 +252,7 @@ struct hfi1_ctxtdata *hfi1_create_ctxtdata(struct 
> > > hfi1_pportdata *ppd, u32 ctxt)
> > >   /* Validate and initialize Rcv Hdr Q variables */
> > >   if (rcvhdrcnt % HDRQ_INCREMENT) {
> > >   dd_dev_err(dd,
> > > -"ctxt%u: header queue count %d must be 
> > > divisible by %d\n",
> > > +"ctxt%u: header queue count %d must be 
> > > divisible by %lud\n",
> > 
> > This is an unrelated change. If you are sending the series based on
> > Dan's comment on 12/13 then please remove this also.
> > 
> This is not an unrelated change. This was needed due to the use of the
> BIT macro for HDRQ_INCREMENT in chip.h.
> Otherwise, the following warning is shown during the build:
> drivers/staging/rdma/hfi1/init.c: In function ‘hfi1_create_ctxtdata’:
> drivers/staging/rdma/hfi1/init.c:254:4: warning: format ‘%u’ expects
> argument of type ‘unsigned int’, but argument 6 has type
> ‘long unsigned int’ [-Wformat=]
> dd_dev_err(dd,
> 
Sorry for the weird characters, they seem to have slipped in when I
copied that message.
Hopefully this is clearer:
drivers/staging/rdma/hfi1/init.c: In function ‘hfi1_create_ctxtdata’:
drivers/staging/rdma/hfi1/init.c:254:4: warning: format ‘%d’ expects argument 
of type ‘int’, but argument 6 has type ‘long unsigned int’ [-Wformat=]
dd_dev_err(dd,
^

> Thanks,
> Jubin John
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 01/13] staging/rdma/hfi1: Use BIT macro

2015-11-13 Thread Jubin John
On Fri, Nov 13, 2015 at 01:03:44PM -0500, Jubin John wrote:
> On Fri, Nov 13, 2015 at 11:09:22AM -0500, Jubin John wrote:
> > On Fri, Nov 13, 2015 at 06:45:58PM +0530, Sudip Mukherjee wrote:
> > > On Wed, Nov 11, 2015 at 02:33:21AM -0500, Jubin John wrote:
> > > > This patch fixes the checkpatch issue:
> > > > CHECK: Prefer using the BIT macro
> > > > 
> > > > Reviewed-by: Dean Luick 
> > > > Reviewed-by: Ira Weiny 
> > > > Reviewed-by: Mike Marciniszyn 
> > > > Signed-off-by: Jubin John 
> > > > ---
> > > 
> > > >  
> > > > diff --git a/drivers/staging/rdma/hfi1/init.c 
> > > > b/drivers/staging/rdma/hfi1/init.c
> > > > index 8666f3a..680f877 100644
> > > > --- a/drivers/staging/rdma/hfi1/init.c
> > > > +++ b/drivers/staging/rdma/hfi1/init.c
> > > > @@ -252,7 +252,7 @@ struct hfi1_ctxtdata *hfi1_create_ctxtdata(struct 
> > > > hfi1_pportdata *ppd, u32 ctxt)
> > > > /* Validate and initialize Rcv Hdr Q variables */
> > > > if (rcvhdrcnt % HDRQ_INCREMENT) {
> > > > dd_dev_err(dd,
> > > > -  "ctxt%u: header queue count %d must 
> > > > be divisible by %d\n",
> > > > +  "ctxt%u: header queue count %d must 
> > > > be divisible by %lud\n",
> > > 
> > > This is an unrelated change. If you are sending the series based on
> > > Dan's comment on 12/13 then please remove this also.
> > > 
> > This is not an unrelated change. This was needed due to the use of the
> > BIT macro for HDRQ_INCREMENT in chip.h.
> > Otherwise, the following warning is shown during the build:
> > drivers/staging/rdma/hfi1/init.c: In function ‘hfi1_create_ctxtdata’:
> > drivers/staging/rdma/hfi1/init.c:254:4: warning: format ‘%u’ expects
> > argument of type ‘unsigned int’, but argument 6 has type
> > ‘long unsigned int’ [-Wformat=]
> > dd_dev_err(dd,
> > 
> Sorry for the weird characters, they seem to have slipped in when I
> copied that message.
> Hopefully this is clearer:
> drivers/staging/rdma/hfi1/init.c: In function ‘hfi1_create_ctxtdata’:
> drivers/staging/rdma/hfi1/init.c:254:4: warning: format ‘%d’ expects argument 
> of type ‘int’, but argument 6 has type ‘long unsigned int’ [-Wformat=]
> dd_dev_err(dd,
>     ^
Same thing happened again :( This was probably due to the gcc color
output on my terminal. Turned off gcc color and trying again:
drivers/staging/rdma/hfi1/init.c: In function ‘hfi1_create_ctxtdata’:
drivers/staging/rdma/hfi1/init.c:254:4: warning: format ‘%d’ expects argument 
of type ‘int’, but argument 6 has type ‘long unsigned int’ [-Wformat=]
dd_dev_err(dd,
^

Sorry for the repeated messages.
> 
> > Thanks,
> > Jubin John
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> > the body of a message to majord...@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/18] staging/rdma/hfi1: Add aeth name syndrome decode

2015-11-13 Thread Jubin John
From: Dean Luick 

Add aeth name syndrome decode

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/trace.c |   29 ++---
 1 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/trace.c 
b/drivers/staging/rdma/hfi1/trace.c
index f55b751..10122e8 100644
--- a/drivers/staging/rdma/hfi1/trace.c
+++ b/drivers/staging/rdma/hfi1/trace.c
@@ -67,7 +67,7 @@ u8 ibhdr_exhdr_len(struct hfi1_ib_header *hdr)
 
 #define IMM_PRN  "imm %d"
 #define RETH_PRN "reth vaddr 0x%.16llx rkey 0x%.8x dlen 0x%.8x"
-#define AETH_PRN "aeth syn 0x%.2x msn 0x%.8x"
+#define AETH_PRN "aeth syn 0x%.2x %s msn 0x%.8x"
 #define DETH_PRN "deth qkey 0x%.8x sqpn 0x%.6x"
 #define ATOMICACKETH_PRN "origdata %lld"
 #define ATOMICETH_PRN "vaddr 0x%llx rkey 0x%.8x sdata %lld cdata %lld"
@@ -79,6 +79,19 @@ static u64 ib_u64_get(__be32 *p)
return ((u64)be32_to_cpu(p[0]) << 32) | be32_to_cpu(p[1]);
 }
 
+static const char *parse_syndrome(u8 syndrome)
+{
+   switch (syndrome >> 5) {
+   case 0:
+   return "ACK";
+   case 1:
+   return "RNRNAK";
+   case 3:
+   return "NAK";
+   }
+   return "";
+}
+
 const char *parse_everbs_hdrs(
struct trace_seq *p,
u8 opcode,
@@ -124,16 +137,18 @@ const char *parse_everbs_hdrs(
case OP(RC, RDMA_READ_RESPONSE_LAST):
case OP(RC, RDMA_READ_RESPONSE_ONLY):
case OP(RC, ACKNOWLEDGE):
-   trace_seq_printf(p, AETH_PRN,
-   be32_to_cpu(eh->aeth) >> 24,
-   be32_to_cpu(eh->aeth) & HFI1_MSN_MASK);
+   trace_seq_printf(p, AETH_PRN, be32_to_cpu(eh->aeth) >> 24,
+parse_syndrome(be32_to_cpu(eh->aeth) >> 24),
+be32_to_cpu(eh->aeth) & HFI1_MSN_MASK);
break;
/* aeth + atomicacketh */
case OP(RC, ATOMIC_ACKNOWLEDGE):
trace_seq_printf(p, AETH_PRN " " ATOMICACKETH_PRN,
-   (be32_to_cpu(eh->at.aeth) >> 24) & 0xff,
-   be32_to_cpu(eh->at.aeth) & HFI1_MSN_MASK,
-   (unsigned long long)ib_u64_get(eh->at.atomic_ack_eth));
+be32_to_cpu(eh->at.aeth) >> 24,
+parse_syndrome(be32_to_cpu(eh->at.aeth) >> 24),
+be32_to_cpu(eh->at.aeth) & HFI1_MSN_MASK,
+(unsigned long long)
+ib_u64_get(eh->at.atomic_ack_eth));
break;
/* atomiceth */
case OP(RC, COMPARE_SWAP):
-- 
1.7.0.7

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/18] staging/rdma/hfi1: Clean up comments

2015-11-13 Thread Jubin John
From: Edward Mascarenhas 

Clean up comments

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Edward Mascarenhas 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c   |1 -
 drivers/staging/rdma/hfi1/driver.c |2 +-
 drivers/staging/rdma/hfi1/hfi.h|4 ++--
 drivers/staging/rdma/hfi1/pcie.c   |2 +-
 drivers/staging/rdma/hfi1/ud.c |2 +-
 5 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index e489819..a5b3653 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -10274,7 +10274,6 @@ int hfi1_set_ctxt_jkey(struct hfi1_devdata *dd, 
unsigned ctxt, u16 jkey)
write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_JOB_KEY, reg);
/*
 * Enable send-side J_KEY integrity check, unless this is A0 h/w
-* (due to A0 erratum).
 */
if (!is_a0(dd)) {
reg = read_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE);
diff --git a/drivers/staging/rdma/hfi1/driver.c 
b/drivers/staging/rdma/hfi1/driver.c
index ce69141..9e58662 100644
--- a/drivers/staging/rdma/hfi1/driver.c
+++ b/drivers/staging/rdma/hfi1/driver.c
@@ -368,7 +368,7 @@ static void rcv_hdrerr(struct hfi1_ctxtdata *rcd, struct 
hfi1_pportdata *ppd,
if (opcode == IB_OPCODE_CNP) {
/*
 * Only in pre-B0 h/w is the CNP_OPCODE handled
-* via this code path (errata 291394).
+* via this code path.
 */
struct hfi1_qp *qp = NULL;
u32 lqpn, rqpn;
diff --git a/drivers/staging/rdma/hfi1/hfi.h b/drivers/staging/rdma/hfi1/hfi.h
index 190f7a2..e7ed319 100644
--- a/drivers/staging/rdma/hfi1/hfi.h
+++ b/drivers/staging/rdma/hfi1/hfi.h
@@ -1714,7 +1714,7 @@ static inline u64 hfi1_pkt_default_send_ctxt_mask(struct 
hfi1_devdata *dd,
base_sc_integrity |= HFI1_PKT_KERNEL_SC_INTEGRITY;
 
if (is_a0(dd))
-   /* turn off send-side job key checks - A0 erratum */
+   /* turn off send-side job key checks - A0 */
return base_sc_integrity &
   ~SEND_CTXT_CHECK_ENABLE_CHECK_JOB_KEY_SMASK;
return base_sc_integrity;
@@ -1741,7 +1741,7 @@ static inline u64 hfi1_pkt_base_sdma_integrity(struct 
hfi1_devdata *dd)
| SEND_DMA_CHECK_ENABLE_CHECK_ENABLE_SMASK;
 
if (is_a0(dd))
-   /* turn off send-side job key checks - A0 erratum */
+   /* turn off send-side job key checks - A0 */
return base_sdma_integrity &
   ~SEND_DMA_CHECK_ENABLE_CHECK_JOB_KEY_SMASK;
return base_sdma_integrity;
diff --git a/drivers/staging/rdma/hfi1/pcie.c b/drivers/staging/rdma/hfi1/pcie.c
index a956044..bfaf137 100644
--- a/drivers/staging/rdma/hfi1/pcie.c
+++ b/drivers/staging/rdma/hfi1/pcie.c
@@ -994,7 +994,7 @@ retry:
 * PcieCfgRegPl100 - Gen3 Control
 *
 * turn off PcieCfgRegPl100.Gen3ZRxDcNonCompl
-* turn on PcieCfgRegPl100.EqEieosCnt (erratum)
+* turn on PcieCfgRegPl100.EqEieosCnt
 * Everything else zero.
 */
reg32 = PCIE_CFG_REG_PL100_EQ_EIEOS_CNT_SMASK;
diff --git a/drivers/staging/rdma/hfi1/ud.c b/drivers/staging/rdma/hfi1/ud.c
index d40d1a1..c77c11b 100644
--- a/drivers/staging/rdma/hfi1/ud.c
+++ b/drivers/staging/rdma/hfi1/ud.c
@@ -671,7 +671,7 @@ void hfi1_ud_rcv(struct hfi1_packet *packet)
if (unlikely(bth1 & HFI1_BECN_SMASK)) {
/*
 * In pre-B0 h/w the CNP_OPCODE is handled via an
-* error path (errata 291394).
+* error path.
 */
struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
u32 lqpn =  be32_to_cpu(ohdr->bth[1]) & HFI1_QPN_MASK;
-- 
1.7.0.7

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/18] staging/rdma/hfi1: Fix qp.h comments

2015-11-13 Thread Jubin John
From: Kaike Wan 

This patch fixes a few qp.h comments.

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Kaike Wan 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/qp.h |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/qp.h b/drivers/staging/rdma/hfi1/qp.h
index b9c1575..8ef64cd 100644
--- a/drivers/staging/rdma/hfi1/qp.h
+++ b/drivers/staging/rdma/hfi1/qp.h
@@ -212,7 +212,7 @@ int hfi1_qp_init(struct hfi1_ibdev *dev);
 void hfi1_qp_exit(struct hfi1_ibdev *dev);
 
 /**
- * hfi1_qp_waitup - wake up on the indicated event
+ * hfi1_qp_wakeup - wake up on the indicated event
  * @qp: the QP
  * @flag: flag the qp on which the qp is stalled
  */
@@ -223,19 +223,19 @@ struct sdma_engine *qp_to_sdma_engine(struct hfi1_qp *qp, 
u8 sc5);
 struct qp_iter;
 
 /**
- * qp_iter_init - wake up on the indicated event
+ * qp_iter_init - initialize the iterator for the qp hash list
  * @dev: the hfi1_ibdev
  */
 struct qp_iter *qp_iter_init(struct hfi1_ibdev *dev);
 
 /**
- * qp_iter_next - wakeup on the indicated event
+ * qp_iter_next - Find the next qp in the hash list
  * @iter: the iterator for the qp hash list
  */
 int qp_iter_next(struct qp_iter *iter);
 
 /**
- * qp_iter_next - wake up on the indicated event
+ * qp_iter_print - print the qp information to seq_file
  * @s: the seq_file to emit the qp information on
  * @iter: the iterator for the qp hash list
  */
-- 
1.7.0.7

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/18] staging/rdma/hfi1: Support alternate firmware names

2015-11-13 Thread Jubin John
From: Dean Luick 

Add support for an automatic fallback for firmware names.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/firmware.c |  189 --
 1 files changed, 157 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/firmware.c 
b/drivers/staging/rdma/hfi1/firmware.c
index b4bdcf3..e80eecf 100644
--- a/drivers/staging/rdma/hfi1/firmware.c
+++ b/drivers/staging/rdma/hfi1/firmware.c
@@ -68,6 +68,10 @@
 #define DEFAULT_FW_SBUS_NAME "hfi1_sbus.fw"
 #define DEFAULT_FW_PCIE_NAME "hfi1_pcie.fw"
 #define DEFAULT_PLATFORM_CONFIG_NAME "hfi1_platform.dat"
+#define ALT_FW_8051_NAME_ASIC "hfi1_dc8051_d.fw"
+#define ALT_FW_FABRIC_NAME "hfi1_fabric_d.fw"
+#define ALT_FW_SBUS_NAME "hfi1_sbus_d.fw"
+#define ALT_FW_PCIE_NAME "hfi1_pcie_d.fw"
 
 static uint fw_8051_load = 1;
 static uint fw_fabric_serdes_load = 1;
@@ -158,7 +162,8 @@ struct firmware_details {
 static DEFINE_MUTEX(fw_mutex);
 enum fw_state {
FW_EMPTY,
-   FW_ACQUIRED,
+   FW_TRY,
+   FW_FINAL,
FW_ERR
 };
 static enum fw_state fw_state = FW_EMPTY;
@@ -428,8 +433,8 @@ static int obtain_one_firmware(struct hfi1_devdata *dd, 
const char *name,
 
ret = request_firmware(&fdet->fw, name, &dd->pcidev->dev);
if (ret) {
-   dd_dev_err(dd, "cannot load firmware \"%s\", err %d\n",
-   name, ret);
+   dd_dev_err(dd, "cannot find firmware \"%s\", err %d\n",
+  name, ret);
return ret;
}
 
@@ -539,28 +544,53 @@ done:
 static void dispose_one_firmware(struct firmware_details *fdet)
 {
release_firmware(fdet->fw);
-   fdet->fw = NULL;
+   /* erase all previous information */
+   memset(fdet, 0, sizeof(*fdet));
 }
 
 /*
- * Called by all HFIs when loading their firmware - i.e. device probe time.
- * The first one will do the actual firmware load.  Use a mutex to resolve
- * any possible race condition.
+ * Obtain the 4 firmwares from the OS.  All must be obtained at once or not
+ * at all.  If called with the firmware state in FW_TRY, use alternate names.
+ * On exit, this routine will have set the firmware state to one of FW_TRY,
+ * FW_FINAL, or FW_ERR.
  *
- * The call to this routine cannot be moved to driver load because the kernel
- * call request_firmware() requires a device which is only available after
- * the first device probe.
+ * Must be holding fw_mutex.
  */
-static int obtain_firmware(struct hfi1_devdata *dd)
+static void __obtain_firmware(struct hfi1_devdata *dd)
 {
int err = 0;
 
-   mutex_lock(&fw_mutex);
-   if (fw_state == FW_ACQUIRED) {
-   goto done;  /* already acquired */
-   } else if (fw_state == FW_ERR) {
-   err = fw_err;
-   goto done;  /* already tried and failed */
+   if (fw_state == FW_FINAL)   /* nothing more to obtain */
+   return;
+   if (fw_state == FW_ERR) /* already in error */
+   return;
+
+   /* fw_state is FW_EMPTY or FW_TRY */
+retry:
+   if (fw_state == FW_TRY) {
+   /*
+* We tried the original and it failed.  Move to the
+* alternate.
+*/
+   dd_dev_info(dd, "using alternate firmware names\n");
+   /*
+* Let others run.  Some systems, when missing firmware, does
+* something that holds for 30 seconds.  If we do that twice
+* in a row it triggers task blocked warning.
+*/
+   cond_resched();
+   if (fw_8051_load)
+   dispose_one_firmware(&fw_8051);
+   if (fw_fabric_serdes_load)
+   dispose_one_firmware(&fw_fabric);
+   if (fw_sbus_load)
+   dispose_one_firmware(&fw_sbus);
+   if (fw_pcie_serdes_load)
+   dispose_one_firmware(&fw_pcie);
+   fw_8051_name = ALT_FW_8051_NAME_ASIC;
+   fw_fabric_serdes_name = ALT_FW_FABRIC_NAME;
+   fw_sbus_name = ALT_FW_SBUS_NAME;
+   fw_pcie_serdes_name = ALT_FW_PCIE_NAME;
}
 
if (fw_8051_load) {
@@ -588,27 +618,82 @@ static int obtain_firmware(struct hfi1_devdata *dd)
goto done;
}
 
+done:
+   if (err) {
+   /* oops, had problems obtaining a firmware */
+   if (fw_state == FW_EMPTY) {
+   /* retry with alternate */
+   fw_state = FW_TRY;
+   goto retry;
+   }
+   fw_state = FW_ERR;
+   fw_err = -ENOENT;
+   } else {
+   /* success */
+ 

[PATCH 02/18] staging/rdma/hfi1: Decode CNP opcode

2015-11-13 Thread Jubin John
From: Dean Luick 

Add CNP opcode decode

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/trace.h |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/trace.h 
b/drivers/staging/rdma/hfi1/trace.h
index 5743029..86c12eb 100644
--- a/drivers/staging/rdma/hfi1/trace.h
+++ b/drivers/staging/rdma/hfi1/trace.h
@@ -417,7 +417,8 @@ __print_symbolic(opcode,   \
ib_opcode_name(UC_RDMA_WRITE_ONLY),\
ib_opcode_name(UC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
ib_opcode_name(UD_SEND_ONLY),  \
-   ib_opcode_name(UD_SEND_ONLY_WITH_IMMEDIATE))
+   ib_opcode_name(UD_SEND_ONLY_WITH_IMMEDIATE),   \
+   ib_opcode_name(CNP))
 
 
 #define LRH_PRN "vl %d lver %d sl %d lnh %d,%s dlid %.4x len %d slid %.4x"
-- 
1.7.0.7

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/18] staging/rdma/hfi: Add one-time LCB reset

2015-11-13 Thread Jubin John
From: Dean Luick 

Add one-time LCB reset on driver load to pre-emptively work
around any LCB power cycle issues.

Reviewed-by: Easwar Hariharan 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c   |   20 
 drivers/staging/rdma/hfi1/chip_registers.h |3 +++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index a5b3653..be89e37 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -5856,6 +5856,23 @@ void init_qsfp(struct hfi1_pportdata *ppd)
}
 }
 
+/*
+ * Do a one-time initialize of the LCB block.
+ */
+static void init_lcb(struct hfi1_devdata *dd)
+{
+   /* the DC has been reset earlier in the driver load */
+
+   /* set LCB for cclk loopback on the port */
+   write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 0x01);
+   write_csr(dd, DC_LCB_CFG_LANE_WIDTH, 0x00);
+   write_csr(dd, DC_LCB_CFG_REINIT_AS_SLAVE, 0x00);
+   write_csr(dd, DC_LCB_CFG_CNT_FOR_SKIP_STALL, 0x110);
+   write_csr(dd, DC_LCB_CFG_CLK_CNTR, 0x08);
+   write_csr(dd, DC_LCB_CFG_LOOPBACK, 0x02);
+   write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 0x00);
+}
+
 int bringup_serdes(struct hfi1_pportdata *ppd)
 {
struct hfi1_devdata *dd = ppd->dd;
@@ -5877,6 +5894,9 @@ int bringup_serdes(struct hfi1_pportdata *ppd)
/* Set linkinit_reason on power up per OPA spec */
ppd->linkinit_reason = OPA_LINKINIT_REASON_LINKUP;
 
+   /* one-time init of the LCB */
+   init_lcb(dd);
+
if (loopback) {
ret = init_loopback(dd);
if (ret < 0)
diff --git a/drivers/staging/rdma/hfi1/chip_registers.h 
b/drivers/staging/rdma/hfi1/chip_registers.h
index bf45de2..21ca8c1 100644
--- a/drivers/staging/rdma/hfi1/chip_registers.h
+++ b/drivers/staging/rdma/hfi1/chip_registers.h
@@ -318,6 +318,9 @@
 #define DC_LCB_CFG_TX_FIFOS_RADR_RST_VAL_SHIFT 0
 #define DC_LCB_CFG_TX_FIFOS_RESET (DC_LCB_CSRS + 0x0008)
 #define DC_LCB_CFG_TX_FIFOS_RESET_VAL_SHIFT 0
+#define DC_LCB_CFG_REINIT_AS_SLAVE (DC_LCB_CSRS + 0x0030)
+#define DC_LCB_CFG_CNT_FOR_SKIP_STALL (DC_LCB_CSRS + 0x0040)
+#define DC_LCB_CFG_CLK_CNTR (DC_LCB_CSRS + 0x0110)
 #define DC_LCB_ERR_CLR (DC_LCB_CSRS + 0x0308)
 #define DC_LCB_ERR_EN (DC_LCB_CSRS + 0x0310)
 #define DC_LCB_ERR_FLG (DC_LCB_CSRS + 0x0300)
-- 
1.7.0.7

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 18/18] staging/rdma/hfi1: Workaround CONFIG_SDMA_VERBOSITY timing issue

2015-11-13 Thread Jubin John
Enabling CONFIG_SDMA_VERBOSITY exposes a timing issue in the
driver/DC firmware. Removing the CCE_INT_* CSR reads from
sdma_dumpstate and a sdma_dumpstate call from the sdma_sendctrl()
works around the issue

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/sdma.c |   11 ---
 1 files changed, 0 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/sdma.c b/drivers/staging/rdma/hfi1/sdma.c
index 2a1da21..b74a451 100644
--- a/drivers/staging/rdma/hfi1/sdma.c
+++ b/drivers/staging/rdma/hfi1/sdma.c
@@ -1635,9 +1635,6 @@ static void sdma_sendctrl(struct sdma_engine *sde, 
unsigned op)
 
spin_unlock_irqrestore(&sde->senddmactrl_lock, flags);
 
-#ifdef CONFIG_SDMA_VERBOSITY
-   sdma_dumpstate(sde);
-#endif
 }
 
 static void sdma_setlengen(struct sdma_engine *sde)
@@ -1774,7 +1771,6 @@ static void init_sdma_regs(
 void sdma_dumpstate(struct sdma_engine *sde)
 {
u64 csr;
-   unsigned i;
 
sdma_dumpstate_helper(SD(CTRL));
sdma_dumpstate_helper(SD(STATUS));
@@ -1782,13 +1778,6 @@ void sdma_dumpstate(struct sdma_engine *sde)
sdma_dumpstate_helper0(SD(ERR_MASK));
sdma_dumpstate_helper(SD(ENG_ERR_STATUS));
sdma_dumpstate_helper(SD(ENG_ERR_MASK));
-
-   for (i = 0; i < CCE_NUM_INT_CSRS; ++i) {
-   sdma_dumpstate_helper2(CCE_INT_STATUS);
-   sdma_dumpstate_helper2(CCE_INT_MASK);
-   sdma_dumpstate_helper2(CCE_INT_BLOCKED);
-   }
-
sdma_dumpstate_helper(SD(TAIL));
sdma_dumpstate_helper(SD(HEAD));
sdma_dumpstate_helper(SD(PRIORITY_THLD));
-- 
1.7.0.7

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 13/18] staging/rdma/hfi1: remove SPC freeze error messages

2015-11-13 Thread Jubin John
From: Dean Luick 

An SPC freeze is not an error.  Remove the messages.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index a62a538..2ac145f 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -6496,7 +6496,6 @@ void handle_freeze(struct work_struct *work)
struct hfi1_devdata *dd = ppd->dd;
 
/* wait for freeze indicators on all affected blocks */
-   dd_dev_info(dd, "Entering SPC freeze\n");
wait_for_freeze_status(dd, 1);
 
/* SPC is now frozen */
@@ -6554,7 +6553,6 @@ void handle_freeze(struct work_struct *work)
wake_up(&dd->event_queue);
 
/* no longer frozen */
-   dd_dev_err(dd, "Exiting SPC freeze\n");
 }
 
 /*
-- 
1.7.0.7

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 16/18] staging/rdma/hfi1: Fix Xmit Wait calculation

2015-11-13 Thread Jubin John
From: Ira Weiny 

Total XMIT wait needs to sum the xmit wait values of all the VLs not just
those requested in the query.  Also, make the algorithm used for both
PortStatus and PortDataCounters the same.

Reviewed-by: Arthur Kepner 
Reviewed-by: Breyer, Scott J 
Signed-off-by: Ira Weiny 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/mad.c |   32 
 1 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/mad.c b/drivers/staging/rdma/hfi1/mad.c
index 32f7037..e151359 100644
--- a/drivers/staging/rdma/hfi1/mad.c
+++ b/drivers/staging/rdma/hfi1/mad.c
@@ -2272,7 +2272,7 @@ static void a0_portstatus(struct hfi1_pportdata *ppd,
if (!is_bx(ppd->dd)) {
unsigned long vl;
int vfi = 0;
-   u64 max_vl_xmit_wait = 0, tmp;
+   u64 sum_vl_xmit_wait = 0;
u32 vl_all_mask = VL_MASK_ALL;
u64 rcv_data, rcv_bubble;
 
@@ -2302,12 +2302,18 @@ static void a0_portstatus(struct hfi1_pportdata *ppd,
 
for_each_set_bit(vl, (unsigned long *)&(vl_all_mask),
 8 * sizeof(vl_all_mask)) {
-   tmp = read_port_cntr(ppd, C_TX_WAIT_VL,
-idx_from_vl(vl));
-   if (tmp > max_vl_xmit_wait)
-   max_vl_xmit_wait = tmp;
+   u64 tmp = sum_vl_xmit_wait +
+ read_port_cntr(ppd, C_TX_WAIT_VL,
+idx_from_vl(vl));
+   if (tmp < sum_vl_xmit_wait) {
+   /* we wrapped */
+   sum_vl_xmit_wait = (u64)~0;
+   break;
+   }
+   sum_vl_xmit_wait = tmp;
}
-   rsp->port_xmit_wait = cpu_to_be64(max_vl_xmit_wait);
+   if (be64_to_cpu(rsp->port_xmit_wait) > sum_vl_xmit_wait)
+   rsp->port_xmit_wait = cpu_to_be64(sum_vl_xmit_wait);
}
 }
 
@@ -2513,13 +2519,14 @@ static u64 get_error_counter_summary(struct ib_device 
*ibdev, u8 port)
return error_counter_summary;
 }
 
-static void a0_datacounters(struct hfi1_devdata *dd, struct _port_dctrs *rsp,
+static void a0_datacounters(struct hfi1_pportdata *ppd, struct _port_dctrs 
*rsp,
u32 vl_select_mask)
 {
-   if (!is_bx(dd)) {
+   if (!is_bx(ppd->dd)) {
unsigned long vl;
int vfi = 0;
u64 rcv_data, rcv_bubble, sum_vl_xmit_wait = 0;
+   u32 vl_all_mask = VL_MASK_ALL;
 
rcv_data = be64_to_cpu(rsp->port_rcv_data);
rcv_bubble = be64_to_cpu(rsp->port_rcv_bubble);
@@ -2545,10 +2552,11 @@ static void a0_datacounters(struct hfi1_devdata *dd, 
struct _port_dctrs *rsp,
vfi++;
}
vfi = 0;
-   for_each_set_bit(vl, (unsigned long *)&(vl_select_mask),
-   8 * sizeof(vl_select_mask)) {
+   for_each_set_bit(vl, (unsigned long *)&(vl_all_mask),
+8 * sizeof(vl_all_mask)) {
u64 tmp = sum_vl_xmit_wait +
-   be64_to_cpu(rsp->vls[vfi++].port_vl_xmit_wait);
+ read_port_cntr(ppd, C_TX_WAIT_VL,
+idx_from_vl(vl));
if (tmp < sum_vl_xmit_wait) {
/* we wrapped */
sum_vl_xmit_wait = (u64) ~0;
@@ -2710,7 +2718,7 @@ static int pma_get_opa_datacounters(struct opa_pma_mad 
*pmp,
vfi++;
}
 
-   a0_datacounters(dd, rsp, vl_select_mask);
+   a0_datacounters(ppd, rsp, vl_select_mask);
 
if (resp_len)
*resp_len += response_data_size;
-- 
1.7.0.7

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/18] staging/rdma/hfi1: Destroy workqueues if hfi1_register_ib_device() call returns error

2015-11-13 Thread Jubin John
From: Harish Chegondi 

Currently, if hfi1_register_ib_device() call is unsuccessful, workqueues
are not being destroyed before bailing out. This patch fixes this issue.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Harish Chegondi 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/init.c |9 -
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/init.c b/drivers/staging/rdma/hfi1/init.c
index 47a1202..54b2a4f 100644
--- a/drivers/staging/rdma/hfi1/init.c
+++ b/drivers/staging/rdma/hfi1/init.c
@@ -1308,6 +1308,7 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 {
int ret = 0, j, pidx, initfail;
struct hfi1_devdata *dd = NULL;
+   struct hfi1_pportdata *ppd;
 
/* First, lock the non-writable module parameters */
HFI1_CAP_LOCK();
@@ -1403,8 +1404,14 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (initfail || ret) {
stop_timers(dd);
flush_workqueue(ib_wq);
-   for (pidx = 0; pidx < dd->num_pports; ++pidx)
+   for (pidx = 0; pidx < dd->num_pports; ++pidx) {
hfi1_quiet_serdes(dd->pport + pidx);
+   ppd = dd->pport + pidx;
+   if (ppd->hfi1_wq) {
+   destroy_workqueue(ppd->hfi1_wq);
+   ppd->hfi1_wq = NULL;
+   }
+   }
if (!j)
hfi1_device_remove(dd);
if (!ret)
-- 
1.7.0.7

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/18] staging/rdma/hfi1: Add a credit push on diagpkt allocate fail

2015-11-13 Thread Jubin John
From: Dean Luick 

When sending a diagnostic packet, if the send context does not
have enough room, force a credit return and try again.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/diag.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/diag.c b/drivers/staging/rdma/hfi1/diag.c
index 88414d7..24baa6a 100644
--- a/drivers/staging/rdma/hfi1/diag.c
+++ b/drivers/staging/rdma/hfi1/diag.c
@@ -379,6 +379,7 @@ static ssize_t diagpkt_send(struct diag_pkt *dp)
pio_release_cb credit_cb = NULL;
void *credit_arg = NULL;
struct diagpkt_wait *wait = NULL;
+   int trycount = 0;
 
dd = hfi1_lookup(dp->unit);
if (!dd || !(dd->flags & HFI1_PRESENT) || !dd->kregbase) {
@@ -493,8 +494,15 @@ static ssize_t diagpkt_send(struct diag_pkt *dp)
credit_arg = wait;
}
 
+retry:
pbuf = sc_buffer_alloc(sc, total_len, credit_cb, credit_arg);
if (!pbuf) {
+   if (trycount == 0) {
+   /* force a credit return and try again */
+   sc_return_credits(sc);
+   trycount = 1;
+   goto retry;
+   }
/*
 * No send buffer means no credit callback.  Undo
 * the wait set-up that was done above.  We free wait
-- 
1.7.0.7

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/18] staging/rdma/hfi1: Extend quiet timeout

2015-11-13 Thread Jubin John
From: Dean Luick 

The longest quiet timeout is now 6s.  Extend the driver wait.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index be89e37..f1ee644 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -6339,9 +6339,10 @@ static int goto_offline(struct hfi1_pportdata *ppd, u8 
rem_reason)
 * depending on how the link went down.  The 8051 firmware
 * will observe the needed wait time and only move to ready
 * when that is completed.  The largest of the quiet timeouts
-* is 2.5s, so wait that long and then a bit more.
+* is 6s, so wait that long and then at least 0.5s more for
+* other transitions, and another 0.5s for a buffer.
 */
-   ret = wait_fm_ready(dd, 3000);
+   ret = wait_fm_ready(dd, 7000);
if (ret) {
dd_dev_err(dd,
"After going offline, timed out waiting for the 8051 to 
become ready to accept host requests\n");
-- 
1.7.0.7

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 12/18] staging/rdma/hfi1: Unexpected link up pkey values are not an error

2015-11-13 Thread Jubin John
From: Dean Luick 

Only warn when link up pkeys are not what we expect.  Also, allow
for the pkey to already be initialized.

Reviewed-by: Arthur Kepner 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index c83f360..a62a538 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -6725,10 +6725,10 @@ static void add_full_mgmt_pkey(struct hfi1_pportdata 
*ppd)
 {
struct hfi1_devdata *dd = ppd->dd;
 
-   /* Sanity check - ppd->pkeys[2] should be 0 */
-   if (ppd->pkeys[2] != 0)
-   dd_dev_err(dd, "%s pkey[2] already set to 0x%x, resetting it to 
0x%x\n",
-  __func__, ppd->pkeys[2], FULL_MGMT_P_KEY);
+   /* Sanity check - ppd->pkeys[2] should be 0, or already initalized */
+   if (!((ppd->pkeys[2] == 0) || (ppd->pkeys[2] == FULL_MGMT_P_KEY)))
+   dd_dev_warn(dd, "%s pkey[2] already set to 0x%x, resetting it 
to 0x%x\n",
+   __func__, ppd->pkeys[2], FULL_MGMT_P_KEY);
ppd->pkeys[2] = FULL_MGMT_P_KEY;
(void)hfi1_set_ib_cfg(ppd, HFI1_IB_CFG_PKEYS, 0);
 }
-- 
1.7.0.7

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 14/18] staging/rdma/hfi1: unknown frame messages are not errors

2015-11-13 Thread Jubin John
From: Dean Luick 

Change reported unknown frame messages into a counter.
These are informational, no errors.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c |   18 ++
 drivers/staging/rdma/hfi1/chip.h |1 +
 drivers/staging/rdma/hfi1/hfi.h  |2 ++
 3 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 2ac145f..f26b9d5 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -1417,6 +1417,17 @@ static u64 access_sw_link_up_cnt(const struct cntr_entry 
*entry, void *context,
return read_write_sw(ppd->dd, &ppd->link_up, mode, data);
 }
 
+static u64 access_sw_unknown_frame_cnt(const struct cntr_entry *entry,
+  void *context, int vl, int mode,
+  u64 data)
+{
+   struct hfi1_pportdata *ppd = (struct hfi1_pportdata *)context;
+
+   if (vl != CNTR_INVALID_VL)
+   return 0;
+   return read_write_sw(ppd->dd, &ppd->unknown_frame_count, mode, data);
+}
+
 static u64 access_sw_xmit_discards(const struct cntr_entry *entry,
void *context, int vl, int mode, u64 data)
 {
@@ -4880,6 +4891,8 @@ static struct cntr_entry port_cntrs[PORT_CNTR_LAST] = {
access_sw_link_dn_cnt),
 [C_SW_LINK_UP] = CNTR_ELEM("SwLinkUp", 0, 0, CNTR_SYNTH | CNTR_32BIT,
access_sw_link_up_cnt),
+[C_SW_UNKNOWN_FRAME] = CNTR_ELEM("UnknownFrame", 0, 0, CNTR_NORMAL,
+access_sw_unknown_frame_cnt),
 [C_SW_XMIT_DSCD] = CNTR_ELEM("XmitDscd", 0, 0, CNTR_SYNTH | CNTR_32BIT,
access_sw_xmit_discards),
 [C_SW_XMIT_DSCD_VL] = CNTR_ELEM("XmitDscdVl", 0, 0,
@@ -7227,6 +7240,11 @@ static void handle_8051_interrupt(struct hfi1_devdata 
*dd, u32 unused, u64 reg)
}
err &= ~(u64)FAILED_LNI;
}
+   /* unknown frames can happen durning LNI, just count */
+   if (err & UNKNOWN_FRAME) {
+   ppd->unknown_frame_count++;
+   err &= ~(u64)UNKNOWN_FRAME;
+   }
if (err) {
/* report remaining errors, but do not do anything */
dd_dev_err(dd, "8051 info error: %s\n",
diff --git a/drivers/staging/rdma/hfi1/chip.h b/drivers/staging/rdma/hfi1/chip.h
index a24dd09..eb22061 100644
--- a/drivers/staging/rdma/hfi1/chip.h
+++ b/drivers/staging/rdma/hfi1/chip.h
@@ -1079,6 +1079,7 @@ enum {
C_RX_WORDS,
C_SW_LINK_DOWN,
C_SW_LINK_UP,
+   C_SW_UNKNOWN_FRAME,
C_SW_XMIT_DSCD,
C_SW_XMIT_DSCD_VL,
C_SW_XMIT_CSTR_ERR,
diff --git a/drivers/staging/rdma/hfi1/hfi.h b/drivers/staging/rdma/hfi1/hfi.h
index 44a7124..4558a19 100644
--- a/drivers/staging/rdma/hfi1/hfi.h
+++ b/drivers/staging/rdma/hfi1/hfi.h
@@ -720,6 +720,8 @@ struct hfi1_pportdata {
u64 link_downed;
/* number of times link retrained successfully */
u64 link_up;
+   /* number of times a link unknown frame was reported */
+   u64 unknown_frame_count;
/* port_ltp_crc_mode is returned in 'portinfo' MADs */
u16 port_ltp_crc_mode;
/* port_crc_mode_enabled is the crc we support */
-- 
1.7.0.7

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/18] staging/rdma/hfi1: Correctly limit VLs against SDMA engines

2015-11-13 Thread Jubin John
From: Dean Luick 

Correctly reduce the number of VLs when limited by the number
of SDMA engines.

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index f1ee644..b0c1e2b 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -10574,9 +10574,9 @@ struct hfi1_devdata *hfi1_init_dd(struct pci_dev *pdev,
/* insure num_vls isn't larger than number of sdma engines */
if (HFI1_CAP_IS_KSET(SDMA) && num_vls > dd->chip_sdma_engines) {
dd_dev_err(dd, "num_vls %u too large, using %u VLs\n",
-   num_vls, HFI1_MAX_VLS_SUPPORTED);
-   ppd->vls_supported = num_vls = HFI1_MAX_VLS_SUPPORTED;
-   ppd->vls_operational = ppd->vls_supported;
+  num_vls, dd->chip_sdma_engines);
+   num_vls = dd->chip_sdma_engines;
+   ppd->vls_supported = dd->chip_sdma_engines;
}
 
/*
-- 
1.7.0.7

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 15/18] staging/rdma/hfi1: Consider VL15 MTU also when calculating the maximum VL MTU

2015-11-13 Thread Jubin John
From: Harish Chegondi 

Currently, only MTUs of VLs 0-7 are checked when calculating the maximum VL
MTU which is used to set the port MTU capability in DCC_CFG_PORT_CONFIG CSR
This can cause a port MTU capability to be set to 0 if MTUs of VLs 0-7 is 0
This would affect the VL15 traffic.

Reviewed-by: Dean Luick 
Reviewed-by: Arthur Kepner 
Signed-off-by: Harish Chegondi 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index f26b9d5..043bfc6 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -9367,7 +9367,8 @@ u32 lrh_max_header_bytes(struct hfi1_devdata *dd)
 static void set_send_length(struct hfi1_pportdata *ppd)
 {
struct hfi1_devdata *dd = ppd->dd;
-   u32 max_hb = lrh_max_header_bytes(dd), maxvlmtu = 0, dcmtu;
+   u32 max_hb = lrh_max_header_bytes(dd), dcmtu;
+   u32 maxvlmtu = dd->vld[15].mtu;
u64 len1 = 0, len2 = (((dd->vld[15].mtu + max_hb) >> 2)
  & SEND_LEN_CHECK1_LEN_VL15_MASK) <<
SEND_LEN_CHECK1_LEN_VL15_SHIFT;
-- 
1.7.0.7

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 17/18] staging/rdma/hfi1: Adding counter resolutions for DataPortCounters

2015-11-13 Thread Jubin John
From: Andrea Lowe 

Changing the 32-bit reserved field in opa_port_data_counters_msg
to the new 'resolution' field. PMA will use resolutions to right-
shift values for LocalLinkIntegrity and LinkErrorRecovery when
computing the ErrorCounterSummary for a DataPortCounters request.

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Andrea Lowe 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/mad.c |   38 ++
 1 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/mad.c b/drivers/staging/rdma/hfi1/mad.c
index e151359..11a571a 100644
--- a/drivers/staging/rdma/hfi1/mad.c
+++ b/drivers/staging/rdma/hfi1/mad.c
@@ -2076,13 +2076,20 @@ struct opa_aggregate {
u8 data[0];
 };
 
-/* Request contains first two fields, response contains those plus the rest */
+#define MSK_LLI 0x00f0
+#define MSK_LLI_SFT 4
+#define MSK_LER 0x000f
+#define MSK_LER_SFT 0
+#define ADD_LLI 8
+#define ADD_LER 2
+
+/* Request contains first three fields, response contains those plus the rest 
*/
 struct opa_port_data_counters_msg {
__be64 port_select_mask[4];
__be32 vl_select_mask;
+   __be32 resolution;
 
/* Response fields follow */
-   __be32 reserved1;
struct _port_dctrs {
u8 port_number;
u8 reserved2[3];
@@ -2480,7 +2487,8 @@ static int pma_get_opa_portstatus(struct opa_pma_mad *pmp,
return reply((struct ib_mad_hdr *)pmp);
 }
 
-static u64 get_error_counter_summary(struct ib_device *ibdev, u8 port)
+static u64 get_error_counter_summary(struct ib_device *ibdev, u8 port,
+u8 res_lli, u8 res_ler)
 {
struct hfi1_devdata *dd = dd_from_ibdev(ibdev);
struct hfi1_ibport *ibp = to_iport(ibdev, port);
@@ -2496,14 +2504,14 @@ static u64 get_error_counter_summary(struct ib_device 
*ibdev, u8 port)
CNTR_INVALID_VL);
error_counter_summary += read_dev_cntr(dd, C_DC_RMT_PHY_ERR,
CNTR_INVALID_VL);
-   error_counter_summary += read_dev_cntr(dd, C_DC_TX_REPLAY,
-   CNTR_INVALID_VL);
-   error_counter_summary += read_dev_cntr(dd, C_DC_RX_REPLAY,
-   CNTR_INVALID_VL);
-   error_counter_summary += read_dev_cntr(dd, C_DC_SEQ_CRC_CNT,
-   CNTR_INVALID_VL);
-   error_counter_summary += read_dev_cntr(dd, C_DC_REINIT_FROM_PEER_CNT,
-   CNTR_INVALID_VL);
+   /* local link integrity must be right-shifted by the lli resolution */
+   tmp = read_dev_cntr(dd, C_DC_RX_REPLAY, CNTR_INVALID_VL);
+   tmp += read_dev_cntr(dd, C_DC_TX_REPLAY, CNTR_INVALID_VL);
+   error_counter_summary += (tmp >> res_lli);
+   /* link error recovery must b right-shifted by the ler resolution */
+   tmp = read_dev_cntr(dd, C_DC_SEQ_CRC_CNT, CNTR_INVALID_VL);
+   tmp += read_dev_cntr(dd, C_DC_REINIT_FROM_PEER_CNT, CNTR_INVALID_VL);
+   error_counter_summary += (tmp >> res_ler);
error_counter_summary += read_dev_cntr(dd, C_DC_RCV_ERR,
CNTR_INVALID_VL);
error_counter_summary += read_dev_cntr(dd, C_RCV_OVF, CNTR_INVALID_VL);
@@ -2583,6 +2591,7 @@ static int pma_get_opa_datacounters(struct opa_pma_mad 
*pmp,
u32 num_ports;
u8 num_pslm;
u8 lq, num_vls;
+   u8 res_lli, res_ler;
u64 port_mask;
unsigned long port_num;
unsigned long vl;
@@ -2593,6 +2602,10 @@ static int pma_get_opa_datacounters(struct opa_pma_mad 
*pmp,
num_pslm = hweight64(be64_to_cpu(req->port_select_mask[3]));
num_vls = hweight32(be32_to_cpu(req->vl_select_mask));
vl_select_mask = be32_to_cpu(req->vl_select_mask);
+   res_lli = (u8)(be32_to_cpu(req->resolution) & MSK_LLI) >> MSK_LLI_SFT;
+   res_lli = res_lli ? res_lli + ADD_LLI : 0;
+   res_ler = (u8)(be32_to_cpu(req->resolution) & MSK_LER) >> MSK_LER_SFT;
+   res_ler = res_ler ? res_ler + ADD_LER : 0;
 
if (num_ports != 1 || (vl_select_mask & ~VL_MASK_ALL)) {
pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;
@@ -2663,7 +2676,8 @@ static int pma_get_opa_datacounters(struct opa_pma_mad 
*pmp,
cpu_to_be64(read_dev_cntr(dd, C_DC_RCV_BCN, CNTR_INVALID_VL));
 
rsp->port_error_counter_summary =
-   cpu_to_be64(get_error_counter_summary(ibdev, port));
+   cpu_to_be64(get_error_counter_summary(ibdev, port,
+ res_lli, res_ler));
 
vlinfo = &(rsp->vls[0]);
vfi = 0;
-- 
1.7.0.7

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/18] staging/rdma/hfi1: Adds software counters for bitfields within various error status fields

2015-11-13 Thread Jubin John
From: Joel Rosenzweig 

Provides error status counters for CceErrStatus, Send*ErrStatus,
RcvErrStatus and MISC_ERR_STATUS

Reviewed-by: Mitko Haralanov 
Reviewed-by: Mike Marciniszyn 
Signed-off-by: Joel Rosenzweig 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c | 3185 +-
 drivers/staging/rdma/hfi1/chip.h |  269 
 drivers/staging/rdma/hfi1/hfi.h  |   34 +
 3 files changed, 3487 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index b0c1e2b..c83f360 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -663,7 +663,7 @@ static struct flag_table egress_err_info_flags[] = {
  */
 #define SES(name) SEND_ERR_STATUS_SEND_##name##_ERR_SMASK
 static struct flag_table send_err_status_flags[] = {
-/* 0*/ FLAG_ENTRY0("SDmaRpyTagErr", SES(CSR_PARITY)),
+/* 0*/ FLAG_ENTRY0("SendCsrParityErr", SES(CSR_PARITY)),
 /* 1*/ FLAG_ENTRY0("SendCsrReadBadAddrErr", SES(CSR_READ_BAD_ADDR)),
 /* 2*/ FLAG_ENTRY0("SendCsrWriteBadAddrErr", SES(CSR_WRITE_BAD_ADDR))
 };
@@ -1538,6 +1538,2336 @@ static u64 access_sw_send_schedule(const struct 
cntr_entry *entry,
return dd->verbs_dev.n_send_schedule;
 }
 
+/* Software counters for the error status bits within MISC_ERR_STATUS */
+static u64 access_misc_pll_lock_fail_err_cnt(const struct cntr_entry *entry,
+void *context, int vl, int mode,
+u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[12];
+}
+
+static u64 access_misc_mbist_fail_err_cnt(const struct cntr_entry *entry,
+ void *context, int vl, int mode,
+ u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[11];
+}
+
+static u64 access_misc_invalid_eep_cmd_err_cnt(const struct cntr_entry *entry,
+  void *context, int vl, int mode,
+  u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[10];
+}
+
+static u64 access_misc_efuse_done_parity_err_cnt(const struct cntr_entry 
*entry,
+void *context, int vl,
+int mode, u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[9];
+}
+
+static u64 access_misc_efuse_write_err_cnt(const struct cntr_entry *entry,
+  void *context, int vl, int mode,
+  u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[8];
+}
+
+static u64 access_misc_efuse_read_bad_addr_err_cnt(
+   const struct cntr_entry *entry,
+   void *context, int vl, int mode, u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[7];
+}
+
+static u64 access_misc_efuse_csr_parity_err_cnt(const struct cntr_entry *entry,
+   void *context, int vl,
+   int mode, u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[6];
+}
+
+static u64 access_misc_fw_auth_failed_err_cnt(const struct cntr_entry *entry,
+ void *context, int vl, int mode,
+ u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[5];
+}
+
+static u64 access_misc_key_mismatch_err_cnt(const struct cntr_entry *entry,
+   void *context, int vl, int mode,
+   u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[4];
+}
+
+static u64 access_misc_sbus_write_failed_err_cnt(const struct cntr_entry 
*entry,
+void *context, int vl,
+int mode, u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[3];
+}
+
+static u64 access_misc_csr_write_bad_addr_err_cnt(
+   const struct cntr_entry *entry,
+   void *context, int vl, int mode, u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->mi

Re: [PATCH 01/13] staging/rdma/hfi1: Use BIT macro

2015-11-16 Thread Jubin John
On Sat, Nov 14, 2015 at 12:41:02PM +0530, Sudip Mukherjee wrote:
> On Fri, Nov 13, 2015 at 11:09:22AM -0500, Jubin John wrote:
> > On Fri, Nov 13, 2015 at 06:45:58PM +0530, Sudip Mukherjee wrote:
> > > On Wed, Nov 11, 2015 at 02:33:21AM -0500, Jubin John wrote:
> > > > This patch fixes the checkpatch issue:
> > > > CHECK: Prefer using the BIT macro
> > > > 
> > > > Reviewed-by: Dean Luick 
> > > > Reviewed-by: Ira Weiny 
> > > > Reviewed-by: Mike Marciniszyn 
> > > > Signed-off-by: Jubin John 
> > > > ---
> > > 
> > > >  
> > > > diff --git a/drivers/staging/rdma/hfi1/init.c 
> > > > b/drivers/staging/rdma/hfi1/init.c
> > > > index 8666f3a..680f877 100644
> > > > --- a/drivers/staging/rdma/hfi1/init.c
> > > > +++ b/drivers/staging/rdma/hfi1/init.c
> > > > @@ -252,7 +252,7 @@ struct hfi1_ctxtdata *hfi1_create_ctxtdata(struct 
> > > > hfi1_pportdata *ppd, u32 ctxt)
> > > > /* Validate and initialize Rcv Hdr Q variables */
> > > > if (rcvhdrcnt % HDRQ_INCREMENT) {
> > > > dd_dev_err(dd,
> > > > -  "ctxt%u: header queue count %d must 
> > > > be divisible by %d\n",
> > > > +  "ctxt%u: header queue count %d must 
> > > > be divisible by %lud\n",
> > > 
> > > This is an unrelated change. If you are sending the series based on
> > > Dan's comment on 12/13 then please remove this also.
> > > 
> > This is not an unrelated change. This was needed due to the use of the
> > BIT macro for HDRQ_INCREMENT in chip.h.
> > Otherwise, the following warning is shown during the build:
> > drivers/staging/rdma/hfi1/init.c: In function ‘hfi1_create_ctxtdata’:
> > drivers/staging/rdma/hfi1/init.c:254:4: warning: format ‘%u’ expects
> > argument of type ‘unsigned int’, but argument 6 has type
> > ‘long unsigned int’ [-Wformat=]
> > dd_dev_err(dd,
> 
> Then it should have better been mentioned in the commit message.

Ok, I will update the commit message in v2.

Thanks,
Jubin John
> 
> regards
> sudip
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 10/13] staging/rdma/hfi1: adding per SDMA engine stats to hfistats

2015-11-16 Thread Jubin John
On Wed, Nov 11, 2015 at 11:22:15AM +0300, Dan Carpenter wrote:
> On Wed, Nov 11, 2015 at 02:33:30AM -0500, Jubin John wrote:
> > @@ -8288,6 +8367,21 @@ static int init_cntrs(struct hfi1_devdata *dd)
> > dd->ndevcntrs++;
> > index++;
> > }
> > +   } else if (dev_cntrs[i].flags & CNTR_SDMA) {
> > +   hfi1_dbg_early(
> > +  "\tProcessing per SDE counters chip 
> > enginers %u\n",
> > +  dd->chip_sdma_engines);
> > +   dev_cntrs[i].offset = index;
> > +   for (j = 0; j < dd->chip_sdma_engines; j++) {
> > +   memset(name, '\0', C_MAX_NAME);
> 
> This patch is ok, but none of the memsets in this function are needed.
> You could remove them in a later patch.
> 
> > +   snprintf(name, C_MAX_NAME, "%s%d",
> > +dev_cntrs[i].name, j);
> > +   sz += strlen(name);
> > +   sz++;
> > +   hfi1_dbg_early("\t\t%s\n", name);
> 
> We're basically just trying to calculate a bunch of strlen()s but there
> is a lot of extra code to generate debug output.  It would be better to
> remove it in a later patch.
> 
> > +   dd->ndevcntrs++;
> > +       index++;
> > +   }
> 
> regards,
> dan carpenter

Hi Dan,

I will let this patch stand as-is and follow up with a clean up patch
to remove the memsets and the debug code.

Thanks,
Jubin John 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 00/13] staging/rdma/hfi1: Driver cleanup and misc fixes

2015-11-16 Thread Jubin John
Rebased this series on top of latest staging-next branch

Changes in v2:
01/13: Updated commit message with more information about changes in patch
04/13: Updated patch subject with "hfi1" instead of "hfi"
07/13: Refreshed patch based on new hfi patches in staging-next
12/13: Changed logic based on Dan's suggestions in
   http://marc.info/?l=linux-driver-devel&m=144723149431368&w=2 

Dean Luick (4):
  staging/rdma/hfi1: Fix downgrade race
  staging/rdma/hfi1: Remove unneeded variable index
  staging/rdma/hfi1: Read EFI variable for device description
  staging/rdma/hfi1: Adjust EPROM partitions, add EPROM commands

Harish Chegondi (1):
  staging/rdma/hfi1: Move s_sde to the read mostly portion of the
hfi1_qp structure

Ira Weiny (1):
  staging/rdma/hfi1: Remove rcv bubbles code

Jubin John (3):
  staging/rdma/hfi1: Use BIT macro
  staging/rdma/hfi1: Add space between concatenated string elements
  staging/rdma/hfi1: Change default krcvqs

Mark F. Brown (1):
  staging/rdma/hfi1: change krcvqs module parameter type from byte to
uint

Mike Marciniszyn (1):
  staging/rdma/hfi1: rework is_a0() and is_bx()

Vennila Megavannan (2):
  staging/rdma/hfi1: remove RxCtxRHQS from hfi1stats
  staging/rdma/hfi1: adding per SDMA engine stats to hfistats

 drivers/staging/rdma/hfi1/Makefile |2 +-
 drivers/staging/rdma/hfi1/chip.c   |  252 +---
 drivers/staging/rdma/hfi1/chip.h   |   55 ---
 drivers/staging/rdma/hfi1/chip_registers.h |2 +-
 drivers/staging/rdma/hfi1/common.h |4 +-
 drivers/staging/rdma/hfi1/diag.c   |4 +-
 drivers/staging/rdma/hfi1/driver.c |2 +-
 drivers/staging/rdma/hfi1/efivar.c |  169 +++
 drivers/staging/rdma/hfi1/efivar.h |   60 +++
 drivers/staging/rdma/hfi1/eprom.c  |  119 --
 drivers/staging/rdma/hfi1/file_ops.c   |   18 +--
 drivers/staging/rdma/hfi1/firmware.c   |2 +-
 drivers/staging/rdma/hfi1/hfi.h|   29 ++--
 drivers/staging/rdma/hfi1/init.c   |8 +-
 drivers/staging/rdma/hfi1/mad.c|   68 +---
 drivers/staging/rdma/hfi1/pcie.c   |4 +-
 drivers/staging/rdma/hfi1/qp.h |2 +-
 drivers/staging/rdma/hfi1/qsfp.h   |   10 +-
 drivers/staging/rdma/hfi1/sdma.c   |   17 ++-
 drivers/staging/rdma/hfi1/sdma.h   |7 +
 drivers/staging/rdma/hfi1/verbs.h  |8 +-
 include/uapi/rdma/hfi/hfi1_user.h  |   10 +-
 22 files changed, 587 insertions(+), 265 deletions(-)
 create mode 100644 drivers/staging/rdma/hfi1/efivar.c
 create mode 100644 drivers/staging/rdma/hfi1/efivar.h

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 06/13] staging/rdma/hfi1: Move s_sde to the read mostly portion of the hfi1_qp structure

2015-11-16 Thread Jubin John
From: Harish Chegondi 

This would reduce L2 cache misses on s_sde in the _hfi1_schedule_send
function when invoked from post_send thereby improving performance of
post_send.

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Harish Chegondi 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/verbs.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/verbs.h 
b/drivers/staging/rdma/hfi1/verbs.h
index 600bd1b..638094d 100644
--- a/drivers/staging/rdma/hfi1/verbs.h
+++ b/drivers/staging/rdma/hfi1/verbs.h
@@ -441,6 +441,7 @@ struct hfi1_qp {
struct hfi1_swqe *s_wq;  /* send work queue */
struct hfi1_mmap_info *ip;
struct ahg_ib_header *s_hdr; /* next packet header to send */
+   struct sdma_engine *s_sde; /* current sde */
u8 s_sc;/* SC[0..4] for next packet */
unsigned long timeout_jiffies;  /* computed from timeout */
 
@@ -504,7 +505,6 @@ struct hfi1_qp {
struct hfi1_swqe *s_wqe;
struct hfi1_sge_state s_sge; /* current send request data */
struct hfi1_mregion *s_rdma_mr;
-   struct sdma_engine *s_sde; /* current sde */
u32 s_cur_size; /* size of send packet in bytes */
u32 s_len;  /* total length of s_sge */
u32 s_rdma_read_len;/* total length of s_rdma_read_sge */
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 03/13] staging/rdma/hfi1: remove RxCtxRHQS from hfi1stats

2015-11-16 Thread Jubin John
From: Vennila Megavannan 

Removed the RxCtxRHQS counter being dumped into dev_cntrs

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Vennila Megavannan 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c   |2 --
 drivers/staging/rdma/hfi1/chip.h   |1 -
 drivers/staging/rdma/hfi1/chip_registers.h |1 -
 3 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 6c942f6..41d8864 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -1587,8 +1587,6 @@ static struct cntr_entry dev_cntrs[DEV_CNTR_LAST] = {
 [C_RX_TID_FLGMS] = RXE32_DEV_CNTR_ELEM(RxTidFLGMs,
RCV_TID_FLOW_GEN_MISMATCH_CNT,
CNTR_NORMAL),
-[C_RX_CTX_RHQS] = RXE32_DEV_CNTR_ELEM(RxCtxRHQS, RCV_CONTEXT_RHQ_STALL,
-   CNTR_NORMAL),
 [C_RX_CTX_EGRS] = RXE32_DEV_CNTR_ELEM(RxCtxEgrS, RCV_CONTEXT_EGR_STALL,
CNTR_NORMAL),
 [C_RCV_TID_FLSMS] = RXE32_DEV_CNTR_ELEM(RxTidFLSMs,
diff --git a/drivers/staging/rdma/hfi1/chip.h b/drivers/staging/rdma/hfi1/chip.h
index cb923c1..d7f3f81 100644
--- a/drivers/staging/rdma/hfi1/chip.h
+++ b/drivers/staging/rdma/hfi1/chip.h
@@ -722,7 +722,6 @@ enum {
C_RX_TID_FULL,
C_RX_TID_INVALID,
C_RX_TID_FLGMS,
-   C_RX_CTX_RHQS,
C_RX_CTX_EGRS,
C_RCV_TID_FLSMS,
C_CCE_PCI_CR_ST,
diff --git a/drivers/staging/rdma/hfi1/chip_registers.h 
b/drivers/staging/rdma/hfi1/chip_registers.h
index bf45de2..5056c84 100644
--- a/drivers/staging/rdma/hfi1/chip_registers.h
+++ b/drivers/staging/rdma/hfi1/chip_registers.h
@@ -379,7 +379,6 @@
 #define DC_LCB_STS_ROUND_TRIP_LTP_CNT (DC_LCB_CSRS + 0x04B0)
 #define RCV_BUF_OVFL_CNT 10
 #define RCV_CONTEXT_EGR_STALL 22
-#define RCV_CONTEXT_RHQ_STALL 21
 #define RCV_DATA_PKT_CNT 0
 #define RCV_DWORD_CNT 1
 #define RCV_TID_FLOW_GEN_MISMATCH_CNT 20
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 01/13] staging/rdma/hfi1: Use BIT macro

2015-11-16 Thread Jubin John
This patch fixes the checkpatch issue:
CHECK: Prefer using the BIT macro

Use of BIT macro for HDRQ_INCREMENT in chip.h causes a change in
format specifier for error message in init.c in order to avoid a
build warning.

Reviewed-by: Dean Luick 
Reviewed-by: Ira Weiny 
Reviewed-by: Mike Marciniszyn 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.h   |   48 ++--
 drivers/staging/rdma/hfi1/common.h |4 +-
 drivers/staging/rdma/hfi1/diag.c   |4 +-
 drivers/staging/rdma/hfi1/hfi.h|   22 
 drivers/staging/rdma/hfi1/init.c   |2 +-
 drivers/staging/rdma/hfi1/mad.c|4 +-
 drivers/staging/rdma/hfi1/qp.h |2 +-
 drivers/staging/rdma/hfi1/qsfp.h   |   10 +++---
 drivers/staging/rdma/hfi1/sdma.c   |8 +++---
 drivers/staging/rdma/hfi1/verbs.h  |6 ++--
 10 files changed, 55 insertions(+), 55 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.h b/drivers/staging/rdma/hfi1/chip.h
index d74aed8..cb923c1 100644
--- a/drivers/staging/rdma/hfi1/chip.h
+++ b/drivers/staging/rdma/hfi1/chip.h
@@ -242,18 +242,18 @@
 #define HCMD_SUCCESS 2
 
 /* DC_DC8051_DBG_ERR_INFO_SET_BY_8051.ERROR - error flags */
-#define SPICO_ROM_FAILED   (1 <<  0)
-#define UNKNOWN_FRAME  (1 <<  1)
-#define TARGET_BER_NOT_MET (1 <<  2)
-#define FAILED_SERDES_INTERNAL_LOOPBACK (1 <<  3)
-#define FAILED_SERDES_INIT (1 <<  4)
-#define FAILED_LNI_POLLING (1 <<  5)
-#define FAILED_LNI_DEBOUNCE(1 <<  6)
-#define FAILED_LNI_ESTBCOMM(1 <<  7)
-#define FAILED_LNI_OPTEQ   (1 <<  8)
-#define FAILED_LNI_VERIFY_CAP1 (1 <<  9)
-#define FAILED_LNI_VERIFY_CAP2 (1 << 10)
-#define FAILED_LNI_CONFIGLT(1 << 11)
+#define SPICO_ROM_FAILED   BIT(0)
+#define UNKNOWN_FRAME  BIT(1)
+#define TARGET_BER_NOT_MET BIT(2)
+#define FAILED_SERDES_INTERNAL_LOOPBACKBIT(3)
+#define FAILED_SERDES_INIT BIT(4)
+#define FAILED_LNI_POLLING BIT(5)
+#define FAILED_LNI_DEBOUNCEBIT(6)
+#define FAILED_LNI_ESTBCOMMBIT(7)
+#define FAILED_LNI_OPTEQ   BIT(8)
+#define FAILED_LNI_VERIFY_CAP1 BIT(9)
+#define FAILED_LNI_VERIFY_CAP2 BIT(10)
+#define FAILED_LNI_CONFIGLTBIT(11)
 
 #define FAILED_LNI (FAILED_LNI_POLLING | FAILED_LNI_DEBOUNCE \
| FAILED_LNI_ESTBCOMM | FAILED_LNI_OPTEQ \
@@ -262,16 +262,16 @@
| FAILED_LNI_CONFIGLT)
 
 /* DC_DC8051_DBG_ERR_INFO_SET_BY_8051.HOST_MSG - host message flags */
-#define HOST_REQ_DONE (1 << 0)
-#define BC_PWR_MGM_MSG(1 << 1)
-#define BC_SMA_MSG(1 << 2)
-#define BC_BCC_UNKOWN_MSG (1 << 3)
-#define BC_IDLE_UNKNOWN_MSG   (1 << 4)
-#define EXT_DEVICE_CFG_REQ(1 << 5)
-#define VERIFY_CAP_FRAME  (1 << 6)
-#define LINKUP_ACHIEVED   (1 << 7)
-#define LINK_GOING_DOWN   (1 << 8)
-#define LINK_WIDTH_DOWNGRADED  (1 << 9)
+#define HOST_REQ_DONE  BIT(0)
+#define BC_PWR_MGM_MSG BIT(1)
+#define BC_SMA_MSG BIT(2)
+#define BC_BCC_UNKNOWN_MSG BIT(3)
+#define BC_IDLE_UNKNOWN_MSGBIT(4)
+#define EXT_DEVICE_CFG_REQ BIT(5)
+#define VERIFY_CAP_FRAME   BIT(6)
+#define LINKUP_ACHIEVEDBIT(7)
+#define LINK_GOING_DOWNBIT(8)
+#define LINK_WIDTH_DOWNGRADED  BIT(9)
 
 /* DC_DC8051_CFG_EXT_DEV_1.REQ_TYPE - 8051 host requests */
 #define HREQ_LOAD_CONFIG   0x01
@@ -335,14 +335,14 @@
  * the CSR fields hold multiples of this value.
  */
 #define RCV_SHIFT 3
-#define RCV_INCREMENT (1 << RCV_SHIFT)
+#define RCV_INCREMENT BIT(RCV_SHIFT)
 
 /*
  * Receive header queue entry increment - the CSR holds multiples of
  * this value.
  */
 #define HDRQ_SIZE_SHIFT 5
-#define HDRQ_INCREMENT (1 << HDRQ_SIZE_SHIFT)
+#define HDRQ_INCREMENT BIT(HDRQ_SIZE_SHIFT)
 
 /*
  * Freeze handling flags
diff --git a/drivers/staging/rdma/hfi1/common.h 
b/drivers/staging/rdma/hfi1/common.h
index 5dd9272..e4b1dc6 100644
--- a/drivers/staging/rdma/hfi1/common.h
+++ b/drivers/staging/rdma/hfi1/common.h
@@ -349,10 +349,10 @@ struct hfi1_message_header {
 #define HFI1_QPN_MASK 0xFF
 #define HFI1_FECN_SHIFT 31
 #define HFI1_FECN_MASK 1
-#define HFI1_FECN_SMASK (1 << HFI1_FECN_SHIFT)
+#define HFI1_FECN_SMASK BIT(HFI1_FECN_SHIFT)
 #define HFI1_BECN_SHIFT 30
 #define HFI1_BECN_MASK 1
-#define HFI1_BECN_SMASK (1 << HFI1_BECN_SHIFT)
+#define HFI1_BECN_SMASK BIT(HFI1_BECN_SHIFT)
 #define HFI1_MULTICAST_LID_BASE 0xC000
 
 static inline __u64 rhf_to_cpu(const __le32 *rbuf)
diff --git a/drivers/staging/rdma/hfi1/diag.c b/drivers/staging/rdma/hfi1/diag.c
index 88414d7..076a419 100644
--- a/drivers/staging/rdma/hfi1/diag

[PATCH v2 02/13] staging/rdma/hfi1: Fix downgrade race

2015-11-16 Thread Jubin John
From: Dean Luick 

A link downgrade can race with link up. Avoid the race
in two ways. First, by having the downgrade application logic
take the link state mutex for all of its checking. Second, by
waiting for the link to move out of the going up state.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c |   31 ---
 1 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index d858f36..6c942f6 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -3907,18 +3907,32 @@ void handle_verify_cap(struct work_struct *work)
  */
 void apply_link_downgrade_policy(struct hfi1_pportdata *ppd, int 
refresh_widths)
 {
-   int skip = 1;
int do_bounce = 0;
-   u16 lwde = ppd->link_width_downgrade_enabled;
+   int tries;
+   u16 lwde;
u16 tx, rx;
 
+   /* use the hls lock to avoid a race with actual link up */
+   tries = 0;
+retry:
mutex_lock(&ppd->hls_lock);
/* only apply if the link is up */
-   if (ppd->host_link_state & HLS_UP)
-   skip = 0;
-   mutex_unlock(&ppd->hls_lock);
-   if (skip)
-   return;
+   if (!(ppd->host_link_state & HLS_UP)) {
+   /* still going up..wait and retry */
+   if (ppd->host_link_state & HLS_GOING_UP) {
+   if (++tries < 1000) {
+   mutex_unlock(&ppd->hls_lock);
+   usleep_range(100, 120); /* arbitrary */
+   goto retry;
+   }
+   dd_dev_err(ppd->dd,
+  "%s: giving up waiting for link state 
change\n",
+  __func__);
+   }
+   goto done;
+   }
+
+   lwde = ppd->link_width_downgrade_enabled;
 
if (refresh_widths) {
get_link_widths(ppd->dd, &tx, &rx);
@@ -3956,6 +3970,9 @@ void apply_link_downgrade_policy(struct hfi1_pportdata 
*ppd, int refresh_widths)
do_bounce = 1;
}
 
+done:
+   mutex_unlock(&ppd->hls_lock);
+
if (do_bounce) {
set_link_down_reason(ppd, OPA_LINKDOWN_REASON_WIDTH_POLICY, 0,
  OPA_LINKDOWN_REASON_WIDTH_POLICY);
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 08/13] staging/rdma/hfi1: change krcvqs module parameter type from byte to uint

2015-11-16 Thread Jubin John
From: Mark F. Brown 

The krcvqs parameter is displayed incorrectly in sysfs.
The workaround is to set the param type as uint.

Reviewed-by: Mike Marciniszyn 
Reviewed-by: Mitko Haralanov 
Signed-off-by: Mark F. Brown 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/hfi.h  |2 +-
 drivers/staging/rdma/hfi1/init.c |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/hfi.h b/drivers/staging/rdma/hfi1/hfi.h
index fe751bb..a8a11da 100644
--- a/drivers/staging/rdma/hfi1/hfi.h
+++ b/drivers/staging/rdma/hfi1/hfi.h
@@ -1625,7 +1625,7 @@ extern unsigned int hfi1_cu;
 extern unsigned int user_credit_return_threshold;
 extern uint num_rcv_contexts;
 extern unsigned n_krcvqs;
-extern u8 krcvqs[];
+extern uint krcvqs[];
 extern int krcvqsset;
 extern uint kdeth_qp;
 extern uint loopback;
diff --git a/drivers/staging/rdma/hfi1/init.c b/drivers/staging/rdma/hfi1/init.c
index 3f5a409..7fa775a 100644
--- a/drivers/staging/rdma/hfi1/init.c
+++ b/drivers/staging/rdma/hfi1/init.c
@@ -87,9 +87,9 @@ module_param_named(num_rcv_contexts, num_rcv_contexts, uint, 
S_IRUGO);
 MODULE_PARM_DESC(
num_rcv_contexts, "Set max number of user receive contexts to use");
 
-u8 krcvqs[RXE_NUM_DATA_VL];
+uint krcvqs[RXE_NUM_DATA_VL];
 int krcvqsset;
-module_param_array(krcvqs, byte, &krcvqsset, S_IRUGO);
+module_param_array(krcvqs, uint, &krcvqsset, S_IRUGO);
 MODULE_PARM_DESC(krcvqs, "Array of the number of kernel receive queues by VL");
 
 /* computed based on above array */
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 05/13] staging/rdma/hfi1: Add space between concatenated string elements

2015-11-16 Thread Jubin John
Space between concantenated string elements is more human
readable and fixes the checkpatch issue:
CHECK: Concatenated strings should use spaces between elements

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c   |   10 +-
 drivers/staging/rdma/hfi1/driver.c |2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 41d8864..7c58c7b 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -8891,8 +8891,8 @@ static int request_intx_irq(struct hfi1_devdata *dd)
 {
int ret;
 
-   snprintf(dd->intx_name, sizeof(dd->intx_name), DRIVER_NAME"_%d",
-   dd->unit);
+   snprintf(dd->intx_name, sizeof(dd->intx_name), DRIVER_NAME "_%d",
+dd->unit);
ret = request_irq(dd->pcidev->irq, general_interrupt,
  IRQF_SHARED, dd->intx_name, dd);
if (ret)
@@ -8994,7 +8994,7 @@ static int request_msix_irqs(struct hfi1_devdata *dd)
handler = general_interrupt;
arg = dd;
snprintf(me->name, sizeof(me->name),
-   DRIVER_NAME"_%d", dd->unit);
+DRIVER_NAME "_%d", dd->unit);
err_info = "general";
} else if (first_sdma <= i && i < last_sdma) {
idx = i - first_sdma;
@@ -9002,7 +9002,7 @@ static int request_msix_irqs(struct hfi1_devdata *dd)
handler = sdma_interrupt;
arg = sde;
snprintf(me->name, sizeof(me->name),
-   DRIVER_NAME"_%d sdma%d", dd->unit, idx);
+DRIVER_NAME "_%d sdma%d", dd->unit, idx);
err_info = "sdma";
remap_sdma_interrupts(dd, idx, i);
} else if (first_rx <= i && i < last_rx) {
@@ -9022,7 +9022,7 @@ static int request_msix_irqs(struct hfi1_devdata *dd)
thread = receive_context_thread;
arg = rcd;
snprintf(me->name, sizeof(me->name),
-   DRIVER_NAME"_%d kctxt%d", dd->unit, idx);
+DRIVER_NAME "_%d kctxt%d", dd->unit, idx);
err_info = "receive context";
remap_intr(dd, IS_RCVAVAIL_START + idx, i);
} else {
diff --git a/drivers/staging/rdma/hfi1/driver.c 
b/drivers/staging/rdma/hfi1/driver.c
index 72ab5e1..3938840 100644
--- a/drivers/staging/rdma/hfi1/driver.c
+++ b/drivers/staging/rdma/hfi1/driver.c
@@ -158,7 +158,7 @@ const char *get_unit_name(int unit)
 {
static char iname[16];
 
-   snprintf(iname, sizeof(iname), DRIVER_NAME"_%u", unit);
+   snprintf(iname, sizeof(iname), DRIVER_NAME "_%u", unit);
return iname;
 }
 
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 04/13] staging/rdma/hfi1: Remove rcv bubbles code

2015-11-16 Thread Jubin John
From: Ira Weiny 

Rcv bubbles were improperly calculated for HFIs, fix that here.

Reviewed-by: Mike Marciniszyn 
Reviewed-by: Arthur Kepner 
Signed-off-by: Ira Weiny 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/mad.c |   64 +-
 1 files changed, 2 insertions(+), 62 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/mad.c b/drivers/staging/rdma/hfi1/mad.c
index 1baeb01..69c5d81 100644
--- a/drivers/staging/rdma/hfi1/mad.c
+++ b/drivers/staging/rdma/hfi1/mad.c
@@ -2271,34 +2271,8 @@ static void a0_portstatus(struct hfi1_pportdata *ppd,
 {
if (!is_bx(ppd->dd)) {
unsigned long vl;
-   int vfi = 0;
u64 max_vl_xmit_wait = 0, tmp;
u32 vl_all_mask = VL_MASK_ALL;
-   u64 rcv_data, rcv_bubble;
-
-   rcv_data = be64_to_cpu(rsp->port_rcv_data);
-   rcv_bubble = be64_to_cpu(rsp->port_rcv_bubble);
-   /* In the measured time period, calculate the total number
-* of flits that were received. Subtract out one false
-* rcv_bubble increment for every 32 received flits but
-* don't let the number go negative.
-*/
-   if (rcv_bubble >= (rcv_data>>5)) {
-   rcv_bubble -= (rcv_data>>5);
-   rsp->port_rcv_bubble = cpu_to_be64(rcv_bubble);
-   }
-   for_each_set_bit(vl, (unsigned long *)&(vl_select_mask),
-8 * sizeof(vl_select_mask)) {
-   rcv_data = be64_to_cpu(rsp->vls[vfi].port_vl_rcv_data);
-   rcv_bubble =
-   be64_to_cpu(rsp->vls[vfi].port_vl_rcv_bubble);
-   if (rcv_bubble >= (rcv_data>>5)) {
-   rcv_bubble -= (rcv_data>>5);
-   rsp->vls[vfi].port_vl_rcv_bubble =
-   cpu_to_be64(rcv_bubble);
-   }
-   vfi++;
-   }
 
for_each_set_bit(vl, (unsigned long *)&(vl_all_mask),
 8 * sizeof(vl_all_mask)) {
@@ -2363,8 +2337,6 @@ static int pma_get_opa_portstatus(struct opa_pma_mad *pmp,
  CNTR_INVALID_VL));
rsp->port_rcv_data = cpu_to_be64(read_dev_cntr(dd, C_DC_RCV_FLITS,
 CNTR_INVALID_VL));
-   rsp->port_rcv_bubble =
-   cpu_to_be64(read_dev_cntr(dd, C_DC_RCV_BBL, CNTR_INVALID_VL));
rsp->port_xmit_pkts = cpu_to_be64(read_dev_cntr(dd, C_DC_XMIT_PKTS,
  CNTR_INVALID_VL));
rsp->port_rcv_pkts = cpu_to_be64(read_dev_cntr(dd, C_DC_RCV_PKTS,
@@ -2434,9 +2406,6 @@ static int pma_get_opa_portstatus(struct opa_pma_mad *pmp,
 
tmp = read_dev_cntr(dd, C_DC_RX_FLIT_VL, idx_from_vl(vl));
rsp->vls[vfi].port_vl_rcv_data = cpu_to_be64(tmp);
-   rsp->vls[vfi].port_vl_rcv_bubble =
-   cpu_to_be64(read_dev_cntr(dd, C_DC_RCV_BBL_VL,
-   idx_from_vl(vl)));
 
rsp->vls[vfi].port_vl_rcv_pkts =
cpu_to_be64(read_dev_cntr(dd, C_DC_RX_PKT_VL,
@@ -2519,32 +2488,8 @@ static void a0_datacounters(struct hfi1_devdata *dd, 
struct _port_dctrs *rsp,
if (!is_bx(dd)) {
unsigned long vl;
int vfi = 0;
-   u64 rcv_data, rcv_bubble, sum_vl_xmit_wait = 0;
-
-   rcv_data = be64_to_cpu(rsp->port_rcv_data);
-   rcv_bubble = be64_to_cpu(rsp->port_rcv_bubble);
-   /* In the measured time period, calculate the total number
-* of flits that were received. Subtract out one false
-* rcv_bubble increment for every 32 received flits but
-* don't let the number go negative.
-*/
-   if (rcv_bubble >= (rcv_data>>5)) {
-   rcv_bubble -= (rcv_data>>5);
-   rsp->port_rcv_bubble = cpu_to_be64(rcv_bubble);
-   }
-   for_each_set_bit(vl, (unsigned long *)&(vl_select_mask),
-   8 * sizeof(vl_select_mask)) {
-   rcv_data = be64_to_cpu(rsp->vls[vfi].port_vl_rcv_data);
-   rcv_bubble =
-   be64_to_cpu(rsp->vls[vfi].port_vl_rcv_bubble);
-   if (rcv_bubble >= (rcv_data>>5)) {
-   rcv_bubble -= (rcv_data>>5);
-   rsp->vls[vfi].port_vl_rcv_bubble =
-   cpu_to_be64(rcv_bubble)

[PATCH v2 10/13] staging/rdma/hfi1: adding per SDMA engine stats to hfistats

2015-11-16 Thread Jubin John
From: Vennila Megavannan 

Added the following per sdma engine stats:
  - SendDmaDescFetchedCnt
  - software maintained count of SDMA interrupts
 (SDmaInt, SDmaIdleInt, SDmaProgressInt)
  - software maintained counts of SDMA error cases

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Mike Marciniszyn 
Signed-off-by: Vennila Megavannan 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c   |  110 +++-
 drivers/staging/rdma/hfi1/chip.h   |5 +
 drivers/staging/rdma/hfi1/chip_registers.h |1 +
 drivers/staging/rdma/hfi1/hfi.h|1 +
 drivers/staging/rdma/hfi1/sdma.c   |9 ++-
 drivers/staging/rdma/hfi1/sdma.h   |7 ++
 6 files changed, 129 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 4adf30c..205dff3 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -1296,10 +1296,58 @@ static u64 dev_access_u32_csr(const struct cntr_entry 
*entry,
void *context, int vl, int mode, u64 data)
 {
struct hfi1_devdata *dd = context;
+   u64 csr = entry->csr;
 
-   if (vl != CNTR_INVALID_VL)
-   return 0;
-   return read_write_csr(dd, entry->csr, mode, data);
+   if (entry->flags & CNTR_SDMA) {
+   if (vl == CNTR_INVALID_VL)
+   return 0;
+   csr += 0x100 * vl;
+   } else {
+   if (vl != CNTR_INVALID_VL)
+   return 0;
+   }
+   return read_write_csr(dd, csr, mode, data);
+}
+
+static u64 access_sde_err_cnt(const struct cntr_entry *entry,
+ void *context, int idx, int mode, u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   if (dd->per_sdma && idx < dd->num_sdma)
+   return dd->per_sdma[idx].err_cnt;
+   return 0;
+}
+
+static u64 access_sde_int_cnt(const struct cntr_entry *entry,
+ void *context, int idx, int mode, u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   if (dd->per_sdma && idx < dd->num_sdma)
+   return dd->per_sdma[idx].sdma_int_cnt;
+   return 0;
+}
+
+static u64 access_sde_idle_int_cnt(const struct cntr_entry *entry,
+  void *context, int idx, int mode, u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   if (dd->per_sdma && idx < dd->num_sdma)
+   return dd->per_sdma[idx].idle_int_cnt;
+   return 0;
+}
+
+static u64 access_sde_progress_int_cnt(const struct cntr_entry *entry,
+  void *context, int idx, int mode,
+  u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   if (dd->per_sdma && idx < dd->num_sdma)
+   return dd->per_sdma[idx].progress_int_cnt;
+   return 0;
 }
 
 static u64 dev_access_u64_csr(const struct cntr_entry *entry, void *context,
@@ -1728,6 +1776,22 @@ static struct cntr_entry dev_cntrs[DEV_CNTR_LAST] = {
access_sw_kmem_wait),
 [C_SW_SEND_SCHED] = CNTR_ELEM("SendSched", 0, 0, CNTR_NORMAL,
access_sw_send_schedule),
+[C_SDMA_DESC_FETCHED_CNT] = CNTR_ELEM("SDEDscFdCn",
+ SEND_DMA_DESC_FETCHED_CNT, 0,
+ CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
+ dev_access_u32_csr),
+[C_SDMA_INT_CNT] = CNTR_ELEM("SDMAInt", 0, 0,
+CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
+access_sde_int_cnt),
+[C_SDMA_ERR_CNT] = CNTR_ELEM("SDMAErrCt", 0, 0,
+CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
+access_sde_err_cnt),
+[C_SDMA_IDLE_INT_CNT] = CNTR_ELEM("SDMAIdInt", 0, 0,
+ CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
+ access_sde_idle_int_cnt),
+[C_SDMA_PROGRESS_INT_CNT] = CNTR_ELEM("SDMAPrIntCn", 0, 0,
+ CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
+ access_sde_progress_int_cnt)
 };
 
 static struct cntr_entry port_cntrs[PORT_CNTR_LAST] = {
@@ -2520,6 +2584,7 @@ static void handle_sdma_eng_err(struct hfi1_devdata *dd,
dd_dev_err(sde->dd, "CONFIG SDMA(%u) source: %u status 0x%llx\n",
   sde->this_idx, source, (unsigned long long)status);
 #endif
+   sde->err_cnt++;
sdma_engine_error(sde, status);
 }
 
@@ -7917,6 +7982,20 @@ u32 hfi1_read_cntrs(struct hfi1_devdata *dd, loff_t pos, 

[PATCH v2 12/13] staging/rdma/hfi1: Read EFI variable for device description

2015-11-16 Thread Jubin John
From: Dean Luick 

Read an EFI variable for the device description.  Create the
infrastructure for additional variable reads.

Reviewed-by: Easwar Hariharan 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/Makefile |2 +-
 drivers/staging/rdma/hfi1/chip.c   |   38 +++--
 drivers/staging/rdma/hfi1/efivar.c |  169 
 drivers/staging/rdma/hfi1/efivar.h |   60 +
 4 files changed, 260 insertions(+), 9 deletions(-)
 create mode 100644 drivers/staging/rdma/hfi1/efivar.c
 create mode 100644 drivers/staging/rdma/hfi1/efivar.h

diff --git a/drivers/staging/rdma/hfi1/Makefile 
b/drivers/staging/rdma/hfi1/Makefile
index 2e5daa6..68c5a31 100644
--- a/drivers/staging/rdma/hfi1/Makefile
+++ b/drivers/staging/rdma/hfi1/Makefile
@@ -7,7 +7,7 @@
 #
 obj-$(CONFIG_INFINIBAND_HFI1) += hfi1.o
 
-hfi1-y := chip.o cq.o device.o diag.o dma.o driver.o eprom.o file_ops.o 
firmware.o \
+hfi1-y := chip.o cq.o device.o diag.o dma.o driver.o efivar.o eprom.o 
file_ops.o firmware.o \
init.o intr.o keys.o mad.o mmap.o mr.o pcie.o pio.o pio_copy.o \
qp.o qsfp.o rc.o ruc.o sdma.o srq.o sysfs.o trace.o twsi.o \
uc.o ud.o user_pages.o user_sdma.o verbs_mcast.o verbs.o
diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 812a3bf..c9a4180 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -63,6 +63,7 @@
 #include "pio.h"
 #include "sdma.h"
 #include "eprom.h"
+#include "efivar.h"
 
 #define NUM_IB_PORTS 1
 
@@ -10547,6 +10548,32 @@ static void asic_should_init(struct hfi1_devdata *dd)
spin_unlock_irqrestore(&hfi1_devs_lock, flags);
 }
 
+/*
+ * Set dd->boardname.  Use a generic name if a name is not returned from
+ * EFI variable space.
+ *
+ * Return 0 on success, -ENOMEM if space could not be allocated.
+ */
+static int obtain_boardname(struct hfi1_devdata *dd)
+{
+   /* generic board description */
+   const char generic[] =
+   "Intel Omni-Path Host Fabric Interface Adapter 100 Series";
+   unsigned long size;
+   int ret;
+
+   ret = read_hfi1_efi_var(dd, "description", &size,
+   (void **)&dd->boardname);
+   if (ret) {
+   dd_dev_err(dd, "Board description not found\n");
+   /* use generic description */
+   dd->boardname = kstrdup(generic, GFP_KERNEL);
+   if (!dd->boardname)
+   return -ENOMEM;
+   }
+   return 0;
+}
+
 /**
  * Allocate and initialize the device structure for the hfi.
  * @dev: the pci_dev for hfi1_ib device
@@ -10744,18 +10771,13 @@ struct hfi1_devdata *hfi1_init_dd(struct pci_dev 
*pdev,
 
parse_platform_config(dd);
 
-   /* add board names as they are defined */
-   dd->boardname = kmalloc(64, GFP_KERNEL);
-   if (!dd->boardname)
+   ret = obtain_boardname(dd);
+   if (ret)
goto bail_cleanup;
-   snprintf(dd->boardname, 64, "Board ID 0x%llx",
-dd->revision >> CCE_REVISION_BOARD_ID_LOWER_NIBBLE_SHIFT
-   & CCE_REVISION_BOARD_ID_LOWER_NIBBLE_MASK);
 
snprintf(dd->boardversion, BOARD_VERS_MAX,
-"ChipABI %u.%u, %s, ChipRev %u.%u, SW Compat %llu\n",
+"ChipABI %u.%u, ChipRev %u.%u, SW Compat %llu\n",
 HFI1_CHIP_VERS_MAJ, HFI1_CHIP_VERS_MIN,
-dd->boardname,
 (u32)dd->majrev,
 (u32)dd->minrev,
 (dd->revision >> CCE_REVISION_SW_SHIFT)
diff --git a/drivers/staging/rdma/hfi1/efivar.c 
b/drivers/staging/rdma/hfi1/efivar.c
new file mode 100644
index 000..7dc5bae
--- /dev/null
+++ b/drivers/staging/rdma/hfi1/efivar.c
@@ -0,0 +1,169 @@
+/*
+ *
+ * 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
+ *
+ * Copyright(c) 2015 Intel Corporation.
+ *
+ * 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
+ *
+ * Copyright(c) 2015 Intel Corporation.
+ *
+ * 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 th

[PATCH v2 11/13] staging/rdma/hfi1: Remove unneeded variable index

2015-11-16 Thread Jubin John
From: Dean Luick 

The variable "index" increments the same as dd->ndevcntrs.
Just use the later.  Remove uneeded usage of "index" in the
fill loop - it is not used there or later in the function.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c |   19 +++
 1 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 205dff3..812a3bf 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -8359,7 +8359,7 @@ mod_timer(&dd->synth_stats_timer, jiffies + HZ * 
SYNTH_CNT_TIME);
 #define C_MAX_NAME 13 /* 12 chars + one for /0 */
 static int init_cntrs(struct hfi1_devdata *dd)
 {
-   int i, rcv_ctxts, index, j;
+   int i, rcv_ctxts, j;
size_t sz;
char *p;
char name[C_MAX_NAME];
@@ -8376,7 +8376,6 @@ static int init_cntrs(struct hfi1_devdata *dd)
/* size names and determine how many we have*/
dd->ndevcntrs = 0;
sz = 0;
-   index = 0;
 
for (i = 0; i < DEV_CNTR_LAST; i++) {
hfi1_dbg_early("Init cntr %s\n", dev_cntrs[i].name);
@@ -8387,7 +8386,7 @@ static int init_cntrs(struct hfi1_devdata *dd)
 
if (dev_cntrs[i].flags & CNTR_VL) {
hfi1_dbg_early("\tProcessing VL cntr\n");
-   dev_cntrs[i].offset = index;
+   dev_cntrs[i].offset = dd->ndevcntrs;
for (j = 0; j < C_VL_COUNT; j++) {
memset(name, '\0', C_MAX_NAME);
snprintf(name, C_MAX_NAME, "%s%d",
@@ -8397,13 +8396,12 @@ static int init_cntrs(struct hfi1_devdata *dd)
sz++;
hfi1_dbg_early("\t\t%s\n", name);
dd->ndevcntrs++;
-   index++;
}
} else if (dev_cntrs[i].flags & CNTR_SDMA) {
hfi1_dbg_early(
   "\tProcessing per SDE counters chip 
enginers %u\n",
   dd->chip_sdma_engines);
-   dev_cntrs[i].offset = index;
+   dev_cntrs[i].offset = dd->ndevcntrs;
for (j = 0; j < dd->chip_sdma_engines; j++) {
memset(name, '\0', C_MAX_NAME);
snprintf(name, C_MAX_NAME, "%s%d",
@@ -8412,24 +8410,22 @@ static int init_cntrs(struct hfi1_devdata *dd)
sz++;
hfi1_dbg_early("\t\t%s\n", name);
dd->ndevcntrs++;
-   index++;
}
} else {
/* +1 for newline  */
sz += strlen(dev_cntrs[i].name) + 1;
+   dev_cntrs[i].offset = dd->ndevcntrs;
dd->ndevcntrs++;
-   dev_cntrs[i].offset = index;
-   index++;
hfi1_dbg_early("\tAdding %s\n", dev_cntrs[i].name);
}
}
 
/* allocate space for the counter values */
-   dd->cntrs = kcalloc(index, sizeof(u64), GFP_KERNEL);
+   dd->cntrs = kcalloc(dd->ndevcntrs, sizeof(u64), GFP_KERNEL);
if (!dd->cntrs)
goto bail;
 
-   dd->scntrs = kcalloc(index, sizeof(u64), GFP_KERNEL);
+   dd->scntrs = kcalloc(dd->ndevcntrs, sizeof(u64), GFP_KERNEL);
if (!dd->scntrs)
goto bail;
 
@@ -8441,7 +8437,7 @@ static int init_cntrs(struct hfi1_devdata *dd)
goto bail;
 
/* fill in the names */
-   for (p = dd->cntrnames, i = 0, index = 0; i < DEV_CNTR_LAST; i++) {
+   for (p = dd->cntrnames, i = 0; i < DEV_CNTR_LAST; i++) {
if (dev_cntrs[i].flags & CNTR_DISABLED) {
/* Nothing */
} else {
@@ -8471,7 +8467,6 @@ static int init_cntrs(struct hfi1_devdata *dd)
p += strlen(dev_cntrs[i].name);
*p++ = '\n';
}
-   index++;
}
}
 
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 13/13] staging/rdma/hfi1: Adjust EPROM partitions, add EPROM commands

2015-11-16 Thread Jubin John
From: Dean Luick 

Add a new EPROM partition, adjusting partition placement.

Add EPROM range commands as a supserset of the partition
commands.  Remove old partition commands.

Enhance EPROM erase, creating a range function and using the
largest erase (sub) commands when possible.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/eprom.c|  119 +++---
 drivers/staging/rdma/hfi1/file_ops.c |   18 ++
 include/uapi/rdma/hfi/hfi1_user.h|   10 +--
 3 files changed, 77 insertions(+), 70 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/eprom.c 
b/drivers/staging/rdma/hfi1/eprom.c
index b61d3ae..fb620c9 100644
--- a/drivers/staging/rdma/hfi1/eprom.c
+++ b/drivers/staging/rdma/hfi1/eprom.c
@@ -53,17 +53,26 @@
 #include "eprom.h"
 
 /*
- * The EPROM is logically divided into two partitions:
+ * The EPROM is logically divided into three partitions:
  * partition 0: the first 128K, visible from PCI ROM BAR
- * partition 1: the rest
+ * partition 1: 4K config file (sector size)
+ * partition 2: the rest
  */
 #define P0_SIZE (128 * 1024)
+#define P1_SIZE   (4 * 1024)
 #define P1_START P0_SIZE
+#define P2_START (P0_SIZE + P1_SIZE)
+
+/* erase sizes supported by the controller */
+#define SIZE_4KB (4 * 1024)
+#define MASK_4KB (SIZE_4KB - 1)
 
-/* largest erase size supported by the controller */
 #define SIZE_32KB (32 * 1024)
 #define MASK_32KB (SIZE_32KB - 1)
 
+#define SIZE_64KB (64 * 1024)
+#define MASK_64KB (SIZE_64KB - 1)
+
 /* controller page size, in bytes */
 #define EP_PAGE_SIZE 256
 #define EEP_PAGE_MASK (EP_PAGE_SIZE - 1)
@@ -75,10 +84,12 @@
 #define CMD_READ_DATA(addr)((0x03 << CMD_SHIFT) | addr)
 #define CMD_READ_SR1   ((0x05 << CMD_SHIFT))
 #define CMD_WRITE_ENABLE   ((0x06 << CMD_SHIFT))
+#define CMD_SECTOR_ERASE_4KB(addr)  ((0x20 << CMD_SHIFT) | addr)
 #define CMD_SECTOR_ERASE_32KB(addr) ((0x52 << CMD_SHIFT) | addr)
 #define CMD_CHIP_ERASE ((0x60 << CMD_SHIFT))
 #define CMD_READ_MANUF_DEV_ID  ((0x90 << CMD_SHIFT))
 #define CMD_RELEASE_POWERDOWN_NOID  ((0xab << CMD_SHIFT))
+#define CMD_SECTOR_ERASE_64KB(addr) ((0xd8 << CMD_SHIFT) | addr)
 
 /* controller interface speeds */
 #define EP_SPEED_FULL 0x2  /* full speed */
@@ -188,28 +199,43 @@ static int erase_chip(struct hfi1_devdata *dd)
 }
 
 /*
- * Erase a range using the 32KB erase command.
+ * Erase a range.
  */
-static int erase_32kb_range(struct hfi1_devdata *dd, u32 start, u32 end)
+static int erase_range(struct hfi1_devdata *dd, u32 start, u32 len)
 {
+   u32 end = start + len;
int ret = 0;
 
if (end < start)
return -EINVAL;
 
-   if ((start & MASK_32KB) || (end & MASK_32KB)) {
+   /* check the end points for the minimum erase */
+   if ((start & MASK_4KB) || (end & MASK_4KB)) {
dd_dev_err(dd,
-   "%s: non-aligned range (0x%x,0x%x) for a 32KB erase\n",
+   "%s: non-aligned range (0x%x,0x%x) for a 4KB erase\n",
__func__, start, end);
return -EINVAL;
}
 
write_enable(dd);
 
-   for (; start < end; start += SIZE_32KB) {
+   while (start < end) {
write_csr(dd, ASIC_EEP_ADDR_CMD, CMD_WRITE_ENABLE);
-   write_csr(dd, ASIC_EEP_ADDR_CMD,
-   CMD_SECTOR_ERASE_32KB(start));
+   /* check in order of largest to smallest */
+   if (((start & MASK_64KB) == 0) && (start + SIZE_64KB <= end)) {
+   write_csr(dd, ASIC_EEP_ADDR_CMD,
+ CMD_SECTOR_ERASE_64KB(start));
+   start += SIZE_64KB;
+   } else if (((start & MASK_32KB) == 0) &&
+  (start + SIZE_32KB <= end)) {
+   write_csr(dd, ASIC_EEP_ADDR_CMD,
+ CMD_SECTOR_ERASE_32KB(start));
+   start += SIZE_32KB;
+   } else {/* 4KB will work */
+   write_csr(dd, ASIC_EEP_ADDR_CMD,
+ CMD_SECTOR_ERASE_4KB(start));
+   start += SIZE_4KB;
+   }
ret = wait_for_not_busy(dd);
if (ret)
goto done;
@@ -309,6 +335,18 @@ done:
return ret;
 }
 
+/* convert an range composite to a length, in bytes */
+static inline u32 extract_rlen(u32 composite)
+{
+   return (composite & 0x) * EP_PAGE_SIZE;
+}
+
+/* convert an range composite to a start, in bytes */
+static inline u32 extract_rstart(u32 composite)
+{
+   return (composite >> 16) * EP_PAGE_SIZE;
+}
+
 /*
  * Perform the given operation on the EPROM. 

[PATCH v2 07/13] staging/rdma/hfi1: rework is_a0() and is_bx()

2015-11-16 Thread Jubin John
From: Mike Marciniszyn 

The current is_bx() will incorrectly match on other steppings.

is_a0() is removed in favor of is_ax().

Reviewed-by: Mark Debbage 
Signed-off-by: Mike Marciniszyn 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c |   44 ++
 drivers/staging/rdma/hfi1/chip.h |1 -
 drivers/staging/rdma/hfi1/firmware.c |2 +-
 drivers/staging/rdma/hfi1/hfi.h  |4 +-
 drivers/staging/rdma/hfi1/init.c |2 +-
 drivers/staging/rdma/hfi1/pcie.c |4 +-
 6 files changed, 24 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 7c58c7b..af59d23 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -1871,13 +1871,6 @@ static struct cntr_entry port_cntrs[PORT_CNTR_LAST] = {
 
 /*  */
 
-/* return true if this is chip revision revision a0 */
-int is_a0(struct hfi1_devdata *dd)
-{
-   return ((dd->revision >> CCE_REVISION_CHIP_REV_MINOR_SHIFT)
-   & CCE_REVISION_CHIP_REV_MINOR_MASK) == 0;
-}
-
 /* return true if this is chip revision revision a */
 int is_ax(struct hfi1_devdata *dd)
 {
@@ -1893,7 +1886,7 @@ int is_bx(struct hfi1_devdata *dd)
u8 chip_rev_minor =
dd->revision >> CCE_REVISION_CHIP_REV_MINOR_SHIFT
& CCE_REVISION_CHIP_REV_MINOR_MASK;
-   return !!(chip_rev_minor & 0x10);
+   return (chip_rev_minor & 0xF0) == 0x10;
 }
 
 /*
@@ -2188,9 +2181,8 @@ static void handle_cce_err(struct hfi1_devdata *dd, u32 
unused, u64 reg)
dd_dev_info(dd, "CCE Error: %s\n",
cce_err_status_string(buf, sizeof(buf), reg));
 
-   if ((reg & CCE_ERR_STATUS_CCE_CLI2_ASYNC_FIFO_PARITY_ERR_SMASK)
-   && is_a0(dd)
-   && (dd->icode != ICODE_FUNCTIONAL_SIMULATOR)) {
+   if ((reg & CCE_ERR_STATUS_CCE_CLI2_ASYNC_FIFO_PARITY_ERR_SMASK) &&
+   is_ax(dd) && (dd->icode != ICODE_FUNCTIONAL_SIMULATOR)) {
/* this error requires a manual drop into SPC freeze mode */
/* then a fix up */
start_freeze_handling(dd->pport, FREEZE_SELF);
@@ -2250,7 +2242,7 @@ static void handle_rxe_err(struct hfi1_devdata *dd, u32 
unused, u64 reg)
 * Freeze mode recovery is disabled for the errors
 * in RXE_FREEZE_ABORT_MASK
 */
-   if (is_a0(dd) && (reg & RXE_FREEZE_ABORT_MASK))
+   if (is_ax(dd) && (reg & RXE_FREEZE_ABORT_MASK))
flags = FREEZE_ABORT;
 
start_freeze_handling(dd->pport, flags);
@@ -2353,7 +2345,7 @@ static void handle_egress_err(struct hfi1_devdata *dd, 
u32 unused, u64 reg)
 
if (reg & ALL_TXE_EGRESS_FREEZE_ERR)
start_freeze_handling(dd->pport, 0);
-   if (is_a0(dd) && (reg &
+   if (is_ax(dd) && (reg &
SEND_EGRESS_ERR_STATUS_TX_CREDIT_RETURN_VL_ERR_SMASK)
&& (dd->icode != ICODE_FUNCTIONAL_SIMULATOR))
start_freeze_handling(dd->pport, 0);
@@ -3048,7 +3040,7 @@ static void adjust_lcb_for_fpga_serdes(struct 
hfi1_devdata *dd)
/* else this is _p */
 
version = emulator_rev(dd);
-   if (!is_a0(dd))
+   if (!is_ax(dd))
version = 0x2d; /* all B0 use 0x2d or higher settings */
 
if (version <= 0x12) {
@@ -3334,7 +3326,7 @@ void handle_freeze(struct work_struct *work)
write_csr(dd, CCE_CTRL, CCE_CTRL_SPC_UNFREEZE_SMASK);
wait_for_freeze_status(dd, 0);
 
-   if (is_a0(dd)) {
+   if (is_ax(dd)) {
write_csr(dd, CCE_CTRL, CCE_CTRL_SPC_FREEZE_SMASK);
wait_for_freeze_status(dd, 1);
write_csr(dd, CCE_CTRL, CCE_CTRL_SPC_UNFREEZE_SMASK);
@@ -3862,7 +3854,7 @@ void handle_verify_cap(struct work_struct *work)
 *  REPLAY_BUF_MBE_SMASK
 *  FLIT_INPUT_BUF_MBE_SMASK
 */
-   if (is_a0(dd)) {/* fixed in B0 */
+   if (is_ax(dd)) {/* fixed in B0 */
reg = read_csr(dd, DC_LCB_CFG_LINK_KILL_EN);
reg |= DC_LCB_CFG_LINK_KILL_EN_REPLAY_BUF_MBE_SMASK
| DC_LCB_CFG_LINK_KILL_EN_FLIT_INPUT_BUF_MBE_SMASK;
@@ -7329,8 +7321,8 @@ static int set_buffer_control(struct hfi1_devdata *dd,
 */
use_all_mask = 0;
if ((be16_to_cpu(new_bc->overall_shared_limit) <
-   be16_to_cpu(cur_bc.overall_shared_limit))
-   || (is_a0(dd) && any_shared_limit_changing)) {
+be16_to_cpu(cur_bc.overall_shared_limit)) ||
+   (is_ax(dd) &

[PATCH v2 09/13] staging/rdma/hfi1: Change default krcvqs

2015-11-16 Thread Jubin John
Change the default number of krcvqs to number of numa nodes + 1
based on the performance data collected.

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index af59d23..4adf30c 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -9200,7 +9200,7 @@ static int set_up_context_variables(struct hfi1_devdata 
*dd)
if (n_krcvqs)
num_kernel_contexts = n_krcvqs + MIN_KERNEL_KCTXTS;
else
-   num_kernel_contexts = num_online_nodes();
+   num_kernel_contexts = num_online_nodes() + 1;
num_kernel_contexts =
max_t(int, MIN_KERNEL_KCTXTS, num_kernel_contexts);
/*
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging/rdma/hfi1: Fix error in hfi1 driver build

2015-11-20 Thread Jubin John
hfi1 driver build fails with the following error:
In function ‘handle_receive_interrupt’:
error: implicit declaration of function ‘skip_rcv_packet’ 
[-Werror=implicit-function-declaration]
last = skip_rcv_packet(&packet, thread);
^
This is due to the inclusion of the skip_rcv_packet() in the
CONFIG_PRESCAN_RXQ ifdef block. This function is independent of
CONFIG_PRESCAN_RXQ and should be outside this block.

Fixes: 82c2611daaf0 ("staging/rdma/hfi1: Handle packets with invalid RHF on 
context 0")
Reviewed-by: Mike Marciniszyn 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/driver.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/driver.c 
b/drivers/staging/rdma/hfi1/driver.c
index 4c52e78..3b7a707 100644
--- a/drivers/staging/rdma/hfi1/driver.c
+++ b/drivers/staging/rdma/hfi1/driver.c
@@ -633,6 +633,7 @@ next:
update_ps_mdata(&mdata, rcd);
}
 }
+#endif /* CONFIG_PRESCAN_RXQ */
 
 static inline int skip_rcv_packet(struct hfi1_packet *packet, int thread)
 {
@@ -659,7 +660,6 @@ static inline int skip_rcv_packet(struct hfi1_packet 
*packet, int thread)
 
return ret;
 }
-#endif /* CONFIG_PRESCAN_RXQ */
 
 static inline int process_rcv_packet(struct hfi1_packet *packet, int thread)
 {
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 2/2] staging/rdma/hfi1: Eliminate WARN_ON when VL is invalid

2015-11-20 Thread Jubin John
On Fri, Nov 20, 2015 at 09:00:23AM -0800, Greg KH wrote:
> On Fri, Nov 20, 2015 at 04:43:56PM +, Marciniszyn, Mike wrote:
> > > >
> > > > Is the inprocess branch available?
> > > 
> > > I do not understand what you mean here :(
> > 
> > Does it fail to apply to staging-next or staging-testing or something else?
> 
> As both trees are now the same, it fails to apply to both at the moment
> :)

I will refresh this patch against the latest staging-next.

Thanks,
Jubin John
> 
> thanks,
> 
> greg k-h
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3] staging/rdma/hfi1: Eliminate WARN_ON when VL is invalid

2015-11-20 Thread Jubin John
From: Ira Weiny 

sdma_select_engine_vl only needs to protect itself from an invalid VL.
Something higher up the stack should be warning the user when they try
to use an SL which maps to an invalid VL.

Reviewed-by: Dean Luick 
Reviewed-by: Mike Marciniszyn 
Reviewed-by: Kaike Wan 
Signed-off-by: Ira Weiny 
Signed-off-by: Jubin John 
---
Changes in v2:
- Removed unlikely() in sdma_select_engine_vl()
Changes in v3:
- Refreshed patch against latest staging-next

 drivers/staging/rdma/hfi1/sdma.c |   11 +--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/sdma.c b/drivers/staging/rdma/hfi1/sdma.c
index 90b7072..0710e2a 100644
--- a/drivers/staging/rdma/hfi1/sdma.c
+++ b/drivers/staging/rdma/hfi1/sdma.c
@@ -765,8 +765,14 @@ struct sdma_engine *sdma_select_engine_vl(
struct sdma_map_elem *e;
struct sdma_engine *rval;
 
-   if (WARN_ON(vl > 8))
-   return &dd->per_sdma[0];
+   /* NOTE This should only happen if SC->VL changed after the initial
+*  checks on the QP/AH
+*  Default will return engine 0 below
+*/
+   if (vl >= num_vls) {
+   rval = NULL;
+   goto done;
+   }
 
rcu_read_lock();
m = rcu_dereference(dd->sdma_map);
@@ -778,6 +784,7 @@ struct sdma_engine *sdma_select_engine_vl(
rval = e->sde[selector & e->mask];
rcu_read_unlock();
 
+done:
rval =  !rval ? &dd->per_sdma[0] : rval;
trace_hfi1_sdma_engine_select(dd, selector, vl, rval->this_idx);
return rval;
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 00/17] Driver cleanup and misc fixes series 3

2015-12-01 Thread Jubin John
Changes in v2:
- Added more information in commit messages of patches 01, 02
  03, 04, 05, 07 and 09
- Fixed driver name to hfi1 in subject line of patch 06
- Refreshed patch 10 on top of staging-next
- Dropped patch 18 (staging/rdma/hfi1: Workaround
  CONFIG_SDMA_VERBOSITY timing issue) from series

Andrea Lowe (1):
  staging/rdma/hfi1: Adding counter resolutions for DataPortCounters

Dean Luick (10):
  staging/rdma/hfi1: Support alternate firmware names
  staging/rdma/hfi1: Decode CNP opcode
  staging/rdma/hfi1: Add aeth name syndrome decode
  staging/rdma/hfi1: Add one-time LCB reset
  staging/rdma/hfi1: Extend quiet timeout
  staging/rdma/hfi1: Add a credit push on diagpkt allocate fail
  staging/rdma/hfi1: Correctly limit VLs against SDMA engines
  staging/rdma/hfi1: Unexpected link up pkey values are not an error
  staging/rdma/hfi1: remove SPC freeze error messages
  staging/rdma/hfi1: unknown frame messages are not errors

Edward Mascarenhas (1):
  staging/rdma/hfi1: Clean up comments

Harish Chegondi (2):
  staging/rdma/hfi1: Destroy workqueues if hfi1_register_ib_device()
call returns error
  staging/rdma/hfi1: Consider VL15 MTU also when calculating the
maximum VL MTU

Ira Weiny (1):
  staging/rdma/hfi1: Fix Xmit Wait calculation

Joel Rosenzweig (1):
  staging/rdma/hfi1: Adds software counters for bitfields within
various error status fields

Kaike Wan (1):
  staging/rdma/hfi1: Fix qp.h comments

 drivers/staging/rdma/hfi1/chip.c   | 3248 +++-
 drivers/staging/rdma/hfi1/chip.h   |  270 +++
 drivers/staging/rdma/hfi1/chip_registers.h |3 +
 drivers/staging/rdma/hfi1/diag.c   |8 +
 drivers/staging/rdma/hfi1/driver.c |2 +-
 drivers/staging/rdma/hfi1/firmware.c   |  189 ++-
 drivers/staging/rdma/hfi1/hfi.h|   40 +-
 drivers/staging/rdma/hfi1/init.c   |9 +-
 drivers/staging/rdma/hfi1/mad.c|   70 +-
 drivers/staging/rdma/hfi1/pcie.c   |2 +-
 drivers/staging/rdma/hfi1/qp.h |8 +-
 drivers/staging/rdma/hfi1/trace.c  |   29 +-
 drivers/staging/rdma/hfi1/trace.h  |3 +-
 drivers/staging/rdma/hfi1/ud.c |2 +-
 14 files changed, 3795 insertions(+), 88 deletions(-)

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 03/17] staging/rdma/hfi1: Add aeth name syndrome decode

2015-12-01 Thread Jubin John
From: Dean Luick 

Add aeth name syndrome decode to enhance debugging.

The IBTA RC ACK contains an ACK extended transport header.

Part of that header is the syndrome field that qualifies the RC ACK as an
ACK, NAK, or RNR NAK.

Without the patch here is the syndrome decode:
aeth syn 0x00

Here is the decode with the fix:
aeth syn 0x00 ACK

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
Changes in v2:
- Added more information in commit message

 drivers/staging/rdma/hfi1/trace.c |   29 ++---
 1 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/trace.c 
b/drivers/staging/rdma/hfi1/trace.c
index f55b751..10122e8 100644
--- a/drivers/staging/rdma/hfi1/trace.c
+++ b/drivers/staging/rdma/hfi1/trace.c
@@ -67,7 +67,7 @@ u8 ibhdr_exhdr_len(struct hfi1_ib_header *hdr)
 
 #define IMM_PRN  "imm %d"
 #define RETH_PRN "reth vaddr 0x%.16llx rkey 0x%.8x dlen 0x%.8x"
-#define AETH_PRN "aeth syn 0x%.2x msn 0x%.8x"
+#define AETH_PRN "aeth syn 0x%.2x %s msn 0x%.8x"
 #define DETH_PRN "deth qkey 0x%.8x sqpn 0x%.6x"
 #define ATOMICACKETH_PRN "origdata %lld"
 #define ATOMICETH_PRN "vaddr 0x%llx rkey 0x%.8x sdata %lld cdata %lld"
@@ -79,6 +79,19 @@ static u64 ib_u64_get(__be32 *p)
return ((u64)be32_to_cpu(p[0]) << 32) | be32_to_cpu(p[1]);
 }
 
+static const char *parse_syndrome(u8 syndrome)
+{
+   switch (syndrome >> 5) {
+   case 0:
+   return "ACK";
+   case 1:
+   return "RNRNAK";
+   case 3:
+   return "NAK";
+   }
+   return "";
+}
+
 const char *parse_everbs_hdrs(
struct trace_seq *p,
u8 opcode,
@@ -124,16 +137,18 @@ const char *parse_everbs_hdrs(
case OP(RC, RDMA_READ_RESPONSE_LAST):
case OP(RC, RDMA_READ_RESPONSE_ONLY):
case OP(RC, ACKNOWLEDGE):
-   trace_seq_printf(p, AETH_PRN,
-   be32_to_cpu(eh->aeth) >> 24,
-   be32_to_cpu(eh->aeth) & HFI1_MSN_MASK);
+   trace_seq_printf(p, AETH_PRN, be32_to_cpu(eh->aeth) >> 24,
+parse_syndrome(be32_to_cpu(eh->aeth) >> 24),
+be32_to_cpu(eh->aeth) & HFI1_MSN_MASK);
break;
/* aeth + atomicacketh */
case OP(RC, ATOMIC_ACKNOWLEDGE):
trace_seq_printf(p, AETH_PRN " " ATOMICACKETH_PRN,
-   (be32_to_cpu(eh->at.aeth) >> 24) & 0xff,
-   be32_to_cpu(eh->at.aeth) & HFI1_MSN_MASK,
-   (unsigned long long)ib_u64_get(eh->at.atomic_ack_eth));
+be32_to_cpu(eh->at.aeth) >> 24,
+parse_syndrome(be32_to_cpu(eh->at.aeth) >> 24),
+be32_to_cpu(eh->at.aeth) & HFI1_MSN_MASK,
+(unsigned long long)
+ib_u64_get(eh->at.atomic_ack_eth));
break;
/* atomiceth */
case OP(RC, COMPARE_SWAP):
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 02/17] staging/rdma/hfi1: Decode CNP opcode

2015-12-01 Thread Jubin John
From: Dean Luick 

Add CNP opcode decode.

Prior to this patch the trace appeared like:

-0 [001] d.h. 94062.578932: input_ibhdr: [:05:00.0] vl 0
lver 0 sl 0 lnh 2,LRH_BTH dlid 0003 len 6 slid 0001 op 0x80,0x80 se 0 m 0
pad 0 tver 0 pkey 0x8001 f 0 b 0 qpn 0x001234 a 0 psn 0x

Note the "op 0x80,0x80".

With this patch:

-0 [000] d.h. 233975.912059: input_ibhdr: [:05:00.0] vl 0
lver 0 sl 0 lnh 2,LRH_BTH dlid 0015 len 6 slid 0014 op 0x80,CNP se 0 m 0
pad 0 tver 0 pkey 0x8001 f 0 b 0 qpn 0x001234 a 0 psn 0x

Note the "op 0x80,CNP"

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
Changes in v2:
- Added more information in commit message

 drivers/staging/rdma/hfi1/trace.h |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/trace.h 
b/drivers/staging/rdma/hfi1/trace.h
index 5743029..86c12eb 100644
--- a/drivers/staging/rdma/hfi1/trace.h
+++ b/drivers/staging/rdma/hfi1/trace.h
@@ -417,7 +417,8 @@ __print_symbolic(opcode,   \
ib_opcode_name(UC_RDMA_WRITE_ONLY),\
ib_opcode_name(UC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
ib_opcode_name(UD_SEND_ONLY),  \
-   ib_opcode_name(UD_SEND_ONLY_WITH_IMMEDIATE))
+   ib_opcode_name(UD_SEND_ONLY_WITH_IMMEDIATE),   \
+   ib_opcode_name(CNP))
 
 
 #define LRH_PRN "vl %d lver %d sl %d lnh %d,%s dlid %.4x len %d slid %.4x"
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 01/17] staging/rdma/hfi1: Support alternate firmware names

2015-12-01 Thread Jubin John
From: Dean Luick 

Add support for an automatic fallback for firmware names to support
debug-signed and production-signed firmware images.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
Changes in v2:
- Added more information in commit message

 drivers/staging/rdma/hfi1/firmware.c |  189 --
 1 files changed, 157 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/firmware.c 
b/drivers/staging/rdma/hfi1/firmware.c
index f311282..35060de 100644
--- a/drivers/staging/rdma/hfi1/firmware.c
+++ b/drivers/staging/rdma/hfi1/firmware.c
@@ -68,6 +68,10 @@
 #define DEFAULT_FW_SBUS_NAME "hfi1_sbus.fw"
 #define DEFAULT_FW_PCIE_NAME "hfi1_pcie.fw"
 #define DEFAULT_PLATFORM_CONFIG_NAME "hfi1_platform.dat"
+#define ALT_FW_8051_NAME_ASIC "hfi1_dc8051_d.fw"
+#define ALT_FW_FABRIC_NAME "hfi1_fabric_d.fw"
+#define ALT_FW_SBUS_NAME "hfi1_sbus_d.fw"
+#define ALT_FW_PCIE_NAME "hfi1_pcie_d.fw"
 
 static uint fw_8051_load = 1;
 static uint fw_fabric_serdes_load = 1;
@@ -158,7 +162,8 @@ struct firmware_details {
 static DEFINE_MUTEX(fw_mutex);
 enum fw_state {
FW_EMPTY,
-   FW_ACQUIRED,
+   FW_TRY,
+   FW_FINAL,
FW_ERR
 };
 static enum fw_state fw_state = FW_EMPTY;
@@ -428,8 +433,8 @@ static int obtain_one_firmware(struct hfi1_devdata *dd, 
const char *name,
 
ret = request_firmware(&fdet->fw, name, &dd->pcidev->dev);
if (ret) {
-   dd_dev_err(dd, "cannot load firmware \"%s\", err %d\n",
-   name, ret);
+   dd_dev_err(dd, "cannot find firmware \"%s\", err %d\n",
+  name, ret);
return ret;
}
 
@@ -539,28 +544,53 @@ done:
 static void dispose_one_firmware(struct firmware_details *fdet)
 {
release_firmware(fdet->fw);
-   fdet->fw = NULL;
+   /* erase all previous information */
+   memset(fdet, 0, sizeof(*fdet));
 }
 
 /*
- * Called by all HFIs when loading their firmware - i.e. device probe time.
- * The first one will do the actual firmware load.  Use a mutex to resolve
- * any possible race condition.
+ * Obtain the 4 firmwares from the OS.  All must be obtained at once or not
+ * at all.  If called with the firmware state in FW_TRY, use alternate names.
+ * On exit, this routine will have set the firmware state to one of FW_TRY,
+ * FW_FINAL, or FW_ERR.
  *
- * The call to this routine cannot be moved to driver load because the kernel
- * call request_firmware() requires a device which is only available after
- * the first device probe.
+ * Must be holding fw_mutex.
  */
-static int obtain_firmware(struct hfi1_devdata *dd)
+static void __obtain_firmware(struct hfi1_devdata *dd)
 {
int err = 0;
 
-   mutex_lock(&fw_mutex);
-   if (fw_state == FW_ACQUIRED) {
-   goto done;  /* already acquired */
-   } else if (fw_state == FW_ERR) {
-   err = fw_err;
-   goto done;  /* already tried and failed */
+   if (fw_state == FW_FINAL)   /* nothing more to obtain */
+   return;
+   if (fw_state == FW_ERR) /* already in error */
+   return;
+
+   /* fw_state is FW_EMPTY or FW_TRY */
+retry:
+   if (fw_state == FW_TRY) {
+   /*
+* We tried the original and it failed.  Move to the
+* alternate.
+*/
+   dd_dev_info(dd, "using alternate firmware names\n");
+   /*
+* Let others run.  Some systems, when missing firmware, does
+* something that holds for 30 seconds.  If we do that twice
+* in a row it triggers task blocked warning.
+*/
+   cond_resched();
+   if (fw_8051_load)
+   dispose_one_firmware(&fw_8051);
+   if (fw_fabric_serdes_load)
+   dispose_one_firmware(&fw_fabric);
+   if (fw_sbus_load)
+   dispose_one_firmware(&fw_sbus);
+   if (fw_pcie_serdes_load)
+   dispose_one_firmware(&fw_pcie);
+   fw_8051_name = ALT_FW_8051_NAME_ASIC;
+   fw_fabric_serdes_name = ALT_FW_FABRIC_NAME;
+   fw_sbus_name = ALT_FW_SBUS_NAME;
+   fw_pcie_serdes_name = ALT_FW_PCIE_NAME;
}
 
if (fw_8051_load) {
@@ -588,27 +618,82 @@ static int obtain_firmware(struct hfi1_devdata *dd)
goto done;
}
 
+done:
+   if (err) {
+   /* oops, had problems obtaining a firmware */
+   if (fw_state == FW_EMPTY) {
+   /* retry with alternate */
+   fw_state = FW_TRY;
+   goto retry;

[PATCH v2 06/17] staging/rdma/hfi1: Add one-time LCB reset

2015-12-01 Thread Jubin John
From: Dean Luick 

Add one-time LCB reset on driver load to pre-emptively work
around any LCB power cycle issues.

Reviewed-by: Easwar Hariharan 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
Changes in v2:
- Fixed driver name to hfi1 in subject line

 drivers/staging/rdma/hfi1/chip.c   |   20 
 drivers/staging/rdma/hfi1/chip_registers.h |3 +++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 6b6af40..8191065 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -5888,6 +5888,23 @@ void init_qsfp(struct hfi1_pportdata *ppd)
}
 }
 
+/*
+ * Do a one-time initialize of the LCB block.
+ */
+static void init_lcb(struct hfi1_devdata *dd)
+{
+   /* the DC has been reset earlier in the driver load */
+
+   /* set LCB for cclk loopback on the port */
+   write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 0x01);
+   write_csr(dd, DC_LCB_CFG_LANE_WIDTH, 0x00);
+   write_csr(dd, DC_LCB_CFG_REINIT_AS_SLAVE, 0x00);
+   write_csr(dd, DC_LCB_CFG_CNT_FOR_SKIP_STALL, 0x110);
+   write_csr(dd, DC_LCB_CFG_CLK_CNTR, 0x08);
+   write_csr(dd, DC_LCB_CFG_LOOPBACK, 0x02);
+   write_csr(dd, DC_LCB_CFG_TX_FIFOS_RESET, 0x00);
+}
+
 int bringup_serdes(struct hfi1_pportdata *ppd)
 {
struct hfi1_devdata *dd = ppd->dd;
@@ -5909,6 +5926,9 @@ int bringup_serdes(struct hfi1_pportdata *ppd)
/* Set linkinit_reason on power up per OPA spec */
ppd->linkinit_reason = OPA_LINKINIT_REASON_LINKUP;
 
+   /* one-time init of the LCB */
+   init_lcb(dd);
+
if (loopback) {
ret = init_loopback(dd);
if (ret < 0)
diff --git a/drivers/staging/rdma/hfi1/chip_registers.h 
b/drivers/staging/rdma/hfi1/chip_registers.h
index bf45de2..21ca8c1 100644
--- a/drivers/staging/rdma/hfi1/chip_registers.h
+++ b/drivers/staging/rdma/hfi1/chip_registers.h
@@ -318,6 +318,9 @@
 #define DC_LCB_CFG_TX_FIFOS_RADR_RST_VAL_SHIFT 0
 #define DC_LCB_CFG_TX_FIFOS_RESET (DC_LCB_CSRS + 0x0008)
 #define DC_LCB_CFG_TX_FIFOS_RESET_VAL_SHIFT 0
+#define DC_LCB_CFG_REINIT_AS_SLAVE (DC_LCB_CSRS + 0x0030)
+#define DC_LCB_CFG_CNT_FOR_SKIP_STALL (DC_LCB_CSRS + 0x0040)
+#define DC_LCB_CFG_CLK_CNTR (DC_LCB_CSRS + 0x0110)
 #define DC_LCB_ERR_CLR (DC_LCB_CSRS + 0x0308)
 #define DC_LCB_ERR_EN (DC_LCB_CSRS + 0x0310)
 #define DC_LCB_ERR_FLG (DC_LCB_CSRS + 0x0300)
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 15/17] staging/rdma/hfi1: Consider VL15 MTU also when calculating the maximum VL MTU

2015-12-01 Thread Jubin John
From: Harish Chegondi 

Currently, only MTUs of VLs 0-7 are checked when calculating the maximum VL
MTU which is used to set the port MTU capability in DCC_CFG_PORT_CONFIG CSR
This can cause a port MTU capability to be set to 0 if MTUs of VLs 0-7 is 0
This would affect the VL15 traffic.

Reviewed-by: Dean Luick 
Reviewed-by: Arthur Kepner 
Signed-off-by: Harish Chegondi 
Signed-off-by: Jubin John 
---
Changes in v2:
- No changes

 drivers/staging/rdma/hfi1/chip.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index e7c1505..9811954 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -9399,7 +9399,8 @@ u32 lrh_max_header_bytes(struct hfi1_devdata *dd)
 static void set_send_length(struct hfi1_pportdata *ppd)
 {
struct hfi1_devdata *dd = ppd->dd;
-   u32 max_hb = lrh_max_header_bytes(dd), maxvlmtu = 0, dcmtu;
+   u32 max_hb = lrh_max_header_bytes(dd), dcmtu;
+   u32 maxvlmtu = dd->vld[15].mtu;
u64 len1 = 0, len2 = (((dd->vld[15].mtu + max_hb) >> 2)
  & SEND_LEN_CHECK1_LEN_VL15_MASK) <<
SEND_LEN_CHECK1_LEN_VL15_SHIFT;
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 16/17] staging/rdma/hfi1: Fix Xmit Wait calculation

2015-12-01 Thread Jubin John
From: Ira Weiny 

Total XMIT wait needs to sum the xmit wait values of all the VLs not just
those requested in the query.  Also, make the algorithm used for both
PortStatus and PortDataCounters the same.

Reviewed-by: Arthur Kepner 
Reviewed-by: Breyer, Scott J 
Signed-off-by: Ira Weiny 
Signed-off-by: Jubin John 
---
Changes in v2:
- No changes

 drivers/staging/rdma/hfi1/mad.c |   32 
 1 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/mad.c b/drivers/staging/rdma/hfi1/mad.c
index a122565..6fb4eab 100644
--- a/drivers/staging/rdma/hfi1/mad.c
+++ b/drivers/staging/rdma/hfi1/mad.c
@@ -2272,7 +2272,7 @@ static void a0_portstatus(struct hfi1_pportdata *ppd,
if (!is_bx(ppd->dd)) {
unsigned long vl;
int vfi = 0;
-   u64 max_vl_xmit_wait = 0, tmp;
+   u64 sum_vl_xmit_wait = 0;
u32 vl_all_mask = VL_MASK_ALL;
u64 rcv_data, rcv_bubble;
 
@@ -2302,12 +2302,18 @@ static void a0_portstatus(struct hfi1_pportdata *ppd,
 
for_each_set_bit(vl, (unsigned long *)&(vl_all_mask),
 8 * sizeof(vl_all_mask)) {
-   tmp = read_port_cntr(ppd, C_TX_WAIT_VL,
-idx_from_vl(vl));
-   if (tmp > max_vl_xmit_wait)
-   max_vl_xmit_wait = tmp;
+   u64 tmp = sum_vl_xmit_wait +
+ read_port_cntr(ppd, C_TX_WAIT_VL,
+idx_from_vl(vl));
+   if (tmp < sum_vl_xmit_wait) {
+   /* we wrapped */
+   sum_vl_xmit_wait = (u64)~0;
+   break;
+   }
+   sum_vl_xmit_wait = tmp;
}
-   rsp->port_xmit_wait = cpu_to_be64(max_vl_xmit_wait);
+   if (be64_to_cpu(rsp->port_xmit_wait) > sum_vl_xmit_wait)
+   rsp->port_xmit_wait = cpu_to_be64(sum_vl_xmit_wait);
}
 }
 
@@ -2513,13 +2519,14 @@ static u64 get_error_counter_summary(struct ib_device 
*ibdev, u8 port)
return error_counter_summary;
 }
 
-static void a0_datacounters(struct hfi1_devdata *dd, struct _port_dctrs *rsp,
+static void a0_datacounters(struct hfi1_pportdata *ppd, struct _port_dctrs 
*rsp,
u32 vl_select_mask)
 {
-   if (!is_bx(dd)) {
+   if (!is_bx(ppd->dd)) {
unsigned long vl;
int vfi = 0;
u64 rcv_data, rcv_bubble, sum_vl_xmit_wait = 0;
+   u32 vl_all_mask = VL_MASK_ALL;
 
rcv_data = be64_to_cpu(rsp->port_rcv_data);
rcv_bubble = be64_to_cpu(rsp->port_rcv_bubble);
@@ -2545,10 +2552,11 @@ static void a0_datacounters(struct hfi1_devdata *dd, 
struct _port_dctrs *rsp,
vfi++;
}
vfi = 0;
-   for_each_set_bit(vl, (unsigned long *)&(vl_select_mask),
-   8 * sizeof(vl_select_mask)) {
+   for_each_set_bit(vl, (unsigned long *)&(vl_all_mask),
+8 * sizeof(vl_all_mask)) {
u64 tmp = sum_vl_xmit_wait +
-   be64_to_cpu(rsp->vls[vfi++].port_vl_xmit_wait);
+ read_port_cntr(ppd, C_TX_WAIT_VL,
+idx_from_vl(vl));
if (tmp < sum_vl_xmit_wait) {
/* we wrapped */
sum_vl_xmit_wait = (u64) ~0;
@@ -2710,7 +2718,7 @@ static int pma_get_opa_datacounters(struct opa_pma_mad 
*pmp,
vfi++;
}
 
-   a0_datacounters(dd, rsp, vl_select_mask);
+   a0_datacounters(ppd, rsp, vl_select_mask);
 
if (resp_len)
*resp_len += response_data_size;
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 11/17] staging/rdma/hfi1: Destroy workqueues if hfi1_register_ib_device() call returns error

2015-12-01 Thread Jubin John
From: Harish Chegondi 

Currently, if hfi1_register_ib_device() call is unsuccessful, workqueues
are not being destroyed before bailing out. This patch fixes this issue.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Harish Chegondi 
Signed-off-by: Jubin John 
---
Changes in v2:
- No changes

 drivers/staging/rdma/hfi1/init.c |9 -
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/init.c b/drivers/staging/rdma/hfi1/init.c
index 1c8286f..f9d9dc1 100644
--- a/drivers/staging/rdma/hfi1/init.c
+++ b/drivers/staging/rdma/hfi1/init.c
@@ -1336,6 +1336,7 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 {
int ret = 0, j, pidx, initfail;
struct hfi1_devdata *dd = NULL;
+   struct hfi1_pportdata *ppd;
 
/* First, lock the non-writable module parameters */
HFI1_CAP_LOCK();
@@ -1431,8 +1432,14 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (initfail || ret) {
stop_timers(dd);
flush_workqueue(ib_wq);
-   for (pidx = 0; pidx < dd->num_pports; ++pidx)
+   for (pidx = 0; pidx < dd->num_pports; ++pidx) {
hfi1_quiet_serdes(dd->pport + pidx);
+   ppd = dd->pport + pidx;
+   if (ppd->hfi1_wq) {
+   destroy_workqueue(ppd->hfi1_wq);
+   ppd->hfi1_wq = NULL;
+   }
+   }
if (!j)
hfi1_device_remove(dd);
if (!ret)
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 09/17] staging/rdma/hfi1: Correctly limit VLs against SDMA engines

2015-12-01 Thread Jubin John
From: Dean Luick 

Correctly reduce the number of VLs when limited by the number
of SDMA engines.

The hardware has multiple egress mechanisms, SDMA and pio, and multiples
of those. These mechanisms are chosen using the VL (8)

The fix corrects a panic issue with one of the platforms that doesn't have
enough SDMA (4) mechanisms for the typical number of VLs.

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
Changes in v2:
- Added more information in commit message

 drivers/staging/rdma/hfi1/chip.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index d9bb389..d17fd29 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -10610,9 +10610,9 @@ struct hfi1_devdata *hfi1_init_dd(struct pci_dev *pdev,
/* insure num_vls isn't larger than number of sdma engines */
if (HFI1_CAP_IS_KSET(SDMA) && num_vls > dd->chip_sdma_engines) {
dd_dev_err(dd, "num_vls %u too large, using %u VLs\n",
-   num_vls, HFI1_MAX_VLS_SUPPORTED);
-   ppd->vls_supported = num_vls = HFI1_MAX_VLS_SUPPORTED;
-   ppd->vls_operational = ppd->vls_supported;
+  num_vls, dd->chip_sdma_engines);
+   num_vls = dd->chip_sdma_engines;
+   ppd->vls_supported = dd->chip_sdma_engines;
}
 
/*
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 05/17] staging/rdma/hfi1: Clean up comments

2015-12-01 Thread Jubin John
From: Edward Mascarenhas 

Clean up comments by deleting numbering and terms internal to Intel.

The information on the actual bugs is not deleted.

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Edward Mascarenhas 
Signed-off-by: Jubin John 
---
Changes in v2:
- Added more information in commit message

 drivers/staging/rdma/hfi1/chip.c   |1 -
 drivers/staging/rdma/hfi1/driver.c |2 +-
 drivers/staging/rdma/hfi1/hfi.h|4 ++--
 drivers/staging/rdma/hfi1/pcie.c   |2 +-
 drivers/staging/rdma/hfi1/ud.c |2 +-
 5 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index dc69159..6b6af40 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -10310,7 +10310,6 @@ int hfi1_set_ctxt_jkey(struct hfi1_devdata *dd, 
unsigned ctxt, u16 jkey)
write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_JOB_KEY, reg);
/*
 * Enable send-side J_KEY integrity check, unless this is A0 h/w
-* (due to A0 erratum).
 */
if (!is_a0(dd)) {
reg = read_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE);
diff --git a/drivers/staging/rdma/hfi1/driver.c 
b/drivers/staging/rdma/hfi1/driver.c
index 4c52e78..1f2054f 100644
--- a/drivers/staging/rdma/hfi1/driver.c
+++ b/drivers/staging/rdma/hfi1/driver.c
@@ -368,7 +368,7 @@ static void rcv_hdrerr(struct hfi1_ctxtdata *rcd, struct 
hfi1_pportdata *ppd,
if (opcode == IB_OPCODE_CNP) {
/*
 * Only in pre-B0 h/w is the CNP_OPCODE handled
-* via this code path (errata 291394).
+* via this code path.
 */
struct hfi1_qp *qp = NULL;
u32 lqpn, rqpn;
diff --git a/drivers/staging/rdma/hfi1/hfi.h b/drivers/staging/rdma/hfi1/hfi.h
index 54ed6b3..92e3ef4 100644
--- a/drivers/staging/rdma/hfi1/hfi.h
+++ b/drivers/staging/rdma/hfi1/hfi.h
@@ -1694,7 +1694,7 @@ static inline u64 hfi1_pkt_default_send_ctxt_mask(struct 
hfi1_devdata *dd,
base_sc_integrity |= HFI1_PKT_KERNEL_SC_INTEGRITY;
 
if (is_a0(dd))
-   /* turn off send-side job key checks - A0 erratum */
+   /* turn off send-side job key checks - A0 */
return base_sc_integrity &
   ~SEND_CTXT_CHECK_ENABLE_CHECK_JOB_KEY_SMASK;
return base_sc_integrity;
@@ -1721,7 +1721,7 @@ static inline u64 hfi1_pkt_base_sdma_integrity(struct 
hfi1_devdata *dd)
| SEND_DMA_CHECK_ENABLE_CHECK_ENABLE_SMASK;
 
if (is_a0(dd))
-   /* turn off send-side job key checks - A0 erratum */
+   /* turn off send-side job key checks - A0 */
return base_sdma_integrity &
   ~SEND_DMA_CHECK_ENABLE_CHECK_JOB_KEY_SMASK;
return base_sdma_integrity;
diff --git a/drivers/staging/rdma/hfi1/pcie.c b/drivers/staging/rdma/hfi1/pcie.c
index 0b7eafb..f90d99d 100644
--- a/drivers/staging/rdma/hfi1/pcie.c
+++ b/drivers/staging/rdma/hfi1/pcie.c
@@ -986,7 +986,7 @@ retry:
 * PcieCfgRegPl100 - Gen3 Control
 *
 * turn off PcieCfgRegPl100.Gen3ZRxDcNonCompl
-* turn on PcieCfgRegPl100.EqEieosCnt (erratum)
+* turn on PcieCfgRegPl100.EqEieosCnt
 * Everything else zero.
 */
reg32 = PCIE_CFG_REG_PL100_EQ_EIEOS_CNT_SMASK;
diff --git a/drivers/staging/rdma/hfi1/ud.c b/drivers/staging/rdma/hfi1/ud.c
index 54ff1f5..a0701e5 100644
--- a/drivers/staging/rdma/hfi1/ud.c
+++ b/drivers/staging/rdma/hfi1/ud.c
@@ -672,7 +672,7 @@ void hfi1_ud_rcv(struct hfi1_packet *packet)
if (unlikely(bth1 & HFI1_BECN_SMASK)) {
/*
 * In pre-B0 h/w the CNP_OPCODE is handled via an
-* error path (errata 291394).
+* error path.
 */
struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
u32 lqpn =  be32_to_cpu(ohdr->bth[1]) & HFI1_QPN_MASK;
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 07/17] staging/rdma/hfi1: Extend quiet timeout

2015-12-01 Thread Jubin John
From: Dean Luick 

The longest quiet timeout is now 6s.  Extend the driver wait to 6s.

The driver wasn't following our internal specification: 6 seconds.
This patch corrects that issue.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
Changes in v2:
- Added more information in commit message

 drivers/staging/rdma/hfi1/chip.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 8191065..d9bb389 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -6371,9 +6371,10 @@ static int goto_offline(struct hfi1_pportdata *ppd, u8 
rem_reason)
 * depending on how the link went down.  The 8051 firmware
 * will observe the needed wait time and only move to ready
 * when that is completed.  The largest of the quiet timeouts
-* is 2.5s, so wait that long and then a bit more.
+* is 6s, so wait that long and then at least 0.5s more for
+* other transitions, and another 0.5s for a buffer.
 */
-   ret = wait_fm_ready(dd, 3000);
+   ret = wait_fm_ready(dd, 7000);
if (ret) {
dd_dev_err(dd,
"After going offline, timed out waiting for the 8051 to 
become ready to accept host requests\n");
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 08/17] staging/rdma/hfi1: Add a credit push on diagpkt allocate fail

2015-12-01 Thread Jubin John
From: Dean Luick 

When sending a diagnostic packet, if the send context does not
have enough room, force a credit return and try again.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
Changes in v2:
- No changes

 drivers/staging/rdma/hfi1/diag.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/diag.c b/drivers/staging/rdma/hfi1/diag.c
index 0aaad74..e4cd333 100644
--- a/drivers/staging/rdma/hfi1/diag.c
+++ b/drivers/staging/rdma/hfi1/diag.c
@@ -379,6 +379,7 @@ static ssize_t diagpkt_send(struct diag_pkt *dp)
pio_release_cb credit_cb = NULL;
void *credit_arg = NULL;
struct diagpkt_wait *wait = NULL;
+   int trycount = 0;
 
dd = hfi1_lookup(dp->unit);
if (!dd || !(dd->flags & HFI1_PRESENT) || !dd->kregbase) {
@@ -493,8 +494,15 @@ static ssize_t diagpkt_send(struct diag_pkt *dp)
credit_arg = wait;
}
 
+retry:
pbuf = sc_buffer_alloc(sc, total_len, credit_cb, credit_arg);
if (!pbuf) {
+   if (trycount == 0) {
+   /* force a credit return and try again */
+   sc_return_credits(sc);
+   trycount = 1;
+   goto retry;
+   }
/*
 * No send buffer means no credit callback.  Undo
 * the wait set-up that was done above.  We free wait
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 10/17] staging/rdma/hfi1: Adds software counters for bitfields within various error status fields

2015-12-01 Thread Jubin John
From: Joel Rosenzweig 

Provides error status counters for CceErrStatus, Send*ErrStatus,
RcvErrStatus and MISC_ERR_STATUS

Reviewed-by: Mitko Haralanov 
Reviewed-by: Mike Marciniszyn 
Signed-off-by: Joel Rosenzweig 
Signed-off-by: Jubin John 
---
Changes in v2:
- Refreshed patch on top of latest staging-next

 drivers/staging/rdma/hfi1/chip.c | 3185 +-
 drivers/staging/rdma/hfi1/chip.h |  269 
 drivers/staging/rdma/hfi1/hfi.h  |   34 +
 3 files changed, 3487 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index d17fd29..e875365 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -663,7 +663,7 @@ static struct flag_table egress_err_info_flags[] = {
  */
 #define SES(name) SEND_ERR_STATUS_SEND_##name##_ERR_SMASK
 static struct flag_table send_err_status_flags[] = {
-/* 0*/ FLAG_ENTRY0("SDmaRpyTagErr", SES(CSR_PARITY)),
+/* 0*/ FLAG_ENTRY0("SendCsrParityErr", SES(CSR_PARITY)),
 /* 1*/ FLAG_ENTRY0("SendCsrReadBadAddrErr", SES(CSR_READ_BAD_ADDR)),
 /* 2*/ FLAG_ENTRY0("SendCsrWriteBadAddrErr", SES(CSR_WRITE_BAD_ADDR))
 };
@@ -1538,6 +1538,2336 @@ static u64 access_sw_send_schedule(const struct 
cntr_entry *entry,
return dd->verbs_dev.n_send_schedule;
 }
 
+/* Software counters for the error status bits within MISC_ERR_STATUS */
+static u64 access_misc_pll_lock_fail_err_cnt(const struct cntr_entry *entry,
+void *context, int vl, int mode,
+u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[12];
+}
+
+static u64 access_misc_mbist_fail_err_cnt(const struct cntr_entry *entry,
+ void *context, int vl, int mode,
+ u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[11];
+}
+
+static u64 access_misc_invalid_eep_cmd_err_cnt(const struct cntr_entry *entry,
+  void *context, int vl, int mode,
+  u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[10];
+}
+
+static u64 access_misc_efuse_done_parity_err_cnt(const struct cntr_entry 
*entry,
+void *context, int vl,
+int mode, u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[9];
+}
+
+static u64 access_misc_efuse_write_err_cnt(const struct cntr_entry *entry,
+  void *context, int vl, int mode,
+  u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[8];
+}
+
+static u64 access_misc_efuse_read_bad_addr_err_cnt(
+   const struct cntr_entry *entry,
+   void *context, int vl, int mode, u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[7];
+}
+
+static u64 access_misc_efuse_csr_parity_err_cnt(const struct cntr_entry *entry,
+   void *context, int vl,
+   int mode, u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[6];
+}
+
+static u64 access_misc_fw_auth_failed_err_cnt(const struct cntr_entry *entry,
+ void *context, int vl, int mode,
+ u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[5];
+}
+
+static u64 access_misc_key_mismatch_err_cnt(const struct cntr_entry *entry,
+   void *context, int vl, int mode,
+   u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[4];
+}
+
+static u64 access_misc_sbus_write_failed_err_cnt(const struct cntr_entry 
*entry,
+void *context, int vl,
+int mode, u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   return dd->misc_err_status_cnt[3];
+}
+
+static u64 access_misc_csr_write_bad_addr_err_cnt(
+   const struct cntr_entry *entry,
+   void *context, int vl, int mode, u64 data)
+{
+   stru

[PATCH v2 14/17] staging/rdma/hfi1: unknown frame messages are not errors

2015-12-01 Thread Jubin John
From: Dean Luick 

Change reported unknown frame messages into a counter.
These are informational, no errors.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
Changes in v2:
- No changes

 drivers/staging/rdma/hfi1/chip.c |   18 ++
 drivers/staging/rdma/hfi1/chip.h |1 +
 drivers/staging/rdma/hfi1/hfi.h  |2 ++
 3 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 85365d8..e7c1505 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -1417,6 +1417,17 @@ static u64 access_sw_link_up_cnt(const struct cntr_entry 
*entry, void *context,
return read_write_sw(ppd->dd, &ppd->link_up, mode, data);
 }
 
+static u64 access_sw_unknown_frame_cnt(const struct cntr_entry *entry,
+  void *context, int vl, int mode,
+  u64 data)
+{
+   struct hfi1_pportdata *ppd = (struct hfi1_pportdata *)context;
+
+   if (vl != CNTR_INVALID_VL)
+   return 0;
+   return read_write_sw(ppd->dd, &ppd->unknown_frame_count, mode, data);
+}
+
 static u64 access_sw_xmit_discards(const struct cntr_entry *entry,
void *context, int vl, int mode, u64 data)
 {
@@ -4880,6 +4891,8 @@ static struct cntr_entry port_cntrs[PORT_CNTR_LAST] = {
access_sw_link_dn_cnt),
 [C_SW_LINK_UP] = CNTR_ELEM("SwLinkUp", 0, 0, CNTR_SYNTH | CNTR_32BIT,
access_sw_link_up_cnt),
+[C_SW_UNKNOWN_FRAME] = CNTR_ELEM("UnknownFrame", 0, 0, CNTR_NORMAL,
+access_sw_unknown_frame_cnt),
 [C_SW_XMIT_DSCD] = CNTR_ELEM("XmitDscd", 0, 0, CNTR_SYNTH | CNTR_32BIT,
access_sw_xmit_discards),
 [C_SW_XMIT_DSCD_VL] = CNTR_ELEM("XmitDscdVl", 0, 0,
@@ -7227,6 +7240,11 @@ static void handle_8051_interrupt(struct hfi1_devdata 
*dd, u32 unused, u64 reg)
}
err &= ~(u64)FAILED_LNI;
}
+   /* unknown frames can happen durning LNI, just count */
+   if (err & UNKNOWN_FRAME) {
+   ppd->unknown_frame_count++;
+   err &= ~(u64)UNKNOWN_FRAME;
+   }
if (err) {
/* report remaining errors, but do not do anything */
dd_dev_err(dd, "8051 info error: %s\n",
diff --git a/drivers/staging/rdma/hfi1/chip.h b/drivers/staging/rdma/hfi1/chip.h
index 3a51137..96f71e1 100644
--- a/drivers/staging/rdma/hfi1/chip.h
+++ b/drivers/staging/rdma/hfi1/chip.h
@@ -1080,6 +1080,7 @@ enum {
C_RX_WORDS,
C_SW_LINK_DOWN,
C_SW_LINK_UP,
+   C_SW_UNKNOWN_FRAME,
C_SW_XMIT_DSCD,
C_SW_XMIT_DSCD_VL,
C_SW_XMIT_CSTR_ERR,
diff --git a/drivers/staging/rdma/hfi1/hfi.h b/drivers/staging/rdma/hfi1/hfi.h
index 41aac12..fcf6331 100644
--- a/drivers/staging/rdma/hfi1/hfi.h
+++ b/drivers/staging/rdma/hfi1/hfi.h
@@ -713,6 +713,8 @@ struct hfi1_pportdata {
u64 link_downed;
/* number of times link retrained successfully */
u64 link_up;
+   /* number of times a link unknown frame was reported */
+   u64 unknown_frame_count;
/* port_ltp_crc_mode is returned in 'portinfo' MADs */
u16 port_ltp_crc_mode;
/* port_crc_mode_enabled is the crc we support */
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 04/17] staging/rdma/hfi1: Fix qp.h comments

2015-12-01 Thread Jubin John
From: Kaike Wan 

This patch fixes a few incorrect header file comments in qp.h

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Kaike Wan 
Signed-off-by: Jubin John 
---
Changes in v2:
- Added more information in commit message

 drivers/staging/rdma/hfi1/qp.h |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/qp.h b/drivers/staging/rdma/hfi1/qp.h
index 94fd748..62a94c5 100644
--- a/drivers/staging/rdma/hfi1/qp.h
+++ b/drivers/staging/rdma/hfi1/qp.h
@@ -211,7 +211,7 @@ int hfi1_qp_init(struct hfi1_ibdev *dev);
 void hfi1_qp_exit(struct hfi1_ibdev *dev);
 
 /**
- * hfi1_qp_waitup - wake up on the indicated event
+ * hfi1_qp_wakeup - wake up on the indicated event
  * @qp: the QP
  * @flag: flag the qp on which the qp is stalled
  */
@@ -222,19 +222,19 @@ struct sdma_engine *qp_to_sdma_engine(struct hfi1_qp *qp, 
u8 sc5);
 struct qp_iter;
 
 /**
- * qp_iter_init - wake up on the indicated event
+ * qp_iter_init - initialize the iterator for the qp hash list
  * @dev: the hfi1_ibdev
  */
 struct qp_iter *qp_iter_init(struct hfi1_ibdev *dev);
 
 /**
- * qp_iter_next - wakeup on the indicated event
+ * qp_iter_next - Find the next qp in the hash list
  * @iter: the iterator for the qp hash list
  */
 int qp_iter_next(struct qp_iter *iter);
 
 /**
- * qp_iter_next - wake up on the indicated event
+ * qp_iter_print - print the qp information to seq_file
  * @s: the seq_file to emit the qp information on
  * @iter: the iterator for the qp hash list
  */
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 13/17] staging/rdma/hfi1: remove SPC freeze error messages

2015-12-01 Thread Jubin John
From: Dean Luick 

An SPC freeze is not an error.  Remove the messages.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
Changes in v2:
- No changes

 drivers/staging/rdma/hfi1/chip.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 342a564..85365d8 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -6496,7 +6496,6 @@ void handle_freeze(struct work_struct *work)
struct hfi1_devdata *dd = ppd->dd;
 
/* wait for freeze indicators on all affected blocks */
-   dd_dev_info(dd, "Entering SPC freeze\n");
wait_for_freeze_status(dd, 1);
 
/* SPC is now frozen */
@@ -6554,7 +6553,6 @@ void handle_freeze(struct work_struct *work)
wake_up(&dd->event_queue);
 
/* no longer frozen */
-   dd_dev_err(dd, "Exiting SPC freeze\n");
 }
 
 /*
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 12/17] staging/rdma/hfi1: Unexpected link up pkey values are not an error

2015-12-01 Thread Jubin John
From: Dean Luick 

Only warn when link up pkeys are not what we expect.  Also, allow
for the pkey to already be initialized.

Reviewed-by: Arthur Kepner 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
Changes in v2:
- No changes

 drivers/staging/rdma/hfi1/chip.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index e875365..342a564 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -6725,10 +6725,10 @@ static void add_full_mgmt_pkey(struct hfi1_pportdata 
*ppd)
 {
struct hfi1_devdata *dd = ppd->dd;
 
-   /* Sanity check - ppd->pkeys[2] should be 0 */
-   if (ppd->pkeys[2] != 0)
-   dd_dev_err(dd, "%s pkey[2] already set to 0x%x, resetting it to 
0x%x\n",
-  __func__, ppd->pkeys[2], FULL_MGMT_P_KEY);
+   /* Sanity check - ppd->pkeys[2] should be 0, or already initalized */
+   if (!((ppd->pkeys[2] == 0) || (ppd->pkeys[2] == FULL_MGMT_P_KEY)))
+   dd_dev_warn(dd, "%s pkey[2] already set to 0x%x, resetting it 
to 0x%x\n",
+   __func__, ppd->pkeys[2], FULL_MGMT_P_KEY);
ppd->pkeys[2] = FULL_MGMT_P_KEY;
(void)hfi1_set_ib_cfg(ppd, HFI1_IB_CFG_PKEYS, 0);
 }
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 17/17] staging/rdma/hfi1: Adding counter resolutions for DataPortCounters

2015-12-01 Thread Jubin John
From: Andrea Lowe 

Changing the 32-bit reserved field in opa_port_data_counters_msg
to the new 'resolution' field. PMA will use resolutions to right-
shift values for LocalLinkIntegrity and LinkErrorRecovery when
computing the ErrorCounterSummary for a DataPortCounters request.

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Andrea Lowe 
Signed-off-by: Jubin John 
---
Changes in v2:
- No changes

 drivers/staging/rdma/hfi1/mad.c |   38 ++
 1 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/mad.c b/drivers/staging/rdma/hfi1/mad.c
index 6fb4eab..565f42c 100644
--- a/drivers/staging/rdma/hfi1/mad.c
+++ b/drivers/staging/rdma/hfi1/mad.c
@@ -2076,13 +2076,20 @@ struct opa_aggregate {
u8 data[0];
 };
 
-/* Request contains first two fields, response contains those plus the rest */
+#define MSK_LLI 0x00f0
+#define MSK_LLI_SFT 4
+#define MSK_LER 0x000f
+#define MSK_LER_SFT 0
+#define ADD_LLI 8
+#define ADD_LER 2
+
+/* Request contains first three fields, response contains those plus the rest 
*/
 struct opa_port_data_counters_msg {
__be64 port_select_mask[4];
__be32 vl_select_mask;
+   __be32 resolution;
 
/* Response fields follow */
-   __be32 reserved1;
struct _port_dctrs {
u8 port_number;
u8 reserved2[3];
@@ -2480,7 +2487,8 @@ static int pma_get_opa_portstatus(struct opa_pma_mad *pmp,
return reply((struct ib_mad_hdr *)pmp);
 }
 
-static u64 get_error_counter_summary(struct ib_device *ibdev, u8 port)
+static u64 get_error_counter_summary(struct ib_device *ibdev, u8 port,
+u8 res_lli, u8 res_ler)
 {
struct hfi1_devdata *dd = dd_from_ibdev(ibdev);
struct hfi1_ibport *ibp = to_iport(ibdev, port);
@@ -2496,14 +2504,14 @@ static u64 get_error_counter_summary(struct ib_device 
*ibdev, u8 port)
CNTR_INVALID_VL);
error_counter_summary += read_dev_cntr(dd, C_DC_RMT_PHY_ERR,
CNTR_INVALID_VL);
-   error_counter_summary += read_dev_cntr(dd, C_DC_TX_REPLAY,
-   CNTR_INVALID_VL);
-   error_counter_summary += read_dev_cntr(dd, C_DC_RX_REPLAY,
-   CNTR_INVALID_VL);
-   error_counter_summary += read_dev_cntr(dd, C_DC_SEQ_CRC_CNT,
-   CNTR_INVALID_VL);
-   error_counter_summary += read_dev_cntr(dd, C_DC_REINIT_FROM_PEER_CNT,
-   CNTR_INVALID_VL);
+   /* local link integrity must be right-shifted by the lli resolution */
+   tmp = read_dev_cntr(dd, C_DC_RX_REPLAY, CNTR_INVALID_VL);
+   tmp += read_dev_cntr(dd, C_DC_TX_REPLAY, CNTR_INVALID_VL);
+   error_counter_summary += (tmp >> res_lli);
+   /* link error recovery must b right-shifted by the ler resolution */
+   tmp = read_dev_cntr(dd, C_DC_SEQ_CRC_CNT, CNTR_INVALID_VL);
+   tmp += read_dev_cntr(dd, C_DC_REINIT_FROM_PEER_CNT, CNTR_INVALID_VL);
+   error_counter_summary += (tmp >> res_ler);
error_counter_summary += read_dev_cntr(dd, C_DC_RCV_ERR,
CNTR_INVALID_VL);
error_counter_summary += read_dev_cntr(dd, C_RCV_OVF, CNTR_INVALID_VL);
@@ -2583,6 +2591,7 @@ static int pma_get_opa_datacounters(struct opa_pma_mad 
*pmp,
u32 num_ports;
u8 num_pslm;
u8 lq, num_vls;
+   u8 res_lli, res_ler;
u64 port_mask;
unsigned long port_num;
unsigned long vl;
@@ -2593,6 +2602,10 @@ static int pma_get_opa_datacounters(struct opa_pma_mad 
*pmp,
num_pslm = hweight64(be64_to_cpu(req->port_select_mask[3]));
num_vls = hweight32(be32_to_cpu(req->vl_select_mask));
vl_select_mask = be32_to_cpu(req->vl_select_mask);
+   res_lli = (u8)(be32_to_cpu(req->resolution) & MSK_LLI) >> MSK_LLI_SFT;
+   res_lli = res_lli ? res_lli + ADD_LLI : 0;
+   res_ler = (u8)(be32_to_cpu(req->resolution) & MSK_LER) >> MSK_LER_SFT;
+   res_ler = res_ler ? res_ler + ADD_LER : 0;
 
if (num_ports != 1 || (vl_select_mask & ~VL_MASK_ALL)) {
pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;
@@ -2663,7 +2676,8 @@ static int pma_get_opa_datacounters(struct opa_pma_mad 
*pmp,
cpu_to_be64(read_dev_cntr(dd, C_DC_RCV_BCN, CNTR_INVALID_VL));
 
rsp->port_error_counter_summary =
-   cpu_to_be64(get_error_counter_summary(ibdev, port));
+   cpu_to_be64(get_error_counter_summary(ibdev, port,
+ res_lli, res_ler));
 
vlinfo = &(rsp->vls[0]);
vfi = 0;
-- 
1.7.1

___
devel mailing list
de...@linux

Re: [PATCH v2 00/13] staging/rdma/hfi1: Driver cleanup and misc fixes

2015-12-08 Thread Jubin John
Hi Greg,

Is this patch series still in your queue? I just wanted to make sure it
didn't get dropped.

Thanks,
Jubin John
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/3] staging/rdma/hfi1: Remove incorrect link credit check

2015-12-17 Thread Jubin John
From: Dean Luick 

Remove an invalid sanity check that compares the local link
credits with the peer link credits.  The two have no dependency
on each other.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index dc69159..78a5f08 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -7267,8 +7267,7 @@ static int set_buffer_control(struct hfi1_devdata *dd,
new_bc->vl[i].shared = 0;
}
new_total += be16_to_cpu(new_bc->overall_shared_limit);
-   if (new_total > (u32)dd->link_credits)
-   return -EINVAL;
+
/* fetch the current values */
get_buffer_control(dd, &cur_bc, &cur_total);
 
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/3] staging/rdma/hfi1: Fix module parameter spelling

2015-12-17 Thread Jubin John
Fix the spelling of user_credit_return_threshold, it was incorrectly
spelled as user_credit_return_theshold causing two module parameters,
one with typo, to be shown in modinfo

Reviewed-by: Ira Weiny 
Reviewed-by: Mike Marciniszyn 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/init.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/init.c b/drivers/staging/rdma/hfi1/init.c
index 1c8286f..8f13d53 100644
--- a/drivers/staging/rdma/hfi1/init.c
+++ b/drivers/staging/rdma/hfi1/init.c
@@ -113,7 +113,7 @@ MODULE_PARM_DESC(hdrq_entsize, "Size of header queue 
entries: 2 - 8B, 16 - 64B (
 
 unsigned int user_credit_return_threshold = 33;/* default is 33% */
 module_param(user_credit_return_threshold, uint, S_IRUGO);
-MODULE_PARM_DESC(user_credit_return_theshold, "Credit return threshold for 
user send contexts, return when unreturned credits passes this many blocks (in 
percent of allocated blocks, 0 is off)");
+MODULE_PARM_DESC(user_credit_return_threshold, "Credit return threshold for 
user send contexts, return when unreturned credits passes this many blocks (in 
percent of allocated blocks, 0 is off)");
 
 static inline u64 encode_rcv_header_entry_size(u16);
 
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/3] staging/rdma/hfi1: check for ARMED->ACTIVE transition in receive interrupt

2015-12-17 Thread Jubin John
From: Jim Snow 

The link state will transition from ARMED to ACTIVE when a non-SC15
packet arrives, but the driver might not notice the change.  With this
fix, if the slowpath receive interrupt handler sees a non-SC15 packet
while in the ARMED state, we queue work to call linkstate_active_work
from process context to promote it to ACTIVE.

Signed-off-by: Jim Snow 
Signed-off-by: Brendan Cunningham 
Reviewed-by: Dean Luick 
Signed-off-by: Jubin John 
---
 drivers/staging/rdma/hfi1/chip.c   |5 ++-
 drivers/staging/rdma/hfi1/chip.h   |2 +
 drivers/staging/rdma/hfi1/driver.c |   66 
 drivers/staging/rdma/hfi1/hfi.h|   12 ++
 drivers/staging/rdma/hfi1/init.c   |1 +
 5 files changed, 84 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 78a5f08..f82b848 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -4606,7 +4606,7 @@ static inline void clear_recv_intr(struct hfi1_ctxtdata 
*rcd)
 }
 
 /* force the receive interrupt */
-static inline void force_recv_intr(struct hfi1_ctxtdata *rcd)
+void force_recv_intr(struct hfi1_ctxtdata *rcd)
 {
write_csr(rcd->dd, CCE_INT_FORCE + (8 * rcd->ireg), rcd->imask);
 }
@@ -4705,7 +4705,7 @@ u32 read_physical_state(struct hfi1_devdata *dd)
& DC_DC8051_STS_CUR_STATE_PORT_MASK;
 }
 
-static u32 read_logical_state(struct hfi1_devdata *dd)
+u32 read_logical_state(struct hfi1_devdata *dd)
 {
u64 reg;
 
@@ -6658,6 +6658,7 @@ int set_link_state(struct hfi1_pportdata *ppd, u32 state)
ppd->link_enabled = 1;
}
 
+   set_all_slowpath(ppd->dd);
ret = set_local_link_attributes(ppd);
if (ret)
break;
diff --git a/drivers/staging/rdma/hfi1/chip.h b/drivers/staging/rdma/hfi1/chip.h
index d74aed8..620cf08 100644
--- a/drivers/staging/rdma/hfi1/chip.h
+++ b/drivers/staging/rdma/hfi1/chip.h
@@ -691,6 +691,8 @@ u64 read_dev_cntr(struct hfi1_devdata *dd, int index, int 
vl);
 u64 write_dev_cntr(struct hfi1_devdata *dd, int index, int vl, u64 data);
 u64 read_port_cntr(struct hfi1_pportdata *ppd, int index, int vl);
 u64 write_port_cntr(struct hfi1_pportdata *ppd, int index, int vl, u64 data);
+u32 read_logical_state(struct hfi1_devdata *dd);
+void force_recv_intr(struct hfi1_ctxtdata *rcd);
 
 /* Per VL indexes */
 enum {
diff --git a/drivers/staging/rdma/hfi1/driver.c 
b/drivers/staging/rdma/hfi1/driver.c
index 4c52e78..16b1be1 100644
--- a/drivers/staging/rdma/hfi1/driver.c
+++ b/drivers/staging/rdma/hfi1/driver.c
@@ -862,6 +862,15 @@ static inline void set_all_dma_rtail(struct hfi1_devdata 
*dd)
&handle_receive_interrupt_dma_rtail;
 }
 
+void set_all_slowpath(struct hfi1_devdata *dd)
+{
+   int i;
+
+   for (i = HFI1_CTRL_CTXT + 1; i < dd->first_user_ctxt; i++)
+   dd->rcd[i]->do_interrupt =
+ &handle_receive_interrupt;
+}
+
 /*
  * handle_receive_interrupt - receive a packet
  * @rcd: the context
@@ -929,6 +938,27 @@ int handle_receive_interrupt(struct hfi1_ctxtdata *rcd, 
int thread)
last = skip_rcv_packet(&packet, thread);
skip_pkt = 0;
} else {
+   /* Auto activate link on non-SC15 packet receive */
+   if (unlikely(rcd->ppd->host_link_state ==
+HLS_UP_ARMED)) {
+   struct work_struct *lsaw =
+ &rcd->ppd->linkstate_active_work;
+   struct hfi1_message_header *hdr =
+ hfi1_get_msgheader(packet.rcd->dd,
+packet.rhf_addr);
+   if (hdr2sc(hdr, packet.rhf) != 0xf) {
+   int hwstate = read_logical_state(dd);
+
+   if (hwstate != LSTATE_ACTIVE) {
+   dd_dev_info(dd, "Unexpected 
link state %d\n",
+   hwstate);
+   } else {
+   queue_work(
+ rcd->ppd->hfi1_wq, lsaw);
+   goto bail;
+   }
+   }
+   }
last = process_rcv_packet(&packet, thread);
}
 
@@ -984,6 +1014,42 @@ bail:
 }
 
 /*
+ * 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 up

Re: [PATCH 2/3] staging/rdma/hfi1: Fix module parameter spelling

2015-12-18 Thread Jubin John
On Fri, Dec 18, 2015 at 09:42:20AM +0300, Dan Carpenter wrote:
> Nice.  Whenever you see a bug like this, you should report it to
> kernel-janitors because you know that 10 other people have made the same
> mistake.

Sure, I will do that for similar bugs.
> 
> I will take care of it.

Thank you.
> 
> regards,
> dan carpenter
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 0/6] staging/rdma/hfi1: Driver cleanup and misc fixes

2015-12-21 Thread Jubin John
These patches were part of patch series:
http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2015-November/081566.html
but did not apply cleanly to the staging-testing branch.

Refreshed the remaining 6 patches against the latest staging-testing.

Changes in v2:
- 01/13: Updated commit message with more information about changes in 
patch
- 04/13: Updated patch subject with "hfi1" instead of "hfi"
- 07/13: Refreshed patch based on new hfi patches in staging-next
- 12/13: Changed logic based on Dan's suggestions in
 http://marc.info/?l=linux-driver-devel&m=144723149431368&w=2
Changes in v3:
- Refreshed remaining 6 patches against latest staging-testing

Dean Luick (1):
  staging/rdma/hfi1: Remove unneeded variable index

Harish Chegondi (1):
  staging/rdma/hfi1: Move s_sde to the read mostly portion of the
hfi1_qp structure

Jubin John (2):
  staging/rdma/hfi1: Use BIT macro
  staging/rdma/hfi1: Change default krcvqs

Mark F. Brown (1):
  staging/rdma/hfi1: change krcvqs module parameter type from byte to
uint

Vennila Megavannan (1):
  staging/rdma/hfi1: adding per SDMA engine stats to hfistats

 drivers/staging/rdma/hfi1/chip.c   |  127 +---
 drivers/staging/rdma/hfi1/chip.h   |   53 +++-
 drivers/staging/rdma/hfi1/chip_registers.h |1 +
 drivers/staging/rdma/hfi1/common.h |4 +-
 drivers/staging/rdma/hfi1/hfi.h|   25 +++---
 drivers/staging/rdma/hfi1/init.c   |6 +-
 drivers/staging/rdma/hfi1/mad.c|4 +-
 drivers/staging/rdma/hfi1/qp.h |2 +-
 drivers/staging/rdma/hfi1/qsfp.h   |   10 +-
 drivers/staging/rdma/hfi1/sdma.c   |   17 +++-
 drivers/staging/rdma/hfi1/sdma.h   |7 ++
 drivers/staging/rdma/hfi1/verbs.h  |2 +-
 12 files changed, 189 insertions(+), 69 deletions(-)

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 4/6] staging/rdma/hfi1: Change default krcvqs

2015-12-21 Thread Jubin John
Change the default number of krcvqs to number of numa nodes + 1
based on the performance data collected.

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Jubin John 
---
Changes in v2:
- None

Changes in v3:
- Refreshed patch against latest staging-testing

 drivers/staging/rdma/hfi1/chip.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index bbe5ad8..503bfca 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -12445,7 +12445,7 @@ static int set_up_context_variables(struct hfi1_devdata 
*dd)
 */
num_kernel_contexts = n_krcvqs + MIN_KERNEL_KCTXTS - 1;
else
-   num_kernel_contexts = num_online_nodes();
+   num_kernel_contexts = num_online_nodes() + 1;
num_kernel_contexts =
max_t(int, MIN_KERNEL_KCTXTS, num_kernel_contexts);
/*
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 3/6] staging/rdma/hfi1: change krcvqs module parameter type from byte to uint

2015-12-21 Thread Jubin John
From: Mark F. Brown 

The krcvqs parameter is displayed incorrectly in sysfs.
The workaround is to set the param type as uint.

Reviewed-by: Mike Marciniszyn 
Reviewed-by: Mitko Haralanov 
Signed-off-by: Mark F. Brown 
Signed-off-by: Jubin John 
---
Changes in v2:
- None

Changes in v3:
- Refreshed patch against latest staging-testing

 drivers/staging/rdma/hfi1/hfi.h  |2 +-
 drivers/staging/rdma/hfi1/init.c |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/hfi.h b/drivers/staging/rdma/hfi1/hfi.h
index 2dfd402..d4a859f 100644
--- a/drivers/staging/rdma/hfi1/hfi.h
+++ b/drivers/staging/rdma/hfi1/hfi.h
@@ -1667,7 +1667,7 @@ extern unsigned int hfi1_cu;
 extern unsigned int user_credit_return_threshold;
 extern int num_user_contexts;
 extern unsigned n_krcvqs;
-extern u8 krcvqs[];
+extern uint krcvqs[];
 extern int krcvqsset;
 extern uint kdeth_qp;
 extern uint loopback;
diff --git a/drivers/staging/rdma/hfi1/init.c b/drivers/staging/rdma/hfi1/init.c
index 35b5e41..dbdc631 100644
--- a/drivers/staging/rdma/hfi1/init.c
+++ b/drivers/staging/rdma/hfi1/init.c
@@ -87,9 +87,9 @@ module_param_named(num_user_contexts, num_user_contexts, 
uint, S_IRUGO);
 MODULE_PARM_DESC(
num_user_contexts, "Set max number of user contexts to use");
 
-u8 krcvqs[RXE_NUM_DATA_VL];
+uint krcvqs[RXE_NUM_DATA_VL];
 int krcvqsset;
-module_param_array(krcvqs, byte, &krcvqsset, S_IRUGO);
+module_param_array(krcvqs, uint, &krcvqsset, S_IRUGO);
 MODULE_PARM_DESC(krcvqs, "Array of the number of non-control kernel receive 
queues by VL");
 
 /* computed based on above array */
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 2/6] staging/rdma/hfi1: Move s_sde to the read mostly portion of the hfi1_qp structure

2015-12-21 Thread Jubin John
From: Harish Chegondi 

This would reduce L2 cache misses on s_sde in the _hfi1_schedule_send
function when invoked from post_send thereby improving performance of
post_send.

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Harish Chegondi 
Signed-off-by: Jubin John 
---
Changes in v2:
- None

Changes in v3:
- Refreshed patch against latest staging-testing

 drivers/staging/rdma/hfi1/verbs.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/verbs.h 
b/drivers/staging/rdma/hfi1/verbs.h
index 72106e5..d22db39 100644
--- a/drivers/staging/rdma/hfi1/verbs.h
+++ b/drivers/staging/rdma/hfi1/verbs.h
@@ -441,6 +441,7 @@ struct hfi1_qp {
struct hfi1_swqe *s_wq;  /* send work queue */
struct hfi1_mmap_info *ip;
struct ahg_ib_header *s_hdr; /* next packet header to send */
+   struct sdma_engine *s_sde; /* current sde */
/* sc for UC/RC QPs - based on ah for UD */
u8 s_sc;
unsigned long timeout_jiffies;  /* computed from timeout */
@@ -506,7 +507,6 @@ struct hfi1_qp {
struct hfi1_swqe *s_wqe;
struct hfi1_sge_state s_sge; /* current send request data */
struct hfi1_mregion *s_rdma_mr;
-   struct sdma_engine *s_sde; /* current sde */
u32 s_cur_size; /* size of send packet in bytes */
u32 s_len;  /* total length of s_sge */
u32 s_rdma_read_len;/* total length of s_rdma_read_sge */
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 1/6] staging/rdma/hfi1: Use BIT macro

2015-12-21 Thread Jubin John
This patch fixes the checkpatch issue:
CHECK: Prefer using the BIT macro

Use of BIT macro for HDRQ_INCREMENT in chip.h causes a change in
format specifier for error message in init.c in order to avoid a
build warning.

Reviewed-by: Dean Luick 
Reviewed-by: Ira Weiny 
Reviewed-by: Mike Marciniszyn 
Signed-off-by: Jubin John 
---
Changes in v2:
- Updated commit message with more information about changes in patch

Changes in v3:
- Refreshed patch against latest staging-testing

 drivers/staging/rdma/hfi1/chip.h   |   48 ++--
 drivers/staging/rdma/hfi1/common.h |4 +-
 drivers/staging/rdma/hfi1/hfi.h|   22 
 drivers/staging/rdma/hfi1/init.c   |2 +-
 drivers/staging/rdma/hfi1/mad.c|4 +-
 drivers/staging/rdma/hfi1/qp.h |2 +-
 drivers/staging/rdma/hfi1/qsfp.h   |   10 +++---
 drivers/staging/rdma/hfi1/sdma.c   |8 +++---
 8 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.h b/drivers/staging/rdma/hfi1/chip.h
index 5b375dd..1368a44 100644
--- a/drivers/staging/rdma/hfi1/chip.h
+++ b/drivers/staging/rdma/hfi1/chip.h
@@ -242,18 +242,18 @@
 #define HCMD_SUCCESS 2
 
 /* DC_DC8051_DBG_ERR_INFO_SET_BY_8051.ERROR - error flags */
-#define SPICO_ROM_FAILED   (1 <<  0)
-#define UNKNOWN_FRAME  (1 <<  1)
-#define TARGET_BER_NOT_MET (1 <<  2)
-#define FAILED_SERDES_INTERNAL_LOOPBACK (1 <<  3)
-#define FAILED_SERDES_INIT (1 <<  4)
-#define FAILED_LNI_POLLING (1 <<  5)
-#define FAILED_LNI_DEBOUNCE(1 <<  6)
-#define FAILED_LNI_ESTBCOMM(1 <<  7)
-#define FAILED_LNI_OPTEQ   (1 <<  8)
-#define FAILED_LNI_VERIFY_CAP1 (1 <<  9)
-#define FAILED_LNI_VERIFY_CAP2 (1 << 10)
-#define FAILED_LNI_CONFIGLT(1 << 11)
+#define SPICO_ROM_FAILED   BIT(0)
+#define UNKNOWN_FRAME  BIT(1)
+#define TARGET_BER_NOT_MET BIT(2)
+#define FAILED_SERDES_INTERNAL_LOOPBACKBIT(3)
+#define FAILED_SERDES_INIT BIT(4)
+#define FAILED_LNI_POLLING BIT(5)
+#define FAILED_LNI_DEBOUNCEBIT(6)
+#define FAILED_LNI_ESTBCOMMBIT(7)
+#define FAILED_LNI_OPTEQ   BIT(8)
+#define FAILED_LNI_VERIFY_CAP1 BIT(9)
+#define FAILED_LNI_VERIFY_CAP2 BIT(10)
+#define FAILED_LNI_CONFIGLTBIT(11)
 
 #define FAILED_LNI (FAILED_LNI_POLLING | FAILED_LNI_DEBOUNCE \
| FAILED_LNI_ESTBCOMM | FAILED_LNI_OPTEQ \
@@ -262,16 +262,16 @@
| FAILED_LNI_CONFIGLT)
 
 /* DC_DC8051_DBG_ERR_INFO_SET_BY_8051.HOST_MSG - host message flags */
-#define HOST_REQ_DONE (1 << 0)
-#define BC_PWR_MGM_MSG(1 << 1)
-#define BC_SMA_MSG(1 << 2)
-#define BC_BCC_UNKOWN_MSG (1 << 3)
-#define BC_IDLE_UNKNOWN_MSG   (1 << 4)
-#define EXT_DEVICE_CFG_REQ(1 << 5)
-#define VERIFY_CAP_FRAME  (1 << 6)
-#define LINKUP_ACHIEVED   (1 << 7)
-#define LINK_GOING_DOWN   (1 << 8)
-#define LINK_WIDTH_DOWNGRADED  (1 << 9)
+#define HOST_REQ_DONE  BIT(0)
+#define BC_PWR_MGM_MSG BIT(1)
+#define BC_SMA_MSG BIT(2)
+#define BC_BCC_UNKNOWN_MSG BIT(3)
+#define BC_IDLE_UNKNOWN_MSGBIT(4)
+#define EXT_DEVICE_CFG_REQ BIT(5)
+#define VERIFY_CAP_FRAME   BIT(6)
+#define LINKUP_ACHIEVEDBIT(7)
+#define LINK_GOING_DOWNBIT(8)
+#define LINK_WIDTH_DOWNGRADED  BIT(9)
 
 /* DC_DC8051_CFG_EXT_DEV_1.REQ_TYPE - 8051 host requests */
 #define HREQ_LOAD_CONFIG   0x01
@@ -335,14 +335,14 @@
  * the CSR fields hold multiples of this value.
  */
 #define RCV_SHIFT 3
-#define RCV_INCREMENT (1 << RCV_SHIFT)
+#define RCV_INCREMENT BIT(RCV_SHIFT)
 
 /*
  * Receive header queue entry increment - the CSR holds multiples of
  * this value.
  */
 #define HDRQ_SIZE_SHIFT 5
-#define HDRQ_INCREMENT (1 << HDRQ_SIZE_SHIFT)
+#define HDRQ_INCREMENT BIT(HDRQ_SIZE_SHIFT)
 
 /*
  * Freeze handling flags
diff --git a/drivers/staging/rdma/hfi1/common.h 
b/drivers/staging/rdma/hfi1/common.h
index 5dd9272..e4b1dc6 100644
--- a/drivers/staging/rdma/hfi1/common.h
+++ b/drivers/staging/rdma/hfi1/common.h
@@ -349,10 +349,10 @@ struct hfi1_message_header {
 #define HFI1_QPN_MASK 0xFF
 #define HFI1_FECN_SHIFT 31
 #define HFI1_FECN_MASK 1
-#define HFI1_FECN_SMASK (1 << HFI1_FECN_SHIFT)
+#define HFI1_FECN_SMASK BIT(HFI1_FECN_SHIFT)
 #define HFI1_BECN_SHIFT 30
 #define HFI1_BECN_MASK 1
-#define HFI1_BECN_SMASK (1 << HFI1_BECN_SHIFT)
+#define HFI1_BECN_SMASK BIT(HFI1_BECN_SHIFT)
 #define HFI1_MULTICAST_LID_BASE 0xC000
 
 static inline __u64 rhf_to_cpu(const __le32 *rbuf)
diff --git a/drivers/staging/rdma/hfi1/hfi.h b/drivers/staging/rdma/hfi1

[PATCH v3 6/6] staging/rdma/hfi1: Remove unneeded variable index

2015-12-21 Thread Jubin John
From: Dean Luick 

The variable "index" increments the same as dd->ndevcntrs.
Just use the later.  Remove uneeded usage of "index" in the
fill loop - it is not used there or later in the function.

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Dean Luick 
Signed-off-by: Jubin John 
---
Changes in v2:
- None

Changes in v3:
- Refreshed patch against latest staging-testing

 drivers/staging/rdma/hfi1/chip.c |   19 +++
 1 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index f4f720d..1109049 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -11592,7 +11592,7 @@ mod_timer(&dd->synth_stats_timer, jiffies + HZ * 
SYNTH_CNT_TIME);
 #define C_MAX_NAME 13 /* 12 chars + one for /0 */
 static int init_cntrs(struct hfi1_devdata *dd)
 {
-   int i, rcv_ctxts, index, j;
+   int i, rcv_ctxts, j;
size_t sz;
char *p;
char name[C_MAX_NAME];
@@ -11609,7 +11609,6 @@ static int init_cntrs(struct hfi1_devdata *dd)
/* size names and determine how many we have*/
dd->ndevcntrs = 0;
sz = 0;
-   index = 0;
 
for (i = 0; i < DEV_CNTR_LAST; i++) {
hfi1_dbg_early("Init cntr %s\n", dev_cntrs[i].name);
@@ -11620,7 +11619,7 @@ static int init_cntrs(struct hfi1_devdata *dd)
 
if (dev_cntrs[i].flags & CNTR_VL) {
hfi1_dbg_early("\tProcessing VL cntr\n");
-   dev_cntrs[i].offset = index;
+   dev_cntrs[i].offset = dd->ndevcntrs;
for (j = 0; j < C_VL_COUNT; j++) {
memset(name, '\0', C_MAX_NAME);
snprintf(name, C_MAX_NAME, "%s%d",
@@ -11630,13 +11629,12 @@ static int init_cntrs(struct hfi1_devdata *dd)
sz++;
hfi1_dbg_early("\t\t%s\n", name);
dd->ndevcntrs++;
-   index++;
}
} else if (dev_cntrs[i].flags & CNTR_SDMA) {
hfi1_dbg_early(
   "\tProcessing per SDE counters chip 
enginers %u\n",
   dd->chip_sdma_engines);
-   dev_cntrs[i].offset = index;
+   dev_cntrs[i].offset = dd->ndevcntrs;
for (j = 0; j < dd->chip_sdma_engines; j++) {
memset(name, '\0', C_MAX_NAME);
snprintf(name, C_MAX_NAME, "%s%d",
@@ -11645,24 +11643,22 @@ static int init_cntrs(struct hfi1_devdata *dd)
sz++;
hfi1_dbg_early("\t\t%s\n", name);
dd->ndevcntrs++;
-   index++;
}
} else {
/* +1 for newline  */
sz += strlen(dev_cntrs[i].name) + 1;
+   dev_cntrs[i].offset = dd->ndevcntrs;
dd->ndevcntrs++;
-   dev_cntrs[i].offset = index;
-   index++;
hfi1_dbg_early("\tAdding %s\n", dev_cntrs[i].name);
}
}
 
/* allocate space for the counter values */
-   dd->cntrs = kcalloc(index, sizeof(u64), GFP_KERNEL);
+   dd->cntrs = kcalloc(dd->ndevcntrs, sizeof(u64), GFP_KERNEL);
if (!dd->cntrs)
goto bail;
 
-   dd->scntrs = kcalloc(index, sizeof(u64), GFP_KERNEL);
+   dd->scntrs = kcalloc(dd->ndevcntrs, sizeof(u64), GFP_KERNEL);
if (!dd->scntrs)
goto bail;
 
@@ -11674,7 +11670,7 @@ static int init_cntrs(struct hfi1_devdata *dd)
goto bail;
 
/* fill in the names */
-   for (p = dd->cntrnames, i = 0, index = 0; i < DEV_CNTR_LAST; i++) {
+   for (p = dd->cntrnames, i = 0; i < DEV_CNTR_LAST; i++) {
if (dev_cntrs[i].flags & CNTR_DISABLED) {
/* Nothing */
} else {
@@ -11704,7 +11700,6 @@ static int init_cntrs(struct hfi1_devdata *dd)
p += strlen(dev_cntrs[i].name);
*p++ = '\n';
}
-   index++;
}
}
 
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 5/6] staging/rdma/hfi1: adding per SDMA engine stats to hfistats

2015-12-21 Thread Jubin John
From: Vennila Megavannan 

Added the following per sdma engine stats:
  - SendDmaDescFetchedCnt
  - software maintained count of SDMA interrupts
 (SDmaInt, SDmaIdleInt, SDmaProgressInt)
  - software maintained counts of SDMA error cases

Reviewed-by: Dennis Dalessandro 
Signed-off-by: Mike Marciniszyn 
Signed-off-by: Vennila Megavannan 
Signed-off-by: Jubin John 
---
Changes in v2:
- None

Changes in v3:
- Refreshed patch against latest staging-testing

 drivers/staging/rdma/hfi1/chip.c   |  110 +++-
 drivers/staging/rdma/hfi1/chip.h   |5 +
 drivers/staging/rdma/hfi1/chip_registers.h |1 +
 drivers/staging/rdma/hfi1/hfi.h|1 +
 drivers/staging/rdma/hfi1/sdma.c   |9 ++-
 drivers/staging/rdma/hfi1/sdma.h   |7 ++
 6 files changed, 129 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index 503bfca..f4f720d 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -1297,10 +1297,58 @@ static u64 dev_access_u32_csr(const struct cntr_entry 
*entry,
void *context, int vl, int mode, u64 data)
 {
struct hfi1_devdata *dd = context;
+   u64 csr = entry->csr;
 
-   if (vl != CNTR_INVALID_VL)
-   return 0;
-   return read_write_csr(dd, entry->csr, mode, data);
+   if (entry->flags & CNTR_SDMA) {
+   if (vl == CNTR_INVALID_VL)
+   return 0;
+   csr += 0x100 * vl;
+   } else {
+   if (vl != CNTR_INVALID_VL)
+   return 0;
+   }
+   return read_write_csr(dd, csr, mode, data);
+}
+
+static u64 access_sde_err_cnt(const struct cntr_entry *entry,
+ void *context, int idx, int mode, u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   if (dd->per_sdma && idx < dd->num_sdma)
+   return dd->per_sdma[idx].err_cnt;
+   return 0;
+}
+
+static u64 access_sde_int_cnt(const struct cntr_entry *entry,
+ void *context, int idx, int mode, u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   if (dd->per_sdma && idx < dd->num_sdma)
+   return dd->per_sdma[idx].sdma_int_cnt;
+   return 0;
+}
+
+static u64 access_sde_idle_int_cnt(const struct cntr_entry *entry,
+  void *context, int idx, int mode, u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   if (dd->per_sdma && idx < dd->num_sdma)
+   return dd->per_sdma[idx].idle_int_cnt;
+   return 0;
+}
+
+static u64 access_sde_progress_int_cnt(const struct cntr_entry *entry,
+  void *context, int idx, int mode,
+  u64 data)
+{
+   struct hfi1_devdata *dd = (struct hfi1_devdata *)context;
+
+   if (dd->per_sdma && idx < dd->num_sdma)
+   return dd->per_sdma[idx].progress_int_cnt;
+   return 0;
 }
 
 static u64 dev_access_u64_csr(const struct cntr_entry *entry, void *context,
@@ -4070,6 +4118,22 @@ static struct cntr_entry dev_cntrs[DEV_CNTR_LAST] = {
access_sw_kmem_wait),
 [C_SW_SEND_SCHED] = CNTR_ELEM("SendSched", 0, 0, CNTR_NORMAL,
access_sw_send_schedule),
+[C_SDMA_DESC_FETCHED_CNT] = CNTR_ELEM("SDEDscFdCn",
+ SEND_DMA_DESC_FETCHED_CNT, 0,
+ CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
+ dev_access_u32_csr),
+[C_SDMA_INT_CNT] = CNTR_ELEM("SDMAInt", 0, 0,
+CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
+access_sde_int_cnt),
+[C_SDMA_ERR_CNT] = CNTR_ELEM("SDMAErrCt", 0, 0,
+CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
+access_sde_err_cnt),
+[C_SDMA_IDLE_INT_CNT] = CNTR_ELEM("SDMAIdInt", 0, 0,
+ CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
+ access_sde_idle_int_cnt),
+[C_SDMA_PROGRESS_INT_CNT] = CNTR_ELEM("SDMAPrIntCn", 0, 0,
+ CNTR_NORMAL | CNTR_32BIT | CNTR_SDMA,
+ access_sde_progress_int_cnt),
 /* MISC_ERR_STATUS */
 [C_MISC_PLL_LOCK_FAIL_ERR] = CNTR_ELEM("MISC_PLL_LOCK_FAIL_ERR", 0, 0,
CNTR_NORMAL,
@@ -5707,6 +5771,7 @@ static void handle_sdma_eng_err(struct hfi1_devdata *dd,
dd_dev_err(sde->dd, "CONFIG SDMA(%u) source: %u status 0x%llx\n",
   sde->this_idx, source, (unsigned long long)status);
 

[PATCH v3 2/2] staging/rdma/hfi1: Fix Xmit Wait calculation

2015-12-21 Thread Jubin John
From: Ira Weiny 

Total XMIT wait needs to sum the xmit wait values of all the VLs not just
those requested in the query.  Also, make the algorithm used for both
PortStatus and PortDataCounters the same.

Reviewed-by: Arthur Kepner 
Reviewed-by: Breyer, Scott J 
Signed-off-by: Ira Weiny 
Signed-off-by: Jubin John 
---
Changes in v2:
- No changes

Changes in v3:
- Refreshed patches against latest staging-testing

 drivers/staging/rdma/hfi1/mad.c |   33 -
 1 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/mad.c b/drivers/staging/rdma/hfi1/mad.c
index 4f5dbd1..bee1c0e 100644
--- a/drivers/staging/rdma/hfi1/mad.c
+++ b/drivers/staging/rdma/hfi1/mad.c
@@ -2279,17 +2279,23 @@ static void a0_portstatus(struct hfi1_pportdata *ppd,
 {
if (!is_bx(ppd->dd)) {
unsigned long vl;
-   u64 max_vl_xmit_wait = 0, tmp;
+   u64 sum_vl_xmit_wait = 0;
u32 vl_all_mask = VL_MASK_ALL;
 
for_each_set_bit(vl, (unsigned long *)&(vl_all_mask),
 8 * sizeof(vl_all_mask)) {
-   tmp = read_port_cntr(ppd, C_TX_WAIT_VL,
-idx_from_vl(vl));
-   if (tmp > max_vl_xmit_wait)
-   max_vl_xmit_wait = tmp;
+   u64 tmp = sum_vl_xmit_wait +
+ read_port_cntr(ppd, C_TX_WAIT_VL,
+idx_from_vl(vl));
+   if (tmp < sum_vl_xmit_wait) {
+   /* we wrapped */
+   sum_vl_xmit_wait = (u64)~0;
+   break;
+   }
+   sum_vl_xmit_wait = tmp;
}
-   rsp->port_xmit_wait = cpu_to_be64(max_vl_xmit_wait);
+   if (be64_to_cpu(rsp->port_xmit_wait) > sum_vl_xmit_wait)
+   rsp->port_xmit_wait = cpu_to_be64(sum_vl_xmit_wait);
}
 }
 
@@ -2491,18 +2497,19 @@ static u64 get_error_counter_summary(struct ib_device 
*ibdev, u8 port,
return error_counter_summary;
 }
 
-static void a0_datacounters(struct hfi1_devdata *dd, struct _port_dctrs *rsp,
+static void a0_datacounters(struct hfi1_pportdata *ppd, struct _port_dctrs 
*rsp,
u32 vl_select_mask)
 {
-   if (!is_bx(dd)) {
+   if (!is_bx(ppd->dd)) {
unsigned long vl;
-   int vfi = 0;
u64 sum_vl_xmit_wait = 0;
+   u32 vl_all_mask = VL_MASK_ALL;
 
-   for_each_set_bit(vl, (unsigned long *)&(vl_select_mask),
-   8 * sizeof(vl_select_mask)) {
+   for_each_set_bit(vl, (unsigned long *)&(vl_all_mask),
+8 * sizeof(vl_all_mask)) {
u64 tmp = sum_vl_xmit_wait +
-   be64_to_cpu(rsp->vls[vfi++].port_vl_xmit_wait);
+ read_port_cntr(ppd, C_TX_WAIT_VL,
+idx_from_vl(vl));
if (tmp < sum_vl_xmit_wait) {
/* we wrapped */
sum_vl_xmit_wait = (u64) ~0;
@@ -2665,7 +2672,7 @@ static int pma_get_opa_datacounters(struct opa_pma_mad 
*pmp,
vfi++;
}
 
-   a0_datacounters(dd, rsp, vl_select_mask);
+   a0_datacounters(ppd, rsp, vl_select_mask);
 
if (resp_len)
*resp_len += response_data_size;
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 0/2] Driver cleanup and misc fixes series 3

2015-12-21 Thread Jubin John
These patches were part of series:
http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2015-December/082248.html
but did not apply cleanly to the staging-testing branch.

Refreshed the remaining 2 patches against the latest staging-testing.

Changes in v2:
- Added more information in commit messages of patches 01, 02
  03, 04, 05, 07 and 09
- Fixed driver name to hfi1 in subject line of patch 06
- Refreshed patch 10 on top of staging-next
- Dropped patch 18 (staging/rdma/hfi1: Workaround
  CONFIG_SDMA_VERBOSITY timing issue) from series

Changes in v3:
- Refreshed remaining 2 patches against latest staging-testing

Edward Mascarenhas (1):
  staging/rdma/hfi1: Clean up comments

Ira Weiny (1):
  staging/rdma/hfi1: Fix Xmit Wait calculation

 drivers/staging/rdma/hfi1/chip.c   |1 -
 drivers/staging/rdma/hfi1/driver.c |2 +-
 drivers/staging/rdma/hfi1/hfi.h|4 ++--
 drivers/staging/rdma/hfi1/mad.c|   33 -
 drivers/staging/rdma/hfi1/pcie.c   |2 +-
 drivers/staging/rdma/hfi1/ud.c |2 +-
 6 files changed, 25 insertions(+), 19 deletions(-)

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 1/2] staging/rdma/hfi1: Clean up comments

2015-12-21 Thread Jubin John
From: Edward Mascarenhas 

Clean up comments by deleting numbering and terms internal to Intel.

The information on the actual bugs is not deleted.

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Edward Mascarenhas 
Signed-off-by: Jubin John 
---
Changes in v2:
- Added more information in commit message

Changes in v3:
- Refreshed patch against latest staging-testing

 drivers/staging/rdma/hfi1/chip.c   |1 -
 drivers/staging/rdma/hfi1/driver.c |2 +-
 drivers/staging/rdma/hfi1/hfi.h|4 ++--
 drivers/staging/rdma/hfi1/pcie.c   |2 +-
 drivers/staging/rdma/hfi1/ud.c |2 +-
 5 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index bbe5ad8..02ba78f 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -13537,7 +13537,6 @@ int hfi1_set_ctxt_jkey(struct hfi1_devdata *dd, 
unsigned ctxt, u16 jkey)
write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_JOB_KEY, reg);
/*
 * Enable send-side J_KEY integrity check, unless this is A0 h/w
-* (due to A0 erratum).
 */
if (!is_ax(dd)) {
reg = read_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE);
diff --git a/drivers/staging/rdma/hfi1/driver.c 
b/drivers/staging/rdma/hfi1/driver.c
index 8485de1..3218520 100644
--- a/drivers/staging/rdma/hfi1/driver.c
+++ b/drivers/staging/rdma/hfi1/driver.c
@@ -368,7 +368,7 @@ static void rcv_hdrerr(struct hfi1_ctxtdata *rcd, struct 
hfi1_pportdata *ppd,
if (opcode == IB_OPCODE_CNP) {
/*
 * Only in pre-B0 h/w is the CNP_OPCODE handled
-* via this code path (errata 291394).
+* via this code path.
 */
struct hfi1_qp *qp = NULL;
u32 lqpn, rqpn;
diff --git a/drivers/staging/rdma/hfi1/hfi.h b/drivers/staging/rdma/hfi1/hfi.h
index 2611bb2..9785a22 100644
--- a/drivers/staging/rdma/hfi1/hfi.h
+++ b/drivers/staging/rdma/hfi1/hfi.h
@@ -1730,7 +1730,7 @@ static inline u64 hfi1_pkt_default_send_ctxt_mask(struct 
hfi1_devdata *dd,
base_sc_integrity |= HFI1_PKT_KERNEL_SC_INTEGRITY;
 
if (is_ax(dd))
-   /* turn off send-side job key checks - A0 erratum */
+   /* turn off send-side job key checks - A0 */
return base_sc_integrity &
   ~SEND_CTXT_CHECK_ENABLE_CHECK_JOB_KEY_SMASK;
return base_sc_integrity;
@@ -1757,7 +1757,7 @@ static inline u64 hfi1_pkt_base_sdma_integrity(struct 
hfi1_devdata *dd)
| SEND_DMA_CHECK_ENABLE_CHECK_ENABLE_SMASK;
 
if (is_ax(dd))
-   /* turn off send-side job key checks - A0 erratum */
+   /* turn off send-side job key checks - A0 */
return base_sdma_integrity &
   ~SEND_DMA_CHECK_ENABLE_CHECK_JOB_KEY_SMASK;
return base_sdma_integrity;
diff --git a/drivers/staging/rdma/hfi1/pcie.c b/drivers/staging/rdma/hfi1/pcie.c
index 8317b07..6745c82 100644
--- a/drivers/staging/rdma/hfi1/pcie.c
+++ b/drivers/staging/rdma/hfi1/pcie.c
@@ -986,7 +986,7 @@ retry:
 * PcieCfgRegPl100 - Gen3 Control
 *
 * turn off PcieCfgRegPl100.Gen3ZRxDcNonCompl
-* turn on PcieCfgRegPl100.EqEieosCnt (erratum)
+* turn on PcieCfgRegPl100.EqEieosCnt
 * Everything else zero.
 */
reg32 = PCIE_CFG_REG_PL100_EQ_EIEOS_CNT_SMASK;
diff --git a/drivers/staging/rdma/hfi1/ud.c b/drivers/staging/rdma/hfi1/ud.c
index bd1b402..25e6053 100644
--- a/drivers/staging/rdma/hfi1/ud.c
+++ b/drivers/staging/rdma/hfi1/ud.c
@@ -671,7 +671,7 @@ void hfi1_ud_rcv(struct hfi1_packet *packet)
if (unlikely(bth1 & HFI1_BECN_SMASK)) {
/*
 * In pre-B0 h/w the CNP_OPCODE is handled via an
-* error path (errata 291394).
+* error path.
 */
struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
u32 lqpn =  be32_to_cpu(ohdr->bth[1]) & HFI1_QPN_MASK;
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/3] staging/rdma/hfi1: check for ARMED->ACTIVE transition in receive interrupt

2015-12-23 Thread Jubin John
On Fri, Dec 18, 2015 at 09:31:39AM +0300, Dan Carpenter wrote:
> Possible off by one, but mostly the whitespace makes me itch.
> 
> Jim was not on the CC list.
> 
> On Thu, Dec 17, 2015 at 07:24:15PM -0500, Jubin John wrote:
> > From: Jim Snow 
> > 
> > The link state will transition from ARMED to ACTIVE when a non-SC15
> > packet arrives, but the driver might not notice the change.  With this
> > fix, if the slowpath receive interrupt handler sees a non-SC15 packet
> > while in the ARMED state, we queue work to call linkstate_active_work
> > from process context to promote it to ACTIVE.
> > 
> > Signed-off-by: Jim Snow 
> > Signed-off-by: Brendan Cunningham 
> > Reviewed-by: Dean Luick 
> > Signed-off-by: Jubin John 
> > ---
> >  drivers/staging/rdma/hfi1/chip.c   |5 ++-
> >  drivers/staging/rdma/hfi1/chip.h   |2 +
> >  drivers/staging/rdma/hfi1/driver.c |   66 
> > 
> >  drivers/staging/rdma/hfi1/hfi.h|   12 ++
> >  drivers/staging/rdma/hfi1/init.c   |1 +
> >  5 files changed, 84 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/staging/rdma/hfi1/chip.c 
> > b/drivers/staging/rdma/hfi1/chip.c
> > index 78a5f08..f82b848 100644
> > --- a/drivers/staging/rdma/hfi1/chip.c
> > +++ b/drivers/staging/rdma/hfi1/chip.c
> > @@ -4606,7 +4606,7 @@ static inline void clear_recv_intr(struct 
> > hfi1_ctxtdata *rcd)
> >  }
> >  
> >  /* force the receive interrupt */
> > -static inline void force_recv_intr(struct hfi1_ctxtdata *rcd)
> > +void force_recv_intr(struct hfi1_ctxtdata *rcd)
> >  {
> > write_csr(rcd->dd, CCE_INT_FORCE + (8 * rcd->ireg), rcd->imask);
> >  }
> > @@ -4705,7 +4705,7 @@ u32 read_physical_state(struct hfi1_devdata *dd)
> > & DC_DC8051_STS_CUR_STATE_PORT_MASK;
> >  }
> >  
> > -static u32 read_logical_state(struct hfi1_devdata *dd)
> > +u32 read_logical_state(struct hfi1_devdata *dd)
> >  {
> > u64 reg;
> >  
> > @@ -6658,6 +6658,7 @@ int set_link_state(struct hfi1_pportdata *ppd, u32 
> > state)
> > ppd->link_enabled = 1;
> > }
> >  
> > +   set_all_slowpath(ppd->dd);
> > ret = set_local_link_attributes(ppd);
> > if (ret)
> > break;
> > diff --git a/drivers/staging/rdma/hfi1/chip.h 
> > b/drivers/staging/rdma/hfi1/chip.h
> > index d74aed8..620cf08 100644
> > --- a/drivers/staging/rdma/hfi1/chip.h
> > +++ b/drivers/staging/rdma/hfi1/chip.h
> > @@ -691,6 +691,8 @@ u64 read_dev_cntr(struct hfi1_devdata *dd, int index, 
> > int vl);
> >  u64 write_dev_cntr(struct hfi1_devdata *dd, int index, int vl, u64 data);
> >  u64 read_port_cntr(struct hfi1_pportdata *ppd, int index, int vl);
> >  u64 write_port_cntr(struct hfi1_pportdata *ppd, int index, int vl, u64 
> > data);
> > +u32 read_logical_state(struct hfi1_devdata *dd);
> > +void force_recv_intr(struct hfi1_ctxtdata *rcd);
> >  
> >  /* Per VL indexes */
> >  enum {
> > diff --git a/drivers/staging/rdma/hfi1/driver.c 
> > b/drivers/staging/rdma/hfi1/driver.c
> > index 4c52e78..16b1be1 100644
> > --- a/drivers/staging/rdma/hfi1/driver.c
> > +++ b/drivers/staging/rdma/hfi1/driver.c
> > @@ -862,6 +862,15 @@ static inline void set_all_dma_rtail(struct 
> > hfi1_devdata *dd)
> > &handle_receive_interrupt_dma_rtail;
> >  }
> >  
> > +void set_all_slowpath(struct hfi1_devdata *dd)
> > +{
> > +   int i;
> > +
> > +   for (i = HFI1_CTRL_CTXT + 1; i < dd->first_user_ctxt; i++)
> > +   dd->rcd[i]->do_interrupt =
> > + &handle_receive_interrupt;
> 
> This fits within the 80 character limit.

Will fix in v2.
> 
> We start counting from HFI1_CTRL_CTXT + 1 but in receive_interrupt_work()
> we start counting from HFI1_CTRL_CTXT.  What's the story?  It's either a
> bug or needs much better documentation.

In set_all_slowpath(), we exclude HFI1_CTRL_CTXT because HFI1_CTRL_CTXT
(the SC15, error, and multicast context) must always use the slowpath
handler. We skip HFI1_CTRL_CTXT in set_all_nodma_rtail() and
set_all_dma_rtail() as well.

receive_interrupt_work() starts at HFI1_CTRL_CTXT because we want to
trigger interrupts on all of the receive contexts, including
HFI1_CTRL_CTXT in case any packets were received on any of the contexts
between the interrupt and when the work function is called.
> 
> > +}
> > +
> >  /*

[PATCH v2] staging/rdma/hfi1: check for ARMED->ACTIVE transition in receive interrupt

2016-01-04 Thread Jubin John
From: Jim Snow 

The link state will transition from ARMED to ACTIVE when a non-SC15
packet arrives, but the driver might not notice the change.  With this
fix, if the slowpath receive interrupt handler sees a non-SC15 packet
while in the ARMED state, we queue work to call linkstate_active_work
from process context to promote it to ACTIVE.

Reviewed-by: Dean Luick 
Reviewed-by: Ira Weiny 
Reviewed-by: Mike Marciniszyn 
Signed-off-by: Jim Snow 
Signed-off-by: Brendan Cunningham 
Signed-off-by: Jubin John 
---
Changes in v2:
- Fixed whitespace
- Converted armed->active transition to inline function
- Added comment to document reason for skipping HFI1_CTRL_CTXT
  in set_all_slowpath()

 drivers/staging/rdma/hfi1/chip.c   |  5 +--
 drivers/staging/rdma/hfi1/chip.h   |  2 ++
 drivers/staging/rdma/hfi1/driver.c | 72 ++
 drivers/staging/rdma/hfi1/hfi.h| 11 ++
 drivers/staging/rdma/hfi1/init.c   |  1 +
 5 files changed, 89 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index f7bf902..63d5d71 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -7878,7 +7878,7 @@ static inline void clear_recv_intr(struct hfi1_ctxtdata 
*rcd)
 }
 
 /* force the receive interrupt */
-static inline void force_recv_intr(struct hfi1_ctxtdata *rcd)
+void force_recv_intr(struct hfi1_ctxtdata *rcd)
 {
write_csr(rcd->dd, CCE_INT_FORCE + (8 * rcd->ireg), rcd->imask);
 }
@@ -7977,7 +7977,7 @@ u32 read_physical_state(struct hfi1_devdata *dd)
& DC_DC8051_STS_CUR_STATE_PORT_MASK;
 }
 
-static u32 read_logical_state(struct hfi1_devdata *dd)
+u32 read_logical_state(struct hfi1_devdata *dd)
 {
u64 reg;
 
@@ -9952,6 +9952,7 @@ int set_link_state(struct hfi1_pportdata *ppd, u32 state)
ppd->link_enabled = 1;
}
 
+   set_all_slowpath(ppd->dd);
ret = set_local_link_attributes(ppd);
if (ret)
break;
diff --git a/drivers/staging/rdma/hfi1/chip.h b/drivers/staging/rdma/hfi1/chip.h
index b46ef66..78ba425 100644
--- a/drivers/staging/rdma/hfi1/chip.h
+++ b/drivers/staging/rdma/hfi1/chip.h
@@ -690,6 +690,8 @@ u64 read_dev_cntr(struct hfi1_devdata *dd, int index, int 
vl);
 u64 write_dev_cntr(struct hfi1_devdata *dd, int index, int vl, u64 data);
 u64 read_port_cntr(struct hfi1_pportdata *ppd, int index, int vl);
 u64 write_port_cntr(struct hfi1_pportdata *ppd, int index, int vl, u64 data);
+u32 read_logical_state(struct hfi1_devdata *dd);
+void force_recv_intr(struct hfi1_ctxtdata *rcd);
 
 /* Per VL indexes */
 enum {
diff --git a/drivers/staging/rdma/hfi1/driver.c 
b/drivers/staging/rdma/hfi1/driver.c
index 3218520..dd8b2c5 100644
--- a/drivers/staging/rdma/hfi1/driver.c
+++ b/drivers/staging/rdma/hfi1/driver.c
@@ -862,6 +862,37 @@ static inline void set_all_dma_rtail(struct hfi1_devdata 
*dd)
&handle_receive_interrupt_dma_rtail;
 }
 
+void set_all_slowpath(struct hfi1_devdata *dd)
+{
+   int i;
+
+   /* HFI1_CTRL_CTXT must always use the slow path interrupt handler */
+   for (i = HFI1_CTRL_CTXT + 1; i < dd->first_user_ctxt; i++)
+   dd->rcd[i]->do_interrupt = &handle_receive_interrupt;
+}
+
+static inline int set_armed_to_active(struct hfi1_ctxtdata *rcd,
+ struct hfi1_packet packet,
+ struct hfi1_devdata *dd)
+{
+   struct work_struct *lsaw = &rcd->ppd->linkstate_active_work;
+   struct hfi1_message_header *hdr = hfi1_get_msgheader(packet.rcd->dd,
+packet.rhf_addr);
+
+   if (hdr2sc(hdr, packet.rhf) != 0xf) {
+   int hwstate = read_logical_state(dd);
+
+   if (hwstate != LSTATE_ACTIVE) {
+   dd_dev_info(dd, "Unexpected link state %d\n", hwstate);
+   return 0;
+   }
+
+   queue_work(rcd->ppd->hfi1_wq, lsaw);
+   return 1;
+   }
+   return 0;
+}
+
 /*
  * handle_receive_interrupt - receive a packet
  * @rcd: the context
@@ -929,6 +960,11 @@ int handle_receive_interrupt(struct hfi1_ctxtdata *rcd, 
int thread)
last = skip_rcv_packet(&packet, thread);
skip_pkt = 0;
} else {
+   /* Auto activate link on non-SC15 packet receive */
+   if (unlikely(rcd->ppd->host_link_state ==
+HLS_UP_ARMED))
+   if (set_armed_to_active(rcd, packet, dd))
+   goto bail;
last = process_rcv_packet(&packet, thread);
}
 
@@ -984,6 +

Re: [PATCH v2] staging/rdma/hfi1: check for ARMED->ACTIVE transition in receive interrupt

2016-01-05 Thread Jubin John
On Mon, Jan 04, 2016 at 10:23:46PM +0200, Leon Romanovsky wrote:
> On Mon, Jan 04, 2016 at 11:21:19AM -0500, Jubin John wrote:
> > From: Jim Snow 
> > 
> > } else {
> > +   /* Auto activate link on non-SC15 packet receive */
> > +   if (unlikely(rcd->ppd->host_link_state ==
> > +HLS_UP_ARMED))
> > +   if (set_armed_to_active(rcd, packet, dd))
> > +   goto bail;
> 
> What is the advantage of double "if" over one "if"?
> Something like that
> + if (unlikely(rcd->ppd->host_link_state == HLS_UP_ARMED) && 
> (set_armed_to_active(rcd, packet, dd))
> + goto bail;

I don't think there is an advantage to the double if, so I will change
it to the single if in v3.

> 
> > last = process_rcv_packet(&packet, thread);
> > }
> >  
> > @@ -984,6 +1020,42 @@ bail:
> >  }
> >  
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3] staging/rdma/hfi1: check for ARMED->ACTIVE transition in receive interrupt

2016-01-05 Thread Jubin John
From: Jim Snow 

The link state will transition from ARMED to ACTIVE when a non-SC15
packet arrives, but the driver might not notice the change.  With this
fix, if the slowpath receive interrupt handler sees a non-SC15 packet
while in the ARMED state, we queue work to call linkstate_active_work
from process context to promote it to ACTIVE.

Reviewed-by: Dean Luick 
Reviewed-by: Ira Weiny 
Reviewed-by: Mike Marciniszyn 
Signed-off-by: Jim Snow 
Signed-off-by: Brendan Cunningham 
Signed-off-by: Jubin John 
---
Changes in v2:
- Fixed whitespace
- Converted armed->active transition to inline function
- Added comment to document reason for skipping HFI1_CTRL_CTXT
  in set_all_slowpath()

Changes in v3:
- Changed from double if to single if statement in
  handle_receive_interrupt()

 drivers/staging/rdma/hfi1/chip.c   |  5 +--
 drivers/staging/rdma/hfi1/chip.h   |  2 ++
 drivers/staging/rdma/hfi1/driver.c | 72 ++
 drivers/staging/rdma/hfi1/hfi.h| 11 ++
 drivers/staging/rdma/hfi1/init.c   |  1 +
 5 files changed, 89 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index f7bf902..63d5d71 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -7878,7 +7878,7 @@ static inline void clear_recv_intr(struct hfi1_ctxtdata 
*rcd)
 }
 
 /* force the receive interrupt */
-static inline void force_recv_intr(struct hfi1_ctxtdata *rcd)
+void force_recv_intr(struct hfi1_ctxtdata *rcd)
 {
write_csr(rcd->dd, CCE_INT_FORCE + (8 * rcd->ireg), rcd->imask);
 }
@@ -7977,7 +7977,7 @@ u32 read_physical_state(struct hfi1_devdata *dd)
& DC_DC8051_STS_CUR_STATE_PORT_MASK;
 }
 
-static u32 read_logical_state(struct hfi1_devdata *dd)
+u32 read_logical_state(struct hfi1_devdata *dd)
 {
u64 reg;
 
@@ -9952,6 +9952,7 @@ int set_link_state(struct hfi1_pportdata *ppd, u32 state)
ppd->link_enabled = 1;
}
 
+   set_all_slowpath(ppd->dd);
ret = set_local_link_attributes(ppd);
if (ret)
break;
diff --git a/drivers/staging/rdma/hfi1/chip.h b/drivers/staging/rdma/hfi1/chip.h
index b46ef66..78ba425 100644
--- a/drivers/staging/rdma/hfi1/chip.h
+++ b/drivers/staging/rdma/hfi1/chip.h
@@ -690,6 +690,8 @@ u64 read_dev_cntr(struct hfi1_devdata *dd, int index, int 
vl);
 u64 write_dev_cntr(struct hfi1_devdata *dd, int index, int vl, u64 data);
 u64 read_port_cntr(struct hfi1_pportdata *ppd, int index, int vl);
 u64 write_port_cntr(struct hfi1_pportdata *ppd, int index, int vl, u64 data);
+u32 read_logical_state(struct hfi1_devdata *dd);
+void force_recv_intr(struct hfi1_ctxtdata *rcd);
 
 /* Per VL indexes */
 enum {
diff --git a/drivers/staging/rdma/hfi1/driver.c 
b/drivers/staging/rdma/hfi1/driver.c
index 3218520..d096f11 100644
--- a/drivers/staging/rdma/hfi1/driver.c
+++ b/drivers/staging/rdma/hfi1/driver.c
@@ -862,6 +862,37 @@ static inline void set_all_dma_rtail(struct hfi1_devdata 
*dd)
&handle_receive_interrupt_dma_rtail;
 }
 
+void set_all_slowpath(struct hfi1_devdata *dd)
+{
+   int i;
+
+   /* HFI1_CTRL_CTXT must always use the slow path interrupt handler */
+   for (i = HFI1_CTRL_CTXT + 1; i < dd->first_user_ctxt; i++)
+   dd->rcd[i]->do_interrupt = &handle_receive_interrupt;
+}
+
+static inline int set_armed_to_active(struct hfi1_ctxtdata *rcd,
+ struct hfi1_packet packet,
+ struct hfi1_devdata *dd)
+{
+   struct work_struct *lsaw = &rcd->ppd->linkstate_active_work;
+   struct hfi1_message_header *hdr = hfi1_get_msgheader(packet.rcd->dd,
+packet.rhf_addr);
+
+   if (hdr2sc(hdr, packet.rhf) != 0xf) {
+   int hwstate = read_logical_state(dd);
+
+   if (hwstate != LSTATE_ACTIVE) {
+   dd_dev_info(dd, "Unexpected link state %d\n", hwstate);
+   return 0;
+   }
+
+   queue_work(rcd->ppd->hfi1_wq, lsaw);
+   return 1;
+   }
+   return 0;
+}
+
 /*
  * handle_receive_interrupt - receive a packet
  * @rcd: the context
@@ -929,6 +960,11 @@ int handle_receive_interrupt(struct hfi1_ctxtdata *rcd, 
int thread)
last = skip_rcv_packet(&packet, thread);
skip_pkt = 0;
} else {
+   /* Auto activate link on non-SC15 packet receive */
+   if (unlikely(rcd->ppd->host_link_state ==
+HLS_UP_ARMED) &&
+   set_armed_to_active(rcd, packet, dd))
+  

[PATCH RESEND v3 0/6] staging/rdma/hfi1: Driver cleanup and misc fixes

2016-01-11 Thread Jubin John
NOTE:
This is being resubmitted to linux-rdma (for patchworks) to aid Doug Ledford in
taking over the staging/rdma subtree.

https://www.mail-archive.com/linux-rdma%40vger.kernel.org/msg30860.html

This patch set is to follow: staging/rdma/hfi1: set Gen3 half-swing for 
integrated devices

Thanks,
Jubin

These patches were originally part of patch series:
http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2015-November/081566.html
but did not apply cleanly to the staging-next branch.

Refreshed the remaining 6 patches against the latest staging-next.

Changes in v2:
- 01/13: Updated commit message with more information about changes in 
patch
- 04/13: Updated patch subject with "hfi1" instead of "hfi"
- 07/13: Refreshed patch based on new hfi patches in staging-next
- 12/13: Changed logic based on Dan's suggestions in
 http://marc.info/?l=linux-driver-devel&m=144723149431368&w=2
Changes in v3:
- Refreshed remaining 6 patches against latest staging-next

Dean Luick (1):
  staging/rdma/hfi1: Remove unneeded variable index

Harish Chegondi (1):
  staging/rdma/hfi1: Move s_sde to the read mostly portion of the
hfi1_qp structure

Jubin John (2):
  staging/rdma/hfi1: Use BIT macro
  staging/rdma/hfi1: Change default krcvqs

Mark F. Brown (1):
  staging/rdma/hfi1: change krcvqs module parameter type from byte to
uint

Vennila Megavannan (1):
  staging/rdma/hfi1: adding per SDMA engine stats to hfistats

 drivers/staging/rdma/hfi1/chip.c   |  127 +---
 drivers/staging/rdma/hfi1/chip.h   |   53 +++-
 drivers/staging/rdma/hfi1/chip_registers.h |1 +
 drivers/staging/rdma/hfi1/common.h |4 +-
 drivers/staging/rdma/hfi1/hfi.h|   25 +++---
 drivers/staging/rdma/hfi1/init.c   |6 +-
 drivers/staging/rdma/hfi1/mad.c|4 +-
 drivers/staging/rdma/hfi1/qp.h |2 +-
 drivers/staging/rdma/hfi1/qsfp.h   |   10 +-
 drivers/staging/rdma/hfi1/sdma.c   |   17 +++-
 drivers/staging/rdma/hfi1/sdma.h   |7 ++
 drivers/staging/rdma/hfi1/verbs.h  |2 +-
 12 files changed, 189 insertions(+), 69 deletions(-)

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RESEND v3 4/6] staging/rdma/hfi1: Change default krcvqs

2016-01-11 Thread Jubin John
Change the default number of krcvqs to number of numa nodes + 1
based on the performance data collected.

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Jubin John 
---
Changes in v2:
- None

Changes in v3:
- Refreshed patch against latest staging-next

 drivers/staging/rdma/hfi1/chip.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.c b/drivers/staging/rdma/hfi1/chip.c
index bbe5ad8..503bfca 100644
--- a/drivers/staging/rdma/hfi1/chip.c
+++ b/drivers/staging/rdma/hfi1/chip.c
@@ -12445,7 +12445,7 @@ static int set_up_context_variables(struct hfi1_devdata 
*dd)
 */
num_kernel_contexts = n_krcvqs + MIN_KERNEL_KCTXTS - 1;
else
-   num_kernel_contexts = num_online_nodes();
+   num_kernel_contexts = num_online_nodes() + 1;
num_kernel_contexts =
max_t(int, MIN_KERNEL_KCTXTS, num_kernel_contexts);
/*
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RESEND v3 2/6] staging/rdma/hfi1: Move s_sde to the read mostly portion of the hfi1_qp structure

2016-01-11 Thread Jubin John
From: Harish Chegondi 

This would reduce L2 cache misses on s_sde in the _hfi1_schedule_send
function when invoked from post_send thereby improving performance of
post_send.

Reviewed-by: Mike Marciniszyn 
Signed-off-by: Harish Chegondi 
Signed-off-by: Jubin John 
---
Changes in v2:
- None

Changes in v3:
- Refreshed patch against latest staging-next

 drivers/staging/rdma/hfi1/verbs.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/verbs.h 
b/drivers/staging/rdma/hfi1/verbs.h
index 72106e5..d22db39 100644
--- a/drivers/staging/rdma/hfi1/verbs.h
+++ b/drivers/staging/rdma/hfi1/verbs.h
@@ -441,6 +441,7 @@ struct hfi1_qp {
struct hfi1_swqe *s_wq;  /* send work queue */
struct hfi1_mmap_info *ip;
struct ahg_ib_header *s_hdr; /* next packet header to send */
+   struct sdma_engine *s_sde; /* current sde */
/* sc for UC/RC QPs - based on ah for UD */
u8 s_sc;
unsigned long timeout_jiffies;  /* computed from timeout */
@@ -506,7 +507,6 @@ struct hfi1_qp {
struct hfi1_swqe *s_wqe;
struct hfi1_sge_state s_sge; /* current send request data */
struct hfi1_mregion *s_rdma_mr;
-   struct sdma_engine *s_sde; /* current sde */
u32 s_cur_size; /* size of send packet in bytes */
u32 s_len;  /* total length of s_sge */
u32 s_rdma_read_len;/* total length of s_rdma_read_sge */
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH RESEND v3 1/6] staging/rdma/hfi1: Use BIT macro

2016-01-11 Thread Jubin John
This patch fixes the checkpatch issue:
CHECK: Prefer using the BIT macro

Use of BIT macro for HDRQ_INCREMENT in chip.h causes a change in
format specifier for error message in init.c in order to avoid a
build warning.

Reviewed-by: Dean Luick 
Reviewed-by: Ira Weiny 
Reviewed-by: Mike Marciniszyn 
Signed-off-by: Jubin John 
---
Changes in v2:
- Updated commit message with more information about changes in patch

Changes in v3:
- Refreshed patch against latest staging-next

 drivers/staging/rdma/hfi1/chip.h   |   48 ++--
 drivers/staging/rdma/hfi1/common.h |4 +-
 drivers/staging/rdma/hfi1/hfi.h|   22 
 drivers/staging/rdma/hfi1/init.c   |2 +-
 drivers/staging/rdma/hfi1/mad.c|4 +-
 drivers/staging/rdma/hfi1/qp.h |2 +-
 drivers/staging/rdma/hfi1/qsfp.h   |   10 +++---
 drivers/staging/rdma/hfi1/sdma.c   |8 +++---
 8 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/chip.h b/drivers/staging/rdma/hfi1/chip.h
index 5b375dd..1368a44 100644
--- a/drivers/staging/rdma/hfi1/chip.h
+++ b/drivers/staging/rdma/hfi1/chip.h
@@ -242,18 +242,18 @@
 #define HCMD_SUCCESS 2
 
 /* DC_DC8051_DBG_ERR_INFO_SET_BY_8051.ERROR - error flags */
-#define SPICO_ROM_FAILED   (1 <<  0)
-#define UNKNOWN_FRAME  (1 <<  1)
-#define TARGET_BER_NOT_MET (1 <<  2)
-#define FAILED_SERDES_INTERNAL_LOOPBACK (1 <<  3)
-#define FAILED_SERDES_INIT (1 <<  4)
-#define FAILED_LNI_POLLING (1 <<  5)
-#define FAILED_LNI_DEBOUNCE(1 <<  6)
-#define FAILED_LNI_ESTBCOMM(1 <<  7)
-#define FAILED_LNI_OPTEQ   (1 <<  8)
-#define FAILED_LNI_VERIFY_CAP1 (1 <<  9)
-#define FAILED_LNI_VERIFY_CAP2 (1 << 10)
-#define FAILED_LNI_CONFIGLT(1 << 11)
+#define SPICO_ROM_FAILED   BIT(0)
+#define UNKNOWN_FRAME  BIT(1)
+#define TARGET_BER_NOT_MET BIT(2)
+#define FAILED_SERDES_INTERNAL_LOOPBACKBIT(3)
+#define FAILED_SERDES_INIT BIT(4)
+#define FAILED_LNI_POLLING BIT(5)
+#define FAILED_LNI_DEBOUNCEBIT(6)
+#define FAILED_LNI_ESTBCOMMBIT(7)
+#define FAILED_LNI_OPTEQ   BIT(8)
+#define FAILED_LNI_VERIFY_CAP1 BIT(9)
+#define FAILED_LNI_VERIFY_CAP2 BIT(10)
+#define FAILED_LNI_CONFIGLTBIT(11)
 
 #define FAILED_LNI (FAILED_LNI_POLLING | FAILED_LNI_DEBOUNCE \
| FAILED_LNI_ESTBCOMM | FAILED_LNI_OPTEQ \
@@ -262,16 +262,16 @@
| FAILED_LNI_CONFIGLT)
 
 /* DC_DC8051_DBG_ERR_INFO_SET_BY_8051.HOST_MSG - host message flags */
-#define HOST_REQ_DONE (1 << 0)
-#define BC_PWR_MGM_MSG(1 << 1)
-#define BC_SMA_MSG(1 << 2)
-#define BC_BCC_UNKOWN_MSG (1 << 3)
-#define BC_IDLE_UNKNOWN_MSG   (1 << 4)
-#define EXT_DEVICE_CFG_REQ(1 << 5)
-#define VERIFY_CAP_FRAME  (1 << 6)
-#define LINKUP_ACHIEVED   (1 << 7)
-#define LINK_GOING_DOWN   (1 << 8)
-#define LINK_WIDTH_DOWNGRADED  (1 << 9)
+#define HOST_REQ_DONE  BIT(0)
+#define BC_PWR_MGM_MSG BIT(1)
+#define BC_SMA_MSG BIT(2)
+#define BC_BCC_UNKNOWN_MSG BIT(3)
+#define BC_IDLE_UNKNOWN_MSGBIT(4)
+#define EXT_DEVICE_CFG_REQ BIT(5)
+#define VERIFY_CAP_FRAME   BIT(6)
+#define LINKUP_ACHIEVEDBIT(7)
+#define LINK_GOING_DOWNBIT(8)
+#define LINK_WIDTH_DOWNGRADED  BIT(9)
 
 /* DC_DC8051_CFG_EXT_DEV_1.REQ_TYPE - 8051 host requests */
 #define HREQ_LOAD_CONFIG   0x01
@@ -335,14 +335,14 @@
  * the CSR fields hold multiples of this value.
  */
 #define RCV_SHIFT 3
-#define RCV_INCREMENT (1 << RCV_SHIFT)
+#define RCV_INCREMENT BIT(RCV_SHIFT)
 
 /*
  * Receive header queue entry increment - the CSR holds multiples of
  * this value.
  */
 #define HDRQ_SIZE_SHIFT 5
-#define HDRQ_INCREMENT (1 << HDRQ_SIZE_SHIFT)
+#define HDRQ_INCREMENT BIT(HDRQ_SIZE_SHIFT)
 
 /*
  * Freeze handling flags
diff --git a/drivers/staging/rdma/hfi1/common.h 
b/drivers/staging/rdma/hfi1/common.h
index 5dd9272..e4b1dc6 100644
--- a/drivers/staging/rdma/hfi1/common.h
+++ b/drivers/staging/rdma/hfi1/common.h
@@ -349,10 +349,10 @@ struct hfi1_message_header {
 #define HFI1_QPN_MASK 0xFF
 #define HFI1_FECN_SHIFT 31
 #define HFI1_FECN_MASK 1
-#define HFI1_FECN_SMASK (1 << HFI1_FECN_SHIFT)
+#define HFI1_FECN_SMASK BIT(HFI1_FECN_SHIFT)
 #define HFI1_BECN_SHIFT 30
 #define HFI1_BECN_MASK 1
-#define HFI1_BECN_SMASK (1 << HFI1_BECN_SHIFT)
+#define HFI1_BECN_SMASK BIT(HFI1_BECN_SHIFT)
 #define HFI1_MULTICAST_LID_BASE 0xC000
 
 static inline __u64 rhf_to_cpu(const __le32 *rbuf)
diff --git a/drivers/staging/rdma/hfi1/hfi.h b/drivers/staging/rdma/hfi1

[PATCH RESEND v3 3/6] staging/rdma/hfi1: change krcvqs module parameter type from byte to uint

2016-01-11 Thread Jubin John
From: Mark F. Brown 

The krcvqs parameter is displayed incorrectly in sysfs.
The workaround is to set the param type as uint.

Reviewed-by: Mike Marciniszyn 
Reviewed-by: Mitko Haralanov 
Signed-off-by: Mark F. Brown 
Signed-off-by: Jubin John 
---
Changes in v2:
- None

Changes in v3:
- Refreshed patch against latest staging-next

 drivers/staging/rdma/hfi1/hfi.h  |2 +-
 drivers/staging/rdma/hfi1/init.c |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rdma/hfi1/hfi.h b/drivers/staging/rdma/hfi1/hfi.h
index 2dfd402..d4a859f 100644
--- a/drivers/staging/rdma/hfi1/hfi.h
+++ b/drivers/staging/rdma/hfi1/hfi.h
@@ -1667,7 +1667,7 @@ extern unsigned int hfi1_cu;
 extern unsigned int user_credit_return_threshold;
 extern int num_user_contexts;
 extern unsigned n_krcvqs;
-extern u8 krcvqs[];
+extern uint krcvqs[];
 extern int krcvqsset;
 extern uint kdeth_qp;
 extern uint loopback;
diff --git a/drivers/staging/rdma/hfi1/init.c b/drivers/staging/rdma/hfi1/init.c
index 35b5e41..dbdc631 100644
--- a/drivers/staging/rdma/hfi1/init.c
+++ b/drivers/staging/rdma/hfi1/init.c
@@ -87,9 +87,9 @@ module_param_named(num_user_contexts, num_user_contexts, 
uint, S_IRUGO);
 MODULE_PARM_DESC(
num_user_contexts, "Set max number of user contexts to use");
 
-u8 krcvqs[RXE_NUM_DATA_VL];
+uint krcvqs[RXE_NUM_DATA_VL];
 int krcvqsset;
-module_param_array(krcvqs, byte, &krcvqsset, S_IRUGO);
+module_param_array(krcvqs, uint, &krcvqsset, S_IRUGO);
 MODULE_PARM_DESC(krcvqs, "Array of the number of non-control kernel receive 
queues by VL");
 
 /* computed based on above array */
-- 
1.7.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


  1   2   >