i40e_virtchnl_pf.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright(c) 2013 - 2018 Intel Corporation. */
  3. #ifndef _I40E_VIRTCHNL_PF_H_
  4. #define _I40E_VIRTCHNL_PF_H_
  5. #include "i40e.h"
  6. #define I40E_MAX_VLANID 4095
  7. #define I40E_VIRTCHNL_SUPPORTED_QTYPES 2
  8. #define I40E_DEFAULT_NUM_MDD_EVENTS_ALLOWED 3
  9. #define I40E_DEFAULT_NUM_INVALID_MSGS_ALLOWED 10
  10. #define I40E_VLAN_PRIORITY_SHIFT 12
  11. #define I40E_VLAN_MASK 0xFFF
  12. #define I40E_PRIORITY_MASK 0x7000
  13. /* Various queue ctrls */
  14. enum i40e_queue_ctrl {
  15. I40E_QUEUE_CTRL_UNKNOWN = 0,
  16. I40E_QUEUE_CTRL_ENABLE,
  17. I40E_QUEUE_CTRL_ENABLECHECK,
  18. I40E_QUEUE_CTRL_DISABLE,
  19. I40E_QUEUE_CTRL_DISABLECHECK,
  20. I40E_QUEUE_CTRL_FASTDISABLE,
  21. I40E_QUEUE_CTRL_FASTDISABLECHECK,
  22. };
  23. /* VF states */
  24. enum i40e_vf_states {
  25. I40E_VF_STATE_INIT = 0,
  26. I40E_VF_STATE_ACTIVE,
  27. I40E_VF_STATE_IWARPENA,
  28. I40E_VF_STATE_DISABLED,
  29. I40E_VF_STATE_MC_PROMISC,
  30. I40E_VF_STATE_UC_PROMISC,
  31. I40E_VF_STATE_PRE_ENABLE,
  32. };
  33. /* VF capabilities */
  34. enum i40e_vf_capabilities {
  35. I40E_VIRTCHNL_VF_CAP_PRIVILEGE = 0,
  36. I40E_VIRTCHNL_VF_CAP_L2,
  37. I40E_VIRTCHNL_VF_CAP_IWARP,
  38. };
  39. /* In ADq, max 4 VSI's can be allocated per VF including primary VF VSI.
  40. * These variables are used to store indices, id's and number of queues
  41. * for each VSI including that of primary VF VSI. Each Traffic class is
  42. * termed as channel and each channel can in-turn have 4 queues which
  43. * means max 16 queues overall per VF.
  44. */
  45. struct i40evf_channel {
  46. u16 vsi_idx; /* index in PF struct for all channel VSIs */
  47. u16 vsi_id; /* VSI ID used by firmware */
  48. u16 num_qps; /* number of queue pairs requested by user */
  49. u64 max_tx_rate; /* bandwidth rate allocation for VSIs */
  50. };
  51. /* VF information structure */
  52. struct i40e_vf {
  53. struct i40e_pf *pf;
  54. /* VF id in the PF space */
  55. s16 vf_id;
  56. /* all VF vsis connect to the same parent */
  57. enum i40e_switch_element_types parent_type;
  58. struct virtchnl_version_info vf_ver;
  59. u32 driver_caps; /* reported by VF driver */
  60. /* VF Port Extender (PE) stag if used */
  61. u16 stag;
  62. struct virtchnl_ether_addr default_lan_addr;
  63. u16 port_vlan_id;
  64. bool pf_set_mac; /* The VMM admin set the VF MAC address */
  65. bool trusted;
  66. /* VSI indices - actual VSI pointers are maintained in the PF structure
  67. * When assigned, these will be non-zero, because VSI 0 is always
  68. * the main LAN VSI for the PF.
  69. */
  70. u16 lan_vsi_idx; /* index into PF struct */
  71. u16 lan_vsi_id; /* ID as used by firmware */
  72. u8 num_queue_pairs; /* num of qps assigned to VF vsis */
  73. u8 num_req_queues; /* num of requested qps */
  74. u64 num_mdd_events; /* num of mdd events detected */
  75. /* num of continuous malformed or invalid msgs detected */
  76. u64 num_invalid_msgs;
  77. u64 num_valid_msgs; /* num of valid msgs detected */
  78. unsigned long vf_caps; /* vf's adv. capabilities */
  79. unsigned long vf_states; /* vf's runtime states */
  80. unsigned int tx_rate; /* Tx bandwidth limit in Mbps */
  81. bool link_forced;
  82. bool link_up; /* only valid if VF link is forced */
  83. bool spoofchk;
  84. u16 num_mac;
  85. u16 num_vlan;
  86. /* ADq related variables */
  87. bool adq_enabled; /* flag to enable adq */
  88. u8 num_tc;
  89. struct i40evf_channel ch[I40E_MAX_VF_VSI];
  90. struct hlist_head cloud_filter_list;
  91. u16 num_cloud_filters;
  92. /* RDMA Client */
  93. struct virtchnl_iwarp_qvlist_info *qvlist_info;
  94. };
  95. void i40e_free_vfs(struct i40e_pf *pf);
  96. int i40e_pci_sriov_configure(struct pci_dev *dev, int num_vfs);
  97. int i40e_alloc_vfs(struct i40e_pf *pf, u16 num_alloc_vfs);
  98. int i40e_vc_process_vf_msg(struct i40e_pf *pf, s16 vf_id, u32 v_opcode,
  99. u32 v_retval, u8 *msg, u16 msglen);
  100. int i40e_vc_process_vflr_event(struct i40e_pf *pf);
  101. bool i40e_reset_vf(struct i40e_vf *vf, bool flr);
  102. bool i40e_reset_all_vfs(struct i40e_pf *pf, bool flr);
  103. void i40e_vc_notify_vf_reset(struct i40e_vf *vf);
  104. /* VF configuration related iplink handlers */
  105. int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac);
  106. int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, int vf_id,
  107. u16 vlan_id, u8 qos, __be16 vlan_proto);
  108. int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,
  109. int max_tx_rate);
  110. int i40e_ndo_set_vf_trust(struct net_device *netdev, int vf_id, bool setting);
  111. int i40e_ndo_get_vf_config(struct net_device *netdev,
  112. int vf_id, struct ifla_vf_info *ivi);
  113. int i40e_ndo_set_vf_link_state(struct net_device *netdev, int vf_id, int link);
  114. int i40e_ndo_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool enable);
  115. void i40e_vc_notify_link_state(struct i40e_pf *pf);
  116. void i40e_vc_notify_reset(struct i40e_pf *pf);
  117. #endif /* _I40E_VIRTCHNL_PF_H_ */