libsrp.h 1.5 KB

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