sriov.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /****************************************************************************
  2. * Driver for Solarflare network controllers and boards
  3. * Copyright 2014-2015 Solarflare Communications Inc.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published
  7. * by the Free Software Foundation, incorporated herein by reference.
  8. */
  9. #include <linux/module.h>
  10. #include "net_driver.h"
  11. #include "nic.h"
  12. #include "sriov.h"
  13. int efx_sriov_set_vf_mac(struct net_device *net_dev, int vf_i, u8 *mac)
  14. {
  15. struct efx_nic *efx = netdev_priv(net_dev);
  16. if (efx->type->sriov_set_vf_mac)
  17. return efx->type->sriov_set_vf_mac(efx, vf_i, mac);
  18. else
  19. return -EOPNOTSUPP;
  20. }
  21. int efx_sriov_set_vf_vlan(struct net_device *net_dev, int vf_i, u16 vlan,
  22. u8 qos)
  23. {
  24. struct efx_nic *efx = netdev_priv(net_dev);
  25. if (efx->type->sriov_set_vf_vlan) {
  26. if ((vlan & ~VLAN_VID_MASK) ||
  27. (qos & ~(VLAN_PRIO_MASK >> VLAN_PRIO_SHIFT)))
  28. return -EINVAL;
  29. return efx->type->sriov_set_vf_vlan(efx, vf_i, vlan, qos);
  30. } else {
  31. return -EOPNOTSUPP;
  32. }
  33. }
  34. int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf_i,
  35. bool spoofchk)
  36. {
  37. struct efx_nic *efx = netdev_priv(net_dev);
  38. if (efx->type->sriov_set_vf_spoofchk)
  39. return efx->type->sriov_set_vf_spoofchk(efx, vf_i, spoofchk);
  40. else
  41. return -EOPNOTSUPP;
  42. }
  43. int efx_sriov_get_vf_config(struct net_device *net_dev, int vf_i,
  44. struct ifla_vf_info *ivi)
  45. {
  46. struct efx_nic *efx = netdev_priv(net_dev);
  47. if (efx->type->sriov_get_vf_config)
  48. return efx->type->sriov_get_vf_config(efx, vf_i, ivi);
  49. else
  50. return -EOPNOTSUPP;
  51. }
  52. int efx_sriov_set_vf_link_state(struct net_device *net_dev, int vf_i,
  53. int link_state)
  54. {
  55. struct efx_nic *efx = netdev_priv(net_dev);
  56. if (efx->type->sriov_set_vf_link_state)
  57. return efx->type->sriov_set_vf_link_state(efx, vf_i,
  58. link_state);
  59. else
  60. return -EOPNOTSUPP;
  61. }
  62. int efx_sriov_get_phys_port_id(struct net_device *net_dev,
  63. struct netdev_phys_item_id *ppid)
  64. {
  65. struct efx_nic *efx = netdev_priv(net_dev);
  66. if (efx->type->sriov_get_phys_port_id)
  67. return efx->type->sriov_get_phys_port_id(efx, ppid);
  68. else
  69. return -EOPNOTSUPP;
  70. }