// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause /* * Copyright (c) 2024 Oracle. All rights reserved. */ /* #include <linux/module.h> #include <linux/slab.h> */ #include <linux/xarray.h> #include <linux/types.h> #include <linux/kref.h> #include <linux/completion.h> #include <linux/sunrpc/svc_rdma.h> #include <linux/sunrpc/rdma_rn.h> #include "xprt_rdma.h" #include <trace/events/rpcrdma.h> /* Per-ib_device private data for rpcrdma */ struct rpcrdma_device { … }; #define RPCRDMA_RD_F_REMOVING … static struct ib_client rpcrdma_ib_client; /* * Listeners have no associated device, so we never register them. * Note that ib_get_client_data() does not check if @device is * NULL for us. */ static struct rpcrdma_device *rpcrdma_get_client_data(struct ib_device *device) { … } /** * rpcrdma_rn_register - register to get device removal notifications * @device: device to monitor * @rn: notification object that wishes to be notified * @done: callback to notify caller of device removal * * Returns zero on success. The callback in rn_done is guaranteed * to be invoked when the device is removed, unless this notification * is unregistered first. * * On failure, a negative errno is returned. */ int rpcrdma_rn_register(struct ib_device *device, struct rpcrdma_notification *rn, void (*done)(struct rpcrdma_notification *rn)) { … } static void rpcrdma_rn_release(struct kref *kref) { … } /** * rpcrdma_rn_unregister - stop device removal notifications * @device: monitored device * @rn: notification object that no longer wishes to be notified */ void rpcrdma_rn_unregister(struct ib_device *device, struct rpcrdma_notification *rn) { … } /** * rpcrdma_add_one - ib_client device insertion callback * @device: device about to be inserted * * Returns zero on success. xprtrdma private data has been allocated * for this device. On failure, a negative errno is returned. */ static int rpcrdma_add_one(struct ib_device *device) { … } /** * rpcrdma_remove_one - ib_client device removal callback * @device: device about to be removed * @client_data: this module's private per-device data * * Upon return, all transports associated with @device have divested * themselves from IB hardware resources. */ static void rpcrdma_remove_one(struct ib_device *device, void *client_data) { … } static struct ib_client rpcrdma_ib_client = …; /** * rpcrdma_ib_client_unregister - unregister ib_client for xprtrdma * * cel: watch for orphaned rpcrdma_device objects on module unload */ void rpcrdma_ib_client_unregister(void) { … } /** * rpcrdma_ib_client_register - register ib_client for rpcrdma * * Returns zero on success, or a negative errno. */ int rpcrdma_ib_client_register(void) { … }