Re: Unable to establish rdma connection, breaks rdma basic functionality

2016-01-06 Thread Hariprasad Shenai
On Wed, Jan 06, 2016 at 12:33:09 +0200, Matan Barak wrote:
> On Wed, Jan 6, 2016 at 6:43 AM, Hariprasad S  wrote:
> >
> > Hi Doug,
> >
> > I am trying to rping server, but it fails when bound to any address other 
> > then IF_ANY.
> > # rping -s -a 102.1.1.129 -C1 -p  -vd
> > created cm_id 0x23d7800
> > rdma_bind_addr: No such file or directory
> > destroy cm_id 0x23d7800
> >
> > If bound to IF_ANY address, server starts but client fails to establish 
> > connection.
> > # rping -s -C1 -p  -vvvd
> > created cm_id 0xc34800
> > rdma_bind_addr successful
> > rdma_listen
> >
> > And the commit which introduced this regression is
> >
> > commit abae1b71dd37bab506b14a6cf6ba7148f4d57232
> > Author: Matan Barak 
> > Date:   Thu Oct 15 18:38:49 2015 +0300
> >
> > IB/cma: cma_validate_port should verify the port and netdevice
> >
> > Previously, cma_validate_port searched for GIDs in IB cache and then
> > tried to verify the found port. This could fail when there are
> > identical GIDs on both ports. In addition, netdevice should be taken
> > into account when searching the GID table.
> > Fixing cma_validate_port to search only the relevant port's cache
> > and netdevice.
> >
> > Signed-off-by: Matan Barak 
> > Signed-off-by: Doug Ledford  >
> >
> > The bug is easily reproducible with latest rc and breaks basic rdma 
> > functionality.
> > Since 4.4 is already in -rc8, can we have a quick fix.
> >
> > Thanks,
> > Hari--
> 
> Hi,
> 
> I don't have a iwarp server, so could you please test this simple fix:
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 2cbf9c9..351e835 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -439,7 +439,7 @@ static inline int cma_validate_port(struct
> ib_device *device, u8 port,
> if ((dev_type != ARPHRD_INFINIBAND) && rdma_protocol_ib(device, port))
> return ret;
> 
> -   if (dev_type == ARPHRD_ETHER)
> +   if (dev_type == ARPHRD_ETHER && rdma_protocol_roce(device, port))
> ndev = dev_get_by_index(_net, bound_if_index);
> 
> ret = ib_find_cached_gid_by_port(device, gid, port, ndev, NULL);
> 
> Regards,
> Matan

Hi Matan,

Thanks. It worked for me.

Regards,
Hari

> 
> > 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


[PATCH for-next] iw_cxgb3: Ignore positive return values from the ofld send functions

2015-12-11 Thread Hariprasad Shenai
The cxgb3_*_send() functions return NET_XMIT_ values, which are
positive integers values. So don't treat positive return values
as an error.

Signed-off-by: Steve Wise <sw...@opengridcomputing.com>
Signed-off-by: Hariprasad Shenai <haripra...@chelsio.com>
---
 drivers/infiniband/hw/cxgb3/iwch_cm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c 
b/drivers/infiniband/hw/cxgb3/iwch_cm.c
index cb78b1e..f504ba7 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
@@ -149,7 +149,7 @@ static int iwch_l2t_send(struct t3cdev *tdev, struct 
sk_buff *skb, struct l2t_en
error = l2t_send(tdev, skb, l2e);
if (error < 0)
kfree_skb(skb);
-   return error;
+   return error < 0 ? error : 0;
 }
 
 int iwch_cxgb3_ofld_send(struct t3cdev *tdev, struct sk_buff *skb)
@@ -165,7 +165,7 @@ int iwch_cxgb3_ofld_send(struct t3cdev *tdev, struct 
sk_buff *skb)
error = cxgb3_ofld_send(tdev, skb);
if (error < 0)
kfree_skb(skb);
-   return error;
+   return error < 0 ? error : 0;
 }
 
 static void release_tid(struct t3cdev *tdev, u32 hwtid, struct sk_buff *skb)
-- 
2.3.4

--
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


[PATCH for-next] iw_cxgb4: Pass qid range to user space driver

2015-12-10 Thread Hariprasad Shenai
Enhances the t4_dev_status_page to pass the qid start and size
attributes from iw_cxgb4 to libcxgb4.
Bump the ABI Version to 3 -> To allow libcxgb4 to detect old drivers and
revert to the old way of computing the qid ranges.

Signed-off-by: Hariprasad Shenai <haripra...@chelsio.com>
Signed-off-by: Steve Wise <sw...@opengridcomputing.com>
---
 drivers/infiniband/hw/cxgb4/device.c | 4 
 drivers/infiniband/hw/cxgb4/t4.h | 7 +++
 drivers/infiniband/hw/cxgb4/user.h   | 2 +-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/cxgb4/device.c 
b/drivers/infiniband/hw/cxgb4/device.c
index 1a29739..fab8ba3 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -850,6 +850,10 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
}
rdev->status_page = (struct t4_dev_status_page *)
__get_free_page(GFP_KERNEL);
+   rdev->status_page->qp_start = rdev->lldi.vr->qp.start;
+   rdev->status_page->qp_size = rdev->lldi.vr->qp.size;
+   rdev->status_page->cq_start = rdev->lldi.vr->cq.start;
+   rdev->status_page->cq_size = rdev->lldi.vr->cq.size;
if (!rdev->status_page) {
pr_err(MOD "error allocating status page\n");
goto err4;
diff --git a/drivers/infiniband/hw/cxgb4/t4.h b/drivers/infiniband/hw/cxgb4/t4.h
index 274a7ab..483d99b 100644
--- a/drivers/infiniband/hw/cxgb4/t4.h
+++ b/drivers/infiniband/hw/cxgb4/t4.h
@@ -700,4 +700,11 @@ static inline void t4_set_cq_in_error(struct t4_cq *cq)
 
 struct t4_dev_status_page {
u8 db_off;
+   u8 pad1;
+   u16 pad2;
+   u32 pad3;
+   u64 qp_start;
+   u64 qp_size;
+   u64 cq_start;
+   u64 cq_size;
 };
diff --git a/drivers/infiniband/hw/cxgb4/user.h 
b/drivers/infiniband/hw/cxgb4/user.h
index cbd0ce1..295f422 100644
--- a/drivers/infiniband/hw/cxgb4/user.h
+++ b/drivers/infiniband/hw/cxgb4/user.h
@@ -32,7 +32,7 @@
 #ifndef __C4IW_USER_H__
 #define __C4IW_USER_H__
 
-#define C4IW_UVERBS_ABI_VERSION2
+#define C4IW_UVERBS_ABI_VERSION3
 
 /*
  * Make sure that all structs defined in this file remain laid out so
-- 
2.3.4

--
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


[PATCH for-next 2/2] iw_cxgb4: Adds support for T6 adapter

2015-09-23 Thread Hariprasad Shenai
Signed-off-by: Hariprasad Shenai <haripra...@chelsio.com>
---
 drivers/infiniband/hw/cxgb4/cm.c   | 317 -
 drivers/infiniband/hw/cxgb4/device.c   |  10 +-
 drivers/infiniband/hw/cxgb4/provider.c |   2 +-
 drivers/infiniband/hw/cxgb4/qp.c   |  16 +-
 drivers/infiniband/hw/cxgb4/t4.h   |   5 +-
 5 files changed, 204 insertions(+), 146 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 6c02211..c9cffce 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -632,22 +632,18 @@ static void best_mtu(const unsigned short *mtus, unsigned 
short mtu,
 
 static int send_connect(struct c4iw_ep *ep)
 {
-   struct cpl_act_open_req *req;
-   struct cpl_t5_act_open_req *t5_req;
-   struct cpl_act_open_req6 *req6;
-   struct cpl_t5_act_open_req6 *t5_req6;
+   struct cpl_act_open_req *req = NULL;
+   struct cpl_t5_act_open_req *t5req = NULL;
+   struct cpl_t6_act_open_req *t6req = NULL;
+   struct cpl_act_open_req6 *req6 = NULL;
+   struct cpl_t5_act_open_req6 *t5req6 = NULL;
+   struct cpl_t6_act_open_req6 *t6req6 = NULL;
struct sk_buff *skb;
u64 opt0;
u32 opt2;
unsigned int mtu_idx;
int wscale;
-   int wrlen;
-   int sizev4 = is_t4(ep->com.dev->rdev.lldi.adapter_type) ?
-   sizeof(struct cpl_act_open_req) :
-   sizeof(struct cpl_t5_act_open_req);
-   int sizev6 = is_t4(ep->com.dev->rdev.lldi.adapter_type) ?
-   sizeof(struct cpl_act_open_req6) :
-   sizeof(struct cpl_t5_act_open_req6);
+   int win, sizev4, sizev6, wrlen;
struct sockaddr_in *la = (struct sockaddr_in *)
 >com.mapped_local_addr;
struct sockaddr_in *ra = (struct sockaddr_in *)
@@ -656,8 +652,28 @@ static int send_connect(struct c4iw_ep *ep)
   >com.mapped_local_addr;
struct sockaddr_in6 *ra6 = (struct sockaddr_in6 *)
   >com.mapped_remote_addr;
-   int win;
int ret;
+   enum chip_type adapter_type = ep->com.dev->rdev.lldi.adapter_type;
+   u32 isn = (prandom_u32() & ~7UL) - 1;
+
+   switch (CHELSIO_CHIP_VERSION(adapter_type)) {
+   case CHELSIO_T4:
+   sizev4 = sizeof(struct cpl_act_open_req);
+   sizev6 = sizeof(struct cpl_act_open_req6);
+   break;
+   case CHELSIO_T5:
+   sizev4 = sizeof(struct cpl_t5_act_open_req);
+   sizev6 = sizeof(struct cpl_t5_act_open_req6);
+   break;
+   case CHELSIO_T6:
+   sizev4 = sizeof(struct cpl_t6_act_open_req);
+   sizev6 = sizeof(struct cpl_t6_act_open_req6);
+   break;
+   default:
+   pr_err("T%d Chip is not supported\n",
+  CHELSIO_CHIP_VERSION(adapter_type));
+   return -EINVAL;
+   }
 
wrlen = (ep->com.remote_addr.ss_family == AF_INET) ?
roundup(sizev4, 16) :
@@ -706,7 +722,10 @@ static int send_connect(struct c4iw_ep *ep)
opt2 |= SACK_EN_F;
if (wscale && enable_tcp_window_scaling)
opt2 |= WND_SCALE_EN_F;
-   if (is_t5(ep->com.dev->rdev.lldi.adapter_type)) {
+   if (CHELSIO_CHIP_VERSION(adapter_type) > CHELSIO_T4) {
+   if (peer2peer)
+   isn += 4;
+
opt2 |= T5_OPT_2_VALID_F;
opt2 |= CONG_CNTRL_V(CONG_ALG_TAHOE);
opt2 |= T5_ISS_F;
@@ -718,102 +737,109 @@ static int send_connect(struct c4iw_ep *ep)
 
t4_set_arp_err_handler(skb, ep, act_open_req_arp_failure);
 
-   if (is_t4(ep->com.dev->rdev.lldi.adapter_type)) {
-   if (ep->com.remote_addr.ss_family == AF_INET) {
-   req = (struct cpl_act_open_req *) skb_put(skb, wrlen);
+   if (ep->com.remote_addr.ss_family == AF_INET) {
+   switch (CHELSIO_CHIP_VERSION(adapter_type)) {
+   case CHELSIO_T4:
+   req = (struct cpl_act_open_req *)skb_put(skb, wrlen);
INIT_TP_WR(req, 0);
-   OPCODE_TID(req) = cpu_to_be32(
-   MK_OPCODE_TID(CPL_ACT_OPEN_REQ,
-   ((ep->rss_qid << 14) | ep->atid)));
-   req->local_port = la->sin_port;
-   req->peer_port = ra->sin_port;
-   req->local_ip = la->sin_addr.s_addr;
-   req->peer_ip = ra->sin_addr.s_addr;
-   req->opt0 = cpu_to_be64(opt0);
+   break;
+   case CHELSIO_T5:
+ 

[PATCH for-next 0/2] RDMA/cxgb4: Add iWARP support for T6 adapter

2015-09-23 Thread Hariprasad Shenai
Hi,

PATCH 1/2 adds changes like new register, structure and functions in cxgb4
driver for iw_cxgb4 driver, and PATCH 2/2 adds iw_cxgb4 specific code to
support T6 adapter.

This patch series has been created against Doug's linux tree and includes
patches on cxgb4 and iw_cxgb4 driver.

We have included all the maintainers of respective drivers. Kindly review
the change and let us know in case of any review comments.

Thanks

Hariprasad Shenai (2):
  cxgb4: T6 adapter lld support for iw_cxgb4 driver
  iw_cxgb4: Adds support for T6 adapter

 drivers/infiniband/hw/cxgb4/cm.c  | 317 +-
 drivers/infiniband/hw/cxgb4/device.c  |  10 +-
 drivers/infiniband/hw/cxgb4/provider.c|   2 +-
 drivers/infiniband/hw/cxgb4/qp.c  |  16 +-
 drivers/infiniband/hw/cxgb4/t4.h  |   5 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h|  41 +--
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c   |  22 ++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h|   2 +
 drivers/net/ethernet/chelsio/cxgb4/t4_chip_type.h |  85 ++
 drivers/net/ethernet/chelsio/cxgb4/t4_msg.h   |  48 
 10 files changed, 362 insertions(+), 186 deletions(-)
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/t4_chip_type.h

-- 
2.3.4

--
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


[PATCH for-next 1/2] cxgb4: T6 adapter lld support for iw_cxgb4 driver

2015-09-23 Thread Hariprasad Shenai
Signed-off-by: Hariprasad Shenai <haripra...@chelsio.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h| 41 +--
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c   | 22 ++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h|  2 +
 drivers/net/ethernet/chelsio/cxgb4/t4_chip_type.h | 85 +++
 drivers/net/ethernet/chelsio/cxgb4/t4_msg.h   | 48 +
 5 files changed, 158 insertions(+), 40 deletions(-)
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/t4_chip_type.h

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index fa0c7b5..11045ec 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -48,6 +48,7 @@
 #include 
 #include 
 #include 
+#include "t4_chip_type.h"
 #include "cxgb4_uld.h"
 
 #define CH_WARN(adap, fmt, ...) dev_warn(adap->pdev_dev, fmt, ## __VA_ARGS__)
@@ -290,31 +291,6 @@ struct pci_params {
unsigned char width;
 };
 
-#define CHELSIO_CHIP_CODE(version, revision) (((version) << 4) | (revision))
-#define CHELSIO_CHIP_FPGA  0x100
-#define CHELSIO_CHIP_VERSION(code) (((code) >> 4) & 0xf)
-#define CHELSIO_CHIP_RELEASE(code) ((code) & 0xf)
-
-#define CHELSIO_T4 0x4
-#define CHELSIO_T5 0x5
-#define CHELSIO_T6 0x6
-
-enum chip_type {
-   T4_A1 = CHELSIO_CHIP_CODE(CHELSIO_T4, 1),
-   T4_A2 = CHELSIO_CHIP_CODE(CHELSIO_T4, 2),
-   T4_FIRST_REV= T4_A1,
-   T4_LAST_REV = T4_A2,
-
-   T5_A0 = CHELSIO_CHIP_CODE(CHELSIO_T5, 0),
-   T5_A1 = CHELSIO_CHIP_CODE(CHELSIO_T5, 1),
-   T5_FIRST_REV= T5_A0,
-   T5_LAST_REV = T5_A1,
-
-   T6_A0 = CHELSIO_CHIP_CODE(CHELSIO_T6, 0),
-   T6_FIRST_REV= T6_A0,
-   T6_LAST_REV = T6_A0,
-};
-
 struct devlog_params {
u32 memtype;/* which memory (EDC0, EDC1, MC) */
u32 start;  /* start of log in firmware memory */
@@ -905,21 +881,6 @@ static inline int is_offload(const struct adapter *adap)
return adap->params.offload;
 }
 
-static inline int is_t6(enum chip_type chip)
-{
-   return CHELSIO_CHIP_VERSION(chip) == CHELSIO_T6;
-}
-
-static inline int is_t5(enum chip_type chip)
-{
-   return CHELSIO_CHIP_VERSION(chip) == CHELSIO_T5;
-}
-
-static inline int is_t4(enum chip_type chip)
-{
-   return CHELSIO_CHIP_VERSION(chip) == CHELSIO_T4;
-}
-
 static inline u32 t4_read_reg(struct adapter *adap, u32 reg_addr)
 {
return readl(adap->regs + reg_addr);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index f5dcde2..aeeb21f 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -1936,6 +1936,28 @@ unsigned int cxgb4_best_aligned_mtu(const unsigned short 
*mtus,
 EXPORT_SYMBOL(cxgb4_best_aligned_mtu);
 
 /**
+ * cxgb4_tp_smt_idx - Get the Source Mac Table index for this VI
+ * @chip: chip type
+ * @viid: VI id of the given port
+ *
+ * Return the SMT index for this VI.
+ */
+unsigned int cxgb4_tp_smt_idx(enum chip_type chip, unsigned int viid)
+{
+   /* In T4/T5, SMT contains 256 SMAC entries organized in
+* 128 rows of 2 entries each.
+* In T6, SMT contains 256 SMAC entries in 256 rows.
+* TODO: The below code needs to be updated when we add support
+* for 256 VFs.
+*/
+   if (CHELSIO_CHIP_VERSION(chip) <= CHELSIO_T5)
+   return ((viid & 0x7f) << 1);
+   else
+   return (viid & 0x7f);
+}
+EXPORT_SYMBOL(cxgb4_tp_smt_idx);
+
+/**
  * cxgb4_port_chan - get the HW channel of a port
  * @dev: the net device for the port
  *
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
index c3a8be5..cf711d5 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include "cxgb4.h"
 
 /* CPL message priority levels */
 enum {
@@ -290,6 +291,7 @@ int cxgb4_ofld_send(struct net_device *dev, struct sk_buff 
*skb);
 unsigned int cxgb4_dbfifo_count(const struct net_device *dev, int lpfifo);
 unsigned int cxgb4_port_chan(const struct net_device *dev);
 unsigned int cxgb4_port_viid(const struct net_device *dev);
+unsigned int cxgb4_tp_smt_idx(enum chip_type chip, unsigned int viid);
 unsigned int cxgb4_port_idx(const struct net_device *dev);
 unsigned int cxgb4_best_mtu(const unsigned short *mtus, unsigned short mtu,
unsigned int *idx);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_chip_type.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4_chip_type.h
new file mode 100644
index 000..54b7181
--- /dev/null
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_chip_t

[PATCH for-next 5/5] iw_cxgb4: set the default MPA version to 2

2015-09-07 Thread Hariprasad Shenai
This enables ORD/IRD negotiation and its about time to enable it by
default

Signed-off-by: Hariprasad Shenai <haripra...@chelsio.com>
---
 drivers/infiniband/hw/cxgb4/cm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 0e2741b..79d6855 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -115,11 +115,11 @@ module_param(ep_timeout_secs, int, 0644);
 MODULE_PARM_DESC(ep_timeout_secs, "CM Endpoint operation timeout "
   "in seconds (default=60)");
 
-static int mpa_rev = 1;
+static int mpa_rev = 2;
 module_param(mpa_rev, int, 0644);
 MODULE_PARM_DESC(mpa_rev, "MPA Revision, 0 supports amso1100, "
"1 is RFC0544 spec compliant, 2 is IETF MPA Peer Connect Draft"
-   " compliant (default=1)");
+   " compliant (default=2)");
 
 static int markers_enabled;
 module_param(markers_enabled, int, 0644);
-- 
2.3.4

--
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


[PATCH for-next 3/5] iw_cxgb4: fix misuse of ep->ord for minimum ird calculation

2015-09-07 Thread Hariprasad Shenai
When calculating the minimum ird in c4iw_accept_cr(), we need to always
have a value of at least 1 if the RTR message is a 0B read.  The code
was
incorrectly using ep->ord for this logic which was incorrectly adjusting
the ird and causing incorrect ord/ird negotiation when using MPAv2 to
negotiate these values.

Signed-off-by: Hariprasad Shenai <haripra...@chelsio.com>
---
 drivers/infiniband/hw/cxgb4/cm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index a26d293..06d208c 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -2878,7 +2878,7 @@ int c4iw_accept_cr(struct iw_cm_id *cm_id, struct 
iw_cm_conn_param *conn_param)
} else {
if (peer2peer &&
(ep->mpa_attr.p2p_type != FW_RI_INIT_P2PTYPE_DISABLED) &&
-   (p2p_type == FW_RI_INIT_P2PTYPE_READ_REQ) && ep->ord == 0)
+   (p2p_type == FW_RI_INIT_P2PTYPE_READ_REQ) && ep->ird == 0)
ep->ird = 1;
}
 
-- 
2.3.4

--
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


[PATCH for-next 1/5] iw_cxgb4: detect fatal errors while creating listening filters

2015-09-07 Thread Hariprasad Shenai
In c4iw_create_listen(), if we're using listen filters, then bail out
of the busy loop if the device becomes fatally dead

Signed-off-by: Hariprasad Shenai <haripra...@chelsio.com>
---
 drivers/infiniband/hw/cxgb4/cm.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 3ad8dc7..42087c9 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -3202,6 +3202,10 @@ static int create_server4(struct c4iw_dev *dev, struct 
c4iw_listen_ep *ep)
sin->sin_addr.s_addr, sin->sin_port, 0,
ep->com.dev->rdev.lldi.rxq_ids[0], 0, 0);
if (err == -EBUSY) {
+   if (c4iw_fatal_error(>com.dev->rdev)) {
+   err = -EIO;
+   break;
+   }
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(usecs_to_jiffies(100));
}
-- 
2.3.4

--
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


[PATCH for-next 0/5] set MPA revision to 2 and misc. fixes for iw_cxgb4

2015-09-07 Thread Hariprasad Shenai
Hi,

This patch series adds the following.
Detect errors while creating listening servers, pass ird/ord info in
connect reply events, fix misuse of ord for ird calculation and for the
ESTABLISHED event we should have the peer's ord/ird so swap the values in
the event before the upcall. Set default MPA version to 2.

This patch series has been created against Doug's linux tree and includes
patches on iw_cxgb4 driver.

We have included all the maintainers of respective drivers. Kindly review
the change and let us know in case of any review comments.

Thanks


Hariprasad Shenai (5):
  iw_cxgb4: detect fatal errors while creating listening filters
  iw_cxgb4: pass the ord/ird in connect reply events
  iw_cxgb4: fix misuse of ep->ord for minimum ird calculation
  iw_cxgb4: reverse the ord/ird in the ESTABLISHED upcall
  iw_cxgb4: set the default MPA version to 2

 drivers/infiniband/hw/cxgb4/cm.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

-- 
2.3.4

--
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


[PATCH for-next 4/5] iw_cxgb4: reverse the ord/ird in the ESTABLISHED upcall

2015-09-07 Thread Hariprasad Shenai
The ESTABLISHED event should have the peer's ord/ird so
swap the values in the event before the upcall.

Signed-off-by: Hariprasad Shenai <haripra...@chelsio.com>
---
 drivers/infiniband/hw/cxgb4/cm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 06d208c..0e2741b 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -1242,8 +1242,8 @@ static void established_upcall(struct c4iw_ep *ep)
PDBG("%s ep %p tid %u\n", __func__, ep, ep->hwtid);
memset(, 0, sizeof(event));
event.event = IW_CM_EVENT_ESTABLISHED;
-   event.ird = ep->ird;
-   event.ord = ep->ord;
+   event.ird = ep->ord;
+   event.ord = ep->ird;
if (ep->com.cm_id) {
PDBG("%s ep %p tid %u\n", __func__, ep, ep->hwtid);
ep->com.cm_id->event_handler(ep->com.cm_id, );
-- 
2.3.4

--
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


[PATCH for-next 2/5] iw_cxgb4: pass the ord/ird in connect reply events

2015-09-07 Thread Hariprasad Shenai
This allows client ULPs to get the negotiated ord/ird which is useful
to avoid stalling the SQ due to exceeding the ORD.

Signed-off-by: Hariprasad Shenai <haripra...@chelsio.com>
---
 drivers/infiniband/hw/cxgb4/cm.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 42087c9..a26d293 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -1169,6 +1169,8 @@ static void connect_reply_upcall(struct c4iw_ep *ep, int 
status)
if ((status == 0) || (status == -ECONNREFUSED)) {
if (!ep->tried_with_mpa_v1) {
/* this means MPA_v2 is used */
+   event.ord = ep->ird;
+   event.ird = ep->ord;
event.private_data_len = ep->plen -
sizeof(struct mpa_v2_conn_params);
event.private_data = ep->mpa_pkt +
@@ -1176,6 +1178,8 @@ static void connect_reply_upcall(struct c4iw_ep *ep, int 
status)
sizeof(struct mpa_v2_conn_params);
} else {
/* this means MPA_v1 is used */
+   event.ord = cur_max_read_depth(ep->com.dev);
+   event.ird = cur_max_read_depth(ep->com.dev);
event.private_data_len = ep->plen;
event.private_data = ep->mpa_pkt +
sizeof(struct mpa_message);
-- 
2.3.4

--
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


[PATCH for-4.3] iw_cxgb4: Add support for clip

2015-08-25 Thread Hariprasad Shenai
Add support for ipv6 address handling clip api provided by lld

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c | 76 +---
 1 file changed, 72 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 3ad8dc7..d699719 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -50,6 +50,7 @@
 #include rdma/ib_addr.h
 
 #include iw_cxgb4.h
+#include clip_tbl.h
 
 static char *states[] = {
idle,
@@ -298,6 +299,16 @@ void _c4iw_free_ep(struct kref *kref)
if (test_bit(QP_REFERENCED, ep-com.flags))
deref_qp(ep);
if (test_bit(RELEASE_RESOURCES, ep-com.flags)) {
+   if (ep-com.remote_addr.ss_family == AF_INET6) {
+   struct sockaddr_in6 *sin6 =
+   (struct sockaddr_in6 *)
+   ep-com.mapped_local_addr;
+
+   cxgb4_clip_release(
+   ep-com.dev-rdev.lldi.ports[0],
+   (const u32 *)sin6-sin6_addr.s6_addr,
+   1);
+   }
remove_handle(ep-com.dev, ep-com.dev-hwtid_idr, ep-hwtid);
cxgb4_remove_tid(ep-com.dev-rdev.lldi.tids, 0, ep-hwtid);
dst_release(ep-dst);
@@ -442,6 +453,12 @@ static void act_open_req_arp_failure(void *handle, struct 
sk_buff *skb)
kfree_skb(skb);
connect_reply_upcall(ep, -EHOSTUNREACH);
state_set(ep-com, DEAD);
+   if (ep-com.remote_addr.ss_family == AF_INET6) {
+   struct sockaddr_in6 *sin6 =
+   (struct sockaddr_in6 *)ep-com.mapped_local_addr;
+   cxgb4_clip_release(ep-com.dev-rdev.lldi.ports[0],
+  (const u32 *)sin6-sin6_addr.s6_addr, 1);
+   }
remove_handle(ep-com.dev, ep-com.dev-atid_idr, ep-atid);
cxgb4_free_atid(ep-com.dev-rdev.lldi.tids, ep-atid);
dst_release(ep-dst);
@@ -640,6 +657,7 @@ static int send_connect(struct c4iw_ep *ep)
struct sockaddr_in6 *ra6 = (struct sockaddr_in6 *)
   ep-com.mapped_remote_addr;
int win;
+   int ret;
 
wrlen = (ep-com.remote_addr.ss_family == AF_INET) ?
roundup(sizev4, 16) :
@@ -693,6 +711,11 @@ static int send_connect(struct c4iw_ep *ep)
opt2 |= CONG_CNTRL_V(CONG_ALG_TAHOE);
opt2 |= T5_ISS_F;
}
+
+   if (ep-com.remote_addr.ss_family == AF_INET6)
+   cxgb4_clip_get(ep-com.dev-rdev.lldi.ports[0],
+  (const u32 *)la6-sin6_addr.s6_addr, 1);
+
t4_set_arp_err_handler(skb, ep, act_open_req_arp_failure);
 
if (is_t4(ep-com.dev-rdev.lldi.adapter_type)) {
@@ -790,7 +813,11 @@ static int send_connect(struct c4iw_ep *ep)
}
 
set_bit(ACT_OPEN_REQ, ep-com.history);
-   return c4iw_l2t_send(ep-com.dev-rdev, skb, ep-l2t);
+   ret = c4iw_l2t_send(ep-com.dev-rdev, skb, ep-l2t);
+   if (ret  ep-com.remote_addr.ss_family == AF_INET6)
+   cxgb4_clip_release(ep-com.dev-rdev.lldi.ports[0],
+  (const u32 *)la6-sin6_addr.s6_addr, 1);
+   return ret;
 }
 
 static void send_mpa_req(struct c4iw_ep *ep, struct sk_buff *skb,
@@ -2091,6 +2118,15 @@ static int act_open_rpl(struct c4iw_dev *dev, struct 
sk_buff *skb)
case CPL_ERR_CONN_EXIST:
if (ep-retry_count++  ACT_OPEN_RETRY_COUNT) {
set_bit(ACT_RETRY_INUSE, ep-com.history);
+   if (ep-com.remote_addr.ss_family == AF_INET6) {
+   struct sockaddr_in6 *sin6 =
+   (struct sockaddr_in6 *)
+   ep-com.mapped_local_addr;
+   cxgb4_clip_release(
+   ep-com.dev-rdev.lldi.ports[0],
+   (const u32 *)
+   sin6-sin6_addr.s6_addr, 1);
+   }
remove_handle(ep-com.dev, ep-com.dev-atid_idr,
atid);
cxgb4_free_atid(t, atid);
@@ -2118,6 +2154,12 @@ static int act_open_rpl(struct c4iw_dev *dev, struct 
sk_buff *skb)
connect_reply_upcall(ep, status2errno(status));
state_set(ep-com, DEAD);
 
+   if (ep-com.remote_addr.ss_family == AF_INET6) {
+   struct sockaddr_in6 *sin6 =
+   (struct sockaddr_in6 *)ep-com.mapped_local_addr;
+   cxgb4_clip_release(ep-com.dev-rdev.lldi.ports[0],
+  (const u32 *)sin6-sin6_addr.s6_addr, 1);
+   }
if (status

[PATCH for-4.2] iw_cxgb4: gracefully handle unknown CQE status errors

2015-07-26 Thread Hariprasad Shenai
c4iw_poll_cq_on() shouldn't fail the poll operation just because
the CQE status is unknown.  Rather, it should map this to the
fatal error status and log the anomaly.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index c7aab48..92d5183 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -814,7 +814,7 @@ static int c4iw_poll_cq_one(struct c4iw_cq *chp, struct 
ib_wc *wc)
printk(KERN_ERR MOD
   Unexpected cqe_status 0x%x for QPID=0x%0x\n,
   CQE_STATUS(cqe), CQE_QPID(cqe));
-   ret = -EINVAL;
+   wc-status = IB_WC_FATAL_ERR;
}
}
 out:
-- 
2.3.4

--
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


[PATCH for-4.2] iw_cxgb4: set the default MPA version to 2

2015-07-26 Thread Hariprasad Shenai
This enables ORD/IRD negotiation and its about time to enable it by
default

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 3ad8dc7..75144d9 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -115,11 +115,11 @@ module_param(ep_timeout_secs, int, 0644);
 MODULE_PARM_DESC(ep_timeout_secs, CM Endpoint operation timeout 
   in seconds (default=60));
 
-static int mpa_rev = 1;
+static int mpa_rev = 2;
 module_param(mpa_rev, int, 0644);
 MODULE_PARM_DESC(mpa_rev, MPA Revision, 0 supports amso1100, 
1 is RFC0544 spec compliant, 2 is IETF MPA Peer Connect Draft
-compliant (default=1));
+compliant (default=2));
 
 static int markers_enabled;
 module_param(markers_enabled, int, 0644);
-- 
2.3.4

--
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


[PATCH for-4.1 1/2] cxgb4: Support for user mode bar2 mappings with T4

2015-06-09 Thread Hariprasad Shenai
Enhance cxgb4_t4_bar2_sge_qregs() and cxgb4_bar2_sge_qregs() to support T4
user mode mappings.  Update all the current users as well.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  | 1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 4 +++-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h  | 1 +
 drivers/net/ethernet/chelsio/cxgb4/sge.c| 4 ++--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c  | 7 ---
 5 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 524d110..e052f05 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -1185,6 +1185,7 @@ enum t4_bar2_qtype { T4_BAR2_QTYPE_EGRESS, 
T4_BAR2_QTYPE_INGRESS };
 int cxgb4_t4_bar2_sge_qregs(struct adapter *adapter,
  unsigned int qid,
  enum t4_bar2_qtype qtype,
+ int user,
  u64 *pbar2_qoffset,
  unsigned int *pbar2_qid);
 
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 803d91b..a935559 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -2145,6 +2145,7 @@ EXPORT_SYMBOL(cxgb4_read_sge_timestamp);
 int cxgb4_bar2_sge_qregs(struct net_device *dev,
 unsigned int qid,
 enum cxgb4_bar2_qtype qtype,
+int user,
 u64 *pbar2_qoffset,
 unsigned int *pbar2_qid)
 {
@@ -2153,6 +2154,7 @@ int cxgb4_bar2_sge_qregs(struct net_device *dev,
 (qtype == CXGB4_BAR2_QTYPE_EGRESS
  ? T4_BAR2_QTYPE_EGRESS
  : T4_BAR2_QTYPE_INGRESS),
+user,
 pbar2_qoffset,
 pbar2_qid);
 }
@@ -2351,7 +2353,7 @@ static void process_db_drop(struct work_struct *work)
int ret;
 
ret = cxgb4_t4_bar2_sge_qregs(adap, qid, T4_BAR2_QTYPE_EGRESS,
-   bar2_qoffset, bar2_qid);
+ 0, bar2_qoffset, bar2_qid);
if (ret)
dev_err(adap-pdev_dev, doorbell drop recovery: 
qid=%d, pidx_inc=%d\n, qid, pidx_inc);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
index 78ab4d4..e33934a 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
@@ -306,6 +306,7 @@ enum cxgb4_bar2_qtype { CXGB4_BAR2_QTYPE_EGRESS, 
CXGB4_BAR2_QTYPE_INGRESS };
 int cxgb4_bar2_sge_qregs(struct net_device *dev,
 unsigned int qid,
 enum cxgb4_bar2_qtype qtype,
+int user,
 u64 *pbar2_qoffset,
 unsigned int *pbar2_qid);
 
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c 
b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index 0d2edda..1b99aec 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -2429,8 +2429,8 @@ static void __iomem *bar2_address(struct adapter *adapter,
u64 bar2_qoffset;
int ret;
 
-   ret = cxgb4_t4_bar2_sge_qregs(adapter, qid, qtype,
-   bar2_qoffset, pbar2_qid);
+   ret = cxgb4_t4_bar2_sge_qregs(adapter, qid, qtype, 0,
+ bar2_qoffset, pbar2_qid);
if (ret)
return NULL;
 
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 5959e3a..2d76a07 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -5102,6 +5102,7 @@ int t4_prep_adapter(struct adapter *adapter)
  * @adapter: the adapter
  * @qid: the Queue ID
  * @qtype: the Ingress or Egress type for @qid
+ * @user: true if this request is for a user mode queue
  * @pbar2_qoffset: BAR2 Queue Offset
  * @pbar2_qid: BAR2 Queue ID or 0 for Queue ID inferred SGE Queues
  *
@@ -5125,6 +5126,7 @@ int t4_prep_adapter(struct adapter *adapter)
 int cxgb4_t4_bar2_sge_qregs(struct adapter *adapter,
  unsigned int qid,
  enum t4_bar2_qtype qtype,
+ int user,
  u64 *pbar2_qoffset,
  unsigned int *pbar2_qid)
 {
@@ -5132,9 +5134,8 @@ int cxgb4_t4_bar2_sge_qregs(struct adapter *adapter,
u64 bar2_page_offset, bar2_qoffset;
unsigned int bar2_qid, bar2_qid_offset

[PATCH for-4.1 2/2] iw_cxgb4: support for bar2 qid densities exceeding the page size

2015-06-09 Thread Hariprasad Shenai
Handle this configuration:

Queues Per Page * SGE BAR2 Queue Register Area Size  Page Size

Use cxgb4_bar2_sge_qregs() to obtain the proper location within the
bar2 region for a given qid.

Rework the DB and GTS write functions to make use of this bar2 info.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cq.c   | 22 ++--
 drivers/infiniband/hw/cxgb4/device.c   | 16 +++--
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h |  5 +--
 drivers/infiniband/hw/cxgb4/qp.c   | 64 ++
 drivers/infiniband/hw/cxgb4/t4.h   | 60 ---
 5 files changed, 98 insertions(+), 69 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index 68ddb37..8e5bbcb 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -156,19 +156,17 @@ static int create_cq(struct c4iw_rdev *rdev, struct t4_cq 
*cq,
goto err4;
 
cq-gen = 1;
+   cq-gts = rdev-lldi.gts_reg;
cq-rdev = rdev;
-   if (user) {
-   u32 off = (cq-cqid  rdev-cqshift)  PAGE_MASK;
 
-   cq-ugts = (u64)rdev-bar2_pa + off;
-   } else if (is_t4(rdev-lldi.adapter_type)) {
-   cq-gts = rdev-lldi.gts_reg;
-   cq-qid_mask = -1U;
-   } else {
-   u32 off = ((cq-cqid  rdev-cqshift)  PAGE_MASK) + 12;
-
-   cq-gts = rdev-bar2_kva + off;
-   cq-qid_mask = rdev-qpmask;
+   cq-bar2_va = c4iw_bar2_addrs(rdev, cq-cqid, T4_BAR2_QTYPE_INGRESS,
+ cq-bar2_qid,
+ user ? cq-bar2_pa : NULL);
+   if (user  !cq-bar2_va) {
+   pr_warn(MOD %s: cqid %u not in BAR2 range.\n,
+   pci_name(rdev-lldi.pdev), cq-cqid);
+   ret = -EINVAL;
+   goto err4;
}
return 0;
 err4:
@@ -971,7 +969,7 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int 
entries,
insert_mmap(ucontext, mm);
 
mm2-key = uresp.gts_key;
-   mm2-addr = chp-cq.ugts;
+   mm2-addr = (u64)(uintptr_t)chp-cq.bar2_pa;
mm2-len = PAGE_SIZE;
insert_mmap(ucontext, mm2);
}
diff --git a/drivers/infiniband/hw/cxgb4/device.c 
b/drivers/infiniband/hw/cxgb4/device.c
index 1ffbd03..ab36804 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -788,13 +788,7 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
goto err1;
}
 
-   /*
-* qpshift is the number of bits to shift the qpid left in order
-* to get the correct address of the doorbell for that qp.
-*/
-   rdev-qpshift = PAGE_SHIFT - ilog2(rdev-lldi.udb_density);
rdev-qpmask = rdev-lldi.udb_density - 1;
-   rdev-cqshift = PAGE_SHIFT - ilog2(rdev-lldi.ucq_density);
rdev-cqmask = rdev-lldi.ucq_density - 1;
PDBG(%s dev %s stag start 0x%0x size 0x%0x num stags %d 
 pbl start 0x%0x size 0x%0x rq start 0x%0x size 0x%0x 
@@ -808,14 +802,12 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
 rdev-lldi.vr-qp.size,
 rdev-lldi.vr-cq.start,
 rdev-lldi.vr-cq.size);
-   PDBG(udb len 0x%x udb base %p db_reg %p gts_reg %p qpshift %lu 
-qpmask 0x%x cqshift %lu cqmask 0x%x\n,
+   PDBG(udb len 0x%x udb base %p db_reg %p gts_reg %p 
+qpmask 0x%x cqmask 0x%x\n,
 (unsigned)pci_resource_len(rdev-lldi.pdev, 2),
 (void *)pci_resource_start(rdev-lldi.pdev, 2),
-rdev-lldi.db_reg,
-rdev-lldi.gts_reg,
-rdev-qpshift, rdev-qpmask,
-rdev-cqshift, rdev-cqmask);
+rdev-lldi.db_reg, rdev-lldi.gts_reg,
+rdev-qpmask, rdev-cqmask);
 
if (c4iw_num_stags(rdev) == 0) {
err = -EINVAL;
diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h 
b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
index d87e165..7a1b675 100644
--- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
+++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
@@ -164,9 +164,7 @@ struct wr_log_entry {
 
 struct c4iw_rdev {
struct c4iw_resource resource;
-   unsigned long qpshift;
u32 qpmask;
-   unsigned long cqshift;
u32 cqmask;
struct c4iw_dev_ucontext uctx;
struct gen_pool *pbl_pool;
@@ -1025,6 +1023,9 @@ void c4iw_ev_dispatch(struct c4iw_dev *dev, struct t4_cqe 
*err_cqe);
 
 extern struct cxgb4_client t4c_client;
 extern c4iw_handler_func c4iw_handlers[NUM_CPL_CMDS];
+void __iomem *c4iw_bar2_addrs(struct c4iw_rdev *rdev, unsigned int qid,
+ enum cxgb4_bar2_qtype qtype,
+ unsigned int *pbar2_qid, u64 *pbar2_pa);
 extern void c4iw_log_wr_stats(struct t4_wq *wq, struct

[PATCH for-4.1 0/2] Adds support for user mode bar2 mapping and bar2 qid density

2015-06-09 Thread Hariprasad Shenai
Hi,

This patch series adds support for user mode bar2 mappings for T4 adapter
and also adds  support for bar2 qid densities exceeding page size.

This patch series has been created against Doug's github tree 'for-4.1'
branch and includes patches on cxgb4 and iw_cxgb4 driver.

We have included all the maintainers of respective drivers. Kindly review
the change and let us know in case of any review comments.

Thanks

Hariprasad Shenai (2):
  cxgb4: Support for user mode bar2 mappings with T4
  iw_cxgb4: support for bar2 qid densities exceeding the page size

 drivers/infiniband/hw/cxgb4/cq.c| 22 -
 drivers/infiniband/hw/cxgb4/device.c| 16 ++-
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h  |  5 +-
 drivers/infiniband/hw/cxgb4/qp.c| 64 -
 drivers/infiniband/hw/cxgb4/t4.h| 60 +++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |  1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |  4 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h  |  1 +
 drivers/net/ethernet/chelsio/cxgb4/sge.c|  4 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c  |  7 +--
 10 files changed, 109 insertions(+), 75 deletions(-)

-- 
2.3.4

--
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


[PATCH for-4.1] iw_cxgb4: Fix kbuild bot reported warnings

2015-04-28 Thread Hariprasad Shenai
Commit 20dca80f (iw_cxgb4: 32b platform fixes) introduced warnings
related to inappropriate argument type while printing arguments

Reported by: Dan Carpenter dan.carpen...@oracle.com
Reported by: kbuild test robot fengguang...@intel.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cq.c  | 5 +++--
 drivers/infiniband/hw/cxgb4/mem.c | 4 ++--
 drivers/infiniband/hw/cxgb4/qp.c  | 4 ++--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index be66d5d..1f114c0 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -340,7 +340,8 @@ static void advance_oldest_read(struct t4_wq *wq)
  */
 void c4iw_flush_hw_cq(struct c4iw_cq *chp)
 {
-   struct t4_cqe *hw_cqe, *swcqe, read_cqe;
+   struct t4_cqe *hw_cqe = NULL;
+   struct t4_cqe *swcqe, read_cqe;
struct c4iw_qp *qhp;
struct t4_swsqe *swsqe;
int ret;
@@ -975,7 +976,7 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int 
entries,
mm2-len = PAGE_SIZE;
insert_mmap(ucontext, mm2);
}
-   PDBG(%s cqid 0x%0x chp %p size %u memsize %zu, dma_addr 0x%0llx\n,
+   PDBG(%s cqid 0x%0x chp %p size %u memsize %lu, dma_addr 0x%0llx\n,
 __func__, chp-cq.cqid, chp, chp-cq.size,
 (uintptr_t)chp-cq.memsize,
 (unsigned long long) chp-cq.dma_addr);
diff --git a/drivers/infiniband/hw/cxgb4/mem.c 
b/drivers/infiniband/hw/cxgb4/mem.c
index 9a26649..42805f6 100644
--- a/drivers/infiniband/hw/cxgb4/mem.c
+++ b/drivers/infiniband/hw/cxgb4/mem.c
@@ -930,7 +930,7 @@ struct ib_fast_reg_page_list *c4iw_alloc_fastreg_pbl(struct 
ib_device *device,
 
PDBG(%s c4pl %p pll_len %u page_list %p dma_addr %pad\n,
 __func__, c4pl, c4pl-pll_len, c4pl-ibpl.page_list,
-(void *)(uintptr_t)c4pl-dma_addr);
+(dma_addr_t *)(uintptr_t)c4pl-dma_addr);
 
return c4pl-ibpl;
 }
@@ -941,7 +941,7 @@ void c4iw_free_fastreg_pbl(struct ib_fast_reg_page_list 
*ibpl)
 
PDBG(%s c4pl %p pll_len %u page_list %p dma_addr %pad\n,
 __func__, c4pl, c4pl-pll_len, c4pl-ibpl.page_list,
-(void *)(uintptr_t)c4pl-dma_addr);
+(dma_addr_t *)(uintptr_t)c4pl-dma_addr);
 
dma_free_coherent(c4pl-dev-rdev.lldi.pdev-dev,
  c4pl-pll_len,
diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
index 7ce40c3..176a238 100644
--- a/drivers/infiniband/hw/cxgb4/qp.c
+++ b/drivers/infiniband/hw/cxgb4/qp.c
@@ -1784,8 +1784,8 @@ struct ib_qp *c4iw_create_qp(struct ib_pd *pd, struct 
ib_qp_init_attr *attrs,
qhp-ibqp.qp_num = qhp-wq.sq.qid;
init_timer((qhp-timer));
INIT_LIST_HEAD(qhp-db_fc_entry);
-   PDBG(%s sq id %u size %u memsize %zu num_entries %u 
-rq id %u size %u memsize %zu num_entries %u\n, __func__,
+   PDBG(%s sq id %u size %u memsize %lu num_entries %u 
+rq id %u size %u memsize %lu num_entries %u\n, __func__,
 qhp-wq.sq.qid, qhp-wq.sq.size, (unsigned long)qhp-wq.sq.memsize,
 attrs-cap.max_send_wr, qhp-wq.rq.qid, qhp-wq.rq.size,
 (unsigned long)qhp-wq.rq.memsize, attrs-cap.max_recv_wr);
-- 
2.3.4

--
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


[PATCHv2 for-4.1 0/4] Misc. fixes and cleanup for iw_cxgb4

2015-04-21 Thread Hariprasad Shenai
Hi,

This patch series changes a macro definition to be consistent with other
register macro defines. Fixes for 32b platform, use BAR2 register for kernel
mode CQ's and enforces qp/cq id requirements.

The patches series is created against github for-4.1 branch.
And includes patches on iw_cxgb4 driver.

We have included all the maintainers of respective drivers. Kindly review the
change and let us know in case of any review comments.

Thanks

V2: Use uintptr_t instead of unsigned long, based on review comment by
Doug Ledford

Hariprasad Shenai (4):
  iw_cxgb4: Cleanup register defines/MACROS
  iw_cxgb4: 32b platform fixes
  iw_cxgb4: use BAR2 GTS register for T5 kernel mode CQs
  iw_cxgb4: enforce qp/cq id requirements

 drivers/infiniband/hw/cxgb4/cm.c  |  6 +++---
 drivers/infiniband/hw/cxgb4/cq.c  | 21 ++---
 drivers/infiniband/hw/cxgb4/device.c  | 29 ++---
 drivers/infiniband/hw/cxgb4/mem.c | 10 +-
 drivers/infiniband/hw/cxgb4/qp.c  | 14 +++---
 drivers/infiniband/hw/cxgb4/t4.h  |  7 ---
 drivers/infiniband/hw/cxgb4/t4fw_ri_api.h |  4 +++-
 7 files changed, 62 insertions(+), 29 deletions(-)

-- 
2.3.4

--
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


[PATCHv2 for-4.1 3/4] iw_cxgb4: use BAR2 GTS register for T5 kernel mode CQs

2015-04-21 Thread Hariprasad Shenai
For T5, we must not use the kdb/kgts registers, in order avoid db drops
under extreme loads.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cq.c | 15 +++
 drivers/infiniband/hw/cxgb4/t4.h |  7 ---
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index 3ca00fa..be66d5d 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -156,12 +156,19 @@ static int create_cq(struct c4iw_rdev *rdev, struct t4_cq 
*cq,
goto err4;
 
cq-gen = 1;
-   cq-gts = rdev-lldi.gts_reg;
cq-rdev = rdev;
if (user) {
-   cq-ugts = (u64)pci_resource_start(rdev-lldi.pdev, 2) +
-   (cq-cqid  rdev-cqshift);
-   cq-ugts = PAGE_MASK;
+   u32 off = (cq-cqid  rdev-cqshift)  PAGE_MASK;
+
+   cq-ugts = (u64)rdev-bar2_pa + off;
+   } else if (is_t4(rdev-lldi.adapter_type)) {
+   cq-gts = rdev-lldi.gts_reg;
+   cq-qid_mask = -1U;
+   } else {
+   u32 off = ((cq-cqid  rdev-cqshift)  PAGE_MASK) + 12;
+
+   cq-gts = rdev-bar2_kva + off;
+   cq-qid_mask = rdev-qpmask;
}
return 0;
 err4:
diff --git a/drivers/infiniband/hw/cxgb4/t4.h b/drivers/infiniband/hw/cxgb4/t4.h
index 871cdca..7f2a6c2 100644
--- a/drivers/infiniband/hw/cxgb4/t4.h
+++ b/drivers/infiniband/hw/cxgb4/t4.h
@@ -539,6 +539,7 @@ struct t4_cq {
size_t memsize;
__be64 bits_type_ts;
u32 cqid;
+   u32 qid_mask;
int vector;
u16 size; /* including status page */
u16 cidx;
@@ -563,12 +564,12 @@ static inline int t4_arm_cq(struct t4_cq *cq, int se)
set_bit(CQ_ARMED, cq-flags);
while (cq-cidx_inc  CIDXINC_M) {
val = SEINTARM_V(0) | CIDXINC_V(CIDXINC_M) | TIMERREG_V(7) |
- INGRESSQID_V(cq-cqid);
+ INGRESSQID_V(cq-cqid  cq-qid_mask);
writel(val, cq-gts);
cq-cidx_inc -= CIDXINC_M;
}
val = SEINTARM_V(se) | CIDXINC_V(cq-cidx_inc) | TIMERREG_V(6) |
- INGRESSQID_V(cq-cqid);
+ INGRESSQID_V(cq-cqid  cq-qid_mask);
writel(val, cq-gts);
cq-cidx_inc = 0;
return 0;
@@ -601,7 +602,7 @@ static inline void t4_hwcq_consume(struct t4_cq *cq)
u32 val;
 
val = SEINTARM_V(0) | CIDXINC_V(cq-cidx_inc) | TIMERREG_V(7) |
- INGRESSQID_V(cq-cqid);
+ INGRESSQID_V(cq-cqid  cq-qid_mask);
writel(val, cq-gts);
cq-cidx_inc = 0;
}
-- 
2.3.4

--
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


[PATCHv2 for-4.1 1/4] iw_cxgb4: Cleanup register defines/MACROS

2015-04-21 Thread Hariprasad Shenai
Cleanup macros and register defines for consistency

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c  | 4 ++--
 drivers/infiniband/hw/cxgb4/t4fw_ri_api.h | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 57176dd..0493cca 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -675,7 +675,7 @@ static int send_connect(struct c4iw_ep *ep)
if (is_t5(ep-com.dev-rdev.lldi.adapter_type)) {
opt2 |= T5_OPT_2_VALID_F;
opt2 |= CONG_CNTRL_V(CONG_ALG_TAHOE);
-   opt2 |= CONG_CNTRL_VALID; /* OPT_2_ISS for T5 */
+   opt2 |= T5_ISS_F;
}
t4_set_arp_err_handler(skb, ep, act_open_req_arp_failure);
 
@@ -2214,7 +2214,7 @@ static void accept_cr(struct c4iw_ep *ep, struct sk_buff 
*skb,
u32 isn = (prandom_u32()  ~7UL) - 1;
opt2 |= T5_OPT_2_VALID_F;
opt2 |= CONG_CNTRL_V(CONG_ALG_TAHOE);
-   opt2 |= CONG_CNTRL_VALID; /* OPT_2_ISS for T5 */
+   opt2 |= T5_ISS_F;
rpl5 = (void *)rpl;
memset(rpl5-iss, 0, roundup(sizeof(*rpl5)-sizeof(*rpl), 16));
if (peer2peer)
diff --git a/drivers/infiniband/hw/cxgb4/t4fw_ri_api.h 
b/drivers/infiniband/hw/cxgb4/t4fw_ri_api.h
index 5e53327..343e8daf 100644
--- a/drivers/infiniband/hw/cxgb4/t4fw_ri_api.h
+++ b/drivers/infiniband/hw/cxgb4/t4fw_ri_api.h
@@ -848,6 +848,8 @@ enum { /* TCP congestion control 
algorithms */
 #define CONG_CNTRL_V(x) ((x)  CONG_CNTRL_S)
 #define CONG_CNTRL_G(x) (((x)  CONG_CNTRL_S)  CONG_CNTRL_M)
 
-#define CONG_CNTRL_VALID   (1  18)
+#define T5_ISS_S18
+#define T5_ISS_V(x) ((x)  T5_ISS_S)
+#define T5_ISS_FT5_ISS_V(1U)
 
 #endif /* _T4FW_RI_API_H_ */
-- 
2.3.4

--
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


[PATCHv2 for-4.1 4/4] iw_cxgb4: enforce qp/cq id requirements

2015-04-21 Thread Hariprasad Shenai
Currently the iw_cxgb4 implementation requires the qp and cq qid densities
to match as well as the qp and cq id ranges.  So fail a device open if
the device configuration doesn't meet the requirements.

The reason for these restictions has to do with the fact that IQ qid X
has a UGTS register in the same bar2 page as EQ qid X.  Thus both qids
need to be allocated to the same user process for security reasons.
The logic that does this (the qpid allocator in iw_cxgb4/resource.c)
handles this but requires the above restrictions.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/device.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/drivers/infiniband/hw/cxgb4/device.c 
b/drivers/infiniband/hw/cxgb4/device.c
index 33bd1ac..3f782f9 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -765,6 +765,29 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
c4iw_init_dev_ucontext(rdev, rdev-uctx);
 
/*
+* This implementation assumes udb_density == ucq_density!  Eventually
+* we might need to support this but for now fail the open. Also the
+* cqid and qpid range must match for now.
+*/
+   if (rdev-lldi.udb_density != rdev-lldi.ucq_density) {
+   pr_err(MOD %s: unsupported udb/ucq densities %u/%u\n,
+  pci_name(rdev-lldi.pdev), rdev-lldi.udb_density,
+  rdev-lldi.ucq_density);
+   err = -EINVAL;
+   goto err1;
+   }
+   if (rdev-lldi.vr-qp.start != rdev-lldi.vr-cq.start ||
+   rdev-lldi.vr-qp.size != rdev-lldi.vr-cq.size) {
+   pr_err(MOD %s: unsupported qp and cq id ranges 
+  qp start %u size %u cq start %u size %u\n,
+  pci_name(rdev-lldi.pdev), rdev-lldi.vr-qp.start,
+  rdev-lldi.vr-qp.size, rdev-lldi.vr-cq.size,
+  rdev-lldi.vr-cq.size);
+   err = -EINVAL;
+   goto err1;
+   }
+
+   /*
 * qpshift is the number of bits to shift the qpid left in order
 * to get the correct address of the doorbell for that qp.
 */
-- 
2.3.4

--
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


[PATCHv2 for-4.1 2/4] iw_cxgb4: 32b platform fixes

2015-04-21 Thread Hariprasad Shenai
- get_dma_mr() was using ~0UL which is should be ~0ULL.  This causes the
DMA MR to get setup incorrectly in hardware.

- wr_log_show() needed a 64b divide function div64_u64() instead of
  doing
division directly.

- fixed warnings about recasting a pointer to a u64

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c |  2 +-
 drivers/infiniband/hw/cxgb4/cq.c |  6 +++---
 drivers/infiniband/hw/cxgb4/device.c |  6 +++---
 drivers/infiniband/hw/cxgb4/mem.c| 10 +-
 drivers/infiniband/hw/cxgb4/qp.c | 14 +++---
 5 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 0493cca..6fb31ba 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -3571,7 +3571,7 @@ static void send_fw_pass_open_req(struct c4iw_dev *dev, 
struct sk_buff *skb,
 * TP will ignore any value  0 for MSS index.
 */
req-tcb.opt0 = cpu_to_be64(MSS_IDX_V(0xF));
-   req-cookie = (unsigned long)skb;
+   req-cookie = (uintptr_t)skb;
 
set_wr_txq(req_skb, CPL_PRIORITY_CONTROL, port_id);
ret = cxgb4_ofld_send(dev-rdev.lldi.ports[0], req_skb);
diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index ab7692a..3ca00fa 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -55,7 +55,7 @@ static int destroy_cq(struct c4iw_rdev *rdev, struct t4_cq 
*cq,
FW_RI_RES_WR_NRES_V(1) |
FW_WR_COMPL_F);
res_wr-len16_pkd = cpu_to_be32(DIV_ROUND_UP(wr_len, 16));
-   res_wr-cookie = (unsigned long) wr_wait;
+   res_wr-cookie = (uintptr_t)wr_wait;
res = res_wr-res;
res-u.cq.restype = FW_RI_RES_TYPE_CQ;
res-u.cq.op = FW_RI_RES_OP_RESET;
@@ -125,7 +125,7 @@ static int create_cq(struct c4iw_rdev *rdev, struct t4_cq 
*cq,
FW_RI_RES_WR_NRES_V(1) |
FW_WR_COMPL_F);
res_wr-len16_pkd = cpu_to_be32(DIV_ROUND_UP(wr_len, 16));
-   res_wr-cookie = (unsigned long) wr_wait;
+   res_wr-cookie = (uintptr_t)wr_wait;
res = res_wr-res;
res-u.cq.restype = FW_RI_RES_TYPE_CQ;
res-u.cq.op = FW_RI_RES_OP_WRITE;
@@ -970,7 +970,7 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int 
entries,
}
PDBG(%s cqid 0x%0x chp %p size %u memsize %zu, dma_addr 0x%0llx\n,
 __func__, chp-cq.cqid, chp, chp-cq.size,
-chp-cq.memsize,
+(uintptr_t)chp-cq.memsize,
 (unsigned long long) chp-cq.dma_addr);
return chp-ibcq;
 err5:
diff --git a/drivers/infiniband/hw/cxgb4/device.c 
b/drivers/infiniband/hw/cxgb4/device.c
index 8fb295e..33bd1ac 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -151,7 +151,7 @@ static int wr_log_show(struct seq_file *seq, void *v)
int prev_ts_set = 0;
int idx, end;
 
-#define ts2ns(ts) div64_ul((ts) * dev-rdev.lldi.cclk_ps, 1000)
+#define ts2ns(ts) div64_u64((ts) * dev-rdev.lldi.cclk_ps, 1000)
 
idx = atomic_read(dev-rdev.wr_log_idx) 
(dev-rdev.wr_log_size - 1);
@@ -784,10 +784,10 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
 rdev-lldi.vr-qp.size,
 rdev-lldi.vr-cq.start,
 rdev-lldi.vr-cq.size);
-   PDBG(udb len 0x%x udb base %llx db_reg %p gts_reg %p qpshift %lu 
+   PDBG(udb len 0x%x udb base %p db_reg %p gts_reg %p qpshift %lu 
 qpmask 0x%x cqshift %lu cqmask 0x%x\n,
 (unsigned)pci_resource_len(rdev-lldi.pdev, 2),
-(u64)pci_resource_start(rdev-lldi.pdev, 2),
+(void *)(uintptr_t)pci_resource_start(rdev-lldi.pdev, 2),
 rdev-lldi.db_reg,
 rdev-lldi.gts_reg,
 rdev-qpshift, rdev-qpmask,
diff --git a/drivers/infiniband/hw/cxgb4/mem.c 
b/drivers/infiniband/hw/cxgb4/mem.c
index 6791fd1..9a26649 100644
--- a/drivers/infiniband/hw/cxgb4/mem.c
+++ b/drivers/infiniband/hw/cxgb4/mem.c
@@ -144,7 +144,7 @@ static int _c4iw_write_mem_inline(struct c4iw_rdev *rdev, 
u32 addr, u32 len,
if (i == (num_wqe-1)) {
req-wr.wr_hi = cpu_to_be32(FW_WR_OP_V(FW_ULPTX_WR) |
FW_WR_COMPL_F);
-   req-wr.wr_lo = (__force __be64)(unsigned long) 
wr_wait;
+   req-wr.wr_lo = (__force __be64)(uintptr_t)wr_wait;
} else
req-wr.wr_hi = cpu_to_be32(FW_WR_OP_V(FW_ULPTX_WR));
req-wr.wr_mid = cpu_to_be32(
@@ -676,12 +676,12 @@ struct ib_mr *c4iw_get_dma_mr(struct ib_pd *pd, int acc)
mhp-attr.zbva = 0;
mhp-attr.va_fbo = 0;
mhp-attr.page_size = 0;
-   mhp-attr.len = ~0UL;
+   mhp-attr.len = ~0ULL

[PATCH for-4.1 2/4] iw_cxgb4: 32b platform fixes

2015-04-17 Thread Hariprasad Shenai
- get_dma_mr() was using ~0UL which is should be ~0ULL.  This causes the
DMA MR to get setup incorrectly in hardware.

- wr_log_show() needed a 64b divide function div64_u64() instead of
  doing
division directly.

- fixed warnings about recasting a pointer to a u64

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c |  2 +-
 drivers/infiniband/hw/cxgb4/cq.c |  6 +++---
 drivers/infiniband/hw/cxgb4/device.c |  6 +++---
 drivers/infiniband/hw/cxgb4/mem.c| 10 +-
 drivers/infiniband/hw/cxgb4/qp.c | 14 +++---
 5 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 6ed5025..636fe84 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -3571,7 +3571,7 @@ static void send_fw_pass_open_req(struct c4iw_dev *dev, 
struct sk_buff *skb,
 * TP will ignore any value  0 for MSS index.
 */
req-tcb.opt0 = cpu_to_be64(MSS_IDX_V(0xF));
-   req-cookie = (unsigned long)skb;
+   req-cookie = (u64)(unsigned long)skb;
 
set_wr_txq(req_skb, CPL_PRIORITY_CONTROL, port_id);
ret = cxgb4_ofld_send(dev-rdev.lldi.ports[0], req_skb);
diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index ab7692a..a0358b1 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -55,7 +55,7 @@ static int destroy_cq(struct c4iw_rdev *rdev, struct t4_cq 
*cq,
FW_RI_RES_WR_NRES_V(1) |
FW_WR_COMPL_F);
res_wr-len16_pkd = cpu_to_be32(DIV_ROUND_UP(wr_len, 16));
-   res_wr-cookie = (unsigned long) wr_wait;
+   res_wr-cookie = (u64)(unsigned long)wr_wait;
res = res_wr-res;
res-u.cq.restype = FW_RI_RES_TYPE_CQ;
res-u.cq.op = FW_RI_RES_OP_RESET;
@@ -125,7 +125,7 @@ static int create_cq(struct c4iw_rdev *rdev, struct t4_cq 
*cq,
FW_RI_RES_WR_NRES_V(1) |
FW_WR_COMPL_F);
res_wr-len16_pkd = cpu_to_be32(DIV_ROUND_UP(wr_len, 16));
-   res_wr-cookie = (unsigned long) wr_wait;
+   res_wr-cookie = (u64)(unsigned long)wr_wait;
res = res_wr-res;
res-u.cq.restype = FW_RI_RES_TYPE_CQ;
res-u.cq.op = FW_RI_RES_OP_WRITE;
@@ -970,7 +970,7 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int 
entries,
}
PDBG(%s cqid 0x%0x chp %p size %u memsize %zu, dma_addr 0x%0llx\n,
 __func__, chp-cq.cqid, chp, chp-cq.size,
-chp-cq.memsize,
+(unsigned long)chp-cq.memsize,
 (unsigned long long) chp-cq.dma_addr);
return chp-ibcq;
 err5:
diff --git a/drivers/infiniband/hw/cxgb4/device.c 
b/drivers/infiniband/hw/cxgb4/device.c
index 8fb295e..5f7bb78 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -151,7 +151,7 @@ static int wr_log_show(struct seq_file *seq, void *v)
int prev_ts_set = 0;
int idx, end;
 
-#define ts2ns(ts) div64_ul((ts) * dev-rdev.lldi.cclk_ps, 1000)
+#define ts2ns(ts) div64_u64((ts) * dev-rdev.lldi.cclk_ps, 1000)
 
idx = atomic_read(dev-rdev.wr_log_idx) 
(dev-rdev.wr_log_size - 1);
@@ -784,10 +784,10 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
 rdev-lldi.vr-qp.size,
 rdev-lldi.vr-cq.start,
 rdev-lldi.vr-cq.size);
-   PDBG(udb len 0x%x udb base %llx db_reg %p gts_reg %p qpshift %lu 
+   PDBG(udb len 0x%x udb base %p db_reg %p gts_reg %p qpshift %lu 
 qpmask 0x%x cqshift %lu cqmask 0x%x\n,
 (unsigned)pci_resource_len(rdev-lldi.pdev, 2),
-(u64)pci_resource_start(rdev-lldi.pdev, 2),
+(void *)(unsigned long)pci_resource_start(rdev-lldi.pdev, 2),
 rdev-lldi.db_reg,
 rdev-lldi.gts_reg,
 rdev-qpshift, rdev-qpmask,
diff --git a/drivers/infiniband/hw/cxgb4/mem.c 
b/drivers/infiniband/hw/cxgb4/mem.c
index 6791fd1..30db971 100644
--- a/drivers/infiniband/hw/cxgb4/mem.c
+++ b/drivers/infiniband/hw/cxgb4/mem.c
@@ -144,7 +144,7 @@ static int _c4iw_write_mem_inline(struct c4iw_rdev *rdev, 
u32 addr, u32 len,
if (i == (num_wqe-1)) {
req-wr.wr_hi = cpu_to_be32(FW_WR_OP_V(FW_ULPTX_WR) |
FW_WR_COMPL_F);
-   req-wr.wr_lo = (__force __be64)(unsigned long) 
wr_wait;
+   req-wr.wr_lo = (__force __be64)(unsigned long)wr_wait;
} else
req-wr.wr_hi = cpu_to_be32(FW_WR_OP_V(FW_ULPTX_WR));
req-wr.wr_mid = cpu_to_be32(
@@ -676,12 +676,12 @@ struct ib_mr *c4iw_get_dma_mr(struct ib_pd *pd, int acc)
mhp-attr.zbva = 0;
mhp-attr.va_fbo = 0;
mhp-attr.page_size = 0;
-   mhp-attr.len

[PATCH for-4.1 3/4] iw_cxgb4: use BAR2 GTS register for T5 kernel mode CQs

2015-04-17 Thread Hariprasad Shenai
For T5, we must not use the kdb/kgts registers, in order avoid db drops
under extreme loads.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cq.c | 15 +++
 drivers/infiniband/hw/cxgb4/t4.h |  7 ---
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index a0358b1..2504bce 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -156,12 +156,19 @@ static int create_cq(struct c4iw_rdev *rdev, struct t4_cq 
*cq,
goto err4;
 
cq-gen = 1;
-   cq-gts = rdev-lldi.gts_reg;
cq-rdev = rdev;
if (user) {
-   cq-ugts = (u64)pci_resource_start(rdev-lldi.pdev, 2) +
-   (cq-cqid  rdev-cqshift);
-   cq-ugts = PAGE_MASK;
+   u32 off = (cq-cqid  rdev-cqshift)  PAGE_MASK;
+
+   cq-ugts = (u64)rdev-bar2_pa + off;
+   } else if (is_t4(rdev-lldi.adapter_type)) {
+   cq-gts = rdev-lldi.gts_reg;
+   cq-qid_mask = -1U;
+   } else {
+   u32 off = ((cq-cqid  rdev-cqshift)  PAGE_MASK) + 12;
+
+   cq-gts = rdev-bar2_kva + off;
+   cq-qid_mask = rdev-qpmask;
}
return 0;
 err4:
diff --git a/drivers/infiniband/hw/cxgb4/t4.h b/drivers/infiniband/hw/cxgb4/t4.h
index 871cdca..0b47f9a 100644
--- a/drivers/infiniband/hw/cxgb4/t4.h
+++ b/drivers/infiniband/hw/cxgb4/t4.h
@@ -539,6 +539,7 @@ struct t4_cq {
size_t memsize;
__be64 bits_type_ts;
u32 cqid;
+   u32 qid_mask;
int vector;
u16 size; /* including status page */
u16 cidx;
@@ -563,12 +564,12 @@ static inline int t4_arm_cq(struct t4_cq *cq, int se)
set_bit(CQ_ARMED, cq-flags);
while (cq-cidx_inc  CIDXINC_M) {
val = SEINTARM_V(0) | CIDXINC_V(CIDXINC_M) | TIMERREG_V(7) |
- INGRESSQID_V(cq-cqid);
+ INGRESSQID_V(cq-cqid  cq-qid_mask);
writel(val, cq-gts);
cq-cidx_inc -= CIDXINC_M;
}
val = SEINTARM_V(se) | CIDXINC_V(cq-cidx_inc) | TIMERREG_V(6) |
- INGRESSQID_V(cq-cqid);
+ INGRESSQID_V(cq-cqid  cq-qid_mask);
writel(val, cq-gts);
cq-cidx_inc = 0;
return 0;
@@ -601,7 +602,7 @@ static inline void t4_hwcq_consume(struct t4_cq *cq)
u32 val;
 
val = SEINTARM_V(0) | CIDXINC_V(cq-cidx_inc) | TIMERREG_V(7) |
- INGRESSQID_V(cq-cqid);
+ INGRESSQID_V(cq-cqid  cq-qid_mask);
writel(val, cq-gts);
cq-cidx_inc = 0;
}
-- 
2.3.4

--
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


[PATCH for-4.1 4/4] iw_cxgb4: enforce qp/cq id requirements

2015-04-17 Thread Hariprasad Shenai
Currently the iw_cxgb4 implementation requires the qp and cq qid densities
to match as well as the qp and cq id ranges.  So fail a device open if
the device configuration doesn't meet the requirements.

The reason for these restictions has to do with the fact that IQ qid X
has a UGTS register in the same bar2 page as EQ qid X.  Thus both qids
need to be allocated to the same user process for security reasons.
The logic that does this (the qpid allocator in iw_cxgb4/resource.c)
handles this but requires the above restrictions.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/device.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/drivers/infiniband/hw/cxgb4/device.c 
b/drivers/infiniband/hw/cxgb4/device.c
index 5f7bb78..f36aa21 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -765,6 +765,29 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
c4iw_init_dev_ucontext(rdev, rdev-uctx);
 
/*
+* This implementation assumes udb_density == ucq_density!  Eventually
+* we might need to support this but for now fail the open. Also the
+* cqid and qpid range must match for now.
+*/
+   if (rdev-lldi.udb_density != rdev-lldi.ucq_density) {
+   pr_err(MOD %s: unsupported udb/ucq densities %u/%u\n,
+  pci_name(rdev-lldi.pdev), rdev-lldi.udb_density,
+  rdev-lldi.ucq_density);
+   err = -EINVAL;
+   goto err1;
+   }
+   if (rdev-lldi.vr-qp.start != rdev-lldi.vr-cq.start ||
+   rdev-lldi.vr-qp.size != rdev-lldi.vr-cq.size) {
+   pr_err(MOD %s: unsupported qp and cq id ranges 
+  qp start %u size %u cq start %u size %u\n,
+  pci_name(rdev-lldi.pdev), rdev-lldi.vr-qp.start,
+  rdev-lldi.vr-qp.size, rdev-lldi.vr-cq.size,
+  rdev-lldi.vr-cq.size);
+   err = -EINVAL;
+   goto err1;
+   }
+
+   /*
 * qpshift is the number of bits to shift the qpid left in order
 * to get the correct address of the doorbell for that qp.
 */
-- 
2.3.4

--
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


[PATCH for-4.1 0/4] Misc. fixes and cleanup for iw_cxgb4

2015-04-17 Thread Hariprasad Shenai
Hi,

This patch series changes a macro definition to be consistent with other
register macro defines. Fixes for 32b platform, use BAR2 register for kernel
mode CQ's and enforces qp/cq id requirements.

The patches series is created against github for-4.1 branch.
And includes patches on iw_cxgb4 driver.

We have included all the maintainers of respective drivers. Kindly review the
change and let us know in case of any review comments.

Thanks

Hariprasad Shenai (4):
  iw_cxgb4: Cleanup register defines/MACROS
  iw_cxgb4: 32b platform fixes
  iw_cxgb4: use BAR2 GTS register for T5 kernel mode CQs
  iw_cxgb4: enforce qp/cq id requirements

 drivers/infiniband/hw/cxgb4/cm.c  |  6 +++---
 drivers/infiniband/hw/cxgb4/cq.c  | 21 ++---
 drivers/infiniband/hw/cxgb4/device.c  | 29 ++---
 drivers/infiniband/hw/cxgb4/mem.c | 10 +-
 drivers/infiniband/hw/cxgb4/qp.c  | 14 +++---
 drivers/infiniband/hw/cxgb4/t4.h  |  7 ---
 drivers/infiniband/hw/cxgb4/t4fw_ri_api.h |  4 +++-
 7 files changed, 62 insertions(+), 29 deletions(-)

-- 
2.3.4

--
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


[PATCH for-4.1 1/4] iw_cxgb4: Cleanup register defines/MACROS

2015-04-17 Thread Hariprasad Shenai
Cleanup macros and register defines for consistency

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c  | 4 ++--
 drivers/infiniband/hw/cxgb4/t4fw_ri_api.h | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 57176dd..6ed5025 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -675,7 +675,7 @@ static int send_connect(struct c4iw_ep *ep)
if (is_t5(ep-com.dev-rdev.lldi.adapter_type)) {
opt2 |= T5_OPT_2_VALID_F;
opt2 |= CONG_CNTRL_V(CONG_ALG_TAHOE);
-   opt2 |= CONG_CNTRL_VALID; /* OPT_2_ISS for T5 */
+   opt2 |= T5_ISS_F;
}
t4_set_arp_err_handler(skb, ep, act_open_req_arp_failure);
 
@@ -2214,7 +2214,7 @@ static void accept_cr(struct c4iw_ep *ep, struct sk_buff 
*skb,
u32 isn = (prandom_u32()  ~7UL) - 1;
opt2 |= T5_OPT_2_VALID_F;
opt2 |= CONG_CNTRL_V(CONG_ALG_TAHOE);
-   opt2 |= CONG_CNTRL_VALID; /* OPT_2_ISS for T5 */
+   opt2 |= T5_ISS_F;
rpl5 = (void *)rpl;
memset(rpl5-iss, 0, roundup(sizeof(*rpl5)-sizeof(*rpl), 16));
if (peer2peer)
diff --git a/drivers/infiniband/hw/cxgb4/t4fw_ri_api.h 
b/drivers/infiniband/hw/cxgb4/t4fw_ri_api.h
index 5e53327..343e8daf 100644
--- a/drivers/infiniband/hw/cxgb4/t4fw_ri_api.h
+++ b/drivers/infiniband/hw/cxgb4/t4fw_ri_api.h
@@ -848,6 +848,8 @@ enum { /* TCP congestion control 
algorithms */
 #define CONG_CNTRL_V(x) ((x)  CONG_CNTRL_S)
 #define CONG_CNTRL_G(x) (((x)  CONG_CNTRL_S)  CONG_CNTRL_M)
 
-#define CONG_CNTRL_VALID   (1  18)
+#define T5_ISS_S18
+#define T5_ISS_V(x) ((x)  T5_ISS_S)
+#define T5_ISS_FT5_ISS_V(1U)
 
 #endif /* _T4FW_RI_API_H_ */
-- 
2.3.4

--
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


[PATCH for-next 2/4] iw_cxgb4: 32b platform fixes

2015-03-19 Thread Hariprasad Shenai
- get_dma_mr() was using ~0UL which is should be ~0ULL.  This causes the
DMA MR to get setup incorrectly in hardware.

- wr_log_show() needed a 64b divide function div64_u64() instead of doing
division directly.

- fixed warnings about recasting a pointer to a u64

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c |2 +-
 drivers/infiniband/hw/cxgb4/cq.c |6 +++---
 drivers/infiniband/hw/cxgb4/device.c |6 +++---
 drivers/infiniband/hw/cxgb4/mem.c|   10 +-
 drivers/infiniband/hw/cxgb4/qp.c |   14 +++---
 5 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 85167dc..7dbff7a 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -3578,7 +3578,7 @@ static void send_fw_pass_open_req(struct c4iw_dev *dev, 
struct sk_buff *skb,
 * TP will ignore any value  0 for MSS index.
 */
req-tcb.opt0 = cpu_to_be64(MSS_IDX_V(0xF));
-   req-cookie = (unsigned long)skb;
+   req-cookie = (u64)(unsigned long)skb;
 
set_wr_txq(req_skb, CPL_PRIORITY_CONTROL, port_id);
ret = cxgb4_ofld_send(dev-rdev.lldi.ports[0], req_skb);
diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index e9fd3a0..aed2b6b 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -55,7 +55,7 @@ static int destroy_cq(struct c4iw_rdev *rdev, struct t4_cq 
*cq,
V_FW_RI_RES_WR_NRES(1) |
FW_WR_COMPL_F);
res_wr-len16_pkd = cpu_to_be32(DIV_ROUND_UP(wr_len, 16));
-   res_wr-cookie = (unsigned long) wr_wait;
+   res_wr-cookie = (u64)(unsigned long)wr_wait;
res = res_wr-res;
res-u.cq.restype = FW_RI_RES_TYPE_CQ;
res-u.cq.op = FW_RI_RES_OP_RESET;
@@ -125,7 +125,7 @@ static int create_cq(struct c4iw_rdev *rdev, struct t4_cq 
*cq,
V_FW_RI_RES_WR_NRES(1) |
FW_WR_COMPL_F);
res_wr-len16_pkd = cpu_to_be32(DIV_ROUND_UP(wr_len, 16));
-   res_wr-cookie = (unsigned long) wr_wait;
+   res_wr-cookie = (u64)(unsigned long)wr_wait;
res = res_wr-res;
res-u.cq.restype = FW_RI_RES_TYPE_CQ;
res-u.cq.op = FW_RI_RES_OP_WRITE;
@@ -970,7 +970,7 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int 
entries,
}
PDBG(%s cqid 0x%0x chp %p size %u memsize %zu, dma_addr 0x%0llx\n,
 __func__, chp-cq.cqid, chp, chp-cq.size,
-chp-cq.memsize,
+(unsigned long)chp-cq.memsize,
 (unsigned long long) chp-cq.dma_addr);
return chp-ibcq;
 err5:
diff --git a/drivers/infiniband/hw/cxgb4/device.c 
b/drivers/infiniband/hw/cxgb4/device.c
index 78ed883..3fbd53d 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -151,7 +151,7 @@ static int wr_log_show(struct seq_file *seq, void *v)
int prev_ts_set = 0;
int idx, end;
 
-#define ts2ns(ts) div64_ul((ts) * dev-rdev.lldi.cclk_ps, 1000)
+#define ts2ns(ts) div64_u64((ts) * dev-rdev.lldi.cclk_ps, 1000)
 
idx = atomic_read(dev-rdev.wr_log_idx) 
(dev-rdev.wr_log_size - 1);
@@ -804,10 +804,10 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
 rdev-lldi.vr-qp.size,
 rdev-lldi.vr-cq.start,
 rdev-lldi.vr-cq.size);
-   PDBG(udb len 0x%x udb base %llx db_reg %p gts_reg %p qpshift %lu 
+   PDBG(udb len 0x%x udb base %p db_reg %p gts_reg %p qpshift %lu 
 qpmask 0x%x cqshift %lu cqmask 0x%x\n,
 (unsigned)pci_resource_len(rdev-lldi.pdev, 2),
-(u64)pci_resource_start(rdev-lldi.pdev, 2),
+(void *)(unsigned long)pci_resource_start(rdev-lldi.pdev, 2),
 rdev-lldi.db_reg,
 rdev-lldi.gts_reg,
 rdev-qpshift, rdev-qpmask,
diff --git a/drivers/infiniband/hw/cxgb4/mem.c 
b/drivers/infiniband/hw/cxgb4/mem.c
index cb43c22..eca41a3 100644
--- a/drivers/infiniband/hw/cxgb4/mem.c
+++ b/drivers/infiniband/hw/cxgb4/mem.c
@@ -144,7 +144,7 @@ static int _c4iw_write_mem_inline(struct c4iw_rdev *rdev, 
u32 addr, u32 len,
if (i == (num_wqe-1)) {
req-wr.wr_hi = cpu_to_be32(FW_WR_OP_V(FW_ULPTX_WR) |
FW_WR_COMPL_F);
-   req-wr.wr_lo = (__force __be64)(unsigned long) 
wr_wait;
+   req-wr.wr_lo = (__force __be64)(unsigned long)wr_wait;
} else
req-wr.wr_hi = cpu_to_be32(FW_WR_OP_V(FW_ULPTX_WR));
req-wr.wr_mid = cpu_to_be32(
@@ -676,12 +676,12 @@ struct ib_mr *c4iw_get_dma_mr(struct ib_pd *pd, int acc)
mhp-attr.zbva = 0;
mhp-attr.va_fbo = 0;
mhp-attr.page_size = 0;
-   mhp

[PATCH for-next 1/4] iw_cxgb4: Cleanup register defines/MACROS

2015-03-19 Thread Hariprasad Shenai
Cleanup macros and register defines for consistency

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c  |4 ++--
 drivers/infiniband/hw/cxgb4/t4fw_ri_api.h |4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 743b805..85167dc 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -675,7 +675,7 @@ static int send_connect(struct c4iw_ep *ep)
if (is_t5(ep-com.dev-rdev.lldi.adapter_type)) {
opt2 |= T5_OPT_2_VALID_F;
opt2 |= V_CONG_CNTRL(CONG_ALG_TAHOE);
-   opt2 |= CONG_CNTRL_VALID; /* OPT_2_ISS for T5 */
+   opt2 |= T5_ISS_F;
}
t4_set_arp_err_handler(skb, ep, act_open_req_arp_failure);
 
@@ -2217,7 +2217,7 @@ static void accept_cr(struct c4iw_ep *ep, struct sk_buff 
*skb,
u32 isn = (prandom_u32()  ~7UL) - 1;
opt2 |= T5_OPT_2_VALID_F;
opt2 |= V_CONG_CNTRL(CONG_ALG_TAHOE);
-   opt2 |= CONG_CNTRL_VALID; /* OPT_2_ISS for T5 */
+   opt2 |= T5_ISS_F;
rpl5 = (void *)rpl;
memset(rpl5-iss, 0, roundup(sizeof(*rpl5)-sizeof(*rpl), 16));
if (peer2peer)
diff --git a/drivers/infiniband/hw/cxgb4/t4fw_ri_api.h 
b/drivers/infiniband/hw/cxgb4/t4fw_ri_api.h
index 5709e77..fe29e87 100644
--- a/drivers/infiniband/hw/cxgb4/t4fw_ri_api.h
+++ b/drivers/infiniband/hw/cxgb4/t4fw_ri_api.h
@@ -848,6 +848,8 @@ enum { /* TCP congestion control 
algorithms */
 #define V_CONG_CNTRL(x) ((x)  S_CONG_CNTRL)
 #define G_CONG_CNTRL(x) (((x)  S_CONG_CNTRL)  M_CONG_CNTRL)
 
-#define CONG_CNTRL_VALID   (1  18)
+#define T5_ISS_S18
+#define T5_ISS_V(x) ((x)  T5_ISS_S)
+#define T5_ISS_FT5_ISS_V(1U)
 
 #endif /* _T4FW_RI_API_H_ */
-- 
1.7.1

--
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


[PATCH for-next 3/4] iw_cxgb4: use BAR2 GTS register for T5 kernel mode CQs

2015-03-19 Thread Hariprasad Shenai
For T5, we must not use the kdb/kgts registers, in order avoid db drops
under extreme loads.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cq.c |   15 +++
 drivers/infiniband/hw/cxgb4/t4.h |7 ---
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index aed2b6b..646caf9 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -156,12 +156,19 @@ static int create_cq(struct c4iw_rdev *rdev, struct t4_cq 
*cq,
goto err4;
 
cq-gen = 1;
-   cq-gts = rdev-lldi.gts_reg;
cq-rdev = rdev;
if (user) {
-   cq-ugts = (u64)pci_resource_start(rdev-lldi.pdev, 2) +
-   (cq-cqid  rdev-cqshift);
-   cq-ugts = PAGE_MASK;
+   u32 off = (cq-cqid  rdev-cqshift)  PAGE_MASK;
+
+   cq-ugts = (u64)rdev-bar2_pa + off;
+   } else if (is_t4(rdev-lldi.adapter_type)) {
+   cq-gts = rdev-lldi.gts_reg;
+   cq-qid_mask = -1U;
+   } else {
+   u32 off = ((cq-cqid  rdev-cqshift)  PAGE_MASK) + 12;
+
+   cq-gts = rdev-bar2_kva + off;
+   cq-qid_mask = rdev-qpmask;
}
return 0;
 err4:
diff --git a/drivers/infiniband/hw/cxgb4/t4.h b/drivers/infiniband/hw/cxgb4/t4.h
index c04e513..97f90e4 100644
--- a/drivers/infiniband/hw/cxgb4/t4.h
+++ b/drivers/infiniband/hw/cxgb4/t4.h
@@ -539,6 +539,7 @@ struct t4_cq {
size_t memsize;
__be64 bits_type_ts;
u32 cqid;
+   u32 qid_mask;
int vector;
u16 size; /* including status page */
u16 cidx;
@@ -563,12 +564,12 @@ static inline int t4_arm_cq(struct t4_cq *cq, int se)
set_bit(CQ_ARMED, cq-flags);
while (cq-cidx_inc  CIDXINC_MASK) {
val = SEINTARM(0) | CIDXINC(CIDXINC_MASK) | TIMERREG(7) |
- INGRESSQID(cq-cqid);
+ INGRESSQID(cq-cqid  cq-qid_mask);
writel(val, cq-gts);
cq-cidx_inc -= CIDXINC_MASK;
}
val = SEINTARM(se) | CIDXINC(cq-cidx_inc) | TIMERREG(6) |
- INGRESSQID(cq-cqid);
+ INGRESSQID(cq-cqid  cq-qid_mask);
writel(val, cq-gts);
cq-cidx_inc = 0;
return 0;
@@ -601,7 +602,7 @@ static inline void t4_hwcq_consume(struct t4_cq *cq)
u32 val;
 
val = SEINTARM(0) | CIDXINC(cq-cidx_inc) | TIMERREG(7) |
- INGRESSQID(cq-cqid);
+ INGRESSQID(cq-cqid  cq-qid_mask);
writel(val, cq-gts);
cq-cidx_inc = 0;
}
-- 
1.7.1

--
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


[PATCH for-next 0/4] Misc. fixes and cleanup for iw_cxgb4

2015-03-19 Thread Hariprasad Shenai
Hi,

This patch series changes a macro definition to be consistent with other
register macro defines. Fixes for 32b platform, use BAR2 register for kernel
mode CQ's and enforces qp/cq id requirements.

The patches series is created against 'infiniband' tree for-next branch.
And includes patches on iw_cxgb4 driver.

We have included all the maintainers of respective drivers. Kindly review the
change and let us know in case of any review comments.

Thanks

Hariprasad Shenai (4):
  iw_cxgb4: Cleanup register defines/MACROS
  iw_cxgb4: 32b platform fixes
  iw_cxgb4: use BAR2 GTS register for T5 kernel mode CQs
  iw_cxgb4: enforce qp/cq id requirements

 drivers/infiniband/hw/cxgb4/cm.c  |6 +++---
 drivers/infiniband/hw/cxgb4/cq.c  |   21 ++---
 drivers/infiniband/hw/cxgb4/device.c  |   29 ++---
 drivers/infiniband/hw/cxgb4/mem.c |   10 +-
 drivers/infiniband/hw/cxgb4/qp.c  |   14 +++---
 drivers/infiniband/hw/cxgb4/t4.h  |7 ---
 drivers/infiniband/hw/cxgb4/t4fw_ri_api.h |4 +++-
 7 files changed, 62 insertions(+), 29 deletions(-)

--
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


[PATCH for-next 4/4] iw_cxgb4: enforce qp/cq id requirements

2015-03-19 Thread Hariprasad Shenai
Currently the iw_cxgb4 implementation requires the qp and cq qid densities
to match as well as the qp and cq id ranges.  So fail a device open if
the device configuration doesn't meet the requirements.

The reason for these restictions has to do with the fact that IQ qid X
has a UGTS register in the same bar2 page as EQ qid X.  Thus both qids
need to be allocated to the same user process for security reasons.
The logic that does this (the qpid allocator in iw_cxgb4/resource.c)
handles this but requires the above restrictions.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/device.c |   23 +++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/device.c 
b/drivers/infiniband/hw/cxgb4/device.c
index 3fbd53d..ecb8ff2 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -785,6 +785,29 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
c4iw_init_dev_ucontext(rdev, rdev-uctx);
 
/*
+* This implementation assumes udb_density == ucq_density!  Eventually
+* we might need to support this but for now fail the open. Also the
+* cqid and qpid range must match for now.
+*/
+   if (rdev-lldi.udb_density != rdev-lldi.ucq_density) {
+   pr_err(MOD %s: unsupported udb/ucq densities %u/%u\n,
+  pci_name(rdev-lldi.pdev), rdev-lldi.udb_density,
+  rdev-lldi.ucq_density);
+   err = -EINVAL;
+   goto err1;
+   }
+   if (rdev-lldi.vr-qp.start != rdev-lldi.vr-cq.start ||
+   rdev-lldi.vr-qp.size != rdev-lldi.vr-cq.size) {
+   pr_err(MOD %s: unsupported qp and cq id ranges 
+  qp start %u size %u cq start %u size %u\n,
+  pci_name(rdev-lldi.pdev), rdev-lldi.vr-qp.start,
+  rdev-lldi.vr-qp.size, rdev-lldi.vr-cq.size,
+  rdev-lldi.vr-cq.size);
+   err = -EINVAL;
+   goto err1;
+   }
+
+   /*
 * qpshift is the number of bits to shift the qpid left in order
 * to get the correct address of the doorbell for that qp.
 */
-- 
1.7.1

--
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


[PATCH for-next] iw_cxgb4: Remove negative advice dmesg warnings

2015-03-10 Thread Hariprasad Shenai
Remove these log messages in favor of per-endpoint counters as well as
device-global counters that can be inspected via debugfs.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c   |   27 ++-
 drivers/infiniband/hw/cxgb4/device.c   |7 +++
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h |7 +++
 3 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 9edc200..743b805 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -2042,9 +2042,12 @@ static int act_open_rpl(struct c4iw_dev *dev, struct 
sk_buff *skb)
 status, status2errno(status));
 
if (is_neg_adv(status)) {
-   dev_warn(dev-rdev.lldi.pdev-dev,
-Connection problems for atid %u status %u (%s)\n,
-atid, status, neg_adv_str(status));
+   PDBG(%s Connection problems for atid %u status %u (%s)\n,
+  __func__, atid, status, neg_adv_str(status));
+   ep-stats.connect_neg_adv++;
+   mutex_lock(dev-rdev.stats.lock);
+   dev-rdev.stats.neg_adv++;
+   mutex_unlock(dev-rdev.stats.lock);
return 0;
}
 
@@ -2520,9 +2523,13 @@ static int peer_abort(struct c4iw_dev *dev, struct 
sk_buff *skb)
 
ep = lookup_tid(t, tid);
if (is_neg_adv(req-status)) {
-   dev_warn(dev-rdev.lldi.pdev-dev,
-Negative advice on abort - tid %u status %d (%s)\n,
-ep-hwtid, req-status, neg_adv_str(req-status));
+   PDBG(%s Negative advice on abort- tid %u status %d (%s)\n,
+__func__, ep-hwtid, req-status,
+neg_adv_str(req-status));
+   ep-stats.abort_neg_adv++;
+   mutex_lock(dev-rdev.stats.lock);
+   dev-rdev.stats.neg_adv++;
+   mutex_unlock(dev-rdev.stats.lock);
return 0;
}
PDBG(%s ep %p tid %u state %u\n, __func__, ep, ep-hwtid,
@@ -3931,9 +3938,11 @@ static int peer_abort_intr(struct c4iw_dev *dev, struct 
sk_buff *skb)
return 0;
}
if (is_neg_adv(req-status)) {
-   dev_warn(dev-rdev.lldi.pdev-dev,
-Negative advice on abort - tid %u status %d (%s)\n,
-ep-hwtid, req-status, neg_adv_str(req-status));
+   PDBG(%s Negative advice on abort- tid %u status %d (%s)\n,
+__func__, ep-hwtid, req-status,
+neg_adv_str(req-status));
+   ep-stats.abort_neg_adv++;
+   dev-rdev.stats.neg_adv++;
kfree_skb(skb);
return 0;
}
diff --git a/drivers/infiniband/hw/cxgb4/device.c 
b/drivers/infiniband/hw/cxgb4/device.c
index eb5df4e..78ed883 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -489,6 +489,7 @@ static int stats_show(struct seq_file *seq, void *v)
   dev-rdev.stats.act_ofld_conn_fails);
seq_printf(seq, PAS_OFLD_CONN_FAILS: %10llu\n,
   dev-rdev.stats.pas_ofld_conn_fails);
+   seq_printf(seq, NEG_ADV_RCVD: %10llu\n, dev-rdev.stats.neg_adv);
seq_printf(seq, AVAILABLE IRD: %10u\n, dev-avail_ird);
return 0;
 }
@@ -560,10 +561,13 @@ static int dump_ep(int id, void *p, void *data)
cc = snprintf(epd-buf + epd-pos, space,
  ep %p cm_id %p qp %p state %d flags 0x%lx 
  history 0x%lx hwtid %d atid %d 
+ conn_na %u abort_na %u 
  %pI4:%d/%d - %pI4:%d/%d\n,
  ep, ep-com.cm_id, ep-com.qp,
  (int)ep-com.state, ep-com.flags,
  ep-com.history, ep-hwtid, ep-atid,
+ ep-stats.connect_neg_adv,
+ ep-stats.abort_neg_adv,
  lsin-sin_addr, ntohs(lsin-sin_port),
  ntohs(mapped_lsin-sin_port),
  rsin-sin_addr, ntohs(rsin-sin_port),
@@ -581,10 +585,13 @@ static int dump_ep(int id, void *p, void *data)
cc = snprintf(epd-buf + epd-pos, space,
  ep %p cm_id %p qp %p state %d flags 0x%lx 
  history 0x%lx hwtid %d atid %d 
+ conn_na %u abort_na %u 
  %pI6:%d/%d - %pI6:%d/%d\n,
  ep, ep-com.cm_id, ep-com.qp,
  (int)ep-com.state, ep-com.flags,
  ep-com.history, ep-hwtid, ep-atid,
+ ep-stats.connect_neg_adv

[PATCH for-next 2/2] iw_cxgb4: Cleanup register defines/MACROS defined in t4fw_ri_api.h

2015-01-15 Thread Hariprasad Shenai
Cleanup all the MACROS that are defined in t4fw_ri_api.h and affected files

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c  |   30 +-
 drivers/infiniband/hw/cxgb4/cq.c  |   22 +-
 drivers/infiniband/hw/cxgb4/device.c  |   12 +-
 drivers/infiniband/hw/cxgb4/ev.c  |   12 +-
 drivers/infiniband/hw/cxgb4/mem.c |   18 +-
 drivers/infiniband/hw/cxgb4/qp.c  |   60 ++--
 drivers/infiniband/hw/cxgb4/t4fw_ri_api.h |  812 ++--
 7 files changed, 483 insertions(+), 483 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 694e030..57176dd 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -674,7 +674,7 @@ static int send_connect(struct c4iw_ep *ep)
opt2 |= WND_SCALE_EN_F;
if (is_t5(ep-com.dev-rdev.lldi.adapter_type)) {
opt2 |= T5_OPT_2_VALID_F;
-   opt2 |= V_CONG_CNTRL(CONG_ALG_TAHOE);
+   opt2 |= CONG_CNTRL_V(CONG_ALG_TAHOE);
opt2 |= CONG_CNTRL_VALID; /* OPT_2_ISS for T5 */
}
t4_set_arp_err_handler(skb, ep, act_open_req_arp_failure);
@@ -1258,8 +1258,8 @@ static int update_rx_credits(struct c4iw_ep *ep, u32 
credits)
OPCODE_TID(req) = cpu_to_be32(MK_OPCODE_TID(CPL_RX_DATA_ACK,
ep-hwtid));
req-credit_dack = cpu_to_be32(credits | RX_FORCE_ACK_F |
-  F_RX_DACK_CHANGE |
-  V_RX_DACK_MODE(dack_mode));
+  RX_DACK_CHANGE_F |
+  RX_DACK_MODE_V(dack_mode));
set_wr_txq(skb, CPL_PRIORITY_ACK, ep-ctrlq_idx);
c4iw_ofld_send(ep-com.dev-rdev, skb);
return credits;
@@ -2205,15 +2205,15 @@ static void accept_cr(struct c4iw_ep *ep, struct 
sk_buff *skb,
const struct tcphdr *tcph;
u32 hlen = ntohl(req-hdr_len);
 
-   tcph = (const void *)(req + 1) + G_ETH_HDR_LEN(hlen) +
-   G_IP_HDR_LEN(hlen);
+   tcph = (const void *)(req + 1) + ETH_HDR_LEN_G(hlen) +
+   IP_HDR_LEN_G(hlen);
if (tcph-ece  tcph-cwr)
opt2 |= CCTRL_ECN_V(1);
}
if (is_t5(ep-com.dev-rdev.lldi.adapter_type)) {
u32 isn = (prandom_u32()  ~7UL) - 1;
opt2 |= T5_OPT_2_VALID_F;
-   opt2 |= V_CONG_CNTRL(CONG_ALG_TAHOE);
+   opt2 |= CONG_CNTRL_V(CONG_ALG_TAHOE);
opt2 |= CONG_CNTRL_VALID; /* OPT_2_ISS for T5 */
rpl5 = (void *)rpl;
memset(rpl5-iss, 0, roundup(sizeof(*rpl5)-sizeof(*rpl), 16));
@@ -2245,8 +2245,8 @@ static void get_4tuple(struct cpl_pass_accept_req *req, 
int *iptype,
   __u8 *local_ip, __u8 *peer_ip,
   __be16 *local_port, __be16 *peer_port)
 {
-   int eth_len = G_ETH_HDR_LEN(be32_to_cpu(req-hdr_len));
-   int ip_len = G_IP_HDR_LEN(be32_to_cpu(req-hdr_len));
+   int eth_len = ETH_HDR_LEN_G(be32_to_cpu(req-hdr_len));
+   int ip_len = IP_HDR_LEN_G(be32_to_cpu(req-hdr_len));
struct iphdr *ip = (struct iphdr *)((u8 *)(req + 1) + eth_len);
struct ipv6hdr *ip6 = (struct ipv6hdr *)((u8 *)(req + 1) + eth_len);
struct tcphdr *tcp = (struct tcphdr *)
@@ -3500,20 +3500,20 @@ static void build_cpl_pass_accept_req(struct sk_buff 
*skb, int stid , u8 tos)
 
req = (struct cpl_pass_accept_req *)__skb_push(skb, sizeof(*req));
memset(req, 0, sizeof(*req));
-   req-l2info = cpu_to_be16(V_SYN_INTF(intf) |
-V_SYN_MAC_IDX(RX_MACIDX_G(
+   req-l2info = cpu_to_be16(SYN_INTF_V(intf) |
+SYN_MAC_IDX_V(RX_MACIDX_G(
 (__force int) htonl(l2info))) |
-F_SYN_XACT_MATCH);
+SYN_XACT_MATCH_F);
eth_hdr_len = is_t4(dev-rdev.lldi.adapter_type) ?
RX_ETHHDR_LEN_G((__force int)htonl(l2info)) :
RX_T5_ETHHDR_LEN_G((__force int)htonl(l2info));
-   req-hdr_len = cpu_to_be32(V_SYN_RX_CHAN(RX_CHAN_G(
+   req-hdr_len = cpu_to_be32(SYN_RX_CHAN_V(RX_CHAN_G(
(__force int) htonl(l2info))) |
-  V_TCP_HDR_LEN(RX_TCPHDR_LEN_G(
+  TCP_HDR_LEN_V(RX_TCPHDR_LEN_G(
(__force int) htons(hdr_len))) |
-  V_IP_HDR_LEN(RX_IPHDR_LEN_G(
+  IP_HDR_LEN_V(RX_IPHDR_LEN_G(
(__force int) htons(hdr_len))) |
-  V_ETH_HDR_LEN(RX_ETHHDR_LEN_G(eth_hdr_len)));
+  ETH_HDR_LEN_V

[PATCH for-next 0/2] Refactor macros to conform to uniform standards

2015-01-15 Thread Hariprasad Shenai
Hi,

This patch series cleansup macros/register defines, defined in t4.h and
t4fw_ri_api.h and all the affected files.

This patch series is created against net-next tree and includes patches on
iw_cxgb4 tree. Since the patches are dependent on previous cleanup patched we
would line to get this series merged through net-next tree.

We have included all the maintainers of respective drivers. Kindly review the
change and let us know in case of any review comments.

Thanks

Hariprasad Shenai (2):
  iw_cxgb4: Cleanup register defines/MACROS defined in t4.h
  iw_cxgb4: Cleanup register defines/MACROS defined in t4fw_ri_api.h

 drivers/infiniband/hw/cxgb4/cm.c  |   30 +-
 drivers/infiniband/hw/cxgb4/cq.c  |   60 ++--
 drivers/infiniband/hw/cxgb4/device.c  |   12 +-
 drivers/infiniband/hw/cxgb4/ev.c  |   12 +-
 drivers/infiniband/hw/cxgb4/mem.c |   18 +-
 drivers/infiniband/hw/cxgb4/qp.c  |   62 ++--
 drivers/infiniband/hw/cxgb4/t4.h  |   90 ++--
 drivers/infiniband/hw/cxgb4/t4fw_ri_api.h |  812 ++--
 8 files changed, 548 insertions(+), 548 deletions(-)

--
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


[PATCH for-next 1/2] iw_cxgb4: Cleanup register defines/MACROS defined in t4.h

2015-01-15 Thread Hariprasad Shenai
Cleanup all the MACROS defined in t4.h and the affected files

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cq.c |   38 
 drivers/infiniband/hw/cxgb4/qp.c |2 +-
 drivers/infiniband/hw/cxgb4/t4.h |   90 +++---
 3 files changed, 65 insertions(+), 65 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index e9fd3a0..39b0da3 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -182,12 +182,12 @@ static void insert_recv_cqe(struct t4_wq *wq, struct 
t4_cq *cq)
PDBG(%s wq %p cq %p sw_cidx %u sw_pidx %u\n, __func__,
 wq, cq, cq-sw_cidx, cq-sw_pidx);
memset(cqe, 0, sizeof(cqe));
-   cqe.header = cpu_to_be32(V_CQE_STATUS(T4_ERR_SWFLUSH) |
-V_CQE_OPCODE(FW_RI_SEND) |
-V_CQE_TYPE(0) |
-V_CQE_SWCQE(1) |
-V_CQE_QPID(wq-sq.qid));
-   cqe.bits_type_ts = cpu_to_be64(V_CQE_GENBIT((u64)cq-gen));
+   cqe.header = cpu_to_be32(CQE_STATUS_V(T4_ERR_SWFLUSH) |
+CQE_OPCODE_V(FW_RI_SEND) |
+CQE_TYPE_V(0) |
+CQE_SWCQE_V(1) |
+CQE_QPID_V(wq-sq.qid));
+   cqe.bits_type_ts = cpu_to_be64(CQE_GENBIT_V((u64)cq-gen));
cq-sw_queue[cq-sw_pidx] = cqe;
t4_swcq_produce(cq);
 }
@@ -215,13 +215,13 @@ static void insert_sq_cqe(struct t4_wq *wq, struct t4_cq 
*cq,
PDBG(%s wq %p cq %p sw_cidx %u sw_pidx %u\n, __func__,
 wq, cq, cq-sw_cidx, cq-sw_pidx);
memset(cqe, 0, sizeof(cqe));
-   cqe.header = cpu_to_be32(V_CQE_STATUS(T4_ERR_SWFLUSH) |
-V_CQE_OPCODE(swcqe-opcode) |
-V_CQE_TYPE(1) |
-V_CQE_SWCQE(1) |
-V_CQE_QPID(wq-sq.qid));
+   cqe.header = cpu_to_be32(CQE_STATUS_V(T4_ERR_SWFLUSH) |
+CQE_OPCODE_V(swcqe-opcode) |
+CQE_TYPE_V(1) |
+CQE_SWCQE_V(1) |
+CQE_QPID_V(wq-sq.qid));
CQE_WRID_SQ_IDX(cqe) = swcqe-idx;
-   cqe.bits_type_ts = cpu_to_be64(V_CQE_GENBIT((u64)cq-gen));
+   cqe.bits_type_ts = cpu_to_be64(CQE_GENBIT_V((u64)cq-gen));
cq-sw_queue[cq-sw_pidx] = cqe;
t4_swcq_produce(cq);
 }
@@ -284,7 +284,7 @@ static void flush_completed_wrs(struct t4_wq *wq, struct 
t4_cq *cq)
 */
PDBG(%s moving cqe into swcq sq idx %u cq idx %u\n,
__func__, cidx, cq-sw_pidx);
-   swsqe-cqe.header |= htonl(V_CQE_SWCQE(1));
+   swsqe-cqe.header |= htonl(CQE_SWCQE_V(1));
cq-sw_queue[cq-sw_pidx] = swsqe-cqe;
t4_swcq_produce(cq);
swsqe-flushed = 1;
@@ -301,10 +301,10 @@ static void create_read_req_cqe(struct t4_wq *wq, struct 
t4_cqe *hw_cqe,
 {
read_cqe-u.scqe.cidx = wq-sq.oldest_read-idx;
read_cqe-len = htonl(wq-sq.oldest_read-read_len);
-   read_cqe-header = htonl(V_CQE_QPID(CQE_QPID(hw_cqe)) |
-   V_CQE_SWCQE(SW_CQE(hw_cqe)) |
-   V_CQE_OPCODE(FW_RI_READ_REQ) |
-   V_CQE_TYPE(1));
+   read_cqe-header = htonl(CQE_QPID_V(CQE_QPID(hw_cqe)) |
+   CQE_SWCQE_V(SW_CQE(hw_cqe)) |
+   CQE_OPCODE_V(FW_RI_READ_REQ) |
+   CQE_TYPE_V(1));
read_cqe-bits_type_ts = hw_cqe-bits_type_ts;
 }
 
@@ -400,7 +400,7 @@ void c4iw_flush_hw_cq(struct c4iw_cq *chp)
} else {
swcqe = chp-cq.sw_queue[chp-cq.sw_pidx];
*swcqe = *hw_cqe;
-   swcqe-header |= cpu_to_be32(V_CQE_SWCQE(1));
+   swcqe-header |= cpu_to_be32(CQE_SWCQE_V(1));
t4_swcq_produce(chp-cq);
}
 next_cqe:
@@ -576,7 +576,7 @@ static int poll_cq(struct t4_wq *wq, struct t4_cq *cq, 
struct t4_cqe *cqe,
}
if (unlikely((CQE_WRID_MSN(hw_cqe) != (wq-rq.msn {
t4_set_wq_in_error(wq);
-   hw_cqe-header |= htonl(V_CQE_STATUS(T4_ERR_MSN));
+   hw_cqe-header |= htonl(CQE_STATUS_V(T4_ERR_MSN));
goto proc_cqe;
}
goto proc_cqe;
diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
index bb85d47..42238ed 100644
--- a/drivers/infiniband/hw/cxgb4/qp.c
+++ b/drivers/infiniband/hw/cxgb4/qp.c
@@ -1776,7 +1776,7 @@ struct ib_qp *c4iw_create_qp(struct ib_pd *pd, struct 
ib_qp_init_attr *attrs

[PATCH net-next 2/5] cxgb4/cxgb4vf/csiostor: Cleanup SGE and PCI related register defines

2015-01-05 Thread Hariprasad Shenai
This patch cleansup remaining SGE related macros/register defines and all PCI
related ones that are defined in t4_regs.h and the affected files.

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|   68 ++--
 drivers/net/ethernet/chelsio/cxgb4/sge.c   |   78 ++--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |  224 
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h   |  605 ++--
 drivers/net/ethernet/chelsio/cxgb4/t4_values.h |4 +
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c|   12 +-
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c |6 +-
 drivers/scsi/csiostor/csio_hw.c|   33 +-
 drivers/scsi/csiostor/csio_hw_chip.h   |4 +-
 drivers/scsi/csiostor/csio_hw_t4.c |  112 ++--
 drivers/scsi/csiostor/csio_hw_t5.c |  114 ++--
 drivers/scsi/csiostor/csio_isr.c   |2 +-
 drivers/scsi/csiostor/csio_wr.c|   36 +-
 13 files changed, 766 insertions(+), 532 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 5e0d57a..16c633f 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -1590,9 +1590,9 @@ static void get_stats(struct net_device *dev, struct 
ethtool_stats *stats,
collect_sge_port_stats(adapter, pi, (struct queue_port_stats *)data);
data += sizeof(struct queue_port_stats) / sizeof(u64);
if (!is_t4(adapter-params.chip)) {
-   t4_write_reg(adapter, SGE_STAT_CFG, STATSOURCE_T5(7));
-   val1 = t4_read_reg(adapter, SGE_STAT_TOTAL);
-   val2 = t4_read_reg(adapter, SGE_STAT_MATCH);
+   t4_write_reg(adapter, SGE_STAT_CFG_A, STATSOURCE_T5_V(7));
+   val1 = t4_read_reg(adapter, SGE_STAT_TOTAL_A);
+   val2 = t4_read_reg(adapter, SGE_STAT_MATCH_A);
*data = val1 - val2;
data++;
*data = val2;
@@ -3601,14 +3601,14 @@ unsigned int cxgb4_dbfifo_count(const struct net_device 
*dev, int lpfifo)
struct adapter *adap = netdev2adap(dev);
u32 v1, v2, lp_count, hp_count;
 
-   v1 = t4_read_reg(adap, A_SGE_DBFIFO_STATUS);
-   v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2);
+   v1 = t4_read_reg(adap, SGE_DBFIFO_STATUS_A);
+   v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2_A);
if (is_t4(adap-params.chip)) {
-   lp_count = G_LP_COUNT(v1);
-   hp_count = G_HP_COUNT(v1);
+   lp_count = LP_COUNT_G(v1);
+   hp_count = HP_COUNT_G(v1);
} else {
-   lp_count = G_LP_COUNT_T5(v1);
-   hp_count = G_HP_COUNT_T5(v2);
+   lp_count = LP_COUNT_T5_G(v1);
+   hp_count = HP_COUNT_T5_G(v2);
}
return lpfifo ? lp_count : hp_count;
 }
@@ -3667,14 +3667,14 @@ int cxgb4_flush_eq_cache(struct net_device *dev)
int ret;
 
ret = t4_fwaddrspace_write(adap, adap-mbox,
-  0xe100 + A_SGE_CTXT_CMD, 0x2000);
+  0xe100 + SGE_CTXT_CMD_A, 0x2000);
return ret;
 }
 EXPORT_SYMBOL(cxgb4_flush_eq_cache);
 
 static int read_eq_indices(struct adapter *adap, u16 qid, u16 *pidx, u16 *cidx)
 {
-   u32 addr = t4_read_reg(adap, A_SGE_DBQ_CTXT_BADDR) + 24 * qid + 8;
+   u32 addr = t4_read_reg(adap, SGE_DBQ_CTXT_BADDR_A) + 24 * qid + 8;
__be64 indices;
int ret;
 
@@ -3728,7 +3728,7 @@ void cxgb4_disable_db_coalescing(struct net_device *dev)
struct adapter *adap;
 
adap = netdev2adap(dev);
-   t4_set_reg_field(adap, A_SGE_DOORBELL_CONTROL, NOCOALESCE_F,
+   t4_set_reg_field(adap, SGE_DOORBELL_CONTROL_A, NOCOALESCE_F,
 NOCOALESCE_F);
 }
 EXPORT_SYMBOL(cxgb4_disable_db_coalescing);
@@ -3738,7 +3738,7 @@ void cxgb4_enable_db_coalescing(struct net_device *dev)
struct adapter *adap;
 
adap = netdev2adap(dev);
-   t4_set_reg_field(adap, A_SGE_DOORBELL_CONTROL, NOCOALESCE_F, 0);
+   t4_set_reg_field(adap, SGE_DOORBELL_CONTROL_A, NOCOALESCE_F, 0);
 }
 EXPORT_SYMBOL(cxgb4_enable_db_coalescing);
 
@@ -3877,14 +3877,14 @@ static void drain_db_fifo(struct adapter *adap, int 
usecs)
u32 v1, v2, lp_count, hp_count;
 
do {
-   v1 = t4_read_reg(adap, A_SGE_DBFIFO_STATUS);
-   v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2);
+   v1 = t4_read_reg(adap, SGE_DBFIFO_STATUS_A);
+   v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2_A);
if (is_t4(adap-params.chip)) {
-   lp_count = G_LP_COUNT(v1);
-   hp_count = G_HP_COUNT(v1);
+   lp_count = LP_COUNT_G(v1);
+   hp_count = HP_COUNT_G(v1);
} else

[PATCH net-next 5/5] cxgb4/cxgb4vf/csiostor: Cleanup PL, XGMAC, SF and MC related register defines

2015-01-05 Thread Hariprasad Shenai
This patch cleanups all PL, XGMAC and SF related macros/register defines
that are defined in t4_regs.h and the affected files

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|   56 +-
 drivers/net/ethernet/chelsio/cxgb4/l2t.c   |9 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |  258 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h   |  538 +++-
 drivers/net/ethernet/chelsio/cxgb4/t4_values.h |   33 ++
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c|2 +-
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c |6 +-
 drivers/scsi/csiostor/csio_hw.c|  186 
 drivers/scsi/csiostor/csio_hw.h|8 +-
 drivers/scsi/csiostor/csio_hw_chip.h   |4 +-
 drivers/scsi/csiostor/csio_mb.c|6 +-
 drivers/scsi/csiostor/csio_wr.c|2 +-
 12 files changed, 594 insertions(+), 514 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 53ad8d3..04e675b 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -834,11 +834,11 @@ static void disable_msi(struct adapter *adapter)
 static irqreturn_t t4_nondata_intr(int irq, void *cookie)
 {
struct adapter *adap = cookie;
+   u32 v = t4_read_reg(adap, MYPF_REG(PL_PF_INT_CAUSE_A));
 
-   u32 v = t4_read_reg(adap, MYPF_REG(PL_PF_INT_CAUSE));
-   if (v  PFSW) {
+   if (v  PFSW_F) {
adap-swintr = 1;
-   t4_write_reg(adap, MYPF_REG(PL_PF_INT_CAUSE), v);
+   t4_write_reg(adap, MYPF_REG(PL_PF_INT_CAUSE_A), v);
}
t4_slow_intr_handler(adap);
return IRQ_HANDLED;
@@ -3654,10 +3654,10 @@ void cxgb4_iscsi_init(struct net_device *dev, unsigned 
int tag_mask,
 {
struct adapter *adap = netdev2adap(dev);
 
-   t4_write_reg(adap, ULP_RX_ISCSI_TAGMASK, tag_mask);
-   t4_write_reg(adap, ULP_RX_ISCSI_PSZ, HPZ0(pgsz_order[0]) |
-HPZ1(pgsz_order[1]) | HPZ2(pgsz_order[2]) |
-HPZ3(pgsz_order[3]));
+   t4_write_reg(adap, ULP_RX_ISCSI_TAGMASK_A, tag_mask);
+   t4_write_reg(adap, ULP_RX_ISCSI_PSZ_A, HPZ0_V(pgsz_order[0]) |
+HPZ1_V(pgsz_order[1]) | HPZ2_V(pgsz_order[2]) |
+HPZ3_V(pgsz_order[3]));
 }
 EXPORT_SYMBOL(cxgb4_iscsi_init);
 
@@ -4580,13 +4580,13 @@ int cxgb4_create_server_filter(const struct net_device 
*dev, unsigned int stid,
f-fs.val.lip[i] = val[i];
f-fs.mask.lip[i] = ~0;
}
-   if (adap-params.tp.vlan_pri_map  F_PORT) {
+   if (adap-params.tp.vlan_pri_map  PORT_F) {
f-fs.val.iport = port;
f-fs.mask.iport = mask;
}
}
 
-   if (adap-params.tp.vlan_pri_map  F_PROTOCOL) {
+   if (adap-params.tp.vlan_pri_map  PROTOCOL_F) {
f-fs.val.proto = IPPROTO_TCP;
f-fs.mask.proto = ~0;
}
@@ -4950,37 +4950,37 @@ static int adap_init1(struct adapter *adap, struct 
fw_caps_config_cmd *c)
 
/* tweak some settings */
t4_write_reg(adap, TP_SHIFT_CNT_A, 0x64f8849);
-   t4_write_reg(adap, ULP_RX_TDDP_PSZ, HPZ0(PAGE_SHIFT - 12));
+   t4_write_reg(adap, ULP_RX_TDDP_PSZ_A, HPZ0_V(PAGE_SHIFT - 12));
t4_write_reg(adap, TP_PIO_ADDR_A, TP_INGRESS_CONFIG_A);
v = t4_read_reg(adap, TP_PIO_DATA_A);
t4_write_reg(adap, TP_PIO_DATA_A, v  ~CSUM_HAS_PSEUDO_HDR_F);
 
/* first 4 Tx modulation queues point to consecutive Tx channels */
adap-params.tp.tx_modq_map = 0xE4;
-   t4_write_reg(adap, A_TP_TX_MOD_QUEUE_REQ_MAP,
-V_TX_MOD_QUEUE_REQ_MAP(adap-params.tp.tx_modq_map));
+   t4_write_reg(adap, TP_TX_MOD_QUEUE_REQ_MAP_A,
+TX_MOD_QUEUE_REQ_MAP_V(adap-params.tp.tx_modq_map));
 
/* associate each Tx modulation queue with consecutive Tx channels */
v = 0x84218421;
t4_write_indirect(adap, TP_PIO_ADDR_A, TP_PIO_DATA_A,
- v, 1, A_TP_TX_SCHED_HDR);
+ v, 1, TP_TX_SCHED_HDR_A);
t4_write_indirect(adap, TP_PIO_ADDR_A, TP_PIO_DATA_A,
- v, 1, A_TP_TX_SCHED_FIFO);
+ v, 1, TP_TX_SCHED_FIFO_A);
t4_write_indirect(adap, TP_PIO_ADDR_A, TP_PIO_DATA_A,
- v, 1, A_TP_TX_SCHED_PCMD);
+ v, 1, TP_TX_SCHED_PCMD_A);
 
 #define T4_TX_MODQ_10G_WEIGHT_DEFAULT 16 /* in KB units */
if (is_offload(adap)) {
-   t4_write_reg(adap, A_TP_TX_MOD_QUEUE_WEIGHT0,
-V_TX_MODQ_WEIGHT0(T4_TX_MODQ_10G_WEIGHT_DEFAULT) |
-V_TX_MODQ_WEIGHT1

[PATCH net-next 3/5] cxgb4/cxg4vf/csiostor: Cleanup MC, MA and CIM related register defines

2015-01-05 Thread Hariprasad Shenai
This patch cleanups all MC, MA and CIM related macros/register defines that are
defined in t4_regs.h and the affected files.

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c   |  206 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h |  501 +++---
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_defs.h |4 +-
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c   |   14 +-
 drivers/scsi/csiostor/csio_hw.c  |  125 +++---
 drivers/scsi/csiostor/csio_hw_t4.c   |   32 +-
 drivers/scsi/csiostor/csio_hw_t5.c   |   36 +-
 drivers/scsi/csiostor/csio_mb.c  |   49 ++-
 8 files changed, 588 insertions(+), 379 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 9f8cd56..c9777e0 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -265,8 +265,8 @@ int t4_wr_mbox_meat(struct adapter *adap, int mbox, const 
void *cmd, int size,
u64 res;
int i, ms, delay_idx;
const __be64 *p = cmd;
-   u32 data_reg = PF_REG(mbox, CIM_PF_MAILBOX_DATA);
-   u32 ctl_reg = PF_REG(mbox, CIM_PF_MAILBOX_CTRL);
+   u32 data_reg = PF_REG(mbox, CIM_PF_MAILBOX_DATA_A);
+   u32 ctl_reg = PF_REG(mbox, CIM_PF_MAILBOX_CTRL_A);
 
if ((size  15) || size  MBOX_LEN)
return -EINVAL;
@@ -278,9 +278,9 @@ int t4_wr_mbox_meat(struct adapter *adap, int mbox, const 
void *cmd, int size,
if (adap-pdev-error_state != pci_channel_io_normal)
return -EIO;
 
-   v = MBOWNER_GET(t4_read_reg(adap, ctl_reg));
+   v = MBOWNER_G(t4_read_reg(adap, ctl_reg));
for (i = 0; v == MBOX_OWNER_NONE  i  3; i++)
-   v = MBOWNER_GET(t4_read_reg(adap, ctl_reg));
+   v = MBOWNER_G(t4_read_reg(adap, ctl_reg));
 
if (v != MBOX_OWNER_DRV)
return v ? -EBUSY : -ETIMEDOUT;
@@ -288,7 +288,7 @@ int t4_wr_mbox_meat(struct adapter *adap, int mbox, const 
void *cmd, int size,
for (i = 0; i  size; i += 8)
t4_write_reg64(adap, data_reg + i, be64_to_cpu(*p++));
 
-   t4_write_reg(adap, ctl_reg, MBMSGVALID | MBOWNER(MBOX_OWNER_FW));
+   t4_write_reg(adap, ctl_reg, MBMSGVALID_F | MBOWNER_V(MBOX_OWNER_FW));
t4_read_reg(adap, ctl_reg);  /* flush write */
 
delay_idx = 0;
@@ -304,8 +304,8 @@ int t4_wr_mbox_meat(struct adapter *adap, int mbox, const 
void *cmd, int size,
mdelay(ms);
 
v = t4_read_reg(adap, ctl_reg);
-   if (MBOWNER_GET(v) == MBOX_OWNER_DRV) {
-   if (!(v  MBMSGVALID)) {
+   if (MBOWNER_G(v) == MBOX_OWNER_DRV) {
+   if (!(v  MBMSGVALID_F)) {
t4_write_reg(adap, ctl_reg, 0);
continue;
}
@@ -351,27 +351,27 @@ int t4_mc_read(struct adapter *adap, int idx, u32 addr, 
__be32 *data, u64 *ecc)
u32 mc_bist_status_rdata, mc_bist_data_pattern;
 
if (is_t4(adap-params.chip)) {
-   mc_bist_cmd = MC_BIST_CMD;
-   mc_bist_cmd_addr = MC_BIST_CMD_ADDR;
-   mc_bist_cmd_len = MC_BIST_CMD_LEN;
-   mc_bist_status_rdata = MC_BIST_STATUS_RDATA;
-   mc_bist_data_pattern = MC_BIST_DATA_PATTERN;
+   mc_bist_cmd = MC_BIST_CMD_A;
+   mc_bist_cmd_addr = MC_BIST_CMD_ADDR_A;
+   mc_bist_cmd_len = MC_BIST_CMD_LEN_A;
+   mc_bist_status_rdata = MC_BIST_STATUS_RDATA_A;
+   mc_bist_data_pattern = MC_BIST_DATA_PATTERN_A;
} else {
-   mc_bist_cmd = MC_REG(MC_P_BIST_CMD, idx);
-   mc_bist_cmd_addr = MC_REG(MC_P_BIST_CMD_ADDR, idx);
-   mc_bist_cmd_len = MC_REG(MC_P_BIST_CMD_LEN, idx);
-   mc_bist_status_rdata = MC_REG(MC_P_BIST_STATUS_RDATA, idx);
-   mc_bist_data_pattern = MC_REG(MC_P_BIST_DATA_PATTERN, idx);
+   mc_bist_cmd = MC_REG(MC_P_BIST_CMD_A, idx);
+   mc_bist_cmd_addr = MC_REG(MC_P_BIST_CMD_ADDR_A, idx);
+   mc_bist_cmd_len = MC_REG(MC_P_BIST_CMD_LEN_A, idx);
+   mc_bist_status_rdata = MC_REG(MC_P_BIST_STATUS_RDATA_A, idx);
+   mc_bist_data_pattern = MC_REG(MC_P_BIST_DATA_PATTERN_A, idx);
}
 
-   if (t4_read_reg(adap, mc_bist_cmd)  START_BIST)
+   if (t4_read_reg(adap, mc_bist_cmd)  START_BIST_F)
return -EBUSY;
t4_write_reg(adap, mc_bist_cmd_addr, addr  ~0x3fU);
t4_write_reg(adap, mc_bist_cmd_len, 64);
t4_write_reg(adap, mc_bist_data_pattern, 0xc);
-   t4_write_reg(adap, mc_bist_cmd, BIST_OPCODE(1) | START_BIST |
-BIST_CMD_GAP(1));
-   i = t4_wait_op_done(adap, mc_bist_cmd, START_BIST, 0, 10, 1);
+   t4_write_reg(adap

[PATCH net-next 0/5] RDMA/cxgb4/cxgb4vf/csiostor: Cleanup register defines

2015-01-05 Thread Hariprasad Shenai
Hi,

This series continues to cleanup all the macros/register defines related to
SGE, PCIE, MC, MA, TCAM, MAC, etc that are defined in t4_regs.h and the
affected files.

Will post another 1 or 2 series so that we can cover all the macros so that
they all follow the same style to be consistent.

The patches series is created against 'net-next' tree.
And includes patches on cxgb4, cxgb4vf, iw_cxgb4 and csiostor driver.

We have included all the maintainers of respective drivers. Kindly review the
change and let us know in case of any review comments.

Thanks

Hariprasad Shenai (5):
  RDMA/cxgb4/cxgb4vf/csiostor: Cleanup SGE register defines
  cxgb4/cxgb4vf/csiostor: Cleanup SGE and PCI related register defines
  cxgb4/cxg4vf/csiostor: Cleanup MC, MA and CIM related register
defines
  cxgb4/csiostor: Cleanup TP, MPS and TCAM related register defines
  cxgb4/cxgb4vf/csiostor: Cleanup PL, XGMAC, SF and MC related register
defines

 drivers/infiniband/hw/cxgb4/t4.h   |   26 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|  266 +-
 drivers/net/ethernet/chelsio/cxgb4/l2t.c   |9 +-
 drivers/net/ethernet/chelsio/cxgb4/sge.c   |  174 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |  960 
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h   | 2749 
 drivers/net/ethernet/chelsio/cxgb4/t4_values.h |  118 +
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c|   40 +-
 drivers/net/ethernet/chelsio/cxgb4vf/sge.c |   47 +-
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_defs.h   |4 +-
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c |   43 +-
 drivers/scsi/csiostor/csio_hw.c|  515 ++--
 drivers/scsi/csiostor/csio_hw.h|8 +-
 drivers/scsi/csiostor/csio_hw_chip.h   |   14 +-
 drivers/scsi/csiostor/csio_hw_t4.c |  144 +-
 drivers/scsi/csiostor/csio_hw_t5.c |  150 +-
 drivers/scsi/csiostor/csio_isr.c   |2 +-
 drivers/scsi/csiostor/csio_mb.c|   53 +-
 drivers/scsi/csiostor/csio_wr.c|  154 +-
 19 files changed, 3151 insertions(+), 2325 deletions(-)
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/t4_values.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


[PATCH net-next 1/5] RDMA/cxgb4/cxgb4vf/csiostor: Cleanup SGE register defines

2015-01-05 Thread Hariprasad Shenai
This patch cleanups all SGE related macros/register defines that are
defined in t4_regs.h and the affected files.

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/t4.h   |   26 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|   76 ++--
 drivers/net/ethernet/chelsio/cxgb4/sge.c   |   96 ++--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |  118 +++---
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h   |  498 +++
 drivers/net/ethernet/chelsio/cxgb4/t4_values.h |   81 
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c|   24 +-
 drivers/net/ethernet/chelsio/cxgb4vf/sge.c |   47 +-
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c |   17 +-
 drivers/scsi/csiostor/csio_hw.c|   58 ++--
 drivers/scsi/csiostor/csio_hw_chip.h   |8 +-
 drivers/scsi/csiostor/csio_wr.c|  112 +++---
 12 files changed, 670 insertions(+), 491 deletions(-)
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/t4_values.h

diff --git a/drivers/infiniband/hw/cxgb4/t4.h b/drivers/infiniband/hw/cxgb4/t4.h
index c04e513..29e764e 100644
--- a/drivers/infiniband/hw/cxgb4/t4.h
+++ b/drivers/infiniband/hw/cxgb4/t4.h
@@ -465,14 +465,14 @@ static inline void t4_ring_sq_db(struct t4_wq *wq, u16 
inc, u8 t5,
} else {
PDBG(%s: DB wq-sq.pidx = %d\n,
 __func__, wq-sq.pidx);
-   writel(PIDX_T5(inc), wq-sq.udb);
+   writel(PIDX_T5_V(inc), wq-sq.udb);
}
 
/* Flush user doorbell area writes. */
wmb();
return;
}
-   writel(QID(wq-sq.qid) | PIDX(inc), wq-db);
+   writel(QID_V(wq-sq.qid) | PIDX_V(inc), wq-db);
 }
 
 static inline void t4_ring_rq_db(struct t4_wq *wq, u16 inc, u8 t5,
@@ -489,14 +489,14 @@ static inline void t4_ring_rq_db(struct t4_wq *wq, u16 
inc, u8 t5,
} else {
PDBG(%s: DB wq-rq.pidx = %d\n,
 __func__, wq-rq.pidx);
-   writel(PIDX_T5(inc), wq-rq.udb);
+   writel(PIDX_T5_V(inc), wq-rq.udb);
}
 
/* Flush user doorbell area writes. */
wmb();
return;
}
-   writel(QID(wq-rq.qid) | PIDX(inc), wq-db);
+   writel(QID_V(wq-rq.qid) | PIDX_V(inc), wq-db);
 }
 
 static inline int t4_wq_in_error(struct t4_wq *wq)
@@ -561,14 +561,14 @@ static inline int t4_arm_cq(struct t4_cq *cq, int se)
u32 val;
 
set_bit(CQ_ARMED, cq-flags);
-   while (cq-cidx_inc  CIDXINC_MASK) {
-   val = SEINTARM(0) | CIDXINC(CIDXINC_MASK) | TIMERREG(7) |
- INGRESSQID(cq-cqid);
+   while (cq-cidx_inc  CIDXINC_M) {
+   val = SEINTARM_V(0) | CIDXINC_V(CIDXINC_M) | TIMERREG_V(7) |
+ INGRESSQID_V(cq-cqid);
writel(val, cq-gts);
-   cq-cidx_inc -= CIDXINC_MASK;
+   cq-cidx_inc -= CIDXINC_M;
}
-   val = SEINTARM(se) | CIDXINC(cq-cidx_inc) | TIMERREG(6) |
- INGRESSQID(cq-cqid);
+   val = SEINTARM_V(se) | CIDXINC_V(cq-cidx_inc) | TIMERREG_V(6) |
+ INGRESSQID_V(cq-cqid);
writel(val, cq-gts);
cq-cidx_inc = 0;
return 0;
@@ -597,11 +597,11 @@ static inline void t4_swcq_consume(struct t4_cq *cq)
 static inline void t4_hwcq_consume(struct t4_cq *cq)
 {
cq-bits_type_ts = cq-queue[cq-cidx].bits_type_ts;
-   if (++cq-cidx_inc == (cq-size  4) || cq-cidx_inc == CIDXINC_MASK) {
+   if (++cq-cidx_inc == (cq-size  4) || cq-cidx_inc == CIDXINC_M) {
u32 val;
 
-   val = SEINTARM(0) | CIDXINC(cq-cidx_inc) | TIMERREG(7) |
- INGRESSQID(cq-cqid);
+   val = SEINTARM_V(0) | CIDXINC_V(cq-cidx_inc) | TIMERREG_V(7) |
+ INGRESSQID_V(cq-cqid);
writel(val, cq-gts);
cq-cidx_inc = 0;
}
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index ccf3436..5e0d57a 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -66,6 +66,7 @@
 
 #include cxgb4.h
 #include t4_regs.h
+#include t4_values.h
 #include t4_msg.h
 #include t4fw_api.h
 #include cxgb4_dcb.h
@@ -1050,9 +1051,9 @@ static void enable_rx(struct adapter *adap)
if (q-handler)
napi_enable(q-napi);
/* 0-increment GTS to start the timer and enable interrupts */
-   t4_write_reg(adap, MYPF_REG(SGE_PF_GTS),
-SEINTARM(q-intr_params) |
-INGRESSQID(q-cntxt_id));
+   t4_write_reg(adap, MYPF_REG(SGE_PF_GTS_A),
+SEINTARM_V(q-intr_params

[PATCH net-next 4/5] cxgb4/csiostor: Cleanup TP, MPS and TCAM related register defines

2015-01-05 Thread Hariprasad Shenai
This patch cleanups all TP, MPS and TCAM related macros/register defines
that are defined in t4_regs.h and the affected files

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   70 ++--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c  |  154 +++---
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h|  607 ++-
 drivers/scsi/csiostor/csio_hw.c |  113 +++--
 drivers/scsi/csiostor/csio_wr.c |4 +-
 5 files changed, 536 insertions(+), 412 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 16c633f..53ad8d3 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -359,8 +359,8 @@ MODULE_PARM_DESC(select_queue,
  */
 enum {
TP_VLAN_PRI_MAP_DEFAULT = HW_TPL_FR_MT_PR_IV_P_FC,
-   TP_VLAN_PRI_MAP_FIRST = FCOE_SHIFT,
-   TP_VLAN_PRI_MAP_LAST = FRAGMENTATION_SHIFT,
+   TP_VLAN_PRI_MAP_FIRST = FCOE_S,
+   TP_VLAN_PRI_MAP_LAST = FRAGMENTATION_S,
 };
 
 static unsigned int tp_vlan_pri_map = TP_VLAN_PRI_MAP_DEFAULT;
@@ -1177,10 +1177,10 @@ freeout:t4_free_sge_resources(adap);
}
 
t4_write_reg(adap, is_t4(adap-params.chip) ?
-   MPS_TRC_RSS_CONTROL :
-   MPS_T5_TRC_RSS_CONTROL,
-RSSCONTROL(netdev2pinfo(adap-port[0])-tx_chan) |
-QUEUENUMBER(s-ethrxq[0].rspq.abs_id));
+   MPS_TRC_RSS_CONTROL_A :
+   MPS_T5_TRC_RSS_CONTROL_A,
+RSSCONTROL_V(netdev2pinfo(adap-port[0])-tx_chan) |
+QUEUENUMBER_V(s-ethrxq[0].rspq.abs_id));
return 0;
 }
 
@@ -4094,7 +4094,7 @@ static void uld_attach(struct adapter *adap, unsigned int 
uld)
lli.nports = adap-params.nports;
lli.wr_cred = adap-params.ofldq_wr_cred;
lli.adapter_type = adap-params.chip;
-   lli.iscsi_iolen = MAXRXDATA_GET(t4_read_reg(adap, TP_PARA_REG2));
+   lli.iscsi_iolen = MAXRXDATA_G(t4_read_reg(adap, TP_PARA_REG2_A));
lli.cclk_ps = 10 / adap-params.vpd.cclk;
lli.udb_density = 1  adap-params.sge.eq_qpp;
lli.ucq_density = 1  adap-params.sge.iq_qpp;
@@ -4949,11 +4949,11 @@ static int adap_init1(struct adapter *adap, struct 
fw_caps_config_cmd *c)
t4_sge_init(adap);
 
/* tweak some settings */
-   t4_write_reg(adap, TP_SHIFT_CNT, 0x64f8849);
+   t4_write_reg(adap, TP_SHIFT_CNT_A, 0x64f8849);
t4_write_reg(adap, ULP_RX_TDDP_PSZ, HPZ0(PAGE_SHIFT - 12));
-   t4_write_reg(adap, TP_PIO_ADDR, TP_INGRESS_CONFIG);
-   v = t4_read_reg(adap, TP_PIO_DATA);
-   t4_write_reg(adap, TP_PIO_DATA, v  ~CSUM_HAS_PSEUDO_HDR);
+   t4_write_reg(adap, TP_PIO_ADDR_A, TP_INGRESS_CONFIG_A);
+   v = t4_read_reg(adap, TP_PIO_DATA_A);
+   t4_write_reg(adap, TP_PIO_DATA_A, v  ~CSUM_HAS_PSEUDO_HDR_F);
 
/* first 4 Tx modulation queues point to consecutive Tx channels */
adap-params.tp.tx_modq_map = 0xE4;
@@ -4962,11 +4962,11 @@ static int adap_init1(struct adapter *adap, struct 
fw_caps_config_cmd *c)
 
/* associate each Tx modulation queue with consecutive Tx channels */
v = 0x84218421;
-   t4_write_indirect(adap, TP_PIO_ADDR, TP_PIO_DATA,
+   t4_write_indirect(adap, TP_PIO_ADDR_A, TP_PIO_DATA_A,
  v, 1, A_TP_TX_SCHED_HDR);
-   t4_write_indirect(adap, TP_PIO_ADDR, TP_PIO_DATA,
+   t4_write_indirect(adap, TP_PIO_ADDR_A, TP_PIO_DATA_A,
  v, 1, A_TP_TX_SCHED_FIFO);
-   t4_write_indirect(adap, TP_PIO_ADDR, TP_PIO_DATA,
+   t4_write_indirect(adap, TP_PIO_ADDR_A, TP_PIO_DATA_A,
  v, 1, A_TP_TX_SCHED_PCMD);
 
 #define T4_TX_MODQ_10G_WEIGHT_DEFAULT 16 /* in KB units */
@@ -5034,8 +5034,8 @@ static int adap_init0_tweaks(struct adapter *adapter)
 * Don't include the IP Pseudo Header in CPL_RX_PKT checksums: Linux
 * adds the pseudo header itself.
 */
-   t4_tp_wr_bits_indirect(adapter, TP_INGRESS_CONFIG,
-  CSUM_HAS_PSEUDO_HDR, 0);
+   t4_tp_wr_bits_indirect(adapter, TP_INGRESS_CONFIG_A,
+  CSUM_HAS_PSEUDO_HDR_F, 0);
 
return 0;
 }
@@ -5401,34 +5401,34 @@ static int adap_init0_no_config(struct adapter 
*adapter, int reset)
case 0:
/* compressed filter field not enabled */
break;
-   case FCOE_MASK:
+   case FCOE_F:
bits +=  1;
break;
-   case PORT_MASK:
+   case PORT_F:
bits +=  3;
break

[PATCH net-next 1/5] RDMA/cxgb4: Cleanup Filter related macros/register defines

2014-11-20 Thread Hariprasad Shenai
This patch cleanups all filter related macros/register defines that are defined
in t4fw_api.h and the affected files.

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c|   14 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   68 ++--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c  |8 +-
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h   |  584 +++---
 4 files changed, 337 insertions(+), 337 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 83fa16f..0ad8e2a 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -1762,10 +1762,10 @@ static void send_fw_act_open_req(struct c4iw_ep *ep, 
unsigned int atid)
req-le.pport = sin-sin_port;
req-le.u.ipv4.pip = sin-sin_addr.s_addr;
req-tcb.t_state_to_astid =
-   htonl(V_FW_OFLD_CONNECTION_WR_T_STATE(TCP_SYN_SENT) |
-   V_FW_OFLD_CONNECTION_WR_ASTID(atid));
+   htonl(FW_OFLD_CONNECTION_WR_T_STATE_V(TCP_SYN_SENT) |
+   FW_OFLD_CONNECTION_WR_ASTID_V(atid));
req-tcb.cplrxdataack_cplpassacceptrpl =
-   htons(F_FW_OFLD_CONNECTION_WR_CPLRXDATAACK);
+   htons(FW_OFLD_CONNECTION_WR_CPLRXDATAACK_F);
req-tcb.tx_max = (__force __be32) jiffies;
req-tcb.rcv_adv = htons(1);
best_mtu(ep-com.dev-rdev.lldi.mtus, ep-mtu, mtu_idx,
@@ -3539,7 +3539,7 @@ static void send_fw_pass_open_req(struct c4iw_dev *dev, 
struct sk_buff *skb,
memset(req, 0, sizeof(*req));
req-op_compl = htonl(V_WR_OP(FW_OFLD_CONNECTION_WR) | FW_WR_COMPL_F);
req-len16_pkd = htonl(FW_WR_LEN16_V(DIV_ROUND_UP(sizeof(*req), 16)));
-   req-le.version_cpl = htonl(F_FW_OFLD_CONNECTION_WR_CPL);
+   req-le.version_cpl = htonl(FW_OFLD_CONNECTION_WR_CPL_F);
req-le.filter = (__force __be32) filter;
req-le.lport = lport;
req-le.pport = rport;
@@ -3548,9 +3548,9 @@ static void send_fw_pass_open_req(struct c4iw_dev *dev, 
struct sk_buff *skb,
req-tcb.rcv_nxt = htonl(rcv_isn + 1);
req-tcb.rcv_adv = htons(window);
req-tcb.t_state_to_astid =
-htonl(V_FW_OFLD_CONNECTION_WR_T_STATE(TCP_SYN_RECV) |
-   V_FW_OFLD_CONNECTION_WR_RCV_SCALE(cpl-tcpopt.wsf) |
-   V_FW_OFLD_CONNECTION_WR_ASTID(
+htonl(FW_OFLD_CONNECTION_WR_T_STATE_V(TCP_SYN_RECV) |
+   FW_OFLD_CONNECTION_WR_RCV_SCALE_V(cpl-tcpopt.wsf) |
+   FW_OFLD_CONNECTION_WR_ASTID_V(
GET_PASS_OPEN_TID(ntohl(cpl-tos_stid;
 
/*
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 19ffe9b..6b6d7e1 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -1342,49 +1342,49 @@ static int set_filter_wr(struct adapter *adapter, int 
fidx)
fwr-op_pkd = htonl(FW_WR_OP_V(FW_FILTER_WR));
fwr-len16_pkd = htonl(FW_WR_LEN16_V(sizeof(*fwr)/16));
fwr-tid_to_iq =
-   htonl(V_FW_FILTER_WR_TID(ftid) |
- V_FW_FILTER_WR_RQTYPE(f-fs.type) |
- V_FW_FILTER_WR_NOREPLY(0) |
- V_FW_FILTER_WR_IQ(f-fs.iq));
+   htonl(FW_FILTER_WR_TID_V(ftid) |
+ FW_FILTER_WR_RQTYPE_V(f-fs.type) |
+ FW_FILTER_WR_NOREPLY_V(0) |
+ FW_FILTER_WR_IQ_V(f-fs.iq));
fwr-del_filter_to_l2tix =
-   htonl(V_FW_FILTER_WR_RPTTID(f-fs.rpttid) |
- V_FW_FILTER_WR_DROP(f-fs.action == FILTER_DROP) |
- V_FW_FILTER_WR_DIRSTEER(f-fs.dirsteer) |
- V_FW_FILTER_WR_MASKHASH(f-fs.maskhash) |
- V_FW_FILTER_WR_DIRSTEERHASH(f-fs.dirsteerhash) |
- V_FW_FILTER_WR_LPBK(f-fs.action == FILTER_SWITCH) |
- V_FW_FILTER_WR_DMAC(f-fs.newdmac) |
- V_FW_FILTER_WR_SMAC(f-fs.newsmac) |
- V_FW_FILTER_WR_INSVLAN(f-fs.newvlan == VLAN_INSERT ||
+   htonl(FW_FILTER_WR_RPTTID_V(f-fs.rpttid) |
+ FW_FILTER_WR_DROP_V(f-fs.action == FILTER_DROP) |
+ FW_FILTER_WR_DIRSTEER_V(f-fs.dirsteer) |
+ FW_FILTER_WR_MASKHASH_V(f-fs.maskhash) |
+ FW_FILTER_WR_DIRSTEERHASH_V(f-fs.dirsteerhash) |
+ FW_FILTER_WR_LPBK_V(f-fs.action == FILTER_SWITCH) |
+ FW_FILTER_WR_DMAC_V(f-fs.newdmac) |
+ FW_FILTER_WR_SMAC_V(f-fs.newsmac) |
+ FW_FILTER_WR_INSVLAN_V(f-fs.newvlan == VLAN_INSERT ||
 f-fs.newvlan == VLAN_REWRITE) |
- V_FW_FILTER_WR_RMVLAN(f-fs.newvlan

[PATCH net-next 2/5] RDMA/cxgb4/csiostor: Cleansup FW related macros/register defines for PF/VF and LDST

2014-11-20 Thread Hariprasad Shenai
This patch cleanups PF/VF and LDST related macros/register defines that are
defined in t4fw_api.h and the affected files.

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c   |2 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|   61 +++--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |   78 +++---
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h  |  270 +---
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c|   10 +-
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c |   72 +++---
 drivers/scsi/csiostor/csio_hw.c|   20 +-
 drivers/scsi/csiostor/csio_mb.c|   30 +-
 drivers/scsi/csiostor/csio_mb.h|   12 +-
 9 files changed, 327 insertions(+), 228 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 0ad8e2a..4b8c611 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -478,7 +478,7 @@ static void send_flowc(struct c4iw_ep *ep, struct sk_buff 
*skb)
  16)) | FW_WR_FLOWID_V(ep-hwtid));
 
flowc-mnemval[0].mnemonic = FW_FLOWC_MNEM_PFNVFN;
-   flowc-mnemval[0].val = cpu_to_be32(FW_PFVF_CMD_PFN
+   flowc-mnemval[0].val = cpu_to_be32(FW_PFVF_CMD_PFN_V
(ep-com.dev-rdev.lldi.pf));
flowc-mnemval[1].mnemonic = FW_FLOWC_MNEM_CH;
flowc-mnemval[1].val = cpu_to_be32(ep-tx_chan);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 6b6d7e1..4caec41 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -141,7 +141,7 @@ static unsigned int pfvfres_pmask(struct adapter *adapter,
 * Give PF's access to all of the ports.
 */
if (vf == 0)
-   return FW_PFVF_CMD_PMASK_MASK;
+   return FW_PFVF_CMD_PMASK_M;
 
/*
 * For VFs, we'll assign them access to the ports based purely on the
@@ -512,9 +512,10 @@ static void dcb_tx_queue_prio_enable(struct net_device 
*dev, int enable)
u32 name, value;
int err;
 
-   name = (FW_PARAMS_MNEM(FW_PARAMS_MNEM_DMAQ) |
-   FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DMAQ_EQ_DCBPRIO_ETH) |
-   FW_PARAMS_PARAM_YZ(txq-q.cntxt_id));
+   name = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DMAQ) |
+   FW_PARAMS_PARAM_X_V(
+   FW_PARAMS_PARAM_DMAQ_EQ_DCBPRIO_ETH) |
+   FW_PARAMS_PARAM_YZ_V(txq-q.cntxt_id));
value = enable ? i : 0x;
 
/* Since we can be called while atomic (from interrupt
@@ -2717,9 +2718,10 @@ static int set_rspq_intr_params(struct sge_rspq *q,
new_idx = closest_thres(adap-sge, cnt);
if (q-desc  q-pktcnt_idx != new_idx) {
/* the queue has already been created, update it */
-   v = FW_PARAMS_MNEM(FW_PARAMS_MNEM_DMAQ) |
-   
FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DMAQ_IQ_INTCNTTHRESH) |
-   FW_PARAMS_PARAM_YZ(q-cntxt_id);
+   v = FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DMAQ) |
+   FW_PARAMS_PARAM_X_V(
+   FW_PARAMS_PARAM_DMAQ_IQ_INTCNTTHRESH) |
+   FW_PARAMS_PARAM_YZ_V(q-cntxt_id);
err = t4_set_params(adap, adap-fn, adap-fn, 0, 1, v,
new_idx);
if (err)
@@ -4870,11 +4872,11 @@ static u32 t4_read_pcie_cfg4(struct adapter *adap, int 
reg)
htonl(FW_CMD_OP_V(FW_LDST_CMD) |
  FW_CMD_REQUEST_F |
  FW_CMD_READ_F |
- FW_LDST_CMD_ADDRSPACE(FW_LDST_ADDRSPC_FUNC_PCIE));
+ FW_LDST_CMD_ADDRSPACE_V(FW_LDST_ADDRSPC_FUNC_PCIE));
ldst_cmd.cycles_to_len16 = htonl(FW_LEN16(ldst_cmd));
-   ldst_cmd.u.pcie.select_naccess = FW_LDST_CMD_NACCESS(1);
+   ldst_cmd.u.pcie.select_naccess = FW_LDST_CMD_NACCESS_V(1);
ldst_cmd.u.pcie.ctrl_to_fn =
-   (FW_LDST_CMD_LC | FW_LDST_CMD_FN(adap-fn));
+   (FW_LDST_CMD_LC_F | FW_LDST_CMD_FN_V(adap-fn));
ldst_cmd.u.pcie.r = reg;
ret = t4_wr_mbox(adap, adap-mbox, ldst_cmd, sizeof(ldst_cmd),
 ldst_cmd);
@@ -5148,8 +5150,8 @@ static int adap_init0_config(struct adapter *adapter, int 
reset)
if (cf-size = FLASH_CFG_MAX_SIZE)
ret = -ENOMEM;
else {
-   params[0] = (FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) |
-FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_CF));
+   params[0

[PATCH net-next 0/5] RDMA/cxgb4,cxgb4vf,csiostor: Cleanup macros

2014-11-20 Thread Hariprasad Shenai
Hi,

This series continues to cleanup all the macros/register defines related to
filter, port, VI, queue, RSS, LDST, firmware, etc that are defined in t4fw_api.h
and the affected files.

Will post few more series so that we can cover all the macros so that they all
follow the same style to be consistent.

The patches series is created against 'net-next' tree.
And includes patches on cxgb4, cxgb4vf, iw_cxgb4 and csiostor driver.

We have included all the maintainers of respective drivers. Kindly review the
change and let us know in case of any review comments.

Thanks

Hariprasad Shenai (5):
  RDMA/cxgb4: Cleanup Filter related macros/register defines
  RDMA/cxgb4/csiostor: Cleansup FW related macros/register defines for
PF/VF and LDST
  cxgb4/cxgb4vf/csiostor: Cleanup macros/register defines related to
queues
  cxgb4/cxgb4vf/csiostor: Cleanup macros/register defines related to
port and VI
  RDMA/cxgb4/cxgb4vf/csiostor: Cleanup macros/register defines related
to PCIE, RSS and FW

 drivers/infiniband/hw/cxgb4/cm.c   |   16 +-
 drivers/infiniband/hw/cxgb4/provider.c |8 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |8 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c |   14 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h |4 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|  193 +-
 drivers/net/ethernet/chelsio/cxgb4/l2t.c   |4 +-
 drivers/net/ethernet/chelsio/cxgb4/sge.c   |  115 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |  292 ++--
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h  | 2121 +---
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c|   26 +-
 drivers/net/ethernet/chelsio/cxgb4vf/sge.c |   63 +-
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c |  232 ++--
 drivers/scsi/csiostor/csio_hw.c|   38 +-
 drivers/scsi/csiostor/csio_init.c  |8 +-
 drivers/scsi/csiostor/csio_mb.c|  171 +-
 drivers/scsi/csiostor/csio_mb.h|   12 +-
 17 files changed, 2004 insertions(+), 1321 deletions(-)

--
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


[PATCH net-next 5/5] RDMA/cxgb4/cxgb4vf/csiostor: Cleanup macros/register defines related to PCIE, RSS and FW

2014-11-20 Thread Hariprasad Shenai
This patch cleanups all PCIE, RSS  FW related macros/register defines that are
defined in t4fw_api.h and the affected files.

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/provider.c |8 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |8 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|   56 +++---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |   68 +++---
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h  |  227 ++--
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c|   16 +-
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c |   52 +++---
 drivers/scsi/csiostor/csio_hw.c|   18 +-
 drivers/scsi/csiostor/csio_init.c  |8 +-
 drivers/scsi/csiostor/csio_mb.c|2 +-
 10 files changed, 282 insertions(+), 181 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/provider.c 
b/drivers/infiniband/hw/cxgb4/provider.c
index 72e3b69..66bd6a2 100644
--- a/drivers/infiniband/hw/cxgb4/provider.c
+++ b/drivers/infiniband/hw/cxgb4/provider.c
@@ -408,10 +408,10 @@ static ssize_t show_fw_ver(struct device *dev, struct 
device_attribute *attr,
PDBG(%s dev 0x%p\n, __func__, dev);
 
return sprintf(buf, %u.%u.%u.%u\n,
-   FW_HDR_FW_VER_MAJOR_GET(c4iw_dev-rdev.lldi.fw_vers),
-   FW_HDR_FW_VER_MINOR_GET(c4iw_dev-rdev.lldi.fw_vers),
-   FW_HDR_FW_VER_MICRO_GET(c4iw_dev-rdev.lldi.fw_vers),
-   FW_HDR_FW_VER_BUILD_GET(c4iw_dev-rdev.lldi.fw_vers));
+   FW_HDR_FW_VER_MAJOR_G(c4iw_dev-rdev.lldi.fw_vers),
+   FW_HDR_FW_VER_MINOR_G(c4iw_dev-rdev.lldi.fw_vers),
+   FW_HDR_FW_VER_MICRO_G(c4iw_dev-rdev.lldi.fw_vers),
+   FW_HDR_FW_VER_BUILD_G(c4iw_dev-rdev.lldi.fw_vers));
 }
 
 static ssize_t show_hca(struct device *dev, struct device_attribute *attr,
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index a2196bc..e8b09bb 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -318,10 +318,10 @@ struct adapter_params {
 #include t4fw_api.h
 
 #define FW_VERSION(chip) ( \
-   FW_HDR_FW_VER_MAJOR_GET(chip##FW_VERSION_MAJOR) | \
-   FW_HDR_FW_VER_MINOR_GET(chip##FW_VERSION_MINOR) | \
-   FW_HDR_FW_VER_MICRO_GET(chip##FW_VERSION_MICRO) | \
-   FW_HDR_FW_VER_BUILD_GET(chip##FW_VERSION_BUILD))
+   FW_HDR_FW_VER_MAJOR_G(chip##FW_VERSION_MAJOR) | \
+   FW_HDR_FW_VER_MINOR_G(chip##FW_VERSION_MINOR) | \
+   FW_HDR_FW_VER_MICRO_G(chip##FW_VERSION_MICRO) | \
+   FW_HDR_FW_VER_BUILD_G(chip##FW_VERSION_BUILD))
 #define FW_INTFVER(chip, intf) (FW_HDR_INTFVER_##intf)
 
 struct fw_info {
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 4c663cc..a576da1 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -1616,14 +1616,14 @@ static void get_drvinfo(struct net_device *dev, struct 
ethtool_drvinfo *info)
if (adapter-params.fw_vers)
snprintf(info-fw_version, sizeof(info-fw_version),
%u.%u.%u.%u, TP %u.%u.%u.%u,
-   FW_HDR_FW_VER_MAJOR_GET(adapter-params.fw_vers),
-   FW_HDR_FW_VER_MINOR_GET(adapter-params.fw_vers),
-   FW_HDR_FW_VER_MICRO_GET(adapter-params.fw_vers),
-   FW_HDR_FW_VER_BUILD_GET(adapter-params.fw_vers),
-   FW_HDR_FW_VER_MAJOR_GET(adapter-params.tp_vers),
-   FW_HDR_FW_VER_MINOR_GET(adapter-params.tp_vers),
-   FW_HDR_FW_VER_MICRO_GET(adapter-params.tp_vers),
-   FW_HDR_FW_VER_BUILD_GET(adapter-params.tp_vers));
+   FW_HDR_FW_VER_MAJOR_G(adapter-params.fw_vers),
+   FW_HDR_FW_VER_MINOR_G(adapter-params.fw_vers),
+   FW_HDR_FW_VER_MICRO_G(adapter-params.fw_vers),
+   FW_HDR_FW_VER_BUILD_G(adapter-params.fw_vers),
+   FW_HDR_FW_VER_MAJOR_G(adapter-params.tp_vers),
+   FW_HDR_FW_VER_MINOR_G(adapter-params.tp_vers),
+   FW_HDR_FW_VER_MICRO_G(adapter-params.tp_vers),
+   FW_HDR_FW_VER_BUILD_G(adapter-params.tp_vers));
 }
 
 static void get_strings(struct net_device *dev, u32 stringset, u8 *data)
@@ -2935,7 +2935,7 @@ static int set_flash(struct net_device *netdev, struct 
ethtool_flash *ef)
int ret;
const struct firmware *fw;
struct adapter *adap = netdev2adap(netdev);
-   unsigned int mbox = FW_PCIE_FW_MASTER_MASK + 1;
+   unsigned int mbox = PCIE_FW_MASTER_M + 1;
 
ef-data[sizeof(ef

[PATCH net-next 3/5] cxgb4/cxgb4vf/csiostor: Cleanup macros/register defines related to queues

2014-11-20 Thread Hariprasad Shenai
This patch cleanups all queue related macros/register defines that are defined
in t4fw_api.h and the affected files.

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/net/ethernet/chelsio/cxgb4/sge.c   |  115 ++--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |   32 +-
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h  |  690 ++--
 drivers/net/ethernet/chelsio/cxgb4vf/sge.c |   63 ++--
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c |8 +-
 drivers/scsi/csiostor/csio_mb.c|  119 ++--
 6 files changed, 684 insertions(+), 343 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c 
b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index 5cc5e19..433560b 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -2299,18 +2299,18 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct 
sge_rspq *iq, bool fwevtq,
memset(c, 0, sizeof(c));
c.op_to_vfn = htonl(FW_CMD_OP_V(FW_IQ_CMD) | FW_CMD_REQUEST_F |
FW_CMD_WRITE_F | FW_CMD_EXEC_F |
-   FW_IQ_CMD_PFN(adap-fn) | FW_IQ_CMD_VFN(0));
-   c.alloc_to_len16 = htonl(FW_IQ_CMD_ALLOC | FW_IQ_CMD_IQSTART(1) |
+   FW_IQ_CMD_PFN_V(adap-fn) | FW_IQ_CMD_VFN_V(0));
+   c.alloc_to_len16 = htonl(FW_IQ_CMD_ALLOC_F | FW_IQ_CMD_IQSTART_F |
 FW_LEN16(c));
-   c.type_to_iqandstindex = htonl(FW_IQ_CMD_TYPE(FW_IQ_TYPE_FL_INT_CAP) |
-   FW_IQ_CMD_IQASYNCH(fwevtq) | FW_IQ_CMD_VIID(pi-viid) |
-   FW_IQ_CMD_IQANDST(intr_idx  0) | FW_IQ_CMD_IQANUD(1) |
-   FW_IQ_CMD_IQANDSTINDEX(intr_idx = 0 ? intr_idx :
+   c.type_to_iqandstindex = htonl(FW_IQ_CMD_TYPE_V(FW_IQ_TYPE_FL_INT_CAP) |
+   FW_IQ_CMD_IQASYNCH_V(fwevtq) | FW_IQ_CMD_VIID_V(pi-viid) |
+   FW_IQ_CMD_IQANDST_V(intr_idx  0) | FW_IQ_CMD_IQANUD_V(1) |
+   FW_IQ_CMD_IQANDSTINDEX_V(intr_idx = 0 ? intr_idx :
-intr_idx - 1));
-   c.iqdroprss_to_iqesize = htons(FW_IQ_CMD_IQPCIECH(pi-tx_chan) |
-   FW_IQ_CMD_IQGTSMODE |
-   FW_IQ_CMD_IQINTCNTTHRESH(iq-pktcnt_idx) |
-   FW_IQ_CMD_IQESIZE(ilog2(iq-iqe_len) - 4));
+   c.iqdroprss_to_iqesize = htons(FW_IQ_CMD_IQPCIECH_V(pi-tx_chan) |
+   FW_IQ_CMD_IQGTSMODE_F |
+   FW_IQ_CMD_IQINTCNTTHRESH_V(iq-pktcnt_idx) |
+   FW_IQ_CMD_IQESIZE_V(ilog2(iq-iqe_len) - 4));
c.iqsize = htons(iq-size);
c.iqaddr = cpu_to_be64(iq-phys_addr);
 
@@ -2323,12 +2323,12 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct 
sge_rspq *iq, bool fwevtq,
goto fl_nomem;
 
flsz = fl-size / 8 + s-stat_len / sizeof(struct tx_desc);
-   c.iqns_to_fl0congen = htonl(FW_IQ_CMD_FL0PACKEN(1) |
-   FW_IQ_CMD_FL0FETCHRO(1) |
-   FW_IQ_CMD_FL0DATARO(1) |
-   FW_IQ_CMD_FL0PADEN(1));
-   c.fl0dcaen_to_fl0cidxfthresh = htons(FW_IQ_CMD_FL0FBMIN(2) |
-   FW_IQ_CMD_FL0FBMAX(3));
+   c.iqns_to_fl0congen = htonl(FW_IQ_CMD_FL0PACKEN_F |
+   FW_IQ_CMD_FL0FETCHRO_F |
+   FW_IQ_CMD_FL0DATARO_F |
+   FW_IQ_CMD_FL0PADEN_F);
+   c.fl0dcaen_to_fl0cidxfthresh = htons(FW_IQ_CMD_FL0FBMIN_V(2) |
+   FW_IQ_CMD_FL0FBMAX_V(3));
c.fl0size = htons(flsz);
c.fl0addr = cpu_to_be64(fl-addr);
}
@@ -2425,19 +2425,20 @@ int t4_sge_alloc_eth_txq(struct adapter *adap, struct 
sge_eth_txq *txq,
memset(c, 0, sizeof(c));
c.op_to_vfn = htonl(FW_CMD_OP_V(FW_EQ_ETH_CMD) | FW_CMD_REQUEST_F |
FW_CMD_WRITE_F | FW_CMD_EXEC_F |
-   FW_EQ_ETH_CMD_PFN(adap-fn) | FW_EQ_ETH_CMD_VFN(0));
-   c.alloc_to_len16 = htonl(FW_EQ_ETH_CMD_ALLOC |
-FW_EQ_ETH_CMD_EQSTART | FW_LEN16(c));
-   c.viid_pkd = htonl(FW_EQ_ETH_CMD_AUTOEQUEQE |
-  FW_EQ_ETH_CMD_VIID(pi-viid));
-   c.fetchszm_to_iqid = htonl(FW_EQ_ETH_CMD_HOSTFCMODE(2) |
-  FW_EQ_ETH_CMD_PCIECHN(pi-tx_chan) |
-  FW_EQ_ETH_CMD_FETCHRO(1) |
-  FW_EQ_ETH_CMD_IQID(iqid));
-   c.dcaen_to_eqsize = htonl(FW_EQ_ETH_CMD_FBMIN(2) |
- FW_EQ_ETH_CMD_FBMAX(3) |
- FW_EQ_ETH_CMD_CIDXFTHRESH(5) |
- FW_EQ_ETH_CMD_EQSIZE(nentries));
+   FW_EQ_ETH_CMD_PFN_V(adap-fn) |
+   FW_EQ_ETH_CMD_VFN_V(0

[PATCH net-next 4/5] cxgb4/cxgb4vf/csiostor: Cleanup macros/register defines related to port and VI

2014-11-20 Thread Hariprasad Shenai
This patch cleanups all port and VI related macros/register defines that are
defined in t4fw_api.h and the affected files.

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c  |   14 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h  |4 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |8 +-
 drivers/net/ethernet/chelsio/cxgb4/l2t.c|4 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c  |  106 
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h   |  350 ---
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c  |  100 
 drivers/scsi/csiostor/csio_mb.c |   20 +-
 8 files changed, 374 insertions(+), 232 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
index cca6049..6c1c5dc 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
@@ -243,7 +243,7 @@ void cxgb4_dcb_handle_fw_update(struct adapter *adap,
const struct fw_port_cmd *pcmd)
 {
const union fw_port_dcb *fwdcb = pcmd-u.dcb;
-   int port = FW_PORT_CMD_PORTID_GET(be32_to_cpu(pcmd-op_to_portid));
+   int port = FW_PORT_CMD_PORTID_G(be32_to_cpu(pcmd-op_to_portid));
struct net_device *dev = adap-port[port];
struct port_info *pi = netdev_priv(dev);
struct port_dcb_info *dcb = pi-dcb;
@@ -256,12 +256,12 @@ void cxgb4_dcb_handle_fw_update(struct adapter *adap,
if (dcb_type == FW_PORT_DCB_TYPE_CONTROL) {
enum cxgb4_dcb_state_input input =
((pcmd-u.dcb.control.all_syncd_pkd 
- FW_PORT_CMD_ALL_SYNCD)
+ FW_PORT_CMD_ALL_SYNCD_F)
 ? CXGB4_DCB_STATE_FW_ALLSYNCED
 : CXGB4_DCB_STATE_FW_INCOMPLETE);
 
if (dcb-dcb_version != FW_PORT_DCB_VER_UNKNOWN) {
-   dcb_running_version = FW_PORT_CMD_DCB_VERSION_GET(
+   dcb_running_version = FW_PORT_CMD_DCB_VERSION_G(
be16_to_cpu(
pcmd-u.dcb.control.dcb_version_to_app_state));
if (dcb_running_version == FW_PORT_DCB_VER_CEE1D01 ||
@@ -519,7 +519,7 @@ static void cxgb4_setpgtccfg_tx(struct net_device *dev, int 
tc,
 
INIT_PORT_DCB_WRITE_CMD(pcmd, pi-port_id);
if (pi-dcb.state == CXGB4_DCB_STATE_HOST)
-   pcmd.op_to_portid |= cpu_to_be32(FW_PORT_CMD_APPLY);
+   pcmd.op_to_portid |= cpu_to_be32(FW_PORT_CMD_APPLY_F);
 
err = t4_wr_mbox(adap, adap-mbox, pcmd, sizeof(pcmd), pcmd);
if (err != FW_PORT_DCB_CFG_SUCCESS)
@@ -583,7 +583,7 @@ static void cxgb4_setpgbwgcfg_tx(struct net_device *dev, 
int pgid,
 
INIT_PORT_DCB_WRITE_CMD(pcmd, pi-port_id);
if (pi-dcb.state == CXGB4_DCB_STATE_HOST)
-   pcmd.op_to_portid |= cpu_to_be32(FW_PORT_CMD_APPLY);
+   pcmd.op_to_portid |= cpu_to_be32(FW_PORT_CMD_APPLY_F);
 
err = t4_wr_mbox(adap, adap-mbox, pcmd, sizeof(pcmd), pcmd);
 
@@ -623,7 +623,7 @@ static void cxgb4_setpfccfg(struct net_device *dev, int 
priority, u8 pfccfg)
 
INIT_PORT_DCB_WRITE_CMD(pcmd, pi-port_id);
if (pi-dcb.state == CXGB4_DCB_STATE_HOST)
-   pcmd.op_to_portid |= cpu_to_be32(FW_PORT_CMD_APPLY);
+   pcmd.op_to_portid |= cpu_to_be32(FW_PORT_CMD_APPLY_F);
 
pcmd.u.dcb.pfc.type = FW_PORT_DCB_TYPE_PFC;
pcmd.u.dcb.pfc.pfcen = pi-dcb.pfcen;
@@ -842,7 +842,7 @@ static int __cxgb4_setapp(struct net_device *dev, u8 
app_idtype, u16 app_id,
/* write out new app table entry */
INIT_PORT_DCB_WRITE_CMD(pcmd, pi-port_id);
if (pi-dcb.state == CXGB4_DCB_STATE_HOST)
-   pcmd.op_to_portid |= cpu_to_be32(FW_PORT_CMD_APPLY);
+   pcmd.op_to_portid |= cpu_to_be32(FW_PORT_CMD_APPLY_F);
 
pcmd.u.dcb.app_priority.type = FW_PORT_DCB_TYPE_APP_ID;
pcmd.u.dcb.app_priority.protocolid = cpu_to_be16(app_id);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h
index c0724a5..31ce425 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h
@@ -45,9 +45,9 @@
cpu_to_be32(FW_CMD_OP_V(FW_PORT_CMD) | \
FW_CMD_REQUEST_F | \
FW_CMD_##__op##_F | \
-   FW_PORT_CMD_PORTID(__port)); \
+   FW_PORT_CMD_PORTID_V(__port)); \
(__pcmd).action_to_len16 = \
-   cpu_to_be32(FW_PORT_CMD_ACTION(__action) | \
+   cpu_to_be32(FW_PORT_CMD_ACTION_V(__action) | \
FW_LEN16(pcmd)); \
} while (0)
 
diff

[PATCH 2/2] rping: ignore flushed completions

2014-11-06 Thread Hariprasad Shenai
Based on original work by Steve Wise st...@opengridcomputing.com

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 examples/rping.c |   15 ++-
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/examples/rping.c b/examples/rping.c
index f0414de..58b642e 100644
--- a/examples/rping.c
+++ b/examples/rping.c
@@ -277,15 +277,20 @@ static int rping_cq_event_handler(struct rping_cb *cb)
struct ibv_wc wc;
struct ibv_recv_wr *bad_wr;
int ret;
+   int flushed = 0;
 
while ((ret = ibv_poll_cq(cb-cq, 1, wc)) == 1) {
ret = 0;
 
if (wc.status) {
-   if (wc.status != IBV_WC_WR_FLUSH_ERR)
-   fprintf(stderr,
-   cq completion failed status %d\n,
-   wc.status);
+   if (wc.status == IBV_WC_WR_FLUSH_ERR) {
+   flushed = 1;
+   continue;
+
+   }
+   fprintf(stderr,
+   cq completion failed status %d\n,
+   wc.status);
ret = -1;
goto error;
}
@@ -334,7 +339,7 @@ static int rping_cq_event_handler(struct rping_cb *cb)
fprintf(stderr, poll error %d\n, ret);
goto error;
}
-   return 0;
+   return flushed;
 
 error:
cb-state = ERROR;
-- 
1.7.1

--
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


[PATCH 1/2] rping: Fixes race, where ibv context was getting freed before memory was deregistered

2014-11-06 Thread Hariprasad Shenai
While running rping as a client without server on the other end, 
rping_test_client fails
and the ibv context was getting freed before memory was deregistered. This 
patch fixes it.

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 examples/rping.c |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/examples/rping.c b/examples/rping.c
index 949cbe6..f0414de 100644
--- a/examples/rping.c
+++ b/examples/rping.c
@@ -1055,18 +1055,19 @@ static int rping_run_client(struct rping_cb *cb)
ret = rping_connect_client(cb);
if (ret) {
fprintf(stderr, connect error %d\n, ret);
-   goto err2;
+   goto err3;
}
 
ret = rping_test_client(cb);
if (ret) {
fprintf(stderr, rping client failed: %d\n, ret);
-   goto err3;
+   goto err4;
}
 
ret = 0;
-err3:
+err4:
rdma_disconnect(cb-cm_id);
+err3:
pthread_join(cb-cqthread, NULL);
 err2:
rping_free_buffers(cb);
-- 
1.7.1

--
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


[PATCHv3 net-next 0/3] RDMA/cxgb4,cxgb4vf,cxgb4i,csiostor: Cleanup macros

2014-11-06 Thread Hariprasad Shenai
Hi,

This series moves the debugfs code to a new file debugfs.c and cleans up
macros/register defines.

Various patches have ended up changing the style of the symbolic macros/register
defines and some of them used the macros/register defines that matches the
output of the script from the hardware team.

As a result, the current kernel.org files are a mix of different macro styles.
Since this macro/register defines is used by five different drivers, a
few patch series have ended up adding duplicate macro/register define entries
with different styles. This makes these register define/macro files a complete
mess and we want to make them clean and consistent.

Will post few more series so that we can cover all the macros so that they all
follow the same style to be consistent.

The patches series is created against 'net-next' tree.
And includes patches on cxgb4, cxgb4vf, iw_cxgb4, csiostor and cxgb4i driver.

We have included all the maintainers of respective drivers. Kindly review the
change and let us know in case of any review comments.

Thanks

V3: Use suffix instead of prefix for macros/register defines
V2: Changes the description and cover-letter content to answer David Miller's
question

Hariprasad Shenai (3):
  cxgb4: Add cxgb4_debugfs.c, move all debugfs code to new file
  cxgb4: Cleanup macros so they follow the same style and look
consistent
  cxgb4: Cleanup macros so they follow the same style and look
consistent, part 2

 drivers/infiniband/hw/cxgb4/cm.c   |   56 +++---
 drivers/infiniband/hw/cxgb4/cq.c   |8 +-
 drivers/infiniband/hw/cxgb4/mem.c  |   14 +-
 drivers/infiniband/hw/cxgb4/qp.c   |   26 ++--
 drivers/net/ethernet/chelsio/cxgb4/Makefile|1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |3 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h |6 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c |  158 ++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.h |   52 ++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|  173 +---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h |   15 +-
 drivers/net/ethernet/chelsio/cxgb4/sge.c   |   32 ++--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |  127 +++---
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h   |   72 +++--
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h  |  142 
 drivers/net/ethernet/chelsio/cxgb4vf/sge.c |   32 ++--
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h |2 +-
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c |  150 +-
 drivers/scsi/csiostor/csio_attr.c  |8 +-
 drivers/scsi/csiostor/csio_hw.c|   14 +-
 drivers/scsi/csiostor/csio_hw_t4.c |   15 +-
 drivers/scsi/csiostor/csio_hw_t5.c |   21 ++-
 drivers/scsi/csiostor/csio_init.c  |6 +-
 drivers/scsi/csiostor/csio_lnode.c |   18 +-
 drivers/scsi/csiostor/csio_mb.c|  172 ++--
 drivers/scsi/csiostor/csio_scsi.c  |   24 ++--
 drivers/scsi/csiostor/csio_wr.h|2 +-
 drivers/scsi/cxgbi/cxgb4i/cxgb4i.c |   35 ++--
 28 files changed, 816 insertions(+), 568 deletions(-)
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.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


[PATCHv3 net-next 1/3] cxgb4: Add cxgb4_debugfs.c, move all debugfs code to new file

2014-11-06 Thread Hariprasad Shenai
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/net/ethernet/chelsio/cxgb4/Makefile|1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c |  158 
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.h |   52 +++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|   97 +
 5 files changed, 217 insertions(+), 92 deletions(-)
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.h

diff --git a/drivers/net/ethernet/chelsio/cxgb4/Makefile 
b/drivers/net/ethernet/chelsio/cxgb4/Makefile
index 1df65c9..b852807 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/Makefile
+++ b/drivers/net/ethernet/chelsio/cxgb4/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_CHELSIO_T4) += cxgb4.o
 
 cxgb4-objs := cxgb4_main.o l2t.o t4_hw.o sge.o
 cxgb4-$(CONFIG_CHELSIO_T4_DCB) +=  cxgb4_dcb.o
+cxgb4-$(CONFIG_DEBUG_FS) += cxgb4_debugfs.o
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 3c481b2..dad1ea9 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -1085,4 +1085,5 @@ void t4_db_dropped(struct adapter *adapter);
 int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox,
 u32 addr, u32 val);
 void t4_sge_decode_idma_state(struct adapter *adapter, int state);
+void t4_free_mem(void *addr);
 #endif /* __CXGB4_H__ */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
new file mode 100644
index 000..e86b5fe
--- /dev/null
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -0,0 +1,158 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2014 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *  - Redistributions of source code must retain the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer.
+ *
+ *  - Redistributions in binary form must reproduce the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer in the documentation and/or other materials
+ *provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include linux/seq_file.h
+#include linux/debugfs.h
+#include linux/string_helpers.h
+#include linux/sort.h
+
+#include cxgb4.h
+#include t4_regs.h
+#include t4fw_api.h
+#include cxgb4_debugfs.h
+#include l2t.h
+
+static ssize_t mem_read(struct file *file, char __user *buf, size_t count,
+   loff_t *ppos)
+{
+   loff_t pos = *ppos;
+   loff_t avail = file_inode(file)-i_size;
+   unsigned int mem = (uintptr_t)file-private_data  3;
+   struct adapter *adap = file-private_data - mem;
+   __be32 *data;
+   int ret;
+
+   if (pos  0)
+   return -EINVAL;
+   if (pos = avail)
+   return 0;
+   if (count  avail - pos)
+   count = avail - pos;
+
+   data = t4_alloc_mem(count);
+   if (!data)
+   return -ENOMEM;
+
+   spin_lock(adap-win0_lock);
+   ret = t4_memory_rw(adap, 0, mem, pos, count, data, T4_MEMORY_READ);
+   spin_unlock(adap-win0_lock);
+   if (ret) {
+   t4_free_mem(data);
+   return ret;
+   }
+   ret = copy_to_user(buf, data, count);
+
+   t4_free_mem(data);
+   if (ret)
+   return -EFAULT;
+
+   *ppos = pos + count;
+   return count;
+}
+
+static const struct file_operations mem_debugfs_fops = {
+   .owner   = THIS_MODULE,
+   .open= simple_open,
+   .read= mem_read,
+   .llseek  = default_llseek,
+};
+
+static void add_debugfs_mem(struct adapter *adap, const char *name,
+   unsigned int idx, unsigned int size_mb)
+{
+   struct dentry *de;
+
+   de

[PATCHv3 net-next 2/3] cxgb4: Cleanup macros so they follow the same style and look consistent

2014-11-06 Thread Hariprasad Shenai
Various patches have ended up changing the style of the symbolic macros/register
to different style.

As a result, the current kernel.org files are a mix of different macro styles.
Since this macro/register defines is used by different drivers a
few patch series have ended up adding duplicate macro/register define entries
with different styles. This makes these register define/macro files a complete
mess and we want to make them clean and consistent. This patch cleans up a part
of it.

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c |   32 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|   16 +++--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |6 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h   |   72 +++-
 drivers/scsi/csiostor/csio_hw_t4.c |   15 ++--
 drivers/scsi/csiostor/csio_hw_t5.c |   21 +++---
 drivers/scsi/csiostor/csio_init.c  |6 +-
 7 files changed, 106 insertions(+), 62 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
index e86b5fe..c98a350 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -128,30 +128,30 @@ int t4_setup_debugfs(struct adapter *adap)
  t4_debugfs_files,
  ARRAY_SIZE(t4_debugfs_files));
 
-   i = t4_read_reg(adap, MA_TARGET_MEM_ENABLE);
-   if (i  EDRAM0_ENABLE) {
-   size = t4_read_reg(adap, MA_EDRAM0_BAR);
-   add_debugfs_mem(adap, edc0, MEM_EDC0, EDRAM_SIZE_GET(size));
+   i = t4_read_reg(adap, MA_TARGET_MEM_ENABLE_A);
+   if (i  EDRAM0_ENABLE_F) {
+   size = t4_read_reg(adap, MA_EDRAM0_BAR_A);
+   add_debugfs_mem(adap, edc0, MEM_EDC0, EDRAM0_SIZE_G(size));
}
-   if (i  EDRAM1_ENABLE) {
-   size = t4_read_reg(adap, MA_EDRAM1_BAR);
-   add_debugfs_mem(adap, edc1, MEM_EDC1, EDRAM_SIZE_GET(size));
+   if (i  EDRAM1_ENABLE_F) {
+   size = t4_read_reg(adap, MA_EDRAM1_BAR_A);
+   add_debugfs_mem(adap, edc1, MEM_EDC1, EDRAM1_SIZE_G(size));
}
if (is_t4(adap-params.chip)) {
-   size = t4_read_reg(adap, MA_EXT_MEMORY_BAR);
-   if (i  EXT_MEM_ENABLE)
+   size = t4_read_reg(adap, MA_EXT_MEMORY_BAR_A);
+   if (i  EXT_MEM_ENABLE_F)
add_debugfs_mem(adap, mc, MEM_MC,
-   EXT_MEM_SIZE_GET(size));
+   EXT_MEM_SIZE_G(size));
} else {
-   if (i  EXT_MEM_ENABLE) {
-   size = t4_read_reg(adap, MA_EXT_MEMORY_BAR);
+   if (i  EXT_MEM0_ENABLE_F) {
+   size = t4_read_reg(adap, MA_EXT_MEMORY0_BAR_A);
add_debugfs_mem(adap, mc0, MEM_MC0,
-   EXT_MEM_SIZE_GET(size));
+   EXT_MEM0_SIZE_G(size));
}
-   if (i  EXT_MEM1_ENABLE) {
-   size = t4_read_reg(adap, MA_EXT_MEMORY1_BAR);
+   if (i  EXT_MEM1_ENABLE_F) {
+   size = t4_read_reg(adap, MA_EXT_MEMORY1_BAR_A);
add_debugfs_mem(adap, mc1, MEM_MC1,
-   EXT_MEM_SIZE_GET(size));
+   EXT_MEM1_SIZE_G(size));
}
}
return 0;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 172f68b..a2d6e50 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3802,7 +3802,7 @@ int cxgb4_read_tpte(struct net_device *dev, u32 stag, 
__be32 *tpte)
 {
struct adapter *adap;
u32 offset, memtype, memaddr;
-   u32 edc0_size, edc1_size, mc0_size, mc1_size;
+   u32 edc0_size, edc1_size, mc0_size, mc1_size, size;
u32 edc0_end, edc1_end, mc0_end, mc1_end;
int ret;
 
@@ -3816,9 +3816,12 @@ int cxgb4_read_tpte(struct net_device *dev, u32 stag, 
__be32 *tpte)
 * and EDC1.  Some cards will have neither MC0 nor MC1, most cards have
 * MC0, and some have both MC0 and MC1.
 */
-   edc0_size = EDRAM_SIZE_GET(t4_read_reg(adap, MA_EDRAM0_BAR))  20;
-   edc1_size = EDRAM_SIZE_GET(t4_read_reg(adap, MA_EDRAM1_BAR))  20;
-   mc0_size = EXT_MEM_SIZE_GET(t4_read_reg(adap, MA_EXT_MEMORY_BAR))  20;
+   size = t4_read_reg(adap, MA_EDRAM0_BAR_A);
+   edc0_size = EDRAM0_SIZE_G(size)  20;
+   size = t4_read_reg(adap, MA_EDRAM1_BAR_A);
+   edc1_size = EDRAM1_SIZE_G(size)  20;
+   size = t4_read_reg(adap, MA_EXT_MEMORY0_BAR_A);
+   mc0_size = EXT_MEM0_SIZE_G(size)  20

[PATCHv3 net-next 3/3] cxgb4: Cleanup macros so they follow the same style and look consistent, part 2

2014-11-06 Thread Hariprasad Shenai
Various patches have ended up changing the style of the symbolic macros/register
defines to different style.

As a result, the current kernel.org files are a mix of different macro styles.
Since this macro/register defines is used by different drivers a
few patch series have ended up adding duplicate macro/register define entries
with different styles. This makes these register define/macro files a complete
mess and we want to make them clean and consistent. This patch cleans up a part
of it.

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c   |   56 
 drivers/infiniband/hw/cxgb4/cq.c   |8 +-
 drivers/infiniband/hw/cxgb4/mem.c  |   14 +-
 drivers/infiniband/hw/cxgb4/qp.c   |   26 ++--
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |2 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h |6 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|   60 
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h |   15 +-
 drivers/net/ethernet/chelsio/cxgb4/sge.c   |   32 ++--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |  121 +++---
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h  |  142 +
 drivers/net/ethernet/chelsio/cxgb4vf/sge.c |   32 ++--
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h |2 +-
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c |  150 +-
 drivers/scsi/csiostor/csio_attr.c  |8 +-
 drivers/scsi/csiostor/csio_hw.c|   14 +-
 drivers/scsi/csiostor/csio_lnode.c |   18 +-
 drivers/scsi/csiostor/csio_mb.c|  172 ++--
 drivers/scsi/csiostor/csio_scsi.c  |   24 ++--
 drivers/scsi/csiostor/csio_wr.h|2 +-
 drivers/scsi/cxgbi/cxgb4i/cxgb4i.c |   35 ++--
 21 files changed, 509 insertions(+), 430 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index fb61f66..a07d8e1 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -472,10 +472,10 @@ static void send_flowc(struct c4iw_ep *ep, struct sk_buff 
*skb)
skb = get_skb(skb, flowclen, GFP_KERNEL);
flowc = (struct fw_flowc_wr *)__skb_put(skb, flowclen);
 
-   flowc-op_to_nparams = cpu_to_be32(FW_WR_OP(FW_FLOWC_WR) |
-  FW_FLOWC_WR_NPARAMS(8));
-   flowc-flowid_len16 = cpu_to_be32(FW_WR_LEN16(DIV_ROUND_UP(flowclen,
- 16)) | FW_WR_FLOWID(ep-hwtid));
+   flowc-op_to_nparams = cpu_to_be32(FW_WR_OP_V(FW_FLOWC_WR) |
+  FW_FLOWC_WR_NPARAMS_V(8));
+   flowc-flowid_len16 = cpu_to_be32(FW_WR_LEN16_V(DIV_ROUND_UP(flowclen,
+ 16)) | FW_WR_FLOWID_V(ep-hwtid));
 
flowc-mnemval[0].mnemonic = FW_FLOWC_MNEM_PFNVFN;
flowc-mnemval[0].val = cpu_to_be32(FW_PFVF_CMD_PFN
@@ -803,16 +803,16 @@ static void send_mpa_req(struct c4iw_ep *ep, struct 
sk_buff *skb,
req = (struct fw_ofld_tx_data_wr *)skb_put(skb, wrlen);
memset(req, 0, wrlen);
req-op_to_immdlen = cpu_to_be32(
-   FW_WR_OP(FW_OFLD_TX_DATA_WR) |
-   FW_WR_COMPL(1) |
-   FW_WR_IMMDLEN(mpalen));
+   FW_WR_OP_V(FW_OFLD_TX_DATA_WR) |
+   FW_WR_COMPL_F |
+   FW_WR_IMMDLEN_V(mpalen));
req-flowid_len16 = cpu_to_be32(
-   FW_WR_FLOWID(ep-hwtid) |
-   FW_WR_LEN16(wrlen  4));
+   FW_WR_FLOWID_V(ep-hwtid) |
+   FW_WR_LEN16_V(wrlen  4));
req-plen = cpu_to_be32(mpalen);
req-tunnel_to_proxy = cpu_to_be32(
-   FW_OFLD_TX_DATA_WR_FLUSH(1) |
-   FW_OFLD_TX_DATA_WR_SHOVE(1));
+   FW_OFLD_TX_DATA_WR_FLUSH_F |
+   FW_OFLD_TX_DATA_WR_SHOVE_F);
 
mpa = (struct mpa_message *)(req + 1);
memcpy(mpa-key, MPA_KEY_REQ, sizeof(mpa-key));
@@ -897,16 +897,16 @@ static int send_mpa_reject(struct c4iw_ep *ep, const void 
*pdata, u8 plen)
req = (struct fw_ofld_tx_data_wr *)skb_put(skb, wrlen);
memset(req, 0, wrlen);
req-op_to_immdlen = cpu_to_be32(
-   FW_WR_OP(FW_OFLD_TX_DATA_WR) |
-   FW_WR_COMPL(1) |
-   FW_WR_IMMDLEN(mpalen));
+   FW_WR_OP_V(FW_OFLD_TX_DATA_WR) |
+   FW_WR_COMPL_F |
+   FW_WR_IMMDLEN_V(mpalen));
req-flowid_len16 = cpu_to_be32(
-   FW_WR_FLOWID(ep-hwtid) |
-   FW_WR_LEN16(wrlen  4));
+   FW_WR_FLOWID_V(ep-hwtid) |
+   FW_WR_LEN16_V(wrlen  4));
req-plen = cpu_to_be32(mpalen);
req-tunnel_to_proxy = cpu_to_be32(
-   FW_OFLD_TX_DATA_WR_FLUSH(1) |
-   FW_OFLD_TX_DATA_WR_SHOVE(1

[PATCH 1/2] iw_cxgb4: Fixes locking issue in process_mpa_request

2014-11-06 Thread Hariprasad Shenai
=
[ INFO: possible recursive locking detected ]
3.17.0+ #3 Tainted: GE
-
kworker/u64:3/299 is trying to acquire lock:
 (epc-mutex){+.+.+.}, at: [a074e07a]
process_mpa_request+0x1aa/0x3e0 [iw_cxgb4]

but task is already holding lock:
 (epc-mutex){+.+.+.}, at: [a074e34e] rx_data+0x9e/0x1f0 [iw_cxgb4]

other info that might help us debug this:
 Possible unsafe locking scenario:

   CPU0
   
  lock(epc-mutex);
  lock(epc-mutex);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

3 locks held by kworker/u64:3/299:
 #0:  (%siw_cxgb4){.+.+.+}, at: [8106f14d]
process_one_work+0x13d/0x4d0
 #1:  (skb_work){+.+.+.}, at: [8106f14d] process_one_work+0x13d/0x4d0
 #2:  (epc-mutex){+.+.+.}, at: [a074e34e] rx_data+0x9e/0x1f0
[iw_cxgb4]

stack backtrace:
CPU: 2 PID: 299 Comm: kworker/u64:3 Tainted: GE  3.17.0+ #3
Hardware name: Dell Inc. PowerEdge T110/0X744K, BIOS 1.2.1 01/28/2010
Workqueue: iw_cxgb4 process_work [iw_cxgb4]
 8800b91593d0 8800b8a2f9f8 815df107 0001
 8800b9158750 8800b8a2fa28 8109f0e2 8800bb768a00
 8800b91593d0 8800b9158750  8800b8a2fa88
Call Trace:
 [815df107] dump_stack+0x49/0x62
 [8109f0e2] print_deadlock_bug+0xf2/0x100
 [810a0f04] validate_chain+0x454/0x700
 [810a1574] __lock_acquire+0x3c4/0x580
 [a074e07a] ? process_mpa_request+0x1aa/0x3e0 [iw_cxgb4]
 [810a17cc] lock_acquire+0x9c/0x110
 [a074e07a] ? process_mpa_request+0x1aa/0x3e0 [iw_cxgb4]
 [815e111b] mutex_lock_nested+0x4b/0x360
 [a074e07a] ? process_mpa_request+0x1aa/0x3e0 [iw_cxgb4]
 [810c181a] ? del_timer_sync+0xaa/0xd0
 [810c1770] ? try_to_del_timer_sync+0x70/0x70
 [a074e07a] process_mpa_request+0x1aa/0x3e0 [iw_cxgb4]
 [a074a3ec] ? update_rx_credits+0xec/0x140 [iw_cxgb4]
 [a074e381] rx_data+0xd1/0x1f0 [iw_cxgb4]
 [8109ff23] ? mark_held_locks+0x73/0xa0
 [815e4b90] ? _raw_spin_unlock_irqrestore+0x40/0x70
 [810a020d] ? trace_hardirqs_on_caller+0xfd/0x1c0
 [810a02dd] ? trace_hardirqs_on+0xd/0x10
 [a074c931] process_work+0x51/0x80 [iw_cxgb4]
 [8106f1c8] process_one_work+0x1b8/0x4d0
 [8106f14d] ? process_one_work+0x13d/0x4d0
 [8106f600] worker_thread+0x120/0x3c0
 [8106f4e0] ? process_one_work+0x4d0/0x4d0
 [81074a0e] kthread+0xde/0x100
 [815e4b40] ? _raw_spin_unlock_irq+0x30/0x40
 [81074930] ? __init_kthread_worker+0x70/0x70
 [815e512c] ret_from_fork+0x7c/0xb0
 [81074930] ? __init_kthread_worker+0x70/0x70
===

Based on original work by Steve Wise sw...@opengridcomputing.com

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index fb61f66..ce87fd3 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -1640,7 +1640,8 @@ static void process_mpa_request(struct c4iw_ep *ep, 
struct sk_buff *skb)
__state_set(ep-com, MPA_REQ_RCVD);
 
/* drive upcall */
-   mutex_lock(ep-parent_ep-com.mutex);
+   mutex_lock_nested(ep-parent_ep-com.mutex,
+ SINGLE_DEPTH_NESTING);
if (ep-parent_ep-com.state != DEAD) {
if (connect_request_upcall(ep))
abort_connection(ep, skb, GFP_KERNEL);
-- 
1.7.1

--
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


[PATCH 0/2] iw_cxgb4: Fixes locking issue and MR limit for T4/T5 adapter

2014-11-06 Thread Hariprasad Shenai
Hi, 

This patch series fixes a lock issue and limit MR's to 8 Gb for Chelsio T4/T5
adapter.

The patches series is created against 'infiniband' tree.
And includes patches on iw_cxgb4 driver.

We have included all the maintainers of respective drivers. Kindly review the
change and let us know in case of any review comments.

Thanks

Hariprasad Shenai (2):
  iw_cxgb4: Fixes locking issue in process_mpa_request
  iw_cxgb4: limit MRs to  8GB for T4/T5 devices

 drivers/infiniband/hw/cxgb4/cm.c  |3 ++-
 drivers/infiniband/hw/cxgb4/mem.c |   22 ++
 2 files changed, 24 insertions(+), 1 deletions(-)

--
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


[PATCH 2/2] iw_cxgb4: limit MRs to 8GB for T4/T5 devices

2014-11-06 Thread Hariprasad Shenai
T4/T5 hardware can't handle MRs = 8GB due to a hardware bug.  So limit
registrations to  8GB for thse devices.

Based on original work by Steve Wise sw...@opengridcomputing.com

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/mem.c |   22 ++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/mem.c 
b/drivers/infiniband/hw/cxgb4/mem.c
index ec7a298..d5dd3f2 100644
--- a/drivers/infiniband/hw/cxgb4/mem.c
+++ b/drivers/infiniband/hw/cxgb4/mem.c
@@ -50,6 +50,13 @@ static int inline_threshold = C4IW_INLINE_THRESHOLD;
 module_param(inline_threshold, int, 0644);
 MODULE_PARM_DESC(inline_threshold, inline vs dsgl threshold (default=128));
 
+static int mr_exceeds_hw_limits(struct c4iw_dev *dev, u64 length)
+{
+   return (is_t4(dev-rdev.lldi.adapter_type) ||
+   is_t5(dev-rdev.lldi.adapter_type)) 
+   length = 8*1024*1024*1024ULL;
+}
+
 static int _c4iw_write_mem_dma_aligned(struct c4iw_rdev *rdev, u32 addr,
   u32 len, dma_addr_t data, int wait)
 {
@@ -536,6 +543,11 @@ int c4iw_reregister_phys_mem(struct ib_mr *mr, int 
mr_rereg_mask,
return ret;
}
 
+   if (mr_exceeds_hw_limits(rhp, total_size)) {
+   kfree(page_list);
+   return -EINVAL;
+   }
+
ret = reregister_mem(rhp, php, mh, shift, npages);
kfree(page_list);
if (ret)
@@ -596,6 +608,12 @@ struct ib_mr *c4iw_register_phys_mem(struct ib_pd *pd,
if (ret)
goto err;
 
+   if (mr_exceeds_hw_limits(rhp, total_size)) {
+   kfree(page_list);
+   ret = -EINVAL;
+   goto err;
+   }
+
ret = alloc_pbl(mhp, npages);
if (ret) {
kfree(page_list);
@@ -699,6 +717,10 @@ struct ib_mr *c4iw_reg_user_mr(struct ib_pd *pd, u64 
start, u64 length,
 
php = to_c4iw_pd(pd);
rhp = php-rhp;
+
+   if (mr_exceeds_hw_limits(rhp, length))
+   return ERR_PTR(-EINVAL);
+
mhp = kzalloc(sizeof(*mhp), GFP_KERNEL);
if (!mhp)
return ERR_PTR(-ENOMEM);
-- 
1.7.1

--
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


[PATCH net-next 2/3] cxgb4: Cleanup macros to match the HW generated one

2014-11-03 Thread Hariprasad Shenai
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c |   32 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|   16 +++--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |6 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h   |   72 +++-
 drivers/scsi/csiostor/csio_hw_t4.c |   15 ++--
 drivers/scsi/csiostor/csio_hw_t5.c |   21 +++---
 drivers/scsi/csiostor/csio_init.c  |6 +-
 7 files changed, 106 insertions(+), 62 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
index e86b5fe..aa75c91 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -128,30 +128,30 @@ int t4_setup_debugfs(struct adapter *adap)
  t4_debugfs_files,
  ARRAY_SIZE(t4_debugfs_files));
 
-   i = t4_read_reg(adap, MA_TARGET_MEM_ENABLE);
-   if (i  EDRAM0_ENABLE) {
-   size = t4_read_reg(adap, MA_EDRAM0_BAR);
-   add_debugfs_mem(adap, edc0, MEM_EDC0, EDRAM_SIZE_GET(size));
+   i = t4_read_reg(adap, A_MA_TARGET_MEM_ENABLE);
+   if (i  F_EDRAM0_ENABLE) {
+   size = t4_read_reg(adap, A_MA_EDRAM0_BAR);
+   add_debugfs_mem(adap, edc0, MEM_EDC0, G_EDRAM0_SIZE(size));
}
-   if (i  EDRAM1_ENABLE) {
-   size = t4_read_reg(adap, MA_EDRAM1_BAR);
-   add_debugfs_mem(adap, edc1, MEM_EDC1, EDRAM_SIZE_GET(size));
+   if (i  F_EDRAM1_ENABLE) {
+   size = t4_read_reg(adap, A_MA_EDRAM1_BAR);
+   add_debugfs_mem(adap, edc1, MEM_EDC1, G_EDRAM1_SIZE(size));
}
if (is_t4(adap-params.chip)) {
-   size = t4_read_reg(adap, MA_EXT_MEMORY_BAR);
-   if (i  EXT_MEM_ENABLE)
+   size = t4_read_reg(adap, A_MA_EXT_MEMORY_BAR);
+   if (i  F_EXT_MEM_ENABLE)
add_debugfs_mem(adap, mc, MEM_MC,
-   EXT_MEM_SIZE_GET(size));
+   G_EXT_MEM_SIZE(size));
} else {
-   if (i  EXT_MEM_ENABLE) {
-   size = t4_read_reg(adap, MA_EXT_MEMORY_BAR);
+   if (i  F_EXT_MEM0_ENABLE) {
+   size = t4_read_reg(adap, A_MA_EXT_MEMORY0_BAR);
add_debugfs_mem(adap, mc0, MEM_MC0,
-   EXT_MEM_SIZE_GET(size));
+   G_EXT_MEM0_SIZE(size));
}
-   if (i  EXT_MEM1_ENABLE) {
-   size = t4_read_reg(adap, MA_EXT_MEMORY1_BAR);
+   if (i  F_EXT_MEM1_ENABLE) {
+   size = t4_read_reg(adap, A_MA_EXT_MEMORY1_BAR);
add_debugfs_mem(adap, mc1, MEM_MC1,
-   EXT_MEM_SIZE_GET(size));
+   G_EXT_MEM1_SIZE(size));
}
}
return 0;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 172f68b..65ce937 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3802,7 +3802,7 @@ int cxgb4_read_tpte(struct net_device *dev, u32 stag, 
__be32 *tpte)
 {
struct adapter *adap;
u32 offset, memtype, memaddr;
-   u32 edc0_size, edc1_size, mc0_size, mc1_size;
+   u32 edc0_size, edc1_size, mc0_size, mc1_size, size;
u32 edc0_end, edc1_end, mc0_end, mc1_end;
int ret;
 
@@ -3816,9 +3816,12 @@ int cxgb4_read_tpte(struct net_device *dev, u32 stag, 
__be32 *tpte)
 * and EDC1.  Some cards will have neither MC0 nor MC1, most cards have
 * MC0, and some have both MC0 and MC1.
 */
-   edc0_size = EDRAM_SIZE_GET(t4_read_reg(adap, MA_EDRAM0_BAR))  20;
-   edc1_size = EDRAM_SIZE_GET(t4_read_reg(adap, MA_EDRAM1_BAR))  20;
-   mc0_size = EXT_MEM_SIZE_GET(t4_read_reg(adap, MA_EXT_MEMORY_BAR))  20;
+   size = t4_read_reg(adap, A_MA_EDRAM0_BAR);
+   edc0_size = G_EDRAM0_SIZE(size)  20;
+   size = t4_read_reg(adap, A_MA_EDRAM1_BAR);
+   edc1_size = G_EDRAM1_SIZE(size)  20;
+   size = t4_read_reg(adap, A_MA_EXT_MEMORY0_BAR);
+   mc0_size = G_EXT_MEM0_SIZE(size)  20;
 
edc0_end = edc0_size;
edc1_end = edc0_end + edc1_size;
@@ -3838,9 +3841,8 @@ int cxgb4_read_tpte(struct net_device *dev, u32 stag, 
__be32 *tpte)
/* T4 only has a single memory channel */
goto err;
} else {
-   mc1_size = EXT_MEM_SIZE_GET(
-   t4_read_reg(adap,
-   MA_EXT_MEMORY1_BAR))  20

[PATCH net-next 1/3] cxgb4: Add cxgb4_debugfs.c, move all debugfs code to new file

2014-11-03 Thread Hariprasad Shenai
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/net/ethernet/chelsio/cxgb4/Makefile|1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c |  158 
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.h |   52 +++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|   97 +
 5 files changed, 217 insertions(+), 92 deletions(-)
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.h

diff --git a/drivers/net/ethernet/chelsio/cxgb4/Makefile 
b/drivers/net/ethernet/chelsio/cxgb4/Makefile
index 1df65c9..b852807 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/Makefile
+++ b/drivers/net/ethernet/chelsio/cxgb4/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_CHELSIO_T4) += cxgb4.o
 
 cxgb4-objs := cxgb4_main.o l2t.o t4_hw.o sge.o
 cxgb4-$(CONFIG_CHELSIO_T4_DCB) +=  cxgb4_dcb.o
+cxgb4-$(CONFIG_DEBUG_FS) += cxgb4_debugfs.o
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 3c481b2..dad1ea9 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -1085,4 +1085,5 @@ void t4_db_dropped(struct adapter *adapter);
 int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox,
 u32 addr, u32 val);
 void t4_sge_decode_idma_state(struct adapter *adapter, int state);
+void t4_free_mem(void *addr);
 #endif /* __CXGB4_H__ */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
new file mode 100644
index 000..e86b5fe
--- /dev/null
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -0,0 +1,158 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2014 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *  - Redistributions of source code must retain the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer.
+ *
+ *  - Redistributions in binary form must reproduce the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer in the documentation and/or other materials
+ *provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include linux/seq_file.h
+#include linux/debugfs.h
+#include linux/string_helpers.h
+#include linux/sort.h
+
+#include cxgb4.h
+#include t4_regs.h
+#include t4fw_api.h
+#include cxgb4_debugfs.h
+#include l2t.h
+
+static ssize_t mem_read(struct file *file, char __user *buf, size_t count,
+   loff_t *ppos)
+{
+   loff_t pos = *ppos;
+   loff_t avail = file_inode(file)-i_size;
+   unsigned int mem = (uintptr_t)file-private_data  3;
+   struct adapter *adap = file-private_data - mem;
+   __be32 *data;
+   int ret;
+
+   if (pos  0)
+   return -EINVAL;
+   if (pos = avail)
+   return 0;
+   if (count  avail - pos)
+   count = avail - pos;
+
+   data = t4_alloc_mem(count);
+   if (!data)
+   return -ENOMEM;
+
+   spin_lock(adap-win0_lock);
+   ret = t4_memory_rw(adap, 0, mem, pos, count, data, T4_MEMORY_READ);
+   spin_unlock(adap-win0_lock);
+   if (ret) {
+   t4_free_mem(data);
+   return ret;
+   }
+   ret = copy_to_user(buf, data, count);
+
+   t4_free_mem(data);
+   if (ret)
+   return -EFAULT;
+
+   *ppos = pos + count;
+   return count;
+}
+
+static const struct file_operations mem_debugfs_fops = {
+   .owner   = THIS_MODULE,
+   .open= simple_open,
+   .read= mem_read,
+   .llseek  = default_llseek,
+};
+
+static void add_debugfs_mem(struct adapter *adap, const char *name,
+   unsigned int idx, unsigned int size_mb)
+{
+   struct dentry *de;
+
+   de

[PATCH net-next 0/3] RDMA/cxgb4,cxgb4vf,cxgb4i,csiostor: Cleanup macros

2014-11-03 Thread Hariprasad Shenai
Hi,

This series moves the debugfs code to a new file debugfs.c, Cleans up macros so
that they match the hardware generated one.

Will post few more series so that we can cover all the macros so that they all
follow the same conventions and looks clean.

The patches series is created against 'net-next' tree.
And includes patches on cxgb4, cxgb4vf, iw_cxgb4, csiostor and cxgb4i driver.

We have included all the maintainers of respective drivers. Kindly review the
change and let us know in case of any review comments.

Thanks

Hariprasad Shenai (3):
  cxgb4: Add cxgb4_debugfs.c, move all debugfs code to new file
  cxgb4: Cleanup macros to match the HW generated one
  cxgb4: Cleanup macros to match the HW generated one, part 2

 drivers/infiniband/hw/cxgb4/cm.c   |   56 +++---
 drivers/infiniband/hw/cxgb4/cq.c   |8 +-
 drivers/infiniband/hw/cxgb4/mem.c  |   14 +-
 drivers/infiniband/hw/cxgb4/qp.c   |   26 ++--
 drivers/net/ethernet/chelsio/cxgb4/Makefile|1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |3 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h |6 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c |  158 ++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.h |   52 ++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|  173 +---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h |   15 +-
 drivers/net/ethernet/chelsio/cxgb4/sge.c   |   32 ++--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |  127 +++---
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h   |   72 +++--
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h  |  142 
 drivers/net/ethernet/chelsio/cxgb4vf/sge.c |   32 ++--
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h |2 +-
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c |  150 +-
 drivers/scsi/csiostor/csio_attr.c  |8 +-
 drivers/scsi/csiostor/csio_hw.c|   14 +-
 drivers/scsi/csiostor/csio_hw_t4.c |   15 +-
 drivers/scsi/csiostor/csio_hw_t5.c |   21 ++-
 drivers/scsi/csiostor/csio_init.c  |6 +-
 drivers/scsi/csiostor/csio_lnode.c |   18 +-
 drivers/scsi/csiostor/csio_mb.c|  172 ++--
 drivers/scsi/csiostor/csio_scsi.c  |   24 ++--
 drivers/scsi/csiostor/csio_wr.h|2 +-
 drivers/scsi/cxgbi/cxgb4i/cxgb4i.c |   35 ++--
 28 files changed, 816 insertions(+), 568 deletions(-)
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.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


[PATCH net-next 3/3] cxgb4: Cleanup macros to match the HW generated one, part 2

2014-11-03 Thread Hariprasad Shenai
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c   |   56 
 drivers/infiniband/hw/cxgb4/cq.c   |8 +-
 drivers/infiniband/hw/cxgb4/mem.c  |   14 +-
 drivers/infiniband/hw/cxgb4/qp.c   |   26 ++--
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |2 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h |6 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|   60 
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h |   15 +-
 drivers/net/ethernet/chelsio/cxgb4/sge.c   |   32 ++--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |  121 +++---
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h  |  142 +
 drivers/net/ethernet/chelsio/cxgb4vf/sge.c |   32 ++--
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h |2 +-
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c |  150 +-
 drivers/scsi/csiostor/csio_attr.c  |8 +-
 drivers/scsi/csiostor/csio_hw.c|   14 +-
 drivers/scsi/csiostor/csio_lnode.c |   18 +-
 drivers/scsi/csiostor/csio_mb.c|  172 ++--
 drivers/scsi/csiostor/csio_scsi.c  |   24 ++--
 drivers/scsi/csiostor/csio_wr.h|2 +-
 drivers/scsi/cxgbi/cxgb4i/cxgb4i.c |   35 ++--
 21 files changed, 509 insertions(+), 430 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index fb61f66..5c0e3b9 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -472,10 +472,10 @@ static void send_flowc(struct c4iw_ep *ep, struct sk_buff 
*skb)
skb = get_skb(skb, flowclen, GFP_KERNEL);
flowc = (struct fw_flowc_wr *)__skb_put(skb, flowclen);
 
-   flowc-op_to_nparams = cpu_to_be32(FW_WR_OP(FW_FLOWC_WR) |
-  FW_FLOWC_WR_NPARAMS(8));
-   flowc-flowid_len16 = cpu_to_be32(FW_WR_LEN16(DIV_ROUND_UP(flowclen,
- 16)) | FW_WR_FLOWID(ep-hwtid));
+   flowc-op_to_nparams = cpu_to_be32(V_FW_WR_OP(FW_FLOWC_WR) |
+  V_FW_FLOWC_WR_NPARAMS(8));
+   flowc-flowid_len16 = cpu_to_be32(V_FW_WR_LEN16(DIV_ROUND_UP(flowclen,
+ 16)) | V_FW_WR_FLOWID(ep-hwtid));
 
flowc-mnemval[0].mnemonic = FW_FLOWC_MNEM_PFNVFN;
flowc-mnemval[0].val = cpu_to_be32(FW_PFVF_CMD_PFN
@@ -803,16 +803,16 @@ static void send_mpa_req(struct c4iw_ep *ep, struct 
sk_buff *skb,
req = (struct fw_ofld_tx_data_wr *)skb_put(skb, wrlen);
memset(req, 0, wrlen);
req-op_to_immdlen = cpu_to_be32(
-   FW_WR_OP(FW_OFLD_TX_DATA_WR) |
-   FW_WR_COMPL(1) |
-   FW_WR_IMMDLEN(mpalen));
+   V_FW_WR_OP(FW_OFLD_TX_DATA_WR) |
+   F_FW_WR_COMPL |
+   V_FW_WR_IMMDLEN(mpalen));
req-flowid_len16 = cpu_to_be32(
-   FW_WR_FLOWID(ep-hwtid) |
-   FW_WR_LEN16(wrlen  4));
+   V_FW_WR_FLOWID(ep-hwtid) |
+   V_FW_WR_LEN16(wrlen  4));
req-plen = cpu_to_be32(mpalen);
req-tunnel_to_proxy = cpu_to_be32(
-   FW_OFLD_TX_DATA_WR_FLUSH(1) |
-   FW_OFLD_TX_DATA_WR_SHOVE(1));
+   F_FW_OFLD_TX_DATA_WR_FLUSH |
+   F_FW_OFLD_TX_DATA_WR_SHOVE);
 
mpa = (struct mpa_message *)(req + 1);
memcpy(mpa-key, MPA_KEY_REQ, sizeof(mpa-key));
@@ -897,16 +897,16 @@ static int send_mpa_reject(struct c4iw_ep *ep, const void 
*pdata, u8 plen)
req = (struct fw_ofld_tx_data_wr *)skb_put(skb, wrlen);
memset(req, 0, wrlen);
req-op_to_immdlen = cpu_to_be32(
-   FW_WR_OP(FW_OFLD_TX_DATA_WR) |
-   FW_WR_COMPL(1) |
-   FW_WR_IMMDLEN(mpalen));
+   V_FW_WR_OP(FW_OFLD_TX_DATA_WR) |
+   F_FW_WR_COMPL |
+   V_FW_WR_IMMDLEN(mpalen));
req-flowid_len16 = cpu_to_be32(
-   FW_WR_FLOWID(ep-hwtid) |
-   FW_WR_LEN16(wrlen  4));
+   V_FW_WR_FLOWID(ep-hwtid) |
+   V_FW_WR_LEN16(wrlen  4));
req-plen = cpu_to_be32(mpalen);
req-tunnel_to_proxy = cpu_to_be32(
-   FW_OFLD_TX_DATA_WR_FLUSH(1) |
-   FW_OFLD_TX_DATA_WR_SHOVE(1));
+   F_FW_OFLD_TX_DATA_WR_FLUSH |
+   F_FW_OFLD_TX_DATA_WR_SHOVE);
 
mpa = (struct mpa_message *)(req + 1);
memset(mpa, 0, sizeof(*mpa));
@@ -977,16 +977,16 @@ static int send_mpa_reply(struct c4iw_ep *ep, const void 
*pdata, u8 plen)
req = (struct fw_ofld_tx_data_wr *) skb_put(skb, wrlen);
memset(req, 0, wrlen);
req-op_to_immdlen = cpu_to_be32(
-   FW_WR_OP(FW_OFLD_TX_DATA_WR) |
-   FW_WR_COMPL(1

[PATCHv2 net-next 0/3] RDMA/cxgb4,cxgb4vf,cxgb4i,csiostor: Cleanup macros

2014-11-03 Thread Hariprasad Shenai
Hi,

This series moves the debugfs code to a new file debugfs.c and cleans up
macros/register defines.

It's not really the hardware which generates these hardware constant symbolic
macros/register defines of course, it's scripts developed by the hardware team.
Various patches have ended up changing the style of the symbolic macros/register
defines and some of them used the macros/register defines that matches the
output of the script from the hardware team.

As a result, the current kernel.org files are a mix of different macro styles.
Since this macro/register defines is used by five different drivers, a
few patch series have ended up adding duplicate macro/register define entries
with different styles. This makes these register define/macro files a complete
mess and we want to make them clean and consistent.

Will post few more series so that we can cover all the macros so that they all
follow the same style to be consistent.

The patches series is created against 'net-next' tree.
And includes patches on cxgb4, cxgb4vf, iw_cxgb4, csiostor and cxgb4i driver.

We have included all the maintainers of respective drivers. Kindly review the
change and let us know in case of any review comments.

Thanks

V2: Changes the description and cover-letter content to answer David Miller's
question

Hariprasad Shenai (3):
  cxgb4: Add cxgb4_debugfs.c, move all debugfs code to new file
  cxgb4: Cleanup macros so they follow the same style and look
consistent
  cxgb4: Cleanup macros so they follow the same style and look
consistent, part 2

 drivers/infiniband/hw/cxgb4/cm.c   |   56 +++---
 drivers/infiniband/hw/cxgb4/cq.c   |8 +-
 drivers/infiniband/hw/cxgb4/mem.c  |   14 +-
 drivers/infiniband/hw/cxgb4/qp.c   |   26 ++--
 drivers/net/ethernet/chelsio/cxgb4/Makefile|1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |3 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h |6 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c |  158 ++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.h |   52 ++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|  173 +---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h |   15 +-
 drivers/net/ethernet/chelsio/cxgb4/sge.c   |   32 ++--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |  127 +++---
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h   |   72 +++--
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h  |  142 
 drivers/net/ethernet/chelsio/cxgb4vf/sge.c |   32 ++--
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h |2 +-
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c |  150 +-
 drivers/scsi/csiostor/csio_attr.c  |8 +-
 drivers/scsi/csiostor/csio_hw.c|   14 +-
 drivers/scsi/csiostor/csio_hw_t4.c |   15 +-
 drivers/scsi/csiostor/csio_hw_t5.c |   21 ++-
 drivers/scsi/csiostor/csio_init.c  |6 +-
 drivers/scsi/csiostor/csio_lnode.c |   18 +-
 drivers/scsi/csiostor/csio_mb.c|  172 ++--
 drivers/scsi/csiostor/csio_scsi.c  |   24 ++--
 drivers/scsi/csiostor/csio_wr.h|2 +-
 drivers/scsi/cxgbi/cxgb4i/cxgb4i.c |   35 ++--
 28 files changed, 816 insertions(+), 568 deletions(-)
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.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


[PATCHv2 net-next 3/3] cxgb4: Cleanup macros so they follow the same style and look consistent, part 2

2014-11-03 Thread Hariprasad Shenai
Various patches have ended up changing the style of the symbolic macros/register
defines and some of them used the macros/register defines that matches the
output of the script from the hardware team.

As a result, the current kernel.org files are a mix of different macro styles.
Since this macro/register defines is used by different drivers a
few patch series have ended up adding duplicate macro/register define entries
with different styles. This makes these register define/macro files a complete
mess and we want to make them clean and consistent. This patch cleans up a part
of it.

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c   |   56 
 drivers/infiniband/hw/cxgb4/cq.c   |8 +-
 drivers/infiniband/hw/cxgb4/mem.c  |   14 +-
 drivers/infiniband/hw/cxgb4/qp.c   |   26 ++--
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |2 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h |6 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|   60 
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h |   15 +-
 drivers/net/ethernet/chelsio/cxgb4/sge.c   |   32 ++--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |  121 +++---
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h  |  142 +
 drivers/net/ethernet/chelsio/cxgb4vf/sge.c |   32 ++--
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h |2 +-
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c |  150 +-
 drivers/scsi/csiostor/csio_attr.c  |8 +-
 drivers/scsi/csiostor/csio_hw.c|   14 +-
 drivers/scsi/csiostor/csio_lnode.c |   18 +-
 drivers/scsi/csiostor/csio_mb.c|  172 ++--
 drivers/scsi/csiostor/csio_scsi.c  |   24 ++--
 drivers/scsi/csiostor/csio_wr.h|2 +-
 drivers/scsi/cxgbi/cxgb4i/cxgb4i.c |   35 ++--
 21 files changed, 509 insertions(+), 430 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index fb61f66..5c0e3b9 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -472,10 +472,10 @@ static void send_flowc(struct c4iw_ep *ep, struct sk_buff 
*skb)
skb = get_skb(skb, flowclen, GFP_KERNEL);
flowc = (struct fw_flowc_wr *)__skb_put(skb, flowclen);
 
-   flowc-op_to_nparams = cpu_to_be32(FW_WR_OP(FW_FLOWC_WR) |
-  FW_FLOWC_WR_NPARAMS(8));
-   flowc-flowid_len16 = cpu_to_be32(FW_WR_LEN16(DIV_ROUND_UP(flowclen,
- 16)) | FW_WR_FLOWID(ep-hwtid));
+   flowc-op_to_nparams = cpu_to_be32(V_FW_WR_OP(FW_FLOWC_WR) |
+  V_FW_FLOWC_WR_NPARAMS(8));
+   flowc-flowid_len16 = cpu_to_be32(V_FW_WR_LEN16(DIV_ROUND_UP(flowclen,
+ 16)) | V_FW_WR_FLOWID(ep-hwtid));
 
flowc-mnemval[0].mnemonic = FW_FLOWC_MNEM_PFNVFN;
flowc-mnemval[0].val = cpu_to_be32(FW_PFVF_CMD_PFN
@@ -803,16 +803,16 @@ static void send_mpa_req(struct c4iw_ep *ep, struct 
sk_buff *skb,
req = (struct fw_ofld_tx_data_wr *)skb_put(skb, wrlen);
memset(req, 0, wrlen);
req-op_to_immdlen = cpu_to_be32(
-   FW_WR_OP(FW_OFLD_TX_DATA_WR) |
-   FW_WR_COMPL(1) |
-   FW_WR_IMMDLEN(mpalen));
+   V_FW_WR_OP(FW_OFLD_TX_DATA_WR) |
+   F_FW_WR_COMPL |
+   V_FW_WR_IMMDLEN(mpalen));
req-flowid_len16 = cpu_to_be32(
-   FW_WR_FLOWID(ep-hwtid) |
-   FW_WR_LEN16(wrlen  4));
+   V_FW_WR_FLOWID(ep-hwtid) |
+   V_FW_WR_LEN16(wrlen  4));
req-plen = cpu_to_be32(mpalen);
req-tunnel_to_proxy = cpu_to_be32(
-   FW_OFLD_TX_DATA_WR_FLUSH(1) |
-   FW_OFLD_TX_DATA_WR_SHOVE(1));
+   F_FW_OFLD_TX_DATA_WR_FLUSH |
+   F_FW_OFLD_TX_DATA_WR_SHOVE);
 
mpa = (struct mpa_message *)(req + 1);
memcpy(mpa-key, MPA_KEY_REQ, sizeof(mpa-key));
@@ -897,16 +897,16 @@ static int send_mpa_reject(struct c4iw_ep *ep, const void 
*pdata, u8 plen)
req = (struct fw_ofld_tx_data_wr *)skb_put(skb, wrlen);
memset(req, 0, wrlen);
req-op_to_immdlen = cpu_to_be32(
-   FW_WR_OP(FW_OFLD_TX_DATA_WR) |
-   FW_WR_COMPL(1) |
-   FW_WR_IMMDLEN(mpalen));
+   V_FW_WR_OP(FW_OFLD_TX_DATA_WR) |
+   F_FW_WR_COMPL |
+   V_FW_WR_IMMDLEN(mpalen));
req-flowid_len16 = cpu_to_be32(
-   FW_WR_FLOWID(ep-hwtid) |
-   FW_WR_LEN16(wrlen  4));
+   V_FW_WR_FLOWID(ep-hwtid) |
+   V_FW_WR_LEN16(wrlen  4));
req-plen = cpu_to_be32(mpalen);
req-tunnel_to_proxy = cpu_to_be32

[PATCHv2 net-next 2/3] cxgb4: Cleanup macros so they follow the same style and look consistent

2014-11-03 Thread Hariprasad Shenai
Various patches have ended up changing the style of the symbolic macros/register
defines and some of them used the macros/register defines that matches the
output of the script from the hardware team.

As a result, the current kernel.org files are a mix of different macro styles.
Since this macro/register defines is used by different drivers a
few patch series have ended up adding duplicate macro/register define entries
with different styles. This makes these register define/macro files a complete
mess and we want to make them clean and consistent. This patch cleans up a part
of it.

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c |   32 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|   16 +++--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |6 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h   |   72 +++-
 drivers/scsi/csiostor/csio_hw_t4.c |   15 ++--
 drivers/scsi/csiostor/csio_hw_t5.c |   21 +++---
 drivers/scsi/csiostor/csio_init.c  |6 +-
 7 files changed, 106 insertions(+), 62 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
index e86b5fe..aa75c91 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -128,30 +128,30 @@ int t4_setup_debugfs(struct adapter *adap)
  t4_debugfs_files,
  ARRAY_SIZE(t4_debugfs_files));
 
-   i = t4_read_reg(adap, MA_TARGET_MEM_ENABLE);
-   if (i  EDRAM0_ENABLE) {
-   size = t4_read_reg(adap, MA_EDRAM0_BAR);
-   add_debugfs_mem(adap, edc0, MEM_EDC0, EDRAM_SIZE_GET(size));
+   i = t4_read_reg(adap, A_MA_TARGET_MEM_ENABLE);
+   if (i  F_EDRAM0_ENABLE) {
+   size = t4_read_reg(adap, A_MA_EDRAM0_BAR);
+   add_debugfs_mem(adap, edc0, MEM_EDC0, G_EDRAM0_SIZE(size));
}
-   if (i  EDRAM1_ENABLE) {
-   size = t4_read_reg(adap, MA_EDRAM1_BAR);
-   add_debugfs_mem(adap, edc1, MEM_EDC1, EDRAM_SIZE_GET(size));
+   if (i  F_EDRAM1_ENABLE) {
+   size = t4_read_reg(adap, A_MA_EDRAM1_BAR);
+   add_debugfs_mem(adap, edc1, MEM_EDC1, G_EDRAM1_SIZE(size));
}
if (is_t4(adap-params.chip)) {
-   size = t4_read_reg(adap, MA_EXT_MEMORY_BAR);
-   if (i  EXT_MEM_ENABLE)
+   size = t4_read_reg(adap, A_MA_EXT_MEMORY_BAR);
+   if (i  F_EXT_MEM_ENABLE)
add_debugfs_mem(adap, mc, MEM_MC,
-   EXT_MEM_SIZE_GET(size));
+   G_EXT_MEM_SIZE(size));
} else {
-   if (i  EXT_MEM_ENABLE) {
-   size = t4_read_reg(adap, MA_EXT_MEMORY_BAR);
+   if (i  F_EXT_MEM0_ENABLE) {
+   size = t4_read_reg(adap, A_MA_EXT_MEMORY0_BAR);
add_debugfs_mem(adap, mc0, MEM_MC0,
-   EXT_MEM_SIZE_GET(size));
+   G_EXT_MEM0_SIZE(size));
}
-   if (i  EXT_MEM1_ENABLE) {
-   size = t4_read_reg(adap, MA_EXT_MEMORY1_BAR);
+   if (i  F_EXT_MEM1_ENABLE) {
+   size = t4_read_reg(adap, A_MA_EXT_MEMORY1_BAR);
add_debugfs_mem(adap, mc1, MEM_MC1,
-   EXT_MEM_SIZE_GET(size));
+   G_EXT_MEM1_SIZE(size));
}
}
return 0;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 172f68b..65ce937 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3802,7 +3802,7 @@ int cxgb4_read_tpte(struct net_device *dev, u32 stag, 
__be32 *tpte)
 {
struct adapter *adap;
u32 offset, memtype, memaddr;
-   u32 edc0_size, edc1_size, mc0_size, mc1_size;
+   u32 edc0_size, edc1_size, mc0_size, mc1_size, size;
u32 edc0_end, edc1_end, mc0_end, mc1_end;
int ret;
 
@@ -3816,9 +3816,12 @@ int cxgb4_read_tpte(struct net_device *dev, u32 stag, 
__be32 *tpte)
 * and EDC1.  Some cards will have neither MC0 nor MC1, most cards have
 * MC0, and some have both MC0 and MC1.
 */
-   edc0_size = EDRAM_SIZE_GET(t4_read_reg(adap, MA_EDRAM0_BAR))  20;
-   edc1_size = EDRAM_SIZE_GET(t4_read_reg(adap, MA_EDRAM1_BAR))  20;
-   mc0_size = EXT_MEM_SIZE_GET(t4_read_reg(adap, MA_EXT_MEMORY_BAR))  20;
+   size = t4_read_reg(adap, A_MA_EDRAM0_BAR);
+   edc0_size = G_EDRAM0_SIZE(size)  20;
+   size = t4_read_reg(adap, A_MA_EDRAM1_BAR);
+   edc1_size = G_EDRAM1_SIZE(size)  20

[PATCHv2 net-next 1/3] cxgb4: Add cxgb4_debugfs.c, move all debugfs code to new file

2014-11-03 Thread Hariprasad Shenai
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/net/ethernet/chelsio/cxgb4/Makefile|1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c |  158 
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.h |   52 +++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|   97 +
 5 files changed, 217 insertions(+), 92 deletions(-)
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.h

diff --git a/drivers/net/ethernet/chelsio/cxgb4/Makefile 
b/drivers/net/ethernet/chelsio/cxgb4/Makefile
index 1df65c9..b852807 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/Makefile
+++ b/drivers/net/ethernet/chelsio/cxgb4/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_CHELSIO_T4) += cxgb4.o
 
 cxgb4-objs := cxgb4_main.o l2t.o t4_hw.o sge.o
 cxgb4-$(CONFIG_CHELSIO_T4_DCB) +=  cxgb4_dcb.o
+cxgb4-$(CONFIG_DEBUG_FS) += cxgb4_debugfs.o
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 3c481b2..dad1ea9 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -1085,4 +1085,5 @@ void t4_db_dropped(struct adapter *adapter);
 int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox,
 u32 addr, u32 val);
 void t4_sge_decode_idma_state(struct adapter *adapter, int state);
+void t4_free_mem(void *addr);
 #endif /* __CXGB4_H__ */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
new file mode 100644
index 000..e86b5fe
--- /dev/null
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -0,0 +1,158 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2014 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *  - Redistributions of source code must retain the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer.
+ *
+ *  - Redistributions in binary form must reproduce the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer in the documentation and/or other materials
+ *provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include linux/seq_file.h
+#include linux/debugfs.h
+#include linux/string_helpers.h
+#include linux/sort.h
+
+#include cxgb4.h
+#include t4_regs.h
+#include t4fw_api.h
+#include cxgb4_debugfs.h
+#include l2t.h
+
+static ssize_t mem_read(struct file *file, char __user *buf, size_t count,
+   loff_t *ppos)
+{
+   loff_t pos = *ppos;
+   loff_t avail = file_inode(file)-i_size;
+   unsigned int mem = (uintptr_t)file-private_data  3;
+   struct adapter *adap = file-private_data - mem;
+   __be32 *data;
+   int ret;
+
+   if (pos  0)
+   return -EINVAL;
+   if (pos = avail)
+   return 0;
+   if (count  avail - pos)
+   count = avail - pos;
+
+   data = t4_alloc_mem(count);
+   if (!data)
+   return -ENOMEM;
+
+   spin_lock(adap-win0_lock);
+   ret = t4_memory_rw(adap, 0, mem, pos, count, data, T4_MEMORY_READ);
+   spin_unlock(adap-win0_lock);
+   if (ret) {
+   t4_free_mem(data);
+   return ret;
+   }
+   ret = copy_to_user(buf, data, count);
+
+   t4_free_mem(data);
+   if (ret)
+   return -EFAULT;
+
+   *ppos = pos + count;
+   return count;
+}
+
+static const struct file_operations mem_debugfs_fops = {
+   .owner   = THIS_MODULE,
+   .open= simple_open,
+   .read= mem_read,
+   .llseek  = default_llseek,
+};
+
+static void add_debugfs_mem(struct adapter *adap, const char *name,
+   unsigned int idx, unsigned int size_mb)
+{
+   struct dentry *de;
+
+   de

[PATCH 0/3] Add missing neigh_release, fix ntuple calculation for IPv6

2014-09-23 Thread Hariprasad Shenai
This patch series adds missing neigh release in find_route function and also
takes IPv6 into consideration in best_mtu and set_emss function. It also fixes
ntuple calculation for IPv6 for T5 adapter.

The patches series is created against 'infiniband' tree.
And includes patches on iw_cxgb4 driver.

We have included all the maintainers of respective drivers. Kindly review the
change and let us know in case of any review comments.

Thanks

Hariprasad Shenai (3):
  RDMA/cxgb4: Take IPv6 into account for best_mtu and set_emss
  RDMA/cxgb4: Add missing neigh_release in find_route
  RDMA/cxgb4: Fix ntuple calculation for ipv6 and remove duplicate line

 drivers/infiniband/hw/cxgb4/cm.c |   32 
 1 files changed, 20 insertions(+), 12 deletions(-)

--
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


[PATCH 2/3] RDMA/cxgb4: Add missing neigh_release in find_route

2014-09-23 Thread Hariprasad Shenai
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 2ca9ec8..2ee9892 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -417,6 +417,7 @@ static struct dst_entry *find_route(struct c4iw_dev *dev, 
__be32 local_ip,
return NULL;
if (!our_interface(dev, n-dev) 
!(n-dev-flags  IFF_LOOPBACK)) {
+   neigh_release(n);
dst_release(rt-dst);
return NULL;
}
-- 
1.7.1

--
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


[PATCH 0/5] Misc. fix for cxgb4 and iw_cxgb4

2014-07-21 Thread Hariprasad Shenai
Hi,
This patch series adds support to enchance error reporting, log detailed
warning for negative advice, support query_qp verb and advertise correct
device max attributes for iwarp.

The patches series is created against 'net-next' tree.
And includes patches on cxgb4 and iw_cxgb4 driver.

Since this patch-series contains changes which are dependent on commit id
4c2c5763 (cxgb4/iw_cxgb4: use firmware ord/ird resource limits) of net-next
tree we would like to request this patch series to get merged via David Miller's
'net-next' tree.

We have included all the maintainers of respective drivers. Kindly review the
change and let us know in case of any review comments.

Thanks 

Hariprasad Shenai (5):
  cxgb4: Add the MC1 registers to read in the interrupt handler
  iw_cxgb4: log detailed warnings for negative advice
  iw_cxgb4: Support query_qp() verb
  iw_cxgb4: advertise the correct device max attributes
  iw_cxgb4: Don't limit TPTE count to 32KB

 drivers/infiniband/hw/cxgb4/cm.c |   29 ++
 drivers/infiniband/hw/cxgb4/cq.c |8 +
 drivers/infiniband/hw/cxgb4/device.c |   16 +-
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h   |2 +-
 drivers/infiniband/hw/cxgb4/provider.c   |4 +-
 drivers/infiniband/hw/cxgb4/qp.c |   41 +-
 drivers/infiniband/hw/cxgb4/t4.h |3 --
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c   |   16 --
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h |3 ++
 9 files changed, 78 insertions(+), 44 deletions(-)

--
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


[PATCH 1/5] cxgb4: Add the MC1 registers to read in the interrupt handler

2014-07-21 Thread Hariprasad Shenai
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c   |   16 +---
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h |3 +++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index eb5a278..e768852 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -1719,16 +1719,24 @@ static void mps_intr_handler(struct adapter *adapter)
  */
 static void mem_intr_handler(struct adapter *adapter, int idx)
 {
-   static const char name[3][5] = { EDC0, EDC1, MC };
+   static const char name[4][7] = { EDC0, EDC1, MC/MC0, MC1 };
 
unsigned int addr, cnt_addr, v;
 
if (idx = MEM_EDC1) {
addr = EDC_REG(EDC_INT_CAUSE, idx);
cnt_addr = EDC_REG(EDC_ECC_STATUS, idx);
+   } else if (idx == MEM_MC) {
+   if (is_t4(adapter-params.chip)) {
+   addr = MC_INT_CAUSE;
+   cnt_addr = MC_ECC_STATUS;
+   } else {
+   addr = MC_P_INT_CAUSE;
+   cnt_addr = MC_P_ECC_STATUS;
+   }
} else {
-   addr = MC_INT_CAUSE;
-   cnt_addr = MC_ECC_STATUS;
+   addr = MC_REG(MC_P_INT_CAUSE, 1);
+   cnt_addr = MC_REG(MC_P_ECC_STATUS, 1);
}
 
v = t4_read_reg(adapter, addr)  MEM_INT_MASK;
@@ -1892,6 +1900,8 @@ int t4_slow_intr_handler(struct adapter *adapter)
pcie_intr_handler(adapter);
if (cause  MC)
mem_intr_handler(adapter, MEM_MC);
+   if (!is_t4(adapter-params.chip)  (cause  MC1))
+   mem_intr_handler(adapter, MEM_MC1);
if (cause  EDC0)
mem_intr_handler(adapter, MEM_EDC0);
if (cause  EDC1)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h
index 3b244ab..e3146e8 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h
@@ -448,11 +448,13 @@
 #define  TDUE 0x0001U
 
 #define MC_INT_CAUSE 0x7518
+#define MC_P_INT_CAUSE 0x41318
 #define  ECC_UE_INT_CAUSE 0x0004U
 #define  ECC_CE_INT_CAUSE 0x0002U
 #define  PERR_INT_CAUSE   0x0001U
 
 #define MC_ECC_STATUS 0x751c
+#define MC_P_ECC_STATUS 0x4131c
 #define  ECC_CECNT_MASK   0xU
 #define  ECC_CECNT_SHIFT  16
 #define  ECC_CECNT(x) ((x)  ECC_CECNT_SHIFT)
@@ -1101,6 +1103,7 @@
 #define  I2CM   0x0002U
 #define  CIM0x0001U
 
+#define MC1 0x31
 #define PL_INT_ENABLE 0x19410
 #define PL_INT_MAP0 0x19414
 #define PL_RST 0x19428
-- 
1.7.1

--
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


[PATCH 3/5] iw_cxgb4: Support query_qp() verb

2014-07-21 Thread Hariprasad Shenai
Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/qp.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
index fd66bd9..0e7e0e3 100644
--- a/drivers/infiniband/hw/cxgb4/qp.c
+++ b/drivers/infiniband/hw/cxgb4/qp.c
@@ -1856,5 +1856,11 @@ int c4iw_ib_query_qp(struct ib_qp *ibqp, struct 
ib_qp_attr *attr,
memset(attr, 0, sizeof *attr);
memset(init_attr, 0, sizeof *init_attr);
attr-qp_state = to_ib_qp_state(qhp-attr.state);
+   init_attr-cap.max_send_wr = qhp-attr.sq_num_entries;
+   init_attr-cap.max_recv_wr = qhp-attr.rq_num_entries;
+   init_attr-cap.max_send_sge = qhp-attr.sq_max_sges;
+   init_attr-cap.max_recv_sge = qhp-attr.sq_max_sges;
+   init_attr-cap.max_inline_data = T4_MAX_SEND_INLINE;
+   init_attr-sq_sig_type = qhp-sq_sig_all ? IB_SIGNAL_ALL_WR : 0;
return 0;
 }
-- 
1.7.1

--
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


[PATCH 5/5] iw_cxgb4: Don't limit TPTE count to 32KB

2014-07-21 Thread Hariprasad Shenai
Use the size advertised by FW

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h |2 +-
 drivers/infiniband/hw/cxgb4/t4.h   |1 -
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h 
b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
index 69f047c..c378fd2 100644
--- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
+++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
@@ -193,7 +193,7 @@ static inline int c4iw_fatal_error(struct c4iw_rdev *rdev)
 
 static inline int c4iw_num_stags(struct c4iw_rdev *rdev)
 {
-   return min((int)T4_MAX_NUM_STAG, (int)(rdev-lldi.vr-stag.size  5));
+   return (int)(rdev-lldi.vr-stag.size  5);
 }
 
 #define C4IW_WR_TO (30*HZ)
diff --git a/drivers/infiniband/hw/cxgb4/t4.h b/drivers/infiniband/hw/cxgb4/t4.h
index 641ab55..df5edfa 100644
--- a/drivers/infiniband/hw/cxgb4/t4.h
+++ b/drivers/infiniband/hw/cxgb4/t4.h
@@ -37,7 +37,6 @@
 #include t4fw_ri_api.h
 
 #define T4_MAX_NUM_PD 65536
-#define T4_MAX_NUM_STAG (115)
 #define T4_MAX_MR_SIZE (~0ULL)
 #define T4_PAGESIZE_MASK 0x000  /* 4KB-128MB */
 #define T4_STAG_UNSET 0x
-- 
1.7.1

--
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


[PATCH] iw_cxgb4: fix for 64-bit integer division

2014-07-17 Thread Hariprasad Shenai
Fixed error introduced in commit id 7730b4c ( cxgb4/iw_cxgb4: work request
logging feature) while compiling on 32 bit architecture reported by kbuild.

Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/device.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/device.c 
b/drivers/infiniband/hw/cxgb4/device.c
index df1f1b5..bb0de61 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -33,6 +33,7 @@
 #include linux/moduleparam.h
 #include linux/debugfs.h
 #include linux/vmalloc.h
+#include linux/math64.h
 
 #include rdma/ib_verbs.h
 
@@ -150,7 +151,7 @@ static int wr_log_show(struct seq_file *seq, void *v)
int prev_ts_set = 0;
int idx, end;
 
-#define ts2ns(ts) ((ts) * dev-rdev.lldi.cclk_ps / 1000)
+#define ts2ns(ts) div64_ul((ts) * dev-rdev.lldi.cclk_ps , 1000)
 
idx = atomic_read(dev-rdev.wr_log_idx) 
(dev-rdev.wr_log_size - 1);
-- 
1.7.1

--
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


[PATCHv2 net-next 0/4] Misc. fixes for iw_cxgb4

2014-07-14 Thread Hariprasad Shenai
This patch series adds support to determine ingress padding boundary at runtime.
Advertise a larger max read queue depth for qps, and gather the resource limits
from fw and use them to avoid exhausting all the resources and display TPTE on
errors and add support for work request logging feature.

The patches series is created against 'net-next' tree.
And includes patches on cxgb4 and iw_cxgb4 driver.

Since this patch-series contains changes which are dependent on commit id
fc5ab02 (cxgb4: Replaced the backdoor mechanism to access the HW memory with
PCIe Window method) we would like to request this patch series to get merged
via David Miller's 'net-next' tree.

We have included all the maintainers of respective drivers. Kindly review the
change and let us know in case of any review comments. 

V2:
 Optimized alloc_ird function, and several other changes related to debug prints
 based on review comments given by Yann Droneaud.

Hariprasad Shenai (4):
  iw_cxgb4: Detect Ing. Padding Boundary at run-time
  cxgb4/iw_cxgb4: use firmware ord/ird resource limits
  cxgb4/iw_cxgb4: display TPTE on errors
  cxgb4/iw_cxgb4: work request logging feature

 drivers/infiniband/hw/cxgb4/cm.c|   80 +++---
 drivers/infiniband/hw/cxgb4/cq.c|8 +-
 drivers/infiniband/hw/cxgb4/device.c|  188 ++-
 drivers/infiniband/hw/cxgb4/ev.c|   55 ++-
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h  |   38 +-
 drivers/infiniband/hw/cxgb4/provider.c  |   10 +-
 drivers/infiniband/hw/cxgb4/qp.c|   76 --
 drivers/infiniband/hw/cxgb4/t4.h|   16 +--
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |3 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |  100 
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h  |7 +
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h|6 +
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h   |2 +
 13 files changed, 528 insertions(+), 61 deletions(-)

--
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


[PATCHv2 net-next 3/4] cxgb4/iw_cxgb4: display TPTE on errors

2014-07-14 Thread Hariprasad Shenai
With ingress WRITE or READ RESPONSE errors, HW provides the offending
stag from the packet.  This patch adds logic to log the parsed TPTE
in this case. cxgb4 now exports a function to read a TPTE entry
from adapter memory.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/device.c|   28 --
 drivers/infiniband/hw/cxgb4/ev.c|   55 +--
 drivers/infiniband/hw/cxgb4/t4.h|4 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   66 +++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h  |1 +
 5 files changed, 143 insertions(+), 11 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/device.c 
b/drivers/infiniband/hw/cxgb4/device.c
index e76358e..8386678 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -241,12 +241,32 @@ static int dump_stag(int id, void *p, void *data)
struct c4iw_debugfs_data *stagd = data;
int space;
int cc;
+   struct fw_ri_tpte tpte;
+   int ret;
 
space = stagd-bufsize - stagd-pos - 1;
if (space == 0)
return 1;
 
-   cc = snprintf(stagd-buf + stagd-pos, space, 0x%x\n, id8);
+   ret = cxgb4_read_tpte(stagd-devp-rdev.lldi.ports[0], (u32)id8,
+ (__be32 *)tpte);
+   if (ret) {
+   dev_err(stagd-devp-rdev.lldi.pdev-dev,
+   %s cxgb4_read_tpte err %d\n, __func__, ret);
+   return ret;
+   }
+   cc = snprintf(stagd-buf + stagd-pos, space,
+ stag: idx 0x%x valid %d key 0x%x state %d pdid %d 
+ perm 0x%x ps %d len 0x%llx va 0x%llx\n,
+ (u32)id8,
+ G_FW_RI_TPTE_VALID(ntohl(tpte.valid_to_pdid)),
+ G_FW_RI_TPTE_STAGKEY(ntohl(tpte.valid_to_pdid)),
+ G_FW_RI_TPTE_STAGSTATE(ntohl(tpte.valid_to_pdid)),
+ G_FW_RI_TPTE_PDID(ntohl(tpte.valid_to_pdid)),
+ G_FW_RI_TPTE_PERM(ntohl(tpte.locread_to_qpid)),
+ G_FW_RI_TPTE_PS(ntohl(tpte.locread_to_qpid)),
+ ((u64)ntohl(tpte.len_hi)  32) | ntohl(tpte.len_lo),
+ ((u64)ntohl(tpte.va_hi)  32) | ntohl(tpte.va_lo_fbo));
if (cc  space)
stagd-pos += cc;
return 0;
@@ -259,7 +279,7 @@ static int stag_release(struct inode *inode, struct file 
*file)
printk(KERN_INFO %s null stagd?\n, __func__);
return 0;
}
-   kfree(stagd-buf);
+   vfree(stagd-buf);
kfree(stagd);
return 0;
 }
@@ -282,8 +302,8 @@ static int stag_open(struct inode *inode, struct file *file)
idr_for_each(stagd-devp-mmidr, count_idrs, count);
spin_unlock_irq(stagd-devp-lock);
 
-   stagd-bufsize = count * sizeof(0x12345678\n);
-   stagd-buf = kmalloc(stagd-bufsize, GFP_KERNEL);
+   stagd-bufsize = count * 256;
+   stagd-buf = vmalloc(stagd-bufsize);
if (!stagd-buf) {
ret = -ENOMEM;
goto err1;
diff --git a/drivers/infiniband/hw/cxgb4/ev.c b/drivers/infiniband/hw/cxgb4/ev.c
index d61d0a1..fbe6051 100644
--- a/drivers/infiniband/hw/cxgb4/ev.c
+++ b/drivers/infiniband/hw/cxgb4/ev.c
@@ -35,6 +35,55 @@
 
 #include iw_cxgb4.h
 
+static void print_tpte(struct c4iw_dev *dev, u32 stag)
+{
+   int ret;
+   struct fw_ri_tpte tpte;
+
+   ret = cxgb4_read_tpte(dev-rdev.lldi.ports[0], stag,
+ (__be32 *)tpte);
+   if (ret) {
+   dev_err(dev-rdev.lldi.pdev-dev,
+   %s cxgb4_read_tpte err %d\n, __func__, ret);
+   return;
+   }
+   PDBG(stag idx 0x%x valid %d key 0x%x state %d pdid %d 
+  perm 0x%x ps %d len 0x%llx va 0x%llx\n,
+  stag  0xff00,
+  G_FW_RI_TPTE_VALID(ntohl(tpte.valid_to_pdid)),
+  G_FW_RI_TPTE_STAGKEY(ntohl(tpte.valid_to_pdid)),
+  G_FW_RI_TPTE_STAGSTATE(ntohl(tpte.valid_to_pdid)),
+  G_FW_RI_TPTE_PDID(ntohl(tpte.valid_to_pdid)),
+  G_FW_RI_TPTE_PERM(ntohl(tpte.locread_to_qpid)),
+  G_FW_RI_TPTE_PS(ntohl(tpte.locread_to_qpid)),
+  ((u64)ntohl(tpte.len_hi)  32) | ntohl(tpte.len_lo),
+  ((u64)ntohl(tpte.va_hi)  32) | ntohl(tpte.va_lo_fbo));
+}
+
+static void dump_err_cqe(struct c4iw_dev *dev, struct t4_cqe *err_cqe)
+{
+   __be64 *p = (void *)err_cqe;
+
+   dev_err(dev-rdev.lldi.pdev-dev,
+   AE qpid %d opcode %d status 0x%x 
+   type %d len 0x%x wrid.hi 0x%x wrid.lo 0x%x\n,
+   CQE_QPID(err_cqe), CQE_OPCODE(err_cqe),
+   CQE_STATUS(err_cqe), CQE_TYPE(err_cqe), ntohl(err_cqe-len),
+   CQE_WRID_HI(err_cqe), CQE_WRID_LOW(err_cqe));
+
+   PDBG(%016llx %016llx %016llx

[PATCHv2 net-next 2/4] cxgb4/iw_cxgb4: use firmware ord/ird resource limits

2014-07-14 Thread Hariprasad Shenai
Advertise a larger max read queue depth for qps, and gather the resource limits
from fw and use them to avoid exhaustinq all the resources.

Design:

cxgb4:

Obtain the max_ordird_qp and max_ird_adapter device params from FW
at init time and pass them up to the ULDs when they attach.  If these
parameters are not available, due to older firmware, then hard-code
the values based on the known values for older firmware.
iw_cxgb4:

Fix the c4iw_query_device() to report these correct values based on
adapter parameters.  ibv_query_device() will always return:

max_qp_rd_atom = max_qp_init_rd_atom = min(module_max, max_ordird_qp)
max_res_rd_atom = max_ird_adapter

Bump up the per qp max module option to 32, allowing it to be increased
by the user up to the device max of max_ordird_qp.  32 seems to be
sufficient to maximize throughput for streaming read benchmarks.

Fail connection setup if the negotiated IRD exhausts the available
adapter ird resources.  So the driver will track the amount of ird
resource in use and not send an RI_WR/INIT to FW that would reduce the
available ird resources below zero.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c|   80 ---
 drivers/infiniband/hw/cxgb4/device.c|2 +
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h  |9 ++-
 drivers/infiniband/hw/cxgb4/provider.c  |6 +-
 drivers/infiniband/hw/cxgb4/qp.c|   54 +--
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |3 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   18 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h  |2 +
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h   |2 +
 9 files changed, 142 insertions(+), 34 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index d62a0f9..df5bd3d 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -79,9 +79,10 @@ static int dack_mode = 1;
 module_param(dack_mode, int, 0644);
 MODULE_PARM_DESC(dack_mode, Delayed ack mode (default=1));
 
-int c4iw_max_read_depth = 8;
+uint c4iw_max_read_depth = 32;
 module_param(c4iw_max_read_depth, int, 0644);
-MODULE_PARM_DESC(c4iw_max_read_depth, Per-connection max ORD/IRD 
(default=8));
+MODULE_PARM_DESC(c4iw_max_read_depth,
+Per-connection max ORD/IRD (default=32));
 
 static int enable_tcp_timestamps;
 module_param(enable_tcp_timestamps, int, 0644);
@@ -813,6 +814,8 @@ static void send_mpa_req(struct c4iw_ep *ep, struct sk_buff 
*skb,
if (mpa_rev_to_use == 2) {
mpa-private_data_size = htons(ntohs(mpa-private_data_size) +
   sizeof (struct 
mpa_v2_conn_params));
+   PDBG(%s initiator ird %u ord %u\n, __func__, ep-ird,
+ep-ord);
mpa_v2_params.ird = htons((u16)ep-ird);
mpa_v2_params.ord = htons((u16)ep-ord);
 
@@ -1182,8 +1185,8 @@ static int connect_request_upcall(struct c4iw_ep *ep)
sizeof(struct mpa_v2_conn_params);
} else {
/* this means MPA_v1 is used. Send max supported */
-   event.ord = c4iw_max_read_depth;
-   event.ird = c4iw_max_read_depth;
+   event.ord = cur_max_read_depth(ep-com.dev);
+   event.ird = cur_max_read_depth(ep-com.dev);
event.private_data_len = ep-plen;
event.private_data = ep-mpa_pkt + sizeof(struct mpa_message);
}
@@ -1247,6 +1250,8 @@ static int update_rx_credits(struct c4iw_ep *ep, u32 
credits)
return credits;
 }
 
+#define RELAXED_IRD_NEGOTIATION 1
+
 static int process_mpa_reply(struct c4iw_ep *ep, struct sk_buff *skb)
 {
struct mpa_message *mpa;
@@ -1358,17 +1363,33 @@ static int process_mpa_reply(struct c4iw_ep *ep, struct 
sk_buff *skb)
MPA_V2_IRD_ORD_MASK;
resp_ord = ntohs(mpa_v2_params-ord) 
MPA_V2_IRD_ORD_MASK;
+   PDBG(%s responder ird %u ord %u ep ird %u ord %u\n,
+__func__, resp_ird, resp_ord, ep-ird, ep-ord);
 
/*
 * This is a double-check. Ideally, below checks are
 * not required since ird/ord stuff has been taken
 * care of in c4iw_accept_cr
 */
-   if ((ep-ird  resp_ord) || (ep-ord  resp_ird)) {
+   if (ep-ird  resp_ord) {
+   if (RELAXED_IRD_NEGOTIATION  resp_ord =
+   ep-com.dev-rdev.lldi.max_ordird_qp)
+   ep-ird = resp_ord;
+   else
+   insuff_ird = 1

[PATCHv2 net-next 1/4] iw_cxgb4: Detect Ing. Padding Boundary at run-time

2014-07-14 Thread Hariprasad Shenai
Updates iw_cxgb4 to determine the Ingress Padding Boundary from
cxgb4_lld_info, and take subsequent actions.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cq.c|4 ++--
 drivers/infiniband/hw/cxgb4/device.c|   21 +
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h  |   12 
 drivers/infiniband/hw/cxgb4/provider.c  |4 ++--
 drivers/infiniband/hw/cxgb4/qp.c|   10 ++
 drivers/infiniband/hw/cxgb4/t4.h|8 
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |2 ++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h  |2 ++
 8 files changed, 47 insertions(+), 16 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index c04292c..f04a838 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -895,7 +895,7 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int 
entries,
/*
 * Make actual HW queue 2x to avoid cdix_inc overflows.
 */
-   hwentries = min(entries * 2, T4_MAX_IQ_SIZE);
+   hwentries = min(entries * 2, rhp-rdev.hw_queue.t4_max_iq_size);
 
/*
 * Make HW queue at least 64 entries so GTS updates aren't too
@@ -912,7 +912,7 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int 
entries,
if (ucontext) {
memsize = roundup(memsize, PAGE_SIZE);
hwentries = memsize / sizeof *chp-cq.queue;
-   while (hwentries  T4_MAX_IQ_SIZE) {
+   while (hwentries  rhp-rdev.hw_queue.t4_max_iq_size) {
memsize -= PAGE_SIZE;
hwentries = memsize / sizeof *chp-cq.queue;
}
diff --git a/drivers/infiniband/hw/cxgb4/device.c 
b/drivers/infiniband/hw/cxgb4/device.c
index dd93aad..88291ef 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -768,6 +768,27 @@ static struct c4iw_dev *c4iw_alloc(const struct 
cxgb4_lld_info *infop)
}
devp-rdev.lldi = *infop;
 
+   /* init various hw-queue params based on lld info */
+   PDBG(%s: Ing. padding boundary is %d, egrsstatuspagesize = %d\n,
+__func__, devp-rdev.lldi.sge_ingpadboundary,
+devp-rdev.lldi.sge_egrstatuspagesize);
+
+   devp-rdev.hw_queue.t4_eq_status_entries =
+   devp-rdev.lldi.sge_ingpadboundary  64 ? 2 : 1;
+   devp-rdev.hw_queue.t4_max_eq_size =
+   65520 - devp-rdev.hw_queue.t4_eq_status_entries;
+   devp-rdev.hw_queue.t4_max_iq_size = 65520 - 1;
+   devp-rdev.hw_queue.t4_max_rq_size =
+   8192 - devp-rdev.hw_queue.t4_eq_status_entries;
+   devp-rdev.hw_queue.t4_max_sq_size =
+   devp-rdev.hw_queue.t4_max_eq_size - 1;
+   devp-rdev.hw_queue.t4_max_qp_depth =
+   devp-rdev.hw_queue.t4_max_rq_size - 1;
+   devp-rdev.hw_queue.t4_max_cq_depth =
+   devp-rdev.hw_queue.t4_max_iq_size - 1;
+   devp-rdev.hw_queue.t4_stat_len =
+   devp-rdev.lldi.sge_egrstatuspagesize;
+
/*
 * For T5 devices, we map all of BAR2 with WC.
 * For T4 devices with onchip qp mem, we map only that part
diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h 
b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
index 125bc5d..9b9754c 100644
--- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
+++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
@@ -139,6 +139,17 @@ struct c4iw_stats {
u64  pas_ofld_conn_fails;
 };
 
+struct c4iw_hw_queue {
+   int t4_eq_status_entries;
+   int t4_max_eq_size;
+   int t4_max_iq_size;
+   int t4_max_rq_size;
+   int t4_max_sq_size;
+   int t4_max_qp_depth;
+   int t4_max_cq_depth;
+   int t4_stat_len;
+};
+
 struct c4iw_rdev {
struct c4iw_resource resource;
unsigned long qpshift;
@@ -156,6 +167,7 @@ struct c4iw_rdev {
unsigned long oc_mw_pa;
void __iomem *oc_mw_kva;
struct c4iw_stats stats;
+   struct c4iw_hw_queue hw_queue;
struct t4_dev_status_page *status_page;
 };
 
diff --git a/drivers/infiniband/hw/cxgb4/provider.c 
b/drivers/infiniband/hw/cxgb4/provider.c
index b1d3053..1d41b92 100644
--- a/drivers/infiniband/hw/cxgb4/provider.c
+++ b/drivers/infiniband/hw/cxgb4/provider.c
@@ -319,13 +319,13 @@ static int c4iw_query_device(struct ib_device *ibdev,
props-vendor_part_id = (u32)dev-rdev.lldi.pdev-device;
props-max_mr_size = T4_MAX_MR_SIZE;
props-max_qp = T4_MAX_NUM_QP;
-   props-max_qp_wr = T4_MAX_QP_DEPTH;
+   props-max_qp_wr = dev-rdev.hw_queue.t4_max_qp_depth;
props-max_sge = T4_MAX_RECV_SGE;
props-max_sge_rd = 1;
props-max_qp_rd_atom = c4iw_max_read_depth;
props-max_qp_init_rd_atom = c4iw_max_read_depth;
props-max_cq = T4_MAX_NUM_CQ

[PATCH 1/4] iw_cxgb4: Detect Ing. Padding Boundary at run-time

2014-07-11 Thread Hariprasad Shenai
Updates iw_cxgb4 to determine the Ingress Padding Boundary from
cxgb4_lld_info, and take subsequent actions.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cq.c|4 ++--
 drivers/infiniband/hw/cxgb4/device.c|   21 +
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h  |   12 
 drivers/infiniband/hw/cxgb4/provider.c  |4 ++--
 drivers/infiniband/hw/cxgb4/qp.c|   10 ++
 drivers/infiniband/hw/cxgb4/t4.h|8 
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |2 ++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h  |2 ++
 8 files changed, 47 insertions(+), 16 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index c04292c..f04a838 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -895,7 +895,7 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int 
entries,
/*
 * Make actual HW queue 2x to avoid cdix_inc overflows.
 */
-   hwentries = min(entries * 2, T4_MAX_IQ_SIZE);
+   hwentries = min(entries * 2, rhp-rdev.hw_queue.t4_max_iq_size);
 
/*
 * Make HW queue at least 64 entries so GTS updates aren't too
@@ -912,7 +912,7 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int 
entries,
if (ucontext) {
memsize = roundup(memsize, PAGE_SIZE);
hwentries = memsize / sizeof *chp-cq.queue;
-   while (hwentries  T4_MAX_IQ_SIZE) {
+   while (hwentries  rhp-rdev.hw_queue.t4_max_iq_size) {
memsize -= PAGE_SIZE;
hwentries = memsize / sizeof *chp-cq.queue;
}
diff --git a/drivers/infiniband/hw/cxgb4/device.c 
b/drivers/infiniband/hw/cxgb4/device.c
index dd93aad..95e6c6c 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -768,6 +768,27 @@ static struct c4iw_dev *c4iw_alloc(const struct 
cxgb4_lld_info *infop)
}
devp-rdev.lldi = *infop;
 
+   /* init various hw-queue params based on lld info */
+   pr_info(%s: ing. padding boundary is %d, egrsstatuspagesize = %d\n,
+   __func__, devp-rdev.lldi.sge_ingpadboundary,
+   devp-rdev.lldi.sge_egrstatuspagesize);
+
+   devp-rdev.hw_queue.t4_eq_status_entries =
+   devp-rdev.lldi.sge_ingpadboundary  64 ? 2 : 1;
+   devp-rdev.hw_queue.t4_max_eq_size =
+   65520 - devp-rdev.hw_queue.t4_eq_status_entries;
+   devp-rdev.hw_queue.t4_max_iq_size = 65520 - 1;
+   devp-rdev.hw_queue.t4_max_rq_size =
+   8192 - devp-rdev.hw_queue.t4_eq_status_entries;
+   devp-rdev.hw_queue.t4_max_sq_size =
+   devp-rdev.hw_queue.t4_max_eq_size - 1;
+   devp-rdev.hw_queue.t4_max_qp_depth =
+   devp-rdev.hw_queue.t4_max_rq_size - 1;
+   devp-rdev.hw_queue.t4_max_cq_depth =
+   devp-rdev.hw_queue.t4_max_iq_size - 1;
+   devp-rdev.hw_queue.t4_stat_len =
+   devp-rdev.lldi.sge_egrstatuspagesize;
+
/*
 * For T5 devices, we map all of BAR2 with WC.
 * For T4 devices with onchip qp mem, we map only that part
diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h 
b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
index 125bc5d..9b9754c 100644
--- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
+++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
@@ -139,6 +139,17 @@ struct c4iw_stats {
u64  pas_ofld_conn_fails;
 };
 
+struct c4iw_hw_queue {
+   int t4_eq_status_entries;
+   int t4_max_eq_size;
+   int t4_max_iq_size;
+   int t4_max_rq_size;
+   int t4_max_sq_size;
+   int t4_max_qp_depth;
+   int t4_max_cq_depth;
+   int t4_stat_len;
+};
+
 struct c4iw_rdev {
struct c4iw_resource resource;
unsigned long qpshift;
@@ -156,6 +167,7 @@ struct c4iw_rdev {
unsigned long oc_mw_pa;
void __iomem *oc_mw_kva;
struct c4iw_stats stats;
+   struct c4iw_hw_queue hw_queue;
struct t4_dev_status_page *status_page;
 };
 
diff --git a/drivers/infiniband/hw/cxgb4/provider.c 
b/drivers/infiniband/hw/cxgb4/provider.c
index b1d3053..1d41b92 100644
--- a/drivers/infiniband/hw/cxgb4/provider.c
+++ b/drivers/infiniband/hw/cxgb4/provider.c
@@ -319,13 +319,13 @@ static int c4iw_query_device(struct ib_device *ibdev,
props-vendor_part_id = (u32)dev-rdev.lldi.pdev-device;
props-max_mr_size = T4_MAX_MR_SIZE;
props-max_qp = T4_MAX_NUM_QP;
-   props-max_qp_wr = T4_MAX_QP_DEPTH;
+   props-max_qp_wr = dev-rdev.hw_queue.t4_max_qp_depth;
props-max_sge = T4_MAX_RECV_SGE;
props-max_sge_rd = 1;
props-max_qp_rd_atom = c4iw_max_read_depth;
props-max_qp_init_rd_atom = c4iw_max_read_depth;
props-max_cq = T4_MAX_NUM_CQ

[PATCH 0/4] Misc. fixes for iw_cxgb4

2014-07-11 Thread Hariprasad Shenai
This patch series adds support to determine ingress padding boundary at runtime.
Advertise a larger max read queue depth for qps, and gather the resource limits
from fw and use them to avoid exhausting all the resources and display TPTE on
errors and add support for work request logging feature.

The patches series is created against 'net-next' tree.
And includes patches on cxgb4 and iw_cxgb4 driver.

Since this patch-series contains changes which are dependent on commit id
fc5ab02 (cxgb4: Replaced the backdoor mechanism to access the HW memory with
PCIe Window method) of net-next tree, we would like to request this patch
series to get merged via David Miller's 'net-next' tree.

We have included all the maintainers of respective drivers. Kindly review the
change and let us know in case of any review comments.

Hariprasad Shenai (4):
  iw_cxgb4: Detect Ing. Padding Boundary at run-time
  cxgb4/iw_cxgb4: use firmware ord/ird resource limits
  cxgb4/iw_cxgb4: display TPTE on errors
  cxgb4/iw_cxgb4: work request logging feature

 drivers/infiniband/hw/cxgb4/cm.c|   80 +++---
 drivers/infiniband/hw/cxgb4/cq.c|8 +-
 drivers/infiniband/hw/cxgb4/device.c|  187 ++-
 drivers/infiniband/hw/cxgb4/ev.c|   53 ++-
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h  |   38 +-
 drivers/infiniband/hw/cxgb4/provider.c  |   10 +-
 drivers/infiniband/hw/cxgb4/qp.c|   75 --
 drivers/infiniband/hw/cxgb4/t4.h|   16 +--
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |3 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |  100 
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h  |7 +
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h|6 +
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h   |2 +
 13 files changed, 524 insertions(+), 61 deletions(-)

--
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


[PATCH 4/4] cxgb4/iw_cxgb4: work request logging feature

2014-07-11 Thread Hariprasad Shenai
This commit enhances the iwarp driver to optionally keep a log of rdma
work request timining data for kernel mode QPs.  If iw_cxgb4 module option
c4iw_wr_log is set to non-zero, each work request is tracked and timing
data maintained in a rolling log that is 4096 entries deep by default.
Module option c4iw_wr_log_size_order allows specifing a log2 size to use
instead of the default order of 12 (4096 entries). Both module options
are read-only and must be passed in at module load time to set them. IE:

modprobe iw_cxgb4 c4iw_wr_log=1 c4iw_wr_log_size_order=10

The timing data is viewable via the iw_cxgb4 debugfs file wr_log.
Writing anything to this file will clear all the timing data.
Data tracked includes:

- The host time when the work request was posted, just before ringing
the doorbell.  The host time when the completion was polled by the
application.  This is also the time the log entry is created.  The delta
of these two times is the amount of time took processing the work request.

- The qid of the EQ used to post the work request.

- The work request opcode.

- The cqe wr_id field.  For sq completions requests this is the swsqe
index.  For recv completions this is the MSN of the ingress SEND.
This value can be used to match log entries from this log with firmware
flowc event entries.

- The sge timestamp value just before ringing the doorbell when
posting,  the sge timestamp value just after polling the completion,
and CQE.timestamp field from the completion itself.  With these three
timestamps we can track the latency from post to poll, and the amount
of time the completion resided in the CQ before being reaped by the
application.  With debug firmware, the sge timestamp is also logged by
firmware in its flowc history so that we can compute the latency from
posting the work request until the firmware sees it.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cq.c|4 +
 drivers/infiniband/hw/cxgb4/device.c|  137 +++
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h  |   17 +++
 drivers/infiniband/hw/cxgb4/qp.c|   12 ++
 drivers/infiniband/hw/cxgb4/t4.h|4 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   14 +++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h  |2 +
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h|6 +
 8 files changed, 196 insertions(+), 0 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index f04a838..de9bcf2 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -633,11 +633,15 @@ proc_cqe:
wq-sq.cidx = (uint16_t)idx;
PDBG(%s completing sq idx %u\n, __func__, wq-sq.cidx);
*cookie = wq-sq.sw_sq[wq-sq.cidx].wr_id;
+   if (c4iw_wr_log)
+   c4iw_log_wr_stats(wq, hw_cqe);
t4_sq_consume(wq);
} else {
PDBG(%s completing rq idx %u\n, __func__, wq-rq.cidx);
*cookie = wq-rq.sw_rq[wq-rq.cidx].wr_id;
BUG_ON(t4_rq_empty(wq));
+   if (c4iw_wr_log)
+   c4iw_log_wr_stats(wq, hw_cqe);
t4_rq_consume(wq);
goto skip_cqe;
}
diff --git a/drivers/infiniband/hw/cxgb4/device.c 
b/drivers/infiniband/hw/cxgb4/device.c
index e8b79a3..f070b08 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -55,6 +55,15 @@ module_param(allow_db_coalescing_on_t5, int, 0644);
 MODULE_PARM_DESC(allow_db_coalescing_on_t5,
 Allow DB Coalescing on T5 (default = 0));
 
+int c4iw_wr_log = 0;
+module_param(c4iw_wr_log, int, 0444);
+MODULE_PARM_DESC(c4iw_wr_log, Enables logging of work request timing data.);
+
+int c4iw_wr_log_size_order = 12;
+module_param(c4iw_wr_log_size_order, int, 0444);
+MODULE_PARM_DESC(c4iw_wr_log_size_order,
+Number of entries (log2) in the work request timing log.);
+
 struct uld_ctx {
struct list_head entry;
struct cxgb4_lld_info lldi;
@@ -103,6 +112,117 @@ static ssize_t debugfs_read(struct file *file, char 
__user *buf, size_t count,
return simple_read_from_buffer(buf, count, ppos, d-buf, d-pos);
 }
 
+void c4iw_log_wr_stats(struct t4_wq *wq, struct t4_cqe *cqe)
+{
+   struct wr_log_entry le;
+   int idx;
+
+   if (!wq-rdev-wr_log)
+   return;
+
+   idx = (atomic_inc_return(wq-rdev-wr_log_idx) - 1) 
+   (wq-rdev-wr_log_size - 1);
+   le.poll_sge_ts = cxgb4_read_sge_timestamp(wq-rdev-lldi.ports[0]);
+   getnstimeofday(le.poll_host_ts);
+   le.valid = 1;
+   le.cqe_sge_ts = CQE_TS(cqe);
+   if (SQ_TYPE(cqe)) {
+   le.qid = wq-sq.qid;
+   le.opcode = CQE_OPCODE(cqe);
+   le.post_host_ts = wq-sq.sw_sq[wq-sq.cidx].host_ts

[PATCH 2/4] cxgb4/iw_cxgb4: use firmware ord/ird resource limits

2014-07-11 Thread Hariprasad Shenai
Advertise a larger max read queue depth for qps, and gather the resource limits
from fw and use them to avoid exhaustinq all the resources.

Design:

cxgb4:

Obtain the max_ordird_qp and max_ird_adapter device params from FW
at init time and pass them up to the ULDs when they attach.  If these
parameters are not available, due to older firmware, then hard-code
the values based on the known values for older firmware.
iw_cxgb4:

Fix the c4iw_query_device() to report these correct values based on
adapter parameters.  ibv_query_device() will always return:

max_qp_rd_atom = max_qp_init_rd_atom = min(module_max, max_ordird_qp)
max_res_rd_atom = max_ird_adapter

Bump up the per qp max module option to 32, allowing it to be increased
by the user up to the device max of max_ordird_qp.  32 seems to be
sufficient to maximize throughput for streaming read benchmarks.

Fail connection setup if the negotiated IRD exhausts the available
adapter ird resources.  So the driver will track the amount of ird
resource in use and not send an RI_WR/INIT to FW that would reduce the
available ird resources below zero.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c|   80 ---
 drivers/infiniband/hw/cxgb4/device.c|2 +
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h  |9 ++-
 drivers/infiniband/hw/cxgb4/provider.c  |6 +-
 drivers/infiniband/hw/cxgb4/qp.c|   53 +--
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |3 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   18 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h  |2 +
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h   |2 +
 9 files changed, 141 insertions(+), 34 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index d62a0f9..df5bd3d 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -79,9 +79,10 @@ static int dack_mode = 1;
 module_param(dack_mode, int, 0644);
 MODULE_PARM_DESC(dack_mode, Delayed ack mode (default=1));
 
-int c4iw_max_read_depth = 8;
+uint c4iw_max_read_depth = 32;
 module_param(c4iw_max_read_depth, int, 0644);
-MODULE_PARM_DESC(c4iw_max_read_depth, Per-connection max ORD/IRD 
(default=8));
+MODULE_PARM_DESC(c4iw_max_read_depth,
+Per-connection max ORD/IRD (default=32));
 
 static int enable_tcp_timestamps;
 module_param(enable_tcp_timestamps, int, 0644);
@@ -813,6 +814,8 @@ static void send_mpa_req(struct c4iw_ep *ep, struct sk_buff 
*skb,
if (mpa_rev_to_use == 2) {
mpa-private_data_size = htons(ntohs(mpa-private_data_size) +
   sizeof (struct 
mpa_v2_conn_params));
+   PDBG(%s initiator ird %u ord %u\n, __func__, ep-ird,
+ep-ord);
mpa_v2_params.ird = htons((u16)ep-ird);
mpa_v2_params.ord = htons((u16)ep-ord);
 
@@ -1182,8 +1185,8 @@ static int connect_request_upcall(struct c4iw_ep *ep)
sizeof(struct mpa_v2_conn_params);
} else {
/* this means MPA_v1 is used. Send max supported */
-   event.ord = c4iw_max_read_depth;
-   event.ird = c4iw_max_read_depth;
+   event.ord = cur_max_read_depth(ep-com.dev);
+   event.ird = cur_max_read_depth(ep-com.dev);
event.private_data_len = ep-plen;
event.private_data = ep-mpa_pkt + sizeof(struct mpa_message);
}
@@ -1247,6 +1250,8 @@ static int update_rx_credits(struct c4iw_ep *ep, u32 
credits)
return credits;
 }
 
+#define RELAXED_IRD_NEGOTIATION 1
+
 static int process_mpa_reply(struct c4iw_ep *ep, struct sk_buff *skb)
 {
struct mpa_message *mpa;
@@ -1358,17 +1363,33 @@ static int process_mpa_reply(struct c4iw_ep *ep, struct 
sk_buff *skb)
MPA_V2_IRD_ORD_MASK;
resp_ord = ntohs(mpa_v2_params-ord) 
MPA_V2_IRD_ORD_MASK;
+   PDBG(%s responder ird %u ord %u ep ird %u ord %u\n,
+__func__, resp_ird, resp_ord, ep-ird, ep-ord);
 
/*
 * This is a double-check. Ideally, below checks are
 * not required since ird/ord stuff has been taken
 * care of in c4iw_accept_cr
 */
-   if ((ep-ird  resp_ord) || (ep-ord  resp_ird)) {
+   if (ep-ird  resp_ord) {
+   if (RELAXED_IRD_NEGOTIATION  resp_ord =
+   ep-com.dev-rdev.lldi.max_ordird_qp)
+   ep-ird = resp_ord;
+   else
+   insuff_ird = 1

[PATCH 3/4] cxgb4/iw_cxgb4: display TPTE on errors

2014-07-11 Thread Hariprasad Shenai
With ingress WRITE or READ RESPONSE errors, HW provides the offending
stag from the packet.  This patch adds logic to log the parsed TPTE
in this case. cxgb4 now exports a function to read a TPTE entry
from adapter memory.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/device.c|   27 --
 drivers/infiniband/hw/cxgb4/ev.c|   53 --
 drivers/infiniband/hw/cxgb4/t4.h|4 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   66 +++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h  |1 +
 5 files changed, 140 insertions(+), 11 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/device.c 
b/drivers/infiniband/hw/cxgb4/device.c
index d2d3dba..e8b79a3 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -241,12 +241,31 @@ static int dump_stag(int id, void *p, void *data)
struct c4iw_debugfs_data *stagd = data;
int space;
int cc;
+   struct fw_ri_tpte tpte;
+   int ret;
 
space = stagd-bufsize - stagd-pos - 1;
if (space == 0)
return 1;
 
-   cc = snprintf(stagd-buf + stagd-pos, space, 0x%x\n, id8);
+   ret = cxgb4_read_tpte(stagd-devp-rdev.lldi.ports[0], (u32)id8,
+ (__be32 *)tpte);
+   if (ret) {
+   pr_info(%s cxgb4_read_tpte err %d\n, __func__, ret);
+   return ret;
+   }
+   cc = snprintf(stagd-buf + stagd-pos, space,
+ stag: idx 0x%x valid %d key 0x%x state %d pdid %d 
+ perm 0x%x ps %d len 0x%llx va 0x%llx\n,
+ (u32)id8,
+ G_FW_RI_TPTE_VALID(ntohl(tpte.valid_to_pdid)),
+ G_FW_RI_TPTE_STAGKEY(ntohl(tpte.valid_to_pdid)),
+ G_FW_RI_TPTE_STAGSTATE(ntohl(tpte.valid_to_pdid)),
+ G_FW_RI_TPTE_PDID(ntohl(tpte.valid_to_pdid)),
+ G_FW_RI_TPTE_PERM(ntohl(tpte.locread_to_qpid)),
+ G_FW_RI_TPTE_PS(ntohl(tpte.locread_to_qpid)),
+ ((u64)ntohl(tpte.len_hi)  32) | ntohl(tpte.len_lo),
+ ((u64)ntohl(tpte.va_hi)  32) | ntohl(tpte.va_lo_fbo));
if (cc  space)
stagd-pos += cc;
return 0;
@@ -259,7 +278,7 @@ static int stag_release(struct inode *inode, struct file 
*file)
printk(KERN_INFO %s null stagd?\n, __func__);
return 0;
}
-   kfree(stagd-buf);
+   vfree(stagd-buf);
kfree(stagd);
return 0;
 }
@@ -282,8 +301,8 @@ static int stag_open(struct inode *inode, struct file *file)
idr_for_each(stagd-devp-mmidr, count_idrs, count);
spin_unlock_irq(stagd-devp-lock);
 
-   stagd-bufsize = count * sizeof(0x12345678\n);
-   stagd-buf = kmalloc(stagd-bufsize, GFP_KERNEL);
+   stagd-bufsize = count * 256;
+   stagd-buf = vmalloc(stagd-bufsize);
if (!stagd-buf) {
ret = -ENOMEM;
goto err1;
diff --git a/drivers/infiniband/hw/cxgb4/ev.c b/drivers/infiniband/hw/cxgb4/ev.c
index d61d0a1..97379f4 100644
--- a/drivers/infiniband/hw/cxgb4/ev.c
+++ b/drivers/infiniband/hw/cxgb4/ev.c
@@ -35,6 +35,53 @@
 
 #include iw_cxgb4.h
 
+static void print_tpte(struct c4iw_dev *dev, u32 stag)
+{
+   int ret;
+   struct fw_ri_tpte tpte;
+
+   ret = cxgb4_read_tpte(dev-rdev.lldi.ports[0], stag,
+ (__be32 *)tpte);
+   if (ret) {
+   pr_err(%s cxgb4_read_tpte err %d\n, __func__, ret);
+   return;
+   }
+   pr_err(stag idx 0x%x valid %d key 0x%x state %d pdid %d 
+  perm 0x%x ps %d len 0x%llx va 0x%llx\n,
+  stag  0xff00,
+  G_FW_RI_TPTE_VALID(ntohl(tpte.valid_to_pdid)),
+  G_FW_RI_TPTE_STAGKEY(ntohl(tpte.valid_to_pdid)),
+  G_FW_RI_TPTE_STAGSTATE(ntohl(tpte.valid_to_pdid)),
+  G_FW_RI_TPTE_PDID(ntohl(tpte.valid_to_pdid)),
+  G_FW_RI_TPTE_PERM(ntohl(tpte.locread_to_qpid)),
+  G_FW_RI_TPTE_PS(ntohl(tpte.locread_to_qpid)),
+  ((u64)ntohl(tpte.len_hi)  32) | ntohl(tpte.len_lo),
+  ((u64)ntohl(tpte.va_hi)  32) | ntohl(tpte.va_lo_fbo));
+}
+
+static void dump_err_cqe(struct c4iw_dev *dev, struct t4_cqe *err_cqe)
+{
+   __be64 *p = (void *)err_cqe;
+
+   pr_err(AE qpid %d opcode %d status 0x%x 
+  type %d len 0x%x wrid.hi 0x%x wrid.lo 0x%x\n,
+  CQE_QPID(err_cqe), CQE_OPCODE(err_cqe),
+  CQE_STATUS(err_cqe), CQE_TYPE(err_cqe), ntohl(err_cqe-len),
+  CQE_WRID_HI(err_cqe), CQE_WRID_LOW(err_cqe));
+
+   pr_err(%016llx %016llx %016llx %016llx\n,
+  be64_to_cpu(p[0]), be64_to_cpu(p[1]), be64_to_cpu(p[2]),
+  be64_to_cpu(p[3

[PATCH 0/5] cxgb4: Fix for PCI passthrough and some Misc. fixes

2014-06-27 Thread Hariprasad Shenai
Hi,

This patch series fixes probe failure in VM when PF is exposed through PCI
Passthrough. Adds support to use firmware interface to get BAR0 value.
Replace the backdoor mechanism to access the HW memory with PCIe Window method
which fixes memory I/O. Also adds device ID of few more adapters for cxgb4 and
cxgb4vf driver.

The patches series is created against 'net-next' tree.
And includes patches on cxgb4, cxgb4vf and iw_cxgb4 driver.

Since this patch-series contains mainly cxgb4 related changes, we would like to
request this patch series to get merged via David Miller's 'net-next' tree.

We have included all the maintainers of respective drivers. Kindly review the
change and let us know in case of any review comments.

Thanks

Hariprasad Shenai (5):
  rdma/cxgb4: Fixes cxgb4 probe failure in VM when PF is exposed
through PCI Passthrough
  cxgb4: Use FW interface to get BAR0 value
  cxgb4: Replaced the backdoor mechanism to access the HW memory with
PCIe Window method
  cxgb4: Adds device ID for few more Chelsio T4 Adapters
  cxgb4vf: Adds device ID for few more Chelsio T4 Adapters

 drivers/infiniband/hw/cxgb4/cm.c   |3 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |   20 ++-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c|  168 +---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h |1 +
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |  270 +--
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h   |6 +
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c|9 +
 7 files changed, 288 insertions(+), 189 deletions(-)

--
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


[PATCH 1/5] rdma/cxgb4: Fixes cxgb4 probe failure in VM when PF is exposed through PCI Passthrough

2014-06-27 Thread Hariprasad Shenai
Change logic which determines our Physical Function at PCI Probe time.
Now we read the PL_WHOAMI register and get the Physical Function.

Pass Physical Function to Upper Layer Drivers in lld_info structure in the
new field pf added to lld_info.  This is useful for the cases where the
PF, say PF4, is attached to a Virtual Machine via some form of PCI
Pass Through technology and the PCI Function shows up as PF0 in the VM.

Based on original work by Casey Leedom lee...@chelsio.com

Signed-off-by: Casey Leedom lee...@chelsio.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c|3 ++-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   18 ++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h  |1 +
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 5e153f6..d62a0f9 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -465,7 +465,8 @@ static void send_flowc(struct c4iw_ep *ep, struct sk_buff 
*skb)
  16)) | FW_WR_FLOWID(ep-hwtid));
 
flowc-mnemval[0].mnemonic = FW_FLOWC_MNEM_PFNVFN;
-   flowc-mnemval[0].val = 
cpu_to_be32(PCI_FUNC(ep-com.dev-rdev.lldi.pdev-devfn)  8);
+   flowc-mnemval[0].val = cpu_to_be32(FW_PFVF_CMD_PFN
+   (ep-com.dev-rdev.lldi.pf));
flowc-mnemval[1].mnemonic = FW_FLOWC_MNEM_CH;
flowc-mnemval[1].val = cpu_to_be32(ep-tx_chan);
flowc-mnemval[2].mnemonic = FW_FLOWC_MNEM_PORT;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index b7154dc..e8e77b8 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -4053,6 +4053,7 @@ static void uld_attach(struct adapter *adap, unsigned int 
uld)
unsigned short i;
 
lli.pdev = adap-pdev;
+   lli.pf = adap-fn;
lli.l2t = adap-l2t;
lli.tids = adap-tids;
lli.ports = adap-port;
@@ -6294,13 +6295,6 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
return err;
}
 
-   /* We control everything through one PF */
-   func = PCI_FUNC(pdev-devfn);
-   if (func != ent-driver_data) {
-   pci_save_state(pdev);/* to restore SR-IOV later */
-   goto sriov;
-   }
-
err = pci_enable_device(pdev);
if (err) {
dev_err(pdev-dev, cannot enable PCI device\n);
@@ -6344,6 +6338,15 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
goto out_free_adapter;
}
 
+   /* We control everything through one PF */
+   func = SOURCEPF_GET(readl(adapter-regs + PL_WHOAMI));
+   if ((pdev-device == 0xa000  func != 0) ||
+   func != ent-driver_data) {
+   pci_save_state(pdev);/* to restore SR-IOV later */
+   err = 0;
+   goto out_unmap_bar0;
+   }
+
adapter-pdev = pdev;
adapter-pdev_dev = pdev-dev;
adapter-mbox = func;
@@ -6507,7 +6510,6 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
if (is_offload(adapter))
attach_ulds(adapter);
 
-sriov:
 #ifdef CONFIG_PCI_IOV
if (func  ARRAY_SIZE(num_vf)  num_vf[func]  0)
if (pci_enable_sriov(pdev, num_vf[func]) == 0)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
index d719dec..8f60851 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
@@ -253,6 +253,7 @@ struct cxgb4_lld_info {
int dbfifo_int_thresh;   /* doorbell fifo int threshold */
unsigned int sge_pktshift;   /* Padding between CPL and */
 /* packet data */
+   unsigned int pf; /* Physical Function we're using */
bool enable_fw_ofld_conn;/* Enable connection through fw */
 /* WR */
bool ulptx_memwrite_dsgl;/* use of T5 DSGL allowed */
-- 
1.7.1

--
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


[PATCH 5/5] cxgb4vf: Adds device ID for few more Chelsio T4 Adapters

2014-06-27 Thread Hariprasad Shenai
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c|9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c 
b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index ff1cdd1..f002af1 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -2924,6 +2924,15 @@ static DEFINE_PCI_DEVICE_TABLE(cxgb4vf_pci_tbl) = {
CH_DEVICE(0x480a, 0),   /* T404-bt */
CH_DEVICE(0x480d, 0),   /* T480-cr */
CH_DEVICE(0x480e, 0),   /* T440-lp-cr */
+   CH_DEVICE(0x4880, 0),
+   CH_DEVICE(0x4880, 1),
+   CH_DEVICE(0x4880, 2),
+   CH_DEVICE(0x4880, 3),
+   CH_DEVICE(0x4880, 4),
+   CH_DEVICE(0x4880, 5),
+   CH_DEVICE(0x4880, 6),
+   CH_DEVICE(0x4880, 7),
+   CH_DEVICE(0x4880, 8),
CH_DEVICE(0x5800, 0),   /* T580-dbg */
CH_DEVICE(0x5801, 0),   /* T520-cr */
CH_DEVICE(0x5802, 0),   /* T522-cr */
-- 
1.7.1

--
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


[PATCH 4/5] cxgb4: Adds device ID for few more Chelsio T4 Adapters

2014-06-27 Thread Hariprasad Shenai
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   20 
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 74ef0e6..921f805 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -224,6 +224,17 @@ static DEFINE_PCI_DEVICE_TABLE(cxgb4_pci_tbl) = {
CH_DEVICE(0x4008, -1),
CH_DEVICE(0x4009, -1),
CH_DEVICE(0x400a, -1),
+   CH_DEVICE(0x400d, -1),
+   CH_DEVICE(0x400e, -1),
+   CH_DEVICE(0x4080, -1),
+   CH_DEVICE(0x4081, -1),
+   CH_DEVICE(0x4082, -1),
+   CH_DEVICE(0x4083, -1),
+   CH_DEVICE(0x4084, -1),
+   CH_DEVICE(0x4085, -1),
+   CH_DEVICE(0x4086, -1),
+   CH_DEVICE(0x4087, -1),
+   CH_DEVICE(0x4088, -1),
CH_DEVICE(0x4401, 4),
CH_DEVICE(0x4402, 4),
CH_DEVICE(0x4403, 4),
@@ -236,6 +247,15 @@ static DEFINE_PCI_DEVICE_TABLE(cxgb4_pci_tbl) = {
CH_DEVICE(0x440a, 4),
CH_DEVICE(0x440d, 4),
CH_DEVICE(0x440e, 4),
+   CH_DEVICE(0x4480, 4),
+   CH_DEVICE(0x4481, 4),
+   CH_DEVICE(0x4482, 4),
+   CH_DEVICE(0x4483, 4),
+   CH_DEVICE(0x4484, 4),
+   CH_DEVICE(0x4485, 4),
+   CH_DEVICE(0x4486, 4),
+   CH_DEVICE(0x4487, 4),
+   CH_DEVICE(0x4488, 4),
CH_DEVICE(0x5001, 4),
CH_DEVICE(0x5002, 4),
CH_DEVICE(0x5003, 4),
-- 
1.7.1

--
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


[PATCH 3/5] cxgb4: Replaced the backdoor mechanism to access the HW memory with PCIe Window method

2014-06-27 Thread Hariprasad Shenai
Rip out a bunch of redundant PCI-E Memory Window Read/Write routines,
collapse the more general purpose routines into a single routine
thereby eliminating the need for a large stack frame (and extra data
copying) in the outer routine, change everything to use the improved
routine t4_memory_rw.

Based on origninal work by Casey Leedom lee...@chelsio.com and
Steve Wise sw...@opengridcomputing.com

Signed-off-by: Casey Leedom lee...@chelsio.com
Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |   15 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   58 +++---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c  |  246 ++-
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h|1 +
 4 files changed, 148 insertions(+), 172 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 4fd2151..f338a7f 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -654,6 +654,7 @@ struct adapter {
struct dentry *debugfs_root;
 
spinlock_t stats_lock;
+   spinlock_t win0_lock cacheline_aligned_in_smp;
 };
 
 /* Defined bit width of user definable filter tuples
@@ -960,8 +961,17 @@ int t4_wait_dev_ready(struct adapter *adap);
 int t4_link_start(struct adapter *adap, unsigned int mbox, unsigned int port,
  struct link_config *lc);
 int t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int 
port);
-int t4_memory_write(struct adapter *adap, int mtype, u32 addr, u32 len,
-   __be32 *buf);
+
+#define T4_MEMORY_WRITE0
+#define T4_MEMORY_READ 1
+int t4_memory_rw(struct adapter *adap, int win, int mtype, u32 addr, u32 len,
+__be32 *buf, int dir);
+static inline int t4_memory_write(struct adapter *adap, int mtype, u32 addr,
+ u32 len, __be32 *buf)
+{
+   return t4_memory_rw(adap, 0, mtype, addr, len, buf, 0);
+}
+
 int t4_seeprom_wp(struct adapter *adapter, bool enable);
 int get_vpd_params(struct adapter *adapter, struct vpd_params *p);
 int t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size);
@@ -1059,7 +1069,6 @@ int t4_ofld_eq_free(struct adapter *adap, unsigned int 
mbox, unsigned int pf,
 int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl);
 void t4_db_full(struct adapter *adapter);
 void t4_db_dropped(struct adapter *adapter);
-int t4_mem_win_read_len(struct adapter *adap, u32 addr, __be32 *data, int len);
 int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox,
 u32 addr, u32 val);
 void t4_sge_decode_idma_state(struct adapter *adapter, int state);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 524a8b2..74ef0e6 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3066,6 +3066,8 @@ static ssize_t mem_read(struct file *file, char __user 
*buf, size_t count,
loff_t avail = file_inode(file)-i_size;
unsigned int mem = (uintptr_t)file-private_data  3;
struct adapter *adap = file-private_data - mem;
+   __be32 *data;
+   int ret;
 
if (pos  0)
return -EINVAL;
@@ -3074,29 +3076,24 @@ static ssize_t mem_read(struct file *file, char __user 
*buf, size_t count,
if (count  avail - pos)
count = avail - pos;
 
-   while (count) {
-   size_t len;
-   int ret, ofst;
-   __be32 data[16];
+   data = t4_alloc_mem(count);
+   if (!data)
+   return -ENOMEM;
 
-   if ((mem == MEM_MC) || (mem == MEM_MC1))
-   ret = t4_mc_read(adap, mem % MEM_MC, pos, data, NULL);
-   else
-   ret = t4_edc_read(adap, mem, pos, data, NULL);
-   if (ret)
-   return ret;
+   spin_lock(adap-win0_lock);
+   ret = t4_memory_rw(adap, 0, mem, pos, count, data, T4_MEMORY_READ);
+   spin_unlock(adap-win0_lock);
+   if (ret) {
+   t4_free_mem(data);
+   return ret;
+   }
+   ret = copy_to_user(buf, data, count);
 
-   ofst = pos % sizeof(data);
-   len = min(count, sizeof(data) - ofst);
-   if (copy_to_user(buf, (u8 *)data + ofst, len))
-   return -EFAULT;
+   t4_free_mem(data);
+   if (ret)
+   return -EFAULT;
 
-   buf += len;
-   pos += len;
-   count -= len;
-   }
-   count = pos - *ppos;
-   *ppos = pos;
+   *ppos = pos + count;
return count;
 }
 
@@ -3757,7 +3754,11 @@ static int read_eq_indices(struct adapter *adap, u16 
qid, u16 *pidx, u16 *cidx)
__be64 indices;
int

[PATCH 0/2] Fixes skb leak and connection clean up on ARP error

2014-06-23 Thread Hariprasad Shenai
Hi,

This patch series fixes skb leak and connection clean up on ARP error for
iw_cxgb4 driver. 

This patch series is created on top of linux-next tree. We would like to
request this patch series to get merged via Roland's infiniband tree master
branch.

We have included all the maintainers of respective drivers. Kindly review the
change and let us know in case of any review comments.

Thanks

Hariprasad Shenai (2):
  iw_cxgb4: Fix skb_leak in reject_cr
  iw_cxgb4: clean up connection on arp error

 drivers/infiniband/hw/cxgb4/cm.c |   12 ++--
 1 files changed, 10 insertions(+), 2 deletions(-)

--
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


[PATCH 1/2] iw_cxgb4: Fix skb_leak in reject_cr

2014-06-23 Thread Hariprasad Shenai
Based on origninal work by Steve Wise sw...@opengridcomputing.com

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 5e153f6..cc36e9b 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -2180,7 +2180,6 @@ static void reject_cr(struct c4iw_dev *dev, u32 hwtid, 
struct sk_buff *skb)
PDBG(%s c4iw_dev %p tid %u\n, __func__, dev, hwtid);
BUG_ON(skb_cloned(skb));
skb_trim(skb, sizeof(struct cpl_tid_release));
-   skb_get(skb);
release_tid(dev-rdev, hwtid, skb);
return;
 }
-- 
1.7.1

--
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


[PATCH 2/2] iw_cxgb4: clean up connection on arp error

2014-06-23 Thread Hariprasad Shenai
Based on origninal work by Steve Wise sw...@opengridcomputing.com

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c |   11 ++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index cc36e9b..6a93280 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -432,8 +432,17 @@ static void arp_failure_discard(void *handle, struct 
sk_buff *skb)
  */
 static void act_open_req_arp_failure(void *handle, struct sk_buff *skb)
 {
+   struct c4iw_ep *ep = handle;
+
printk(KERN_ERR MOD ARP failure duing connect\n);
kfree_skb(skb);
+   connect_reply_upcall(ep, -EHOSTUNREACH);
+   state_set(ep-com, DEAD);
+   remove_handle(ep-com.dev, ep-com.dev-atid_idr, ep-atid);
+   cxgb4_free_atid(ep-com.dev-rdev.lldi.tids, ep-atid);
+   dst_release(ep-dst);
+   cxgb4_l2t_release(ep-l2t);
+   c4iw_put_ep(ep-com);
 }
 
 /*
@@ -658,7 +667,7 @@ static int send_connect(struct c4iw_ep *ep)
opt2 |= T5_OPT_2_VALID;
opt2 |= V_CONG_CNTRL(CONG_ALG_TAHOE);
}
-   t4_set_arp_err_handler(skb, NULL, act_open_req_arp_failure);
+   t4_set_arp_err_handler(skb, ep, act_open_req_arp_failure);
 
if (is_t4(ep-com.dev-rdev.lldi.adapter_type)) {
if (ep-com.remote_addr.ss_family == AF_INET) {
-- 
1.7.1

--
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


[PATCH net-next 0/4] Adds support for CIQ and other misc. fixes for rdma/cxgb4

2014-06-06 Thread Hariprasad Shenai
Hi All,

This patch series adds support to allocate and use IQs specifically for
indirect interrupts, adds fixes to align ISS for iWARP connections  fixes
related to tcp snd/rvd window for Chelsio T4/T5 adapters on iw_cxgb4.
Also changes Interrupt Holdoff Packet Count threshold of response queues for
cxgb4 driver.

The patches series is created against 'net-next' tree.
And includes patches on cxgb4 and iw_cxgb4 driver.

Since this patch-series contains cxgb4 and iw_cxgb4 patches, we would like to
request this patch series to get merged via David Miller's 'net-next' tree.

We have included all the maintainers of respective drivers. Kindly review the
change and let us know in case of any review comments.

Thanks 

Hariprasad Shenai (4):
  iw_cxgb4: Allocate and use IQs specifically for indirect interrupts
  iw_cxgb4: Choose appropriate hw mtu index and ISS for iWARP
connections
  iw_cxgb4: don't truncate the recv window size
  cxgb4: Change default Interrupt Holdoff Packet Count Threshold

 drivers/infiniband/hw/cxgb4/cm.c|  127 +++--
 drivers/infiniband/hw/cxgb4/cq.c|7 +-
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h  |2 +
 drivers/infiniband/hw/cxgb4/provider.c  |2 +-
 drivers/infiniband/hw/cxgb4/t4.h|1 +
 drivers/infiniband/hw/cxgb4/t4fw_ri_api.h   |1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |   14 ++-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |  236 +++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h  |7 +
 drivers/net/ethernet/chelsio/cxgb4/sge.c|5 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.h  |1 +
 drivers/net/ethernet/chelsio/cxgb4/t4_msg.h |   10 +
 12 files changed, 356 insertions(+), 57 deletions(-)

--
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


[PATCH net-next 4/4] cxgb4: Change default Interrupt Holdoff Packet Count Threshold

2014-06-06 Thread Hariprasad Shenai
Based on original work by Casey Leedom lee...@chelsio.com

Signed-off-by: Casey Leedom lee...@chelsio.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   69 +--
 drivers/net/ethernet/chelsio/cxgb4/sge.c|1 -
 2 files changed, 40 insertions(+), 30 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 5fa5f2a..2f8d6b9 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -2503,8 +2503,7 @@ static unsigned int qtimer_val(const struct adapter *adap,
 }
 
 /**
- * set_rxq_intr_params - set a queue's interrupt holdoff parameters
- * @adap: the adapter
+ * set_rspq_intr_params - set a queue's interrupt holdoff parameters
  * @q: the Rx queue
  * @us: the hold-off time in us, or 0 to disable timer
  * @cnt: the hold-off packet count, or 0 to disable counter
@@ -2512,9 +2511,11 @@ static unsigned int qtimer_val(const struct adapter 
*adap,
  * Sets an Rx queue's interrupt hold-off time and packet count.  At least
  * one of the two needs to be enabled for the queue to generate interrupts.
  */
-static int set_rxq_intr_params(struct adapter *adap, struct sge_rspq *q,
-  unsigned int us, unsigned int cnt)
+static int set_rspq_intr_params(struct sge_rspq *q,
+   unsigned int us, unsigned int cnt)
 {
+   struct adapter *adap = q-adap;
+
if ((us | cnt) == 0)
cnt = 1;
 
@@ -2541,24 +2542,34 @@ static int set_rxq_intr_params(struct adapter *adap, 
struct sge_rspq *q,
return 0;
 }
 
-static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
+/**
+ * set_rx_intr_params - set a net devices's RX interrupt holdoff paramete!
+ * @dev: the network device
+ * @us: the hold-off time in us, or 0 to disable timer
+ * @cnt: the hold-off packet count, or 0 to disable counter
+ *
+ * Set the RX interrupt hold-off parameters for a network device.
+ */
+static int set_rx_intr_params(struct net_device *dev,
+ unsigned int us, unsigned int cnt)
 {
-   const struct port_info *pi = netdev_priv(dev);
+   int i, err;
+   struct port_info *pi = netdev_priv(dev);
struct adapter *adap = pi-adapter;
-   struct sge_rspq *q;
-   int i;
-   int r = 0;
-
-   for (i = pi-first_qset; i  pi-first_qset + pi-nqsets; i++) {
-   q = adap-sge.ethrxq[i].rspq;
-   r = set_rxq_intr_params(adap, q, c-rx_coalesce_usecs,
-   c-rx_max_coalesced_frames);
-   if (r) {
-   dev_err(dev-dev, failed to set coalesce %d\n, r);
-   break;
-   }
+   struct sge_eth_rxq *q = adap-sge.ethrxq[pi-first_qset];
+
+   for (i = 0; i  pi-nqsets; i++, q++) {
+   err = set_rspq_intr_params(q-rspq, us, cnt);
+   if (err)
+   return err;
}
-   return r;
+   return 0;
+}
+
+static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
+{
+   return set_rx_intr_params(dev, c-rx_coalesce_usecs,
+ c-rx_max_coalesced_frames);
 }
 
 static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
@@ -5812,12 +5823,12 @@ static inline bool is_x_10g_port(const struct 
link_config *lc)
   (lc-supported  FW_PORT_CAP_SPEED_40G) != 0;
 }
 
-static inline void init_rspq(struct sge_rspq *q, u8 timer_idx, u8 pkt_cnt_idx,
+static inline void init_rspq(struct adapter *adap, struct sge_rspq *q,
+unsigned int us, unsigned int cnt,
 unsigned int size, unsigned int iqe_size)
 {
-   q-intr_params = QINTR_TIMER_IDX(timer_idx) |
-(pkt_cnt_idx  SGE_NCOUNTERS ? QINTR_CNT_EN : 0);
-   q-pktcnt_idx = pkt_cnt_idx  SGE_NCOUNTERS ? pkt_cnt_idx : 0;
+   q-adap = adap;
+   set_rspq_intr_params(q, us, cnt);
q-iqe_len = iqe_size;
q-size = size;
 }
@@ -5876,7 +5887,7 @@ static void cfg_queues(struct adapter *adap)
for (i = 0; i  ARRAY_SIZE(s-ethrxq); i++) {
struct sge_eth_rxq *r = s-ethrxq[i];
 
-   init_rspq(r-rspq, 0, 0, 1024, 64);
+   init_rspq(adap, r-rspq, 5, 10, 1024, 64);
r-fl.size = 72;
}
 
@@ -5892,7 +5903,7 @@ static void cfg_queues(struct adapter *adap)
for (i = 0; i  ARRAY_SIZE(s-ofldrxq); i++) {
struct sge_ofld_rxq *r = s-ofldrxq[i];
 
-   init_rspq(r-rspq, 0, 0, 1024, 64);
+   init_rspq(adap, r-rspq, 5, 1, 1024, 64);
r-rspq.uld = CXGB4_ULD_ISCSI;
r-fl.size = 72;
}
@@ -5900,7 +5911,7 @@ static void cfg_queues(struct adapter *adap)
for (i = 0; i  ARRAY_SIZE

[PATCH net-next 1/4] iw_cxgb4: Allocate and use IQs specifically for indirect interrupts

2014-06-06 Thread Hariprasad Shenai
Currently indirect interrupts for RDMA CQs funnel through the LLD's RDMA
RXQs, which also handle direct interrupts for offload CPLs during RDMA
connection setup/teardown.  The intended T4 usage model, however, is to
have indirect interrupts flow through dedicated IQs. IE not to mix
indirect interrupts with CPL messages in an IQ.  This patch adds the
concept of RDMA concentrator IQs, or CIQs, setup and maintained by the
LLD and exported to iw_cxgb4 for use when creating CQs. RDMA CPLs will
flow through the LLD's RDMA RXQs, and CQ interrupts flow through the
CIQs.

Design:

cxgb4 creates and exports an array of CIQs for the RDMA ULD.  These IQs
are sized according to the max available CQs available at adapter init.
In addition, these IQs don't need FL buffers since they only service
indirect interrupts.  One CIQ is setup per RX channel similar to the
RDMA RXQs.

iw_cxgb4 will utilize these CIQs based on the vector value passed into
create_cq().  The num_comp_vectors advertised by iw_cxgb4 will be the
number of CIQs configured, and thus the vector value will be the index
into the array of CIQs.

Based on original work by Steve Wise sw...@opengridcomputing.com

Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cq.c|7 ++-
 drivers/infiniband/hw/cxgb4/provider.c  |2 +-
 drivers/infiniband/hw/cxgb4/t4.h|1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |   14 -
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |   62 +--
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h  |2 +
 drivers/net/ethernet/chelsio/cxgb4/sge.c|4 ++
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.h  |1 +
 8 files changed, 84 insertions(+), 9 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index cfaa56a..71fc2ef 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -134,7 +134,8 @@ static int create_cq(struct c4iw_rdev *rdev, struct t4_cq 
*cq,
V_FW_RI_RES_WR_IQANUS(0) |
V_FW_RI_RES_WR_IQANUD(1) |
F_FW_RI_RES_WR_IQANDST |
-   V_FW_RI_RES_WR_IQANDSTINDEX(*rdev-lldi.rxq_ids));
+   V_FW_RI_RES_WR_IQANDSTINDEX(
+   rdev-lldi.ciq_ids[cq-vector]));
res-u.cq.iqdroprss_to_iqesize = cpu_to_be16(
F_FW_RI_RES_WR_IQDROPRSS |
V_FW_RI_RES_WR_IQPCIECH(2) |
@@ -870,6 +871,9 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int 
entries,
 
rhp = to_c4iw_dev(ibdev);
 
+   if (vector = rhp-rdev.lldi.nciq)
+   return ERR_PTR(-EINVAL);
+
chp = kzalloc(sizeof(*chp), GFP_KERNEL);
if (!chp)
return ERR_PTR(-ENOMEM);
@@ -915,6 +919,7 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int 
entries,
}
chp-cq.size = hwentries;
chp-cq.memsize = memsize;
+   chp-cq.vector = vector;
 
ret = create_cq(rhp-rdev, chp-cq,
ucontext ? ucontext-uctx : rhp-rdev.uctx);
diff --git a/drivers/infiniband/hw/cxgb4/provider.c 
b/drivers/infiniband/hw/cxgb4/provider.c
index a94a3e1..31cd188 100644
--- a/drivers/infiniband/hw/cxgb4/provider.c
+++ b/drivers/infiniband/hw/cxgb4/provider.c
@@ -499,7 +499,7 @@ int c4iw_register_device(struct c4iw_dev *dev)
dev-ibdev.node_type = RDMA_NODE_RNIC;
memcpy(dev-ibdev.node_desc, C4IW_NODE_DESC, sizeof(C4IW_NODE_DESC));
dev-ibdev.phys_port_cnt = dev-rdev.lldi.nports;
-   dev-ibdev.num_comp_vectors = 1;
+   dev-ibdev.num_comp_vectors =  dev-rdev.lldi.nciq;
dev-ibdev.dma_device = (dev-rdev.lldi.pdev-dev);
dev-ibdev.query_device = c4iw_query_device;
dev-ibdev.query_port = c4iw_query_port;
diff --git a/drivers/infiniband/hw/cxgb4/t4.h b/drivers/infiniband/hw/cxgb4/t4.h
index 2178f31..68b0a6b 100644
--- a/drivers/infiniband/hw/cxgb4/t4.h
+++ b/drivers/infiniband/hw/cxgb4/t4.h
@@ -542,6 +542,7 @@ struct t4_cq {
size_t memsize;
__be64 bits_type_ts;
u32 cqid;
+   int vector;
u16 size; /* including status page */
u16 cidx;
u16 sw_pidx;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 32db377..f503dce 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -357,11 +357,17 @@ enum {
MAX_OFLD_QSETS = 16,  /* # of offload Tx/Rx queue sets */
MAX_CTRL_QUEUES = NCHAN,  /* # of control Tx queues */
MAX_RDMA_QUEUES = NCHAN,  /* # of streaming RDMA Rx queues */
+   MAX_RDMA_CIQS = NCHAN,/* # of  RDMA concentrator IQs */
+   MAX_ISCSI_QUEUES = NCHAN, /* # of streaming iSCSI Rx queues */
 };
 
 enum

[PATCH net-next 2/4] iw_cxgb4: Choose appropriate hw mtu index and ISS for iWARP connections

2014-06-06 Thread Hariprasad Shenai
Select the appropriate hw mtu index and initial sequence number to optimize
hw memory performance.

Add new cxgb4_best_aligned_mtu() which allows callers to provide enough
information to be used to [possibly] select an MTU which will result in the
TCP Data Segment Size (AKA Maximum Segment Size) to be an aligned value.

If an RTR message exhange is required, then align the ISS to 8B - 1 + 4, so
that after the SYN the send seqno will align on a 4B boundary. The RTR
message exchange will leave the send seqno aligned on an 8B boundary.
If an RTR is not required, then align the ISS to 8B - 1.  The goal is
to have the send seqno be 8B aligned when we send the first FPDU.

Based on original work by Casey Leedom leee...@chelsio.com and
Steve Wise sw...@opengridcomputing.com

Signed-off-by: Casey Leedom lee...@chelsio.com
Signed-off-by: Steve Wise sw...@opengridcomputing.com
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/cm.c|   73 +---
 drivers/infiniband/hw/cxgb4/t4fw_ri_api.h   |1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c |  107 ++-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h  |5 +
 drivers/net/ethernet/chelsio/cxgb4/t4_msg.h |9 ++
 5 files changed, 180 insertions(+), 15 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 1f863a9..d2e9f72 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -232,12 +232,16 @@ static void release_tid(struct c4iw_rdev *rdev, u32 
hwtid, struct sk_buff *skb)
 
 static void set_emss(struct c4iw_ep *ep, u16 opt)
 {
-   ep-emss = ep-com.dev-rdev.lldi.mtus[GET_TCPOPT_MSS(opt)] - 40;
+   ep-emss = ep-com.dev-rdev.lldi.mtus[GET_TCPOPT_MSS(opt)] -
+  sizeof(struct iphdr) - sizeof(struct tcphdr);
ep-mss = ep-emss;
if (GET_TCPOPT_TSTAMP(opt))
ep-emss -= 12;
if (ep-emss  128)
ep-emss = 128;
+   if (ep-emss  7)
+   PDBG(Warning: misaligned mtu idx %u mss %u emss=%u\n,
+GET_TCPOPT_MSS(opt), ep-mss, ep-emss);
PDBG(%s mss_idx %u mss %u emss=%u\n, __func__, GET_TCPOPT_MSS(opt),
 ep-mss, ep-emss);
 }
@@ -528,6 +532,17 @@ static int send_abort(struct c4iw_ep *ep, struct sk_buff 
*skb, gfp_t gfp)
return c4iw_l2t_send(ep-com.dev-rdev, skb, ep-l2t);
 }
 
+static void best_mtu(const unsigned short *mtus, unsigned short mtu,
+unsigned int *idx, int use_ts)
+{
+   unsigned short hdr_size = sizeof(struct iphdr) +
+ sizeof(struct tcphdr) +
+ (use_ts ? 12 : 0);
+   unsigned short data_size = mtu - hdr_size;
+
+   cxgb4_best_aligned_mtu(mtus, hdr_size, data_size, 8, idx);
+}
+
 static int send_connect(struct c4iw_ep *ep)
 {
struct cpl_act_open_req *req;
@@ -565,7 +580,8 @@ static int send_connect(struct c4iw_ep *ep)
}
set_wr_txq(skb, CPL_PRIORITY_SETUP, ep-ctrlq_idx);
 
-   cxgb4_best_mtu(ep-com.dev-rdev.lldi.mtus, ep-mtu, mtu_idx);
+   best_mtu(ep-com.dev-rdev.lldi.mtus, ep-mtu, mtu_idx,
+enable_tcp_timestamps);
wscale = compute_wscale(rcv_win);
opt0 = (nocong ? NO_CONG(1) : 0) |
   KEEP_ALIVE(1) |
@@ -633,6 +649,13 @@ static int send_connect(struct c4iw_ep *ep)
req6-opt2 = cpu_to_be32(opt2);
}
} else {
+   u32 isn = (prandom_u32()  ~7UL) - 1;
+
+   opt2 |= T5_OPT_2_VALID;
+   opt2 |= CONG_CNTRL_VALID; /* OPT_2_ISS for T5 */
+   if (peer2peer)
+   isn += 4;
+
if (ep-com.remote_addr.ss_family == AF_INET) {
t5_req = (struct cpl_t5_act_open_req *)
 skb_put(skb, wrlen);
@@ -649,6 +672,9 @@ static int send_connect(struct c4iw_ep *ep)
 cxgb4_select_ntuple(
 ep-com.dev-rdev.lldi.ports[0],
 ep-l2t)));
+   t5_req-rsvd = cpu_to_be32(isn);
+   PDBG(%s snd_isn %u\n, __func__,
+be32_to_cpu(t5_req-rsvd));
t5_req-opt2 = cpu_to_be32(opt2);
} else {
t5_req6 = (struct cpl_t5_act_open_req6 *)
@@ -672,6 +698,9 @@ static int send_connect(struct c4iw_ep *ep)
cxgb4_select_ntuple(
ep-com.dev-rdev.lldi.ports[0],
ep-l2t));
+   t5_req6-rsvd = cpu_to_be32(isn);
+   PDBG(%s snd_isn %u\n, __func__,
+be32_to_cpu(t5_req6-rsvd

[PATCH] iw_cxgb4: Update Kconfig to include Chelsio T5 adapter.

2014-04-25 Thread Hariprasad Shenai
Signed-off-by: Hariprasad Shenai haripra...@chelsio.com
---
 drivers/infiniband/hw/cxgb4/Kconfig | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/Kconfig 
b/drivers/infiniband/hw/cxgb4/Kconfig
index d4e8983..23f38cf 100644
--- a/drivers/infiniband/hw/cxgb4/Kconfig
+++ b/drivers/infiniband/hw/cxgb4/Kconfig
@@ -1,10 +1,10 @@
 config INFINIBAND_CXGB4
-   tristate Chelsio T4 RDMA Driver
+   tristate Chelsio T4/T5 RDMA Driver
depends on CHELSIO_T4  INET  (IPV6 || IPV6=n)
select GENERIC_ALLOCATOR
---help---
- This is an iWARP/RDMA driver for the Chelsio T4 1GbE and
- 10GbE adapters.
+ This is an iWARP/RDMA driver for the Chelsio T4 and T5
+ 1GbE, 10GbE adapters and T5 40GbE adapter.
 
  For general information about Chelsio and our products, visit
  our website at http://www.chelsio.com.
-- 
1.8.4

--
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


[PATCH 4/8] iw_cxgb4: Max fastreg depth depends on DSGL support

2014-03-26 Thread Hariprasad Shenai
From: Steve Wise sw...@opengridcomputing.com

The max depth of a fastreg mr depends on whether the device supports
DSGL or not.  So compute it dynamically based on the device support and
the module use_dsgl option.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
---
 drivers/infiniband/hw/cxgb4/provider.c | 2 +-
 drivers/infiniband/hw/cxgb4/qp.c   | 3 ++-
 drivers/infiniband/hw/cxgb4/t4.h   | 9 -
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/provider.c 
b/drivers/infiniband/hw/cxgb4/provider.c
index 7e94c9a..deaaa21 100644
--- a/drivers/infiniband/hw/cxgb4/provider.c
+++ b/drivers/infiniband/hw/cxgb4/provider.c
@@ -287,7 +287,7 @@ static int c4iw_query_device(struct ib_device *ibdev,
props-max_mr = c4iw_num_stags(dev-rdev);
props-max_pd = T4_MAX_NUM_PD;
props-local_ca_ack_delay = 0;
-   props-max_fast_reg_page_list_len = T4_MAX_FR_DEPTH;
+   props-max_fast_reg_page_list_len = t4_max_fr_depth(use_dsgl);
 
return 0;
 }
diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
index 8ad7d2e..0af82af 100644
--- a/drivers/infiniband/hw/cxgb4/qp.c
+++ b/drivers/infiniband/hw/cxgb4/qp.c
@@ -555,7 +555,8 @@ static int build_fastreg(struct t4_sq *sq, union t4_wr *wqe,
int pbllen = roundup(wr-wr.fast_reg.page_list_len * sizeof(u64), 32);
int rem;
 
-   if (wr-wr.fast_reg.page_list_len  T4_MAX_FR_DEPTH)
+   if (wr-wr.fast_reg.page_list_len 
+   t4_max_fr_depth(use_dsgl))
return -EINVAL;
 
wqe-fr.qpbinde_to_dcacpu = 0;
diff --git a/drivers/infiniband/hw/cxgb4/t4.h b/drivers/infiniband/hw/cxgb4/t4.h
index 62017a7..1ba7a87 100644
--- a/drivers/infiniband/hw/cxgb4/t4.h
+++ b/drivers/infiniband/hw/cxgb4/t4.h
@@ -84,7 +84,14 @@ struct t4_status_page {
sizeof(struct fw_ri_isgl)) / sizeof(struct fw_ri_sge))
 #define T4_MAX_FR_IMMD ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_fr_nsmr_wr) - \
sizeof(struct fw_ri_immd))  ~31UL)
-#define T4_MAX_FR_DEPTH (1024 / sizeof(u64))
+#define T4_MAX_FR_IMMD_DEPTH (T4_MAX_FR_IMMD / sizeof(u64))
+#define T4_MAX_FR_DSGL 1024
+#define T4_MAX_FR_DSGL_DEPTH (T4_MAX_FR_DSGL / sizeof(u64))
+
+static inline int t4_max_fr_depth(int use_dsgl)
+{
+   return use_dsgl ? T4_MAX_FR_DSGL_DEPTH : T4_MAX_FR_IMMD_DEPTH;
+}
 
 #define T4_RQ_NUM_SLOTS 2
 #define T4_RQ_NUM_BYTES (T4_EQ_ENTRY_SIZE * T4_RQ_NUM_SLOTS)
-- 
1.8.4

--
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


[PATCH 2/8] iw_cxgb4: rmb() after reading valid gen bit

2014-03-26 Thread Hariprasad Shenai
From: Steve Wise sw...@opengridcomputing.com

Some HW platforms can reorder read operations, so we must rmb() after
we see a valid gen bit in a CQE but before we read any other fields from
the CQE.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
---
 drivers/infiniband/hw/cxgb4/t4.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/infiniband/hw/cxgb4/t4.h b/drivers/infiniband/hw/cxgb4/t4.h
index e73ace7..62017a7 100644
--- a/drivers/infiniband/hw/cxgb4/t4.h
+++ b/drivers/infiniband/hw/cxgb4/t4.h
@@ -566,6 +566,8 @@ static inline int t4_next_hw_cqe(struct t4_cq *cq, struct 
t4_cqe **cqe)
printk(KERN_ERR MOD cq overflow cqid %u\n, cq-cqid);
BUG_ON(1);
} else if (t4_valid_cqe(cq, cq-queue[cq-cidx])) {
+   /* Ensure CQE is flushed to memory */
+   rmb();
*cqe = cq-queue[cq-cidx];
ret = 0;
} else
-- 
1.8.4

--
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


[PATCH 1/8] iw_cxgb4: endpoint timeout fixes

2014-03-26 Thread Hariprasad Shenai
From: Steve Wise sw...@opengridcomputing.com

1) timedout endpoint processing can be starved. If there is continual
CPL messages flowing into the driver, the endpoint timeout processing
can be starved.  This condition exposed the other bugs below.

Solution: In process_work(), call process_timedout_eps() after each CPL
is processed.

2) Connection events can be processed even though the endpoint is on
the timeout list.  If the endpoint is scheduled for timeout processing,
then we must ignore MPA Start Requests and Replies.

Solution: Change stop_ep_timer() to return 1 if the ep has already been
queued for timeout processing.  All the callers of stop_ep_timer() need
to check this and act accordingly.  There are just a few cases where
the caller needs to do something different if stop_ep_timer() returns 1:

1) in process_mpa_reply(), ignore the reply and  process_timeout()
will abort the connection.

2) in process_mpa_request, ignore the request and process_timeout()
will abort the connection.

It is ok for callers of stop_ep_timer() to abort the connection since
that will leave the state in ABORTING or DEAD, and process_timeout()
now ignores timeouts when the ep is in these states.

3) Double insertion on the timeout list.  Since the endpoint timers are
used for connection setup and teardown, we need to guard against the
possibility that an endpoint is already on the timeout list.  This is
a rare condition and only seen under heavy load and in the presense of
the above 2 bugs.

Solution: In ep_timeout(), don't queue the endpoint if it is already on
the queue.

Signed-off-by: Steve Wise sw...@opengridcomputing.com
---
 drivers/infiniband/hw/cxgb4/cm.c | 89 +---
 1 file changed, 56 insertions(+), 33 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index fe5db3c..471614e 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -173,12 +173,15 @@ static void start_ep_timer(struct c4iw_ep *ep)
add_timer(ep-timer);
 }
 
-static void stop_ep_timer(struct c4iw_ep *ep)
+static int stop_ep_timer(struct c4iw_ep *ep)
 {
PDBG(%s ep %p stopping\n, __func__, ep);
del_timer_sync(ep-timer);
-   if (!test_and_set_bit(TIMEOUT, ep-com.flags))
+   if (!test_and_set_bit(TIMEOUT, ep-com.flags)) {
c4iw_put_ep(ep-com);
+   return 0;
+   }
+   return 1;
 }
 
 static int c4iw_l2t_send(struct c4iw_rdev *rdev, struct sk_buff *skb,
@@ -1165,12 +1168,11 @@ static void process_mpa_reply(struct c4iw_ep *ep, 
struct sk_buff *skb)
PDBG(%s ep %p tid %u\n, __func__, ep, ep-hwtid);
 
/*
-* Stop mpa timer.  If it expired, then the state has
-* changed and we bail since ep_timeout already aborted
-* the connection.
+* Stop mpa timer.  If it expired, then
+* we ignore the MPA reply.  process_timeout()
+* will abort the connection.
 */
-   stop_ep_timer(ep);
-   if (ep-com.state != MPA_REQ_SENT)
+   if (stop_ep_timer(ep))
return;
 
/*
@@ -1375,15 +1377,12 @@ static void process_mpa_request(struct c4iw_ep *ep, 
struct sk_buff *skb)
 
PDBG(%s ep %p tid %u\n, __func__, ep, ep-hwtid);
 
-   if (ep-com.state != MPA_REQ_WAIT)
-   return;
-
/*
 * If we get more than the supported amount of private data
 * then we must fail this connection.
 */
if (ep-mpa_pkt_len + skb-len  sizeof(ep-mpa_pkt)) {
-   stop_ep_timer(ep);
+   (void)stop_ep_timer(ep);
abort_connection(ep, skb, GFP_KERNEL);
return;
}
@@ -1413,13 +1412,13 @@ static void process_mpa_request(struct c4iw_ep *ep, 
struct sk_buff *skb)
if (mpa-revision  mpa_rev) {
printk(KERN_ERR MOD %s MPA version mismatch. Local = %d,
Received = %d\n, __func__, mpa_rev, mpa-revision);
-   stop_ep_timer(ep);
+   (void)stop_ep_timer(ep);
abort_connection(ep, skb, GFP_KERNEL);
return;
}
 
if (memcmp(mpa-key, MPA_KEY_REQ, sizeof(mpa-key))) {
-   stop_ep_timer(ep);
+   (void)stop_ep_timer(ep);
abort_connection(ep, skb, GFP_KERNEL);
return;
}
@@ -1430,7 +1429,7 @@ static void process_mpa_request(struct c4iw_ep *ep, 
struct sk_buff *skb)
 * Fail if there's too much private data.
 */
if (plen  MPA_MAX_PRIVATE_DATA) {
-   stop_ep_timer(ep);
+   (void)stop_ep_timer(ep);
abort_connection(ep, skb, GFP_KERNEL);
return;
}
@@ -1439,7 +1438,7 @@ static void process_mpa_request(struct c4iw_ep *ep, 
struct sk_buff *skb)
 * If plen does not account for pkt size
 */
if (ep-mpa_pkt_len  (sizeof(*mpa) + plen)) {
-   

[PATCH 6/8] iw_cxgb4: Initialize reserved fields in a FW work request

2014-03-26 Thread Hariprasad Shenai
From: Steve Wise sw...@opengridcomputing.com

Signed-off-by: Steve Wise sw...@opengridcomputing.com
---
 drivers/infiniband/hw/cxgb4/qp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
index 0af82af..e865fa4 100644
--- a/drivers/infiniband/hw/cxgb4/qp.c
+++ b/drivers/infiniband/hw/cxgb4/qp.c
@@ -425,6 +425,8 @@ static int build_rdma_send(struct t4_sq *sq, union t4_wr 
*wqe,
default:
return -EINVAL;
}
+   wqe-send.r3 = 0;
+   wqe-send.r4 = 0;
 
plen = 0;
if (wr-num_sge) {
-- 
1.8.4

--
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


  1   2   3   4   >