switchdev.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * net/switchdev/switchdev.c - 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. #include <linux/kernel.h>
  11. #include <linux/types.h>
  12. #include <linux/init.h>
  13. #include <linux/netdevice.h>
  14. #include <net/switchdev.h>
  15. /**
  16. * netdev_switch_parent_id_get - Get ID of a switch
  17. * @dev: port device
  18. * @psid: switch ID
  19. *
  20. * Get ID of a switch this port is part of.
  21. */
  22. int netdev_switch_parent_id_get(struct net_device *dev,
  23. struct netdev_phys_item_id *psid)
  24. {
  25. const struct net_device_ops *ops = dev->netdev_ops;
  26. if (!ops->ndo_switch_parent_id_get)
  27. return -EOPNOTSUPP;
  28. return ops->ndo_switch_parent_id_get(dev, psid);
  29. }
  30. EXPORT_SYMBOL(netdev_switch_parent_id_get);
  31. /**
  32. * netdev_switch_port_stp_update - Notify switch device port of STP
  33. * state change
  34. * @dev: port device
  35. * @state: port STP state
  36. *
  37. * Notify switch device port of bridge port STP state change.
  38. */
  39. int netdev_switch_port_stp_update(struct net_device *dev, u8 state)
  40. {
  41. const struct net_device_ops *ops = dev->netdev_ops;
  42. if (!ops->ndo_switch_port_stp_update)
  43. return -EOPNOTSUPP;
  44. WARN_ON(!ops->ndo_switch_parent_id_get);
  45. return ops->ndo_switch_port_stp_update(dev, state);
  46. }
  47. EXPORT_SYMBOL(netdev_switch_port_stp_update);