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