libsrp.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef __LIBSRP_H__
  2. #define __LIBSRP_H__
  3. #include <linux/list.h>
  4. #include <linux/kfifo.h>
  5. #include <scsi/scsi_cmnd.h>
  6. #include <scsi/scsi_host.h>
  7. #include <scsi/srp.h>
  8. enum iue_flags {
  9. V_DIOVER,
  10. V_WRITE,
  11. V_LINKED,
  12. V_FLYING,
  13. };
  14. struct srp_buf {
  15. dma_addr_t dma;
  16. void *buf;
  17. };
  18. struct srp_queue {
  19. void *pool;
  20. void *items;
  21. struct kfifo queue;
  22. spinlock_t lock;
  23. };
  24. struct srp_target {
  25. struct Scsi_Host *shost;
  26. struct device *dev;
  27. spinlock_t lock;
  28. struct list_head cmd_queue;
  29. size_t srp_iu_size;
  30. struct srp_queue iu_queue;
  31. size_t rx_ring_size;
  32. struct srp_buf **rx_ring;
  33. void *ldata;
  34. };
  35. struct iu_entry {
  36. struct srp_target *target;
  37. struct list_head ilist;
  38. dma_addr_t remote_token;
  39. unsigned long flags;
  40. struct srp_buf *sbuf;
  41. };
  42. typedef int (srp_rdma_t)(struct scsi_cmnd *, struct scatterlist *, int,
  43. struct srp_direct_buf *, int,
  44. enum dma_data_direction, unsigned int);
  45. extern int srp_target_alloc(struct srp_target *, struct device *, size_t, size_t);
  46. extern void srp_target_free(struct srp_target *);
  47. extern struct iu_entry *srp_iu_get(struct srp_target *);
  48. extern void srp_iu_put(struct iu_entry *);
  49. extern int srp_cmd_queue(struct Scsi_Host *, struct srp_cmd *, void *, u64, u64);
  50. extern int srp_transfer_data(struct scsi_cmnd *, struct srp_cmd *,
  51. srp_rdma_t, int, int);
  52. static inline struct srp_target *host_to_srp_target(struct Scsi_Host *host)
  53. {
  54. return (struct srp_target *) host->hostdata;
  55. }
  56. static inline int srp_cmd_direction(struct srp_cmd *cmd)
  57. {
  58. return (cmd->buf_fmt >> 4) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
  59. }
  60. #endif