Skip to content

Commit

Permalink
rdma_rxe: Use netlink messages to add/delete links
Browse files Browse the repository at this point in the history
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@mellanox.com>
Reviewed-by: Yanjun Zhu <yanjun.zhu@oracle.com>
Signed-off-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
Steve Wise authored and Jason Gunthorpe committed Feb 20, 2019
1 parent 3856ec4 commit 66920e1
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 13 deletions.
36 changes: 34 additions & 2 deletions drivers/infiniband/sw/rxe/rxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* SOFTWARE.
*/

#include <rdma/rdma_netlink.h>
#include <net/addrconf.h>
#include "rxe.h"
#include "rxe_loc.h"
Expand Down Expand Up @@ -301,7 +302,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;

Expand All @@ -311,9 +312,36 @@ int rxe_add(struct rxe_dev *rxe, unsigned int mtu)

rxe_set_mtu(rxe, mtu);

return rxe_register_device(rxe);
return rxe_register_device(rxe, ibdev_name);
}

static int rxe_newlink(const char *ibdev_name, struct net_device *ndev)
{
struct rxe_dev *exists;
int err = 0;

exists = rxe_get_dev_from_net(ndev);
if (exists) {
ib_device_put(&exists->ib_dev);
pr_err("already configured on %s\n", ndev->name);
err = -EEXIST;
goto err;
}

err = rxe_net_add(ibdev_name, ndev);
if (err) {
pr_err("failed to add %s\n", ndev->name);
goto err;
}
err:
return err;
}

static struct rdma_link_ops rxe_link_ops = {
.type = "rxe",
.newlink = rxe_newlink,
};

static int __init rxe_module_init(void)
{
int err;
Expand All @@ -329,12 +357,14 @@ static int __init rxe_module_init(void)
if (err)
return err;

rdma_link_register(&rxe_link_ops);
pr_info("loaded\n");
return 0;
}

static void __exit rxe_module_exit(void)
{
rdma_link_unregister(&rxe_link_ops);
ib_unregister_driver(RDMA_DRIVER_RXE);
rxe_net_exit();
rxe_cache_exit();
Expand All @@ -344,3 +374,5 @@ static void __exit rxe_module_exit(void)

late_initcall(rxe_module_init);
module_exit(rxe_module_exit);

MODULE_ALIAS_RDMA_LINK("rxe");
2 changes: 1 addition & 1 deletion drivers/infiniband/sw/rxe/rxe.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static inline u32 rxe_crc32(struct rxe_dev *rxe,

void rxe_set_mtu(struct rxe_dev *rxe, unsigned int dev_mtu);

int rxe_add(struct rxe_dev *rxe, unsigned int mtu);
int rxe_add(struct rxe_dev *rxe, unsigned int mtu, const char *ibdev_name);

void rxe_rcv(struct sk_buff *skb);

Expand Down
4 changes: 2 additions & 2 deletions drivers/infiniband/sw/rxe/rxe_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ enum rdma_link_layer rxe_link_layer(struct rxe_dev *rxe, unsigned int port_num)
return IB_LINK_LAYER_ETHERNET;
}

int rxe_net_add(struct net_device *ndev)
int rxe_net_add(const char *ibdev_name, struct net_device *ndev)
{
int err;
struct rxe_dev *rxe = NULL;
Expand All @@ -528,7 +528,7 @@ int rxe_net_add(struct net_device *ndev)

rxe->ndev = ndev;

err = rxe_add(rxe, ndev->mtu);
err = rxe_add(rxe, ndev->mtu, ibdev_name);
if (err) {
ib_dealloc_device(&rxe->ib_dev);
return err;
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/sw/rxe/rxe_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct rxe_recv_sockets {
struct socket *sk6;
};

int rxe_net_add(struct net_device *ndev);
int rxe_net_add(const char *ibdev_name, struct net_device *ndev);

int rxe_net_init(void);
void rxe_net_exit(void);
Expand Down
3 changes: 2 additions & 1 deletion drivers/infiniband/sw/rxe/rxe_param.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ enum rxe_device_param {
| IB_DEVICE_SYS_IMAGE_GUID
| IB_DEVICE_RC_RNR_NAK_GEN
| IB_DEVICE_SRQ_RESIZE
| IB_DEVICE_MEM_MGT_EXTENSIONS,
| IB_DEVICE_MEM_MGT_EXTENSIONS
| IB_DEVICE_ALLOW_USER_UNREG,
RXE_MAX_SGE = 32,
RXE_MAX_SGE_RD = 32,
RXE_MAX_CQ = 16384,
Expand Down
6 changes: 3 additions & 3 deletions drivers/infiniband/sw/rxe/rxe_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static int rxe_param_set_add(const char *val, const struct kernel_param *kp)
goto err;
}

err = rxe_net_add(ndev);
err = rxe_net_add("rxe%d", ndev);
if (err) {
pr_err("failed to add %s\n", intf);
goto err;
Expand Down Expand Up @@ -130,6 +130,6 @@ static const struct kernel_param_ops rxe_remove_ops = {
};

module_param_cb(add, &rxe_add_ops, NULL, 0200);
MODULE_PARM_DESC(add, "Create RXE device over network interface");
MODULE_PARM_DESC(add, "DEPRECATED. Create RXE device over network interface");
module_param_cb(remove, &rxe_remove_ops, NULL, 0200);
MODULE_PARM_DESC(remove, "Remove RXE device over network interface");
MODULE_PARM_DESC(remove, "DEPRECATED. Remove RXE device over network interface");
4 changes: 2 additions & 2 deletions drivers/infiniband/sw/rxe/rxe_verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ static const struct ib_device_ops rxe_dev_ops = {
INIT_RDMA_OBJ_SIZE(ib_pd, rxe_pd, ibpd),
};

int rxe_register_device(struct rxe_dev *rxe)
int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name)
{
int err;
struct ib_device *dev = &rxe->ib_dev;
Expand Down Expand Up @@ -1251,7 +1251,7 @@ int rxe_register_device(struct rxe_dev *rxe)

rdma_set_device_sysfs_group(dev, &rxe_attr_group);
dev->driver_id = RDMA_DRIVER_RXE;
err = ib_register_device(dev, "rxe%d");
err = ib_register_device(dev, ibdev_name);
if (err)
pr_warn("%s failed with error %d\n", __func__, err);

Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/sw/rxe/rxe_verbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ static inline struct rxe_mem *to_rmw(struct ib_mw *mw)
return mw ? container_of(mw, struct rxe_mem, ibmw) : NULL;
}

int rxe_register_device(struct rxe_dev *rxe);
int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name);

void rxe_mc_cleanup(struct rxe_pool_entry *arg);

Expand Down

0 comments on commit 66920e1

Please sign in to comment.