sriov.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #ifndef EFX_SRIOV_H
  7. #define EFX_SRIOV_H
  8. #include "net_driver.h"
  9. #ifdef CONFIG_SFC_SIENA_SRIOV
  10. static inline
  11. int efx_sriov_set_vf_mac(struct net_device *net_dev, int vf_i, u8 *mac)
  12. {
  13. struct efx_nic *efx = netdev_priv(net_dev);
  14. if (efx->type->sriov_set_vf_mac)
  15. return efx->type->sriov_set_vf_mac(efx, vf_i, mac);
  16. else
  17. return -EOPNOTSUPP;
  18. }
  19. static inline
  20. int efx_sriov_set_vf_vlan(struct net_device *net_dev, int vf_i, u16 vlan,
  21. u8 qos, __be16 vlan_proto)
  22. {
  23. struct efx_nic *efx = netdev_priv(net_dev);
  24. if (efx->type->sriov_set_vf_vlan) {
  25. if ((vlan & ~VLAN_VID_MASK) ||
  26. (qos & ~(VLAN_PRIO_MASK >> VLAN_PRIO_SHIFT)))
  27. return -EINVAL;
  28. if (vlan_proto != htons(ETH_P_8021Q))
  29. return -EPROTONOSUPPORT;
  30. return efx->type->sriov_set_vf_vlan(efx, vf_i, vlan, qos);
  31. } else {
  32. return -EOPNOTSUPP;
  33. }
  34. }
  35. static inline
  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. static inline
  46. int efx_sriov_get_vf_config(struct net_device *net_dev, int vf_i,
  47. struct ifla_vf_info *ivi)
  48. {
  49. struct efx_nic *efx = netdev_priv(net_dev);
  50. if (efx->type->sriov_get_vf_config)
  51. return efx->type->sriov_get_vf_config(efx, vf_i, ivi);
  52. else
  53. return -EOPNOTSUPP;
  54. }
  55. static inline
  56. int efx_sriov_set_vf_link_state(struct net_device *net_dev, int vf_i,
  57. int link_state)
  58. {
  59. struct efx_nic *efx = netdev_priv(net_dev);
  60. if (efx->type->sriov_set_vf_link_state)
  61. return efx->type->sriov_set_vf_link_state(efx, vf_i,
  62. link_state);
  63. else
  64. return -EOPNOTSUPP;
  65. }
  66. #endif /* CONFIG_SFC_SIENA_SRIOV */
  67. #endif /* EFX_SRIOV_H */