~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/net/devlink.h

Version: ~ [ linux-5.6-rc7 ] ~ [ linux-5.5.11 ] ~ [ linux-5.4.27 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.112 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.174 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.217 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.217 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.82 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * include/net/devlink.h - Network physical device Netlink interface
  3  * Copyright (c) 2016 Mellanox Technologies. All rights reserved.
  4  * Copyright (c) 2016 Jiri Pirko <jiri@mellanox.com>
  5  *
  6  * This program is free software; you can redistribute it and/or modify
  7  * it under the terms of the GNU General Public License as published by
  8  * the Free Software Foundation; either version 2 of the License, or
  9  * (at your option) any later version.
 10  */
 11 #ifndef _NET_DEVLINK_H_
 12 #define _NET_DEVLINK_H_
 13 
 14 #include <linux/device.h>
 15 #include <linux/slab.h>
 16 #include <linux/gfp.h>
 17 #include <linux/list.h>
 18 #include <linux/netdevice.h>
 19 #include <net/net_namespace.h>
 20 #include <uapi/linux/devlink.h>
 21 
 22 struct devlink_ops;
 23 
 24 struct devlink {
 25         struct list_head list;
 26         struct list_head port_list;
 27         const struct devlink_ops *ops;
 28         struct device *dev;
 29         possible_net_t _net;
 30         char priv[0] __aligned(NETDEV_ALIGN);
 31 };
 32 
 33 struct devlink_port {
 34         struct list_head list;
 35         struct devlink *devlink;
 36         unsigned index;
 37         bool registered;
 38         enum devlink_port_type type;
 39         enum devlink_port_type desired_type;
 40         void *type_dev;
 41         bool split;
 42         u32 split_group;
 43 };
 44 
 45 struct devlink_ops {
 46         size_t priv_size;
 47         int (*port_type_set)(struct devlink_port *devlink_port,
 48                              enum devlink_port_type port_type);
 49         int (*port_split)(struct devlink *devlink, unsigned int port_index,
 50                           unsigned int count);
 51         int (*port_unsplit)(struct devlink *devlink, unsigned int port_index);
 52 };
 53 
 54 static inline void *devlink_priv(struct devlink *devlink)
 55 {
 56         BUG_ON(!devlink);
 57         return &devlink->priv;
 58 }
 59 
 60 static inline struct devlink *priv_to_devlink(void *priv)
 61 {
 62         BUG_ON(!priv);
 63         return container_of(priv, struct devlink, priv);
 64 }
 65 
 66 struct ib_device;
 67 
 68 #if IS_ENABLED(CONFIG_NET_DEVLINK)
 69 
 70 struct devlink *devlink_alloc(const struct devlink_ops *ops, size_t priv_size);
 71 int devlink_register(struct devlink *devlink, struct device *dev);
 72 void devlink_unregister(struct devlink *devlink);
 73 void devlink_free(struct devlink *devlink);
 74 int devlink_port_register(struct devlink *devlink,
 75                           struct devlink_port *devlink_port,
 76                           unsigned int port_index);
 77 void devlink_port_unregister(struct devlink_port *devlink_port);
 78 void devlink_port_type_eth_set(struct devlink_port *devlink_port,
 79                                struct net_device *netdev);
 80 void devlink_port_type_ib_set(struct devlink_port *devlink_port,
 81                               struct ib_device *ibdev);
 82 void devlink_port_type_clear(struct devlink_port *devlink_port);
 83 void devlink_port_split_set(struct devlink_port *devlink_port,
 84                             u32 split_group);
 85 
 86 #else
 87 
 88 static inline struct devlink *devlink_alloc(const struct devlink_ops *ops,
 89                                             size_t priv_size)
 90 {
 91         return kzalloc(sizeof(struct devlink) + priv_size, GFP_KERNEL);
 92 }
 93 
 94 static inline int devlink_register(struct devlink *devlink, struct device *dev)
 95 {
 96         return 0;
 97 }
 98 
 99 static inline void devlink_unregister(struct devlink *devlink)
100 {
101 }
102 
103 static inline void devlink_free(struct devlink *devlink)
104 {
105         kfree(devlink);
106 }
107 
108 static inline int devlink_port_register(struct devlink *devlink,
109                                         struct devlink_port *devlink_port,
110                                         unsigned int port_index)
111 {
112         return 0;
113 }
114 
115 static inline void devlink_port_unregister(struct devlink_port *devlink_port)
116 {
117 }
118 
119 static inline void devlink_port_type_eth_set(struct devlink_port *devlink_port,
120                                              struct net_device *netdev)
121 {
122 }
123 
124 static inline void devlink_port_type_ib_set(struct devlink_port *devlink_port,
125                                             struct ib_device *ibdev)
126 {
127 }
128 
129 static inline void devlink_port_type_clear(struct devlink_port *devlink_port)
130 {
131 }
132 
133 static inline void devlink_port_split_set(struct devlink_port *devlink_port,
134                                           u32 split_group)
135 {
136 }
137 
138 #endif
139 
140 #endif /* _NET_DEVLINK_H_ */
141 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp