Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * iSCSI over TCP/IP Data-Path lib
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2008 Mike Christie
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 2008 Red Hat, Inc.  All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * maintained by open-iscsi@googlegroups.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #ifndef LIBISCSI_TCP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #define LIBISCSI_TCP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <scsi/libiscsi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) struct iscsi_tcp_conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) struct iscsi_segment;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) struct sk_buff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) struct ahash_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) typedef int iscsi_segment_done_fn_t(struct iscsi_tcp_conn *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 				    struct iscsi_segment *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) struct iscsi_segment {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	unsigned char		*data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	unsigned int		size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	unsigned int		copied;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	unsigned int		total_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	unsigned int		total_copied;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	struct ahash_request	*hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	unsigned char		padbuf[ISCSI_PAD_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	unsigned char		recv_digest[ISCSI_DIGEST_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	unsigned char		digest[ISCSI_DIGEST_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	unsigned int		digest_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	struct scatterlist	*sg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	void			*sg_mapped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	unsigned int		sg_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	bool			atomic_mapped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	iscsi_segment_done_fn_t	*done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) /* Socket connection receive helper */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) struct iscsi_tcp_recv {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	struct iscsi_hdr	*hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	struct iscsi_segment	segment;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	/* Allocate buffer for BHS + AHS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	uint32_t		hdr_buf[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	/* copied and flipped values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	int			datalen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) struct iscsi_tcp_conn {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	struct iscsi_conn	*iscsi_conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	void			*dd_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	int			stop_stage;	/* conn_stop() flag: *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 						 * stop to recover,  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 						 * stop to terminate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	/* control data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	struct iscsi_tcp_recv	in;		/* TCP receive context */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	/* CRC32C (Rx) LLD should set this is they do not offload */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	struct ahash_request	*rx_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) struct iscsi_tcp_task {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	uint32_t		exp_datasn;	/* expected target's R2TSN/DataSN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	int			data_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	struct iscsi_r2t_info	*r2t;		/* in progress solict R2T */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	struct iscsi_pool	r2tpool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	struct kfifo		r2tqueue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	void			*dd_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	spinlock_t		pool2queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	spinlock_t		queue2pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	ISCSI_TCP_SEGMENT_DONE,		/* curr seg has been processed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	ISCSI_TCP_SKB_DONE,		/* skb is out of data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	ISCSI_TCP_CONN_ERR,		/* iscsi layer has fired a conn err */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	ISCSI_TCP_SUSPENDED,		/* conn is suspended */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) extern void iscsi_tcp_hdr_recv_prep(struct iscsi_tcp_conn *tcp_conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) extern int iscsi_tcp_recv_skb(struct iscsi_conn *conn, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 			      unsigned int offset, bool offloaded, int *status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) extern void iscsi_tcp_cleanup_task(struct iscsi_task *task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) extern int iscsi_tcp_task_init(struct iscsi_task *task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) extern int iscsi_tcp_task_xmit(struct iscsi_task *task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) /* segment helpers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) extern int iscsi_tcp_recv_segment_is_hdr(struct iscsi_tcp_conn *tcp_conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) extern int iscsi_tcp_segment_done(struct iscsi_tcp_conn *tcp_conn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 				  struct iscsi_segment *segment, int recv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 				  unsigned copied);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) extern void iscsi_tcp_segment_unmap(struct iscsi_segment *segment);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) extern void iscsi_segment_init_linear(struct iscsi_segment *segment,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 				      void *data, size_t size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 				      iscsi_segment_done_fn_t *done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 				      struct ahash_request *hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) extern int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) iscsi_segment_seek_sg(struct iscsi_segment *segment,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		      struct scatterlist *sg_list, unsigned int sg_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		      unsigned int offset, size_t size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		      iscsi_segment_done_fn_t *done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		      struct ahash_request *hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) /* digest helpers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) extern void iscsi_tcp_dgst_header(struct ahash_request *hash, const void *hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 				  size_t hdrlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 				  unsigned char digest[ISCSI_DIGEST_SIZE]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) extern struct iscsi_cls_conn *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) iscsi_tcp_conn_setup(struct iscsi_cls_session *cls_session, int dd_data_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		     uint32_t conn_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) extern void iscsi_tcp_conn_teardown(struct iscsi_cls_conn *cls_conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) /* misc helpers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) extern int iscsi_tcp_r2tpool_alloc(struct iscsi_session *session);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) extern void iscsi_tcp_r2tpool_free(struct iscsi_session *session);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) extern int iscsi_tcp_set_max_r2t(struct iscsi_conn *conn, char *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) extern void iscsi_tcp_conn_get_stats(struct iscsi_cls_conn *cls_conn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 				     struct iscsi_stats *stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #endif /* LIBISCSI_TCP_H */