qlcnic_sriov.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. /*
  2. * QLogic qlcnic NIC Driver
  3. * Copyright (c) 2009-2013 QLogic Corporation
  4. *
  5. * See LICENSE.qlcnic for copyright and licensing details.
  6. */
  7. #ifndef _QLCNIC_83XX_SRIOV_H_
  8. #define _QLCNIC_83XX_SRIOV_H_
  9. #include "qlcnic.h"
  10. #include <linux/types.h>
  11. #include <linux/pci.h>
  12. extern const u32 qlcnic_83xx_reg_tbl[];
  13. extern const u32 qlcnic_83xx_ext_reg_tbl[];
  14. struct qlcnic_bc_payload {
  15. u64 payload[126];
  16. };
  17. struct qlcnic_bc_hdr {
  18. #if defined(__LITTLE_ENDIAN)
  19. u8 version;
  20. u8 msg_type:4;
  21. u8 rsvd1:3;
  22. u8 op_type:1;
  23. u8 num_cmds;
  24. u8 num_frags;
  25. u8 frag_num;
  26. u8 cmd_op;
  27. u16 seq_id;
  28. u64 rsvd3;
  29. #elif defined(__BIG_ENDIAN)
  30. u8 num_frags;
  31. u8 num_cmds;
  32. u8 op_type:1;
  33. u8 rsvd1:3;
  34. u8 msg_type:4;
  35. u8 version;
  36. u16 seq_id;
  37. u8 cmd_op;
  38. u8 frag_num;
  39. u64 rsvd3;
  40. #endif
  41. };
  42. enum qlcnic_bc_commands {
  43. QLCNIC_BC_CMD_CHANNEL_INIT = 0x0,
  44. QLCNIC_BC_CMD_CHANNEL_TERM = 0x1,
  45. QLCNIC_BC_CMD_GET_ACL = 0x2,
  46. QLCNIC_BC_CMD_CFG_GUEST_VLAN = 0x3,
  47. };
  48. #define QLC_BC_CMD 1
  49. struct qlcnic_trans_list {
  50. /* Lock for manipulating list */
  51. spinlock_t lock;
  52. struct list_head wait_list;
  53. int count;
  54. };
  55. enum qlcnic_trans_state {
  56. QLC_INIT = 0,
  57. QLC_WAIT_FOR_CHANNEL_FREE,
  58. QLC_WAIT_FOR_RESP,
  59. QLC_ABORT,
  60. QLC_END,
  61. };
  62. struct qlcnic_bc_trans {
  63. u8 func_id;
  64. u8 active;
  65. u8 curr_rsp_frag;
  66. u8 curr_req_frag;
  67. u16 cmd_id;
  68. u16 req_pay_size;
  69. u16 rsp_pay_size;
  70. u32 trans_id;
  71. enum qlcnic_trans_state trans_state;
  72. struct list_head list;
  73. struct qlcnic_bc_hdr *req_hdr;
  74. struct qlcnic_bc_hdr *rsp_hdr;
  75. struct qlcnic_bc_payload *req_pay;
  76. struct qlcnic_bc_payload *rsp_pay;
  77. struct completion resp_cmpl;
  78. struct qlcnic_vf_info *vf;
  79. };
  80. enum qlcnic_vf_state {
  81. QLC_BC_VF_SEND = 0,
  82. QLC_BC_VF_RECV,
  83. QLC_BC_VF_CHANNEL,
  84. QLC_BC_VF_STATE,
  85. QLC_BC_VF_FLR,
  86. QLC_BC_VF_SOFT_FLR,
  87. };
  88. enum qlcnic_vlan_mode {
  89. QLC_NO_VLAN_MODE = 0,
  90. QLC_PVID_MODE,
  91. QLC_GUEST_VLAN_MODE,
  92. };
  93. struct qlcnic_resources {
  94. u16 num_tx_mac_filters;
  95. u16 num_rx_ucast_mac_filters;
  96. u16 num_rx_mcast_mac_filters;
  97. u16 num_txvlan_keys;
  98. u16 num_rx_queues;
  99. u16 num_tx_queues;
  100. u16 num_rx_buf_rings;
  101. u16 num_rx_status_rings;
  102. u16 num_destip;
  103. u32 num_lro_flows_supported;
  104. u16 max_local_ipv6_addrs;
  105. u16 max_remote_ipv6_addrs;
  106. };
  107. struct qlcnic_vport {
  108. u16 handle;
  109. u16 max_tx_bw;
  110. u16 min_tx_bw;
  111. u8 vlan_mode;
  112. u16 vlan;
  113. u8 qos;
  114. bool spoofchk;
  115. u8 mac[6];
  116. };
  117. struct qlcnic_vf_info {
  118. u8 pci_func;
  119. u16 rx_ctx_id;
  120. u16 tx_ctx_id;
  121. unsigned long state;
  122. struct completion ch_free_cmpl;
  123. struct work_struct trans_work;
  124. struct work_struct flr_work;
  125. /* It synchronizes commands sent from VF */
  126. struct mutex send_cmd_lock;
  127. struct qlcnic_bc_trans *send_cmd;
  128. struct qlcnic_bc_trans *flr_trans;
  129. struct qlcnic_trans_list rcv_act;
  130. struct qlcnic_trans_list rcv_pend;
  131. struct qlcnic_adapter *adapter;
  132. struct qlcnic_vport *vp;
  133. };
  134. struct qlcnic_async_work_list {
  135. struct list_head list;
  136. struct work_struct work;
  137. void *ptr;
  138. };
  139. struct qlcnic_back_channel {
  140. u16 trans_counter;
  141. struct workqueue_struct *bc_trans_wq;
  142. struct workqueue_struct *bc_async_wq;
  143. struct workqueue_struct *bc_flr_wq;
  144. struct list_head async_list;
  145. };
  146. struct qlcnic_sriov {
  147. u16 vp_handle;
  148. u8 num_vfs;
  149. u8 any_vlan;
  150. u8 vlan_mode;
  151. u16 num_allowed_vlans;
  152. u16 *allowed_vlans;
  153. u16 vlan;
  154. struct qlcnic_resources ff_max;
  155. struct qlcnic_back_channel bc;
  156. struct qlcnic_vf_info *vf_info;
  157. };
  158. int qlcnic_sriov_init(struct qlcnic_adapter *, int);
  159. void qlcnic_sriov_cleanup(struct qlcnic_adapter *);
  160. void __qlcnic_sriov_cleanup(struct qlcnic_adapter *);
  161. void qlcnic_sriov_vf_register_map(struct qlcnic_hardware_context *);
  162. int qlcnic_sriov_vf_init(struct qlcnic_adapter *, int);
  163. void qlcnic_sriov_vf_set_ops(struct qlcnic_adapter *);
  164. int qlcnic_sriov_func_to_index(struct qlcnic_adapter *, u8);
  165. int qlcnic_sriov_channel_cfg_cmd(struct qlcnic_adapter *, u8);
  166. void qlcnic_sriov_handle_bc_event(struct qlcnic_adapter *, u32);
  167. int qlcnic_sriov_cfg_bc_intr(struct qlcnic_adapter *, u8);
  168. void qlcnic_sriov_cleanup_async_list(struct qlcnic_back_channel *);
  169. void qlcnic_sriov_cleanup_list(struct qlcnic_trans_list *);
  170. int __qlcnic_sriov_add_act_list(struct qlcnic_sriov *, struct qlcnic_vf_info *,
  171. struct qlcnic_bc_trans *);
  172. int qlcnic_sriov_get_vf_vport_info(struct qlcnic_adapter *,
  173. struct qlcnic_info *, u16);
  174. int qlcnic_sriov_cfg_vf_guest_vlan(struct qlcnic_adapter *, u16, u8);
  175. int qlcnic_sriov_vf_shutdown(struct pci_dev *);
  176. int qlcnic_sriov_vf_resume(struct qlcnic_adapter *);
  177. static inline bool qlcnic_sriov_enable_check(struct qlcnic_adapter *adapter)
  178. {
  179. return test_bit(__QLCNIC_SRIOV_ENABLE, &adapter->state) ? true : false;
  180. }
  181. #ifdef CONFIG_QLCNIC_SRIOV
  182. void qlcnic_sriov_pf_process_bc_cmd(struct qlcnic_adapter *,
  183. struct qlcnic_bc_trans *,
  184. struct qlcnic_cmd_args *);
  185. void qlcnic_sriov_pf_disable(struct qlcnic_adapter *);
  186. void qlcnic_sriov_pf_cleanup(struct qlcnic_adapter *);
  187. int qlcnic_pci_sriov_configure(struct pci_dev *, int);
  188. void qlcnic_pf_set_interface_id_create_rx_ctx(struct qlcnic_adapter *, u32 *);
  189. void qlcnic_pf_set_interface_id_create_tx_ctx(struct qlcnic_adapter *, u32 *);
  190. void qlcnic_pf_set_interface_id_del_rx_ctx(struct qlcnic_adapter *, u32 *);
  191. void qlcnic_pf_set_interface_id_del_tx_ctx(struct qlcnic_adapter *, u32 *);
  192. void qlcnic_pf_set_interface_id_promisc(struct qlcnic_adapter *, u32 *);
  193. void qlcnic_pf_set_interface_id_ipaddr(struct qlcnic_adapter *, u32 *);
  194. void qlcnic_pf_set_interface_id_macaddr(struct qlcnic_adapter *, u32 *);
  195. void qlcnic_sriov_pf_handle_flr(struct qlcnic_sriov *, struct qlcnic_vf_info *);
  196. bool qlcnic_sriov_soft_flr_check(struct qlcnic_adapter *,
  197. struct qlcnic_bc_trans *,
  198. struct qlcnic_vf_info *);
  199. void qlcnic_sriov_pf_reset(struct qlcnic_adapter *);
  200. int qlcnic_sriov_pf_reinit(struct qlcnic_adapter *);
  201. int qlcnic_sriov_set_vf_mac(struct net_device *, int, u8 *);
  202. int qlcnic_sriov_set_vf_tx_rate(struct net_device *, int, int);
  203. int qlcnic_sriov_get_vf_config(struct net_device *, int ,
  204. struct ifla_vf_info *);
  205. int qlcnic_sriov_set_vf_vlan(struct net_device *, int, u16, u8);
  206. int qlcnic_sriov_set_vf_spoofchk(struct net_device *, int, bool);
  207. #else
  208. static inline void qlcnic_sriov_pf_disable(struct qlcnic_adapter *adapter) {}
  209. static inline void qlcnic_sriov_pf_cleanup(struct qlcnic_adapter *adapter) {}
  210. static inline void
  211. qlcnic_pf_set_interface_id_create_rx_ctx(struct qlcnic_adapter *adapter,
  212. u32 *int_id) {}
  213. static inline void
  214. qlcnic_pf_set_interface_id_create_tx_ctx(struct qlcnic_adapter *adapter,
  215. u32 *int_id) {}
  216. static inline void
  217. qlcnic_pf_set_interface_id_del_rx_ctx(struct qlcnic_adapter *adapter,
  218. u32 *int_id) {}
  219. static inline void
  220. qlcnic_pf_set_interface_id_del_tx_ctx(struct qlcnic_adapter *adapter,
  221. u32 *int_id) {}
  222. static inline void
  223. qlcnic_pf_set_interface_id_ipaddr(struct qlcnic_adapter *adapter, u32 *int_id)
  224. {}
  225. static inline void
  226. qlcnic_pf_set_interface_id_macaddr(struct qlcnic_adapter *adapter, u32 *int_id)
  227. {}
  228. static inline void
  229. qlcnic_pf_set_interface_id_promisc(struct qlcnic_adapter *adapter, u32 *int_id)
  230. {}
  231. static inline void qlcnic_sriov_pf_handle_flr(struct qlcnic_sriov *sriov,
  232. struct qlcnic_vf_info *vf) {}
  233. static inline bool qlcnic_sriov_soft_flr_check(struct qlcnic_adapter *adapter,
  234. struct qlcnic_bc_trans *trans,
  235. struct qlcnic_vf_info *vf)
  236. { return false; }
  237. static inline void qlcnic_sriov_pf_reset(struct qlcnic_adapter *adapter) {}
  238. static inline int qlcnic_sriov_pf_reinit(struct qlcnic_adapter *adapter)
  239. { return 0; }
  240. #endif
  241. #endif