switchdev.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * include/net/switchdev.h - Switch device API
  3. * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. */
  10. #ifndef _LINUX_SWITCHDEV_H_
  11. #define _LINUX_SWITCHDEV_H_
  12. #include <linux/netdevice.h>
  13. #include <linux/notifier.h>
  14. enum netdev_switch_notifier_type {
  15. NETDEV_SWITCH_FDB_ADD = 1,
  16. NETDEV_SWITCH_FDB_DEL,
  17. };
  18. struct netdev_switch_notifier_info {
  19. struct net_device *dev;
  20. };
  21. struct netdev_switch_notifier_fdb_info {
  22. struct netdev_switch_notifier_info info; /* must be first */
  23. const unsigned char *addr;
  24. u16 vid;
  25. };
  26. static inline struct net_device *
  27. netdev_switch_notifier_info_to_dev(const struct netdev_switch_notifier_info *info)
  28. {
  29. return info->dev;
  30. }
  31. #ifdef CONFIG_NET_SWITCHDEV
  32. int netdev_switch_parent_id_get(struct net_device *dev,
  33. struct netdev_phys_item_id *psid);
  34. int netdev_switch_port_stp_update(struct net_device *dev, u8 state);
  35. int register_netdev_switch_notifier(struct notifier_block *nb);
  36. int unregister_netdev_switch_notifier(struct notifier_block *nb);
  37. int call_netdev_switch_notifiers(unsigned long val, struct net_device *dev,
  38. struct netdev_switch_notifier_info *info);
  39. #else
  40. static inline int netdev_switch_parent_id_get(struct net_device *dev,
  41. struct netdev_phys_item_id *psid)
  42. {
  43. return -EOPNOTSUPP;
  44. }
  45. static inline int netdev_switch_port_stp_update(struct net_device *dev,
  46. u8 state)
  47. {
  48. return -EOPNOTSUPP;
  49. }
  50. static inline int register_netdev_switch_notifier(struct notifier_block *nb)
  51. {
  52. return 0;
  53. }
  54. static inline int unregister_netdev_switch_notifier(struct notifier_block *nb)
  55. {
  56. return 0;
  57. }
  58. static inline int call_netdev_switch_notifiers(unsigned long val, struct net_device *dev,
  59. struct netdev_switch_notifier_info *info)
  60. {
  61. return NOTIFY_DONE;
  62. }
  63. #endif
  64. #endif /* _LINUX_SWITCHDEV_H_ */