ice_virtchnl_pf.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2018, Intel Corporation. */
  3. #ifndef _ICE_VIRTCHNL_PF_H_
  4. #define _ICE_VIRTCHNL_PF_H_
  5. #include "ice.h"
  6. #define ICE_MAX_VLANID 4095
  7. #define ICE_VLAN_PRIORITY_S 12
  8. #define ICE_VLAN_M 0xFFF
  9. #define ICE_PRIORITY_M 0x7000
  10. #define ICE_MAX_VLAN_PER_VF 8 /* restriction for non-trusted VF */
  11. /* Restrict number of MACs a non-trusted VF can program */
  12. #define ICE_MAX_MACADDR_PER_VF 12
  13. #define ICE_DFLT_NUM_INVAL_MSGS_ALLOWED 10
  14. /* Static VF transaction/status register def */
  15. #define VF_DEVICE_STATUS 0xAA
  16. #define VF_TRANS_PENDING_M 0x20
  17. /* Specific VF states */
  18. enum ice_vf_states {
  19. ICE_VF_STATE_INIT = 0,
  20. ICE_VF_STATE_ACTIVE,
  21. ICE_VF_STATE_ENA,
  22. ICE_VF_STATE_DIS,
  23. ICE_VF_STATE_MC_PROMISC,
  24. ICE_VF_STATE_UC_PROMISC,
  25. /* state to indicate if PF needs to do vector assignment for VF.
  26. * This needs to be set during first time VF initialization or later
  27. * when VF asks for more Vectors through virtchnl OP.
  28. */
  29. ICE_VF_STATE_CFG_INTR,
  30. ICE_VF_STATES_NBITS
  31. };
  32. /* VF capabilities */
  33. enum ice_virtchnl_cap {
  34. ICE_VIRTCHNL_VF_CAP_L2 = 0,
  35. ICE_VIRTCHNL_VF_CAP_PRIVILEGE,
  36. };
  37. /* VF information structure */
  38. struct ice_vf {
  39. struct ice_pf *pf;
  40. s16 vf_id; /* VF id in the PF space */
  41. u32 driver_caps; /* reported by VF driver */
  42. int first_vector_idx; /* first vector index of this VF */
  43. struct ice_sw *vf_sw_id; /* switch id the VF VSIs connect to */
  44. struct virtchnl_version_info vf_ver;
  45. struct virtchnl_ether_addr dflt_lan_addr;
  46. u16 port_vlan_id;
  47. u8 pf_set_mac; /* VF MAC address set by VMM admin */
  48. u8 trusted;
  49. u16 lan_vsi_idx; /* index into PF struct */
  50. u16 lan_vsi_num; /* ID as used by firmware */
  51. u64 num_inval_msgs; /* number of continuous invalid msgs */
  52. u64 num_valid_msgs; /* number of valid msgs detected */
  53. unsigned long vf_caps; /* vf's adv. capabilities */
  54. DECLARE_BITMAP(vf_states, ICE_VF_STATES_NBITS); /* VF runtime states */
  55. unsigned int tx_rate; /* Tx bandwidth limit in Mbps */
  56. u8 link_forced;
  57. u8 link_up; /* only valid if VF link is forced */
  58. u8 spoofchk;
  59. u16 num_mac;
  60. u16 num_vlan;
  61. u8 num_req_qs; /* num of queue pairs requested by VF */
  62. };
  63. #ifdef CONFIG_PCI_IOV
  64. void ice_process_vflr_event(struct ice_pf *pf);
  65. int ice_sriov_configure(struct pci_dev *pdev, int num_vfs);
  66. int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac);
  67. int ice_get_vf_cfg(struct net_device *netdev, int vf_id,
  68. struct ifla_vf_info *ivi);
  69. void ice_free_vfs(struct ice_pf *pf);
  70. void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event);
  71. void ice_vc_notify_link_state(struct ice_pf *pf);
  72. void ice_vc_notify_reset(struct ice_pf *pf);
  73. bool ice_reset_all_vfs(struct ice_pf *pf, bool is_vflr);
  74. int ice_set_vf_port_vlan(struct net_device *netdev, int vf_id,
  75. u16 vlan_id, u8 qos, __be16 vlan_proto);
  76. int ice_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,
  77. int max_tx_rate);
  78. int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted);
  79. int ice_set_vf_link_state(struct net_device *netdev, int vf_id, int link_state);
  80. int ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena);
  81. #else /* CONFIG_PCI_IOV */
  82. #define ice_process_vflr_event(pf) do {} while (0)
  83. #define ice_free_vfs(pf) do {} while (0)
  84. #define ice_vc_process_vf_msg(pf, event) do {} while (0)
  85. #define ice_vc_notify_link_state(pf) do {} while (0)
  86. #define ice_vc_notify_reset(pf) do {} while (0)
  87. static inline bool
  88. ice_reset_all_vfs(struct ice_pf __always_unused *pf,
  89. bool __always_unused is_vflr)
  90. {
  91. return true;
  92. }
  93. static inline int
  94. ice_sriov_configure(struct pci_dev __always_unused *pdev,
  95. int __always_unused num_vfs)
  96. {
  97. return -EOPNOTSUPP;
  98. }
  99. static inline int
  100. ice_set_vf_mac(struct net_device __always_unused *netdev,
  101. int __always_unused vf_id, u8 __always_unused *mac)
  102. {
  103. return -EOPNOTSUPP;
  104. }
  105. static inline int
  106. ice_get_vf_cfg(struct net_device __always_unused *netdev,
  107. int __always_unused vf_id,
  108. struct ifla_vf_info __always_unused *ivi)
  109. {
  110. return -EOPNOTSUPP;
  111. }
  112. static inline int
  113. ice_set_vf_trust(struct net_device __always_unused *netdev,
  114. int __always_unused vf_id, bool __always_unused trusted)
  115. {
  116. return -EOPNOTSUPP;
  117. }
  118. static inline int
  119. ice_set_vf_port_vlan(struct net_device __always_unused *netdev,
  120. int __always_unused vf_id, u16 __always_unused vid,
  121. u8 __always_unused qos, __be16 __always_unused v_proto)
  122. {
  123. return -EOPNOTSUPP;
  124. }
  125. static inline int
  126. ice_set_vf_spoofchk(struct net_device __always_unused *netdev,
  127. int __always_unused vf_id, bool __always_unused ena)
  128. {
  129. return -EOPNOTSUPP;
  130. }
  131. static inline int
  132. ice_set_vf_link_state(struct net_device __always_unused *netdev,
  133. int __always_unused vf_id, int __always_unused link_state)
  134. {
  135. return -EOPNOTSUPP;
  136. }
  137. static inline int
  138. ice_set_vf_bw(struct net_device __always_unused *netdev,
  139. int __always_unused vf_id, int __always_unused min_tx_rate,
  140. int __always_unused max_tx_rate)
  141. {
  142. return -EOPNOTSUPP;
  143. }
  144. #endif /* CONFIG_PCI_IOV */
  145. #endif /* _ICE_VIRTCHNL_PF_H_ */