xref: /linux/drivers/net/ethernet/intel/ixd/ixd_devlink.h (revision 91ec2035134982b98fab0609a9fd8480e8217dc1)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2025, Intel Corporation. */
3 
4 #ifndef _IXD_DEVLINK_H_
5 #define _IXD_DEVLINK_H_
6 
7 #include <net/devlink.h>
8 
9 #include "ixd.h"
10 
11 struct ixd_adapter *ixd_adapter_alloc(struct device *dev);
12 
13 /**
14  * ixd_devlink_free - teardown the devlink
15  * @adapter: the adapter structure to free
16  *
17  */
ixd_devlink_free(struct ixd_adapter * adapter)18 static inline void ixd_devlink_free(struct ixd_adapter *adapter)
19 {
20 	struct devlink *devlink = priv_to_devlink(adapter);
21 
22 	devlink_free(devlink);
23 }
24 
25 /**
26  * ixd_devlink_unregister - Unregister devlink for this adapter.
27  * @adapter: the adapter structure to cleanup
28  *
29  * Init task must be completed or cancelled beforehand.
30  */
ixd_devlink_unregister(struct ixd_adapter * adapter)31 static inline void ixd_devlink_unregister(struct ixd_adapter *adapter)
32 {
33 	if (!adapter->init_task.success)
34 		return;
35 
36 	devlink_unregister(priv_to_devlink(adapter));
37 }
38 
39 /**
40  * ixd_devlink_register - Register devlink interface for this adapter
41  * @adapter: pointer to ixd adapter structure to be associated with devlink
42  *
43  * Register the devlink instance associated with this adapter
44  */
ixd_devlink_register(struct ixd_adapter * adapter)45 static inline void ixd_devlink_register(struct ixd_adapter *adapter)
46 {
47 	devlink_register(priv_to_devlink(adapter));
48 }
49 
50 #endif /* _IXD_DEVLINK_H_ */
51