📄 target_negotiate.h
字号:
/* common/target_negotiate.h * * This defines the functions used in the Login phase * by the iSCSI target for parameter negotiation * * vi: set autoindent tabstop=8 shiftwidth=4 : * * This file contains auxilliary functions for iscsi initiator * code that are responsible for dealing with error recovery. * * Copyright (C) 2001-2003 InterOperability Lab (IOL) * University of New Hampshier (UNH) * Durham, NH 03824 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * * The name of IOL and/or UNH may not be used to endorse or promote * products derived from this software without specific prior * written permission.*/#ifndef _TARGET_NEGOTIATE_H#define _TARGET_NEGOTIATE_H#include <asm/semaphore.h>/* names of bit numbers in the iscsi_conn control byte */#define SILENCE_BIT 0#define NEED_NOPIN_BIT 1/* maximum number of unreplied-to NopIns to send to initiator before aborting */#define MAX_OUTSTANDING_NOPINS 4/* maximum number of different IP_address:port listening sockets and threads * (used as size of iscsi_portal_groups[]) */#define MAX_PORTAL 32/* queue item to send a reject pdu back to initiator */struct reject_item { struct list_head reject_link; __u8 bad_header[ISCSI_HDR_LEN]; __u8 reason;};/* global struct to store properties corresponding to an iscsi target */struct iscsi_global{ /* conn_id: id assigned to connections within session */ __u32 conn_id; /* ntsih: id assigned to target sessions */ __u16 ntsih; /* Data and Status snack support - SAI */ __u8 targ_snack_flg; /* phase-collapse setting - cdeng */ signed char phase_collapse; /* session_list: list of sessions */ struct list_head session_list; /* bad_session_list: list of sessions that failed during startup */ struct list_head bad_session_list; /* session_sem: semaphore to add and remove sessions from both session lists * this semaphore also controls access to session->conn_list */ struct semaphore session_sem; /* session_read_mutex: semaphore to read (no changes) both session lists * as well as the session->conn_list */ struct semaphore session_read_mutex; /* session_readers: counts number of current readers of the session lists */ __u32 session_readers; /* server_thr: task struct for the server thread */ struct task_struct *server_thr[MAX_PORTAL]; /* server_socket: socket on which the server listens */ struct socket *server_socket[MAX_PORTAL]; /* server_sem: semaphore for killing the server thread */ struct semaphore server_sem; /* device: device returned by the STML */ struct STD *device; /* force: manageable bits to initialize connection flags */ __u32 force; /* nop_period: timeout period to send periodic NopIns to initiator */ __u32 nop_period; /* Added r2t retransmit period - SAI */ __u32 r2t_period; /* text parameters accepted by the target */ struct parameter_type (*param_tbl)[MAX_CONFIG_PARAMS]; /* chap parameter - CHONG */ struct auth_parameter_type auth_parameter;};/* stores everything related to an iscsi connection on the target */struct iscsi_conn { /* conn_link: structure for threading this conn onto lists */ struct list_head conn_link; /* conn_id: the id for this connection */ int conn_id; /* cid: connection id assigned by the Initiator */ __u16 cid; /* portal_group_tag: target_portal_group_tag for the connection */ __u16 portal_group_tag; /* conn_socket: socket used by this connection */ struct socket *conn_socket; /* session: what session does this connection belong to */ struct iscsi_session *session; /* dev: device on which this connection was received */ struct iscsi_global *dev; /* rx_thread: task struct for rx_thread */ struct task_struct *rx_thread; /* tx_thread: task struct for tx_thread */ struct task_struct *tx_thread; /* tx_sem: semaphore to control operation of tx_thread */ struct semaphore tx_sem; /* semaphores to kill rx and tx threads */ struct semaphore kill_rx_sem; struct semaphore kill_tx_sem; /* reject_list: list of rejects to be sent back to initiator */ struct list_head reject_list; /* reject_sem: semaphore to add/remove reject items */ struct semaphore reject_sem; /* bad_hdr: complete header of bad PDU for reject */ __u8 bad_hdr[ISCSI_HDR_LEN]; /* hdr_crc: 1 if header digest in use, else 0 */ int hdr_crc; /* data_crc: 1 if data digest in use, else 0 */ int data_crc; /* active: 1 if connection is in use, else 0 */ __u8 active; /* control: bits to control tx thread wakeups, sending NopIn pings */ unsigned long control; /* nop_period: timeout period to send periodic NopIns to initiator */ __u32 nop_period; struct timer_list nop_timer; /* outstanding_nopins: number of NopIns sent but not yet replied to */ atomic_t outstanding_nopins; /* connection_flags: bits to control stuff during login and FFP */ __u32 connection_flags; /* text_in_progress: ptr to text command in-progress, else NULL */ void *text_in_progress; /* text_in_progress_sem: semaphore to add/remove text_in_progress */ struct semaphore text_in_progress_sem; /* * Connection WIDE COUNTERS: stat_sn */ __u32 stat_sn; __u32 max_send_length; /*initiator's MaxRecvPDULength */ __u32 max_recv_length; /*target's MaxRecvPDULength */ /* fields to keep track of ip addresses */ struct sockaddr *ip_address; /* initiator's ipv4/ipv6 address */ struct sockaddr *local_ip_address;/* target's ipv4/ipv6 address */};/* stores everything related to an iscsi session on the target */struct iscsi_session { /* sess_link: structure for threading this session onto lists */ struct list_head sess_link; /* isid: id assigned to a session by the Initiator */ __u8 isid[6]; /* SNACK flags for Error Recovery - SAI */ __u8 targ_snack_flg; /* tsih: id assigned to a session by the Target */ __u16 tsih; /* portal_group_tag: target_portal_group_tag for the session */ __u16 portal_group_tag; /* cmnd_id: these are the values assigned as target_tags */ __u32 cmnd_id; /* cmnd_list: list of commands received within session */ struct iscsi_cmnd *cmnd_list; /* conn_sem: semaphore to add/remove commands and reject items */ struct semaphore cmnd_sem; /* nconn: no of active connections */ int nconn; /* conn_list: list of connections within session * access to this list is under protection of the session_sem * it can be read only when session_list is read protected * it can be written only when session_list is write protected */ struct list_head conn_list; /* devdata: pointer to the device specific data */ struct iscsi_global *devdata; /* Added the r2t retransmit timer - SAI */ __u32 r2t_period; struct timer_list *r2t_timer; /* error recovery ver ref18_04 */ struct task_struct *retran_thread; struct semaphore retran_sem; struct semaphore thr_kill_sem; /* For parameters */ struct parameter_type (*session_params)[MAX_CONFIG_PARAMS]; struct session_operational_parameters *oper_param; /* version identifiers */ __u8 version_min; __u8 version_max; __u8 version_active; /* * SESSION WIDE COUNTERS: exp_cmd_sn and max_cmd_sn */ __u32 cmd_sn; __u32 exp_cmd_sn; __u32 max_cmd_sn; /* command ordering variables - SAI */ struct semaphore cmd_order_sem; struct order_cmd *cmd_order_head; struct order_cmd *cmd_order_tail;};void __attribute__ ((no_instrument_function))print_isid_tsih_message(struct iscsi_session *session, char *message);int parameter_negotiate(struct iscsi_conn *conn, struct parameter_type p_param_tbl[MAX_CONFIG_PARAMS], struct iscsi_init_login_cmnd *loginpdu, __u32 when_called, struct auth_parameter_type auth_param);/* set back the leading only keys if these keys were set to be * " KEY_TO_BE_NEGOTIATED" in the leading connection negotation.*/void reset_parameter_table(struct parameter_type p_param_tbl[MAX_CONFIG_PARAMS]);/* * iscsi_release_session: This function is responsible for closing out * a session and removing it from whatever list it is on. * INPUT: session to be released * OUTPUT: 0 if success, < 0 if there is trouble */intiscsi_release_session(struct iscsi_session *session);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -