On Tue, Nov 27, 2018 at 07:37:03AM -0800, Steve Wise wrote: > Add support for the RDMA_NLDEV_CMD_NEWLINK/DELLINK messages which allow > dynamically adding new RXE links. Deprecate the old module options > for now. > > Cc: Moni Shoua <monis@xxxxxxxxxxxx> > Signed-off-by: Steve Wise <swise@xxxxxxxxxxxxxxxxxxxxx> > drivers/infiniband/sw/rxe/rxe.c | 62 +++++++++++++++++++++++++++++++++-- > drivers/infiniband/sw/rxe/rxe.h | 2 +- > drivers/infiniband/sw/rxe/rxe_net.c | 4 +-- > drivers/infiniband/sw/rxe/rxe_net.h | 2 +- > drivers/infiniband/sw/rxe/rxe_sysfs.c | 6 ++-- > drivers/infiniband/sw/rxe/rxe_verbs.c | 4 +-- > drivers/infiniband/sw/rxe/rxe_verbs.h | 2 +- > 7 files changed, 70 insertions(+), 12 deletions(-) > > diff --git a/drivers/infiniband/sw/rxe/rxe.c b/drivers/infiniband/sw/rxe/rxe.c > index 383e65c7bbc0..c09534b513ff 100644 > +++ b/drivers/infiniband/sw/rxe/rxe.c > @@ -31,6 +31,7 @@ > * SOFTWARE. > */ > > +#include <rdma/rdma_netlink.h> > #include <net/addrconf.h> > #include "rxe.h" > #include "rxe_loc.h" > @@ -308,7 +309,7 @@ void rxe_set_mtu(struct rxe_dev *rxe, unsigned int ndev_mtu) > /* called by ifc layer to create new rxe device. > * The caller should allocate memory for rxe by calling ib_alloc_device. > */ > -int rxe_add(struct rxe_dev *rxe, unsigned int mtu) > +int rxe_add(struct rxe_dev *rxe, unsigned int mtu, const char *ibdev_name) > { > int err; > > @@ -320,7 +321,7 @@ int rxe_add(struct rxe_dev *rxe, unsigned int mtu) > > rxe_set_mtu(rxe, mtu); > > - err = rxe_register_device(rxe); > + err = rxe_register_device(rxe, ibdev_name); > if (err) > goto err1; > > @@ -339,6 +340,59 @@ void rxe_remove(struct rxe_dev *rxe) > rxe_dev_put(rxe); > } > > +static struct ib_device *rxe_newlink(const char *ibdev_name, > + const char *ndev_name) > +{ > + struct net_device *ndev = NULL; > + struct rxe_dev *rxe; > + int err = 0; > + > + ndev = dev_get_by_name(&init_net, ndev_name); > + if (!ndev) { > + pr_err("interface %s not found\n", ndev_name); > + err = -ENODEV; > + goto err; > + } > + > + if (net_to_rxe(ndev)) { > + pr_err("already configured on %s\n", ndev_name); > + err = -EEXIST; > + goto err; > + } > + > + rxe = rxe_net_add(ibdev_name, ndev); > + if (!rxe) { > + pr_err("failed to add %s\n", ndev_name); > + err = -EINVAL; > + goto err; > + } > + > + if (netif_running(ndev) && netif_carrier_ok(ndev)) > + rxe_port_up(rxe); > + else > + rxe_port_down(rxe); > + pr_info("added %s to %s\n", rxe->ib_dev.name, ndev->name); > +err: > + if (ndev) > + dev_put(ndev); > + return err ? ERR_PTR(err) : &rxe->ib_dev; > +} > + > +static int rxe_dellink(struct ib_device *device) > +{ > + struct rxe_dev *rxe = to_rdev(device); > + > + list_del(&rxe->list); > + rxe_remove(rxe); New code still has to be written write correct locking, so this needs locking and the pattern I showed earlier, it must deal with the new races it creates. Jason