switchdev.c 949 B

123456789101112131415161718192021222324252627282930313233
  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);