aboutsummaryrefslogtreecommitdiffstats
path: root/net/switchdev
diff options
context:
space:
mode:
authorJiri Pirko <jiri@resnulli.us>2015-05-10 12:47:46 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-12 18:43:52 -0400
commitebb9a03a590e2325f747be43c8db450e92509501 (patch)
treef83107e8c5e623e5ae6a3461cdc19e387bc6dd0f /net/switchdev
parenta3eb95f891d6130b1fc03dd07a8b54cf0a5c8ab8 (diff)
switchdev: s/netdev_switch_/switchdev_/ and s/NETDEV_SWITCH_/SWITCHDEV_/
Turned out that "switchdev" sticks. So just unify all related terms to use this prefix. Signed-off-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: Scott Feldman <sfeldma@gmail.com> Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com> Acked-by: Andy Gospodarek <gospo@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/switchdev')
-rw-r--r--net/switchdev/switchdev.c134
1 files changed, 67 insertions, 67 deletions
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 46568b85c333..52613ed49a8c 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -19,14 +19,14 @@
19#include <net/switchdev.h> 19#include <net/switchdev.h>
20 20
21/** 21/**
22 * netdev_switch_parent_id_get - Get ID of a switch 22 * switchdev_parent_id_get - Get ID of a switch
23 * @dev: port device 23 * @dev: port device
24 * @psid: switch ID 24 * @psid: switch ID
25 * 25 *
26 * Get ID of a switch this port is part of. 26 * Get ID of a switch this port is part of.
27 */ 27 */
28int netdev_switch_parent_id_get(struct net_device *dev, 28int switchdev_parent_id_get(struct net_device *dev,
29 struct netdev_phys_item_id *psid) 29 struct netdev_phys_item_id *psid)
30{ 30{
31 const struct swdev_ops *ops = dev->swdev_ops; 31 const struct swdev_ops *ops = dev->swdev_ops;
32 32
@@ -34,17 +34,17 @@ int netdev_switch_parent_id_get(struct net_device *dev,
34 return -EOPNOTSUPP; 34 return -EOPNOTSUPP;
35 return ops->swdev_parent_id_get(dev, psid); 35 return ops->swdev_parent_id_get(dev, psid);
36} 36}
37EXPORT_SYMBOL_GPL(netdev_switch_parent_id_get); 37EXPORT_SYMBOL_GPL(switchdev_parent_id_get);
38 38
39/** 39/**
40 * netdev_switch_port_stp_update - Notify switch device port of STP 40 * switchdev_port_stp_update - Notify switch device port of STP
41 * state change 41 * state change
42 * @dev: port device 42 * @dev: port device
43 * @state: port STP state 43 * @state: port STP state
44 * 44 *
45 * Notify switch device port of bridge port STP state change. 45 * Notify switch device port of bridge port STP state change.
46 */ 46 */
47int netdev_switch_port_stp_update(struct net_device *dev, u8 state) 47int switchdev_port_stp_update(struct net_device *dev, u8 state)
48{ 48{
49 const struct swdev_ops *ops = dev->swdev_ops; 49 const struct swdev_ops *ops = dev->swdev_ops;
50 struct net_device *lower_dev; 50 struct net_device *lower_dev;
@@ -55,57 +55,57 @@ int netdev_switch_port_stp_update(struct net_device *dev, u8 state)
55 return ops->swdev_port_stp_update(dev, state); 55 return ops->swdev_port_stp_update(dev, state);
56 56
57 netdev_for_each_lower_dev(dev, lower_dev, iter) { 57 netdev_for_each_lower_dev(dev, lower_dev, iter) {
58 err = netdev_switch_port_stp_update(lower_dev, state); 58 err = switchdev_port_stp_update(lower_dev, state);
59 if (err && err != -EOPNOTSUPP) 59 if (err && err != -EOPNOTSUPP)
60 return err; 60 return err;
61 } 61 }
62 62
63 return err; 63 return err;
64} 64}
65EXPORT_SYMBOL_GPL(netdev_switch_port_stp_update); 65EXPORT_SYMBOL_GPL(switchdev_port_stp_update);
66 66
67static DEFINE_MUTEX(netdev_switch_mutex); 67static DEFINE_MUTEX(switchdev_mutex);
68static RAW_NOTIFIER_HEAD(netdev_switch_notif_chain); 68static RAW_NOTIFIER_HEAD(switchdev_notif_chain);
69 69
70/** 70/**
71 * register_netdev_switch_notifier - Register notifier 71 * register_switchdev_notifier - Register notifier
72 * @nb: notifier_block 72 * @nb: notifier_block
73 * 73 *
74 * Register switch device notifier. This should be used by code 74 * Register switch device notifier. This should be used by code
75 * which needs to monitor events happening in particular device. 75 * which needs to monitor events happening in particular device.
76 * Return values are same as for atomic_notifier_chain_register(). 76 * Return values are same as for atomic_notifier_chain_register().
77 */ 77 */
78int register_netdev_switch_notifier(struct notifier_block *nb) 78int register_switchdev_notifier(struct notifier_block *nb)
79{ 79{
80 int err; 80 int err;
81 81
82 mutex_lock(&netdev_switch_mutex); 82 mutex_lock(&switchdev_mutex);
83 err = raw_notifier_chain_register(&netdev_switch_notif_chain, nb); 83 err = raw_notifier_chain_register(&switchdev_notif_chain, nb);
84 mutex_unlock(&netdev_switch_mutex); 84 mutex_unlock(&switchdev_mutex);
85 return err; 85 return err;
86} 86}
87EXPORT_SYMBOL_GPL(register_netdev_switch_notifier); 87EXPORT_SYMBOL_GPL(register_switchdev_notifier);
88 88
89/** 89/**
90 * unregister_netdev_switch_notifier - Unregister notifier 90 * unregister_switchdev_notifier - Unregister notifier
91 * @nb: notifier_block 91 * @nb: notifier_block
92 * 92 *
93 * Unregister switch device notifier. 93 * Unregister switch device notifier.
94 * Return values are same as for atomic_notifier_chain_unregister(). 94 * Return values are same as for atomic_notifier_chain_unregister().
95 */ 95 */
96int unregister_netdev_switch_notifier(struct notifier_block *nb) 96int unregister_switchdev_notifier(struct notifier_block *nb)
97{ 97{
98 int err; 98 int err;
99 99
100 mutex_lock(&netdev_switch_mutex); 100 mutex_lock(&switchdev_mutex);
101 err = raw_notifier_chain_unregister(&netdev_switch_notif_chain, nb); 101 err = raw_notifier_chain_unregister(&switchdev_notif_chain, nb);
102 mutex_unlock(&netdev_switch_mutex); 102 mutex_unlock(&switchdev_mutex);
103 return err; 103 return err;
104} 104}
105EXPORT_SYMBOL_GPL(unregister_netdev_switch_notifier); 105EXPORT_SYMBOL_GPL(unregister_switchdev_notifier);
106 106
107/** 107/**
108 * call_netdev_switch_notifiers - Call notifiers 108 * call_switchdev_notifiers - Call notifiers
109 * @val: value passed unmodified to notifier function 109 * @val: value passed unmodified to notifier function
110 * @dev: port device 110 * @dev: port device
111 * @info: notifier information data 111 * @info: notifier information data
@@ -114,21 +114,21 @@ EXPORT_SYMBOL_GPL(unregister_netdev_switch_notifier);
114 * when it needs to propagate hardware event. 114 * when it needs to propagate hardware event.
115 * Return values are same as for atomic_notifier_call_chain(). 115 * Return values are same as for atomic_notifier_call_chain().
116 */ 116 */
117int call_netdev_switch_notifiers(unsigned long val, struct net_device *dev, 117int call_switchdev_notifiers(unsigned long val, struct net_device *dev,
118 struct netdev_switch_notifier_info *info) 118 struct switchdev_notifier_info *info)
119{ 119{
120 int err; 120 int err;
121 121
122 info->dev = dev; 122 info->dev = dev;
123 mutex_lock(&netdev_switch_mutex); 123 mutex_lock(&switchdev_mutex);
124 err = raw_notifier_call_chain(&netdev_switch_notif_chain, val, info); 124 err = raw_notifier_call_chain(&switchdev_notif_chain, val, info);
125 mutex_unlock(&netdev_switch_mutex); 125 mutex_unlock(&switchdev_mutex);
126 return err; 126 return err;
127} 127}
128EXPORT_SYMBOL_GPL(call_netdev_switch_notifiers); 128EXPORT_SYMBOL_GPL(call_switchdev_notifiers);
129 129
130/** 130/**
131 * netdev_switch_port_bridge_setlink - Notify switch device port of bridge 131 * switchdev_port_bridge_setlink - Notify switch device port of bridge
132 * port attributes 132 * port attributes
133 * 133 *
134 * @dev: port device 134 * @dev: port device
@@ -137,8 +137,8 @@ EXPORT_SYMBOL_GPL(call_netdev_switch_notifiers);
137 * 137 *
138 * Notify switch device port of bridge port attributes 138 * Notify switch device port of bridge port attributes
139 */ 139 */
140int netdev_switch_port_bridge_setlink(struct net_device *dev, 140int switchdev_port_bridge_setlink(struct net_device *dev,
141 struct nlmsghdr *nlh, u16 flags) 141 struct nlmsghdr *nlh, u16 flags)
142{ 142{
143 const struct net_device_ops *ops = dev->netdev_ops; 143 const struct net_device_ops *ops = dev->netdev_ops;
144 144
@@ -150,10 +150,10 @@ int netdev_switch_port_bridge_setlink(struct net_device *dev,
150 150
151 return ops->ndo_bridge_setlink(dev, nlh, flags); 151 return ops->ndo_bridge_setlink(dev, nlh, flags);
152} 152}
153EXPORT_SYMBOL_GPL(netdev_switch_port_bridge_setlink); 153EXPORT_SYMBOL_GPL(switchdev_port_bridge_setlink);
154 154
155/** 155/**
156 * netdev_switch_port_bridge_dellink - Notify switch device port of bridge 156 * switchdev_port_bridge_dellink - Notify switch device port of bridge
157 * port attribute delete 157 * port attribute delete
158 * 158 *
159 * @dev: port device 159 * @dev: port device
@@ -162,8 +162,8 @@ EXPORT_SYMBOL_GPL(netdev_switch_port_bridge_setlink);
162 * 162 *
163 * Notify switch device port of bridge port attribute delete 163 * Notify switch device port of bridge port attribute delete
164 */ 164 */
165int netdev_switch_port_bridge_dellink(struct net_device *dev, 165int switchdev_port_bridge_dellink(struct net_device *dev,
166 struct nlmsghdr *nlh, u16 flags) 166 struct nlmsghdr *nlh, u16 flags)
167{ 167{
168 const struct net_device_ops *ops = dev->netdev_ops; 168 const struct net_device_ops *ops = dev->netdev_ops;
169 169
@@ -175,11 +175,11 @@ int netdev_switch_port_bridge_dellink(struct net_device *dev,
175 175
176 return ops->ndo_bridge_dellink(dev, nlh, flags); 176 return ops->ndo_bridge_dellink(dev, nlh, flags);
177} 177}
178EXPORT_SYMBOL_GPL(netdev_switch_port_bridge_dellink); 178EXPORT_SYMBOL_GPL(switchdev_port_bridge_dellink);
179 179
180/** 180/**
181 * ndo_dflt_netdev_switch_port_bridge_setlink - default ndo bridge setlink 181 * ndo_dflt_switchdev_port_bridge_setlink - default ndo bridge setlink
182 * op for master devices 182 * op for master devices
183 * 183 *
184 * @dev: port device 184 * @dev: port device
185 * @nlh: netlink msg with bridge port attributes 185 * @nlh: netlink msg with bridge port attributes
@@ -187,8 +187,8 @@ EXPORT_SYMBOL_GPL(netdev_switch_port_bridge_dellink);
187 * 187 *
188 * Notify master device slaves of bridge port attributes 188 * Notify master device slaves of bridge port attributes
189 */ 189 */
190int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev, 190int ndo_dflt_switchdev_port_bridge_setlink(struct net_device *dev,
191 struct nlmsghdr *nlh, u16 flags) 191 struct nlmsghdr *nlh, u16 flags)
192{ 192{
193 struct net_device *lower_dev; 193 struct net_device *lower_dev;
194 struct list_head *iter; 194 struct list_head *iter;
@@ -198,18 +198,18 @@ int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev,
198 return ret; 198 return ret;
199 199
200 netdev_for_each_lower_dev(dev, lower_dev, iter) { 200 netdev_for_each_lower_dev(dev, lower_dev, iter) {
201 err = netdev_switch_port_bridge_setlink(lower_dev, nlh, flags); 201 err = switchdev_port_bridge_setlink(lower_dev, nlh, flags);
202 if (err && err != -EOPNOTSUPP) 202 if (err && err != -EOPNOTSUPP)
203 ret = err; 203 ret = err;
204 } 204 }
205 205
206 return ret; 206 return ret;
207} 207}
208EXPORT_SYMBOL_GPL(ndo_dflt_netdev_switch_port_bridge_setlink); 208EXPORT_SYMBOL_GPL(ndo_dflt_switchdev_port_bridge_setlink);
209 209
210/** 210/**
211 * ndo_dflt_netdev_switch_port_bridge_dellink - default ndo bridge dellink 211 * ndo_dflt_switchdev_port_bridge_dellink - default ndo bridge dellink
212 * op for master devices 212 * op for master devices
213 * 213 *
214 * @dev: port device 214 * @dev: port device
215 * @nlh: netlink msg with bridge port attributes 215 * @nlh: netlink msg with bridge port attributes
@@ -217,8 +217,8 @@ EXPORT_SYMBOL_GPL(ndo_dflt_netdev_switch_port_bridge_setlink);
217 * 217 *
218 * Notify master device slaves of bridge port attribute deletes 218 * Notify master device slaves of bridge port attribute deletes
219 */ 219 */
220int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev, 220int ndo_dflt_switchdev_port_bridge_dellink(struct net_device *dev,
221 struct nlmsghdr *nlh, u16 flags) 221 struct nlmsghdr *nlh, u16 flags)
222{ 222{
223 struct net_device *lower_dev; 223 struct net_device *lower_dev;
224 struct list_head *iter; 224 struct list_head *iter;
@@ -228,16 +228,16 @@ int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev,
228 return ret; 228 return ret;
229 229
230 netdev_for_each_lower_dev(dev, lower_dev, iter) { 230 netdev_for_each_lower_dev(dev, lower_dev, iter) {
231 err = netdev_switch_port_bridge_dellink(lower_dev, nlh, flags); 231 err = switchdev_port_bridge_dellink(lower_dev, nlh, flags);
232 if (err && err != -EOPNOTSUPP) 232 if (err && err != -EOPNOTSUPP)
233 ret = err; 233 ret = err;
234 } 234 }
235 235
236 return ret; 236 return ret;
237} 237}
238EXPORT_SYMBOL_GPL(ndo_dflt_netdev_switch_port_bridge_dellink); 238EXPORT_SYMBOL_GPL(ndo_dflt_switchdev_port_bridge_dellink);
239 239
240static struct net_device *netdev_switch_get_lowest_dev(struct net_device *dev) 240static struct net_device *switchdev_get_lowest_dev(struct net_device *dev)
241{ 241{
242 const struct swdev_ops *ops = dev->swdev_ops; 242 const struct swdev_ops *ops = dev->swdev_ops;
243 struct net_device *lower_dev; 243 struct net_device *lower_dev;
@@ -253,7 +253,7 @@ static struct net_device *netdev_switch_get_lowest_dev(struct net_device *dev)
253 return dev; 253 return dev;
254 254
255 netdev_for_each_lower_dev(dev, lower_dev, iter) { 255 netdev_for_each_lower_dev(dev, lower_dev, iter) {
256 port_dev = netdev_switch_get_lowest_dev(lower_dev); 256 port_dev = switchdev_get_lowest_dev(lower_dev);
257 if (port_dev) 257 if (port_dev)
258 return port_dev; 258 return port_dev;
259 } 259 }
@@ -261,7 +261,7 @@ static struct net_device *netdev_switch_get_lowest_dev(struct net_device *dev)
261 return NULL; 261 return NULL;
262} 262}
263 263
264static struct net_device *netdev_switch_get_dev_by_nhs(struct fib_info *fi) 264static struct net_device *switchdev_get_dev_by_nhs(struct fib_info *fi)
265{ 265{
266 struct netdev_phys_item_id psid; 266 struct netdev_phys_item_id psid;
267 struct netdev_phys_item_id prev_psid; 267 struct netdev_phys_item_id prev_psid;
@@ -276,11 +276,11 @@ static struct net_device *netdev_switch_get_dev_by_nhs(struct fib_info *fi)
276 if (!nh->nh_dev) 276 if (!nh->nh_dev)
277 return NULL; 277 return NULL;
278 278
279 dev = netdev_switch_get_lowest_dev(nh->nh_dev); 279 dev = switchdev_get_lowest_dev(nh->nh_dev);
280 if (!dev) 280 if (!dev)
281 return NULL; 281 return NULL;
282 282
283 if (netdev_switch_parent_id_get(dev, &psid)) 283 if (switchdev_parent_id_get(dev, &psid))
284 return NULL; 284 return NULL;
285 285
286 if (nhsel > 0) { 286 if (nhsel > 0) {
@@ -297,7 +297,7 @@ static struct net_device *netdev_switch_get_dev_by_nhs(struct fib_info *fi)
297} 297}
298 298
299/** 299/**
300 * netdev_switch_fib_ipv4_add - Add IPv4 route entry to switch 300 * switchdev_fib_ipv4_add - Add IPv4 route entry to switch
301 * 301 *
302 * @dst: route's IPv4 destination address 302 * @dst: route's IPv4 destination address
303 * @dst_len: destination address length (prefix length) 303 * @dst_len: destination address length (prefix length)
@@ -309,8 +309,8 @@ static struct net_device *netdev_switch_get_dev_by_nhs(struct fib_info *fi)
309 * 309 *
310 * Add IPv4 route entry to switch device. 310 * Add IPv4 route entry to switch device.
311 */ 311 */
312int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi, 312int switchdev_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
313 u8 tos, u8 type, u32 nlflags, u32 tb_id) 313 u8 tos, u8 type, u32 nlflags, u32 tb_id)
314{ 314{
315 struct net_device *dev; 315 struct net_device *dev;
316 const struct swdev_ops *ops; 316 const struct swdev_ops *ops;
@@ -328,7 +328,7 @@ int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
328 if (fi->fib_net->ipv4.fib_offload_disabled) 328 if (fi->fib_net->ipv4.fib_offload_disabled)
329 return 0; 329 return 0;
330 330
331 dev = netdev_switch_get_dev_by_nhs(fi); 331 dev = switchdev_get_dev_by_nhs(fi);
332 if (!dev) 332 if (!dev)
333 return 0; 333 return 0;
334 ops = dev->swdev_ops; 334 ops = dev->swdev_ops;
@@ -343,10 +343,10 @@ int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
343 343
344 return err; 344 return err;
345} 345}
346EXPORT_SYMBOL_GPL(netdev_switch_fib_ipv4_add); 346EXPORT_SYMBOL_GPL(switchdev_fib_ipv4_add);
347 347
348/** 348/**
349 * netdev_switch_fib_ipv4_del - Delete IPv4 route entry from switch 349 * switchdev_fib_ipv4_del - Delete IPv4 route entry from switch
350 * 350 *
351 * @dst: route's IPv4 destination address 351 * @dst: route's IPv4 destination address
352 * @dst_len: destination address length (prefix length) 352 * @dst_len: destination address length (prefix length)
@@ -357,8 +357,8 @@ EXPORT_SYMBOL_GPL(netdev_switch_fib_ipv4_add);
357 * 357 *
358 * Delete IPv4 route entry from switch device. 358 * Delete IPv4 route entry from switch device.
359 */ 359 */
360int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi, 360int switchdev_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
361 u8 tos, u8 type, u32 tb_id) 361 u8 tos, u8 type, u32 tb_id)
362{ 362{
363 struct net_device *dev; 363 struct net_device *dev;
364 const struct swdev_ops *ops; 364 const struct swdev_ops *ops;
@@ -367,7 +367,7 @@ int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
367 if (!(fi->fib_flags & RTNH_F_EXTERNAL)) 367 if (!(fi->fib_flags & RTNH_F_EXTERNAL))
368 return 0; 368 return 0;
369 369
370 dev = netdev_switch_get_dev_by_nhs(fi); 370 dev = switchdev_get_dev_by_nhs(fi);
371 if (!dev) 371 if (!dev)
372 return 0; 372 return 0;
373 ops = dev->swdev_ops; 373 ops = dev->swdev_ops;
@@ -381,14 +381,14 @@ int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
381 381
382 return err; 382 return err;
383} 383}
384EXPORT_SYMBOL_GPL(netdev_switch_fib_ipv4_del); 384EXPORT_SYMBOL_GPL(switchdev_fib_ipv4_del);
385 385
386/** 386/**
387 * netdev_switch_fib_ipv4_abort - Abort an IPv4 FIB operation 387 * switchdev_fib_ipv4_abort - Abort an IPv4 FIB operation
388 * 388 *
389 * @fi: route FIB info structure 389 * @fi: route FIB info structure
390 */ 390 */
391void netdev_switch_fib_ipv4_abort(struct fib_info *fi) 391void switchdev_fib_ipv4_abort(struct fib_info *fi)
392{ 392{
393 /* There was a problem installing this route to the offload 393 /* There was a problem installing this route to the offload
394 * device. For now, until we come up with more refined 394 * device. For now, until we come up with more refined
@@ -401,4 +401,4 @@ void netdev_switch_fib_ipv4_abort(struct fib_info *fi)
401 fib_flush_external(fi->fib_net); 401 fib_flush_external(fi->fib_net);
402 fi->fib_net->ipv4.fib_offload_disabled = true; 402 fi->fib_net->ipv4.fib_offload_disabled = true;
403} 403}
404EXPORT_SYMBOL_GPL(netdev_switch_fib_ipv4_abort); 404EXPORT_SYMBOL_GPL(switchdev_fib_ipv4_abort);