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