Re: [PATCH V2 1/9] net/mlx5: Mellanox Connect-IB, core driver part 1/3

2013-07-04 Thread Jack Morgenstein
On Thursday 04 July 2013 17:17, Joe Perches wrote:
> Not the vertical spacing, the newline inside the quotes.
> ie: "unknown status code\n" should be "unknown status code"
> 
You're right!  I misunderstood, and did not notice the newline char.
Good catch!

While I was at it, though, I eliminated the blank lines between
the cases/default -- fewer lines in the file, and readable enough
this way.

Thanks!
-Jack
--
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 1/9] net/mlx5: Mellanox Connect-IB, core driver part 1/3

2013-07-04 Thread Joe Perches
On Thu, 2013-07-04 at 16:26 +0300, Jack Morgenstein wrote:
> On Wednesday 03 July 2013 23:29, Joe Perches wrote:
> > On Wed, 2013-07-03 at 20:13 +0300, Or Gerlitz wrote:
> > > From: Eli Cohen 
> > 
> > trivial comments:
> > 
> > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c 
> > > b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
> > []
> > > +static const char *deliv_status_to_str(u8 status)
> > > +{
> > > + switch (status) {
> > > + case MLX5_CMD_DELIVERY_STAT_OK:
> > > + return "no errors";
> > []
> > > + default:
> > > + return "unknown status code\n";
> > > + }
> > > +}
> > Likely unnecessary newline for default case
> All the cases here have newlines between them, to enhance readability.
> (not just the default). If you feel strongly about this, I'll do the change
> for V3.

Not the vertical spacing, the newline inside the quotes.
ie: "unknown status code\n" should be "unknown status code"


--
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 5/9] IB/mlx5: Mellanox Connect-IB, IB driver part 1/5

2013-07-04 Thread Jack Morgenstein
On Thursday 04 July 2013 16:15, Jack Morgenstein wrote:
> > > +   *inlen = sizeof **cqb + sizeof *(*cqb)->pas * ncont;
> > 
> > sizeof always uses parentheses
> 
I'll fix this, too.

-Jack
--
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 7/9] IB/mlx5: Mellanox Connect-IB, IB driver part 3/5

2013-07-04 Thread Jack Morgenstein
On Thursday 04 July 2013 00:10, Joe Perches wrote:
> On Wed, 2013-07-03 at 20:13 +0300, Or Gerlitz wrote:
> > From: Eli Cohen 
> 
> More trivia:
> 
> > diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h 
> > b/drivers/infiniband/hw/mlx5/mlx5_ib.h
> []
> > +#define mlx5_ib_dbg(dev, format, arg...)   \
> > +do {   
> > \
> > +   pr_debug("%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name,  \
> > +__func__, __LINE__, current->pid, ##arg);  \
> > +} while (0)
> 
> unnecessary do {} while (0)

In this case, you are correct. The pr_debug macro itself does this internally
where needed -- not surprising, since pr_debug must also be usable for code 
like:
if (foo)
pr_debug(...).
I'll remove the do-while in V3.

> > +static void clean_keys(struct mlx5_ib_dev *dev, int c)
> > +{
> > +   struct device *ddev = dev->ib_dev.dma_device;
> > +   struct mlx5_mr_cache *cache = &dev->cache;
> > +   struct mlx5_cache_ent *ent = &cache->ent[c];
> > +   struct mlx5_ib_mr *mr;
> > +   int size;
> > +   int err;
> > +
> > +   while (1) {
> > +   spin_lock(&ent->lock);
> > +   if (list_empty(&ent->head)) {
> > +   spin_unlock(&ent->lock);
> > +   return;
> > +   }
> > +   mr = list_first_entry(&ent->head, struct mlx5_ib_mr, list);
> > +   list_del(&mr->list);
> > +   ent->cur--;
> > +   ent->size--;
> > +   spin_unlock(&ent->lock);
> > +   err = mlx5_core_destroy_mkey(&dev->mdev, &mr->mmr);
> > +   if (err) {
> > +   mlx5_ib_warn(dev, "failed destroy mkey\n");
> 
> Are you leaking anything here by not freeing?
Actually, if the mkey-destroy fails, it is extremely risky to free
the memory resources it uses.  A tiny memory leak (in such a rare case)
is far preferable to a kernel crash.

> 
> > +   } else {
> > +   size = ALIGN(sizeof(u64) * (1 << mr->order), 0x40);
> > +   dma_unmap_single(ddev, mr->dma, size, DMA_TO_DEVICE);
> > +   kfree(mr->pas);
> > +   kfree(mr);
> > +   }
> > +   };
> > +}
> 
> > +static struct mlx5_ib_mr *reg_create(struct ib_pd *pd, u64 virt_addr,
> > +u64 length, struct ib_umem *umem,
> > +int npages, int page_shift,
> > +int access_flags)
> > +{
> []
> > +   mr = kzalloc(sizeof(*mr), GFP_KERNEL);
> > +   if (!mr) {
> > +   mlx5_ib_warn(dev, "allocation failed\n");
> 
> Another unnecessary OOM

Will remove for V3 

> > +   mr = ERR_PTR(-ENOMEM);
> > +   }
> > +
> > +   inlen = sizeof(*in) + sizeof(*in->pas) * ((npages + 1) / 2) * 2;
> > +   in = vzalloc(inlen);
> > +   if (!in) {
> > +   mlx5_ib_warn(dev, "alloc failed\n");
> 
> here too.

Will remove for V3 

> > +   err = -ENOMEM;
> > +   goto err_1;
> > +   }
> 
Thanks again for the review!

-Jack 
--
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 1/9] net/mlx5: Mellanox Connect-IB, core driver part 1/3

2013-07-04 Thread Jack Morgenstein
On Wednesday 03 July 2013 23:29, Joe Perches wrote:
> On Wed, 2013-07-03 at 20:13 +0300, Or Gerlitz wrote:
> > From: Eli Cohen 
> 
> trivial comments:
> 
> > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c 
> > b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
> []
> > +static const char *deliv_status_to_str(u8 status)
> > +{
> > +   switch (status) {
> > +   case MLX5_CMD_DELIVERY_STAT_OK:
> > +   return "no errors";
> []
> > +   default:
> > +   return "unknown status code\n";
> > +   }
> > +}
> Likely unnecessary newline for default case
All the cases here have newlines between them, to enhance readability.
(not just the default). If you feel strongly about this, I'll do the change
for V3.

> > +static struct mlx5_cmd_mailbox *alloc_cmd_box(struct mlx5_core_dev *dev,
> > + gfp_t flags)
> > +{
> > +   struct mlx5_cmd_mailbox *mailbox;
> > +
> > +   mailbox = kmalloc(sizeof(*mailbox), flags);
> > +   if (!mailbox) {
> > +   mlx5_core_dbg(dev, "failed allocation\n");
> > +   return ERR_PTR(-ENOMEM);
> > +   }
> 
> unnecessary OOM message.

Will remove these kmalloc failure printouts in V3
> 
> > +static void set_wqname(struct mlx5_core_dev *dev)
> > +{
> > +   struct mlx5_cmd *cmd = &dev->cmd;
> > +
> > +   strcpy(cmd->wq_name, "mlx5_cmd_");
> > +   strcat(cmd->wq_name, dev_name(&dev->pdev->dev));
> 
> More likely snprintf might be better.
> 
>   snprintf(cmd->wq_name, sizeof(cmd->wq_name), "mlx5_cmd_%s",
>dev_name(&dev->pdev->dev));
> 
Will change this for V3
> How big is wq_name?
32 bytes. Should be enough to hold dev names. However, to be on the safe side
I'll do the change.

-Jack
--
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 5/9] IB/mlx5: Mellanox Connect-IB, IB driver part 1/5

2013-07-04 Thread Jack Morgenstein
On Wednesday 03 July 2013 23:59, Joe Perches wrote:
> On Wed, 2013-07-03 at 20:13 +0300, Or Gerlitz wrote:
> > From: Eli Cohen 
> > diff --git a/drivers/infiniband/hw/mlx5/ah.c 
> > b/drivers/infiniband/hw/mlx5/ah.c
> []
> > +struct ib_ah *create_ib_ah(struct ib_ah_attr *ah_attr,
> > +  struct mlx5_ib_ah *ah)
> > +{
> > +   u32 sgi;
> 
> sgi is used once here and looks more confusing than helpful
> 
Will fix in V3
> 
> []
> 
> > +static void *get_sw_cqe(struct mlx5_ib_cq *cq, int n)
> > +{
> > +   void *cqe = get_cqe(cq, n & cq->ibcq.cqe);
> > +   struct mlx5_cqe64 *cqe64;
> > +
> > +   cqe64 = (cq->mcq.cqe_sz == 64) ? cqe : cqe + 64;
> > +   return ((cqe64->op_own & MLX5_CQE_OWNER_MASK) ^
> > +   !!(n & (cq->ibcq.cqe + 1))) ? NULL : cqe;
> 
> I think "foo ^ !!bar" is excessively tricky.
> 
The mlx4 driver already uses "!!foo ^ !!bar" in several places in the kernel 
(and this is old code).
I assume that your problem with the above code is that it uses "foo" and not 
"!!foo".

Please note, though, that this code is data-path code -- and in this specific 
case,  foo = !!foo
(since MLX5_CQE_OWNER_MASK = 1). We decided, therefore, in this specific case, 
not to add the unnecessary
"!!", even though at first glance it may look tricky -- performance here IMHO 
is more important.

> > +static enum ib_wc_opcode get_umr_comp(struct mlx5_ib_wq *wq, int idx)
> > +{
> 
> > +   pr_warn("unkonwn completion status\n");
> 
> unknown tyop

Will fix in V3

> []
> 
> > +static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata,
> > + struct ib_ucontext *context, struct mlx5_ib_cq *cq,
> > + int entries, struct mlx5_create_cq_mbox_in **cqb,
> > + int *cqe_size, int *index, int *inlen)
> []
> > +   *inlen = sizeof **cqb + sizeof *(*cqb)->pas * ncont;
> 
> sizeof always uses parentheses
> 
> > +   *cqb = vzalloc(*inlen);
> 
> Perhaps you may be using vzalloc too often.
> 
> Maybe you should have a helper allocating either
> from kmalloc or vmalloc as necessary based on size.
We will look into this.

Thanks for reviewing!

-Jack

--
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 4/4] RDMA/cxgb4: Add support for active and passive open connection with IPv6 address

2013-07-04 Thread Vipul Pandya
Add new cpl messages, cpl_act_open_req6 and cpl_t5_act_open_req6, for
initiating active open connections.

Use LLD api cxgb4_create_server and cxgb4_create_server6 for initiating passive
open connections. Similarly use cxgb4_remove_server to remove the passive open
connections in place of listen_stop.

Add support for iWARP over VLAN device and enable IPv6 support on VLAN device.

Make use of import_ep in c4iw_reconnect.

Signed-off-by: Vipul Pandya 
---
V2: Used local variables instead of typecasting in patch 1/4.
V3: Removed dereferencing ep before initializing it in patch 4/4.

 drivers/infiniband/hw/cxgb4/cm.c   | 807 ++---
 drivers/infiniband/hw/cxgb4/device.c   | 116 +++--
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h |   4 +-
 3 files changed, 628 insertions(+), 299 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 76d8812..9423441 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -44,6 +44,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "iw_cxgb4.h"
 
@@ -333,19 +335,72 @@ static struct sk_buff *get_skb(struct sk_buff *skb, int 
len, gfp_t gfp)
return skb;
 }
 
-static struct rtable *find_route(struct c4iw_dev *dev, __be32 local_ip,
+static struct net_device *get_real_dev(struct net_device *egress_dev)
+{
+   struct net_device *phys_dev = egress_dev;
+   if (egress_dev->priv_flags & IFF_802_1Q_VLAN)
+   phys_dev = vlan_dev_real_dev(egress_dev);
+   return phys_dev;
+}
+
+static int our_interface(struct c4iw_dev *dev, struct net_device *egress_dev)
+{
+   int i;
+
+   egress_dev = get_real_dev(egress_dev);
+   for (i = 0; i < dev->rdev.lldi.nports; i++)
+   if (dev->rdev.lldi.ports[i] == egress_dev)
+   return 1;
+   return 0;
+}
+
+static struct dst_entry *find_route6(struct c4iw_dev *dev, __u8 *local_ip,
+__u8 *peer_ip, __be16 local_port,
+__be16 peer_port, u8 tos,
+__u32 sin6_scope_id)
+{
+   struct flowi6 fl6;
+   struct dst_entry *dst;
+
+   memset(&fl6, 0, sizeof(fl6));
+   memcpy(&fl6.daddr, peer_ip, 16);
+   memcpy(&fl6.saddr, local_ip, 16);
+   if (ipv6_addr_type(&fl6.daddr) & IPV6_ADDR_LINKLOCAL)
+   fl6.flowi6_oif = sin6_scope_id;
+   dst = ip6_route_output(&init_net, NULL, &fl6);
+   if (!dst)
+   goto out;
+   if (!our_interface(dev, ip6_dst_idev(dst)->dev) &&
+   !(ip6_dst_idev(dst)->dev->flags & IFF_LOOPBACK)) {
+   dst_release(dst);
+   dst = NULL;
+   }
+out:
+   return dst;
+}
+
+static struct dst_entry *find_route(struct c4iw_dev *dev, __be32 local_ip,
 __be32 peer_ip, __be16 local_port,
 __be16 peer_port, u8 tos)
 {
struct rtable *rt;
struct flowi4 fl4;
+   struct neighbour *n;
 
rt = ip_route_output_ports(&init_net, &fl4, NULL, peer_ip, local_ip,
   peer_port, local_port, IPPROTO_TCP,
   tos, 0);
if (IS_ERR(rt))
return NULL;
-   return rt;
+   n = dst_neigh_lookup(&rt->dst, &peer_ip);
+   if (!n)
+   return NULL;
+   if (!our_interface(dev, n->dev)) {
+   dst_release(&rt->dst);
+   return NULL;
+   }
+   neigh_release(n);
+   return &rt->dst;
 }
 
 static void arp_failure_discard(void *handle, struct sk_buff *skb)
@@ -512,15 +567,28 @@ static int send_connect(struct c4iw_ep *ep)
 {
struct cpl_act_open_req *req;
struct cpl_t5_act_open_req *t5_req;
+   struct cpl_act_open_req6 *req6;
+   struct cpl_t5_act_open_req6 *t5_req6;
struct sk_buff *skb;
u64 opt0;
u32 opt2;
unsigned int mtu_idx;
int wscale;
-   int size = is_t4(ep->com.dev->rdev.lldi.adapter_type) ?
-   sizeof(struct cpl_act_open_req) :
-   sizeof(struct cpl_t5_act_open_req);
-   int wrlen = roundup(size, 16);
+   int wrlen;
+   int sizev4 = is_t4(ep->com.dev->rdev.lldi.adapter_type) ?
+   sizeof(struct cpl_act_open_req) :
+   sizeof(struct cpl_t5_act_open_req);
+   int sizev6 = is_t4(ep->com.dev->rdev.lldi.adapter_type) ?
+   sizeof(struct cpl_act_open_req6) :
+   sizeof(struct cpl_t5_act_open_req6);
+   struct sockaddr_in *la = (struct sockaddr_in *)&ep->com.local_addr;
+   struct sockaddr_in *ra = (struct sockaddr_in *)&ep->com.remote_addr;
+   struct sockaddr_in6 *la6 = (struct sockaddr_in6 *)&ep->com.local_addr;
+   struct sockaddr_in6 *ra6 = (struct sockaddr_in6 *)&ep->com.remote_addr;
+
+   wrlen = (ep->com.remote_addr.ss_

[PATCH V3 2/4] cxgb4: Add routines to create and remove listening IPv6 servers

2013-07-04 Thread Vipul Pandya
Add cxgb4_create_server6 and cxgb4_remove_server routines to create and remove
listening IPv6 servers.

Return success (0) from cxgb4_create_server in case of ctrl queue congestion
since in case of congestion, passive open request gets queued and gets
processed later. If non zero value is returned it can be treated as an error
and ULD can free STID which can result into an error in passive open reply.

Add cpl structure for active open request with IPv6 address for T5.

Signed-off-by: Vipul Pandya 
---
V2: Used local variables instead of typecasting in patch 1/4.
V3: Removed dereferencing ep before initializing it in patch 4/4.

 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 71 -
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h  |  5 ++
 drivers/net/ethernet/chelsio/cxgb4/t4_msg.h | 17 +-
 3 files changed, 91 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 5a3256b..d1d6ff7 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3246,6 +3246,7 @@ int cxgb4_create_server(const struct net_device *dev, 
unsigned int stid,
struct sk_buff *skb;
struct adapter *adap;
struct cpl_pass_open_req *req;
+   int ret;
 
skb = alloc_skb(sizeof(*req), GFP_KERNEL);
if (!skb)
@@ -3263,10 +3264,78 @@ int cxgb4_create_server(const struct net_device *dev, 
unsigned int stid,
req->opt0 = cpu_to_be64(TX_CHAN(chan));
req->opt1 = cpu_to_be64(CONN_POLICY_ASK |
SYN_RSS_ENABLE | SYN_RSS_QUEUE(queue));
-   return t4_mgmt_tx(adap, skb);
+   ret = t4_mgmt_tx(adap, skb);
+   return net_xmit_eval(ret);
 }
 EXPORT_SYMBOL(cxgb4_create_server);
 
+/* cxgb4_create_server6 - create an IPv6 server
+ * @dev: the device
+ * @stid: the server TID
+ * @sip: local IPv6 address to bind server to
+ * @sport: the server's TCP port
+ * @queue: queue to direct messages from this server to
+ *
+ * Create an IPv6 server for the given port and address.
+ * Returns <0 on error and one of the %NET_XMIT_* values on success.
+ */
+int cxgb4_create_server6(const struct net_device *dev, unsigned int stid,
+const struct in6_addr *sip, __be16 sport,
+unsigned int queue)
+{
+   unsigned int chan;
+   struct sk_buff *skb;
+   struct adapter *adap;
+   struct cpl_pass_open_req6 *req;
+   int ret;
+
+   skb = alloc_skb(sizeof(*req), GFP_KERNEL);
+   if (!skb)
+   return -ENOMEM;
+
+   adap = netdev2adap(dev);
+   req = (struct cpl_pass_open_req6 *)__skb_put(skb, sizeof(*req));
+   INIT_TP_WR(req, 0);
+   OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_PASS_OPEN_REQ6, stid));
+   req->local_port = sport;
+   req->peer_port = htons(0);
+   req->local_ip_hi = *(__be64 *)(sip->s6_addr);
+   req->local_ip_lo = *(__be64 *)(sip->s6_addr + 8);
+   req->peer_ip_hi = cpu_to_be64(0);
+   req->peer_ip_lo = cpu_to_be64(0);
+   chan = rxq_to_chan(&adap->sge, queue);
+   req->opt0 = cpu_to_be64(TX_CHAN(chan));
+   req->opt1 = cpu_to_be64(CONN_POLICY_ASK |
+   SYN_RSS_ENABLE | SYN_RSS_QUEUE(queue));
+   ret = t4_mgmt_tx(adap, skb);
+   return net_xmit_eval(ret);
+}
+EXPORT_SYMBOL(cxgb4_create_server6);
+
+int cxgb4_remove_server(const struct net_device *dev, unsigned int stid,
+   unsigned int queue, bool ipv6)
+{
+   struct sk_buff *skb;
+   struct adapter *adap;
+   struct cpl_close_listsvr_req *req;
+   int ret;
+
+   adap = netdev2adap(dev);
+
+   skb = alloc_skb(sizeof(*req), GFP_KERNEL);
+   if (!skb)
+   return -ENOMEM;
+
+   req = (struct cpl_close_listsvr_req *)__skb_put(skb, sizeof(*req));
+   INIT_TP_WR(req, 0);
+   OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_CLOSE_LISTSRV_REQ, stid));
+   req->reply_ctrl = htons(NO_REPLY(0) | (ipv6 ? LISTSVR_IPV6(1) :
+   LISTSVR_IPV6(0)) | QUEUENO(queue));
+   ret = t4_mgmt_tx(adap, skb);
+   return net_xmit_eval(ret);
+}
+EXPORT_SYMBOL(cxgb4_remove_server);
+
 /**
  * cxgb4_best_mtu - find the entry in the MTU table closest to an MTU
  * @mtus: the HW MTU table
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
index 4faf4d0..6f21f24 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
@@ -154,6 +154,11 @@ struct in6_addr;
 int cxgb4_create_server(const struct net_device *dev, unsigned int stid,
__be32 sip, __be16 sport, __be16 vlan,
unsigned int queue);
+int cxgb4_create_server6(const struct net_device *dev, unsigned int stid,
+const struc

[PATCH V3 1/4] RDMA/cma: Add IPv6 support for iWARP.

2013-07-04 Thread Vipul Pandya
From: Steve Wise 

This patch modifies the type of local_addr and remote_addr fields in struct
iw_cm_id from struct sockaddr_in to struct sockaddr_storage to hold IPv6 and
IPv4 addresses uniformly. It changes the references of local_addr and
remote_addr in RDMA/cxgb4, RDMA/cxgb3, RDMA/nes and amso drivers such that build
failure is avoided. However to be able to actully run the traffic over IPv6
address respective drivers have to add supportive code.

Signed-off-by: Steve Wise 
---
V2: Used local variables instead of typecasting in patch 1/4.
V3: Removed dereferencing ep before initializing it in patch 4/4.

 drivers/infiniband/core/cma.c  |  44 --
 drivers/infiniband/hw/amso1100/c2_ae.c |  18 ++--
 drivers/infiniband/hw/amso1100/c2_cm.c |  16 +++-
 drivers/infiniband/hw/cxgb3/iwch_cm.c  |  46 +++---
 drivers/infiniband/hw/cxgb4/cm.c   |  55 ++--
 drivers/infiniband/hw/nes/nes_cm.c | 150 ++---
 include/rdma/iw_cm.h   |   8 +-
 7 files changed, 185 insertions(+), 152 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index f1c279f..92464fb 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1385,8 +1385,9 @@ static int cma_iw_handler(struct iw_cm_id *iw_id, struct 
iw_cm_event *iw_event)
 {
struct rdma_id_private *id_priv = iw_id->context;
struct rdma_cm_event event;
-   struct sockaddr_in *sin;
int ret = 0;
+   struct sockaddr *laddr = (struct sockaddr *)&iw_event->local_addr;
+   struct sockaddr *raddr = (struct sockaddr *)&iw_event->remote_addr;
 
if (cma_disable_callback(id_priv, RDMA_CM_CONNECT))
return 0;
@@ -1397,10 +1398,10 @@ static int cma_iw_handler(struct iw_cm_id *iw_id, 
struct iw_cm_event *iw_event)
event.event = RDMA_CM_EVENT_DISCONNECTED;
break;
case IW_CM_EVENT_CONNECT_REPLY:
-   sin = (struct sockaddr_in *) cma_src_addr(id_priv);
-   *sin = iw_event->local_addr;
-   sin = (struct sockaddr_in *) cma_dst_addr(id_priv);
-   *sin = iw_event->remote_addr;
+   memcpy(cma_src_addr(id_priv), laddr,
+  rdma_addr_size(laddr));
+   memcpy(cma_dst_addr(id_priv), raddr,
+  rdma_addr_size(raddr));
switch (iw_event->status) {
case 0:
event.event = RDMA_CM_EVENT_ESTABLISHED;
@@ -1450,11 +1451,12 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
 {
struct rdma_cm_id *new_cm_id;
struct rdma_id_private *listen_id, *conn_id;
-   struct sockaddr_in *sin;
struct net_device *dev = NULL;
struct rdma_cm_event event;
int ret;
struct ib_device_attr attr;
+   struct sockaddr *laddr = (struct sockaddr *)&iw_event->local_addr;
+   struct sockaddr *raddr = (struct sockaddr *)&iw_event->remote_addr;
 
listen_id = cm_id->context;
if (cma_disable_callback(listen_id, RDMA_CM_LISTEN))
@@ -1472,14 +1474,7 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
mutex_lock_nested(&conn_id->handler_mutex, SINGLE_DEPTH_NESTING);
conn_id->state = RDMA_CM_CONNECT;
 
-   dev = ip_dev_find(&init_net, iw_event->local_addr.sin_addr.s_addr);
-   if (!dev) {
-   ret = -EADDRNOTAVAIL;
-   mutex_unlock(&conn_id->handler_mutex);
-   rdma_destroy_id(new_cm_id);
-   goto out;
-   }
-   ret = rdma_copy_addr(&conn_id->id.route.addr.dev_addr, dev, NULL);
+   ret = rdma_translate_ip(laddr, &conn_id->id.route.addr.dev_addr);
if (ret) {
mutex_unlock(&conn_id->handler_mutex);
rdma_destroy_id(new_cm_id);
@@ -1497,10 +1492,8 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
cm_id->context = conn_id;
cm_id->cm_handler = cma_iw_handler;
 
-   sin = (struct sockaddr_in *) cma_src_addr(conn_id);
-   *sin = iw_event->local_addr;
-   sin = (struct sockaddr_in *) cma_dst_addr(conn_id);
-   *sin = iw_event->remote_addr;
+   memcpy(cma_src_addr(conn_id), laddr, rdma_addr_size(laddr));
+   memcpy(cma_dst_addr(conn_id), raddr, rdma_addr_size(raddr));
 
ret = ib_query_device(conn_id->id.device, &attr);
if (ret) {
@@ -1576,7 +1569,6 @@ static int cma_ib_listen(struct rdma_id_private *id_priv)
 static int cma_iw_listen(struct rdma_id_private *id_priv, int backlog)
 {
int ret;
-   struct sockaddr_in *sin;
struct iw_cm_id *id;
 
id = iw_create_cm_id(id_priv->id.device,
@@ -1587,8 +1579,8 @@ static int cma_iw_listen(struct rdma_id_private *id_priv, 
int backlog)
 
id_priv->cm_id.iw = id;
 
-   sin = (struct sockaddr_in *) cma_src_addr(id_priv);
-   id_priv->cm_id.iw->local_addr = *sin;
+   memcpy(&id_priv->cm_id.iw->local_addr, cma_src_addr(i

[PATCH V3 3/4] cxgb4: Add CLIP support to store compressed IPv6 address

2013-07-04 Thread Vipul Pandya
The Compressed LIP region is used to hold a limited number of Local IPv6
addresses. This region is primarily used to reduce the TCAM space consumed for
an IPv6 offloaded connection. A 128-bit LIP will be reduced to 13-bit and stored
in the TCAM if there is a match between the IPv6 tuple's LIP and the one stored
in the CLIP region.

Signed-off-by: Vipul Pandya 
---
V2: Used local variables instead of typecasting in patch 1/4.
V3: Removed dereferencing ep before initializing it in patch 4/4.

 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |   1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 217 
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h   |  23 +++
 3 files changed, 241 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 2aafb80..dfd1e36 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -576,6 +576,7 @@ struct adapter {
struct l2t_data *l2t;
void *uld_handle[CXGB4_ULD_MAX];
struct list_head list_node;
+   struct list_head rcu_node;
 
struct tid_info tids;
void **tid_release_head;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index d1d6ff7..038df4b 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -60,6 +60,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "cxgb4.h"
@@ -68,6 +69,11 @@
 #include "t4fw_api.h"
 #include "l2t.h"
 
+#include <../drivers/net/bonding/bonding.h>
+
+#ifdef DRV_VERSION
+#undef DRV_VERSION
+#endif
 #define DRV_VERSION "2.0.0-ko"
 #define DRV_DESC "Chelsio T4/T5 Network Driver"
 
@@ -400,6 +406,9 @@ static struct dentry *cxgb4_debugfs_root;
 
 static LIST_HEAD(adapter_list);
 static DEFINE_MUTEX(uld_mutex);
+/* Adapter list to be accessed from atomic context */
+static LIST_HEAD(adap_rcu_list);
+static DEFINE_SPINLOCK(adap_rcu_lock);
 static struct cxgb4_uld_info ulds[CXGB4_ULD_MAX];
 static const char *uld_str[] = { "RDMA", "iSCSI" };
 
@@ -3227,6 +3236,38 @@ static int tid_init(struct tid_info *t)
return 0;
 }
 
+static int cxgb4_clip_get(const struct net_device *dev,
+ const struct in6_addr *lip)
+{
+   struct adapter *adap;
+   struct fw_clip_cmd c;
+
+   adap = netdev2adap(dev);
+   memset(&c, 0, sizeof(c));
+   c.op_to_write = htonl(FW_CMD_OP(FW_CLIP_CMD) |
+   FW_CMD_REQUEST | FW_CMD_WRITE);
+   c.alloc_to_len16 = htonl(F_FW_CLIP_CMD_ALLOC | FW_LEN16(c));
+   *(__be64 *)&c.ip_hi = *(__be64 *)(lip->s6_addr);
+   *(__be64 *)&c.ip_lo = *(__be64 *)(lip->s6_addr + 8);
+   return t4_wr_mbox_meat(adap, adap->mbox, &c, sizeof(c), &c, false);
+}
+
+static int cxgb4_clip_release(const struct net_device *dev,
+ const struct in6_addr *lip)
+{
+   struct adapter *adap;
+   struct fw_clip_cmd c;
+
+   adap = netdev2adap(dev);
+   memset(&c, 0, sizeof(c));
+   c.op_to_write = htonl(FW_CMD_OP(FW_CLIP_CMD) |
+   FW_CMD_REQUEST | FW_CMD_READ);
+   c.alloc_to_len16 = htonl(F_FW_CLIP_CMD_FREE | FW_LEN16(c));
+   *(__be64 *)&c.ip_hi = *(__be64 *)(lip->s6_addr);
+   *(__be64 *)&c.ip_lo = *(__be64 *)(lip->s6_addr + 8);
+   return t4_wr_mbox_meat(adap, adap->mbox, &c, sizeof(c), &c, false);
+}
+
 /**
  * cxgb4_create_server - create an IP server
  * @dev: the device
@@ -3790,6 +3831,10 @@ static void attach_ulds(struct adapter *adap)
 {
unsigned int i;
 
+   spin_lock(&adap_rcu_lock);
+   list_add_tail_rcu(&adap->rcu_node, &adap_rcu_list);
+   spin_unlock(&adap_rcu_lock);
+
mutex_lock(&uld_mutex);
list_add_tail(&adap->list_node, &adapter_list);
for (i = 0; i < CXGB4_ULD_MAX; i++)
@@ -3815,6 +3860,10 @@ static void detach_ulds(struct adapter *adap)
netevent_registered = false;
}
mutex_unlock(&uld_mutex);
+
+   spin_lock(&adap_rcu_lock);
+   list_del_rcu(&adap->rcu_node);
+   spin_unlock(&adap_rcu_lock);
 }
 
 static void notify_ulds(struct adapter *adap, enum cxgb4_state new_state)
@@ -3878,6 +3927,169 @@ int cxgb4_unregister_uld(enum cxgb4_uld type)
 }
 EXPORT_SYMBOL(cxgb4_unregister_uld);
 
+/* Check if netdev on which event is occured belongs to us or not. Return
+ * suceess (1) if it belongs otherwise failure (0).
+ */
+static int cxgb4_netdev(struct net_device *netdev)
+{
+   struct adapter *adap;
+   int i;
+
+   spin_lock(&adap_rcu_lock);
+   list_for_each_entry_rcu(adap, &adap_rcu_list, rcu_node)
+   for (i = 0; i < MAX_NPORTS; i++)
+   if (adap->port[i] == netdev) {
+   spin_unlock(&adap_rcu_lock);
+   return 1;
+   }
+   spin_unlock(&adap_rcu_lock)

[PATCH V3 0/4] Add IPv6 support for iWARP

2013-07-04 Thread Vipul Pandya
Hi All,

This patch series adds IPv6 support for iWARP. It enables Chelsio's T4 and T5
adapters to transmitt RDMA traffic over IPv6 address. It adds new apis and cpl
messages in cxgb4 to support IPv6 operations and uses them in RDMA/cxgb4.

The patch series  modifies the type of local_addr and remote_addr fields in
struct iw_cm_id from struct sockaddr_in to struct sockaddr_storage to hold IPv6
and IPv4 addresses uniformly. It changes the references of local_addr and
remote_addr in RDMA/cxgb4, RDMA/cxgb3, RDMA/nes and amso drivers such that build
failure is avoided.

We would like to submit this patch series via Roland's infiniband tree for-next
branch.

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

Thanks,
Vipul Pandya

V2: Used local variables instead of typecasting in patch 1/4.
V3: Removed dereferencing ep before initializing it in patch 4/4.

Steve Wise (1):
  RDMA/cma: Add IPv6 support for iWARP.

Vipul Pandya (3):
  cxgb4: Add routines to create and remove listening IPv6 servers
  cxgb4: Add CLIP support to store compressed IPv6 address
  RDMA/cxgb4: Add support for active and passive open connection with
IPv6 address

 drivers/infiniband/core/cma.c   |  44 +-
 drivers/infiniband/hw/amso1100/c2_ae.c  |  18 +-
 drivers/infiniband/hw/amso1100/c2_cm.c  |  16 +-
 drivers/infiniband/hw/cxgb3/iwch_cm.c   |  46 +-
 drivers/infiniband/hw/cxgb4/cm.c| 844 
 drivers/infiniband/hw/cxgb4/device.c| 116 +++-
 drivers/infiniband/hw/cxgb4/iw_cxgb4.h  |   4 +-
 drivers/infiniband/hw/nes/nes_cm.c  | 150 +++--
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h  |   1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 288 +++-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h  |   5 +
 drivers/net/ethernet/chelsio/cxgb4/t4_msg.h |  17 +-
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h   |  23 +
 include/rdma/iw_cm.h|   8 +-
 14 files changed, 1136 insertions(+), 444 deletions(-)

-- 
1.8.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 v3 07/13] scsi_transport_srp: Add transport layer error handling

2013-07-04 Thread Bart Van Assche

On 07/04/13 10:01, Bart Van Assche wrote:

On 07/03/13 20:57, David Dillow wrote:

And I'm getting the strong sense that the answer to my question about
fast_io_fail_tmo >= 0 when dev_loss_tmo is that we should not allow that
combination, even if it doesn't break the kernel. If it doesn't make
sense, there is no reason to create an opportunity for user confusion.


Let's take a step back. I think we agree that the only combinations of
timeout parameters that are useful are those combinations that guarantee
that SCSI commands will be finished in a reasonable time and also that
allow multipath to detect failed paths. The first requirement comes down
to limiting the value fast_io_fail_tmo can be set to. The second
requirement means that either reconnect_delay or fast_io_fail_tmo must
be set (please note that a reconnect failure changes the state of all
involved SCSI devices into SDEV_TRANSPORT_OFFLINE). So how about
modifying srp_tmo_valid() as follows:
* Add an argument called "reconnect_delay".
* Add the following code in that function:
 if (reconnect_delay < 0 && fast_io_fail_tmo < 0 && dev_loss_tmo < 0)
 return -EINVAL;


(replying to my own e-mail)

A small correction to what I wrote above: a reconnect failure only 
causes the SCSI device state to be changed into SDEV_TRANSPORT_OFFLINE 
if the fast_io_fail mechanism has been disabled.


Bart.

--
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 07/13] scsi_transport_srp: Add transport layer error handling

2013-07-04 Thread Bart Van Assche

On 07/03/13 20:57, David Dillow wrote:

And I'm getting the strong sense that the answer to my question about
fast_io_fail_tmo >= 0 when dev_loss_tmo is that we should not allow that
combination, even if it doesn't break the kernel. If it doesn't make
sense, there is no reason to create an opportunity for user confusion.


Let's take a step back. I think we agree that the only combinations of 
timeout parameters that are useful are those combinations that guarantee 
that SCSI commands will be finished in a reasonable time and also that 
allow multipath to detect failed paths. The first requirement comes down 
to limiting the value fast_io_fail_tmo can be set to. The second 
requirement means that either reconnect_delay or fast_io_fail_tmo must 
be set (please note that a reconnect failure changes the state of all 
involved SCSI devices into SDEV_TRANSPORT_OFFLINE). So how about 
modifying srp_tmo_valid() as follows:

* Add an argument called "reconnect_delay".
* Add the following code in that function:
if (reconnect_delay < 0 && fast_io_fail_tmo < 0 && dev_loss_tmo < 0)
return -EINVAL;

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