snic_res.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright 2014 Cisco Systems, Inc. All rights reserved.
  3. *
  4. * This program is free software; you may redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; version 2 of the License.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  9. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  11. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  12. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  13. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  14. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  15. * SOFTWARE.
  16. */
  17. #ifndef __SNIC_RES_H
  18. #define __SNIC_RES_H
  19. #include "snic_io.h"
  20. #include "wq_enet_desc.h"
  21. #include "vnic_wq.h"
  22. #include "snic_fwint.h"
  23. #include "vnic_cq_fw.h"
  24. static inline void
  25. snic_icmnd_init(struct snic_host_req *req, u32 cmnd_id, u32 host_id, u64 ctx,
  26. u16 flags, u64 tgt_id, u8 *lun, u8 *scsi_cdb, u8 cdb_len,
  27. u32 data_len, u16 sg_cnt, ulong sgl_addr,
  28. dma_addr_t sns_addr_pa, u32 sense_len)
  29. {
  30. snic_io_hdr_enc(&req->hdr, SNIC_REQ_ICMND, 0, cmnd_id, host_id, sg_cnt,
  31. ctx);
  32. req->u.icmnd.flags = cpu_to_le16(flags);
  33. req->u.icmnd.tgt_id = cpu_to_le64(tgt_id);
  34. memcpy(&req->u.icmnd.lun_id, lun, LUN_ADDR_LEN);
  35. req->u.icmnd.cdb_len = cdb_len;
  36. memset(req->u.icmnd.cdb, 0, SNIC_CDB_LEN);
  37. memcpy(req->u.icmnd.cdb, scsi_cdb, cdb_len);
  38. req->u.icmnd.data_len = cpu_to_le32(data_len);
  39. req->u.icmnd.sg_addr = cpu_to_le64(sgl_addr);
  40. req->u.icmnd.sense_len = cpu_to_le32(sense_len);
  41. req->u.icmnd.sense_addr = cpu_to_le64(sns_addr_pa);
  42. }
  43. static inline void
  44. snic_itmf_init(struct snic_host_req *req, u32 cmnd_id, u32 host_id, ulong ctx,
  45. u16 flags, u32 req_id, u64 tgt_id, u8 *lun, u8 tm_type)
  46. {
  47. snic_io_hdr_enc(&req->hdr, SNIC_REQ_ITMF, 0, cmnd_id, host_id, 0, ctx);
  48. req->u.itmf.tm_type = tm_type;
  49. req->u.itmf.flags = cpu_to_le16(flags);
  50. /* req_id valid only in abort, clear task */
  51. req->u.itmf.req_id = cpu_to_le32(req_id);
  52. req->u.itmf.tgt_id = cpu_to_le64(tgt_id);
  53. memcpy(&req->u.itmf.lun_id, lun, LUN_ADDR_LEN);
  54. }
  55. static inline void
  56. snic_queue_wq_eth_desc(struct vnic_wq *wq,
  57. void *os_buf,
  58. dma_addr_t dma_addr,
  59. unsigned int len,
  60. int vlan_tag_insert,
  61. unsigned int vlan_tag,
  62. int cq_entry)
  63. {
  64. struct wq_enet_desc *desc = svnic_wq_next_desc(wq);
  65. wq_enet_desc_enc(desc,
  66. (u64)dma_addr | VNIC_PADDR_TARGET,
  67. (u16)len,
  68. 0, /* mss_or_csum_offset */
  69. 0, /* fc_eof */
  70. 0, /* offload mode */
  71. 1, /* eop */
  72. (u8)cq_entry,
  73. 0, /* fcoe_encap */
  74. (u8)vlan_tag_insert,
  75. (u16)vlan_tag,
  76. 0 /* loopback */);
  77. svnic_wq_post(wq, os_buf, dma_addr, len, 1, 1);
  78. }
  79. struct snic;
  80. int snic_get_vnic_config(struct snic *);
  81. int snic_alloc_vnic_res(struct snic *);
  82. void snic_free_vnic_res(struct snic *);
  83. void snic_get_res_counts(struct snic *);
  84. void snic_log_q_error(struct snic *);
  85. int snic_get_vnic_resources_size(struct snic *);
  86. #endif /* __SNIC_RES_H */