switchdev.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
  48. u8 tos, u8 type, u32 tb_id);
  49. int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
  50. u8 tos, u8 type, u32 tb_id);
  51. void netdev_switch_fib_ipv4_abort(struct fib_info *fi);
  52. #else
  53. static inline int netdev_switch_parent_id_get(struct net_device *dev,
  54. struct netdev_phys_item_id *psid)
  55. {
  56. return -EOPNOTSUPP;
  57. }
  58. static inline int netdev_switch_port_stp_update(struct net_device *dev,
  59. u8 state)
  60. {
  61. return -EOPNOTSUPP;
  62. }
  63. static inline int register_netdev_switch_notifier(struct notifier_block *nb)
  64. {
  65. return 0;
  66. }
  67. static inline int unregister_netdev_switch_notifier(struct notifier_block *nb)
  68. {
  69. return 0;
  70. }
  71. static inline int call_netdev_switch_notifiers(unsigned long val, struct net_device *dev,
  72. struct netdev_switch_notifier_info *info)
  73. {
  74. return NOTIFY_DONE;
  75. }
  76. static inline int netdev_switch_port_bridge_setlink(struct net_device *dev,
  77. struct nlmsghdr *nlh,
  78. u16 flags)
  79. {
  80. return -EOPNOTSUPP;
  81. }
  82. static inline int netdev_switch_port_bridge_dellink(struct net_device *dev,
  83. struct nlmsghdr *nlh,
  84. u16 flags)
  85. {
  86. return -EOPNOTSUPP;
  87. }
  88. static inline int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev,
  89. struct nlmsghdr *nlh,
  90. u16 flags)
  91. {
  92. return 0;
  93. }
  94. static inline int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev,
  95. struct nlmsghdr *nlh,
  96. u16 flags)
  97. {
  98. return 0;
  99. }
  100. static inline int netdev_switch_fib_ipv4_add(u32 dst, int dst_len,
  101. struct fib_info *fi,
  102. u8 tos, u8 type, u32 tb_id)
  103. {
  104. return 0;
  105. }
  106. static inline int netdev_switch_fib_ipv4_del(u32 dst, int dst_len,
  107. struct fib_info *fi,
  108. u8 tos, u8 type, u32 tb_id)
  109. {
  110. return 0;
  111. }
  112. static inline void netdev_switch_fib_ipv4_abort(struct fib_info *fi)
  113. {
  114. }
  115. #endif
  116. #endif /* _LINUX_SWITCHDEV_H_ */