ice_virtchnl_pf.h 5.0 KB

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