sriov.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /****************************************************************************
  3. * Driver for Solarflare network controllers and boards
  4. * Copyright 2014-2015 Solarflare Communications Inc.
  5. */
  6. #include <linux/module.h>
  7. #include "net_driver.h"
  8. #include "nic.h"
  9. #include "sriov.h"
  10. int efx_sriov_set_vf_mac(struct net_device *net_dev, int vf_i, u8 *mac)
  11. {
  12. struct efx_nic *efx = netdev_priv(net_dev);
  13. if (efx->type->sriov_set_vf_mac)
  14. return efx->type->sriov_set_vf_mac(efx, vf_i, mac);
  15. else
  16. return -EOPNOTSUPP;
  17. }
  18. int efx_sriov_set_vf_vlan(struct net_device *net_dev, int vf_i, u16 vlan,
  19. u8 qos, __be16 vlan_proto)
  20. {
  21. struct efx_nic *efx = netdev_priv(net_dev);
  22. if (efx->type->sriov_set_vf_vlan) {
  23. if ((vlan & ~VLAN_VID_MASK) ||
  24. (qos & ~(VLAN_PRIO_MASK >> VLAN_PRIO_SHIFT)))
  25. return -EINVAL;
  26. if (vlan_proto != htons(ETH_P_8021Q))
  27. return -EPROTONOSUPPORT;
  28. return efx->type->sriov_set_vf_vlan(efx, vf_i, vlan, qos);
  29. } else {
  30. return -EOPNOTSUPP;
  31. }
  32. }
  33. int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf_i,
  34. bool spoofchk)
  35. {
  36. struct efx_nic *efx = netdev_priv(net_dev);
  37. if (efx->type->sriov_set_vf_spoofchk)
  38. return efx->type->sriov_set_vf_spoofchk(efx, vf_i, spoofchk);
  39. else
  40. return -EOPNOTSUPP;
  41. }
  42. int efx_sriov_get_vf_config(struct net_device *net_dev, int vf_i,
  43. struct ifla_vf_info *ivi)
  44. {
  45. struct efx_nic *efx = netdev_priv(net_dev);
  46. if (efx->type->sriov_get_vf_config)
  47. return efx->type->sriov_get_vf_config(efx, vf_i, ivi);
  48. else
  49. return -EOPNOTSUPP;
  50. }
  51. int efx_sriov_set_vf_link_state(struct net_device *net_dev, int vf_i,
  52. int link_state)
  53. {
  54. struct efx_nic *efx = netdev_priv(net_dev);
  55. if (efx->type->sriov_set_vf_link_state)
  56. return efx->type->sriov_set_vf_link_state(efx, vf_i,
  57. link_state);
  58. else
  59. return -EOPNOTSUPP;
  60. }