sriov.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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, __be16 vlan_proto)
  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. if (vlan_proto != htons(ETH_P_8021Q))
  30. return -EPROTONOSUPPORT;
  31. return efx->type->sriov_set_vf_vlan(efx, vf_i, vlan, qos);
  32. } else {
  33. return -EOPNOTSUPP;
  34. }
  35. }
  36. int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf_i,
  37. bool spoofchk)
  38. {
  39. struct efx_nic *efx = netdev_priv(net_dev);
  40. if (efx->type->sriov_set_vf_spoofchk)
  41. return efx->type->sriov_set_vf_spoofchk(efx, vf_i, spoofchk);
  42. else
  43. return -EOPNOTSUPP;
  44. }
  45. int efx_sriov_get_vf_config(struct net_device *net_dev, int vf_i,
  46. struct ifla_vf_info *ivi)
  47. {
  48. struct efx_nic *efx = netdev_priv(net_dev);
  49. if (efx->type->sriov_get_vf_config)
  50. return efx->type->sriov_get_vf_config(efx, vf_i, ivi);
  51. else
  52. return -EOPNOTSUPP;
  53. }
  54. int efx_sriov_set_vf_link_state(struct net_device *net_dev, int vf_i,
  55. int link_state)
  56. {
  57. struct efx_nic *efx = netdev_priv(net_dev);
  58. if (efx->type->sriov_set_vf_link_state)
  59. return efx->type->sriov_set_vf_link_state(efx, vf_i,
  60. link_state);
  61. else
  62. return -EOPNOTSUPP;
  63. }
  64. int efx_sriov_get_phys_port_id(struct net_device *net_dev,
  65. struct netdev_phys_item_id *ppid)
  66. {
  67. struct efx_nic *efx = netdev_priv(net_dev);
  68. if (efx->type->sriov_get_phys_port_id)
  69. return efx->type->sriov_get_phys_port_id(efx, ppid);
  70. else
  71. return -EOPNOTSUPP;
  72. }