Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Jiri Pirko | 007f790 | 2014-11-28 14:34:17 +0100 | [diff] [blame] | 2 | /* |
| 3 | * include/net/switchdev.h - Switch device API |
Jiri Pirko | 7ea6eb3 | 2015-09-24 10:02:41 +0200 | [diff] [blame] | 4 | * Copyright (c) 2014-2015 Jiri Pirko <jiri@resnulli.us> |
Scott Feldman | f8f2147 | 2015-03-09 13:59:09 -0700 | [diff] [blame] | 5 | * Copyright (c) 2014-2015 Scott Feldman <sfeldma@gmail.com> |
Jiri Pirko | 007f790 | 2014-11-28 14:34:17 +0100 | [diff] [blame] | 6 | */ |
| 7 | #ifndef _LINUX_SWITCHDEV_H_ |
| 8 | #define _LINUX_SWITCHDEV_H_ |
| 9 | |
| 10 | #include <linux/netdevice.h> |
Jiri Pirko | 03bf0c2 | 2015-01-15 23:49:36 +0100 | [diff] [blame] | 11 | #include <linux/notifier.h> |
Jiri Pirko | 7ea6eb3 | 2015-09-24 10:02:41 +0200 | [diff] [blame] | 12 | #include <linux/list.h> |
Jiri Pirko | 850d0cb | 2015-10-14 19:40:51 +0200 | [diff] [blame] | 13 | #include <net/ip_fib.h> |
Jiri Pirko | 03bf0c2 | 2015-01-15 23:49:36 +0100 | [diff] [blame] | 14 | |
Scott Feldman | 3094333 | 2015-05-10 09:47:48 -0700 | [diff] [blame] | 15 | #define SWITCHDEV_F_NO_RECURSE BIT(0) |
Scott Feldman | 464314e | 2015-10-08 19:23:18 -0700 | [diff] [blame] | 16 | #define SWITCHDEV_F_SKIP_EOPNOTSUPP BIT(1) |
Jiri Pirko | 0bc05d5 | 2015-10-14 19:40:50 +0200 | [diff] [blame] | 17 | #define SWITCHDEV_F_DEFER BIT(2) |
Scott Feldman | 3094333 | 2015-05-10 09:47:48 -0700 | [diff] [blame] | 18 | |
Jiri Pirko | 7ea6eb3 | 2015-09-24 10:02:41 +0200 | [diff] [blame] | 19 | struct switchdev_trans { |
Jiri Pirko | f623ab7 | 2015-09-24 10:02:49 +0200 | [diff] [blame] | 20 | bool ph_prepare; |
Jiri Pirko | 7ea6eb3 | 2015-09-24 10:02:41 +0200 | [diff] [blame] | 21 | }; |
| 22 | |
Jiri Pirko | 8bdb427 | 2015-09-24 10:02:43 +0200 | [diff] [blame] | 23 | static inline bool switchdev_trans_ph_prepare(struct switchdev_trans *trans) |
| 24 | { |
Jiri Pirko | f623ab7 | 2015-09-24 10:02:49 +0200 | [diff] [blame] | 25 | return trans && trans->ph_prepare; |
Jiri Pirko | 8bdb427 | 2015-09-24 10:02:43 +0200 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | static inline bool switchdev_trans_ph_commit(struct switchdev_trans *trans) |
| 29 | { |
Jiri Pirko | f623ab7 | 2015-09-24 10:02:49 +0200 | [diff] [blame] | 30 | return trans && !trans->ph_prepare; |
Jiri Pirko | 8bdb427 | 2015-09-24 10:02:43 +0200 | [diff] [blame] | 31 | } |
| 32 | |
Scott Feldman | 3094333 | 2015-05-10 09:47:48 -0700 | [diff] [blame] | 33 | enum switchdev_attr_id { |
Jiri Pirko | 1f86839 | 2015-10-01 11:03:42 +0200 | [diff] [blame] | 34 | SWITCHDEV_ATTR_ID_UNDEFINED, |
Jiri Pirko | 1f86839 | 2015-10-01 11:03:42 +0200 | [diff] [blame] | 35 | SWITCHDEV_ATTR_ID_PORT_STP_STATE, |
| 36 | SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS, |
Florian Fainelli | 746dc18 | 2019-02-20 16:58:19 -0800 | [diff] [blame] | 37 | SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS, |
Nogah Frankel | 6d54964 | 2017-02-09 14:54:42 +0100 | [diff] [blame] | 38 | SWITCHDEV_ATTR_ID_PORT_MROUTER, |
Scott Feldman | f55ac58 | 2015-10-08 19:23:17 -0700 | [diff] [blame] | 39 | SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME, |
Elad Raz | 81435c3 | 2016-01-06 13:01:05 +0100 | [diff] [blame] | 40 | SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING, |
Nogah Frankel | 147c1e9 | 2017-02-09 14:54:40 +0100 | [diff] [blame] | 41 | SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED, |
Yotam Gigi | 7704142 | 2017-10-09 11:15:31 +0200 | [diff] [blame] | 42 | SWITCHDEV_ATTR_ID_BRIDGE_MROUTER, |
Horatiu Vultur | c284b54 | 2020-04-26 15:22:03 +0200 | [diff] [blame] | 43 | #if IS_ENABLED(CONFIG_BRIDGE_MRP) |
| 44 | SWITCHDEV_ATTR_ID_MRP_PORT_STATE, |
| 45 | SWITCHDEV_ATTR_ID_MRP_PORT_ROLE, |
| 46 | #endif |
Scott Feldman | 3094333 | 2015-05-10 09:47:48 -0700 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | struct switchdev_attr { |
Ido Schimmel | 6ff64f6 | 2015-12-15 16:03:35 +0100 | [diff] [blame] | 50 | struct net_device *orig_dev; |
Scott Feldman | 3094333 | 2015-05-10 09:47:48 -0700 | [diff] [blame] | 51 | enum switchdev_attr_id id; |
Scott Feldman | 3094333 | 2015-05-10 09:47:48 -0700 | [diff] [blame] | 52 | u32 flags; |
Elad Raz | 7ceb2af | 2016-04-21 12:52:43 +0200 | [diff] [blame] | 53 | void *complete_priv; |
| 54 | void (*complete)(struct net_device *dev, int err, void *priv); |
Scott Feldman | f8e20a9 | 2015-05-10 09:47:49 -0700 | [diff] [blame] | 55 | union { |
Scott Feldman | 3563606 | 2015-05-10 09:47:51 -0700 | [diff] [blame] | 56 | u8 stp_state; /* PORT_STP_STATE */ |
Florian Fainelli | 746dc18 | 2019-02-20 16:58:19 -0800 | [diff] [blame] | 57 | unsigned long brport_flags; /* PORT_{PRE}_BRIDGE_FLAGS */ |
Nogah Frankel | 6d54964 | 2017-02-09 14:54:42 +0100 | [diff] [blame] | 58 | bool mrouter; /* PORT_MROUTER */ |
Vivien Didelot | eabfdda | 2016-07-18 15:02:06 -0400 | [diff] [blame] | 59 | clock_t ageing_time; /* BRIDGE_AGEING_TIME */ |
Elad Raz | 81435c3 | 2016-01-06 13:01:05 +0100 | [diff] [blame] | 60 | bool vlan_filtering; /* BRIDGE_VLAN_FILTERING */ |
Nogah Frankel | 147c1e9 | 2017-02-09 14:54:40 +0100 | [diff] [blame] | 61 | bool mc_disabled; /* MC_DISABLED */ |
Horatiu Vultur | c284b54 | 2020-04-26 15:22:03 +0200 | [diff] [blame] | 62 | #if IS_ENABLED(CONFIG_BRIDGE_MRP) |
| 63 | u8 mrp_port_state; /* MRP_PORT_STATE */ |
| 64 | u8 mrp_port_role; /* MRP_PORT_ROLE */ |
Horatiu Vultur | c284b54 | 2020-04-26 15:22:03 +0200 | [diff] [blame] | 65 | #endif |
Scott Feldman | 42275bd | 2015-05-13 11:16:50 -0700 | [diff] [blame] | 66 | } u; |
Scott Feldman | 3094333 | 2015-05-10 09:47:48 -0700 | [diff] [blame] | 67 | }; |
| 68 | |
Scott Feldman | 491d0f1 | 2015-05-10 09:47:52 -0700 | [diff] [blame] | 69 | enum switchdev_obj_id { |
Jiri Pirko | 57d8083 | 2015-10-01 11:03:41 +0200 | [diff] [blame] | 70 | SWITCHDEV_OBJ_ID_UNDEFINED, |
| 71 | SWITCHDEV_OBJ_ID_PORT_VLAN, |
Elad Raz | 4d41e125 | 2016-01-10 21:06:22 +0100 | [diff] [blame] | 72 | SWITCHDEV_OBJ_ID_PORT_MDB, |
Andrew Lunn | 47d5b6d | 2017-11-09 23:10:59 +0100 | [diff] [blame] | 73 | SWITCHDEV_OBJ_ID_HOST_MDB, |
Horatiu Vultur | c284b54 | 2020-04-26 15:22:03 +0200 | [diff] [blame] | 74 | #if IS_ENABLED(CONFIG_BRIDGE_MRP) |
| 75 | SWITCHDEV_OBJ_ID_MRP, |
| 76 | SWITCHDEV_OBJ_ID_RING_TEST_MRP, |
| 77 | SWITCHDEV_OBJ_ID_RING_ROLE_MRP, |
| 78 | SWITCHDEV_OBJ_ID_RING_STATE_MRP, |
Horatiu Vultur | cf7c527 | 2020-07-14 09:34:47 +0200 | [diff] [blame^] | 79 | SWITCHDEV_OBJ_ID_IN_TEST_MRP, |
| 80 | SWITCHDEV_OBJ_ID_IN_ROLE_MRP, |
| 81 | SWITCHDEV_OBJ_ID_IN_STATE_MRP, |
| 82 | |
Horatiu Vultur | c284b54 | 2020-04-26 15:22:03 +0200 | [diff] [blame] | 83 | #endif |
Scott Feldman | 491d0f1 | 2015-05-10 09:47:52 -0700 | [diff] [blame] | 84 | }; |
| 85 | |
Jiri Pirko | 648b4a9 | 2015-10-01 11:03:45 +0200 | [diff] [blame] | 86 | struct switchdev_obj { |
Ido Schimmel | 6ff64f6 | 2015-12-15 16:03:35 +0100 | [diff] [blame] | 87 | struct net_device *orig_dev; |
Jiri Pirko | 9e8f4a5 | 2015-10-01 11:03:46 +0200 | [diff] [blame] | 88 | enum switchdev_obj_id id; |
Jiri Pirko | 4d429c5 | 2015-10-14 19:40:52 +0200 | [diff] [blame] | 89 | u32 flags; |
Elad Raz | 7ceb2af | 2016-04-21 12:52:43 +0200 | [diff] [blame] | 90 | void *complete_priv; |
| 91 | void (*complete)(struct net_device *dev, int err, void *priv); |
Jiri Pirko | 648b4a9 | 2015-10-01 11:03:45 +0200 | [diff] [blame] | 92 | }; |
| 93 | |
Jiri Pirko | 57d8083 | 2015-10-01 11:03:41 +0200 | [diff] [blame] | 94 | /* SWITCHDEV_OBJ_ID_PORT_VLAN */ |
Jiri Pirko | 8f24f30 | 2015-10-01 11:03:43 +0200 | [diff] [blame] | 95 | struct switchdev_obj_port_vlan { |
Jiri Pirko | 648b4a9 | 2015-10-01 11:03:45 +0200 | [diff] [blame] | 96 | struct switchdev_obj obj; |
Vivien Didelot | 44bbcf5 | 2015-09-29 12:07:18 -0400 | [diff] [blame] | 97 | u16 flags; |
| 98 | u16 vid_begin; |
| 99 | u16 vid_end; |
| 100 | }; |
| 101 | |
Petr Machata | ec394af | 2018-11-22 23:28:07 +0000 | [diff] [blame] | 102 | #define SWITCHDEV_OBJ_PORT_VLAN(OBJ) \ |
| 103 | container_of((OBJ), struct switchdev_obj_port_vlan, obj) |
Jiri Pirko | 648b4a9 | 2015-10-01 11:03:45 +0200 | [diff] [blame] | 104 | |
Elad Raz | 4d41e125 | 2016-01-10 21:06:22 +0100 | [diff] [blame] | 105 | /* SWITCHDEV_OBJ_ID_PORT_MDB */ |
| 106 | struct switchdev_obj_port_mdb { |
| 107 | struct switchdev_obj obj; |
| 108 | unsigned char addr[ETH_ALEN]; |
| 109 | u16 vid; |
| 110 | }; |
| 111 | |
Petr Machata | ec394af | 2018-11-22 23:28:07 +0000 | [diff] [blame] | 112 | #define SWITCHDEV_OBJ_PORT_MDB(OBJ) \ |
| 113 | container_of((OBJ), struct switchdev_obj_port_mdb, obj) |
Elad Raz | 4d41e125 | 2016-01-10 21:06:22 +0100 | [diff] [blame] | 114 | |
Horatiu Vultur | c284b54 | 2020-04-26 15:22:03 +0200 | [diff] [blame] | 115 | |
| 116 | #if IS_ENABLED(CONFIG_BRIDGE_MRP) |
| 117 | /* SWITCHDEV_OBJ_ID_MRP */ |
| 118 | struct switchdev_obj_mrp { |
| 119 | struct switchdev_obj obj; |
| 120 | struct net_device *p_port; |
| 121 | struct net_device *s_port; |
| 122 | u32 ring_id; |
Horatiu Vultur | 4b3a61b | 2020-05-30 18:09:47 +0000 | [diff] [blame] | 123 | u16 prio; |
Horatiu Vultur | c284b54 | 2020-04-26 15:22:03 +0200 | [diff] [blame] | 124 | }; |
| 125 | |
| 126 | #define SWITCHDEV_OBJ_MRP(OBJ) \ |
| 127 | container_of((OBJ), struct switchdev_obj_mrp, obj) |
| 128 | |
| 129 | /* SWITCHDEV_OBJ_ID_RING_TEST_MRP */ |
| 130 | struct switchdev_obj_ring_test_mrp { |
| 131 | struct switchdev_obj obj; |
| 132 | /* The value is in us and a value of 0 represents to stop */ |
| 133 | u32 interval; |
| 134 | u8 max_miss; |
| 135 | u32 ring_id; |
| 136 | u32 period; |
Horatiu Vultur | c6676e7 | 2020-05-30 18:09:48 +0000 | [diff] [blame] | 137 | bool monitor; |
Horatiu Vultur | c284b54 | 2020-04-26 15:22:03 +0200 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | #define SWITCHDEV_OBJ_RING_TEST_MRP(OBJ) \ |
| 141 | container_of((OBJ), struct switchdev_obj_ring_test_mrp, obj) |
| 142 | |
| 143 | /* SWICHDEV_OBJ_ID_RING_ROLE_MRP */ |
| 144 | struct switchdev_obj_ring_role_mrp { |
| 145 | struct switchdev_obj obj; |
| 146 | u8 ring_role; |
| 147 | u32 ring_id; |
| 148 | }; |
| 149 | |
| 150 | #define SWITCHDEV_OBJ_RING_ROLE_MRP(OBJ) \ |
| 151 | container_of((OBJ), struct switchdev_obj_ring_role_mrp, obj) |
| 152 | |
| 153 | struct switchdev_obj_ring_state_mrp { |
| 154 | struct switchdev_obj obj; |
| 155 | u8 ring_state; |
| 156 | u32 ring_id; |
| 157 | }; |
| 158 | |
| 159 | #define SWITCHDEV_OBJ_RING_STATE_MRP(OBJ) \ |
| 160 | container_of((OBJ), struct switchdev_obj_ring_state_mrp, obj) |
| 161 | |
Horatiu Vultur | cf7c527 | 2020-07-14 09:34:47 +0200 | [diff] [blame^] | 162 | /* SWITCHDEV_OBJ_ID_IN_TEST_MRP */ |
| 163 | struct switchdev_obj_in_test_mrp { |
| 164 | struct switchdev_obj obj; |
| 165 | /* The value is in us and a value of 0 represents to stop */ |
| 166 | u32 interval; |
| 167 | u32 in_id; |
| 168 | u32 period; |
| 169 | u8 max_miss; |
| 170 | }; |
| 171 | |
| 172 | #define SWITCHDEV_OBJ_IN_TEST_MRP(OBJ) \ |
| 173 | container_of((OBJ), struct switchdev_obj_in_test_mrp, obj) |
| 174 | |
| 175 | /* SWICHDEV_OBJ_ID_IN_ROLE_MRP */ |
| 176 | struct switchdev_obj_in_role_mrp { |
| 177 | struct switchdev_obj obj; |
| 178 | struct net_device *i_port; |
| 179 | u32 ring_id; |
| 180 | u16 in_id; |
| 181 | u8 in_role; |
| 182 | }; |
| 183 | |
| 184 | #define SWITCHDEV_OBJ_IN_ROLE_MRP(OBJ) \ |
| 185 | container_of((OBJ), struct switchdev_obj_in_role_mrp, obj) |
| 186 | |
| 187 | struct switchdev_obj_in_state_mrp { |
| 188 | struct switchdev_obj obj; |
| 189 | u32 in_id; |
| 190 | u8 in_state; |
| 191 | }; |
| 192 | |
| 193 | #define SWITCHDEV_OBJ_IN_STATE_MRP(OBJ) \ |
| 194 | container_of((OBJ), struct switchdev_obj_in_state_mrp, obj) |
| 195 | |
Horatiu Vultur | c284b54 | 2020-04-26 15:22:03 +0200 | [diff] [blame] | 196 | #endif |
| 197 | |
Jiri Pirko | 648b4a9 | 2015-10-01 11:03:45 +0200 | [diff] [blame] | 198 | typedef int switchdev_obj_dump_cb_t(struct switchdev_obj *obj); |
| 199 | |
Jiri Pirko | ebb9a03 | 2015-05-10 09:47:46 -0700 | [diff] [blame] | 200 | enum switchdev_notifier_type { |
Arkadi Sharshevsky | 6b26b51 | 2017-06-08 08:44:14 +0200 | [diff] [blame] | 201 | SWITCHDEV_FDB_ADD_TO_BRIDGE = 1, |
| 202 | SWITCHDEV_FDB_DEL_TO_BRIDGE, |
| 203 | SWITCHDEV_FDB_ADD_TO_DEVICE, |
| 204 | SWITCHDEV_FDB_DEL_TO_DEVICE, |
Arkadi Sharshevsky | 9fe8bce | 2017-06-08 08:44:15 +0200 | [diff] [blame] | 205 | SWITCHDEV_FDB_OFFLOADED, |
Petr Machata | 9a99735 | 2018-10-17 08:53:22 +0000 | [diff] [blame] | 206 | |
Petr Machata | aa4efe2 | 2018-11-22 23:28:38 +0000 | [diff] [blame] | 207 | SWITCHDEV_PORT_OBJ_ADD, /* Blocking. */ |
| 208 | SWITCHDEV_PORT_OBJ_DEL, /* Blocking. */ |
Florian Fainelli | 1cb33af | 2019-02-27 11:44:25 -0800 | [diff] [blame] | 209 | SWITCHDEV_PORT_ATTR_SET, /* May be blocking . */ |
Petr Machata | aa4efe2 | 2018-11-22 23:28:38 +0000 | [diff] [blame] | 210 | |
Petr Machata | 5728ae0 | 2018-11-21 08:02:39 +0000 | [diff] [blame] | 211 | SWITCHDEV_VXLAN_FDB_ADD_TO_BRIDGE, |
| 212 | SWITCHDEV_VXLAN_FDB_DEL_TO_BRIDGE, |
Petr Machata | 9a99735 | 2018-10-17 08:53:22 +0000 | [diff] [blame] | 213 | SWITCHDEV_VXLAN_FDB_ADD_TO_DEVICE, |
| 214 | SWITCHDEV_VXLAN_FDB_DEL_TO_DEVICE, |
Petr Machata | 0efe117 | 2018-10-17 08:53:26 +0000 | [diff] [blame] | 215 | SWITCHDEV_VXLAN_FDB_OFFLOADED, |
Jiri Pirko | 3aeb661 | 2015-01-15 23:49:37 +0100 | [diff] [blame] | 216 | }; |
| 217 | |
Jiri Pirko | ebb9a03 | 2015-05-10 09:47:46 -0700 | [diff] [blame] | 218 | struct switchdev_notifier_info { |
Jiri Pirko | 03bf0c2 | 2015-01-15 23:49:36 +0100 | [diff] [blame] | 219 | struct net_device *dev; |
Petr Machata | 479c86d | 2018-12-12 17:02:54 +0000 | [diff] [blame] | 220 | struct netlink_ext_ack *extack; |
Jiri Pirko | 03bf0c2 | 2015-01-15 23:49:36 +0100 | [diff] [blame] | 221 | }; |
| 222 | |
Jiri Pirko | ebb9a03 | 2015-05-10 09:47:46 -0700 | [diff] [blame] | 223 | struct switchdev_notifier_fdb_info { |
| 224 | struct switchdev_notifier_info info; /* must be first */ |
Jiri Pirko | 3aeb661 | 2015-01-15 23:49:37 +0100 | [diff] [blame] | 225 | const unsigned char *addr; |
| 226 | u16 vid; |
Ido Schimmel | e9ba0fb | 2018-10-17 08:53:29 +0000 | [diff] [blame] | 227 | u8 added_by_user:1, |
| 228 | offloaded:1; |
Jiri Pirko | 3aeb661 | 2015-01-15 23:49:37 +0100 | [diff] [blame] | 229 | }; |
| 230 | |
Petr Machata | aa4efe2 | 2018-11-22 23:28:38 +0000 | [diff] [blame] | 231 | struct switchdev_notifier_port_obj_info { |
| 232 | struct switchdev_notifier_info info; /* must be first */ |
| 233 | const struct switchdev_obj *obj; |
| 234 | struct switchdev_trans *trans; |
| 235 | bool handled; |
| 236 | }; |
| 237 | |
Florian Fainelli | 1cb33af | 2019-02-27 11:44:25 -0800 | [diff] [blame] | 238 | struct switchdev_notifier_port_attr_info { |
| 239 | struct switchdev_notifier_info info; /* must be first */ |
| 240 | const struct switchdev_attr *attr; |
| 241 | struct switchdev_trans *trans; |
| 242 | bool handled; |
| 243 | }; |
| 244 | |
Jiri Pirko | 03bf0c2 | 2015-01-15 23:49:36 +0100 | [diff] [blame] | 245 | static inline struct net_device * |
Jiri Pirko | ebb9a03 | 2015-05-10 09:47:46 -0700 | [diff] [blame] | 246 | switchdev_notifier_info_to_dev(const struct switchdev_notifier_info *info) |
Jiri Pirko | 03bf0c2 | 2015-01-15 23:49:36 +0100 | [diff] [blame] | 247 | { |
| 248 | return info->dev; |
| 249 | } |
Jiri Pirko | 007f790 | 2014-11-28 14:34:17 +0100 | [diff] [blame] | 250 | |
Petr Machata | 479c86d | 2018-12-12 17:02:54 +0000 | [diff] [blame] | 251 | static inline struct netlink_ext_ack * |
| 252 | switchdev_notifier_info_to_extack(const struct switchdev_notifier_info *info) |
| 253 | { |
| 254 | return info->extack; |
| 255 | } |
| 256 | |
Jiri Pirko | 007f790 | 2014-11-28 14:34:17 +0100 | [diff] [blame] | 257 | #ifdef CONFIG_NET_SWITCHDEV |
| 258 | |
Jiri Pirko | 793f401 | 2015-10-14 19:40:48 +0200 | [diff] [blame] | 259 | void switchdev_deferred_process(void); |
Scott Feldman | 3094333 | 2015-05-10 09:47:48 -0700 | [diff] [blame] | 260 | int switchdev_port_attr_set(struct net_device *dev, |
Jiri Pirko | f7fadf3 | 2015-10-14 19:40:49 +0200 | [diff] [blame] | 261 | const struct switchdev_attr *attr); |
Jiri Pirko | 9e8f4a5 | 2015-10-01 11:03:46 +0200 | [diff] [blame] | 262 | int switchdev_port_obj_add(struct net_device *dev, |
Petr Machata | 69b7320 | 2018-12-12 17:02:52 +0000 | [diff] [blame] | 263 | const struct switchdev_obj *obj, |
| 264 | struct netlink_ext_ack *extack); |
Jiri Pirko | 9e8f4a5 | 2015-10-01 11:03:46 +0200 | [diff] [blame] | 265 | int switchdev_port_obj_del(struct net_device *dev, |
Jiri Pirko | 648b4a9 | 2015-10-01 11:03:45 +0200 | [diff] [blame] | 266 | const struct switchdev_obj *obj); |
Petr Machata | a93e3b1 | 2018-11-22 23:28:25 +0000 | [diff] [blame] | 267 | |
Jiri Pirko | ebb9a03 | 2015-05-10 09:47:46 -0700 | [diff] [blame] | 268 | int register_switchdev_notifier(struct notifier_block *nb); |
| 269 | int unregister_switchdev_notifier(struct notifier_block *nb); |
| 270 | int call_switchdev_notifiers(unsigned long val, struct net_device *dev, |
Petr Machata | 6685987 | 2019-01-16 23:06:56 +0000 | [diff] [blame] | 271 | struct switchdev_notifier_info *info, |
| 272 | struct netlink_ext_ack *extack); |
Petr Machata | a93e3b1 | 2018-11-22 23:28:25 +0000 | [diff] [blame] | 273 | |
| 274 | int register_switchdev_blocking_notifier(struct notifier_block *nb); |
| 275 | int unregister_switchdev_blocking_notifier(struct notifier_block *nb); |
| 276 | int call_switchdev_blocking_notifiers(unsigned long val, struct net_device *dev, |
Petr Machata | 479c86d | 2018-12-12 17:02:54 +0000 | [diff] [blame] | 277 | struct switchdev_notifier_info *info, |
| 278 | struct netlink_ext_ack *extack); |
Petr Machata | a93e3b1 | 2018-11-22 23:28:25 +0000 | [diff] [blame] | 279 | |
Scott Feldman | 1a3b2ec | 2015-07-18 18:24:50 -0700 | [diff] [blame] | 280 | void switchdev_port_fwd_mark_set(struct net_device *dev, |
| 281 | struct net_device *group_dev, |
| 282 | bool joining); |
Scott Feldman | 5e8d904 | 2015-03-05 21:21:15 -0800 | [diff] [blame] | 283 | |
Petr Machata | f30f060 | 2018-11-22 23:29:44 +0000 | [diff] [blame] | 284 | int switchdev_handle_port_obj_add(struct net_device *dev, |
| 285 | struct switchdev_notifier_port_obj_info *port_obj_info, |
| 286 | bool (*check_cb)(const struct net_device *dev), |
| 287 | int (*add_cb)(struct net_device *dev, |
| 288 | const struct switchdev_obj *obj, |
Petr Machata | 6921351 | 2018-12-12 17:02:56 +0000 | [diff] [blame] | 289 | struct switchdev_trans *trans, |
| 290 | struct netlink_ext_ack *extack)); |
Petr Machata | f30f060 | 2018-11-22 23:29:44 +0000 | [diff] [blame] | 291 | int switchdev_handle_port_obj_del(struct net_device *dev, |
| 292 | struct switchdev_notifier_port_obj_info *port_obj_info, |
| 293 | bool (*check_cb)(const struct net_device *dev), |
| 294 | int (*del_cb)(struct net_device *dev, |
| 295 | const struct switchdev_obj *obj)); |
| 296 | |
Florian Fainelli | 1cb33af | 2019-02-27 11:44:25 -0800 | [diff] [blame] | 297 | int switchdev_handle_port_attr_set(struct net_device *dev, |
| 298 | struct switchdev_notifier_port_attr_info *port_attr_info, |
| 299 | bool (*check_cb)(const struct net_device *dev), |
| 300 | int (*set_cb)(struct net_device *dev, |
| 301 | const struct switchdev_attr *attr, |
| 302 | struct switchdev_trans *trans)); |
Jiri Pirko | 007f790 | 2014-11-28 14:34:17 +0100 | [diff] [blame] | 303 | #else |
| 304 | |
Jiri Pirko | 793f401 | 2015-10-14 19:40:48 +0200 | [diff] [blame] | 305 | static inline void switchdev_deferred_process(void) |
| 306 | { |
| 307 | } |
| 308 | |
Scott Feldman | 3094333 | 2015-05-10 09:47:48 -0700 | [diff] [blame] | 309 | static inline int switchdev_port_attr_set(struct net_device *dev, |
Jiri Pirko | f7fadf3 | 2015-10-14 19:40:49 +0200 | [diff] [blame] | 310 | const struct switchdev_attr *attr) |
Scott Feldman | 3094333 | 2015-05-10 09:47:48 -0700 | [diff] [blame] | 311 | { |
| 312 | return -EOPNOTSUPP; |
| 313 | } |
| 314 | |
Scott Feldman | 491d0f1 | 2015-05-10 09:47:52 -0700 | [diff] [blame] | 315 | static inline int switchdev_port_obj_add(struct net_device *dev, |
Petr Machata | 69b7320 | 2018-12-12 17:02:52 +0000 | [diff] [blame] | 316 | const struct switchdev_obj *obj, |
| 317 | struct netlink_ext_ack *extack) |
Scott Feldman | 491d0f1 | 2015-05-10 09:47:52 -0700 | [diff] [blame] | 318 | { |
| 319 | return -EOPNOTSUPP; |
| 320 | } |
| 321 | |
| 322 | static inline int switchdev_port_obj_del(struct net_device *dev, |
Jiri Pirko | 648b4a9 | 2015-10-01 11:03:45 +0200 | [diff] [blame] | 323 | const struct switchdev_obj *obj) |
Scott Feldman | 491d0f1 | 2015-05-10 09:47:52 -0700 | [diff] [blame] | 324 | { |
| 325 | return -EOPNOTSUPP; |
| 326 | } |
| 327 | |
Jiri Pirko | ebb9a03 | 2015-05-10 09:47:46 -0700 | [diff] [blame] | 328 | static inline int register_switchdev_notifier(struct notifier_block *nb) |
Jiri Pirko | 03bf0c2 | 2015-01-15 23:49:36 +0100 | [diff] [blame] | 329 | { |
| 330 | return 0; |
| 331 | } |
| 332 | |
Jiri Pirko | ebb9a03 | 2015-05-10 09:47:46 -0700 | [diff] [blame] | 333 | static inline int unregister_switchdev_notifier(struct notifier_block *nb) |
Jiri Pirko | 03bf0c2 | 2015-01-15 23:49:36 +0100 | [diff] [blame] | 334 | { |
| 335 | return 0; |
| 336 | } |
| 337 | |
Jiri Pirko | ebb9a03 | 2015-05-10 09:47:46 -0700 | [diff] [blame] | 338 | static inline int call_switchdev_notifiers(unsigned long val, |
| 339 | struct net_device *dev, |
Petr Machata | 6685987 | 2019-01-16 23:06:56 +0000 | [diff] [blame] | 340 | struct switchdev_notifier_info *info, |
| 341 | struct netlink_ext_ack *extack) |
Jiri Pirko | 03bf0c2 | 2015-01-15 23:49:36 +0100 | [diff] [blame] | 342 | { |
| 343 | return NOTIFY_DONE; |
| 344 | } |
| 345 | |
Petr Machata | a93e3b1 | 2018-11-22 23:28:25 +0000 | [diff] [blame] | 346 | static inline int |
| 347 | register_switchdev_blocking_notifier(struct notifier_block *nb) |
| 348 | { |
| 349 | return 0; |
| 350 | } |
| 351 | |
| 352 | static inline int |
| 353 | unregister_switchdev_blocking_notifier(struct notifier_block *nb) |
| 354 | { |
| 355 | return 0; |
| 356 | } |
| 357 | |
| 358 | static inline int |
| 359 | call_switchdev_blocking_notifiers(unsigned long val, |
| 360 | struct net_device *dev, |
Petr Machata | 479c86d | 2018-12-12 17:02:54 +0000 | [diff] [blame] | 361 | struct switchdev_notifier_info *info, |
| 362 | struct netlink_ext_ack *extack) |
Petr Machata | a93e3b1 | 2018-11-22 23:28:25 +0000 | [diff] [blame] | 363 | { |
| 364 | return NOTIFY_DONE; |
| 365 | } |
| 366 | |
Petr Machata | f30f060 | 2018-11-22 23:29:44 +0000 | [diff] [blame] | 367 | static inline int |
| 368 | switchdev_handle_port_obj_add(struct net_device *dev, |
| 369 | struct switchdev_notifier_port_obj_info *port_obj_info, |
| 370 | bool (*check_cb)(const struct net_device *dev), |
| 371 | int (*add_cb)(struct net_device *dev, |
| 372 | const struct switchdev_obj *obj, |
Petr Machata | 6921351 | 2018-12-12 17:02:56 +0000 | [diff] [blame] | 373 | struct switchdev_trans *trans, |
| 374 | struct netlink_ext_ack *extack)) |
Petr Machata | f30f060 | 2018-11-22 23:29:44 +0000 | [diff] [blame] | 375 | { |
| 376 | return 0; |
| 377 | } |
| 378 | |
| 379 | static inline int |
| 380 | switchdev_handle_port_obj_del(struct net_device *dev, |
| 381 | struct switchdev_notifier_port_obj_info *port_obj_info, |
| 382 | bool (*check_cb)(const struct net_device *dev), |
| 383 | int (*del_cb)(struct net_device *dev, |
| 384 | const struct switchdev_obj *obj)) |
| 385 | { |
| 386 | return 0; |
| 387 | } |
| 388 | |
Florian Fainelli | 1cb33af | 2019-02-27 11:44:25 -0800 | [diff] [blame] | 389 | static inline int |
| 390 | switchdev_handle_port_attr_set(struct net_device *dev, |
| 391 | struct switchdev_notifier_port_attr_info *port_attr_info, |
| 392 | bool (*check_cb)(const struct net_device *dev), |
| 393 | int (*set_cb)(struct net_device *dev, |
| 394 | const struct switchdev_attr *attr, |
| 395 | struct switchdev_trans *trans)) |
| 396 | { |
| 397 | return 0; |
| 398 | } |
Jiri Pirko | 007f790 | 2014-11-28 14:34:17 +0100 | [diff] [blame] | 399 | #endif |
| 400 | |
| 401 | #endif /* _LINUX_SWITCHDEV_H_ */ |