Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  *  BSG helper library
0004  *
0005  *  Copyright (C) 2008   James Smart, Emulex Corporation
0006  *  Copyright (C) 2011   Red Hat, Inc.  All rights reserved.
0007  *  Copyright (C) 2011   Mike Christie
0008  */
0009 #ifndef _BLK_BSG_
0010 #define _BLK_BSG_
0011 
0012 #include <linux/blkdev.h>
0013 
0014 struct bsg_job;
0015 struct request;
0016 struct device;
0017 struct scatterlist;
0018 struct request_queue;
0019 
0020 typedef int (bsg_job_fn) (struct bsg_job *);
0021 typedef enum blk_eh_timer_return (bsg_timeout_fn)(struct request *);
0022 
0023 struct bsg_buffer {
0024     unsigned int payload_len;
0025     int sg_cnt;
0026     struct scatterlist *sg_list;
0027 };
0028 
0029 struct bsg_job {
0030     struct device *dev;
0031 
0032     struct kref kref;
0033 
0034     unsigned int timeout;
0035 
0036     /* Transport/driver specific request/reply structs */
0037     void *request;
0038     void *reply;
0039 
0040     unsigned int request_len;
0041     unsigned int reply_len;
0042     /*
0043      * On entry : reply_len indicates the buffer size allocated for
0044      * the reply.
0045      *
0046      * Upon completion : the message handler must set reply_len
0047      *  to indicates the size of the reply to be returned to the
0048      *  caller.
0049      */
0050 
0051     /* DMA payloads for the request/response */
0052     struct bsg_buffer request_payload;
0053     struct bsg_buffer reply_payload;
0054 
0055     int result;
0056     unsigned int reply_payload_rcv_len;
0057 
0058     /* BIDI support */
0059     struct request *bidi_rq;
0060     struct bio *bidi_bio;
0061 
0062     void *dd_data;      /* Used for driver-specific storage */
0063 };
0064 
0065 void bsg_job_done(struct bsg_job *job, int result,
0066           unsigned int reply_payload_rcv_len);
0067 struct request_queue *bsg_setup_queue(struct device *dev, const char *name,
0068         bsg_job_fn *job_fn, bsg_timeout_fn *timeout, int dd_job_size);
0069 void bsg_remove_queue(struct request_queue *q);
0070 void bsg_job_put(struct bsg_job *job);
0071 int __must_check bsg_job_get(struct bsg_job *job);
0072 
0073 #endif