[PATCH] RDMA/ocrdma: Fix double free in ocrdma_alloc_pd()
Commit 9ba1377daa51 ("RDMA/ocrdma: Move PD resource management to driver.") modified the err exit path in function ocrdma_alloc_pd() so that a call of _ocrdma_dealloc_pd(dev, pd) is followed by kfree(pd). However, _ocrdma_dealloc_pd() already unconditionally frees argument pd. Thus remove the double free. Detected by Coverity CID 1271296. Signed-off-by: Christian Engelmayer --- Compile tested only. Applies against linux-next. --- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c index 877175563634..74219d288aea 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c @@ -675,12 +675,10 @@ pd_mapping: return &pd->ibpd; err: - if (is_uctx_pd) { + if (is_uctx_pd) ocrdma_release_ucontext_pd(uctx); - } else { + else status = _ocrdma_dealloc_pd(dev, pd); - kfree(pd); - } exit: return ERR_PTR(status); } -- 1.9.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
Re: [PATCH v4 14/19] IB/core: Add IB_DEVICE_OPA_MAD_SUPPORT device cap flag
On 2/17/2015 4:25 PM, Weiny, Ira wrote: > > diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index > 3ab4033..2614233 100644 > --- a/include/rdma/ib_verbs.h > +++ b/include/rdma/ib_verbs.h > @@ -128,6 +128,10 @@ enum ib_device_cap_flags { > IB_DEVICE_ON_DEMAND_PAGING = (1<<31), > }; > > +enum ib_device_cap_flags2 { > + IB_DEVICE_OPA_MAD_SUPPORT = 1 > +}; > + > enum ib_signature_prot_cap { > IB_PROT_T10DIF_TYPE_1 = 1, > IB_PROT_T10DIF_TYPE_2 = 1 << 1, > @@ -210,6 +214,7 @@ struct ib_device_attr { > int sig_prot_cap; > int sig_guard_cap; > struct ib_odp_caps odp_caps; > + u64 device_cap_flags2; > u32 max_mad_size; > }; > Why is OPA support determined via a device capability flag ? What are the tradeoffs for doing it this way versus the other choices that have been used in the past for other RDMA technologies like RoCE, iWARP, >> usNIC, ... ? >>> >>> None of those technologies use the MAD stack for Subnet Management. >> Other MAD support is very limited (ie IB compatible PMA queries on the local >> port only). >>> >>> Do you have a suggestion for alternatives? >> >> The desire to leverage the IB MAD infrastructure for OPA is understood but >> the >> current approach represents OPA as a device capability which does not seem >> appropriate because OPA is clearly a different type of RDMA technology than >> IB. >> > > While it is a different type of technology, standard verbs[*] remains 100% > compatible. Unlike other verbs technologies user space software does not > need any knowledge that the underlying device is not IB. For example, PR > (and SA) queries, CM, rdmacm, and verbs calls themselves are all 100% IB > compatible. Even if OPA is 100% standard verbs compatible which it does not appear to be, that does not make OPA an extra capability of an IBA device. While it is a primary goal of the RDMA stack to have a common verbs API for various RDMA interconnects, each one is properly represented to allow it’s unique characteristics to be exposed. > Therefore, to address your initial question regarding tradeoffs I believe > this method is the least invasive to the code as well as removing any > potential performance penalties to core verbs. > > Ira > > [*] We don't support some of the extensions particularly those which have > been most recently introduced. And we would like to make our own extensions > in the form of higher MTU availability, but the patch is not yet ready to be > submitted upstream. There appear to be a number of things that are not exposed by the current patch set which will be needed in subsequent patches. It would be better to see the complete picture so it can be reviewed as a whole. -- 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 9/9] IB/ipoib: drop mcast_mutex usage
On Mon, 2015-02-23 at 18:56 +0200, Or Gerlitz wrote: > On Sun, Feb 22, 2015 at 2:27 AM, Doug Ledford wrote: > > We needed the mcast_mutex when we had to prevent the join completion > > callback from having the value it stored in mcast->mc overwritten > > downstream patches of this series (7/9 and 8/9) make pretty much heavy > usage of the mcast_mutex (e.g add/delete lines that use it), and patch > 9/9 removes it altogether.. which would be very confusing for > maintaining purposes. Is there a sane way to avoid that?! No. The changes that make dropping the mutex possible are part of patch 7. Patch 7 changes the semantics of the MCAST_FLAG_BUSY usage, and fixes some locking bugs, but that's different than wholesale changing of the locking type. If you want to preserve bisecability and be able to test the semantic changes to the FLAG_BUSY usage separate from the changes to the locking type, then they have to be separated. So, for the sake of good engineering practices and separation of distinctly different types of changes, that locking change should not be folded into patch 7. -- Doug Ledford GPG KeyID: 0E572FDD signature.asc Description: This is a digitally signed message part
RE: [PATCH 09/30] IB/core: Modify ib_verbs and cma in order to use roce_gid_cache
> -Original Message- > From: Matan Barak [mailto:mat...@mellanox.com] > Sent: Monday, February 23, 2015 3:47 PM > To: Devesh Sharma; Somnath Kotur; rol...@kernel.org > Cc: linux-rdma@vger.kernel.org > Subject: Re: [PATCH 09/30] IB/core: Modify ib_verbs and cma in order to use > roce_gid_cache > > > > On 2/23/2015 7:25 AM, Devesh Sharma wrote: > > Hi Matan, > > > > Please find a comment inline below: > > > > -Regards > > Devesh > >> -Original Message- > >> From: linux-rdma-ow...@vger.kernel.org [mailto:linux-rdma- > >> ow...@vger.kernel.org] On Behalf Of Somnath Kotur > >> Sent: Friday, February 20, 2015 3:32 AM > >> To: rol...@kernel.org > >> Cc: linux-rdma@vger.kernel.org; Matan Barak; Somnath Kotur > >> Subject: [PATCH 09/30] IB/core: Modify ib_verbs and cma in order to > >> use roce_gid_cache > >> > >> From: Matan Barak > >> > >> Previously, we resolved the dmac and took the smac and vlan from the > >> resolved address. Changing that into finding a net device that > >> matches the IP and vlan of the network packet and querying the RoCE > >> GID cache for this net device, GID and GID type. > >> > >> ocrdma driver changes were done by Somnath Kotur > >> > >> > >> Signed-off-by: Matan Barak > >> Signed-off-by: Somnath Kotur > >> --- > >> drivers/infiniband/core/addr.c |3 +- > >> drivers/infiniband/core/cm.c | 30 -- > >> drivers/infiniband/core/cma.c|9 -- > >> drivers/infiniband/core/core_priv.h |4 +- > >> drivers/infiniband/core/sa_query.c |4 - > >> drivers/infiniband/core/ucma.c |1 - > >> drivers/infiniband/core/uverbs_cmd.c |6 +- > >> drivers/infiniband/core/verbs.c | 159 > >> + > >> drivers/infiniband/hw/mlx4/ah.c | 15 +++- > >> drivers/infiniband/hw/mlx4/mad.c | 12 ++- > >> drivers/infiniband/hw/mlx4/mcg.c |2 +- > >> drivers/infiniband/hw/mlx4/mlx4_ib.h |2 +- > >> drivers/infiniband/hw/mlx4/qp.c | 42 ++-- > >> drivers/infiniband/hw/ocrdma/ocrdma.h|1 + > >> drivers/infiniband/hw/ocrdma/ocrdma_ah.c | 20 +++-- > >> drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 17 ++- > >> include/rdma/ib_addr.h |2 +- > >> include/rdma/ib_sa.h |2 - > >> include/rdma/ib_verbs.h |7 +- > >> 19 files changed, 183 insertions(+), 155 deletions(-) > >> > >> diff --git a/drivers/infiniband/core/addr.c > >> b/drivers/infiniband/core/addr.c index f80da50..43af7f5 100644 > >> --- a/drivers/infiniband/core/addr.c > >> +++ b/drivers/infiniband/core/addr.c > >> @@ -458,7 +458,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, int if_index) > >> { > >>int ret = 0; > >>struct rdma_dev_addr dev_addr; > >> @@ -481,6 +481,7 @@ int rdma_addr_find_dmac_by_grh(union ib_gid > >> *sgid, union ib_gid *dgid, u8 *dmac, > >>return ret; > >> > >>memset(&dev_addr, 0, sizeof(dev_addr)); > >> + dev_addr.bound_dev_if = if_index; > >> > >>ctx.addr = &dev_addr; > >>init_completion(&ctx.comp); > >> diff --git a/drivers/infiniband/core/cm.c > >> b/drivers/infiniband/core/cm.c index > >> d88f2ae..7974e74 100644 > >> --- a/drivers/infiniband/core/cm.c > >> +++ b/drivers/infiniband/core/cm.c > >> @@ -178,8 +178,6 @@ struct cm_av { > >>struct ib_ah_attr ah_attr; > >>u16 pkey_index; > >>u8 timeout; > >> - u8 valid; > >> - u8 smac[ETH_ALEN]; > >> }; > >> > >> struct cm_work { > >> @@ -382,7 +380,6 @@ static int cm_init_av_by_path(struct > >> ib_sa_path_rec *path, struct cm_av *av) > >> &av->ah_attr); > >>av->timeout = path->packet_life_time + 1; > >> > >> - av->valid = 1; > >>return 0; > >> } > >> > >> @@ -1563,7 +1560,6 @@ static int cm_req_handler(struct cm_work *work) > >>cm_format_paths_from_req(req_msg, &work->path[0], &work- > >>> path[1]); > >> > >>memcpy(work->path[0].dmac, cm_id_priv->av.ah_attr.dmac, > ETH_ALEN); > >> - work->path[0].vlan_id = cm_id_priv->av.ah_attr.vlan_id; > >>ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av); > >>if (ret) { > >>ib_get_cached_gid(work->port->cm_dev->ib_device, > >> @@ -3511,32 +3507,6 @@ static int cm_init_qp_rtr_attr(struct > >> cm_id_private *cm_id_priv, > >>*qp_attr_mask = IB_QP_STATE | IB_QP_AV | > IB_QP_PATH_MTU | > >>IB_QP_DEST_QPN | IB_QP_RQ_PSN; > >>qp_attr->ah_attr = cm_id_priv->av.ah_attr; > >> - if (!cm_id_priv->av.valid) { > >> - spin_unlock_irqrestore(&cm_id_priv->lock, flags); > >> - return -EINVAL; > >> - } > >> - if (cm_id_priv->av.ah_attr.vla
Re: [PATCH 9/9] IB/ipoib: drop mcast_mutex usage
On Sun, Feb 22, 2015 at 2:27 AM, Doug Ledford wrote: > We needed the mcast_mutex when we had to prevent the join completion > callback from having the value it stored in mcast->mc overwritten downstream patches of this series (7/9 and 8/9) make pretty much heavy usage of the mcast_mutex (e.g add/delete lines that use it), and patch 9/9 removes it altogether.. which would be very confusing for maintaining purposes. Is there a sane way to avoid that?! -- 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 5/9] IB/ipoib: Use dedicated workqueues per interface
On Sun, Feb 22, 2015 at 2:27 AM, Doug Ledford wrote: > @@ -236,12 +247,19 @@ out_free_send_cq: > out_free_recv_cq: > ib_destroy_cq(priv->recv_cq); > > +out_cm_dev_cleanup: > + ipoib_cm_dev_cleanup(dev); > + > +out_free_wq: > + destroy_workqueue(priv->wq); > + priv->wq = NULL; > + > out_free_mr: > ib_dereg_mr(priv->mr); > - ipoib_cm_dev_cleanup(dev); > > out_free_pd: > ib_dealloc_pd(priv->pd); > + > return -ENODEV; > } just quick initial feedback to get fixed for V1 of the reworked series: please avoid random addition/deletion of blank lines as part of patch that fix bug X or introduce feature Y > > @@ -265,11 +283,18 @@ void ipoib_transport_dev_cleanup(struct net_device *dev) > > ipoib_cm_dev_cleanup(dev); > > + if (priv->wq) { > + flush_workqueue(priv->wq); > + destroy_workqueue(priv->wq); > + priv->wq = NULL; > + } > + > if (ib_dereg_mr(priv->mr)) > ipoib_warn(priv, "ib_dereg_mr failed\n"); > > if (ib_dealloc_pd(priv->pd)) > ipoib_warn(priv, "ib_dealloc_pd failed\n"); > + > } here too -- 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] IB/verbs: Check each operation of dma_ops individually
Current approach force one to implement all ops even when some functions can use the default implementation. As a result, for new DMA ops (e.x new arch) many functions just wrap the default function. The fix is to check each DMA operation individually so one can leave empty the ones not need to be override. Signed-off-by: Yuval Shaia --- include/rdma/ib_verbs.h | 22 +++--- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 0d74f1d..166c01a 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -2145,7 +2145,7 @@ struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags); */ static inline int ib_dma_mapping_error(struct ib_device *dev, u64 dma_addr) { - if (dev->dma_ops) + if (dev->dma_ops && dev->dma_ops->mapping_error) return dev->dma_ops->mapping_error(dev, dma_addr); return dma_mapping_error(dev->dma_device, dma_addr); } @@ -2161,7 +2161,7 @@ static inline u64 ib_dma_map_single(struct ib_device *dev, void *cpu_addr, size_t size, enum dma_data_direction direction) { - if (dev->dma_ops) + if (dev->dma_ops && dev->dma_ops->map_single) return dev->dma_ops->map_single(dev, cpu_addr, size, direction); return dma_map_single(dev->dma_device, cpu_addr, size, direction); } @@ -2177,7 +2177,7 @@ static inline void ib_dma_unmap_single(struct ib_device *dev, u64 addr, size_t size, enum dma_data_direction direction) { - if (dev->dma_ops) + if (dev->dma_ops && dev->dma_ops->unmap_single) dev->dma_ops->unmap_single(dev, addr, size, direction); else dma_unmap_single(dev->dma_device, addr, size, direction); @@ -2215,7 +2215,7 @@ static inline u64 ib_dma_map_page(struct ib_device *dev, size_t size, enum dma_data_direction direction) { - if (dev->dma_ops) + if (dev->dma_ops && dev->dma_ops->map_page) return dev->dma_ops->map_page(dev, page, offset, size, direction); return dma_map_page(dev->dma_device, page, offset, size, direction); } @@ -2231,7 +2231,7 @@ static inline void ib_dma_unmap_page(struct ib_device *dev, u64 addr, size_t size, enum dma_data_direction direction) { - if (dev->dma_ops) + if (dev->dma_ops && dev->dma_ops->unmap_page) dev->dma_ops->unmap_page(dev, addr, size, direction); else dma_unmap_page(dev->dma_device, addr, size, direction); @@ -2248,7 +2248,7 @@ static inline int ib_dma_map_sg(struct ib_device *dev, struct scatterlist *sg, int nents, enum dma_data_direction direction) { - if (dev->dma_ops) + if (dev->dma_ops && dev->dma_ops->map_sg) return dev->dma_ops->map_sg(dev, sg, nents, direction); return dma_map_sg(dev->dma_device, sg, nents, direction); } @@ -2264,7 +2264,7 @@ static inline void ib_dma_unmap_sg(struct ib_device *dev, struct scatterlist *sg, int nents, enum dma_data_direction direction) { - if (dev->dma_ops) + if (dev->dma_ops && dev->dma_ops->unmap_sg) dev->dma_ops->unmap_sg(dev, sg, nents, direction); else dma_unmap_sg(dev->dma_device, sg, nents, direction); @@ -2325,7 +2325,7 @@ static inline void ib_dma_sync_single_for_cpu(struct ib_device *dev, size_t size, enum dma_data_direction dir) { - if (dev->dma_ops) + if (dev->dma_ops && dev->dma_ops->sync_single_for_cpu) dev->dma_ops->sync_single_for_cpu(dev, addr, size, dir); else dma_sync_single_for_cpu(dev->dma_device, addr, size, dir); @@ -2343,7 +2343,7 @@ static inline void ib_dma_sync_single_for_device(struct ib_device *dev, size_t size, enum dma_data_direction dir) { - if (dev->dma_ops) + if (dev->dma_ops && dev->dma_ops->sync_single_for_device) dev->dma_ops->sync_single_for_device(dev, addr, size, dir); else dma_sync_single_for_device(dev->dma_device, addr, size, dir); @@ -2361,7 +2361,7 @@ static inline void *ib_dma_alloc_coherent(struct ib_device *dev, u64 *dma_handle, gfp_t flag) { - if (dev->dma_ops) + if (dev->dma_ops && dev->dma_ops->alloc_coherent) return dev->dma_
Re: [PATCH 09/30] IB/core: Modify ib_verbs and cma in order to use roce_gid_cache
On 2/23/2015 12:32 PM, Somnath Kotur wrote: -Original Message- From: Matan Barak [mailto:mat...@mellanox.com] Sent: Monday, February 23, 2015 3:47 PM To: Devesh Sharma; Somnath Kotur; rol...@kernel.org Cc: linux-rdma@vger.kernel.org Subject: Re: [PATCH 09/30] IB/core: Modify ib_verbs and cma in order to use roce_gid_cache On 2/23/2015 7:25 AM, Devesh Sharma wrote: Hi Matan, Please find a comment inline below: -Regards Devesh -Original Message- From: linux-rdma-ow...@vger.kernel.org [mailto:linux-rdma- ow...@vger.kernel.org] On Behalf Of Somnath Kotur Sent: Friday, February 20, 2015 3:32 AM To: rol...@kernel.org Cc: linux-rdma@vger.kernel.org; Matan Barak; Somnath Kotur Subject: [PATCH 09/30] IB/core: Modify ib_verbs and cma in order to use roce_gid_cache From: Matan Barak Previously, we resolved the dmac and took the smac and vlan from the resolved address. Changing that into finding a net device that matches the IP and vlan of the network packet and querying the RoCE GID cache for this net device, GID and GID type. ocrdma driver changes were done by Somnath Kotur Signed-off-by: Matan Barak Signed-off-by: Somnath Kotur --- drivers/infiniband/core/addr.c |3 +- drivers/infiniband/core/cm.c | 30 -- drivers/infiniband/core/cma.c|9 -- drivers/infiniband/core/core_priv.h |4 +- drivers/infiniband/core/sa_query.c |4 - drivers/infiniband/core/ucma.c |1 - drivers/infiniband/core/uverbs_cmd.c |6 +- drivers/infiniband/core/verbs.c | 159 +-- -- drivers/infiniband/hw/mlx4/ah.c | 15 +++- drivers/infiniband/hw/mlx4/mad.c | 12 ++- drivers/infiniband/hw/mlx4/mcg.c |2 +- drivers/infiniband/hw/mlx4/mlx4_ib.h |2 +- drivers/infiniband/hw/mlx4/qp.c | 42 ++-- drivers/infiniband/hw/ocrdma/ocrdma.h|1 + drivers/infiniband/hw/ocrdma/ocrdma_ah.c | 20 +++-- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 17 ++- include/rdma/ib_addr.h |2 +- include/rdma/ib_sa.h |2 - include/rdma/ib_verbs.h |7 +- 19 files changed, 183 insertions(+), 155 deletions(-) diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c index f80da50..43af7f5 100644 --- a/drivers/infiniband/core/addr.c +++ b/drivers/infiniband/core/addr.c @@ -458,7 +458,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, int if_index) { int ret = 0; struct rdma_dev_addr dev_addr; @@ -481,6 +481,7 @@ int rdma_addr_find_dmac_by_grh(union ib_gid *sgid, union ib_gid *dgid, u8 *dmac, return ret; memset(&dev_addr, 0, sizeof(dev_addr)); + dev_addr.bound_dev_if = if_index; ctx.addr = &dev_addr; init_completion(&ctx.comp); diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index d88f2ae..7974e74 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -178,8 +178,6 @@ struct cm_av { struct ib_ah_attr ah_attr; u16 pkey_index; u8 timeout; - u8 valid; - u8 smac[ETH_ALEN]; }; struct cm_work { @@ -382,7 +380,6 @@ static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av) &av->ah_attr); av->timeout = path->packet_life_time + 1; - av->valid = 1; return 0; } @@ -1563,7 +1560,6 @@ static int cm_req_handler(struct cm_work *work) cm_format_paths_from_req(req_msg, &work->path[0], &work- path[1]); memcpy(work->path[0].dmac, cm_id_priv->av.ah_attr.dmac, ETH_ALEN); - work->path[0].vlan_id = cm_id_priv->av.ah_attr.vlan_id; ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av); if (ret) { ib_get_cached_gid(work->port->cm_dev->ib_device, @@ -3511,32 +3507,6 @@ static int cm_init_qp_rtr_attr(struct cm_id_private *cm_id_priv, *qp_attr_mask = IB_QP_STATE | IB_QP_AV | IB_QP_PATH_MTU | IB_QP_DEST_QPN | IB_QP_RQ_PSN; qp_attr->ah_attr = cm_id_priv->av.ah_attr; - if (!cm_id_priv->av.valid) { - spin_unlock_irqrestore(&cm_id_priv->lock, flags); - return -EINVAL; - } - if (cm_id_priv->av.ah_attr.vlan_id != 0x) { - qp_attr->vlan_id = cm_id_priv->av.ah_attr.vlan_id; - *qp_attr_mask |= IB_QP_VID; - } - if (!is_zero_ether_addr(cm_id_priv->av.smac)) { - memcpy(qp_attr->smac, cm_id_priv->av.smac, - sizeof(qp_
Re: [PATCH 09/30] IB/core: Modify ib_verbs and cma in order to use roce_gid_cache
On 2/23/2015 7:25 AM, Devesh Sharma wrote: Hi Matan, Please find a comment inline below: -Regards Devesh -Original Message- From: linux-rdma-ow...@vger.kernel.org [mailto:linux-rdma- ow...@vger.kernel.org] On Behalf Of Somnath Kotur Sent: Friday, February 20, 2015 3:32 AM To: rol...@kernel.org Cc: linux-rdma@vger.kernel.org; Matan Barak; Somnath Kotur Subject: [PATCH 09/30] IB/core: Modify ib_verbs and cma in order to use roce_gid_cache From: Matan Barak Previously, we resolved the dmac and took the smac and vlan from the resolved address. Changing that into finding a net device that matches the IP and vlan of the network packet and querying the RoCE GID cache for this net device, GID and GID type. ocrdma driver changes were done by Somnath Kotur Signed-off-by: Matan Barak Signed-off-by: Somnath Kotur --- drivers/infiniband/core/addr.c |3 +- drivers/infiniband/core/cm.c | 30 -- drivers/infiniband/core/cma.c|9 -- drivers/infiniband/core/core_priv.h |4 +- drivers/infiniband/core/sa_query.c |4 - drivers/infiniband/core/ucma.c |1 - drivers/infiniband/core/uverbs_cmd.c |6 +- drivers/infiniband/core/verbs.c | 159 + drivers/infiniband/hw/mlx4/ah.c | 15 +++- drivers/infiniband/hw/mlx4/mad.c | 12 ++- drivers/infiniband/hw/mlx4/mcg.c |2 +- drivers/infiniband/hw/mlx4/mlx4_ib.h |2 +- drivers/infiniband/hw/mlx4/qp.c | 42 ++-- drivers/infiniband/hw/ocrdma/ocrdma.h|1 + drivers/infiniband/hw/ocrdma/ocrdma_ah.c | 20 +++-- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 17 ++- include/rdma/ib_addr.h |2 +- include/rdma/ib_sa.h |2 - include/rdma/ib_verbs.h |7 +- 19 files changed, 183 insertions(+), 155 deletions(-) diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c index f80da50..43af7f5 100644 --- a/drivers/infiniband/core/addr.c +++ b/drivers/infiniband/core/addr.c @@ -458,7 +458,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, int if_index) { int ret = 0; struct rdma_dev_addr dev_addr; @@ -481,6 +481,7 @@ int rdma_addr_find_dmac_by_grh(union ib_gid *sgid, union ib_gid *dgid, u8 *dmac, return ret; memset(&dev_addr, 0, sizeof(dev_addr)); + dev_addr.bound_dev_if = if_index; ctx.addr = &dev_addr; init_completion(&ctx.comp); diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index d88f2ae..7974e74 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -178,8 +178,6 @@ struct cm_av { struct ib_ah_attr ah_attr; u16 pkey_index; u8 timeout; - u8 valid; - u8 smac[ETH_ALEN]; }; struct cm_work { @@ -382,7 +380,6 @@ static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av) &av->ah_attr); av->timeout = path->packet_life_time + 1; - av->valid = 1; return 0; } @@ -1563,7 +1560,6 @@ static int cm_req_handler(struct cm_work *work) cm_format_paths_from_req(req_msg, &work->path[0], &work- path[1]); memcpy(work->path[0].dmac, cm_id_priv->av.ah_attr.dmac, ETH_ALEN); - work->path[0].vlan_id = cm_id_priv->av.ah_attr.vlan_id; ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av); if (ret) { ib_get_cached_gid(work->port->cm_dev->ib_device, @@ -3511,32 +3507,6 @@ static int cm_init_qp_rtr_attr(struct cm_id_private *cm_id_priv, *qp_attr_mask = IB_QP_STATE | IB_QP_AV | IB_QP_PATH_MTU | IB_QP_DEST_QPN | IB_QP_RQ_PSN; qp_attr->ah_attr = cm_id_priv->av.ah_attr; - if (!cm_id_priv->av.valid) { - spin_unlock_irqrestore(&cm_id_priv->lock, flags); - return -EINVAL; - } - if (cm_id_priv->av.ah_attr.vlan_id != 0x) { - qp_attr->vlan_id = cm_id_priv->av.ah_attr.vlan_id; - *qp_attr_mask |= IB_QP_VID; - } - if (!is_zero_ether_addr(cm_id_priv->av.smac)) { - memcpy(qp_attr->smac, cm_id_priv->av.smac, - sizeof(qp_attr->smac)); - *qp_attr_mask |= IB_QP_SMAC; - } - if (cm_id_priv->alt_av.valid) { - if (cm_id_priv->alt_av.ah_attr.vlan_id != 0x) { - qp_attr->alt_vlan_id = - cm_id_priv->alt_av.ah_attr.vlan_id; - *
RE: [PATCH 09/30] IB/core: Modify ib_verbs and cma in order to use roce_gid_cache
> -Original Message- > From: Matan Barak [mailto:mat...@mellanox.com] > Sent: Monday, February 23, 2015 3:47 PM > To: Devesh Sharma; Somnath Kotur; rol...@kernel.org > Cc: linux-rdma@vger.kernel.org > Subject: Re: [PATCH 09/30] IB/core: Modify ib_verbs and cma in order to use > roce_gid_cache > > > > On 2/23/2015 7:25 AM, Devesh Sharma wrote: > > Hi Matan, > > > > Please find a comment inline below: > > > > -Regards > > Devesh > >> -Original Message- > >> From: linux-rdma-ow...@vger.kernel.org [mailto:linux-rdma- > >> ow...@vger.kernel.org] On Behalf Of Somnath Kotur > >> Sent: Friday, February 20, 2015 3:32 AM > >> To: rol...@kernel.org > >> Cc: linux-rdma@vger.kernel.org; Matan Barak; Somnath Kotur > >> Subject: [PATCH 09/30] IB/core: Modify ib_verbs and cma in order to > >> use roce_gid_cache > >> > >> From: Matan Barak > >> > >> Previously, we resolved the dmac and took the smac and vlan from the > >> resolved address. Changing that into finding a net device that > >> matches the IP and vlan of the network packet and querying the RoCE > >> GID cache for this net device, GID and GID type. > >> > >> ocrdma driver changes were done by Somnath Kotur > >> > >> > >> Signed-off-by: Matan Barak > >> Signed-off-by: Somnath Kotur > >> --- > >> drivers/infiniband/core/addr.c |3 +- > >> drivers/infiniband/core/cm.c | 30 -- > >> drivers/infiniband/core/cma.c|9 -- > >> drivers/infiniband/core/core_priv.h |4 +- > >> drivers/infiniband/core/sa_query.c |4 - > >> drivers/infiniband/core/ucma.c |1 - > >> drivers/infiniband/core/uverbs_cmd.c |6 +- > >> drivers/infiniband/core/verbs.c | 159 > >> +-- > -- > >> drivers/infiniband/hw/mlx4/ah.c | 15 +++- > >> drivers/infiniband/hw/mlx4/mad.c | 12 ++- > >> drivers/infiniband/hw/mlx4/mcg.c |2 +- > >> drivers/infiniband/hw/mlx4/mlx4_ib.h |2 +- > >> drivers/infiniband/hw/mlx4/qp.c | 42 ++-- > >> drivers/infiniband/hw/ocrdma/ocrdma.h|1 + > >> drivers/infiniband/hw/ocrdma/ocrdma_ah.c | 20 +++-- > >> drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 17 ++- > >> include/rdma/ib_addr.h |2 +- > >> include/rdma/ib_sa.h |2 - > >> include/rdma/ib_verbs.h |7 +- > >> 19 files changed, 183 insertions(+), 155 deletions(-) > >> > >> diff --git a/drivers/infiniband/core/addr.c > >> b/drivers/infiniband/core/addr.c index f80da50..43af7f5 100644 > >> --- a/drivers/infiniband/core/addr.c > >> +++ b/drivers/infiniband/core/addr.c > >> @@ -458,7 +458,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, int if_index) > >> { > >>int ret = 0; > >>struct rdma_dev_addr dev_addr; > >> @@ -481,6 +481,7 @@ int rdma_addr_find_dmac_by_grh(union ib_gid > >> *sgid, union ib_gid *dgid, u8 *dmac, > >>return ret; > >> > >>memset(&dev_addr, 0, sizeof(dev_addr)); > >> + dev_addr.bound_dev_if = if_index; > >> > >>ctx.addr = &dev_addr; > >>init_completion(&ctx.comp); > >> diff --git a/drivers/infiniband/core/cm.c > >> b/drivers/infiniband/core/cm.c index > >> d88f2ae..7974e74 100644 > >> --- a/drivers/infiniband/core/cm.c > >> +++ b/drivers/infiniband/core/cm.c > >> @@ -178,8 +178,6 @@ struct cm_av { > >>struct ib_ah_attr ah_attr; > >>u16 pkey_index; > >>u8 timeout; > >> - u8 valid; > >> - u8 smac[ETH_ALEN]; > >> }; > >> > >> struct cm_work { > >> @@ -382,7 +380,6 @@ static int cm_init_av_by_path(struct > >> ib_sa_path_rec *path, struct cm_av *av) > >> &av->ah_attr); > >>av->timeout = path->packet_life_time + 1; > >> > >> - av->valid = 1; > >>return 0; > >> } > >> > >> @@ -1563,7 +1560,6 @@ static int cm_req_handler(struct cm_work > *work) > >>cm_format_paths_from_req(req_msg, &work->path[0], &work- > >>> path[1]); > >> > >>memcpy(work->path[0].dmac, cm_id_priv->av.ah_attr.dmac, > ETH_ALEN); > >> - work->path[0].vlan_id = cm_id_priv->av.ah_attr.vlan_id; > >>ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av); > >>if (ret) { > >>ib_get_cached_gid(work->port->cm_dev->ib_device, > >> @@ -3511,32 +3507,6 @@ static int cm_init_qp_rtr_attr(struct > >> cm_id_private *cm_id_priv, > >>*qp_attr_mask = IB_QP_STATE | IB_QP_AV | > IB_QP_PATH_MTU | > >>IB_QP_DEST_QPN | IB_QP_RQ_PSN; > >>qp_attr->ah_attr = cm_id_priv->av.ah_attr; > >> - if (!cm_id_priv->av.valid) { > >> - spin_unlock_irqrestore(&cm_id_priv->lock, flags); > >> - return -EINVAL; > >> - } > >> - if (cm_id_priv->av.ah_at