Message ID | 1706698552-25383-5-git-send-email-kotaranov@linux.microsoft.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | RDMA/mana_ib: Enable RNIC adapter and populate it with GIDs | expand |
> Subject: [PATCH rdma-next v1 4/5] RDMA/mana_ib: Enable RoCE on port 1 > > Set netdev and RoCEv2 flag to be used in GID population. > mana_ib is auxiliary device, thus we need GIDs of the master netdev. > > Signed-off-by: Konstantin Taranov <kotaranov@linux.microsoft.com> > --- > drivers/infiniband/hw/mana/device.c | 14 ++++++++++++++ > drivers/infiniband/hw/mana/main.c | 16 ++++++++++++---- > 2 files changed, 26 insertions(+), 4 deletions(-) > > diff --git a/drivers/infiniband/hw/mana/device.c > b/drivers/infiniband/hw/mana/device.c > index 11b0410..b9ff3fd 100644 > --- a/drivers/infiniband/hw/mana/device.c > +++ b/drivers/infiniband/hw/mana/device.c > @@ -53,6 +53,7 @@ static int mana_ib_probe(struct auxiliary_device *adev, { > struct mana_adev *madev = container_of(adev, struct mana_adev, > adev); > struct gdma_dev *mdev = madev->mdev; > + struct net_device *upper_ndev; > struct mana_context *mc; > struct mana_ib_dev *dev; > int ret; > @@ -79,6 +80,19 @@ static int mana_ib_probe(struct auxiliary_device *adev, > dev->ib_dev.num_comp_vectors = 1; > dev->ib_dev.dev.parent = mdev->gdma_context->dev; > > + rcu_read_lock(); /* required to get upper dev */ > + upper_ndev = netdev_master_upper_dev_get_rcu(mc->ports[0]); > + rcu_read_unlock(); Should call rcu_read_unlock() after upper_ndev is used and no longer needed, or it could be freed after someone calls rcu_synchronize(). > + if (!upper_ndev) { > + ibdev_err(&dev->ib_dev, "Failed to get master netdev"); > + goto free_ib_device; > + } > + ret = ib_device_set_netdev(&dev->ib_dev, upper_ndev, 1); > + if (ret) { > + ibdev_err(&dev->ib_dev, "Failed to set ib netdev, ret %d", ret); > + goto free_ib_device; > + } > + > ret = mana_gd_register_device(&mdev->gdma_context->mana_ib); > if (ret) { > ibdev_err(&dev->ib_dev, "Failed to register device, ret %d", diff - > -git a/drivers/infiniband/hw/mana/main.c b/drivers/infiniband/hw/mana/main.c > index 3e05a62..645abf3 100644 > --- a/drivers/infiniband/hw/mana/main.c > +++ b/drivers/infiniband/hw/mana/main.c > @@ -462,11 +462,19 @@ int mana_ib_mmap(struct ib_ucontext *ibcontext, > struct vm_area_struct *vma) int mana_ib_get_port_immutable(struct ib_device > *ibdev, u32 port_num, > struct ib_port_immutable *immutable) { > - /* > - * This version only support RAW_PACKET > - * other values need to be filled for other types > - */ > + struct mana_ib_dev *mdev = container_of(ibdev, struct mana_ib_dev, > ib_dev); > + struct ib_port_attr attr; > + int err; > + > + err = ib_query_port(ibdev, port_num, &attr); > + if (err) > + return err; > + > + immutable->pkey_tbl_len = attr.pkey_tbl_len; > + immutable->gid_tbl_len = attr.gid_tbl_len; > immutable->core_cap_flags = RDMA_CORE_PORT_RAW_PACKET; > + if (port_num == 1 && rnic_is_enabled(mdev)) > + immutable->core_cap_flags |= > RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP; > > return 0; > } > -- > 1.8.3.1
> > Subject: [PATCH rdma-next v1 4/5] RDMA/mana_ib: Enable RoCE on port 1 > > > > Set netdev and RoCEv2 flag to be used in GID population. > > mana_ib is auxiliary device, thus we need GIDs of the master netdev. > > > > Signed-off-by: Konstantin Taranov <kotaranov@linux.microsoft.com> > > --- > > drivers/infiniband/hw/mana/device.c | 14 ++++++++++++++ > > drivers/infiniband/hw/mana/main.c | 16 ++++++++++++---- > > 2 files changed, 26 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/infiniband/hw/mana/device.c > > b/drivers/infiniband/hw/mana/device.c > > index 11b0410..b9ff3fd 100644 > > --- a/drivers/infiniband/hw/mana/device.c > > +++ b/drivers/infiniband/hw/mana/device.c > > @@ -53,6 +53,7 @@ static int mana_ib_probe(struct auxiliary_device > *adev, { > > struct mana_adev *madev = container_of(adev, struct mana_adev, > > adev); > > struct gdma_dev *mdev = madev->mdev; > > + struct net_device *upper_ndev; > > struct mana_context *mc; > > struct mana_ib_dev *dev; > > int ret; > > @@ -79,6 +80,19 @@ static int mana_ib_probe(struct auxiliary_device > *adev, > > dev->ib_dev.num_comp_vectors = 1; > > dev->ib_dev.dev.parent = mdev->gdma_context->dev; > > > > + rcu_read_lock(); /* required to get upper dev */ > > + upper_ndev = netdev_master_upper_dev_get_rcu(mc->ports[0]); > > + rcu_read_unlock(); > > Should call rcu_read_unlock() after upper_ndev is used and no longer > needed, or it could be freed after someone calls rcu_synchronize(). > Thanks! I will unlock right after the netdev is set. I will address it in the v2. > > + if (!upper_ndev) { > > + ibdev_err(&dev->ib_dev, "Failed to get master netdev"); > > + goto free_ib_device; > > + } > > + ret = ib_device_set_netdev(&dev->ib_dev, upper_ndev, 1); > > + if (ret) { > > + ibdev_err(&dev->ib_dev, "Failed to set ib netdev, ret %d", > ret); > > + goto free_ib_device; > > + } > > + > > ret = mana_gd_register_device(&mdev->gdma_context->mana_ib); > > if (ret) { > > ibdev_err(&dev->ib_dev, "Failed to register device, ret %d", > diff - > > -git a/drivers/infiniband/hw/mana/main.c > > b/drivers/infiniband/hw/mana/main.c > > index 3e05a62..645abf3 100644 > > --- a/drivers/infiniband/hw/mana/main.c > > +++ b/drivers/infiniband/hw/mana/main.c > > @@ -462,11 +462,19 @@ int mana_ib_mmap(struct ib_ucontext > *ibcontext, > > struct vm_area_struct *vma) int mana_ib_get_port_immutable(struct > > ib_device *ibdev, u32 port_num, > > struct ib_port_immutable *immutable) { > > - /* > > - * This version only support RAW_PACKET > > - * other values need to be filled for other types > > - */ > > + struct mana_ib_dev *mdev = container_of(ibdev, struct > mana_ib_dev, > > ib_dev); > > + struct ib_port_attr attr; > > + int err; > > + > > + err = ib_query_port(ibdev, port_num, &attr); > > + if (err) > > + return err; > > + > > + immutable->pkey_tbl_len = attr.pkey_tbl_len; > > + immutable->gid_tbl_len = attr.gid_tbl_len; > > immutable->core_cap_flags = RDMA_CORE_PORT_RAW_PACKET; > > + if (port_num == 1 && rnic_is_enabled(mdev)) > > + immutable->core_cap_flags |= > > RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP; > > > > return 0; > > } > > -- > > 1.8.3.1
diff --git a/drivers/infiniband/hw/mana/device.c b/drivers/infiniband/hw/mana/device.c index 11b0410..b9ff3fd 100644 --- a/drivers/infiniband/hw/mana/device.c +++ b/drivers/infiniband/hw/mana/device.c @@ -53,6 +53,7 @@ static int mana_ib_probe(struct auxiliary_device *adev, { struct mana_adev *madev = container_of(adev, struct mana_adev, adev); struct gdma_dev *mdev = madev->mdev; + struct net_device *upper_ndev; struct mana_context *mc; struct mana_ib_dev *dev; int ret; @@ -79,6 +80,19 @@ static int mana_ib_probe(struct auxiliary_device *adev, dev->ib_dev.num_comp_vectors = 1; dev->ib_dev.dev.parent = mdev->gdma_context->dev; + rcu_read_lock(); /* required to get upper dev */ + upper_ndev = netdev_master_upper_dev_get_rcu(mc->ports[0]); + rcu_read_unlock(); + if (!upper_ndev) { + ibdev_err(&dev->ib_dev, "Failed to get master netdev"); + goto free_ib_device; + } + ret = ib_device_set_netdev(&dev->ib_dev, upper_ndev, 1); + if (ret) { + ibdev_err(&dev->ib_dev, "Failed to set ib netdev, ret %d", ret); + goto free_ib_device; + } + ret = mana_gd_register_device(&mdev->gdma_context->mana_ib); if (ret) { ibdev_err(&dev->ib_dev, "Failed to register device, ret %d", diff --git a/drivers/infiniband/hw/mana/main.c b/drivers/infiniband/hw/mana/main.c index 3e05a62..645abf3 100644 --- a/drivers/infiniband/hw/mana/main.c +++ b/drivers/infiniband/hw/mana/main.c @@ -462,11 +462,19 @@ int mana_ib_mmap(struct ib_ucontext *ibcontext, struct vm_area_struct *vma) int mana_ib_get_port_immutable(struct ib_device *ibdev, u32 port_num, struct ib_port_immutable *immutable) { - /* - * This version only support RAW_PACKET - * other values need to be filled for other types - */ + struct mana_ib_dev *mdev = container_of(ibdev, struct mana_ib_dev, ib_dev); + struct ib_port_attr attr; + int err; + + err = ib_query_port(ibdev, port_num, &attr); + if (err) + return err; + + immutable->pkey_tbl_len = attr.pkey_tbl_len; + immutable->gid_tbl_len = attr.gid_tbl_len; immutable->core_cap_flags = RDMA_CORE_PORT_RAW_PACKET; + if (port_num == 1 && rnic_is_enabled(mdev)) + immutable->core_cap_flags |= RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP; return 0; }
Set netdev and RoCEv2 flag to be used in GID population. mana_ib is auxiliary device, thus we need GIDs of the master netdev. Signed-off-by: Konstantin Taranov <kotaranov@linux.microsoft.com> --- drivers/infiniband/hw/mana/device.c | 14 ++++++++++++++ drivers/infiniband/hw/mana/main.c | 16 ++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-)