On Tue, Jun 05, 2018 at 03:43:18PM +0800, Yanjun Zhu wrote: > > > On 2018/6/5 13:40, Leon Romanovsky wrote: > > From: Parav Pandit <parav@xxxxxxxxxxxx> > > > > rxe_netdev_from_av can now be done by the core code directly from the > > gid_attrs, no need for a helper in the driver. > > > > ib_find_cached_gid_by_port can be switched to use the rdma version here as > > well. > > > > Signed-off-by: Parav Pandit <parav@xxxxxxxxxxxx> > > Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx> > > Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> > > --- > > drivers/infiniband/sw/rxe/rxe_net.c | 50 ++++++++++++------------------------ > > drivers/infiniband/sw/rxe/rxe_recv.c | 12 ++++++--- > > 2 files changed, 25 insertions(+), 37 deletions(-) > > > > diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c > > index 59ec6d918ed4..79b69943a8af 100644 > > --- a/drivers/infiniband/sw/rxe/rxe_net.c > > +++ b/drivers/infiniband/sw/rxe/rxe_net.c > > @@ -182,39 +182,19 @@ static struct dst_entry *rxe_find_route6(struct net_device *ndev, > > #endif > > -/* > > - * Derive the net_device from the av. > > - * For physical devices, this will just return rxe->ndev. > > - * But for VLAN devices, it will return the vlan dev. > > - * Caller should dev_put() the returned net_device. > > - */ > > -static struct net_device *rxe_netdev_from_av(struct rxe_dev *rxe, > > - int port_num, > > - struct rxe_av *av) > > -{ > > - union ib_gid gid; > > - struct ib_gid_attr attr; > > - struct net_device *ndev = rxe->ndev; > > - > > - if (ib_get_cached_gid(&rxe->ib_dev, port_num, av->grh.sgid_index, > > - &gid, &attr) == 0 && > > - attr.ndev && attr.ndev != ndev) > > - ndev = attr.ndev; > > - else > > - /* Only to ensure that caller may call dev_put() */ > > - dev_hold(ndev); > > - > > - return ndev; > > -} > > - > > static struct dst_entry *rxe_find_route(struct rxe_dev *rxe, > > struct rxe_qp *qp, > > struct rxe_av *av) > > { > > + const struct ib_gid_attr *attr; > > struct dst_entry *dst = NULL; > > struct net_device *ndev; > > - ndev = rxe_netdev_from_av(rxe, qp->attr.port_num, av); > > + attr = rdma_get_gid_attr(&rxe->ib_dev, qp->attr.port_num, > > + av->grh.sgid_index); > > + if (IS_ERR(attr)) > Can unlikely is used here since this is in fast path? Please see include/linux/err.h. IS_ERR() already has unlikely statement built in. IS_ERR -> IS_ERR_VALUE -> unlikely. Thanks
Attachment:
signature.asc
Description: PGP signature