Re: [PATCH v5 19/27] IB/Verbs: Use management helper cap_iw_cm()

2015-04-21 Thread Michael Wang


On 04/20/2015 05:51 PM, Tom Tucker wrote:
[snip]
int ib_query_gid(struct ib_device *device,
 u8 port_num, int index, union ib_gid *gid);

 iWARP devices _must_ support the IWCM so cap_iw_cm() is not really useful.
 Sean suggested to add this helper paired with cap_ib_cm(), may be there are
 some consideration on maintainability?

 Me too also prefer this way to make the code more readable ;-)
 
 It's more consistent, but not necessarily more readable -- if by readability 
 we mean understanding.
 
 If the reader knows how the transports work, then the reader would be 
 confused by the addition of a check that is always true. For the reader that 
 doesn't know, the addition of the check implies that the support is optional, 
 which it is not.

The purpose is to make sure folks understand what we really want to check
when they reviewing the code :-) and prepared for the further reform which may
not rely on technology type any more, for example the device could tell core
layer directly what management it required with a bitmask :-)

Regards,
Michael Wang

 
 Tom
 
 Regards,
 Michael Wang


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


Re: [PATCH v5 19/27] IB/Verbs: Use management helper cap_iw_cm()

2015-04-21 Thread Tom Tucker

On 4/21/15 2:39 AM, Michael Wang wrote:


On 04/20/2015 05:51 PM, Tom Tucker wrote:
[snip]

int ib_query_gid(struct ib_device *device,
 u8 port_num, int index, union ib_gid *gid);


iWARP devices _must_ support the IWCM so cap_iw_cm() is not really useful.

Sean suggested to add this helper paired with cap_ib_cm(), may be there are
some consideration on maintainability?

Me too also prefer this way to make the code more readable ;-)

It's more consistent, but not necessarily more readable -- if by readability we 
mean understanding.

If the reader knows how the transports work, then the reader would be confused 
by the addition of a check that is always true. For the reader that doesn't 
know, the addition of the check implies that the support is optional, which it 
is not.

The purpose is to make sure folks understand what we really want to check
when they reviewing the code :-) and prepared for the further reform which may
not rely on technology type any more, for example the device could tell core
layer directly what management it required with a bitmask :-)

Hi Michael,

Thanks for the reply, but my premise was just wrong...I need to review the 
whole patch, not just a snippet.


Thanks,
Tom

Regards,
Michael Wang


Tom


Regards,
Michael Wang

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


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


Re: [PATCH v5 19/27] IB/Verbs: Use management helper cap_iw_cm()

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:40:27AM +0200, Michael Wang wrote:
 
 Introduce helper cap_iw_cm() to help us check if the port of an
 IB device support IWARP Communication Manager.
 
 Cc: Hal Rosenstock h...@dev.mellanox.co.il
 Cc: Steve Wise sw...@opengridcomputing.com
 Cc: Tom Talpey t...@talpey.com
 Cc: Jason Gunthorpe jguntho...@obsidianresearch.com
 Cc: Doug Ledford dledf...@redhat.com
 Cc: Ira Weiny ira.we...@intel.com
 Cc: Sean Hefty sean.he...@intel.com
 Signed-off-by: Michael Wang yun.w...@profitbricks.com

Reviewed-by: Ira Weiny ira.we...@intel.com

 ---
  drivers/infiniband/core/cma.c | 14 +++---
  include/rdma/ib_verbs.h   | 15 +++
  2 files changed, 22 insertions(+), 7 deletions(-)
 
 diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
 index ff59dbc..dd37b4a 100644
 --- a/drivers/infiniband/core/cma.c
 +++ b/drivers/infiniband/core/cma.c
 @@ -775,7 +775,7 @@ int rdma_init_qp_attr(struct rdma_cm_id *id, struct 
 ib_qp_attr *qp_attr,
  
   if (qp_attr-qp_state == IB_QPS_RTR)
   qp_attr-rq_psn = id_priv-seq_num;
 - } else if (rdma_tech_iwarp(id-device, id-port_num)) {
 + } else if (cap_iw_cm(id-device, id-port_num)) {
   if (!id_priv-cm_id.iw) {
   qp_attr-qp_access_flags = 0;
   *qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS;
 @@ -1057,7 +1057,7 @@ void rdma_destroy_id(struct rdma_cm_id *id)
   if (cap_ib_cm(id_priv-id.device, 1)) {
   if (id_priv-cm_id.ib)
   ib_destroy_cm_id(id_priv-cm_id.ib);
 - } else if (rdma_tech_iwarp(id_priv-id.device, 1)) {
 + } else if (cap_iw_cm(id_priv-id.device, 1)) {
   if (id_priv-cm_id.iw)
   iw_destroy_cm_id(id_priv-cm_id.iw);
   }
 @@ -2541,7 +2541,7 @@ int rdma_listen(struct rdma_cm_id *id, int backlog)
   ret = cma_ib_listen(id_priv);
   if (ret)
   goto err;
 - } else if (rdma_tech_iwarp(id-device, 1)) {
 + } else if (cap_iw_cm(id-device, 1)) {
   ret = cma_iw_listen(id_priv, backlog);
   if (ret)
   goto err;
 @@ -2886,7 +2886,7 @@ int rdma_connect(struct rdma_cm_id *id, struct 
 rdma_conn_param *conn_param)
   ret = cma_resolve_ib_udp(id_priv, conn_param);
   else
   ret = cma_connect_ib(id_priv, conn_param);
 - } else if (rdma_tech_iwarp(id-device, id-port_num))
 + } else if (cap_iw_cm(id-device, id-port_num))
   ret = cma_connect_iw(id_priv, conn_param);
   else
   ret = -ENOSYS;
 @@ -3008,7 +3008,7 @@ int rdma_accept(struct rdma_cm_id *id, struct 
 rdma_conn_param *conn_param)
   else
   ret = cma_rep_recv(id_priv);
   }
 - } else if (rdma_tech_iwarp(id-device, id-port_num))
 + } else if (cap_iw_cm(id-device, id-port_num))
   ret = cma_accept_iw(id_priv, conn_param);
   else
   ret = -ENOSYS;
 @@ -3063,7 +3063,7 @@ int rdma_reject(struct rdma_cm_id *id, const void 
 *private_data,
   ret = ib_send_cm_rej(id_priv-cm_id.ib,
IB_CM_REJ_CONSUMER_DEFINED, NULL,
0, private_data, private_data_len);
 - } else if (rdma_tech_iwarp(id-device, id-port_num)) {
 + } else if (cap_iw_cm(id-device, id-port_num)) {
   ret = iw_cm_reject(id_priv-cm_id.iw,
  private_data, private_data_len);
   } else
 @@ -3089,7 +3089,7 @@ int rdma_disconnect(struct rdma_cm_id *id)
   /* Initiate or respond to a disconnect. */
   if (ib_send_cm_dreq(id_priv-cm_id.ib, NULL, 0))
   ib_send_cm_drep(id_priv-cm_id.ib, NULL, 0);
 - } else if (rdma_tech_iwarp(id-device, id-port_num)) {
 + } else if (cap_iw_cm(id-device, id-port_num)) {
   ret = iw_cm_disconnect(id_priv-cm_id.iw, 0);
   } else
   ret = -EINVAL;
 diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
 index 6805e3e..e4999f6 100644
 --- a/include/rdma/ib_verbs.h
 +++ b/include/rdma/ib_verbs.h
 @@ -1818,6 +1818,21 @@ static inline int cap_ib_cm(struct ib_device *device, 
 u8 port_num)
   return rdma_ib_or_iboe(device, port_num);
  }
  
 +/**
 + * cap_iw_cm - Check if the port of device has the capability IWARP
 + * Communication Manager.
 + *
 + * @device: Device to be checked
 + * @port_num: Port number of the device
 + *
 + * Return 0 when port of the device don't support IWARP
 + * Communication Manager.
 + */
 +static inline int cap_iw_cm(struct ib_device *device, u8 port_num)
 +{
 + return rdma_tech_iwarp(device, port_num);
 +}
 +
  int ib_query_gid(struct 

Re: [PATCH v5 19/27] IB/Verbs: Use management helper cap_iw_cm()

2015-04-20 Thread Steve Wise

On 4/20/2015 3:40 AM, Michael Wang wrote:

Introduce helper cap_iw_cm() to help us check if the port of an
IB device support IWARP Communication Manager.

Cc: Hal Rosenstock h...@dev.mellanox.co.il
Cc: Steve Wise sw...@opengridcomputing.com
Cc: Tom Talpey t...@talpey.com
Cc: Jason Gunthorpe jguntho...@obsidianresearch.com
Cc: Doug Ledford dledf...@redhat.com
Cc: Ira Weiny ira.we...@intel.com
Cc: Sean Hefty sean.he...@intel.com
Signed-off-by: Michael Wang yun.w...@profitbricks.com
---
  drivers/infiniband/core/cma.c | 14 +++---
  include/rdma/ib_verbs.h   | 15 +++
  2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index ff59dbc..dd37b4a 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -775,7 +775,7 @@ int rdma_init_qp_attr(struct rdma_cm_id *id, struct 
ib_qp_attr *qp_attr,
  
  		if (qp_attr-qp_state == IB_QPS_RTR)

qp_attr-rq_psn = id_priv-seq_num;
-   } else if (rdma_tech_iwarp(id-device, id-port_num)) {
+   } else if (cap_iw_cm(id-device, id-port_num)) {
if (!id_priv-cm_id.iw) {
qp_attr-qp_access_flags = 0;
*qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS;
@@ -1057,7 +1057,7 @@ void rdma_destroy_id(struct rdma_cm_id *id)
if (cap_ib_cm(id_priv-id.device, 1)) {
if (id_priv-cm_id.ib)
ib_destroy_cm_id(id_priv-cm_id.ib);
-   } else if (rdma_tech_iwarp(id_priv-id.device, 1)) {
+   } else if (cap_iw_cm(id_priv-id.device, 1)) {
if (id_priv-cm_id.iw)
iw_destroy_cm_id(id_priv-cm_id.iw);
}
@@ -2541,7 +2541,7 @@ int rdma_listen(struct rdma_cm_id *id, int backlog)
ret = cma_ib_listen(id_priv);
if (ret)
goto err;
-   } else if (rdma_tech_iwarp(id-device, 1)) {
+   } else if (cap_iw_cm(id-device, 1)) {
ret = cma_iw_listen(id_priv, backlog);
if (ret)
goto err;
@@ -2886,7 +2886,7 @@ int rdma_connect(struct rdma_cm_id *id, struct 
rdma_conn_param *conn_param)
ret = cma_resolve_ib_udp(id_priv, conn_param);
else
ret = cma_connect_ib(id_priv, conn_param);
-   } else if (rdma_tech_iwarp(id-device, id-port_num))
+   } else if (cap_iw_cm(id-device, id-port_num))
ret = cma_connect_iw(id_priv, conn_param);
else
ret = -ENOSYS;
@@ -3008,7 +3008,7 @@ int rdma_accept(struct rdma_cm_id *id, struct 
rdma_conn_param *conn_param)
else
ret = cma_rep_recv(id_priv);
}
-   } else if (rdma_tech_iwarp(id-device, id-port_num))
+   } else if (cap_iw_cm(id-device, id-port_num))
ret = cma_accept_iw(id_priv, conn_param);
else
ret = -ENOSYS;
@@ -3063,7 +3063,7 @@ int rdma_reject(struct rdma_cm_id *id, const void 
*private_data,
ret = ib_send_cm_rej(id_priv-cm_id.ib,
 IB_CM_REJ_CONSUMER_DEFINED, NULL,
 0, private_data, private_data_len);
-   } else if (rdma_tech_iwarp(id-device, id-port_num)) {
+   } else if (cap_iw_cm(id-device, id-port_num)) {
ret = iw_cm_reject(id_priv-cm_id.iw,
   private_data, private_data_len);
} else
@@ -3089,7 +3089,7 @@ int rdma_disconnect(struct rdma_cm_id *id)
/* Initiate or respond to a disconnect. */
if (ib_send_cm_dreq(id_priv-cm_id.ib, NULL, 0))
ib_send_cm_drep(id_priv-cm_id.ib, NULL, 0);
-   } else if (rdma_tech_iwarp(id-device, id-port_num)) {
+   } else if (cap_iw_cm(id-device, id-port_num)) {
ret = iw_cm_disconnect(id_priv-cm_id.iw, 0);
} else
ret = -EINVAL;
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 6805e3e..e4999f6 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1818,6 +1818,21 @@ static inline int cap_ib_cm(struct ib_device *device, u8 
port_num)
return rdma_ib_or_iboe(device, port_num);
  }
  
+/**

+ * cap_iw_cm - Check if the port of device has the capability IWARP
+ * Communication Manager.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device don't support IWARP
+ * Communication Manager.
+ */
+static inline int cap_iw_cm(struct ib_device *device, u8 port_num)
+{
+   return rdma_tech_iwarp(device, port_num);
+}
+
  int ib_query_gid(struct ib_device *device,
 u8 port_num, int index, union 

Re: [PATCH v5 19/27] IB/Verbs: Use management helper cap_iw_cm()

2015-04-20 Thread Michael Wang
On 04/20/2015 04:00 PM, Steve Wise wrote:
 On 4/20/2015 3:40 AM, Michael Wang wrote:
[snip]
 diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
 index 6805e3e..e4999f6 100644
 --- a/include/rdma/ib_verbs.h
 +++ b/include/rdma/ib_verbs.h
 @@ -1818,6 +1818,21 @@ static inline int cap_ib_cm(struct ib_device *device, 
 u8 port_num)
   return rdma_ib_or_iboe(device, port_num);
   }
   +/**
 + * cap_iw_cm - Check if the port of device has the capability IWARP
 + * Communication Manager.
 + *
 + * @device: Device to be checked
 + * @port_num: Port number of the device
 + *
 + * Return 0 when port of the device don't support IWARP
 + * Communication Manager.
 + */
 +static inline int cap_iw_cm(struct ib_device *device, u8 port_num)
 +{
 +return rdma_tech_iwarp(device, port_num);
 +}
 +
   int ib_query_gid(struct ib_device *device,
u8 port_num, int index, union ib_gid *gid);
   
 
 iWARP devices _must_ support the IWCM so cap_iw_cm() is not really useful.

Sean suggested to add this helper paired with cap_ib_cm(), may be there are
some consideration on maintainability?

Me too also prefer this way to make the code more readable ;-)

Regards,
Michael Wang

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


Re: [PATCH v5 19/27] IB/Verbs: Use management helper cap_iw_cm()

2015-04-20 Thread Tom Tucker

On 4/20/15 11:19 AM, Jason Gunthorpe wrote:

On Mon, Apr 20, 2015 at 10:51:58AM -0500, Tom Tucker wrote:

On 4/20/15 10:16 AM, Michael Wang wrote:

On 04/20/2015 04:00 PM, Steve Wise wrote:

On 4/20/2015 3:40 AM, Michael Wang wrote:

[snip]

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 6805e3e..e4999f6 100644
+++ b/include/rdma/ib_verbs.h
@@ -1818,6 +1818,21 @@ static inline int cap_ib_cm(struct ib_device *device, u8 
port_num)
   return rdma_ib_or_iboe(device, port_num);
   }
   +/**
+ * cap_iw_cm - Check if the port of device has the capability IWARP
+ * Communication Manager.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device don't support IWARP
+ * Communication Manager.
+ */
+static inline int cap_iw_cm(struct ib_device *device, u8 port_num)
+{
+return rdma_tech_iwarp(device, port_num);
+}
+
   int ib_query_gid(struct ib_device *device,
u8 port_num, int index, union ib_gid *gid);

iWARP devices _must_ support the IWCM so cap_iw_cm() is not really useful.

Sean suggested to add this helper paired with cap_ib_cm(), may be there are
some consideration on maintainability?

Me too also prefer this way to make the code more readable ;-)

It's more consistent, but not necessarily more readable -- if by
readability we mean understanding.

If the reader knows how the transports work, then the reader would
be confused by the addition of a check that is always true. For the
reader that doesn't know, the addition of the check implies that the
support is optional, which it is not.

No, it says this code is concerned with the unique parts of iWarp
related to CM, not the other unique parts of iWarp. The check isn't
aways true, it is just always true on iWarp devices.

That became the problem with the old way of just saying 'is iWarp'
(and others). There are too many differences, the why became lost in
many places.

There are now too many standards, and several do not have public docs,
to keep relying on a mess of 'is standard' tests.


You're right Jason, this gets called with the device handle so it's only 
true for iwarp.



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


Re: [PATCH v5 19/27] IB/Verbs: Use management helper cap_iw_cm()

2015-04-20 Thread Jason Gunthorpe
On Mon, Apr 20, 2015 at 10:51:58AM -0500, Tom Tucker wrote:
 On 4/20/15 10:16 AM, Michael Wang wrote:
 On 04/20/2015 04:00 PM, Steve Wise wrote:
 On 4/20/2015 3:40 AM, Michael Wang wrote:
 [snip]
 diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
 index 6805e3e..e4999f6 100644
 +++ b/include/rdma/ib_verbs.h
 @@ -1818,6 +1818,21 @@ static inline int cap_ib_cm(struct ib_device 
 *device, u8 port_num)
return rdma_ib_or_iboe(device, port_num);
}
+/**
 + * cap_iw_cm - Check if the port of device has the capability IWARP
 + * Communication Manager.
 + *
 + * @device: Device to be checked
 + * @port_num: Port number of the device
 + *
 + * Return 0 when port of the device don't support IWARP
 + * Communication Manager.
 + */
 +static inline int cap_iw_cm(struct ib_device *device, u8 port_num)
 +{
 +return rdma_tech_iwarp(device, port_num);
 +}
 +
int ib_query_gid(struct ib_device *device,
 u8 port_num, int index, union ib_gid *gid);
 iWARP devices _must_ support the IWCM so cap_iw_cm() is not really useful.
 Sean suggested to add this helper paired with cap_ib_cm(), may be there are
 some consideration on maintainability?
 
 Me too also prefer this way to make the code more readable ;-)
 
 It's more consistent, but not necessarily more readable -- if by
 readability we mean understanding.
 
 If the reader knows how the transports work, then the reader would
 be confused by the addition of a check that is always true. For the
 reader that doesn't know, the addition of the check implies that the
 support is optional, which it is not.

No, it says this code is concerned with the unique parts of iWarp
related to CM, not the other unique parts of iWarp. The check isn't
aways true, it is just always true on iWarp devices.

That became the problem with the old way of just saying 'is iWarp'
(and others). There are too many differences, the why became lost in
many places.

There are now too many standards, and several do not have public docs,
to keep relying on a mess of 'is standard' tests.

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


Re: [PATCH v5 19/27] IB/Verbs: Use management helper cap_iw_cm()

2015-04-20 Thread Tom Tucker

On 4/20/15 10:16 AM, Michael Wang wrote:

On 04/20/2015 04:00 PM, Steve Wise wrote:

On 4/20/2015 3:40 AM, Michael Wang wrote:

[snip]

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 6805e3e..e4999f6 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1818,6 +1818,21 @@ static inline int cap_ib_cm(struct ib_device *device, u8 
port_num)
   return rdma_ib_or_iboe(device, port_num);
   }
   +/**
+ * cap_iw_cm - Check if the port of device has the capability IWARP
+ * Communication Manager.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device don't support IWARP
+ * Communication Manager.
+ */
+static inline int cap_iw_cm(struct ib_device *device, u8 port_num)
+{
+return rdma_tech_iwarp(device, port_num);
+}
+
   int ib_query_gid(struct ib_device *device,
u8 port_num, int index, union ib_gid *gid);
   

iWARP devices _must_ support the IWCM so cap_iw_cm() is not really useful.

Sean suggested to add this helper paired with cap_ib_cm(), may be there are
some consideration on maintainability?

Me too also prefer this way to make the code more readable ;-)


It's more consistent, but not necessarily more readable -- if by 
readability we mean understanding.


If the reader knows how the transports work, then the reader would be 
confused by the addition of a check that is always true. For the reader 
that doesn't know, the addition of the check implies that the support is 
optional, which it is not.


Tom


Regards,
Michael Wang




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