switchdev.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * include/net/switchdev.h - Switch device API
  3. * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us>
  4. * Copyright (c) 2014-2015 Scott Feldman <sfeldma@gmail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #ifndef _LINUX_SWITCHDEV_H_
  12. #define _LINUX_SWITCHDEV_H_
  13. #include <linux/netdevice.h>
  14. #include <linux/notifier.h>
  15. enum netdev_switch_notifier_type {
  16. NETDEV_SWITCH_FDB_ADD = 1,
  17. NETDEV_SWITCH_FDB_DEL,
  18. };
  19. struct netdev_switch_notifier_info {
  20. struct net_device *dev;
  21. };
  22. struct netdev_switch_notifier_fdb_info {
  23. struct netdev_switch_notifier_info info; /* must be first */
  24. const unsigned char *addr;
  25. u16 vid;
  26. };
  27. static inline struct net_device *
  28. netdev_switch_notifier_info_to_dev(const struct netdev_switch_notifier_info *info)
  29. {
  30. return info->dev;
  31. }
  32. #ifdef CONFIG_NET_SWITCHDEV
  33. int netdev_switch_parent_id_get(struct net_device *dev,
  34. struct netdev_phys_item_id *psid);
  35. int netdev_switch_port_stp_update(struct net_device *dev, u8 state);
  36. int register_netdev_switch_notifier(struct notifier_block *nb);
  37. int unregister_netdev_switch_notifier(struct notifier_block *nb);
  38. int call_netdev_switch_notifiers(unsigned long val, struct net_device *dev,
  39. struct netdev_switch_notifier_info *info);
  40. int netdev_switch_port_bridge_setlink(struct net_device *dev,
  41. struct nlmsghdr *nlh, u16 flags);
  42. int netdev_switch_port_bridge_dellink(struct net_device *dev,
  43. struct nlmsghdr *nlh, u16 flags);
  44. int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev,
  45. struct nlmsghdr *nlh, u16 flags);
  46. int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev,
  47. struct nlmsghdr *nlh, u16 flags);
  48. int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
  49. u8 tos, u8 type, u32 nlflags, u32 tb_id);
  50. int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
  51. u8 tos, u8 type, u32 tb_id);
  52. void netdev_switch_fib_ipv4_abort(struct fib_info *fi);
  53. #else
  54. static inline int netdev_switch_parent_id_get(struct net_device *dev,
  55. struct netdev_phys_item_id *psid)
  56. {
  57. return -EOPNOTSUPP;
  58. }
  59. static inline int netdev_switch_port_stp_update(struct net_device *dev,
  60. u8 state)
  61. {
  62. return -EOPNOTSUPP;
  63. }
  64. static inline int register_netdev_switch_notifier(struct notifier_block *nb)
  65. {
  66. return 0;
  67. }
  68. static inline int unregister_netdev_switch_notifier(struct notifier_block *nb)
  69. {
  70. return 0;
  71. }
  72. static inline int call_netdev_switch_notifiers(unsigned long val, struct net_device *dev,
  73. struct netdev_switch_notifier_info *info)
  74. {
  75. return NOTIFY_DONE;
  76. }
  77. static inline int netdev_switch_port_bridge_setlink(struct net_device *dev,
  78. struct nlmsghdr *nlh,
  79. u16 flags)
  80. {
  81. return -EOPNOTSUPP;
  82. }
  83. static inline int netdev_switch_port_bridge_dellink(struct net_device *dev,
  84. struct nlmsghdr *nlh,
  85. u16 flags)
  86. {
  87. return -EOPNOTSUPP;
  88. }
  89. static inline int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev,
  90. struct nlmsghdr *nlh,
  91. u16 flags)
  92. {
  93. return 0;
  94. }
  95. static inline int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev,
  96. struct nlmsghdr *nlh,
  97. u16 flags)
  98. {
  99. return 0;
  100. }
  101. static inline int netdev_switch_fib_ipv4_add(u32 dst, int dst_len,
  102. struct fib_info *fi,
  103. u8 tos, u8 type,
  104. u32 nlflags, u32 tb_id)
  105. {
  106. return 0;
  107. }
  108. static inline int netdev_switch_fib_ipv4_del(u32 dst, int dst_len,
  109. struct fib_info *fi,
  110. u8 tos, u8 type, u32 tb_id)
  111. {
  112. return 0;
  113. }
  114. static inline void netdev_switch_fib_ipv4_abort(struct fib_info *fi)
  115. {
  116. }
  117. #endif
  118. #endif /* _LINUX_SWITCHDEV_H_ */