[PATCH] ibsim/sim_cmd.c: Add ULLONG_MAX if not defined

2015-04-21 Thread Ilya Nelkenbaum
From: Ilya Nelkenbaum 

In old glibc versions (< 2.9.90) it is not defined

Signed-off-by: Ilya Nelkenbaum 
---
 ibsim/sim_cmd.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c
index 4822a0b..249228a 100644
--- a/ibsim/sim_cmd.c
+++ b/ibsim/sim_cmd.c
@@ -934,6 +934,11 @@ static int do_perf_counter_set(FILE *f, char *line)
field_trim--;
*(field_trim + 1) = 0;
 
+#ifndef ULLONG_MAX
+/* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */
+#   define ULLONG_MAX   18446744073709551615ULL
+#endif
+
errno = 0;
value = strtoull(s, &val_error, 0);
if((value == 0 || value == ULLONG_MAX) && errno != 0) {
-- 
1.8.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


Re: ioremap_uc() followed by set_memory_wc() - burrying MTRR

2015-04-21 Thread Jason Gunthorpe
On Wed, Apr 22, 2015 at 01:39:07AM +0200, Luis R. Rodriguez wrote:
> > Mike, do you think the time is right to just remove the iPath driver?
> 
> With PAT now being default the driver effectively won't work
> with write-combining on modern kernels. Even if systems are old
> they likely had PAT support, when upgrading kernels PAT will work
> but write-combing won't on ipath.

Sorry, do you mean the driver already doesn't get WC? Or do you mean
after some more pending patches are applied?

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 22/27] IB/Verbs: Use management helper cap_ipoib()

2015-04-21 Thread Jason Gunthorpe
On Mon, Apr 20, 2015 at 10:41:38AM +0200, Michael Wang wrote:
 
> Introduce helper cap_ipoib() to help us check if the port of an
> IB device support IP over Infiniband.

I thought we were dropping this in favor of listing the actual
features the ULP required unconditionally? One of my messages had the
start of a list..

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 00/27] IB/Verbs: IB Management Helpers

2015-04-21 Thread ira.weiny
On Tue, Apr 21, 2015 at 11:36:40PM +, Liran Liss wrote:
> Hi Michael,
> 
> The spirit of this patch-set is great, but I think that we need to clarify 
> some concepts.
> Since this will affect the whole patch-set, I am laying out my concerns here 
> instead.
> 
> A suggestion for the resulting management helpers is given below.
> I believe the result would be much more coherent.
> --Liran
> 
> In general
> 
> 
> An ib_dev (or a port of) should be distinguished by 3 qualifiers:
> - The link layer:
> -- Ethernet (shared by iWARP, USNIC, and ROCE)
> -- Infiniband
> 
> - The transport (*)
> -- IBTA transport (shared by IB and ROCE)
> -- iWARP transport
> -- USNIC transport
> 
> (*) Transport means both:
> - The L4 wire protocols (e.g., BTH+ headers of IBTA, optionally encapsulated 
> by UDP in ROCEv2, or the iWARP stack)
> - The transport semantics (for example, there are slight semantic differences 
> between IBTA and iWARP)
> 
> - The node type (**)
> -- CA
> -- Switch
> -- Router
> 
> (**) This has been extended to also encode the transport in the current code.
> At least for user-space visible APIs, we might chose to leave this for 
> backward compatibility, but we can consider cleaning up the kernel code.
> 
> So, I think that our "old-transport" below is just fine.
> No need to change it (and you aren't, since it is currently implemented as a 
> function).

I think there is a need to change this.  Encoding the transport into the node
type is not a good idea.  Having different "transport semantics" while still
returning the same transport for the port is confusing.

The only thing which is clear currently is Link Layer.

But the use of "Link Layer" in the code is so convoluted that it is very
confusing.

> 
> The "new-transport" does not really exist, but is broken into several 
> capability checks of the L4 transport, optionally with conditions on the link 
> type.
> I would remove the table below and tell what we really want to achieve:
> ==> move technology-specific feature-check logic out of the (multiple!) IB 
> code components and various ULPs into per-feature helpers.
> 
> 
> Detailed remarks
> ==
> 
> 1) The introduction of cap_*_*() stuff should have been introduced directly 
> in patch 02/27.
> This back-and-forth between rdma_ib_or_iboe() and cap_* is confusing and 
> increases the number of patches in the patch-set.
> Do this and remove patches 16-24.

I think this is a result of the back and forth which has gone on.  Some
squashing could be done but the current series is pretty straight forward when
you look at the patches.  Most are less than a page long at this point.

> 
> 2)The name rdma_tech_* is lame.
> rdma_transport_*(), adhering to the above (*) remark, is much better.
> For example, both IB and ROCE *do* use the same transport. 

Define Transport?  There has been a lot of discussion over what a transport is
in Verbs.

> 
> 3) The name cap_* as it is used above is not accurate.
> You use it to describe technology characteristics rather than extendable 
> capabilities.
> I would suggest having a single convention for all helpers, such as 
> rdma_has_*() and rdma_is_*().
> For example: cap_ib_smi() ==> rdma_has_smi().

rdma_has_smi is not sufficient for the new OPA technology.  We discussed many
different names and cap_* was settled on.  The use of cap_ib_* was for things
which are specific to IB Ports.

Frankly when RoCE was added functions like this this should have been added for
clarity into the CM and multicast code.  But at the time a simple "is link layer
check" was sufficient.  Now we have so many different devices and layers that
this clean up is needed to support the future.

> 
> 4) Remove all capabilities that do not introduce any distinction in the 
> current code.
> We can add them as needed later.
> This means remove patches:
> - [PATCH v5 22/27] IB/Verbs: Use management helper cap_ipoib() – all IB 
> devices support ipoib

Ah?  What is the point of supporting IPoIB on RoCE?  What do you mean by "IB
device"?

> - [PATCH v5 24/27] IB/Verbs: Use management helper cap_af_ib() – all IB 
> devices support AF_IB.

But not a generic RDMA device...  Which is what is being queried in the call.

> 
> On the other hand:
> - rdma_has_multicast() makes sense, since iWARP doesn’t support it.
> - cap_ib_sa() might make sense to cut code even further in the CMA, since 
> RoCE has a GSI but no SA.

As does cap_ib_mad, cap_ib_cm, etc.

> 
> 5) Do no modify phys_state_show() in [PATCH v5 09/27] IB/Verbs: Reform 
> IB-core verbs/uverbs_cmd/sysfs
> It *is* the link layer!

I agree with this.  When the Link Layer is directly being requested we should
report the link layer.  However, the internal uses of Link Layer should be
minimal if not 0.

> 
> 6) Remove cap_read_multi_sge
> It is not device/port feature, but a transport capability.
> Use rdma_is_iwarp_transport() instead, or introduce a new transport flag in 
> 'enum ib_device_cap_flags'.

This was already debated 

Re: [PATCH v5 00/27] IB/Verbs: IB Management Helpers

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:28:57AM +0200, Michael Wang wrote:
> 
> Since v4:
>   * Thanks for the comments from Hal, Sean, Tom, Or Gerlitz, Jason,
> Roland, Ira and Steve :-) Please remind me if anything missed :-P
>   * Fix logical issue inside 3#, 14#
>   * Refine 3#, 4#, 5# with label 'free'
>   * Rework 10# to stop using port 1 when port already assigned
> 
> There are plenty of lengthy code to check the transport type of IB device,
> or the link layer type of it's port, but actually we are just speculating
> whether a particular management/feature is supported by the device/port.
> 
> Thus instead of inferring, we should have our own mechanism for IB management
> capability/protocol/feature checking, several proposals below.
> 
> This patch set will reform the method of getting transport type, we will
> now using query_transport() instead of inferring from transport and link
> layer respectively, also we defined the new transport type to make the
> concept more reasonable.
> 
> Mapping List:
>   node-type   link-layer  old-transport   new-transport
> nes   RNICETH IWARP   IWARP
> amso1100  RNICETH IWARP   IWARP
> cxgb3 RNICETH IWARP   IWARP
> cxgb4 RNICETH IWARP   IWARP
> usnic USNIC_UDP   ETH USNIC_UDP   USNIC_UDP
> ocrdmaIB_CA   ETH IB  IBOE
> mlx4  IB_CA   IB/ETH  IB  IB/IBOE
> mlx5  IB_CA   IB  IB  IB
> ehca  IB_CA   IB  IB  IB
> ipath IB_CA   IB  IB  IB
> mthca IB_CA   IB  IB  IB
> qib   IB_CA   IB  IB  IB
> 
> For example:
>   if (transport == IB) && (link-layer == ETH)
> will now become:
>   if (query_transport() == IBOE)
> 
> Thus we will be able to get rid of the respective transport and link-layer
> checking, and it will help us to add new protocol/Technology (like OPA) more
> easier, also with the introduced management helpers, IB management logical
> will be more clear and easier for extending.
> 
> Highlights:
> The patch set covered a wide range of IB stuff, thus for those who are
> familiar with the particular part, your suggestion would be invaluable ;-)
> 
> Patch 1#~15# included all the logical reform, 16#~25# introduced the
> management helpers, 26#~27# do clean up.
> 
> Patches haven't been tested yet, we appreciate if any one who have these
> HW willing to provide his Tested-by :-)
> 
> Doug suggested the bitmask mechanism:
>   https://www.mail-archive.com/linux-rdma@vger.kernel.org/msg23765.html
> which could be the plan for future reforming, we prefer that to be another
> series which focus on semantic and performance.
> 
> This patch-set is somewhat 'bloated' now and it may be a good timing for
> staging, I'd like to suggest we focus on improving existed helpers and 
> push
> all the further reforms into next series ;-)
>

Series tested for IPoIB and MAD functionality on qib and mlx4 hardware.

Tested-by: Ira Weiny 

> 
> Proposals:
> Sean:
>   https://www.mail-archive.com/linux-rdma@vger.kernel.org/msg23339.html
> Doug:
>   https://www.mail-archive.com/linux-rdma@vger.kernel.org/msg23418.html
>   https://www.mail-archive.com/linux-rdma@vger.kernel.org/msg23765.html
> Jason:
>   https://www.mail-archive.com/linux-rdma@vger.kernel.org/msg23425.html
> 
> Michael Wang (27):
> IB/Verbs: Implement new callback query_transport()
> IB/Verbs: Implement raw management helpers
> IB/Verbs: Reform IB-core mad/agent/user_mad
> IB/Verbs: Reform IB-core cm
> IB/Verbs: Reform IB-core sa_query
> IB/Verbs: Reform IB-core multicast
> IB/Verbs: Reform IB-ulp ipoib
> IB/Verbs: Reform IB-ulp xprtrdma
> IB/Verbs: Reform IB-core verbs/uverbs_cmd/sysfs
> IB/Verbs: Reform cm related part in IB-core cma/ucm
> IB/Verbs: Reform route related part in IB-core cma
> IB/Verbs: Reform mcast related part in IB-core cma
> IB/Verbs: Reserve legacy transport type in 'dev_addr'
> IB/Verbs: Reform cma_acquire_dev()
> IB/Verbs: Reform rest part in IB-core cma
> IB/Verbs: Use management helper cap_ib_mad()
> IB/Verbs: Use management helper cap_ib_smi()
> IB/Verbs: Use management helper cap_ib_cm()
> IB/Verbs: Use management helper cap_iw_cm()
> IB/Verbs: Use management helper cap_ib_sa()
> IB/Verbs: Use management helper cap_ib_mcast()
> IB/Verbs: Use management helper cap_ipoib()
> IB/Verbs: Use management helper cap_read_multi_sge()
> IB/Verbs: Use management helper cap_af_ib()
> IB/Verbs: Use management helper cap_eth_ah()
> IB/Verbs: Clean up rdma_ib_o

Re: [PATCH v5 27/27] IB/Verbs: Cleanup rdma_node_get_transport()

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:43:51AM +0200, Michael Wang wrote:
> 
> We have get rid of all the scene using legacy rdma_node_get_transport(),
> now clean it up.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/core/verbs.c | 21 -
>  include/rdma/ib_verbs.h |  3 ---
>  2 files changed, 24 deletions(-)
> 
> diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
> index ee4b5cb..bbea0c0 100644
> --- a/drivers/infiniband/core/verbs.c
> +++ b/drivers/infiniband/core/verbs.c
> @@ -107,27 +107,6 @@ __attribute_const__ int ib_rate_to_mbps(enum ib_rate 
> rate)
>  }
>  EXPORT_SYMBOL(ib_rate_to_mbps);
>  
> -__attribute_const__ enum rdma_transport_type
> -rdma_node_get_transport(enum rdma_node_type node_type)
> -{
> - switch (node_type) {
> - case RDMA_NODE_IB_CA:
> - case RDMA_NODE_IB_SWITCH:
> - case RDMA_NODE_IB_ROUTER:
> - return RDMA_TRANSPORT_IB;
> - case RDMA_NODE_RNIC:
> - return RDMA_TRANSPORT_IWARP;
> - case RDMA_NODE_USNIC:
> - return RDMA_TRANSPORT_USNIC;
> - case RDMA_NODE_USNIC_UDP:
> - return RDMA_TRANSPORT_USNIC_UDP;
> - default:
> - BUG();
> - return 0;
> - }
> -}
> -EXPORT_SYMBOL(rdma_node_get_transport);
> -
>  enum rdma_link_layer rdma_port_get_link_layer(struct ib_device *device, u8 
> port_num)
>  {
>   if (device->get_link_layer)
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index 0c0a4f0..f2ea6e7 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -84,9 +84,6 @@ enum rdma_transport_type {
>   RDMA_TRANSPORT_IBOE,
>  };
>  
> -__attribute_const__ enum rdma_transport_type
> -rdma_node_get_transport(enum rdma_node_type node_type);
> -
>  enum rdma_link_layer {
>   IB_LINK_LAYER_UNSPECIFIED,
>   IB_LINK_LAYER_INFINIBAND,
> -- 
> 2.1.0
--
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 26/27] IB/Verbs: Clean up rdma_ib_or_iboe()

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:43:26AM +0200, Michael Wang wrote:
> 
> We have finished introducing the cap_XX(), and raw helper rdma_ib_or_iboe()
> is no longer necessary, thus clean it up.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

>
> ---
>  include/rdma/ib_verbs.h  | 19 +--
>  net/sunrpc/xprtrdma/svc_rdma_transport.c |  6 --
>  2 files changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index 45050cb..0c0a4f0 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1766,13 +1766,6 @@ static inline int rdma_tech_iwarp(struct ib_device 
> *device, u8 port_num)
>   == RDMA_TRANSPORT_IWARP;
>  }
>  
> -static inline int rdma_ib_or_iboe(struct ib_device *device, u8 port_num)
> -{
> - enum rdma_transport_type tp = device->query_transport(device, port_num);
> -
> - return (tp == RDMA_TRANSPORT_IB || tp == RDMA_TRANSPORT_IBOE);
> -}
> -
>  /**
>   * cap_ib_mad - Check if the port of device has the capability Infiniband
>   * Management Datagrams.
> @@ -1785,7 +1778,9 @@ static inline int rdma_ib_or_iboe(struct ib_device 
> *device, u8 port_num)
>   */
>  static inline int cap_ib_mad(struct ib_device *device, u8 port_num)
>  {
> - return rdma_ib_or_iboe(device, port_num);
> + enum rdma_transport_type tp = device->query_transport(device, port_num);
> +
> + return (tp == RDMA_TRANSPORT_IB || tp == RDMA_TRANSPORT_IBOE);
>  }
>  
>  /**
> @@ -1815,7 +1810,9 @@ static inline int cap_ib_smi(struct ib_device *device, 
> u8 port_num)
>   */
>  static inline int cap_ib_cm(struct ib_device *device, u8 port_num)
>  {
> - return rdma_ib_or_iboe(device, port_num);
> + enum rdma_transport_type tp = device->query_transport(device, port_num);
> +
> + return (tp == RDMA_TRANSPORT_IB || tp == RDMA_TRANSPORT_IBOE);
>  }
>  
>  /**
> @@ -1890,7 +1887,9 @@ static inline int cap_ipoib(struct ib_device *device, 
> u8 port_num)
>   */
>  static inline int cap_af_ib(struct ib_device *device, u8 port_num)
>  {
> - return rdma_ib_or_iboe(device, port_num);
> + enum rdma_transport_type tp = device->query_transport(device, port_num);
> +
> + return (tp == RDMA_TRANSPORT_IB || tp == RDMA_TRANSPORT_IBOE);
>  }
>  
>  /**
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c 
> b/net/sunrpc/xprtrdma/svc_rdma_transport.c
> index a09b7a1..8af6f92 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
> @@ -987,8 +987,10 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt 
> *xprt)
>*/
>   if (!rdma_tech_iwarp(newxprt->sc_cm_id->device,
>newxprt->sc_cm_id->port_num) &&
> - !rdma_ib_or_iboe(newxprt->sc_cm_id->device,
> -  newxprt->sc_cm_id->port_num))
> + !rdma_tech_ib(newxprt->sc_cm_id->device,
> +   newxprt->sc_cm_id->port_num) &&
> + !rdma_tech_iboe(newxprt->sc_cm_id->device,
> + newxprt->sc_cm_id->port_num))
>   goto errout;
>  
>   if (!(newxprt->sc_dev_caps & SVCRDMA_DEVCAP_FAST_REG) ||
> -- 
> 2.1.0
--
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 25/27] IB/Verbs: Use management helper cap_eth_ah()

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:43:03AM +0200, Michael Wang wrote:
> 
> Introduce helper cap_eth_ah() to help us check if the port of an
> IB device support Ethernet Address Handler.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/core/cma.c  |  2 +-
>  drivers/infiniband/core/sa_query.c |  2 +-
>  drivers/infiniband/core/verbs.c|  2 +-
>  include/rdma/ib_verbs.h| 15 +++
>  4 files changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 9c1f5b72..b9f7ccc 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -732,7 +732,7 @@ static int cma_ib_init_qp_attr(struct rdma_id_private 
> *id_priv,
>   int ret;
>   u16 pkey;
>  
> - if (rdma_tech_iboe(id_priv->id.device, id_priv->id.port_num))
> + if (cap_eth_ah(id_priv->id.device, id_priv->id.port_num))
>   pkey = 0x;
>   else
>   pkey = ib_addr_get_pkey(dev_addr);
> diff --git a/drivers/infiniband/core/sa_query.c 
> b/drivers/infiniband/core/sa_query.c
> index f14a66f..063c17c 100644
> --- a/drivers/infiniband/core/sa_query.c
> +++ b/drivers/infiniband/core/sa_query.c
> @@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 
> port_num,
>   ah_attr->port_num = port_num;
>   ah_attr->static_rate = rec->rate;
>  
> - force_grh = rdma_tech_iboe(device, port_num);
> + force_grh = cap_eth_ah(device, port_num);
>  
>   if (rec->hop_limit > 1 || force_grh) {
>   ah_attr->ah_flags = IB_AH_GRH;
> diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
> index 7264860..ee4b5cb 100644
> --- a/drivers/infiniband/core/verbs.c
> +++ b/drivers/infiniband/core/verbs.c
> @@ -202,7 +202,7 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 
> port_num, struct ib_wc *wc,
>   int ret;
>  
>   memset(ah_attr, 0, sizeof *ah_attr);
> - if (rdma_tech_iboe(device, port_num)) {
> + if (cap_eth_ah(device, port_num)) {
>   if (!(wc->wc_flags & IB_WC_GRH))
>   return -EPROTOTYPE;
>  
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index 9cfab09..45050cb 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1894,6 +1894,21 @@ static inline int cap_af_ib(struct ib_device *device, 
> u8 port_num)
>  }
>  
>  /**
> + * cap_eth_ah - Check if the port of device has the capability
> + * Ethernet Address Handler.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device don't support
> + * Ethernet Address Handler.
> + */
> +static inline int cap_eth_ah(struct ib_device *device, u8 port_num)
> +{
> + return rdma_tech_iboe(device, port_num);
> +}
> +
> +/**
>   * cap_read_multi_sge - Check if the port of device has the capability
>   * RDMA Read Multiple Scatter-Gather Entries.
>   *
> -- 
> 2.1.0
--
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 24/27] IB/Verbs: Use management helper cap_af_ib()

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:42:33AM +0200, Michael Wang wrote:
> 
> Introduce helper cap_af_ib() to help us check if the port of an
> IB device support Native Infiniband Address.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/core/cma.c |  2 +-
>  include/rdma/ib_verbs.h   | 15 +++
>  2 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 05d148e..9c1f5b72 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -469,7 +469,7 @@ static int cma_resolve_ib_dev(struct rdma_id_private 
> *id_priv)
>  
>   list_for_each_entry(cur_dev, &dev_list, list) {
>   for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) {
> - if (!rdma_ib_or_iboe(cur_dev->device, p))
> + if (!cap_af_ib(cur_dev->device, p))
>   continue;
>  
>   if (ib_find_cached_pkey(cur_dev->device, p, pkey, 
> &index))
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index 074f66d..9cfab09 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1879,6 +1879,21 @@ static inline int cap_ipoib(struct ib_device *device, 
> u8 port_num)
>  }
>  
>  /**
> + * cap_af_ib - Check if the port of device has the capability
> + * Native Infiniband Address.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device don't support
> + * Native Infiniband Address.
> + */
> +static inline int cap_af_ib(struct ib_device *device, u8 port_num)
> +{
> + return rdma_ib_or_iboe(device, port_num);
> +}
> +
> +/**
>   * cap_read_multi_sge - Check if the port of device has the capability
>   * RDMA Read Multiple Scatter-Gather Entries.
>   *
> -- 
> 2.1.0
--
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 22/27] IB/Verbs: Use management helper cap_ipoib()

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:41:38AM +0200, Michael Wang wrote:
> 
> Introduce helper cap_ipoib() to help us check if the port of an
> IB device support IP over Infiniband.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/ulp/ipoib/ipoib_main.c |  2 +-
>  include/rdma/ib_verbs.h   | 15 +++
>  2 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c 
> b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> index 60b379d..a9812df 100644
> --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
> +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> @@ -1671,7 +1671,7 @@ static void ipoib_add_one(struct ib_device *device)
>   }
>  
>   for (p = s; p <= e; ++p) {
> - if (!rdma_tech_ib(device, p))
> + if (!cap_ipoib(device, p))
>   continue;
>   dev = ipoib_add_port("ib%d", device, p);
>   if (!IS_ERR(dev)) {
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index 6e354df..d0ae08e 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1863,6 +1863,21 @@ static inline int cap_ib_mcast(struct ib_device 
> *device, u8 port_num)
>   return cap_ib_sa(device, port_num);
>  }
>  
> +/**
> + * cap_ipoib - Check if the port of device has the capability
> + * IP over Infiniband.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device don't support
> + * IP over Infiniband.
> + */
> +static inline int cap_ipoib(struct ib_device *device, u8 port_num)
> +{
> + return rdma_tech_ib(device, port_num);
> +}
> +
>  int ib_query_gid(struct ib_device *device,
>u8 port_num, int index, union ib_gid *gid);
>  
> -- 
> 2.1.0
--
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 21/27] IB/Verbs: Use management helper cap_ib_mcast()

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:41:14AM +0200, Michael Wang wrote:
> 
> Introduce helper cap_ib_mcast() to help us check if the port of an
> IB device support Infiniband Multicast.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/core/cma.c   |  6 +++---
>  drivers/infiniband/core/multicast.c |  6 +++---
>  include/rdma/ib_verbs.h | 15 +++
>  3 files changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 8484ae3..58ec946 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -1028,7 +1028,7 @@ static void cma_leave_mc_groups(struct rdma_id_private 
> *id_priv)
>   mc = container_of(id_priv->mc_list.next,
> struct cma_multicast, list);
>   list_del(&mc->list);
> - if (rdma_tech_ib(id_priv->cma_dev->device,
> + if (cap_ib_mcast(id_priv->cma_dev->device,
> id_priv->id.port_num)) {
>   ib_sa_free_multicast(mc->multicast.ib);
>   kfree(mc);
> @@ -3342,7 +3342,7 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct 
> sockaddr *addr,
>   if (rdma_tech_iboe(id->device, id->port_num)) {
>   kref_init(&mc->mcref);
>   ret = cma_iboe_join_multicast(id_priv, mc);
> - } else if (rdma_tech_ib(id->device, id->port_num))
> + } else if (cap_ib_mcast(id->device, id->port_num))
>   ret = cma_join_ib_multicast(id_priv, mc);
>   else
>   ret = -ENOSYS;
> @@ -3376,7 +3376,7 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct 
> sockaddr *addr)
>  
>   BUG_ON(id_priv->cma_dev->device != id->device);
>  
> - if (rdma_tech_ib(id->device, id->port_num)) {
> + if (cap_ib_mcast(id->device, id->port_num)) {
>   ib_sa_free_multicast(mc->multicast.ib);
>   kfree(mc);
>   } else if (rdma_tech_iboe(id->device, id->port_num))
> diff --git a/drivers/infiniband/core/multicast.c 
> b/drivers/infiniband/core/multicast.c
> index 24d93f5..bdc1880 100644
> --- a/drivers/infiniband/core/multicast.c
> +++ b/drivers/infiniband/core/multicast.c
> @@ -780,7 +780,7 @@ static void mcast_event_handler(struct ib_event_handler 
> *handler,
>   int index;
>  
>   dev = container_of(handler, struct mcast_device, event_handler);
> - if (WARN_ON(!rdma_tech_ib(dev->device, event->element.port_num)))
> + if (WARN_ON(!cap_ib_mcast(dev->device, event->element.port_num)))
>   return;
>  
>   index = event->element.port_num - dev->start_port;
> @@ -820,7 +820,7 @@ static void mcast_add_one(struct ib_device *device)
>   }
>  
>   for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> - if (!rdma_tech_ib(device, dev->start_port + i))
> + if (!cap_ib_mcast(device, dev->start_port + i))
>   continue;
>   port = &dev->port[i];
>   port->dev = dev;
> @@ -858,7 +858,7 @@ static void mcast_remove_one(struct ib_device *device)
>   flush_workqueue(mcast_wq);
>  
>   for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> - if (rdma_tech_ib(device, dev->start_port + i)) {
> + if (cap_ib_mcast(device, dev->start_port + i)) {
>   port = &dev->port[i];
>   deref_port(port);
>   wait_for_completion(&port->comp);
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index de3a168..6e354df 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1848,6 +1848,21 @@ static inline int cap_ib_sa(struct ib_device *device, 
> u8 port_num)
>   return rdma_tech_ib(device, port_num);
>  }
>  
> +/**
> + * cap_ib_mcast - Check if the port of device has the capability Infiniband
> + * Multicast.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device don't support Infiniband
> + * Multicast.
> + */
> +static inline int cap_ib_mcast(struct ib_device *device, u8 port_num)
> +{
> + return cap_ib_sa(device, port_num);
> +}
> +
>  int ib_query_gid(struct ib_device *device,
>u8 port_num, int index, union ib_gid *gid);
>  
> -- 
> 2.1.0
--
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 20/27] IB/Verbs: Use management helper cap_ib_sa()

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:40:50AM +0200, Michael Wang wrote:
> 
> Introduce helper cap_ib_sa() to help us check if the port of an
> IB device support Infiniband Subnet Administration.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/core/cma.c  |  4 ++--
>  drivers/infiniband/core/sa_query.c | 10 +-
>  drivers/infiniband/core/ucma.c |  2 +-
>  include/rdma/ib_verbs.h| 15 +++
>  4 files changed, 23 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index dd37b4a..b92f81b 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -954,7 +954,7 @@ static inline int cma_user_data_offset(struct 
> rdma_id_private *id_priv)
>  
>  static void cma_cancel_route(struct rdma_id_private *id_priv)
>  {
> - if (rdma_tech_ib(id_priv->id.device, id_priv->id.port_num)) {
> + if (cap_ib_sa(id_priv->id.device, id_priv->id.port_num)) {
>   if (id_priv->query)
>   ib_sa_cancel_query(id_priv->query_id, id_priv->query);
>   }
> @@ -1978,7 +1978,7 @@ int rdma_resolve_route(struct rdma_cm_id *id, int 
> timeout_ms)
>   return -EINVAL;
>  
>   atomic_inc(&id_priv->refcount);
> - if (rdma_tech_ib(id->device, id->port_num))
> + if (cap_ib_sa(id->device, id->port_num))
>   ret = cma_resolve_ib_route(id_priv, timeout_ms);
>   else if (rdma_tech_iboe(id->device, id->port_num))
>   ret = cma_resolve_iboe_route(id_priv);
> diff --git a/drivers/infiniband/core/sa_query.c 
> b/drivers/infiniband/core/sa_query.c
> index 60dc7aa..f14a66f 100644
> --- a/drivers/infiniband/core/sa_query.c
> +++ b/drivers/infiniband/core/sa_query.c
> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, 
> struct ib_event *event
>   struct ib_sa_port *port =
>   &sa_dev->port[event->element.port_num - 
> sa_dev->start_port];
>  
> - if (WARN_ON(!rdma_tech_ib(handler->device, port->port_num)))
> + if (WARN_ON(!cap_ib_sa(handler->device, port->port_num)))
>   return;
>  
>   spin_lock_irqsave(&port->ah_lock, flags);
> @@ -1173,7 +1173,7 @@ static void ib_sa_add_one(struct ib_device *device)
>  
>   for (i = 0; i <= e - s; ++i) {
>   spin_lock_init(&sa_dev->port[i].ah_lock);
> - if (!rdma_tech_ib(device, i + 1))
> + if (!cap_ib_sa(device, i + 1))
>   continue;
>  
>   sa_dev->port[i].sm_ah= NULL;
> @@ -1208,7 +1208,7 @@ static void ib_sa_add_one(struct ib_device *device)
>   goto err;
>  
>   for (i = 0; i <= e - s; ++i) {
> - if (rdma_tech_ib(device, i + 1))
> + if (cap_ib_sa(device, i + 1))
>   update_sm_ah(&sa_dev->port[i].update_task);
>   }
>  
> @@ -1216,7 +1216,7 @@ static void ib_sa_add_one(struct ib_device *device)
>  
>  err:
>   while (--i >= 0) {
> - if (rdma_tech_ib(device, i + 1))
> + if (cap_ib_sa(device, i + 1))
>   ib_unregister_mad_agent(sa_dev->port[i].agent);
>   }
>  
> @@ -1238,7 +1238,7 @@ static void ib_sa_remove_one(struct ib_device *device)
>   flush_workqueue(ib_wq);
>  
>   for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
> - if (rdma_tech_ib(device, i + 1)) {
> + if (cap_ib_sa(device, i + 1)) {
>   ib_unregister_mad_agent(sa_dev->port[i].agent);
>   if (sa_dev->port[i].sm_ah)
>   kref_put(&sa_dev->port[i].sm_ah->ref, 
> free_sm_ah);
> diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
> index 7331c6c..bed7957 100644
> --- a/drivers/infiniband/core/ucma.c
> +++ b/drivers/infiniband/core/ucma.c
> @@ -723,7 +723,7 @@ static ssize_t ucma_query_route(struct ucma_file *file,
>   resp.node_guid = (__force __u64) ctx->cm_id->device->node_guid;
>   resp.port_num = ctx->cm_id->port_num;
>  
> - if (rdma_tech_ib(ctx->cm_id->device, ctx->cm_id->port_num))
> + if (cap_ib_sa(ctx->cm_id->device, ctx->cm_id->port_num))
>   ucma_copy_ib_route(&resp, &ctx->cm_id->route);
>   else if (rdma_tech_iboe(ctx->cm_id->device, ctx->cm_id->port_num))
>   ucma_copy_iboe_route(&resp, &ctx->cm_id->route);
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index e4999f6..de3a168 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1833,6 +1833,21 @@ static inline int cap_iw_cm(struct ib_device *device, 
> u8 port_num)
>   return rdma_tech_iwarp(device, port_num);
>  }
>  
> +/**
> + * cap_ib_sa - Check if the port of device has the capability Infiniba

Re: [PATCH v5 23/27] IB/Verbs: Use management helper cap_read_multi_sge()

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:42:07AM +0200, Michael Wang wrote:
> 
> Introduce helper cap_read_multi_sge() to help us check if the port of an
> IB device support RDMA Read Multiple Scatter-Gather Entries.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  include/rdma/ib_verbs.h | 15 +++
>  net/sunrpc/xprtrdma/svc_rdma_recvfrom.c |  3 ++-
>  2 files changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index d0ae08e..074f66d 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1878,6 +1878,21 @@ static inline int cap_ipoib(struct ib_device *device, 
> u8 port_num)
>   return rdma_tech_ib(device, port_num);
>  }
>  
> +/**
> + * cap_read_multi_sge - Check if the port of device has the capability
> + * RDMA Read Multiple Scatter-Gather Entries.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device don't support
> + * RDMA Read Multiple Scatter-Gather Entries.
> + */
> +static inline int cap_read_multi_sge(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);
>  
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c 
> b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> index a5bed5b..7711b7a 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> @@ -117,7 +117,8 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
>  
>  static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
>  {
> - if (rdma_tech_iwarp(xprt->sc_cm_id->device, xprt->sc_cm_id->port_num))
> + if (!cap_read_multi_sge(xprt->sc_cm_id->device,
> + xprt->sc_cm_id->port_num))
>   return 1;
>   else
>   return min_t(int, sge_count, xprt->sc_max_sge);
> -- 
> 2.1.0
--
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 16/27] IB/Verbs: Use management helper cap_ib_mad()

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:39:12AM +0200, Michael Wang wrote:
> 
> Introduce helper cap_ib_mad() to help us check if the port of an
> IB device support Infiniband Management Datagrams.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/core/mad.c  |  6 +++---
>  drivers/infiniband/core/user_mad.c |  6 +++---
>  include/rdma/ib_verbs.h| 15 +++
>  3 files changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
> index 1822932..4315aeb 100644
> --- a/drivers/infiniband/core/mad.c
> +++ b/drivers/infiniband/core/mad.c
> @@ -3066,7 +3066,7 @@ static void ib_mad_init_device(struct ib_device *device)
>   }
>  
>   for (i = start; i <= end; i++) {
> - if (!rdma_ib_or_iboe(device, i))
> + if (!cap_ib_mad(device, i))
>   continue;
>  
>   if (ib_mad_port_open(device, i)) {
> @@ -3087,7 +3087,7 @@ error_agent:
>  
>  error:
>   while (--i >= start) {
> - if (!rdma_ib_or_iboe(device, i))
> + if (!cap_ib_mad(device, i))
>   continue;
>  
>   if (ib_agent_port_close(device, i))
> @@ -3111,7 +3111,7 @@ static void ib_mad_remove_device(struct ib_device 
> *device)
>   }
>  
>   for (i = start; i <= end; i++) {
> - if (!rdma_ib_or_iboe(device, i))
> + if (!cap_ib_mad(device, i))
>   continue;
>  
>   if (ib_agent_port_close(device, i))
> diff --git a/drivers/infiniband/core/user_mad.c 
> b/drivers/infiniband/core/user_mad.c
> index 71fc8ba..b52884b 100644
> --- a/drivers/infiniband/core/user_mad.c
> +++ b/drivers/infiniband/core/user_mad.c
> @@ -1294,7 +1294,7 @@ static void ib_umad_add_one(struct ib_device *device)
>   umad_dev->end_port   = e;
>  
>   for (i = s; i <= e; ++i) {
> - if (!rdma_ib_or_iboe(device, i))
> + if (!cap_ib_mad(device, i))
>   continue;
>  
>   umad_dev->port[i - s].umad_dev = umad_dev;
> @@ -1317,7 +1317,7 @@ static void ib_umad_add_one(struct ib_device *device)
>  
>  err:
>   while (--i >= s) {
> - if (!rdma_ib_or_iboe(device, i))
> + if (!cap_ib_mad(device, i))
>   continue;
>  
>   ib_umad_kill_port(&umad_dev->port[i - s]);
> @@ -1335,7 +1335,7 @@ static void ib_umad_remove_one(struct ib_device *device)
>   return;
>  
>   for (i = 0; i <= umad_dev->end_port - umad_dev->start_port; ++i) {
> - if (rdma_ib_or_iboe(device, i))
> + if (cap_ib_mad(device, i))
>   ib_umad_kill_port(&umad_dev->port[i]);
>   }
>  
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index a12e876..624e963 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1773,6 +1773,21 @@ static inline int rdma_ib_or_iboe(struct ib_device 
> *device, u8 port_num)
>   return (tp == RDMA_TRANSPORT_IB || tp == RDMA_TRANSPORT_IBOE);
>  }
>  
> +/**
> + * cap_ib_mad - Check if the port of device has the capability Infiniband
> + * Management Datagrams.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device don't support Infiniband
> + * Management Datagrams.
> + */
> +static inline int cap_ib_mad(struct ib_device *device, u8 port_num)
> +{
> + return rdma_ib_or_iboe(device, port_num);
> +}
> +
>  int ib_query_gid(struct ib_device *device,
>u8 port_num, int index, union ib_gid *gid);
>  
> -- 
> 2.1.0
--
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 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

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

Re: [PATCH v5 17/27] IB/Verbs: Use management helper cap_ib_smi()

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:39:37AM +0200, Michael Wang wrote:
> 
> Introduce helper cap_ib_smi() to help us check if the port of an
> IB device support Infiniband Subnet Management Interface.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/core/agent.c |  2 +-
>  drivers/infiniband/core/mad.c   |  2 +-
>  include/rdma/ib_verbs.h | 15 +++
>  3 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
> index ffdef4d..61471ee 100644
> --- a/drivers/infiniband/core/agent.c
> +++ b/drivers/infiniband/core/agent.c
> @@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int 
> port_num)
>   goto error1;
>   }
>  
> - if (rdma_tech_ib(device, port_num)) {
> + if (cap_ib_smi(device, port_num)) {
>   /* Obtain send only MAD agent for SMI QP */
>   port_priv->agent[0] = ib_register_mad_agent(device, port_num,
>   IB_QPT_SMI, NULL, 0,
> diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
> index 4315aeb..ee3a05e 100644
> --- a/drivers/infiniband/core/mad.c
> +++ b/drivers/infiniband/core/mad.c
> @@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
>   init_mad_qp(port_priv, &port_priv->qp_info[1]);
>  
>   cq_size = mad_sendq_size + mad_recvq_size;
> - has_smi = rdma_tech_ib(device, port_num);
> + has_smi = cap_ib_smi(device, port_num);
>   if (has_smi)
>   cq_size *= 2;
>  
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index 624e963..873b9a6 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1788,6 +1788,21 @@ static inline int cap_ib_mad(struct ib_device *device, 
> u8 port_num)
>   return rdma_ib_or_iboe(device, port_num);
>  }
>  
> +/**
> + * cap_ib_smi - Check if the port of device has the capability Infiniband
> + * Subnet Management Interface.
> + *
> + * @device: Device to be checked
> + * @port_num: Port number of the device
> + *
> + * Return 0 when port of the device don't support Infiniband
> + * Subnet Management Interface.
> + */
> +static inline int cap_ib_smi(struct ib_device *device, u8 port_num)
> +{
> + return rdma_tech_ib(device, port_num);
> +}
> +
>  int ib_query_gid(struct ib_device *device,
>u8 port_num, int index, union ib_gid *gid);
>  
> -- 
> 2.1.0
--
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 15/27] IB/Verbs: Reform rest part in IB-core cma

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:38:49AM +0200, Michael Wang wrote:
> 
> Use raw management helpers to reform rest part in IB-core cma.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/core/cma.c | 20 +---
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 44e7bb9..ec64b97 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -468,10 +468,10 @@ static int cma_resolve_ib_dev(struct rdma_id_private 
> *id_priv)
>   pkey = ntohs(addr->sib_pkey);
>  
>   list_for_each_entry(cur_dev, &dev_list, list) {
> - if (rdma_node_get_transport(cur_dev->device->node_type) != 
> RDMA_TRANSPORT_IB)
> - continue;
> -
>   for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) {
> + if (!rdma_ib_or_iboe(cur_dev->device, p))
> + continue;
> +
>   if (ib_find_cached_pkey(cur_dev->device, p, pkey, 
> &index))
>   continue;
>  
> @@ -666,10 +666,9 @@ static int cma_modify_qp_rtr(struct rdma_id_private 
> *id_priv,
>   if (ret)
>   goto out;
>  
> - if (rdma_node_get_transport(id_priv->cma_dev->device->node_type)
> - == RDMA_TRANSPORT_IB &&
> - rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)
> - == IB_LINK_LAYER_ETHERNET) {
> + BUG_ON(id_priv->cma_dev->device != id_priv->id.device);
> +
> + if (rdma_tech_iboe(id_priv->id.device, id_priv->id.port_num)) {
>   ret = rdma_addr_find_smac_by_sgid(&sgid, qp_attr.smac, NULL);
>  
>   if (ret)
> @@ -733,11 +732,10 @@ static int cma_ib_init_qp_attr(struct rdma_id_private 
> *id_priv,
>   int ret;
>   u16 pkey;
>  
> - if (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num) 
> ==
> - IB_LINK_LAYER_INFINIBAND)
> - pkey = ib_addr_get_pkey(dev_addr);
> - else
> + if (rdma_tech_iboe(id_priv->id.device, id_priv->id.port_num))
>   pkey = 0x;
> + else
> + pkey = ib_addr_get_pkey(dev_addr);
>  
>   ret = ib_find_cached_pkey(id_priv->id.device, id_priv->id.port_num,
> pkey, &qp_attr->pkey_index);
> -- 
> 2.1.0
--
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 18/27] IB/Verbs: Use management helper cap_ib_cm()

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:40:04AM +0200, Michael Wang wrote:
> 
> Introduce helper cap_ib_cm() to help us check if the port of an
> IB device support Infiniband Communication Manager.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/core/cm.c  |  6 +++---
>  drivers/infiniband/core/cma.c | 19 +--
>  drivers/infiniband/core/ucm.c |  2 +-
>  include/rdma/ib_verbs.h   | 15 +++
>  4 files changed, 28 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
> index 3c10b75..eae4c9f 100644
> --- a/drivers/infiniband/core/cm.c
> +++ b/drivers/infiniband/core/cm.c
> @@ -3781,7 +3781,7 @@ static void cm_add_one(struct ib_device *ib_device)
>  
>   set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask);
>   for (i = 1; i <= ib_device->phys_port_cnt; i++) {
> - if (!rdma_ib_or_iboe(ib_device, i))
> + if (!cap_ib_cm(ib_device, i))
>   continue;
>  
>   port = kzalloc(sizeof *port, GFP_KERNEL);
> @@ -3832,7 +3832,7 @@ error1:
>   port_modify.set_port_cap_mask = 0;
>   port_modify.clr_port_cap_mask = IB_PORT_CM_SUP;
>   while (--i) {
> - if (!rdma_ib_or_iboe(ib_device, i))
> + if (!cap_ib_cm(ib_device, i))
>   continue;
>  
>   port = cm_dev->port[i-1];
> @@ -3864,7 +3864,7 @@ static void cm_remove_one(struct ib_device *ib_device)
>   write_unlock_irqrestore(&cm.device_lock, flags);
>  
>   for (i = 1; i <= ib_device->phys_port_cnt; i++) {
> - if (!rdma_ib_or_iboe(ib_device, i))
> + if (!cap_ib_cm(ib_device, i))
>   continue;
>  
>   port = cm_dev->port[i-1];
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index ec64b97..ff59dbc 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -766,7 +766,7 @@ int rdma_init_qp_attr(struct rdma_cm_id *id, struct 
> ib_qp_attr *qp_attr,
>   int ret = 0;
>  
>   id_priv = container_of(id, struct rdma_id_private, id);
> - if (rdma_ib_or_iboe(id->device, id->port_num)) {
> + if (cap_ib_cm(id->device, id->port_num)) {
>   if (!id_priv->cm_id.ib || (id_priv->id.qp_type == IB_QPT_UD))
>   ret = cma_ib_init_qp_attr(id_priv, qp_attr, 
> qp_attr_mask);
>   else
> @@ -1054,7 +1054,7 @@ void rdma_destroy_id(struct rdma_cm_id *id)
>   mutex_unlock(&id_priv->handler_mutex);
>  
>   if (id_priv->cma_dev) {
> - if (rdma_ib_or_iboe(id_priv->id.device, 1)) {
> + 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)) {
> @@ -1637,8 +1637,7 @@ static void cma_listen_on_dev(struct rdma_id_private 
> *id_priv,
>   struct rdma_cm_id *id;
>   int ret;
>  
> - if (cma_family(id_priv) == AF_IB &&
> - !rdma_ib_or_iboe(cma_dev->device, 1))
> + if (cma_family(id_priv) == AF_IB && !cap_ib_cm(cma_dev->device, 1))
>   return;
>  
>   id = rdma_create_id(cma_listen_handler, id_priv, id_priv->id.ps,
> @@ -2029,7 +2028,7 @@ static int cma_bind_loopback(struct rdma_id_private 
> *id_priv)
>   mutex_lock(&lock);
>   list_for_each_entry(cur_dev, &dev_list, list) {
>   if (cma_family(id_priv) == AF_IB &&
> - !rdma_ib_or_iboe(cur_dev->device, 1))
> + !cap_ib_cm(cur_dev->device, 1))
>   continue;
>  
>   if (!cma_dev)
> @@ -2538,7 +2537,7 @@ int rdma_listen(struct rdma_cm_id *id, int backlog)
>  
>   id_priv->backlog = backlog;
>   if (id->device) {
> - if (rdma_ib_or_iboe(id->device, 1)) {
> + if (cap_ib_cm(id->device, 1)) {
>   ret = cma_ib_listen(id_priv);
>   if (ret)
>   goto err;
> @@ -2882,7 +2881,7 @@ int rdma_connect(struct rdma_cm_id *id, struct 
> rdma_conn_param *conn_param)
>   id_priv->srq = conn_param->srq;
>   }
>  
> - if (rdma_ib_or_iboe(id->device, id->port_num)) {
> + if (cap_ib_cm(id->device, id->port_num)) {
>   if (id->qp_type == IB_QPT_UD)
>   ret = cma_resolve_ib_udp(id_priv, conn_param);
>   else
> @@ -2993,7 +2992,7 @@ int rdma_accept(struct rdma_cm_id *id, struct 
> rdma_conn_param *conn_param)
>   id_priv->srq = conn_param->srq;
>   }
>  
> - if (rdma_ib_or_iboe(id->device, id->port_num)) {
> + if (cap_ib_cm(id->device, id->port_num)) {
>   if (id->qp_type == IB_QPT_UD) {
>   if (conn_param)

Re: [PATCH v5 14/27] IB/Verbs: Reform cma_acquire_dev()

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:38:23AM +0200, Michael Wang wrote:
> 
> Reform cma_acquire_dev() with management helpers, introduce
> cma_validate_port() to make the code more clean.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/core/cma.c | 68 
> +--
>  1 file changed, 40 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 6195bf6..44e7bb9 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -370,18 +370,35 @@ static int cma_translate_addr(struct sockaddr *addr, 
> struct rdma_dev_addr *dev_a
>   return ret;
>  }
>  
> +static inline int cma_validate_port(struct ib_device *device, u8 port,
> +   union ib_gid *gid, int dev_type)
> +{
> + u8 found_port;
> + int ret = -ENODEV;
> +
> + if ((dev_type == ARPHRD_INFINIBAND) && !rdma_tech_ib(device, port))
> + return ret;
> +
> + if ((dev_type != ARPHRD_INFINIBAND) && rdma_tech_ib(device, port))
> + return ret;
> +
> + ret = ib_find_cached_gid(device, gid, &found_port, NULL);
> + if (port != found_port)
> + return -ENODEV;
> +
> + return ret;
> +}
> +
>  static int cma_acquire_dev(struct rdma_id_private *id_priv,
>  struct rdma_id_private *listen_id_priv)
>  {
>   struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
>   struct cma_device *cma_dev;
> - union ib_gid gid, iboe_gid;
> + union ib_gid gid, iboe_gid, *gidp;
>   int ret = -ENODEV;
> - u8 port, found_port;
> - enum rdma_link_layer dev_ll = dev_addr->dev_type == ARPHRD_INFINIBAND ?
> - IB_LINK_LAYER_INFINIBAND : IB_LINK_LAYER_ETHERNET;
> + u8 port;
>  
> - if (dev_ll != IB_LINK_LAYER_INFINIBAND &&
> + if (dev_addr->dev_type != ARPHRD_INFINIBAND &&
>   id_priv->id.ps == RDMA_PS_IPOIB)
>   return -EINVAL;
>  
> @@ -391,41 +408,36 @@ static int cma_acquire_dev(struct rdma_id_private 
> *id_priv,
>  
>   memcpy(&gid, dev_addr->src_dev_addr +
>  rdma_addr_gid_offset(dev_addr), sizeof gid);
> - if (listen_id_priv &&
> - rdma_port_get_link_layer(listen_id_priv->id.device,
> -  listen_id_priv->id.port_num) == dev_ll) {
> +
> + if (listen_id_priv) {
>   cma_dev = listen_id_priv->cma_dev;
>   port = listen_id_priv->id.port_num;
> - if (rdma_node_get_transport(cma_dev->device->node_type) == 
> RDMA_TRANSPORT_IB &&
> - rdma_port_get_link_layer(cma_dev->device, port) == 
> IB_LINK_LAYER_ETHERNET)
> - ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
> -  &found_port, NULL);
> - else
> - ret = ib_find_cached_gid(cma_dev->device, &gid,
> -  &found_port, NULL);
> + gidp = rdma_tech_iboe(cma_dev->device, port) ?
> +&iboe_gid : &gid;
>  
> - if (!ret && (port  == found_port)) {
> - id_priv->id.port_num = found_port;
> + ret = cma_validate_port(cma_dev->device, port, gidp,
> + dev_addr->dev_type);
> + if (!ret) {
> + id_priv->id.port_num = port;
>   goto out;
>   }
>   }
> +
>   list_for_each_entry(cma_dev, &dev_list, list) {
>   for (port = 1; port <= cma_dev->device->phys_port_cnt; ++port) {
>   if (listen_id_priv &&
>   listen_id_priv->cma_dev == cma_dev &&
>   listen_id_priv->id.port_num == port)
>   continue;
> - if (rdma_port_get_link_layer(cma_dev->device, port) == 
> dev_ll) {
> - if 
> (rdma_node_get_transport(cma_dev->device->node_type) == RDMA_TRANSPORT_IB &&
> - rdma_port_get_link_layer(cma_dev->device, 
> port) == IB_LINK_LAYER_ETHERNET)
> - ret = 
> ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
> - else
> - ret = 
> ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
> -
> - if (!ret && (port == found_port)) {
> - id_priv->id.port_num = found_port;
> - goto out;
> - }
> +
> + gidp = rdma_tech_iboe(cma_dev->device, port) ?
> +&iboe_gid : &gid;
> +
> + ret = 

Re: [PATCH v5 13/27] IB/Verbs: Reserve legacy transport type in 'dev_addr'

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:38:00AM +0200, Michael Wang wrote:
> 
> Reserve the legacy transport type for the 'transport' member
> of 'struct rdma_dev_addr' until we make sure this is no
> longer needed.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/core/cma.c | 25 +++--
>  1 file changed, 23 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index ebac646..6195bf6 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -244,14 +244,35 @@ static inline void cma_set_ip_ver(struct cma_hdr *hdr, 
> u8 ip_ver)
>   hdr->ip_version = (ip_ver << 4) | (hdr->ip_version & 0xF);
>  }
>  
> +static inline void cma_set_legacy_transport(struct rdma_cm_id *id)
> +{
> + switch (id->device->node_type) {
> + case RDMA_NODE_IB_CA:
> + case RDMA_NODE_IB_SWITCH:
> + case RDMA_NODE_IB_ROUTER:
> + id->route.addr.dev_addr.transport = RDMA_TRANSPORT_IB;
> + break;
> + case RDMA_NODE_RNIC:
> + id->route.addr.dev_addr.transport = RDMA_TRANSPORT_IWARP;
> + break;
> + case RDMA_NODE_USNIC:
> + id->route.addr.dev_addr.transport = RDMA_TRANSPORT_USNIC;
> + break;
> + case RDMA_NODE_USNIC_UDP:
> + id->route.addr.dev_addr.transport = RDMA_TRANSPORT_USNIC_UDP;
> + break;
> + default:
> + BUG();
> + }
> +}
> +
>  static void cma_attach_to_dev(struct rdma_id_private *id_priv,
> struct cma_device *cma_dev)
>  {
>   atomic_inc(&cma_dev->refcount);
>   id_priv->cma_dev = cma_dev;
>   id_priv->id.device = cma_dev->device;
> - id_priv->id.route.addr.dev_addr.transport =
> - rdma_node_get_transport(cma_dev->device->node_type);
> + cma_set_legacy_transport(&id_priv->id);
>   list_add_tail(&id_priv->list, &cma_dev->id_list);
>  }
>  
> -- 
> 2.1.0
--
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 12/27] IB/Verbs: Reform mcast related part in IB-core cma

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:37:35AM +0200, Michael Wang wrote:
> 
> Use raw management helpers to reform mcast related part in IB-core cma.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/core/cma.c | 56 
> ++-
>  1 file changed, 18 insertions(+), 38 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index fa69f34..a89c246 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -997,17 +997,12 @@ static void cma_leave_mc_groups(struct rdma_id_private 
> *id_priv)
>   mc = container_of(id_priv->mc_list.next,
> struct cma_multicast, list);
>   list_del(&mc->list);
> - switch (rdma_port_get_link_layer(id_priv->cma_dev->device, 
> id_priv->id.port_num)) {
> - case IB_LINK_LAYER_INFINIBAND:
> + if (rdma_tech_ib(id_priv->cma_dev->device,
> +   id_priv->id.port_num)) {
>   ib_sa_free_multicast(mc->multicast.ib);
>   kfree(mc);
> - break;
> - case IB_LINK_LAYER_ETHERNET:
> + } else
>   kref_put(&mc->mcref, release_mc);
> - break;
> - default:
> - break;
> - }
>   }
>  }
>  
> @@ -3314,24 +3309,13 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct 
> sockaddr *addr,
>   list_add(&mc->list, &id_priv->mc_list);
>   spin_unlock(&id_priv->lock);
>  
> - switch (rdma_node_get_transport(id->device->node_type)) {
> - case RDMA_TRANSPORT_IB:
> - switch (rdma_port_get_link_layer(id->device, id->port_num)) {
> - case IB_LINK_LAYER_INFINIBAND:
> - ret = cma_join_ib_multicast(id_priv, mc);
> - break;
> - case IB_LINK_LAYER_ETHERNET:
> - kref_init(&mc->mcref);
> - ret = cma_iboe_join_multicast(id_priv, mc);
> - break;
> - default:
> - ret = -EINVAL;
> - }
> - break;
> - default:
> + if (rdma_tech_iboe(id->device, id->port_num)) {
> + kref_init(&mc->mcref);
> + ret = cma_iboe_join_multicast(id_priv, mc);
> + } else if (rdma_tech_ib(id->device, id->port_num))
> + ret = cma_join_ib_multicast(id_priv, mc);
> + else
>   ret = -ENOSYS;
> - break;
> - }
>  
>   if (ret) {
>   spin_lock_irq(&id_priv->lock);
> @@ -3359,19 +3343,15 @@ void rdma_leave_multicast(struct rdma_cm_id *id, 
> struct sockaddr *addr)
>   ib_detach_mcast(id->qp,
>   &mc->multicast.ib->rec.mgid,
>   
> be16_to_cpu(mc->multicast.ib->rec.mlid));
> - if 
> (rdma_node_get_transport(id_priv->cma_dev->device->node_type) == 
> RDMA_TRANSPORT_IB) {
> - switch (rdma_port_get_link_layer(id->device, 
> id->port_num)) {
> - case IB_LINK_LAYER_INFINIBAND:
> - ib_sa_free_multicast(mc->multicast.ib);
> - kfree(mc);
> - break;
> - case IB_LINK_LAYER_ETHERNET:
> - kref_put(&mc->mcref, release_mc);
> - break;
> - default:
> - break;
> - }
> - }
> +
> + BUG_ON(id_priv->cma_dev->device != id->device);
> +
> + if (rdma_tech_ib(id->device, id->port_num)) {
> + ib_sa_free_multicast(mc->multicast.ib);
> + kfree(mc);
> + } else if (rdma_tech_iboe(id->device, id->port_num))
> + kref_put(&mc->mcref, release_mc);
> +
>   return;
>   }
>   }
> -- 
> 2.1.0
--
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 03/27] IB/Verbs: Reform IB-core mad/agent/user_mad

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:33:11AM +0200, Michael Wang wrote:
> 
> Use raw management helpers to reform IB-core mad/agent/user_mad.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/core/agent.c|  2 +-
>  drivers/infiniband/core/mad.c  | 43 
> +++---
>  drivers/infiniband/core/user_mad.c | 26 ---
>  3 files changed, 41 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
> index f6d2961..ffdef4d 100644
> --- a/drivers/infiniband/core/agent.c
> +++ b/drivers/infiniband/core/agent.c
> @@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int 
> port_num)
>   goto error1;
>   }
>  
> - if (rdma_port_get_link_layer(device, port_num) == 
> IB_LINK_LAYER_INFINIBAND) {
> + if (rdma_tech_ib(device, port_num)) {
>   /* Obtain send only MAD agent for SMI QP */
>   port_priv->agent[0] = ib_register_mad_agent(device, port_num,
>   IB_QPT_SMI, NULL, 0,
> diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
> index 74c30f4..1822932 100644
> --- a/drivers/infiniband/core/mad.c
> +++ b/drivers/infiniband/core/mad.c
> @@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
>   init_mad_qp(port_priv, &port_priv->qp_info[1]);
>  
>   cq_size = mad_sendq_size + mad_recvq_size;
> - has_smi = rdma_port_get_link_layer(device, port_num) == 
> IB_LINK_LAYER_INFINIBAND;
> + has_smi = rdma_tech_ib(device, port_num);
>   if (has_smi)
>   cq_size *= 2;
>  
> @@ -3057,9 +3057,6 @@ static void ib_mad_init_device(struct ib_device *device)
>  {
>   int start, end, i;
>  
> - if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
> - return;
> -
>   if (device->node_type == RDMA_NODE_IB_SWITCH) {
>   start = 0;
>   end   = 0;
> @@ -3069,6 +3066,9 @@ static void ib_mad_init_device(struct ib_device *device)
>   }
>  
>   for (i = start; i <= end; i++) {
> + if (!rdma_ib_or_iboe(device, i))
> + continue;
> +
>   if (ib_mad_port_open(device, i)) {
>   dev_err(&device->dev, "Couldn't open port %d\n", i);
>   goto error;
> @@ -3086,40 +3086,39 @@ error_agent:
>   dev_err(&device->dev, "Couldn't close port %d\n", i);
>  
>  error:
> - i--;
> + while (--i >= start) {
> + if (!rdma_ib_or_iboe(device, i))
> + continue;
>  
> - while (i >= start) {
>   if (ib_agent_port_close(device, i))
>   dev_err(&device->dev,
>   "Couldn't close port %d for agents\n", i);
>   if (ib_mad_port_close(device, i))
>   dev_err(&device->dev, "Couldn't close port %d\n", i);
> - i--;
>   }
>  }
>  
>  static void ib_mad_remove_device(struct ib_device *device)
>  {
> - int i, num_ports, cur_port;
> -
> - if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
> - return;
> + int start, end, i;
>  
>   if (device->node_type == RDMA_NODE_IB_SWITCH) {
> - num_ports = 1;
> - cur_port = 0;
> + start = 0;
> + end   = 0;
>   } else {
> - num_ports = device->phys_port_cnt;
> - cur_port = 1;
> + start = 1;
> + end   = device->phys_port_cnt;
>   }
> - for (i = 0; i < num_ports; i++, cur_port++) {
> - if (ib_agent_port_close(device, cur_port))
> +
> + for (i = start; i <= end; i++) {
> + if (!rdma_ib_or_iboe(device, i))
> + continue;
> +
> + if (ib_agent_port_close(device, i))
>   dev_err(&device->dev,
> - "Couldn't close port %d for agents\n",
> - cur_port);
> - if (ib_mad_port_close(device, cur_port))
> - dev_err(&device->dev, "Couldn't close port %d\n",
> - cur_port);
> + "Couldn't close port %d for agents\n", i);
> + if (ib_mad_port_close(device, i))
> + dev_err(&device->dev, "Couldn't close port %d\n", i);
>   }
>  }
>  
> diff --git a/drivers/infiniband/core/user_mad.c 
> b/drivers/infiniband/core/user_mad.c
> index 928cdd2..aa8b334 100644
> --- a/drivers/infiniband/core/user_mad.c
> +++ b/drivers/infiniband/core/user_mad.c
> @@ -1273,9 +1273,7 @@ static void ib_umad_add_one(struct ib_device *device)
>  {
>   struct ib_umad_device *umad_dev;
>   int s, e, i;
> -
> - if (rdm

Re: [PATCH v5 11/27] IB/Verbs: Reform route related part in IB-core cma

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:37:13AM +0200, Michael Wang wrote:
> 
> Use raw management helpers to reform route related part in IB-core cma.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/core/cma.c  | 31 ---
>  drivers/infiniband/core/ucma.c | 25 ++---
>  2 files changed, 14 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
> index 815e41b..fa69f34 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -923,13 +923,9 @@ static inline int cma_user_data_offset(struct 
> rdma_id_private *id_priv)
>  
>  static void cma_cancel_route(struct rdma_id_private *id_priv)
>  {
> - switch (rdma_port_get_link_layer(id_priv->id.device, 
> id_priv->id.port_num)) {
> - case IB_LINK_LAYER_INFINIBAND:
> + if (rdma_tech_ib(id_priv->id.device, id_priv->id.port_num)) {
>   if (id_priv->query)
>   ib_sa_cancel_query(id_priv->query_id, id_priv->query);
> - break;
> - default:
> - break;
>   }
>  }
>  
> @@ -1957,26 +1953,15 @@ int rdma_resolve_route(struct rdma_cm_id *id, int 
> timeout_ms)
>   return -EINVAL;
>  
>   atomic_inc(&id_priv->refcount);
> - switch (rdma_node_get_transport(id->device->node_type)) {
> - case RDMA_TRANSPORT_IB:
> - switch (rdma_port_get_link_layer(id->device, id->port_num)) {
> - case IB_LINK_LAYER_INFINIBAND:
> - ret = cma_resolve_ib_route(id_priv, timeout_ms);
> - break;
> - case IB_LINK_LAYER_ETHERNET:
> - ret = cma_resolve_iboe_route(id_priv);
> - break;
> - default:
> - ret = -ENOSYS;
> - }
> - break;
> - case RDMA_TRANSPORT_IWARP:
> + if (rdma_tech_ib(id->device, id->port_num))
> + ret = cma_resolve_ib_route(id_priv, timeout_ms);
> + else if (rdma_tech_iboe(id->device, id->port_num))
> + ret = cma_resolve_iboe_route(id_priv);
> + else if (rdma_tech_iwarp(id->device, id->port_num))
>   ret = cma_resolve_iw_route(id_priv, timeout_ms);
> - break;
> - default:
> + else
>   ret = -ENOSYS;
> - break;
> - }
> +
>   if (ret)
>   goto err;
>  
> diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
> index 45d67e9..7331c6c 100644
> --- a/drivers/infiniband/core/ucma.c
> +++ b/drivers/infiniband/core/ucma.c
> @@ -722,26 +722,13 @@ static ssize_t ucma_query_route(struct ucma_file *file,
>  
>   resp.node_guid = (__force __u64) ctx->cm_id->device->node_guid;
>   resp.port_num = ctx->cm_id->port_num;
> - switch (rdma_node_get_transport(ctx->cm_id->device->node_type)) {
> - case RDMA_TRANSPORT_IB:
> - switch (rdma_port_get_link_layer(ctx->cm_id->device,
> - ctx->cm_id->port_num)) {
> - case IB_LINK_LAYER_INFINIBAND:
> - ucma_copy_ib_route(&resp, &ctx->cm_id->route);
> - break;
> - case IB_LINK_LAYER_ETHERNET:
> - ucma_copy_iboe_route(&resp, &ctx->cm_id->route);
> - break;
> - default:
> - break;
> - }
> - break;
> - case RDMA_TRANSPORT_IWARP:
> +
> + if (rdma_tech_ib(ctx->cm_id->device, ctx->cm_id->port_num))
> + ucma_copy_ib_route(&resp, &ctx->cm_id->route);
> + else if (rdma_tech_iboe(ctx->cm_id->device, ctx->cm_id->port_num))
> + ucma_copy_iboe_route(&resp, &ctx->cm_id->route);
> + else if (rdma_tech_iwarp(ctx->cm_id->device, ctx->cm_id->port_num))
>   ucma_copy_iw_route(&resp, &ctx->cm_id->route);
> - break;
> - default:
> - break;
> - }
>  
>  out:
>   if (copy_to_user((void __user *)(unsigned long)cmd.response,
> -- 
> 2.1.0
--
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 05/27] IB/Verbs: Reform IB-core sa_query

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:34:23AM +0200, Michael Wang wrote:
> 
> Use raw management helpers to reform IB-core sa_query.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 
>

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/core/sa_query.c | 29 +
>  1 file changed, 17 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/infiniband/core/sa_query.c 
> b/drivers/infiniband/core/sa_query.c
> index c38f030..60dc7aa 100644
> --- a/drivers/infiniband/core/sa_query.c
> +++ b/drivers/infiniband/core/sa_query.c
> @@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, 
> struct ib_event *event
>   struct ib_sa_port *port =
>   &sa_dev->port[event->element.port_num - 
> sa_dev->start_port];
>  
> - if (rdma_port_get_link_layer(handler->device, port->port_num) 
> != IB_LINK_LAYER_INFINIBAND)
> + if (WARN_ON(!rdma_tech_ib(handler->device, port->port_num)))
>   return;
>  
>   spin_lock_irqsave(&port->ah_lock, flags);
> @@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 
> port_num,
>   ah_attr->port_num = port_num;
>   ah_attr->static_rate = rec->rate;
>  
> - force_grh = rdma_port_get_link_layer(device, port_num) == 
> IB_LINK_LAYER_ETHERNET;
> + force_grh = rdma_tech_iboe(device, port_num);
>  
>   if (rec->hop_limit > 1 || force_grh) {
>   ah_attr->ah_flags = IB_AH_GRH;
> @@ -1153,9 +1153,7 @@ static void ib_sa_add_one(struct ib_device *device)
>  {
>   struct ib_sa_device *sa_dev;
>   int s, e, i;
> -
> - if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
> - return;
> + int count = 0;
>  
>   if (device->node_type == RDMA_NODE_IB_SWITCH)
>   s = e = 0;
> @@ -1175,7 +1173,7 @@ static void ib_sa_add_one(struct ib_device *device)
>  
>   for (i = 0; i <= e - s; ++i) {
>   spin_lock_init(&sa_dev->port[i].ah_lock);
> - if (rdma_port_get_link_layer(device, i + 1) != 
> IB_LINK_LAYER_INFINIBAND)
> + if (!rdma_tech_ib(device, i + 1))
>   continue;
>  
>   sa_dev->port[i].sm_ah= NULL;
> @@ -1189,8 +1187,13 @@ static void ib_sa_add_one(struct ib_device *device)
>   goto err;
>  
>   INIT_WORK(&sa_dev->port[i].update_task, update_sm_ah);
> +
> + count++;
>   }
>  
> + if (!count)
> + goto free;
> +
>   ib_set_client_data(device, &sa_client, sa_dev);
>  
>   /*
> @@ -1204,19 +1207,21 @@ static void ib_sa_add_one(struct ib_device *device)
>   if (ib_register_event_handler(&sa_dev->event_handler))
>   goto err;
>  
> - for (i = 0; i <= e - s; ++i)
> - if (rdma_port_get_link_layer(device, i + 1) == 
> IB_LINK_LAYER_INFINIBAND)
> + for (i = 0; i <= e - s; ++i) {
> + if (rdma_tech_ib(device, i + 1))
>   update_sm_ah(&sa_dev->port[i].update_task);
> + }
>  
>   return;
>  
>  err:
> - while (--i >= 0)
> - if (rdma_port_get_link_layer(device, i + 1) == 
> IB_LINK_LAYER_INFINIBAND)
> + while (--i >= 0) {
> + if (rdma_tech_ib(device, i + 1))
>   ib_unregister_mad_agent(sa_dev->port[i].agent);
> + }
>  
> +free:
>   kfree(sa_dev);
> -
>   return;
>  }
>  
> @@ -1233,7 +1238,7 @@ static void ib_sa_remove_one(struct ib_device *device)
>   flush_workqueue(ib_wq);
>  
>   for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
> - if (rdma_port_get_link_layer(device, i + 1) == 
> IB_LINK_LAYER_INFINIBAND) {
> + if (rdma_tech_ib(device, i + 1)) {
>   ib_unregister_mad_agent(sa_dev->port[i].agent);
>   if (sa_dev->port[i].sm_ah)
>   kref_put(&sa_dev->port[i].sm_ah->ref, 
> free_sm_ah);
> -- 
> 2.1.0
--
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 08/27] IB/Verbs: Reform IB-ulp xprtrdma

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:35:47AM +0200, Michael Wang wrote:
> 
> Use raw management helpers to reform IB-ulp xprtrdma.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  net/sunrpc/xprtrdma/svc_rdma_recvfrom.c  |  3 +--
>  net/sunrpc/xprtrdma/svc_rdma_transport.c | 45 
> +---
>  2 files changed, 19 insertions(+), 29 deletions(-)
> 
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c 
> b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> index f9f13a3..a5bed5b 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
> @@ -117,8 +117,7 @@ static void rdma_build_arg_xdr(struct svc_rqst *rqstp,
>  
>  static int rdma_read_max_sge(struct svcxprt_rdma *xprt, int sge_count)
>  {
> - if (rdma_node_get_transport(xprt->sc_cm_id->device->node_type) ==
> -  RDMA_TRANSPORT_IWARP)
> + if (rdma_tech_iwarp(xprt->sc_cm_id->device, xprt->sc_cm_id->port_num))
>   return 1;
>   else
>   return min_t(int, sge_count, xprt->sc_max_sge);
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c 
> b/net/sunrpc/xprtrdma/svc_rdma_transport.c
> index f609c1c..a09b7a1 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
> @@ -851,7 +851,7 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt 
> *xprt)
>   struct ib_qp_init_attr qp_attr;
>   struct ib_device_attr devattr;
>   int uninitialized_var(dma_mr_acc);
> - int need_dma_mr;
> + int need_dma_mr = 0;
>   int ret;
>   int i;
>  
> @@ -985,35 +985,26 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt 
> *xprt)
>   /*
>* Determine if a DMA MR is required and if so, what privs are required
>*/
> - switch (rdma_node_get_transport(newxprt->sc_cm_id->device->node_type)) {
> - case RDMA_TRANSPORT_IWARP:
> - newxprt->sc_dev_caps |= SVCRDMA_DEVCAP_READ_W_INV;
> - if (!(newxprt->sc_dev_caps & SVCRDMA_DEVCAP_FAST_REG)) {
> - need_dma_mr = 1;
> - dma_mr_acc =
> - (IB_ACCESS_LOCAL_WRITE |
> -  IB_ACCESS_REMOTE_WRITE);
> - } else if (!(devattr.device_cap_flags & 
> IB_DEVICE_LOCAL_DMA_LKEY)) {
> - need_dma_mr = 1;
> - dma_mr_acc = IB_ACCESS_LOCAL_WRITE;
> - } else
> - need_dma_mr = 0;
> - break;
> - case RDMA_TRANSPORT_IB:
> - if (!(newxprt->sc_dev_caps & SVCRDMA_DEVCAP_FAST_REG)) {
> - need_dma_mr = 1;
> - dma_mr_acc = IB_ACCESS_LOCAL_WRITE;
> - } else if (!(devattr.device_cap_flags &
> -  IB_DEVICE_LOCAL_DMA_LKEY)) {
> - need_dma_mr = 1;
> - dma_mr_acc = IB_ACCESS_LOCAL_WRITE;
> - } else
> - need_dma_mr = 0;
> - break;
> - default:
> + if (!rdma_tech_iwarp(newxprt->sc_cm_id->device,
> +  newxprt->sc_cm_id->port_num) &&
> + !rdma_ib_or_iboe(newxprt->sc_cm_id->device,
> +  newxprt->sc_cm_id->port_num))
>   goto errout;
> +
> + if (!(newxprt->sc_dev_caps & SVCRDMA_DEVCAP_FAST_REG) ||
> + !(devattr.device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY)) {
> + need_dma_mr = 1;
> + dma_mr_acc = IB_ACCESS_LOCAL_WRITE;
> + if (rdma_tech_iwarp(newxprt->sc_cm_id->device,
> + newxprt->sc_cm_id->port_num) &&
> + !(newxprt->sc_dev_caps & SVCRDMA_DEVCAP_FAST_REG))
> + dma_mr_acc |= IB_ACCESS_REMOTE_WRITE;
>   }
>  
> + if (rdma_tech_iwarp(newxprt->sc_cm_id->device,
> + newxprt->sc_cm_id->port_num))
> + newxprt->sc_dev_caps |= SVCRDMA_DEVCAP_READ_W_INV;
> +
>   /* Create the DMA MR if needed, otherwise, use the DMA LKEY */
>   if (need_dma_mr) {
>   /* Register all of physical memory */
> -- 
> 2.1.0
--
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 02/27] IB/Verbs: Implement raw management helpers

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:32:32AM +0200, Michael Wang wrote:
> 
> Add raw helpers:
>   rdma_tech_ib
>   rdma_tech_iboe
>   rdma_tech_iwarp
>   rdma_ib_or_iboe (transition, clean up later)
> To help us detect which technology the port supported.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  include/rdma/ib_verbs.h | 25 +
>  1 file changed, 25 insertions(+)
> 
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index d54f91e..a12e876 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -1748,6 +1748,31 @@ int ib_query_port(struct ib_device *device,
>  enum rdma_link_layer rdma_port_get_link_layer(struct ib_device *device,
>  u8 port_num);
>  
> +static inline int rdma_tech_ib(struct ib_device *device, u8 port_num)
> +{
> + return device->query_transport(device, port_num)
> + == RDMA_TRANSPORT_IB;
> +}
> +
> +static inline int rdma_tech_iboe(struct ib_device *device, u8 port_num)
> +{
> + return device->query_transport(device, port_num)
> + == RDMA_TRANSPORT_IBOE;
> +}
> +
> +static inline int rdma_tech_iwarp(struct ib_device *device, u8 port_num)
> +{
> + return device->query_transport(device, port_num)
> + == RDMA_TRANSPORT_IWARP;
> +}
> +
> +static inline int rdma_ib_or_iboe(struct ib_device *device, u8 port_num)
> +{
> + enum rdma_transport_type tp = device->query_transport(device, port_num);
> +
> + return (tp == RDMA_TRANSPORT_IB || tp == RDMA_TRANSPORT_IBOE);
> +}
> +
>  int ib_query_gid(struct ib_device *device,
>u8 port_num, int index, union ib_gid *gid);
>  
> -- 
> 2.1.0
--
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 07/27] IB/Verbs: Reform IB-ulp ipoib

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:35:15AM +0200, Michael Wang wrote:
> 
> Use raw management helpers to reform IB-ulp ipoib.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/ulp/ipoib/ipoib_main.c | 15 ---
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c 
> b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> index 58b5aa3..60b379d 100644
> --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
> +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> @@ -1654,9 +1654,7 @@ static void ipoib_add_one(struct ib_device *device)
>   struct net_device *dev;
>   struct ipoib_dev_priv *priv;
>   int s, e, p;
> -
> - if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
> - return;
> + int count = 0;
>  
>   dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL);
>   if (!dev_list)
> @@ -1673,15 +1671,21 @@ static void ipoib_add_one(struct ib_device *device)
>   }
>  
>   for (p = s; p <= e; ++p) {
> - if (rdma_port_get_link_layer(device, p) != 
> IB_LINK_LAYER_INFINIBAND)
> + if (!rdma_tech_ib(device, p))
>   continue;
>   dev = ipoib_add_port("ib%d", device, p);
>   if (!IS_ERR(dev)) {
>   priv = netdev_priv(dev);
>   list_add_tail(&priv->list, dev_list);
> + count++;
>   }
>   }
>  
> + if (!count) {
> + kfree(dev_list);
> + return;
> + }
> +
>   ib_set_client_data(device, &ipoib_client, dev_list);
>  }
>  
> @@ -1690,9 +1694,6 @@ static void ipoib_remove_one(struct ib_device *device)
>   struct ipoib_dev_priv *priv, *tmp;
>   struct list_head *dev_list;
>  
> - if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
> - return;
> -
>   dev_list = ib_get_client_data(device, &ipoib_client);
>   if (!dev_list)
>   return;
> -- 
> 2.1.0
--
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 04/27] IB/Verbs: Reform IB-core cm

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:33:45AM +0200, Michael Wang wrote:
> 
> Use raw management helpers to reform IB-core cm.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/core/cm.c | 20 +---
>  1 file changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
> index e28a494..3c10b75 100644
> --- a/drivers/infiniband/core/cm.c
> +++ b/drivers/infiniband/core/cm.c
> @@ -3761,9 +3761,7 @@ static void cm_add_one(struct ib_device *ib_device)
>   unsigned long flags;
>   int ret;
>   u8 i;
> -
> - if (rdma_node_get_transport(ib_device->node_type) != RDMA_TRANSPORT_IB)
> - return;
> + int count = 0;
>  
>   cm_dev = kzalloc(sizeof(*cm_dev) + sizeof(*port) *
>ib_device->phys_port_cnt, GFP_KERNEL);
> @@ -3783,6 +3781,9 @@ static void cm_add_one(struct ib_device *ib_device)
>  
>   set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask);
>   for (i = 1; i <= ib_device->phys_port_cnt; i++) {
> + if (!rdma_ib_or_iboe(ib_device, i))
> + continue;
> +
>   port = kzalloc(sizeof *port, GFP_KERNEL);
>   if (!port)
>   goto error1;
> @@ -3809,7 +3810,13 @@ static void cm_add_one(struct ib_device *ib_device)
>   ret = ib_modify_port(ib_device, i, 0, &port_modify);
>   if (ret)
>   goto error3;
> +
> + count++;
>   }
> +
> + if (!count)
> + goto free;
> +
>   ib_set_client_data(ib_device, &cm_client, cm_dev);
>  
>   write_lock_irqsave(&cm.device_lock, flags);
> @@ -3825,11 +3832,15 @@ error1:
>   port_modify.set_port_cap_mask = 0;
>   port_modify.clr_port_cap_mask = IB_PORT_CM_SUP;
>   while (--i) {
> + if (!rdma_ib_or_iboe(ib_device, i))
> + continue;
> +
>   port = cm_dev->port[i-1];
>   ib_modify_port(ib_device, port->port_num, 0, &port_modify);
>   ib_unregister_mad_agent(port->mad_agent);
>   cm_remove_port_fs(port);
>   }
> +free:
>   device_unregister(cm_dev->device);
>   kfree(cm_dev);
>  }
> @@ -3853,6 +3864,9 @@ static void cm_remove_one(struct ib_device *ib_device)
>   write_unlock_irqrestore(&cm.device_lock, flags);
>  
>   for (i = 1; i <= ib_device->phys_port_cnt; i++) {
> + if (!rdma_ib_or_iboe(ib_device, i))
> + continue;
> +
>   port = cm_dev->port[i-1];
>   ib_modify_port(ib_device, port->port_num, 0, &port_modify);
>   ib_unregister_mad_agent(port->mad_agent);
> -- 
> 2.1.0
--
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 06/27] IB/Verbs: Reform IB-core multicast

2015-04-21 Thread ira.weiny
On Mon, Apr 20, 2015 at 10:34:48AM +0200, Michael Wang wrote:
> 
> Use raw management helpers to reform IB-core multicast.
> 
> Cc: Hal Rosenstock 
> Cc: Steve Wise 
> Cc: Tom Talpey 
> Cc: Jason Gunthorpe 
> Cc: Doug Ledford 
> Cc: Ira Weiny 
> Cc: Sean Hefty 
> Signed-off-by: Michael Wang 

Reviewed-by: Ira Weiny 

> ---
>  drivers/infiniband/core/multicast.c | 12 +++-
>  1 file changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/infiniband/core/multicast.c 
> b/drivers/infiniband/core/multicast.c
> index fa17b55..24d93f5 100644
> --- a/drivers/infiniband/core/multicast.c
> +++ b/drivers/infiniband/core/multicast.c
> @@ -780,8 +780,7 @@ static void mcast_event_handler(struct ib_event_handler 
> *handler,
>   int index;
>  
>   dev = container_of(handler, struct mcast_device, event_handler);
> - if (rdma_port_get_link_layer(dev->device, event->element.port_num) !=
> - IB_LINK_LAYER_INFINIBAND)
> + if (WARN_ON(!rdma_tech_ib(dev->device, event->element.port_num)))
>   return;
>  
>   index = event->element.port_num - dev->start_port;
> @@ -808,9 +807,6 @@ static void mcast_add_one(struct ib_device *device)
>   int i;
>   int count = 0;
>  
> - if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
> - return;
> -
>   dev = kmalloc(sizeof *dev + device->phys_port_cnt * sizeof *port,
> GFP_KERNEL);
>   if (!dev)
> @@ -824,8 +820,7 @@ static void mcast_add_one(struct ib_device *device)
>   }
>  
>   for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> - if (rdma_port_get_link_layer(device, dev->start_port + i) !=
> - IB_LINK_LAYER_INFINIBAND)
> + if (!rdma_tech_ib(device, dev->start_port + i))
>   continue;
>   port = &dev->port[i];
>   port->dev = dev;
> @@ -863,8 +858,7 @@ static void mcast_remove_one(struct ib_device *device)
>   flush_workqueue(mcast_wq);
>  
>   for (i = 0; i <= dev->end_port - dev->start_port; i++) {
> - if (rdma_port_get_link_layer(device, dev->start_port + i) ==
> - IB_LINK_LAYER_INFINIBAND) {
> + if (rdma_tech_ib(device, dev->start_port + i)) {
>   port = &dev->port[i];
>   deref_port(port);
>   wait_for_completion(&port->comp);
> -- 
> 2.1.0
--
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: ioremap_uc() followed by set_memory_wc() - burrying MTRR

2015-04-21 Thread Luis R. Rodriguez
On Tue, Apr 21, 2015 at 04:57:32PM -0600, Jason Gunthorpe wrote:
> On Wed, Apr 22, 2015 at 12:46:01AM +0200, Luis R. Rodriguez wrote:
> 
> > are talking about annotating the qib driver as "known to be broken without 
> > PAT"
> > and since the ipath driver needs considerable work to be ported to
> > use PAT (the
> 
> This only seems to be true for one of the chips that driver supports,
> not all possibilities.
> 
> > userspace register is just one area) I wanted to review if we can just 
> > remove
> > MTRR use on the ipath driver and annotate write-combining with PAT as a TODO
> > item.
> 
> AFAIK, dropping MTRR support will completely break the performance to
> the point the driver is unusable. If we drop MTRR we may as well
> remove the driver.

To be clear, the arch_phys_wc_add() API will be a no-op when PAT is
enabled on a system. Although some folks think PAT is new, its not,
its just that our implementation on Linux lacked a bit of push, recent
changes however make PAT support complete and that means now we'll have
PAT enabled on systems that likely didn't before on recent kernels.

There are other important motivations to use PAT:

 * Xen won't work with MTRR, having a unified PAT enabled kernel
   will ensure that when Xen is used write-combinging will take
   effect

 * Long term we want to make strong UC the default to ioremap() on
   x86, right now its not, its UC-, we need to convert all drivers
   that want write-combining over to use ioremap_wc() for their
   specific area, and it must not overlap. There are issues with
   using mtrr_add() on regions marked as UC-, since its the default
   this  means that mtrr_add() use on ioramp'd areas on PAT systems
   will actually make write-combining *void*. Refer to this table
   for combinatorial effects for non-PAT / PAT of wc MTRR:

   https://marc.info/?l=linux-kernel&m=142964809710517&w=1

So as the train of PAT enablement moves forward it means systems
that have PAT enabled now might not have write-combining effective.
In order to get the best of both worlds, non-PAT and PAT systems
we must design drivers cleanly for the non-writecombining and
write-combining areas. This mean using ioremap_nocache() for MMIO
and ioremap_wc() *only* for the desired, write-combining area,
followed by arch_phys_wc_add().

> Mike, do you think the time is right to just remove the iPath driver?

With PAT now being default the driver effectively won't work
with write-combining on modern kernels. Even if systems are old
they likely had PAT support, when upgrading kernels PAT will work
but write-combing won't on ipath.

  Luis
--
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 00/27] IB/Verbs: IB Management Helpers

2015-04-21 Thread Liran Liss
Hi Michael,

The spirit of this patch-set is great, but I think that we need to clarify some 
concepts.
Since this will affect the whole patch-set, I am laying out my concerns here 
instead.

A suggestion for the resulting management helpers is given below.
I believe the result would be much more coherent.
--Liran

In general


An ib_dev (or a port of) should be distinguished by 3 qualifiers:
- The link layer:
-- Ethernet (shared by iWARP, USNIC, and ROCE)
-- Infiniband

- The transport (*)
-- IBTA transport (shared by IB and ROCE)
-- iWARP transport
-- USNIC transport

(*) Transport means both:
- The L4 wire protocols (e.g., BTH+ headers of IBTA, optionally encapsulated by 
UDP in ROCEv2, or the iWARP stack)
- The transport semantics (for example, there are slight semantic differences 
between IBTA and iWARP)

- The node type (**)
-- CA
-- Switch
-- Router

(**) This has been extended to also encode the transport in the current code.
At least for user-space visible APIs, we might chose to leave this for backward 
compatibility, but we can consider cleaning up the kernel code.

So, I think that our "old-transport" below is just fine.
No need to change it (and you aren't, since it is currently implemented as a 
function).

The "new-transport" does not really exist, but is broken into several 
capability checks of the L4 transport, optionally with conditions on the link 
type.
I would remove the table below and tell what we really want to achieve:
==> move technology-specific feature-check logic out of the (multiple!) IB code 
components and various ULPs into per-feature helpers.


Detailed remarks
==

1) The introduction of cap_*_*() stuff should have been introduced directly in 
patch 02/27.
This back-and-forth between rdma_ib_or_iboe() and cap_* is confusing and 
increases the number of patches in the patch-set.
Do this and remove patches 16-24.

2)The name rdma_tech_* is lame.
rdma_transport_*(), adhering to the above (*) remark, is much better.
For example, both IB and ROCE *do* use the same transport. 

3) The name cap_* as it is used above is not accurate.
You use it to describe technology characteristics rather than extendable 
capabilities.
I would suggest having a single convention for all helpers, such as 
rdma_has_*() and rdma_is_*().
For example: cap_ib_smi() ==> rdma_has_smi().

4) Remove all capabilities that do not introduce any distinction in the current 
code.
We can add them as needed later.
This means remove patches:
- [PATCH v5 22/27] IB/Verbs: Use management helper cap_ipoib() – all IB devices 
support ipoib
- [PATCH v5 24/27] IB/Verbs: Use management helper cap_af_ib() – all IB devices 
support AF_IB.

On the other hand:
- rdma_has_multicast() makes sense, since iWARP doesn’t support it.
- cap_ib_sa() might make sense to cut code even further in the CMA, since RoCE 
has a GSI but no SA.

5) Do no modify phys_state_show() in [PATCH v5 09/27] IB/Verbs: Reform IB-core 
verbs/uverbs_cmd/sysfs
It *is* the link layer!

6) Remove cap_read_multi_sge
It is not device/port feature, but a transport capability.
Use rdma_is_iwarp_transport() instead, or introduce a new transport flag in 
'enum ib_device_cap_flags'.
 
7) Remove [PATCH v5 25/27] IB/Verbs: Use management helper cap_eth_ah().
Address handles that refer to Ethernet links always have Ethernet addressing.

In the CMA code, using rdma_tech_iboe() is just fine. This is how you define 
cap_eth_ah() anyway.
Currently, this patch just adds clutter.

8) Remove patch [PATCH v5 26/27] IB/Verbs: Clean up rdma_ib_or_iboe().
We do need a transport qualifier, as exemplified in comment 5) above, and for a 
complete clean model.
This is after renaming the function to rdma_is_ib_transport()...


Putting it all together
==

We are left with the following helpers:
- rdma_is_ib_transport()
- rdma_is_iwarp_transport()
- rdma_is_usnic_transport()
- rdma_is_iboe()
- rdma_has_mad()
- rdma_has_smi()
- rdma_has_gsi() - complements smi; can be used by the mad code for clarity
- rdma_has_sa()
- rdma_has_cm()
- rdma_has_mcast()


> Subject: [PATCH v5 00/27] IB/Verbs: IB Management Helpers
> 
> 
> Since v4:
>   * Thanks for the comments from Hal, Sean, Tom, Or Gerlitz, Jason,
> Roland, Ira and Steve :-) Please remind me if anything missed :-P
>   * Fix logical issue inside 3#, 14#
>   * Refine 3#, 4#, 5# with label 'free'
>   * Rework 10# to stop using port 1 when port already assigned
> 
> There are plenty of lengthy code to check the transport type of IB device, or
> the link layer type of it's port, but actually we are just speculating 
> whether a
> particular management/feature is supported by the device/port.
> 
> Thus instead of inferring, we should have our own mechanism for IB
> management capability/protocol/feature checking, several proposals below.
> 
> This patch set will reform the method of getting transport type, we will now
> using query_transport() instead of inferring from transport and link layer
> respecti

Re: ioremap_uc() followed by set_memory_wc() - burrying MTRR

2015-04-21 Thread Jason Gunthorpe
On Wed, Apr 22, 2015 at 12:46:01AM +0200, Luis R. Rodriguez wrote:

> are talking about annotating the qib driver as "known to be broken without 
> PAT"
> and since the ipath driver needs considerable work to be ported to
> use PAT (the

This only seems to be true for one of the chips that driver supports,
not all possibilities.

> userspace register is just one area) I wanted to review if we can just remove
> MTRR use on the ipath driver and annotate write-combining with PAT as a TODO
> item.

AFAIK, dropping MTRR support will completely break the performance to
the point the driver is unusable. If we drop MTRR we may as well
remove the driver.

Mike, do you think the time is right to just remove the iPath driver?

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: ioremap_uc() followed by set_memory_wc() - burrying MTRR

2015-04-21 Thread Luis R. Rodriguez
On Wed, Apr 15, 2015 at 01:42:47PM -0700, Andy Lutomirski wrote:
> On Mon, Apr 13, 2015 at 10:49 AM, Luis R. Rodriguez  wrote:
> 
> > c) ivtv: the driver does not have the PCI space mapped out separately, and
> > in fact it actually does not do the math for the framebuffer, instead it 
> > lets
> > the device's own CPU do that and assume where its at, see
> > ivtvfb_get_framebuffer() and CX2341X_OSD_GET_FRAMEBUFFER, it has a get
> > but not a setter. Its not clear if the firmware would make a split easy.
> > We'd need ioremap_ucminus() here too and __arch_phys_wc_add().
> >
> 
> IMO this should be conceptually easy to split.  Once we get the
> framebuffer address, just unmap it (or don't prematurely map it) and
> then ioremap the thing.

Side note to ipath driver folks: as reviewed with Andy Walls, the
ivtv driver cannot easily be ported to use PAT so we are evaluating
simply removing write-combing from that driver on future kernels.

> 
> > From the beginning it seems only framebuffer devices used MTRR/WC, lately it
> > seems infiniband drivers also find good use for for it for PIO TX buffers to
> > blast some sort of data, in the future I would not be surprised if other
> > devices found use for it.
> 
> IMO the Infiniband maintainers should fix their code.  Especially in
> the server space, there aren't that many MTRRs to go around.  I wrote
> arch_phys_wc_add in the first place because my server *ran out of
> MTRRs*.
> 
> Hey, IB people: can you fix your drivers to use arch_phys_wc_add
> (which is permitted to be a no-op) along with ioremap_wc?  Your users

ipath driver maintainers:

The ipath driver is one of two drivers left to convert over to
arch_phys_wc_add(). MTRR use is being deprecated, and its use is actually
highly discouraged now that we have proper PAT implemenation on Linux. Since we
are talking about annotating the qib driver as "known to be broken without PAT"
and since the ipath driver needs considerable work to be ported to use PAT (the
userspace register is just one area) I wanted to review if we can just remove
MTRR use on the ipath driver and annotate write-combining with PAT as a TODO
item.

This would help a lot in our journey to bury MTRR use.

  Luis
--
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 v4 2/2] IB/qib: use arch_phys_wc_add()

2015-04-21 Thread Jason Gunthorpe
On Tue, Apr 21, 2015 at 02:50:35PM -0700, Luis R. Rodriguez wrote:
> - if (qib_wc_pat) {
> - resource_size_t vl15off;
> - /*
> -  * We do not set WC on the VL15 buffers to avoid
> -  * a rare problem with unaligned writes from
> -  * interrupt-flushed store buffers, so we need
> -  * to map those separately here.  We can't solve
> -  * this for the rarely used mtrr case.
> -  */
> - ret = init_chip_wc_pat(dd, 0);
> - if (ret)
> - goto bail;
> + /*
> +  * We do not set WC on the VL15 buffers to avoid
> +  * a rare problem with unaligned writes from
> +  * interrupt-flushed store buffers, so we need
> +  * to map those separately here.  We can't solve
> +  * this for the rarely used mtrr case.
> +  */

This is a small change in behavior, but it doesn't seem important..

Mike, what do you think about adding:

 if (dd->wc_cookie)
dev_err(.., "Using this device without CPU PAT support is known to be 
broken");

or similar..

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


[PATCH v4 2/2] IB/qib: use arch_phys_wc_add()

2015-04-21 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

This driver already makes use of ioremap_wc() on PIO buffers,
so convert it to use arch_phys_wc_add().

The qib driver uses a mmap() special case for when PAT is
not used, this behaviour used to be determined with a
module parameter but since we have been asked to just
remove that module parameter this checks for the WC cookie,
if not set we can assume PAT was used. If its set we do
what we used to do for the mmap for when MTRR was enabled.

The removal of the module parameter is OK given that Andy
notes that even if users of module parameter are still around
it will not prevent loading of the module on recent kernels.

Cc: Toshi Kani 
Cc: Rickard Strandqvist 
Cc: Mike Marciniszyn 
Cc: Roland Dreier 
Cc: Sean Hefty 
Cc: Hal Rosenstock 
Cc: Dennis Dalessandro 
Cc: Andy Lutomirski 
Cc: Suresh Siddha 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Dave Airlie 
Cc: Bjorn Helgaas 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: Dave Hansen 
Cc: Arnd Bergmann 
Cc: Michael S. Tsirkin 
Cc: Stefan Bader 
Cc: konrad.w...@oracle.com
Cc: ville.syrj...@linux.intel.com
Cc: david.vra...@citrix.com
Cc: jbeul...@suse.com
Cc: Roger Pau Monné 
Cc: infinip...@intel.com
Cc: linux-rdma@vger.kernel.org
Cc: linux-fb...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Cc: xen-de...@lists.xensource.com
Signed-off-by: Luis R. Rodriguez 
---
 drivers/infiniband/hw/qib/qib.h   |  1 -
 drivers/infiniband/hw/qib/qib_file_ops.c  |  3 ++-
 drivers/infiniband/hw/qib/qib_iba6120.c   |  8 +++---
 drivers/infiniband/hw/qib/qib_iba7220.c   |  8 +++---
 drivers/infiniband/hw/qib/qib_iba7322.c   | 41 +++
 drivers/infiniband/hw/qib/qib_init.c  | 26 ++--
 drivers/infiniband/hw/qib/qib_wc_x86_64.c | 31 +++
 7 files changed, 39 insertions(+), 79 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
index ffd48bf..ba5173e2 100644
--- a/drivers/infiniband/hw/qib/qib.h
+++ b/drivers/infiniband/hw/qib/qib.h
@@ -1136,7 +1136,6 @@ extern struct qib_devdata *qib_lookup(int unit);
 extern u32 qib_cpulist_count;
 extern unsigned long *qib_cpulist;
 
-extern unsigned qib_wc_pat;
 extern unsigned qib_cc_table_size;
 int qib_init(struct qib_devdata *, int);
 int init_chip_wc_pat(struct qib_devdata *dd, u32);
diff --git a/drivers/infiniband/hw/qib/qib_file_ops.c 
b/drivers/infiniband/hw/qib/qib_file_ops.c
index 9ea6c44..9868499 100644
--- a/drivers/infiniband/hw/qib/qib_file_ops.c
+++ b/drivers/infiniband/hw/qib/qib_file_ops.c
@@ -835,7 +835,8 @@ static int mmap_piobufs(struct vm_area_struct *vma,
vma->vm_flags &= ~VM_MAYREAD;
vma->vm_flags |= VM_DONTCOPY | VM_DONTEXPAND;
 
-   if (qib_wc_pat)
+   /* MTRR was used if this is non-zero */
+   if (!dd->wc_cookie)
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
 
ret = io_remap_pfn_range(vma, vma->vm_start, phys >> PAGE_SHIFT,
diff --git a/drivers/infiniband/hw/qib/qib_iba6120.c 
b/drivers/infiniband/hw/qib/qib_iba6120.c
index 0d2ba59..4b927809 100644
--- a/drivers/infiniband/hw/qib/qib_iba6120.c
+++ b/drivers/infiniband/hw/qib/qib_iba6120.c
@@ -3315,11 +3315,9 @@ static int init_6120_variables(struct qib_devdata *dd)
qib_6120_config_ctxts(dd);
qib_set_ctxtcnt(dd);
 
-   if (qib_wc_pat) {
-   ret = init_chip_wc_pat(dd, 0);
-   if (ret)
-   goto bail;
-   }
+   ret = init_chip_wc_pat(dd, 0);
+   if (ret)
+   goto bail;
set_6120_baseaddrs(dd); /* set chip access pointers now */
 
ret = 0;
diff --git a/drivers/infiniband/hw/qib/qib_iba7220.c 
b/drivers/infiniband/hw/qib/qib_iba7220.c
index 22affda..00b2af2 100644
--- a/drivers/infiniband/hw/qib/qib_iba7220.c
+++ b/drivers/infiniband/hw/qib/qib_iba7220.c
@@ -4126,11 +4126,9 @@ static int qib_init_7220_variables(struct qib_devdata 
*dd)
qib_7220_config_ctxts(dd);
qib_set_ctxtcnt(dd);  /* needed for PAT setup */
 
-   if (qib_wc_pat) {
-   ret = init_chip_wc_pat(dd, 0);
-   if (ret)
-   goto bail;
-   }
+   ret = init_chip_wc_pat(dd, 0);
+   if (ret)
+   goto bail;
set_7220_baseaddrs(dd); /* set chip access pointers now */
 
ret = 0;
diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c 
b/drivers/infiniband/hw/qib/qib_iba7322.c
index ef97b71..f32b462 100644
--- a/drivers/infiniband/hw/qib/qib_iba7322.c
+++ b/drivers/infiniband/hw/qib/qib_iba7322.c
@@ -6429,6 +6429,7 @@ static int qib_init_7322_variables(struct qib_devdata *dd)
unsigned features, pidx, sbufcnt;
int ret, mtu;
u32 sbufs, updthresh;
+   resource_size_t vl15off;
 
/* pport structs are contiguous, allocated after devdata */
ppd = (struct qib_pportdata *)(dd + 1);
@@ -6677,29 +6678,27 @@ static 

[PATCH v4 1/2] IB/qib: add acounting for MTRR

2015-04-21 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

There is no good reason not to, we eventually delete it as well.

Cc: Toshi Kani 
Cc: Suresh Siddha 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: Mike Marciniszyn 
Cc: Roland Dreier 
Cc: Sean Hefty 
Cc: Hal Rosenstock 
Cc: linux-rdma@vger.kernel.org
Cc: linux-fb...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/infiniband/hw/qib/qib_wc_x86_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/qib/qib_wc_x86_64.c 
b/drivers/infiniband/hw/qib/qib_wc_x86_64.c
index 81b225f..fe0850a 100644
--- a/drivers/infiniband/hw/qib/qib_wc_x86_64.c
+++ b/drivers/infiniband/hw/qib/qib_wc_x86_64.c
@@ -118,7 +118,7 @@ int qib_enable_wc(struct qib_devdata *dd)
if (!ret) {
int cookie;
 
-   cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 0);
+   cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 1);
if (cookie < 0) {
{
qib_devinfo(dd->pcidev,
-- 
2.3.2.209.gd67f9d5.dirty

--
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 v4 0/2] qib: few changes to bury MTRR use

2015-04-21 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

MTRR use is being deprecated and should only be used
with the helper arch_phys_wc_add() when PAT is not
available and enabled. This v4 follows addresse the
removal of the PAT module parameter for the driver which
was always preferring PAT anyway.

Luis R. Rodriguez (2):
  IB/qib: add acounting for MTRR
  IB/qib: use arch_phys_wc_add()

 drivers/infiniband/hw/qib/qib.h   |  1 -
 drivers/infiniband/hw/qib/qib_file_ops.c  |  3 ++-
 drivers/infiniband/hw/qib/qib_iba6120.c   |  8 +++---
 drivers/infiniband/hw/qib/qib_iba7220.c   |  8 +++---
 drivers/infiniband/hw/qib/qib_iba7322.c   | 41 +++
 drivers/infiniband/hw/qib/qib_init.c  | 26 ++--
 drivers/infiniband/hw/qib/qib_wc_x86_64.c | 31 +++
 7 files changed, 39 insertions(+), 79 deletions(-)

-- 
2.3.2.209.gd67f9d5.dirty

--
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 net] net/mlx4_core: Fix reading HCA max message size in mlx4_QUERY_DEV_CAP

2015-04-21 Thread David Miller
From: Or Gerlitz 
Date: Tue, 21 Apr 2015 15:46:34 +0300

> From: Eran Ben Elisha 
> 
> Currently we parse max_msg_sz from the wrong offset in QUERY_DEV_CAP,
> fix to use the right offset.
> 
> Fixes: 0b131561a7d6 ('net/mlx4_en: Add Flow control statistics [..]')
> Signed-off-by: Eran Ben Elisha 
> Signed-off-by: Or Gerlitz 

Applied, thanks.
--
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 v3 2/3] IB/qib: use arch_phys_wc_add()

2015-04-21 Thread Luis R. Rodriguez
On Tue, Apr 21, 2015 at 2:12 PM, Andy Lutomirski  wrote:
> On Tue, Apr 21, 2015 at 2:09 PM, Luis R. Rodriguez
>  wrote:
>> On Tue, Apr 21, 2015 at 1:59 PM, Marciniszyn, Mike
>>  wrote:
 > This driver already makes use of ioremap_wc() on PIO buffers, so
 > convert it to use arch_phys_wc_add().

 This is probably OK, but I think you should also remove the qib_wc_pat 
 module
 parameter.

 Jason
>>>
>>> Revise based on Jason's request and I will do some testing.
>>
>> I did thiink about this -- but removal of module parameters can often
>> times break users of the module parameter, I figured its best to leave
>> it to you guys to decide what to do with that, so this leaves it as a
>> no-op. Can this series be applied and then you can decide what to do
>> to not affect your users on top of this?
>
> As of a few kernel versions ago, unrecognized module parameters no
> longer cause the module to refuse to load.

Sexy, I'll respin the changes only to the qib driver. Can the changes
to ipath still be applied?

 Luis
--
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 v3 2/3] IB/qib: use arch_phys_wc_add()

2015-04-21 Thread Andy Lutomirski
On Tue, Apr 21, 2015 at 2:09 PM, Luis R. Rodriguez
 wrote:
> On Tue, Apr 21, 2015 at 1:59 PM, Marciniszyn, Mike
>  wrote:
>>> > This driver already makes use of ioremap_wc() on PIO buffers, so
>>> > convert it to use arch_phys_wc_add().
>>>
>>> This is probably OK, but I think you should also remove the qib_wc_pat 
>>> module
>>> parameter.
>>>
>>> Jason
>>
>> Revise based on Jason's request and I will do some testing.
>
> I did thiink about this -- but removal of module parameters can often
> times break users of the module parameter, I figured its best to leave
> it to you guys to decide what to do with that, so this leaves it as a
> no-op. Can this series be applied and then you can decide what to do
> to not affect your users on top of this?

As of a few kernel versions ago, unrecognized module parameters no
longer cause the module to refuse to load.

--Andy

>
>  Luis



-- 
Andy Lutomirski
AMA Capital Management, LLC
--
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 v3 2/3] IB/qib: use arch_phys_wc_add()

2015-04-21 Thread Luis R. Rodriguez
On Tue, Apr 21, 2015 at 1:59 PM, Marciniszyn, Mike
 wrote:
>> > This driver already makes use of ioremap_wc() on PIO buffers, so
>> > convert it to use arch_phys_wc_add().
>>
>> This is probably OK, but I think you should also remove the qib_wc_pat module
>> parameter.
>>
>> Jason
>
> Revise based on Jason's request and I will do some testing.

I did thiink about this -- but removal of module parameters can often
times break users of the module parameter, I figured its best to leave
it to you guys to decide what to do with that, so this leaves it as a
no-op. Can this series be applied and then you can decide what to do
to not affect your users on top of this?

 Luis
--
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 v3 2/3] IB/qib: use arch_phys_wc_add()

2015-04-21 Thread Marciniszyn, Mike
> > This driver already makes use of ioremap_wc() on PIO buffers, so
> > convert it to use arch_phys_wc_add().
> 
> This is probably OK, but I think you should also remove the qib_wc_pat module
> parameter.
> 
> Jason

Revise based on Jason's request and I will do some testing.

Mike
--
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 v3 2/3] IB/qib: use arch_phys_wc_add()

2015-04-21 Thread Jason Gunthorpe
On Tue, Apr 21, 2015 at 01:37:55PM -0700, Luis R. Rodriguez wrote:
> From: "Luis R. Rodriguez" 
> 
> This driver already makes use of ioremap_wc() on PIO buffers,
> so convert it to use arch_phys_wc_add().

This is probably OK, but I think you should also remove the qib_wc_pat
module parameter.

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


[PATCH v3 1/3] IB/qib: add acounting for MTRR

2015-04-21 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

There is no good reason not to, we eventually delete it as well.

Cc: Toshi Kani 
Cc: Suresh Siddha 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: Mike Marciniszyn 
Cc: Roland Dreier 
Cc: Sean Hefty 
Cc: Hal Rosenstock 
Cc: linux-rdma@vger.kernel.org
Cc: linux-fb...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/infiniband/hw/qib/qib_wc_x86_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/qib/qib_wc_x86_64.c 
b/drivers/infiniband/hw/qib/qib_wc_x86_64.c
index 81b225f..fe0850a 100644
--- a/drivers/infiniband/hw/qib/qib_wc_x86_64.c
+++ b/drivers/infiniband/hw/qib/qib_wc_x86_64.c
@@ -118,7 +118,7 @@ int qib_enable_wc(struct qib_devdata *dd)
if (!ret) {
int cookie;
 
-   cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 0);
+   cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 1);
if (cookie < 0) {
{
qib_devinfo(dd->pcidev,
-- 
2.3.2.209.gd67f9d5.dirty

--
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 v3 3/3] IB/ipath: add counting for MTRR

2015-04-21 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

There is no good reason not to, we eventually delete it as well.

Cc: Toshi Kani 
Cc: Roland Dreier 
Cc: Sean Hefty 
Cc: Hal Rosenstock 
Cc: Suresh Siddha 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Andy Lutomirski 
Cc: Dave Airlie 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: infinip...@intel.com
Cc: linux-rdma@vger.kernel.org
Cc: linux-fb...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Luis R. Rodriguez 
---
 drivers/infiniband/hw/ipath/ipath_wc_x86_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c 
b/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
index 4ad0b93..70c1f3a 100644
--- a/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
+++ b/drivers/infiniband/hw/ipath/ipath_wc_x86_64.c
@@ -127,7 +127,7 @@ int ipath_enable_wc(struct ipath_devdata *dd)
   "(addr %llx, len=0x%llx)\n",
   (unsigned long long) pioaddr,
   (unsigned long long) piolen);
-   cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 0);
+   cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 1);
if (cookie < 0) {
{
dev_info(&dd->pcidev->dev,
-- 
2.3.2.209.gd67f9d5.dirty

--
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 v3 2/3] IB/qib: use arch_phys_wc_add()

2015-04-21 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

This driver already makes use of ioremap_wc() on PIO buffers,
so convert it to use arch_phys_wc_add().

Cc: Toshi Kani 
Cc: Rickard Strandqvist 
Cc: Mike Marciniszyn 
Cc: Roland Dreier 
Cc: Sean Hefty 
Cc: Hal Rosenstock 
Cc: Dennis Dalessandro 
Cc: Andy Lutomirski 
Cc: Suresh Siddha 
Cc: Ingo Molnar 
Cc: Thomas Gleixner 
Cc: Juergen Gross 
Cc: Daniel Vetter 
Cc: Dave Airlie 
Cc: Bjorn Helgaas 
Cc: Antonino Daplas 
Cc: Jean-Christophe Plagniol-Villard 
Cc: Tomi Valkeinen 
Cc: Dave Hansen 
Cc: Arnd Bergmann 
Cc: Michael S. Tsirkin 
Cc: Stefan Bader 
Cc: konrad.w...@oracle.com
Cc: ville.syrj...@linux.intel.com
Cc: david.vra...@citrix.com
Cc: jbeul...@suse.com
Cc: Roger Pau Monné 
Cc: infinip...@intel.com
Cc: linux-rdma@vger.kernel.org
Cc: linux-fb...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Cc: xen-de...@lists.xensource.com
Signed-off-by: Luis R. Rodriguez 
---
 drivers/infiniband/hw/qib/qib_wc_x86_64.c | 31 ---
 1 file changed, 4 insertions(+), 27 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib_wc_x86_64.c 
b/drivers/infiniband/hw/qib/qib_wc_x86_64.c
index fe0850a..6d61ef9 100644
--- a/drivers/infiniband/hw/qib/qib_wc_x86_64.c
+++ b/drivers/infiniband/hw/qib/qib_wc_x86_64.c
@@ -116,21 +116,9 @@ int qib_enable_wc(struct qib_devdata *dd)
}
 
if (!ret) {
-   int cookie;
-
-   cookie = mtrr_add(pioaddr, piolen, MTRR_TYPE_WRCOMB, 1);
-   if (cookie < 0) {
-   {
-   qib_devinfo(dd->pcidev,
-"mtrr_add()  WC for PIO bufs failed 
(%d)\n",
-cookie);
-   ret = -EINVAL;
-   }
-   } else {
-   dd->wc_cookie = cookie;
-   dd->wc_base = (unsigned long) pioaddr;
-   dd->wc_len = (unsigned long) piolen;
-   }
+   dd->wc_cookie = arch_phys_wc_add(pioaddr, piolen);
+   if (dd->wc_cookie < 0)
+   ret = -EINVAL;
}
 
return ret;
@@ -142,18 +130,7 @@ int qib_enable_wc(struct qib_devdata *dd)
  */
 void qib_disable_wc(struct qib_devdata *dd)
 {
-   if (dd->wc_cookie) {
-   int r;
-
-   r = mtrr_del(dd->wc_cookie, dd->wc_base,
-dd->wc_len);
-   if (r < 0)
-   qib_devinfo(dd->pcidev,
-"mtrr_del(%lx, %lx, %lx) failed: %d\n",
-dd->wc_cookie, dd->wc_base,
-dd->wc_len, r);
-   dd->wc_cookie = 0; /* even on failure */
-   }
+   arch_phys_wc_del(dd->wc_cookie);
 }
 
 /**
-- 
2.3.2.209.gd67f9d5.dirty

--
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 v3 0/3] infiniband: few MTRR fixes and conversions

2015-04-21 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

Infiniband has a few MTRR uses which from the looks of it
was first written on the ipath driver, later copied and pasted
on the qib driver. The behaviour of not counting is matched on
both drivers but with no good reason, since we want to generalize
use of MTRR in order to actually phase it, fix the driver to use
accounting as all other kernel users and also convert the qib
driver to arch_phys_wc_add().

The ipath driver is left without conversion to arch_phys_wc_add().

Luis R. Rodriguez (3):
  IB/qib: add acounting for MTRR
  IB/qib: use arch_phys_wc_add()
  IB/ipath: add counting for MTRR

 drivers/infiniband/hw/ipath/ipath_wc_x86_64.c |  2 +-
 drivers/infiniband/hw/qib/qib_wc_x86_64.c | 31 ---
 2 files changed, 5 insertions(+), 28 deletions(-)

-- 
2.3.2.209.gd67f9d5.dirty

--
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 3/3] RDMA/cxgb4: Report the actual address of the remote connecting peer

2015-04-21 Thread Tatyana Nikolova
From: Steve Wise 

Get the actual (non-mapped) ip/tcp address of the connecting peer from
the port mapper

Also setup the passive side endpoint to correctly display the actual
and mapped addresses for the new connection.

Signed-off-by: Steve Wise 
---
 drivers/infiniband/hw/cxgb4/cm.c |   54 +++--
 drivers/infiniband/hw/cxgb4/device.c |1 +
 2 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 57176dd..390e837 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -583,6 +583,22 @@ static void c4iw_record_pm_msg(struct c4iw_ep *ep,
sizeof(ep->com.mapped_remote_addr));
 }
 
+static int get_remote_addr(struct c4iw_ep *ep)
+{
+   int ret;
+
+   print_addr(&ep->com, __func__, "get_remote_addr");
+
+   ret = iwpm_get_remote_info(&ep->com.mapped_local_addr,
+  &ep->com.mapped_remote_addr,
+  &ep->com.remote_addr, RDMA_NL_C4IW);
+   if (ret)
+   pr_info(MOD "Unable to find remote peer addr info - err %d\n",
+   ret);
+
+   return ret;
+}
+
 static void best_mtu(const unsigned short *mtus, unsigned short mtu,
 unsigned int *idx, int use_ts, int ipv6)
 {
@@ -2352,27 +2368,57 @@ static int pass_accept_req(struct c4iw_dev *dev, struct 
sk_buff *skb)
state_set(&child_ep->com, CONNECTING);
child_ep->com.dev = dev;
child_ep->com.cm_id = NULL;
+
+   /*
+* The mapped_local and mapped_remote addresses get setup with
+* the actual 4-tuple.  The local address will be based on the
+* actual local address of the connection, but on the port number
+* of the parent listening endpoint.  The remote address is
+* setup based on a query to the IWPM since we don't know what it
+* originally was before mapping.  If no mapping was done, then
+* mapped_remote == remote, and mapped_local == local.
+*/
if (iptype == 4) {
struct sockaddr_in *sin = (struct sockaddr_in *)
-   &child_ep->com.local_addr;
+   &child_ep->com.mapped_local_addr;
+
sin->sin_family = PF_INET;
sin->sin_port = local_port;
sin->sin_addr.s_addr = *(__be32 *)local_ip;
-   sin = (struct sockaddr_in *)&child_ep->com.remote_addr;
+
+   sin = (struct sockaddr_in *)&child_ep->com.local_addr;
+   sin->sin_family = PF_INET;
+   sin->sin_port = ((struct sockaddr_in *)
+&parent_ep->com.local_addr)->sin_port;
+   sin->sin_addr.s_addr = *(__be32 *)local_ip;
+
+   sin = (struct sockaddr_in *)&child_ep->com.mapped_remote_addr;
sin->sin_family = PF_INET;
sin->sin_port = peer_port;
sin->sin_addr.s_addr = *(__be32 *)peer_ip;
} else {
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)
-   &child_ep->com.local_addr;
+   &child_ep->com.mapped_local_addr;
+
sin6->sin6_family = PF_INET6;
sin6->sin6_port = local_port;
memcpy(sin6->sin6_addr.s6_addr, local_ip, 16);
-   sin6 = (struct sockaddr_in6 *)&child_ep->com.remote_addr;
+
+   sin6 = (struct sockaddr_in6 *)&child_ep->com.local_addr;
+   sin6->sin6_family = PF_INET6;
+   sin6->sin6_port = ((struct sockaddr_in6 *)
+  &parent_ep->com.local_addr)->sin6_port;
+   memcpy(sin6->sin6_addr.s6_addr, local_ip, 16);
+
+   sin6 = (struct sockaddr_in6 *)&child_ep->com.mapped_remote_addr;
sin6->sin6_family = PF_INET6;
sin6->sin6_port = peer_port;
memcpy(sin6->sin6_addr.s6_addr, peer_ip, 16);
}
+   memcpy(&child_ep->com.remote_addr, &child_ep->com.mapped_remote_addr,
+  sizeof(child_ep->com.remote_addr));
+   get_remote_addr(child_ep);
+
c4iw_get_ep(&parent_ep->com);
child_ep->parent_ep = parent_ep;
child_ep->tos = PASS_OPEN_TOS_G(ntohl(req->tos_stid));
diff --git a/drivers/infiniband/hw/cxgb4/device.c 
b/drivers/infiniband/hw/cxgb4/device.c
index 8fb295e..db7513d 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -93,6 +93,7 @@ static struct ibnl_client_cbs c4iw_nl_cb_table[] = {
[RDMA_NL_IWPM_ADD_MAPPING] = {.dump = iwpm_add_mapping_cb},
[RDMA_NL_IWPM_QUERY_MAPPING] = {.dump = iwpm_add_and_query_mapping_cb},
[RDMA_NL_IWPM_HANDLE_ERR] = {.dump = iwpm_mapping_error_cb},
+   [RDMA_NL_IWPM_REMOTE_INFO] = {.dump = iwpm_remote_info_cb},
[RDMA_NL_IWPM_MAPINFO] = {.dump = iwpm_mapping_info_cb},
[RDMA_NL_IWPM_MAPI

[PATCH for-4.1 2/3] RDMA/nes: Report the actual address of the remote connecting peer

2015-04-21 Thread Tatyana Nikolova
Get the actual (non-mapped) ip/tcp address of the connecting peer from
the port mapper and report the address info to the user space application
at the time of connection establishment

Signed-off-by: Tatyana Nikolova 
---
 drivers/infiniband/hw/nes/nes.c|1 +
 drivers/infiniband/hw/nes/nes_cm.c |   65 ++-
 2 files changed, 49 insertions(+), 17 deletions(-)

diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
index 3b2a6dc..9f9d5c5 100644
--- a/drivers/infiniband/hw/nes/nes.c
+++ b/drivers/infiniband/hw/nes/nes.c
@@ -116,6 +116,7 @@ static struct ibnl_client_cbs nes_nl_cb_table[] = {
[RDMA_NL_IWPM_REG_PID] = {.dump = iwpm_register_pid_cb},
[RDMA_NL_IWPM_ADD_MAPPING] = {.dump = iwpm_add_mapping_cb},
[RDMA_NL_IWPM_QUERY_MAPPING] = {.dump = iwpm_add_and_query_mapping_cb},
+   [RDMA_NL_IWPM_REMOTE_INFO] = {.dump = iwpm_remote_info_cb},
[RDMA_NL_IWPM_HANDLE_ERR] = {.dump = iwpm_mapping_error_cb},
[RDMA_NL_IWPM_MAPINFO] = {.dump = iwpm_mapping_info_cb},
[RDMA_NL_IWPM_MAPINFO_NUM] = {.dump = iwpm_ack_mapping_info_cb}
diff --git a/drivers/infiniband/hw/nes/nes_cm.c 
b/drivers/infiniband/hw/nes/nes_cm.c
index 6f09a72..72b4341 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -596,27 +596,52 @@ static void nes_form_reg_msg(struct nes_vnic *nesvnic,
memcpy(pm_msg->if_name, nesvnic->netdev->name, IWPM_IFNAME_SIZE);
 }
 
+static void record_sockaddr_info(struct sockaddr_storage *addr_info,
+   nes_addr_t *ip_addr, u16 *port_num)
+{
+   struct sockaddr_in *in_addr = (struct sockaddr_in *)addr_info;
+
+   if (in_addr->sin_family == AF_INET) {
+   *ip_addr = ntohl(in_addr->sin_addr.s_addr);
+   *port_num = ntohs(in_addr->sin_port);
+   }
+}
+
 /*
  * nes_record_pm_msg - Save the received mapping info
  */
 static void nes_record_pm_msg(struct nes_cm_info *cm_info,
struct iwpm_sa_data *pm_msg)
 {
-   struct sockaddr_in *mapped_loc_addr =
-   (struct sockaddr_in *)&pm_msg->mapped_loc_addr;
-   struct sockaddr_in *mapped_rem_addr =
-   (struct sockaddr_in *)&pm_msg->mapped_rem_addr;
-
-   if (mapped_loc_addr->sin_family == AF_INET) {
-   cm_info->mapped_loc_addr =
-   ntohl(mapped_loc_addr->sin_addr.s_addr);
-   cm_info->mapped_loc_port = ntohs(mapped_loc_addr->sin_port);
-   }
-   if (mapped_rem_addr->sin_family == AF_INET) {
-   cm_info->mapped_rem_addr =
-   ntohl(mapped_rem_addr->sin_addr.s_addr);
-   cm_info->mapped_rem_port = ntohs(mapped_rem_addr->sin_port);
-   }
+   record_sockaddr_info(&pm_msg->mapped_loc_addr,
+   &cm_info->mapped_loc_addr, &cm_info->mapped_loc_port);
+
+   record_sockaddr_info(&pm_msg->mapped_rem_addr,
+   &cm_info->mapped_rem_addr, &cm_info->mapped_rem_port);
+}
+
+/*
+ * nes_get_reminfo - Get the address info of the remote connecting peer
+ */
+static int nes_get_remote_addr(struct nes_cm_node *cm_node)
+{
+   struct sockaddr_storage mapped_loc_addr, mapped_rem_addr;
+   struct sockaddr_storage remote_addr;
+   int ret;
+
+   nes_create_sockaddr(htonl(cm_node->mapped_loc_addr),
+   htons(cm_node->mapped_loc_port), &mapped_loc_addr);
+   nes_create_sockaddr(htonl(cm_node->mapped_rem_addr),
+   htons(cm_node->mapped_rem_port), &mapped_rem_addr);
+
+   ret = iwpm_get_remote_info(&mapped_loc_addr, &mapped_rem_addr,
+   &remote_addr, RDMA_NL_NES);
+   if (ret)
+   nes_debug(NES_DBG_CM, "Unable to find remote peer address 
info\n");
+   else
+   record_sockaddr_info(&remote_addr, &cm_node->rem_addr,
+   &cm_node->rem_port);
+   return ret;
 }
 
 /**
@@ -1566,9 +1591,14 @@ static struct nes_cm_node *make_cm_node(struct 
nes_cm_core *cm_core,
return NULL;
 
/* set our node specific transport info */
-   cm_node->loc_addr = cm_info->loc_addr;
+   if (listener) {
+   cm_node->loc_addr = listener->loc_addr;
+   cm_node->loc_port = listener->loc_port;
+   } else {
+   cm_node->loc_addr = cm_info->loc_addr;
+   cm_node->loc_port = cm_info->loc_port;
+   }
cm_node->rem_addr = cm_info->rem_addr;
-   cm_node->loc_port = cm_info->loc_port;
cm_node->rem_port = cm_info->rem_port;
 
cm_node->mapped_loc_addr = cm_info->mapped_loc_addr;
@@ -2151,6 +2181,7 @@ static int handle_ack_pkt(struct nes_cm_node *cm_node, 
struct sk_buff *skb,
cm_node->state = NES_CM_STATE_ESTABLISHED;
if (datasize) {
cm_node->tcp_cntxt.rcv_nxt = inc_sequence + datasize;
+ 

[PATCH for-4.1 1/3] RDMA/core: Enable the iWarp Port Mapper to provide the actual address of the connecting peer to its clients

2015-04-21 Thread Tatyana Nikolova
Add functionality to enable the port mapper on the passive side to provide to 
its
clients the actual (non-mapped) ip/tcp address information of the connecting 
peer

1) Adding remote_info_cb() to process the address info of the connecting peer
   The address info is provided by the user space port mapper service when
   the connection is initiated by the peer
2) Adding a hash list to store the remote address info
3) Adding functionality to add/remove the remote address info
   After the info has been provided to the port mapper client,
   it is removed from the hash list

Signed-off-by: Tatyana Nikolova 
Reviewed-by: Steve Wise 
---
 drivers/infiniband/core/iwpm_msg.c  |   73 -
 drivers/infiniband/core/iwpm_util.c |  208 +--
 drivers/infiniband/core/iwpm_util.h |   15 +++
 include/rdma/iw_portmap.h   |   25 
 include/uapi/rdma/rdma_netlink.h|1 +
 5 files changed, 288 insertions(+), 34 deletions(-)

diff --git a/drivers/infiniband/core/iwpm_msg.c 
b/drivers/infiniband/core/iwpm_msg.c
index b85ddbc..ab08170 100644
--- a/drivers/infiniband/core/iwpm_msg.c
+++ b/drivers/infiniband/core/iwpm_msg.c
@@ -468,7 +468,8 @@ add_mapping_response_exit:
 }
 EXPORT_SYMBOL(iwpm_add_mapping_cb);
 
-/* netlink attribute policy for the response to add and query mapping request 
*/
+/* netlink attribute policy for the response to add and query mapping request
+ * and response with remote address info */
 static const struct nla_policy resp_query_policy[IWPM_NLA_RQUERY_MAPPING_MAX] 
= {
[IWPM_NLA_QUERY_MAPPING_SEQ]  = { .type = NLA_U32 },
[IWPM_NLA_QUERY_LOCAL_ADDR]   = { .len = sizeof(struct 
sockaddr_storage) },
@@ -559,6 +560,76 @@ query_mapping_response_exit:
 }
 EXPORT_SYMBOL(iwpm_add_and_query_mapping_cb);
 
+/*
+ * iwpm_remote_info_cb - Process a port mapper message, containing
+ *   the remote connecting peer address info
+ */
+int iwpm_remote_info_cb(struct sk_buff *skb, struct netlink_callback *cb)
+{
+   struct nlattr *nltb[IWPM_NLA_RQUERY_MAPPING_MAX];
+   struct sockaddr_storage *local_sockaddr, *remote_sockaddr;
+   struct sockaddr_storage *mapped_loc_sockaddr, *mapped_rem_sockaddr;
+   struct iwpm_remote_info *rem_info;
+   const char *msg_type;
+   u8 nl_client;
+   int ret = -EINVAL;
+
+   msg_type = "Remote Mapping info";
+   if (iwpm_parse_nlmsg(cb, IWPM_NLA_RQUERY_MAPPING_MAX,
+   resp_query_policy, nltb, msg_type))
+   return ret;
+
+   nl_client = RDMA_NL_GET_CLIENT(cb->nlh->nlmsg_type);
+   if (!iwpm_valid_client(nl_client)) {
+   pr_info("%s: Invalid port mapper client = %d\n",
+   __func__, nl_client);
+   return ret;
+   }
+   atomic_set(&echo_nlmsg_seq, cb->nlh->nlmsg_seq);
+
+   local_sockaddr = (struct sockaddr_storage *)
+   nla_data(nltb[IWPM_NLA_QUERY_LOCAL_ADDR]);
+   remote_sockaddr = (struct sockaddr_storage *)
+   nla_data(nltb[IWPM_NLA_QUERY_REMOTE_ADDR]);
+   mapped_loc_sockaddr = (struct sockaddr_storage *)
+   nla_data(nltb[IWPM_NLA_RQUERY_MAPPED_LOC_ADDR]);
+   mapped_rem_sockaddr = (struct sockaddr_storage *)
+   nla_data(nltb[IWPM_NLA_RQUERY_MAPPED_REM_ADDR]);
+
+   if (mapped_loc_sockaddr->ss_family != local_sockaddr->ss_family ||
+   mapped_rem_sockaddr->ss_family != remote_sockaddr->ss_family) {
+   pr_info("%s: Sockaddr family doesn't match the requested one\n",
+   __func__);
+   return ret;
+   }
+   rem_info = kzalloc(sizeof(struct iwpm_remote_info), GFP_ATOMIC);
+   if (!rem_info) {
+   pr_err("%s: Unable to allocate a remote info\n", __func__);
+   ret = -ENOMEM;
+   return ret;
+   }
+   memcpy(&rem_info->mapped_loc_sockaddr, mapped_loc_sockaddr,
+  sizeof(struct sockaddr_storage));
+   memcpy(&rem_info->remote_sockaddr, remote_sockaddr,
+  sizeof(struct sockaddr_storage));
+   memcpy(&rem_info->mapped_rem_sockaddr, mapped_rem_sockaddr,
+  sizeof(struct sockaddr_storage));
+   rem_info->nl_client = nl_client;
+
+   iwpm_add_remote_info(rem_info);
+
+   iwpm_print_sockaddr(local_sockaddr,
+   "remote_info: Local sockaddr:");
+   iwpm_print_sockaddr(mapped_loc_sockaddr,
+   "remote_info: Mapped local sockaddr:");
+   iwpm_print_sockaddr(remote_sockaddr,
+   "remote_info: Remote sockaddr:");
+   iwpm_print_sockaddr(mapped_rem_sockaddr,
+   "remote_info: Mapped remote sockaddr:");
+   return ret;
+}
+EXPORT_SYMBOL(iwpm_remote_info_cb);
+
 /* netlink attribute policy for the received request for mapping info */
 static const struct nla_policy resp_mapinfo_policy[IWPM_

[PATCH for-4.1 0/3] Enable the iWarp Port Mapper to provide the actual address of the connecting peer to its clients

2015-04-21 Thread Tatyana Nikolova
This patch series was first submitted for inclusion upstream on 10/13/14,
but it seems to have slipped through the cracks.

When iWARP port mapping is being done, the passive side of a connection only
knows the mapped address/port of the peer. This patch series enables the passive
side port mapper to get the actual (non-mapped) address info of the connecting
peer and provide it to its clients. The port mapper client needs to report the
actual address info to the user space application which isn't aware of the port
mapper service. 

Tatyana Nikolova (2):
  RDMA/core: Add functionality to enable the passive side port mapper to 
provide the
actual (non-mapped) ip/tcp address of the connecting peer to its client
  RDMA/nes: Get the actual (non-mapped) ip/tcp address of the connecting
peer from the port mapper and record it
Steve Wise (1):
  RDMA/cxgb4: Get the actual (non-mapped) ip/tcp address of the connecting
peer from the port mapper and record it

 drivers/infiniband/core/iwpm_msg.c   |   73 -
 drivers/infiniband/core/iwpm_util.c  |  208 --
 drivers/infiniband/core/iwpm_util.h  |   15 +++
 drivers/infiniband/hw/cxgb4/cm.c |   54 -
 drivers/infiniband/hw/cxgb4/device.c |1 +
 drivers/infiniband/hw/nes/nes.c  |1 +
 drivers/infiniband/hw/nes/nes_cm.c   |   65 ---
 include/rdma/iw_portmap.h|   25 
 include/uapi/rdma/rdma_netlink.h |1 +
 9 files changed, 388 insertions(+), 55 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


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

2015-04-21 Thread Doug Ledford
On Wed, 2015-04-22 at 01:44 +0530, Hariprasad Shenai wrote:
> 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(-)
> 

These look better now, thanks.

-- 
Doug Ledford 
  GPG KeyID: 0E572FDD




signature.asc
Description: This is a digitally signed message part


Re: [PATCH v5 00/27] IB/Verbs: IB Management Helpers

2015-04-21 Thread Michael Wang


On 04/21/2015 01:03 PM, Devesh Sharma wrote:
> Hi Michael,
> 
> It will be great help if you could base you patches on existing Roland's tree 
> and share to branch details to pull. 
> Just like Chuck lever does for his nfs-rdma patches?

I've setup a repository in:
https://github.com/ywang-pb/infiniband-wy
git url is:
g...@github.com:ywang-pb/infiniband-wy.git

It's based on latest infiniband/for-next, branch 'mgmt-helpers' contain
this patch set, please let me know if there are any issues :-)

Regards,
Michael Wang

> 
> -Regards
> Devesh
> 
>> -Original Message-
>> From: Michael Wang [mailto:yun.w...@profitbricks.com]
>> Sent: Tuesday, April 21, 2015 1:17 PM
>> To: Devesh Sharma; Roland Dreier; Sean Hefty; Hal Rosenstock; linux-
>> r...@vger.kernel.org; linux-ker...@vger.kernel.org; h...@dev.mellanox.co.il
>> Cc: Tom Tucker; Steve Wise; Hoang-Nam Nguyen; Christoph Raisch; Mike
>> Marciniszyn; Eli Cohen; Faisal Latif; Jack Morgenstein; Or Gerlitz; Haggai 
>> Eran;
>> Ira Weiny; Tom Talpey; Jason Gunthorpe; Doug Ledford
>> Subject: Re: [PATCH v5 00/27] IB/Verbs: IB Management Helpers
>>
>> Hi, Devesh
>>
>> On 04/21/2015 07:41 AM, Devesh Sharma wrote:
>>> Hi Michael,
>>>
>>> is there a specific git branch available to pull out all the patches?
>>
>> Not yet, we may need the maintainer to tell us which branch could the series
>> been applied for testing purpose, after we all satisfied :-)
>>
>> For now we could 'git am' these patches to 'infiniband.git/for-next'
>> in order to do testing.
>>
>> Regards,
>> Michael Wang
>>
>>>
>>> -Regards
>>> Devesh
>>>
 -Original Message-
 From: linux-rdma-ow...@vger.kernel.org [mailto:linux-rdma-
 ow...@vger.kernel.org] On Behalf Of Michael Wang
 Sent: Monday, April 20, 2015 1:59 PM
 To: Roland Dreier; Sean Hefty; Hal Rosenstock;
 linux-rdma@vger.kernel.org; linux-ker...@vger.kernel.org;
 h...@dev.mellanox.co.il
 Cc: Tom Tucker; Steve Wise; Hoang-Nam Nguyen; Christoph Raisch; Mike
 Marciniszyn; Eli Cohen; Faisal Latif; Jack Morgenstein; Or Gerlitz;
 Haggai Eran; Ira Weiny; Tom Talpey; Jason Gunthorpe; Doug Ledford;
 Michael Wang
 Subject: [PATCH v5 00/27] IB/Verbs: IB Management Helpers


 Since v4:
   * Thanks for the comments from Hal, Sean, Tom, Or Gerlitz, Jason,
 Roland, Ira and Steve :-) Please remind me if anything missed :-P
   * Fix logical issue inside 3#, 14#
   * Refine 3#, 4#, 5# with label 'free'
   * Rework 10# to stop using port 1 when port already assigned

 There are plenty of lengthy code to check the transport type of IB
 device, or the link layer type of it's port, but actually we are just
 speculating whether a particular management/feature is supported by the
>> device/port.

 Thus instead of inferring, we should have our own mechanism for IB
 management capability/protocol/feature checking, several proposals below.

 This patch set will reform the method of getting transport type, we
 will now using query_transport() instead of inferring from transport
 and link layer respectively, also we defined the new transport type
 to make the concept more reasonable.

 Mapping List:
node-type   link-layer  old-transport   new-transport
 nesRNICETH IWARP   IWARP
 amso1100   RNICETH IWARP   IWARP
 cxgb3  RNICETH IWARP   IWARP
 cxgb4  RNICETH IWARP   IWARP
 usnic  USNIC_UDP   ETH USNIC_UDP   USNIC_UDP
 ocrdma IB_CA   ETH IB  IBOE
 mlx4   IB_CA   IB/ETH  IB  IB/IBOE
 mlx5   IB_CA   IB  IB  IB
 ehca   IB_CA   IB  IB  IB
 ipath  IB_CA   IB  IB  IB
 mthca  IB_CA   IB  IB  IB
 qibIB_CA   IB  IB  IB

 For example:
if (transport == IB) && (link-layer == ETH) will now become:
if (query_transport() == IBOE)

 Thus we will be able to get rid of the respective transport and
 link-layer checking, and it will help us to add new
 protocol/Technology (like OPA) more easier, also with the introduced
 management helpers, IB management logical will be more clear and easier
>> for extending.

 Highlights:
 The patch set covered a wide range of IB stuff, thus for those who are
 familiar with the particular part, your suggestion would be
 invaluable ;-)

 Patch 1#~15# included all the logical reform, 16#~25# introduced the
 management helpers, 26#~27# do clean up.

 Patches haven't been tested yet, we appreciate if any

Re: [PATCH v2 07/11] IB/cm: Add network namespace support

2015-04-21 Thread Jason Gunthorpe
On Tue, Apr 21, 2015 at 03:07:47PM +0300, Haggai Eran wrote:

> Namespace is needed for RoCE address resolution, in cases where the
> driver doesn't report the MAC as part of the ib_wc.

This patch explicitly says it doesn't deal with RoCE, so why are we
adding namespaces to support RoCE paths in this series? Especially
since we have no idea how that should fit into verbs.

Frankly, that stuff is the most objectionable part of this series.

I suggest:
 1) Focus only on the RDMA-CM, and only on IB support, as the title
says
 2) Drop all changes to verbs and cm and otherwise that are not
directly related to IB
 3) Very, very, strongly justify why the remaining layer violations are
necessary, and think very carefully about doing something else.

For IB, it is very clear to me that only the RDMA-CM can possibly have
the knoweldge to find the namespace, so only the RDMA-CM should be
touching it.

If the interface between the RDMA-CM and IB-CM layers is preventing
something, then extend the interface, don't drop RDMA-CM code into
IB-CM.

>From that point, with working IB, we can revisit what is needed to
make iWarp and RoCE work at the verbs layer and ultimately at the CM
layer, in steps.

Your other questions:

> Using the GID alone is not enough to distinguish between namespaces,
> because you can have multiple IPoIB interfaces, all using the GID (and
> possibly the same P_Key), and each belonging to a different namespace.

Exactly, this is why IB GID layers can't possibly need to touch the net
namespace.

> The listener rbtree's key is currently the service ID, for
> instance. Now with namespaces, you can have multiple listeners
> listening on the same service ID, so we need to use (service ID,
> namespace) as the key.

CM doesn't care, a service ID is registered by RDMA-CM and RDMA-CM can
demux the (service ID,IP) tuple to the right namespace. Having CM
snoop private data is a huge layering violation!

> looks at it's private data and demuxes it to a net namespace.
> I don't see it there. The code seem to fetch the GID from the GRH.
> Because the IP address in the source GID can be the same for different
> namespaces, this is not enough to pick the right namespace.

For IB, ib_init_ah_from_wc does not need a namespace.

For RoCEE, the GID *MUST* be enough to find the namespace because each
namespace will create a unique GID table entry.

RoCEE and IB are going to be totally different in how this
implemented...

I expect RoCEE to have namespace constraints at the verbs QP level,
while IB cannot - that feels like a huge journey...

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


[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 
Signed-off-by: Hariprasad Shenai 
---
 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.le

[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 
Signed-off-by: Hariprasad Shenai 
---
 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 
---
 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 
Signed-off-by: Hariprasad Shenai 
---
 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


Re: [PATCH v2 00/11] Add network namespace support in the RDMA-CM

2015-04-21 Thread Haggai Eran
On 21/04/2015 17:11, Steve Wise wrote:
> On 4/21/2015 1:36 AM, Haggai Eran wrote:
>> On 20/04/2015 17:53, Steve Wise wrote:
>>> Hey Haggai,
>>>
>>> Did you check for changes needed in drivers/infiniband/core/iwcm.c?
>> We focused on namespace support for InfiniBand alone in this series. We
>> didn't handle iWARP, nor did we implement support for RoCE or other
>> transports.
>>
>>> I notice that it uses init_net here:
>>>
>>> static int __init iw_cm_init(void)
>>> {
>>>  iwcm_wq = create_singlethread_workqueue("iw_cm_wq");
>>>  if (!iwcm_wq)
>>>  return -ENOMEM;
>>>
>>>  iwcm_ctl_table_hdr = register_net_sysctl(&init_net,
>>> "net/iw_cm",
>>>   iwcm_ctl_table);
>>>  if (!iwcm_ctl_table_hdr) {
>>>  pr_err("iw_cm: couldn't register sysctl paths\n");
>>>  destroy_workqueue(iwcm_wq);
>>>  return -ENOMEM;
>>>  }
>>>
>>>  return 0;
>>> }
>>>
>> I see the only thing in the iWARP sysctl registered here is the default
>> backlog. If you want to control this parameter per namespace, we could
>> store it per network namespace, and add a namespace parameter to
>> iw_cm_listen. I'm not sure how important this is though.
> 
> I don't think it needs to be per namespace, as long as it still applies
> across all name spaces.

It will, but it will currently only be visible and controllable through
init's namespace.


--
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 v2 00/11] Add network namespace support in the RDMA-CM

2015-04-21 Thread Steve Wise

On 4/21/2015 1:36 AM, Haggai Eran wrote:

On 20/04/2015 17:53, Steve Wise wrote:

Hey Haggai,

Did you check for changes needed in drivers/infiniband/core/iwcm.c?

We focused on namespace support for InfiniBand alone in this series. We
didn't handle iWARP, nor did we implement support for RoCE or other
transports.


I notice that it uses init_net here:

static int __init iw_cm_init(void)
{
 iwcm_wq = create_singlethread_workqueue("iw_cm_wq");
 if (!iwcm_wq)
 return -ENOMEM;

 iwcm_ctl_table_hdr = register_net_sysctl(&init_net, "net/iw_cm",
  iwcm_ctl_table);
 if (!iwcm_ctl_table_hdr) {
 pr_err("iw_cm: couldn't register sysctl paths\n");
 destroy_workqueue(iwcm_wq);
 return -ENOMEM;
 }

 return 0;
}


I see the only thing in the iWARP sysctl registered here is the default
backlog. If you want to control this parameter per namespace, we could
store it per network namespace, and add a namespace parameter to
iw_cm_listen. I'm not sure how important this is though.


I don't think it needs to be per namespace, as long as it still applies 
across all name spaces.


Steve.
--
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 infiniband-diags] vendstat: mad_rpc_close_port not called in corner cases

2015-04-21 Thread Hal Rosenstock
From: Vladimir Koushnir 
Date: Thu, 16 Apr 2015 18:27:39 +0300

Call mad_rpc_close_port in all corner cases.
This is needed so fds are not leaked with ibsim.

Signed-off-by: Vladimir Koushnir 
Signed-off-by: Hal Rosenstock 
---
 src/vendstat.c |   82 
 1 files changed, 53 insertions(+), 29 deletions(-)

diff --git a/src/vendstat.c b/src/vendstat.c
index 11ee73e..baade3e 100644
--- a/src/vendstat.c
+++ b/src/vendstat.c
@@ -172,13 +172,14 @@ static int do_vendor(ib_portid_t *portid, struct 
ibmad_port *srcport,
call.attrid = attr_id;
call.mod = attr_mod;
 
-   if (!ib_vendor_call_via(data, portid, &call, srcport))
-   IBEXIT("vendstat: method %u, attribute %u", method, attr_id);
-
+   if (!ib_vendor_call_via(data, portid, &call, srcport)) {
+   fprintf(stderr,"vendstat: method %u, attribute %u failure\n", 
method, attr_id);
+   return -1;
+   }
return 0;
 }
 
-static void do_config_space_records(ib_portid_t *portid, unsigned set,
+static int do_config_space_records(ib_portid_t *portid, unsigned set,
is3_config_space_t *cs, unsigned records)
 {
unsigned i;
@@ -194,17 +195,19 @@ static void do_config_space_records(ib_portid_t *portid, 
unsigned set,
if (do_vendor(portid, srcport, IB_MLX_VENDOR_CLASS,
  set ? IB_MAD_METHOD_SET : IB_MAD_METHOD_GET,
  IB_MLX_IS3_CONFIG_SPACE_ACCESS, 2 << 22 | records << 16,
- cs))
-   IBEXIT("cannot %s config space records", set ? "set" : "get");
-
+ cs)) {
+   fprintf(stderr,"cannot %s config space records\n", set ? "set" 
: "get");
+   return -1;
+   }
for (i = 0; i < records; i++) {
printf("Config space record at 0x%x: 0x%x\n",
   ntohl(cs->record[i].address),
   ntohl(cs->record[i].data & cs->record[i].mask));
}
+   return 0;
 }
 
-static void counter_groups_info(ib_portid_t * portid, int port)
+static int counter_groups_info(ib_portid_t * portid, int port)
 {
char buf[1024];
is4_counter_group_info_t *cg_info;
@@ -213,15 +216,17 @@ static void counter_groups_info(ib_portid_t * portid, int 
port)
/* Counter Group Info */
memset(&buf, 0, sizeof(buf));
if (do_vendor(portid, srcport, IB_MLX_VENDOR_CLASS, IB_MAD_METHOD_GET,
- IB_MLX_IS4_COUNTER_GROUP_INFO, port, buf))
-   IBEXIT("counter group info query");
-
+ IB_MLX_IS4_COUNTER_GROUP_INFO, port, buf)) {
+   fprintf(stderr,"counter group info query failure\n");
+   return -1;
+   }
cg_info = (is4_counter_group_info_t *) & buf;
num_cg = cg_info->num_of_counter_groups;
printf("counter_group_info:\n");
printf("%d counter groups\n", num_cg);
for (i = 0; i < num_cg; i++)
printf("group%d mask %#x\n", i, ntohl(cg_info->group_masks[i]));
+   return 0;
 }
 
 /* Group0 counter config values */
@@ -236,7 +241,7 @@ static void counter_groups_info(ib_portid_t * portid, int 
port)
 
 static int cg0, cg1;
 
-static void config_counter_groups(ib_portid_t * portid, int port)
+static int config_counter_groups(ib_portid_t * portid, int port)
 {
char buf[1024];
is4_config_counter_groups_t *cg_config;
@@ -251,15 +256,19 @@ static void config_counter_groups(ib_portid_t * portid, 
int port)
cg_config->group_selects[1].group_select = (uint8_t) cg1;
 
if (do_vendor(portid, srcport, IB_MLX_VENDOR_CLASS, IB_MAD_METHOD_SET,
- IB_MLX_IS4_CONFIG_COUNTER_GROUP, port, buf))
-   IBEXIT("config counter group set");
-
+ IB_MLX_IS4_CONFIG_COUNTER_GROUP, port, buf)) {
+   fprintf(stderr, "config counter group set failure\n");
+   return -1;
+   }
/* get config counter groups */
memset(&buf, 0, sizeof(buf));
 
if (do_vendor(portid, srcport, IB_MLX_VENDOR_CLASS, IB_MAD_METHOD_GET,
- IB_MLX_IS4_CONFIG_COUNTER_GROUP, port, buf))
-   IBEXIT("config counter group query");
+ IB_MLX_IS4_CONFIG_COUNTER_GROUP, port, buf)) {
+   fprintf(stderr, "config counter group query failure\n");
+   return -1;
+   }
+   return 0;
 }
 
 static int general_info, xmit_wait, counter_group_info, config_counter_group;
@@ -364,20 +373,26 @@ int main(int argc, char **argv)
 
if (argc) {
if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
-  ibd_dest_type, ibd_sm_id, srcport) < 0)
+  ibd_dest_type, ibd_sm_id, srcport) < 0) {
+   mad_rpc_close_port(srcport);
IBEXIT("can't resolve destinati

[PATCH net] net/mlx4_core: Fix reading HCA max message size in mlx4_QUERY_DEV_CAP

2015-04-21 Thread Or Gerlitz
From: Eran Ben Elisha 

Currently we parse max_msg_sz from the wrong offset in QUERY_DEV_CAP,
fix to use the right offset.

Fixes: 0b131561a7d6 ('net/mlx4_en: Add Flow control statistics [..]')
Signed-off-by: Eran Ben Elisha 
Signed-off-by: Or Gerlitz 
---

Hi Dave, 

Sending this fix early as that innocent bug breaks RoCE applications on SRIOV 
VFs,
since the max message size there gets down to two bytes. No need for -stable 
here
as the bug was introduced in this merge window.

Or.

 drivers/net/ethernet/mellanox/mlx4/fw.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c 
b/drivers/net/ethernet/mellanox/mlx4/fw.c
index b9881fc..a407981 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -781,10 +781,10 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct 
mlx4_dev_cap *dev_cap)
MLX4_GET(field, outbox, QUERY_DEV_CAP_VL_PORT_OFFSET);
dev_cap->num_ports = field & 0xf;
MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_MSG_SZ_OFFSET);
+   dev_cap->max_msg_sz = 1 << (field & 0x1f);
MLX4_GET(field, outbox, QUERY_DEV_CAP_PORT_FLOWSTATS_COUNTERS_OFFSET);
if (field & 0x10)
dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN;
-   dev_cap->max_msg_sz = 1 << (field & 0x1f);
MLX4_GET(field, outbox, QUERY_DEV_CAP_FLOW_STEERING_RANGE_EN_OFFSET);
if (field & 0x80)
dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_FS_EN;
-- 
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 infiniband-diags] dump_fts: Open global file descriptor after calling ibnd_discover_fabric

2015-04-21 Thread Hal Rosenstock
From: Vladimir Koushnir 
Date: Thu, 16 Apr 2015 16:56:40 +0300

Global file descriptor for SMPs should be opened only after running
ibnd_discover_fabric() to avoid parallel usage of two SMP file descriptors

Signed-off-by: Vladimir Koushnir 
Signed-off-by: Hal Rosenstock 
---
 src/dump_fts.c |   30 +++---
 1 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/dump_fts.c b/src/dump_fts.c
index 0de61da..387211f 100644
--- a/src/dump_fts.c
+++ b/src/dump_fts.c
@@ -457,33 +457,41 @@ int main(int argc, char **argv)
if (argc > 1)
endlid = strtoul(argv[1], 0, 0);
 
-   srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
-   if (!srcport)
-   IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
-
node_name_map = open_node_name_map(node_name_map_file);
 
-   smp_mkey_set(srcport, ibd_mkey);
-
-   if (ibd_timeout) {
-   mad_rpc_set_timeout(srcport, ibd_timeout);
+   if (ibd_timeout)
config.timeout_ms = ibd_timeout;
-   }
 
config.flags = ibd_ibnetdisc_flags;
config.mkey = ibd_mkey;
 
if ((fabric = ibnd_discover_fabric(ibd_ca, ibd_ca_port, NULL,
&config)) != NULL) {
+
+   srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 
3);
+   if (!srcport) {
+   fprintf(stderr,
+   "Failed to open '%s' port '%d'\n", ibd_ca, 
ibd_ca_port);
+   rc = -1;
+   goto Exit;
+   }
+   smp_mkey_set(srcport, ibd_mkey);
+
+   if (ibd_timeout) {
+   mad_rpc_set_timeout(srcport, ibd_timeout);
+   }
+
ibnd_iter_nodes_type(fabric, process_switch, IB_NODE_SWITCH, 
fabric);
+
+   mad_rpc_close_port(srcport);
+
} else {
fprintf(stderr, "Failed to discover fabric\n");
rc = -1;
}
-
+Exit:
ibnd_destroy_fabric(fabric);
 
-   mad_rpc_close_port(srcport);
close_node_name_map(node_name_map);
exit(rc);
 }
-- 
1.7.8.2

--
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 infiniband-diags] ibqueryerrors: Close global file descriptor before running ibnd_discover_fabric

2015-04-21 Thread Hal Rosenstock
From: Vladimir Koushnir 
Date: Thu, 16 Apr 2015 16:29:43 +0300

Global file descriptor for SMPs and GMPs should be closed before running
ibnd_discover_fabric() to avoid parallel usage of two SMP file descriptors

Signed-off-by: Vladimir Koushnir 
Signed-off-by: Hal Rosenstock 
---
 src/ibqueryerrors.c |   34 +++---
 1 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/src/ibqueryerrors.c b/src/ibqueryerrors.c
index 9d9ec45..8fbb9d1 100644
--- a/src/ibqueryerrors.c
+++ b/src/ibqueryerrors.c
@@ -973,6 +975,7 @@ int main(int argc, char **argv)
{0}
};
char usage_args[] = "";
+   uint8_t ni[IB_SMP_DATA_SIZE] = { 0 };
 
memset(suppressed_fields, 0, sizeof suppressed_fields);
ibdiag_process_opts(argc, argv, &config, "cDGKLnRrSs", opts, 
process_opt,
@@ -998,14 +1001,21 @@ int main(int argc, char **argv)
config.flags = ibd_ibnetdisc_flags;
config.mkey = ibd_mkey;
 
+   if (!smp_query_via(ni, &portid, IB_ATTR_NODE_INFO, 0,
+  ibd_timeout, ibmad_port)) {
+   mad_rpc_close_port(ibmad_port);
+   IBEXIT("Failed to query local Node Info\n");
+   }
node_name_map = open_node_name_map(node_name_map_file);
 
if (dr_path && load_cache_file) {
+   mad_rpc_close_port(ibmad_port);
fprintf(stderr, "Cannot specify cache and direct route path\n");
exit(-1);
}
 
if (resolve_self(ibd_ca, ibd_ca_port, &self_portid, &port, 
&self_gid.raw) < 0) {
+   mad_rpc_close_port(ibmad_port);
IBEXIT("can't resolve self port %s", argv[0]);
goto close_port;
}
@@ -1028,6 +1038,8 @@ int main(int argc, char **argv)
lid2sl_table[portid.lid] = portid.sl;
}
 
+   mad_rpc_close_port(ibmad_port);
+
if (load_cache_file) {
if ((fabric = ibnd_load_fabric(load_cache_file, 0)) == NULL) {
fprintf(stderr, "loading cached fabric failed\n");
@@ -1064,13 +1076,7 @@ int main(int argc, char **argv)
port_guid_str);
} else if (dr_path) {
ibnd_port_t *port = ibnd_find_port_dr(fabric, dr_path);
-   uint8_t ni[IB_SMP_DATA_SIZE] = { 0 };
 
-   if (!smp_query_via(ni, &portid, IB_ATTR_NODE_INFO, 0,
-  ibd_timeout, ibmad_port)) {
-   rc = -1;
-   goto destroy_fabric;
-   }
mad_decode_field(ni, IB_NODE_PORT_GUID_F, &(port_guid));
 
port = ibnd_find_port_guid(fabric, port_guid);
@@ -1085,7 +1091,22 @@ int main(int argc, char **argv)
if(obtain_sl)
if(path_record_query(self_gid,0))
goto destroy_fabric;
+
+   /* reopen the global ibmad_port */
+   ibmad_port = mad_rpc_open_port(ibd_ca, ibd_ca_port,
+  mgmt_classes, 4);
+   if (!ibmad_port)
+   IBEXIT("Failed to reopen port: %s:%d\n",
+   ibd_ca, ibd_ca_port);
+
+
+   smp_mkey_set(ibmad_port, ibd_mkey);
+
+   if (ibd_timeout)
+   mad_rpc_set_timeout(ibmad_port, ibd_timeout);
+
ibnd_iter_nodes(fabric, print_node, NULL);
+   mad_rpc_close_port(ibmad_port);
}
 
rc = print_summary();
@@ -1096,7 +1117,6 @@ destroy_fabric:
ibnd_destroy_fabric(fabric);
 
 close_port:
-   mad_rpc_close_port(ibmad_port);
close_node_name_map(node_name_map);
exit(rc);
 }
-- 
1.7.8.2

--
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 infiniband-diags] ibqueryerrors: Resource leak in path_record_query

2015-04-21 Thread Hal Rosenstock
From: Vladimir Koushnir 
Date: Thu Apr 16 16:39:43 2015 +0300

sa_free_handle function is not called at the end of
path_record_query function.
The patch fixes file descriptor leak when path_record_query
function is called.

Signed-off-by: Vladimir Koushnir 
Signed-off-by: Hal Rosenstock 
---
 src/ibqueryerrors.c |   34 +++---
 1 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/src/ibqueryerrors.c b/src/ibqueryerrors.c
index 9d9ec45..8fbb9d1 100644
--- a/src/ibqueryerrors.c
+++ b/src/ibqueryerrors.c
@@ -344,6 +344,7 @@ static int path_record_query(ib_gid_t sgid,uint64_t dguid)
 
(uint16_t)IB_SA_ATTR_PATHRECORD,0,cl_ntoh64(comp_mask),ibd_sakey,
 &pr, sizeof(pr), &result);
  if (ret) {
+ sa_free_handle(h);
  fprintf(stderr, "Query SA failed: %s; sa call path_query 
failed\n", strerror(ret));
  return ret;
  }
@@ -355,6 +356,7 @@ static int path_record_query(ib_gid_t sgid,uint64_t dguid)

  insert_lid2sl_table(&result);
 Exit:
+ sa_free_handle(h);
  sa_free_result_mad(&result);
  return ret;
 }
-- 
1.7.8.2

--
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 v2 07/11] IB/cm: Add network namespace support

2015-04-21 Thread Haggai Eran
On 20/04/2015 20:06, Jason Gunthorpe wrote:
> On Mon, Apr 20, 2015 at 12:03:38PM +0300, Haggai Eran wrote:
>> From: Guy Shapiro 
>>
>> Add namespace support to the IB-CM layer.
> 
>> - Each CM-ID now has a network namespace it is associated with, assigned at
>>   creation. This namespace is used as needed during subsequent action on the
>>   CM-ID or related objects.
> 
> There is really something weird about this layering. At the CM layer
> there should be no concept of an IP address, it only deals with GIDs.

Using the GID alone is not enough to distinguish between namespaces,
because you can have multiple IPoIB interfaces, all using the GID (and
possibly the same P_Key), and each belonging to a different namespace.

> So how can a CM object have a network namespace associated with it?

The listener rbtree's key is currently the service ID, for instance. Now
with namespaces, you can have multiple listeners listening on the same
service ID, so we need to use (service ID, namespace) as the key.

> 
>>  {
>>  av->port = port;
>>  av->pkey_index = wc->pkey_index;
>>  ib_init_ah_from_wc(port->cm_dev->ib_device, port->port_num, wc,
>> -   grh, &av->ah_attr, &init_net);
>> +   grh, &av->ah_attr, net);
> 
> There is something deeply wrong with adding network namespace
> arguments to verbs.
> 
> For rocee the gid index clearly specifies the network namespace
> to use, so much of this should go away and have rocee get the
> namespace from the gid index.
> 
> Ie in ib_init_ah_from_wc we have the ib_wc which contains the sgid
> index.

I don't see it there. The code seem to fetch the GID from the GRH.
Because the IP address in the source GID can be the same for different
namespaces, this is not enough to pick the right namespace.

Regards,
Haggai
--
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 00/27] IB/Verbs: IB Management Helpers

2015-04-21 Thread Devesh Sharma
Hi Michael,

It will be great help if you could base you patches on existing Roland's tree 
and share to branch details to pull. 
Just like Chuck lever does for his nfs-rdma patches?

-Regards
Devesh

> -Original Message-
> From: Michael Wang [mailto:yun.w...@profitbricks.com]
> Sent: Tuesday, April 21, 2015 1:17 PM
> To: Devesh Sharma; Roland Dreier; Sean Hefty; Hal Rosenstock; linux-
> r...@vger.kernel.org; linux-ker...@vger.kernel.org; h...@dev.mellanox.co.il
> Cc: Tom Tucker; Steve Wise; Hoang-Nam Nguyen; Christoph Raisch; Mike
> Marciniszyn; Eli Cohen; Faisal Latif; Jack Morgenstein; Or Gerlitz; Haggai 
> Eran;
> Ira Weiny; Tom Talpey; Jason Gunthorpe; Doug Ledford
> Subject: Re: [PATCH v5 00/27] IB/Verbs: IB Management Helpers
> 
> Hi, Devesh
> 
> On 04/21/2015 07:41 AM, Devesh Sharma wrote:
> > Hi Michael,
> >
> > is there a specific git branch available to pull out all the patches?
> 
> Not yet, we may need the maintainer to tell us which branch could the series
> been applied for testing purpose, after we all satisfied :-)
> 
> For now we could 'git am' these patches to 'infiniband.git/for-next'
> in order to do testing.
> 
> Regards,
> Michael Wang
> 
> >
> > -Regards
> > Devesh
> >
> >> -Original Message-
> >> From: linux-rdma-ow...@vger.kernel.org [mailto:linux-rdma-
> >> ow...@vger.kernel.org] On Behalf Of Michael Wang
> >> Sent: Monday, April 20, 2015 1:59 PM
> >> To: Roland Dreier; Sean Hefty; Hal Rosenstock;
> >> linux-rdma@vger.kernel.org; linux-ker...@vger.kernel.org;
> >> h...@dev.mellanox.co.il
> >> Cc: Tom Tucker; Steve Wise; Hoang-Nam Nguyen; Christoph Raisch; Mike
> >> Marciniszyn; Eli Cohen; Faisal Latif; Jack Morgenstein; Or Gerlitz;
> >> Haggai Eran; Ira Weiny; Tom Talpey; Jason Gunthorpe; Doug Ledford;
> >> Michael Wang
> >> Subject: [PATCH v5 00/27] IB/Verbs: IB Management Helpers
> >>
> >>
> >> Since v4:
> >>   * Thanks for the comments from Hal, Sean, Tom, Or Gerlitz, Jason,
> >> Roland, Ira and Steve :-) Please remind me if anything missed :-P
> >>   * Fix logical issue inside 3#, 14#
> >>   * Refine 3#, 4#, 5# with label 'free'
> >>   * Rework 10# to stop using port 1 when port already assigned
> >>
> >> There are plenty of lengthy code to check the transport type of IB
> >> device, or the link layer type of it's port, but actually we are just
> >> speculating whether a particular management/feature is supported by the
> device/port.
> >>
> >> Thus instead of inferring, we should have our own mechanism for IB
> >> management capability/protocol/feature checking, several proposals below.
> >>
> >> This patch set will reform the method of getting transport type, we
> >> will now using query_transport() instead of inferring from transport
> >> and link layer respectively, also we defined the new transport type
> >> to make the concept more reasonable.
> >>
> >> Mapping List:
> >>node-type   link-layer  old-transport   new-transport
> >> nesRNICETH IWARP   IWARP
> >> amso1100   RNICETH IWARP   IWARP
> >> cxgb3  RNICETH IWARP   IWARP
> >> cxgb4  RNICETH IWARP   IWARP
> >> usnic  USNIC_UDP   ETH USNIC_UDP   USNIC_UDP
> >> ocrdma IB_CA   ETH IB  IBOE
> >> mlx4   IB_CA   IB/ETH  IB  IB/IBOE
> >> mlx5   IB_CA   IB  IB  IB
> >> ehca   IB_CA   IB  IB  IB
> >> ipath  IB_CA   IB  IB  IB
> >> mthca  IB_CA   IB  IB  IB
> >> qibIB_CA   IB  IB  IB
> >>
> >> For example:
> >>if (transport == IB) && (link-layer == ETH) will now become:
> >>if (query_transport() == IBOE)
> >>
> >> Thus we will be able to get rid of the respective transport and
> >> link-layer checking, and it will help us to add new
> >> protocol/Technology (like OPA) more easier, also with the introduced
> >> management helpers, IB management logical will be more clear and easier
> for extending.
> >>
> >> Highlights:
> >> The patch set covered a wide range of IB stuff, thus for those who are
> >> familiar with the particular part, your suggestion would be
> >> invaluable ;-)
> >>
> >> Patch 1#~15# included all the logical reform, 16#~25# introduced the
> >> management helpers, 26#~27# do clean up.
> >>
> >> Patches haven't been tested yet, we appreciate if any one who have 
> >> these
> >> HW willing to provide his Tested-by :-)
> >>
> >> Doug suggested the bitmask mechanism:
> >>https://www.mail-archive.com/linux-
> >> r...@vger.kernel.org/msg23765.html
> >> which could be the plan for future reforming, we prefer that to be
> another
> >> series which focus on semantic and performance.
> >>
> >> This patch-set is s

Re: [PATCH v2 02/11] IB/addr: Pass network namespace as a parameter

2015-04-21 Thread Haggai Eran
On 21/04/2015 01:05, Doug Ledford wrote:
> On Mon, 2015-04-20 at 12:03 +0300, Haggai Eran wrote:
>> From: Guy Shapiro 
>>
>> Add network namespace support to the ib_addr module. For that, all the 
>> address
>> resolution and matching should be done using the appropriate namespace 
>> instead
>> of init_net.
>>
>> This is achieved by:
>>
>> 1. Adding an explicit network namespace argument to exported function that
>>require a namespace.
>> 2. Saving the namespace in the rdma_addr_client structure.
>> 3. Using it when calling networking functions.
>>
>> In order to preserve the behavior of calling modules, &init_net is
>> passed as the parameter in calls from other modules. This is modified as
>> namespace support is added on more levels.
>>
>> Signed-off-by: Haggai Eran 
>> Signed-off-by: Yotam Kenneth 
>> Signed-off-by: Shachar Raindel 
>> Signed-off-by: Guy Shapiro 
>> ---
>>  drivers/infiniband/core/addr.c   | 31 --
>>  drivers/infiniband/core/cma.c|  4 ++-
>>  drivers/infiniband/core/verbs.c  | 14 +++---
>>  drivers/infiniband/hw/ocrdma/ocrdma_ah.c |  3 ++-
>>  include/rdma/ib_addr.h   | 44 
>> 
>>  5 files changed, 72 insertions(+), 24 deletions(-)
>>
>> diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
>> index f80da50d84a5..95beaef6b66d 100644
>> --- a/drivers/infiniband/core/addr.c
>> +++ b/drivers/infiniband/core/addr.c
>> @@ -128,7 +128,7 @@ int rdma_translate_ip(struct sockaddr *addr, struct 
>> rdma_dev_addr *dev_addr,
>>  int ret = -EADDRNOTAVAIL;
>>  
>>  if (dev_addr->bound_dev_if) {
>> -dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
>> +dev = dev_get_by_index(dev_addr->net, dev_addr->bound_dev_if);
>>  if (!dev)
>>  return -ENODEV;
>>  ret = rdma_copy_addr(dev_addr, dev, NULL);
>> @@ -137,9 +137,10 @@ int rdma_translate_ip(struct sockaddr *addr, struct 
>> rdma_dev_addr *dev_addr,
>>  }
>>  
>>  switch (addr->sa_family) {
>> -case AF_INET:
>> -dev = ip_dev_find(&init_net,
>> -((struct sockaddr_in *) addr)->sin_addr.s_addr);
>> +case AF_INET: {
>^ Please don't add brackets just so you can
> convert a cast into a variable declaration that's unnecessary
> 
>> +struct sockaddr_in *addr_in = (struct sockaddr_in *)addr;
>> +
>> +dev = ip_dev_find(dev_addr->net, addr_in->sin_addr.s_addr);
>>  
>>  if (!dev)
>>  return ret;
>> @@ -149,12 +150,12 @@ int rdma_translate_ip(struct sockaddr *addr, struct 
>> rdma_dev_addr *dev_addr,
>>  *vlan_id = rdma_vlan_dev_vlan_id(dev);
>>  dev_put(dev);
>>  break;
>> -
>> +}
>>  #if IS_ENABLED(CONFIG_IPV6)
>>  case AF_INET6:
>>  rcu_read_lock();
>> -for_each_netdev_rcu(&init_net, dev) {
>> -if (ipv6_chk_addr(&init_net,
>> +for_each_netdev_rcu(dev_addr->net, dev) {
>> +if (ipv6_chk_addr(dev_addr->net,
>>&((struct sockaddr_in6 *) 
>> addr)->sin6_addr,
>>dev, 1)) {
>>  ret = rdma_copy_addr(dev_addr, dev, NULL);
>> @@ -236,7 +237,7 @@ static int addr4_resolve(struct sockaddr_in *src_in,
>>  fl4.daddr = dst_ip;
>>  fl4.saddr = src_ip;
>>  fl4.flowi4_oif = addr->bound_dev_if;
>> -rt = ip_route_output_key(&init_net, &fl4);
>> +rt = ip_route_output_key(addr->net, &fl4);
>>  if (IS_ERR(rt)) {
>>  ret = PTR_ERR(rt);
>>  goto out;
>> @@ -278,12 +279,13 @@ static int addr6_resolve(struct sockaddr_in6 *src_in,
>>  fl6.saddr = src_in->sin6_addr;
>>  fl6.flowi6_oif = addr->bound_dev_if;
>>  
>> -dst = ip6_route_output(&init_net, NULL, &fl6);
>> +dst = ip6_route_output(addr->net, NULL, &fl6);
>>  if ((ret = dst->error))
>>  goto put;
>>  
>>  if (ipv6_addr_any(&fl6.saddr)) {
>> -ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
>> +ret = ipv6_dev_get_saddr(addr->net,
>> + ip6_dst_idev(dst)->dev,
>>   &fl6.daddr, 0, &fl6.saddr);
>>  if (ret)
>>  goto put;
>> @@ -458,7 +460,7 @@ static void resolve_cb(int status, struct sockaddr 
>> *src_addr,
>>  }
>>  
>>  int rdma_addr_find_dmac_by_grh(union ib_gid *sgid, union ib_gid *dgid, u8 
>> *dmac,
>> -   u16 *vlan_id)
>> +   u16 *vlan_id, struct net *net)
> 
> In the core networking code, the net namespace is always first.  Please
> stick with that paradigm.
> 

I'll fix these comments in the next revision.

Thanks,
Haggai

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
th

Re: [PATCH v2 02/11] IB/addr: Pass network namespace as a parameter

2015-04-21 Thread Haggai Eran
On 20/04/2015 20:09, Jason Gunthorpe wrote:
> On Mon, Apr 20, 2015 at 12:03:33PM +0300, Haggai Eran wrote:
>> +/** rdma_addr_find_smac_by_sgid() - Find the src MAC and VLAN ID for a src 
>> GID
>> + * @sgid:   Source GID to find the MAC and VLAN for.
>> + * @smac:   A buffer to contain the resulting MAC address.
>> + * @vlan_id:Will contain the resulting VLAN ID.
>> + * @net:Network namespace to use for the address resolution.
>> + *
>> + * It is the caller's responsibility to keep the network namespace alive 
>> until
>> + * the function returns.
>> + */
>> +int rdma_addr_find_smac_by_sgid(union ib_gid *sgid, u8 *smac, u16 *vlan_id,
>> +struct net *net);
> 
> kdocs are typically placed with the body of the function, not at the
> prototype.

I'll move it in the next revision. We did that because other functions
(rdma_translate_ip, rdma_resolve_ip) are documented inside ib_addr.h
this way.

Haggai
--
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 v2 01/11] RDMA/CMA: Mark IPv4 addresses correctly when the listener is IPv6

2015-04-21 Thread Haggai Eran
On 20/04/2015 23:01, Jason Gunthorpe wrote:
> On Mon, Apr 20, 2015 at 09:38:02PM +0300, Or Gerlitz wrote:
>> On Mon, Apr 20, 2015 at 7:41 PM, Jason Gunthorpe
>>  wrote:
>>> On Mon, Apr 20, 2015 at 12:03:32PM +0300, Haggai Eran wrote:
 From: Yotam Kenneth 

 When accepting a new connection with the listener being IPv6, the
 family of the new connection is set as IPv6. This causes cma_zero_addr
 function to return true on an non-zero address. As a result, the wrong
 code path is taken. This causes the connection request to be rejected,
 as the RDMA-CM code looks for the wrong type of device.
>>>
>>> This description doesn't really make sense as to what the problem is.
> 
>> Jason, could you take a look @ this thread
>> http://marc.info/?t=14158939504&r=1&w=2 where the authors
>> addressed some comments from Sean and he eventually Acked the patch?
> 
> Please actually read my comments:
> 
>  If listen_id->route.addr.src_addr.ss_family != AF_INET then it is
>  invalid to cast to sockaddr_in.

That's correct. We didn't address it because it was part of the existing
code. Anyway, in a later patch in this series we move this code from the
CMA to the CM module. Then we get the port number from the service ID
instead of from the listener ID, since the listener ID's port isn't
available.

> 
> Sean asked basically the same thing, and his question was ignored too.
> 
> This should take care of it, testing, and figuring the fixes tag is
> left as an exercise to the reader..
> 

Fixes: e51060f08a61 ("IB: IP address based RDMA connection manager")
Tested-by: Haggai Eran 

Haggai
--
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 14/27] IB/Verbs: Reform cma_acquire_dev()

2015-04-21 Thread Michael Wang


On 04/21/2015 08:15 AM, Devesh Sharma wrote:
> Looks good, I would like to test with ocrdma before confirming.

That's great :-) Any testing would be really helpful, please let
us know if there is some thing broken.

Regards,
Michael Wang

> 
>> -Original Message-
>> From: linux-rdma-ow...@vger.kernel.org [mailto:linux-rdma-
>> ow...@vger.kernel.org] On Behalf Of Michael Wang
>> Sent: Monday, April 20, 2015 2:08 PM
>> To: Roland Dreier; Sean Hefty; linux-rdma@vger.kernel.org; linux-
>> ker...@vger.kernel.org; h...@dev.mellanox.co.il
>> Cc: Michael Wang; Tom Tucker; Steve Wise; Hoang-Nam Nguyen; Christoph
>> Raisch; Mike Marciniszyn; Eli Cohen; Faisal Latif; Jack Morgenstein; Or 
>> Gerlitz;
>> Haggai Eran; Ira Weiny; Tom Talpey; Jason Gunthorpe; Doug Ledford
>> Subject: [PATCH v5 14/27] IB/Verbs: Reform cma_acquire_dev()
>>
>>
>> Reform cma_acquire_dev() with management helpers, introduce
>> cma_validate_port() to make the code more clean.
>>
>> Cc: Hal Rosenstock 
>> Cc: Steve Wise 
>> Cc: Tom Talpey 
>> Cc: Jason Gunthorpe 
>> Cc: Doug Ledford 
>> Cc: Ira Weiny 
>> Cc: Sean Hefty 
>> Signed-off-by: Michael Wang 
>> ---
>>  drivers/infiniband/core/cma.c | 68 +
>> --
>>  1 file changed, 40 insertions(+), 28 deletions(-)
>>
>> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
>> index 6195bf6..44e7bb9 100644
>> --- a/drivers/infiniband/core/cma.c
>> +++ b/drivers/infiniband/core/cma.c
>> @@ -370,18 +370,35 @@ static int cma_translate_addr(struct sockaddr *addr,
>> struct rdma_dev_addr *dev_a
>>  return ret;
>>  }
>>
>> +static inline int cma_validate_port(struct ib_device *device, u8 port,
>> +  union ib_gid *gid, int dev_type) {
>> +u8 found_port;
>> +int ret = -ENODEV;
>> +
>> +if ((dev_type == ARPHRD_INFINIBAND) && !rdma_tech_ib(device,
>> port))
>> +return ret;
>> +
>> +if ((dev_type != ARPHRD_INFINIBAND) && rdma_tech_ib(device, port))
>> +return ret;
>> +
>> +ret = ib_find_cached_gid(device, gid, &found_port, NULL);
>> +if (port != found_port)
>> +return -ENODEV;
>> +
>> +return ret;
>> +}
>> +
>>  static int cma_acquire_dev(struct rdma_id_private *id_priv,
>> struct rdma_id_private *listen_id_priv)  {
>>  struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
>>  struct cma_device *cma_dev;
>> -union ib_gid gid, iboe_gid;
>> +union ib_gid gid, iboe_gid, *gidp;
>>  int ret = -ENODEV;
>> -u8 port, found_port;
>> -enum rdma_link_layer dev_ll = dev_addr->dev_type ==
>> ARPHRD_INFINIBAND ?
>> -IB_LINK_LAYER_INFINIBAND : IB_LINK_LAYER_ETHERNET;
>> +u8 port;
>>
>> -if (dev_ll != IB_LINK_LAYER_INFINIBAND &&
>> +if (dev_addr->dev_type != ARPHRD_INFINIBAND &&
>>  id_priv->id.ps == RDMA_PS_IPOIB)
>>  return -EINVAL;
>>
>> @@ -391,41 +408,36 @@ static int cma_acquire_dev(struct rdma_id_private
>> *id_priv,
>>
>>  memcpy(&gid, dev_addr->src_dev_addr +
>> rdma_addr_gid_offset(dev_addr), sizeof gid);
>> -if (listen_id_priv &&
>> -rdma_port_get_link_layer(listen_id_priv->id.device,
>> - listen_id_priv->id.port_num) == dev_ll) {
>> +
>> +if (listen_id_priv) {
>>  cma_dev = listen_id_priv->cma_dev;
>>  port = listen_id_priv->id.port_num;
>> -if (rdma_node_get_transport(cma_dev->device->node_type)
>> == RDMA_TRANSPORT_IB &&
>> -rdma_port_get_link_layer(cma_dev->device, port) ==
>> IB_LINK_LAYER_ETHERNET)
>> -ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
>> - &found_port, NULL);
>> -else
>> -ret = ib_find_cached_gid(cma_dev->device, &gid,
>> - &found_port, NULL);
>> +gidp = rdma_tech_iboe(cma_dev->device, port) ?
>> +   &iboe_gid : &gid;
>>
>> -if (!ret && (port  == found_port)) {
>> -id_priv->id.port_num = found_port;
>> +ret = cma_validate_port(cma_dev->device, port, gidp,
>> +dev_addr->dev_type);
>> +if (!ret) {
>> +id_priv->id.port_num = port;
>>  goto out;
>>  }
>>  }
>> +
>>  list_for_each_entry(cma_dev, &dev_list, list) {
>>  for (port = 1; port <= cma_dev->device->phys_port_cnt; ++port)
>> {
>>  if (listen_id_priv &&
>>  listen_id_priv->cma_dev == cma_dev &&
>>  listen_id_priv->id.port_num == port)
>>  continue;
>> -if (rdma_port_get_link_layer(cma_dev->device, port)
>> == dev_ll) {
>> -if (rdma_node_get_transport(cma_dev-
>>> device->node_type) ==

Re: [PATCH v5 13/27] IB/Verbs: Reserve legacy transport type in 'dev_addr'

2015-04-21 Thread Michael Wang
On 04/21/2015 07:58 AM, Devesh Sharma wrote:
[snip]
>>
>> diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
>> index ebac646..6195bf6 100644
>> --- a/drivers/infiniband/core/cma.c
>> +++ b/drivers/infiniband/core/cma.c
>> @@ -244,14 +244,35 @@ static inline void cma_set_ip_ver(struct cma_hdr
>> *hdr, u8 ip_ver)
>>  hdr->ip_version = (ip_ver << 4) | (hdr->ip_version & 0xF);  }
>>
>> +static inline void cma_set_legacy_transport(struct rdma_cm_id *id) {
>> +switch (id->device->node_type) {
>> +case RDMA_NODE_IB_CA:
>> +case RDMA_NODE_IB_SWITCH:
>> +case RDMA_NODE_IB_ROUTER:
>> +id->route.addr.dev_addr.transport = RDMA_TRANSPORT_IB;
> 
> What about IBOE transport, am I missing something here? As of today ocrdma 
> exports node_type  as RDMA_NODE_IB_CA, here transport will be set to 
> RDMA_TRANSPORT_IB,
> Should it be RDMA_TRANPORT_IBOE?

This part is actually just the old method we used to get transport type, I'm
not sure about the usage of this 'transport' so reserve the old way for it :-P

Actually I can't locate the place using this stuff in core layer, thus I guess 
it
may be used by user layer or the protocol, as long as these layer using the old
logical, we better don't touch anything ;-)

Regards,
Michael Wang

> 
>> +break;
>> +case RDMA_NODE_RNIC:
>> +id->route.addr.dev_addr.transport =
>> RDMA_TRANSPORT_IWARP;
>> +break;
>> +case RDMA_NODE_USNIC:
>> +id->route.addr.dev_addr.transport =
>> RDMA_TRANSPORT_USNIC;
>> +break;
>> +case RDMA_NODE_USNIC_UDP:
>> +id->route.addr.dev_addr.transport =
>> RDMA_TRANSPORT_USNIC_UDP;
>> +break;
>> +default:
>> +BUG();
>> +}
>> +}
>> +
>>  static void cma_attach_to_dev(struct rdma_id_private *id_priv,
>>struct cma_device *cma_dev)
>>  {
>>  atomic_inc(&cma_dev->refcount);
>>  id_priv->cma_dev = cma_dev;
>>  id_priv->id.device = cma_dev->device;
>> -id_priv->id.route.addr.dev_addr.transport =
>> -rdma_node_get_transport(cma_dev->device->node_type);
>> +cma_set_legacy_transport(&id_priv->id);
>>  list_add_tail(&id_priv->list, &cma_dev->id_list);  }
>>
>> --
>> 2.1.0
>> --
>> 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 04/27] IB/Verbs: Reform IB-core cm

2015-04-21 Thread Michael Wang


On 04/20/2015 07:04 PM, Hal Rosenstock wrote:
> On 4/20/2015 4:33 AM, Michael Wang wrote:
>>
>> Use raw management helpers to reform IB-core cm.
>>
>> Cc: Hal Rosenstock 
>> Cc: Steve Wise 
>> Cc: Tom Talpey 
>> Cc: Jason Gunthorpe 
>> Cc: Doug Ledford 
>> Cc: Ira Weiny 
>> Cc: Sean Hefty 
>> Signed-off-by: Michael Wang 
>> ---
>>  drivers/infiniband/core/cm.c | 20 +---
>>  1 file changed, 17 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
>> index e28a494..3c10b75 100644
>> --- a/drivers/infiniband/core/cm.c
>> +++ b/drivers/infiniband/core/cm.c
>> @@ -3761,9 +3761,7 @@ static void cm_add_one(struct ib_device *ib_device)
>>  unsigned long flags;
>>  int ret;
>>  u8 i;
>> -
>> -if (rdma_node_get_transport(ib_device->node_type) != RDMA_TRANSPORT_IB)
>> -return;
>> +int count = 0;
> 
> Nit: Should the int count line be moved above u8 i declaration so
> declarations are naturally aligned ?

Make sense, will be in next version :-)

Regards,
Michael Wang

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