bsg-lib.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * BSG helper library
  4. *
  5. * Copyright (C) 2008 James Smart, Emulex Corporation
  6. * Copyright (C) 2011 Red Hat, Inc. All rights reserved.
  7. * Copyright (C) 2011 Mike Christie
  8. */
  9. #ifndef _BLK_BSG_
  10. #define _BLK_BSG_
  11. #include <linux/blkdev.h>
  12. struct bsg_job;
  13. struct request;
  14. struct device;
  15. struct scatterlist;
  16. struct request_queue;
  17. typedef int (bsg_job_fn) (struct bsg_job *);
  18. typedef enum blk_eh_timer_return (bsg_timeout_fn)(struct request *);
  19. struct bsg_buffer {
  20. unsigned int payload_len;
  21. int sg_cnt;
  22. struct scatterlist *sg_list;
  23. };
  24. struct bsg_job {
  25. struct device *dev;
  26. struct kref kref;
  27. unsigned int timeout;
  28. /* Transport/driver specific request/reply structs */
  29. void *request;
  30. void *reply;
  31. unsigned int request_len;
  32. unsigned int reply_len;
  33. /*
  34. * On entry : reply_len indicates the buffer size allocated for
  35. * the reply.
  36. *
  37. * Upon completion : the message handler must set reply_len
  38. * to indicates the size of the reply to be returned to the
  39. * caller.
  40. */
  41. /* DMA payloads for the request/response */
  42. struct bsg_buffer request_payload;
  43. struct bsg_buffer reply_payload;
  44. int result;
  45. unsigned int reply_payload_rcv_len;
  46. /* BIDI support */
  47. struct request *bidi_rq;
  48. struct bio *bidi_bio;
  49. void *dd_data; /* Used for driver-specific storage */
  50. };
  51. void bsg_job_done(struct bsg_job *job, int result,
  52. unsigned int reply_payload_rcv_len);
  53. struct request_queue *bsg_setup_queue(struct device *dev, const char *name,
  54. bsg_job_fn *job_fn, bsg_timeout_fn *timeout, int dd_job_size);
  55. void bsg_remove_queue(struct request_queue *q);
  56. void bsg_job_put(struct bsg_job *job);
  57. int __must_check bsg_job_get(struct bsg_job *job);
  58. #endif