snic_res.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright 2014 Cisco Systems, Inc. All rights reserved. */
  3. #ifndef __SNIC_RES_H
  4. #define __SNIC_RES_H
  5. #include "snic_io.h"
  6. #include "wq_enet_desc.h"
  7. #include "vnic_wq.h"
  8. #include "snic_fwint.h"
  9. #include "vnic_cq_fw.h"
  10. static inline void
  11. snic_icmnd_init(struct snic_host_req *req, u32 cmnd_id, u32 host_id, u64 ctx,
  12. u16 flags, u64 tgt_id, u8 *lun, u8 *scsi_cdb, u8 cdb_len,
  13. u32 data_len, u16 sg_cnt, ulong sgl_addr,
  14. dma_addr_t sns_addr_pa, u32 sense_len)
  15. {
  16. snic_io_hdr_enc(&req->hdr, SNIC_REQ_ICMND, 0, cmnd_id, host_id, sg_cnt,
  17. ctx);
  18. req->u.icmnd.flags = cpu_to_le16(flags);
  19. req->u.icmnd.tgt_id = cpu_to_le64(tgt_id);
  20. memcpy(&req->u.icmnd.lun_id, lun, LUN_ADDR_LEN);
  21. req->u.icmnd.cdb_len = cdb_len;
  22. memset(req->u.icmnd.cdb, 0, SNIC_CDB_LEN);
  23. memcpy(req->u.icmnd.cdb, scsi_cdb, cdb_len);
  24. req->u.icmnd.data_len = cpu_to_le32(data_len);
  25. req->u.icmnd.sg_addr = cpu_to_le64(sgl_addr);
  26. req->u.icmnd.sense_len = cpu_to_le32(sense_len);
  27. req->u.icmnd.sense_addr = cpu_to_le64(sns_addr_pa);
  28. }
  29. static inline void
  30. snic_itmf_init(struct snic_host_req *req, u32 cmnd_id, u32 host_id, ulong ctx,
  31. u16 flags, u32 req_id, u64 tgt_id, u8 *lun, u8 tm_type)
  32. {
  33. snic_io_hdr_enc(&req->hdr, SNIC_REQ_ITMF, 0, cmnd_id, host_id, 0, ctx);
  34. req->u.itmf.tm_type = tm_type;
  35. req->u.itmf.flags = cpu_to_le16(flags);
  36. /* req_id valid only in abort, clear task */
  37. req->u.itmf.req_id = cpu_to_le32(req_id);
  38. req->u.itmf.tgt_id = cpu_to_le64(tgt_id);
  39. memcpy(&req->u.itmf.lun_id, lun, LUN_ADDR_LEN);
  40. }
  41. static inline void
  42. snic_queue_wq_eth_desc(struct vnic_wq *wq,
  43. void *os_buf,
  44. dma_addr_t dma_addr,
  45. unsigned int len,
  46. int vlan_tag_insert,
  47. unsigned int vlan_tag,
  48. int cq_entry)
  49. {
  50. struct wq_enet_desc *desc = svnic_wq_next_desc(wq);
  51. wq_enet_desc_enc(desc,
  52. (u64)dma_addr | VNIC_PADDR_TARGET,
  53. (u16)len,
  54. 0, /* mss_or_csum_offset */
  55. 0, /* fc_eof */
  56. 0, /* offload mode */
  57. 1, /* eop */
  58. (u8)cq_entry,
  59. 0, /* fcoe_encap */
  60. (u8)vlan_tag_insert,
  61. (u16)vlan_tag,
  62. 0 /* loopback */);
  63. svnic_wq_post(wq, os_buf, dma_addr, len, 1, 1);
  64. }
  65. struct snic;
  66. int snic_get_vnic_config(struct snic *);
  67. int snic_alloc_vnic_res(struct snic *);
  68. void snic_free_vnic_res(struct snic *);
  69. void snic_get_res_counts(struct snic *);
  70. void snic_log_q_error(struct snic *);
  71. int snic_get_vnic_resources_size(struct snic *);
  72. #endif /* __SNIC_RES_H */