switchdev.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. int netdev_switch_port_bridge_setlink(struct net_device *dev,
  40. struct nlmsghdr *nlh, u16 flags);
  41. int netdev_switch_port_bridge_dellink(struct net_device *dev,
  42. struct nlmsghdr *nlh, u16 flags);
  43. int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev,
  44. struct nlmsghdr *nlh, u16 flags);
  45. int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev,
  46. struct nlmsghdr *nlh, u16 flags);
  47. #else
  48. static inline int netdev_switch_parent_id_get(struct net_device *dev,
  49. struct netdev_phys_item_id *psid)
  50. {
  51. return -EOPNOTSUPP;
  52. }
  53. static inline int netdev_switch_port_stp_update(struct net_device *dev,
  54. u8 state)
  55. {
  56. return -EOPNOTSUPP;
  57. }
  58. static inline int register_netdev_switch_notifier(struct notifier_block *nb)
  59. {
  60. return 0;
  61. }
  62. static inline int unregister_netdev_switch_notifier(struct notifier_block *nb)
  63. {
  64. return 0;
  65. }
  66. static inline int call_netdev_switch_notifiers(unsigned long val, struct net_device *dev,
  67. struct netdev_switch_notifier_info *info)
  68. {
  69. return NOTIFY_DONE;
  70. }
  71. static inline int netdev_switch_port_bridge_setlink(struct net_device *dev,
  72. struct nlmsghdr *nlh,
  73. u16 flags)
  74. {
  75. return -EOPNOTSUPP;
  76. }
  77. static inline int netdev_switch_port_bridge_dellink(struct net_device *dev,
  78. struct nlmsghdr *nlh,
  79. u16 flags)
  80. {
  81. return -EOPNOTSUPP;
  82. }
  83. static inline int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev,
  84. struct nlmsghdr *nlh,
  85. u16 flags)
  86. {
  87. return 0;
  88. }
  89. static inline int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev,
  90. struct nlmsghdr *nlh,
  91. u16 flags)
  92. {
  93. return 0;
  94. }
  95. #endif
  96. #endif /* _LINUX_SWITCHDEV_H_ */