summaryrefslogtreecommitdiff
path: root/usr/flashnode.h
blob: 2950fb5935dadffb69bd2e9b743d6c0d77c250c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
 * iSCSI flashnode helpers
 *
 * Copyright (C) 2013 QLogic Corporation.
 * Maintained by open-iscsi@googlegroups.com
 *
 * 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 of the License, 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.
 *
 * See the file COPYING included with this distribution for more details.
 */
#ifndef FLASHNODE_H
#define FLASHNODE_H
#include <sys/types.h>
#include <netdb.h>
#include <net/if.h>

#include "types.h"
#include "config.h"
#include "auth.h"

#define MAX_FLASHNODE_IDX UINT_MAX

typedef enum portal_type {
	IPV4,
	IPV6,
} portal_type_e;

typedef struct flashnode_sess_rec {
	char			targetname[TARGET_NAME_MAXLEN];
	char			targetalias[TARGET_NAME_MAXLEN];
	char			username[AUTH_STR_MAX_LEN];
	char			username_in[AUTH_STR_MAX_LEN];
	char			password[AUTH_STR_MAX_LEN];
	char			password_in[AUTH_STR_MAX_LEN];
	/* indicates if discovery was done through iSNS discovery service
	 * or through sendTarget */
	char			discovery_parent_type[ISCSI_MAX_STR_LEN];
	char			isid[16];
	char			portal_type[5]; /* ipv4 or ipv6 */
	unsigned		first_burst_len;
	unsigned		max_burst_len;
	uint16_t		def_time2wait;
	uint16_t		def_time2retain;
	uint16_t		max_outstanding_r2t;
	uint16_t		tsid;
	uint16_t		def_taskmgmt_tmo;
	uint16_t		tpgt;
	uint16_t		chap_out_idx;
	uint16_t		chap_in_idx;
	/* index of iSCSI discovery session if the entry is
	 * discovered by iSCSI discovery session
	 */
	uint16_t		discovery_parent_idx;
	/* Firmware auto sendtarget discovery disable */
	uint8_t			auto_snd_tgt_disable;
	uint8_t			discovery_session;
	/* indicates if this flashnode entry is enabled or disabled */
	uint8_t			entry_enable;
	uint8_t			immediate_data;
	uint8_t			initial_r2t;
	uint8_t			data_seq_in_order;
	uint8_t			data_pdu_in_order;
	uint8_t			chap_auth_en;
	/* enables firmware to auto logout the discovery session on discovery
	 * completion
	 */
	uint8_t			discovery_logout_en;
	uint8_t			bidi_chap_en;
	/* makes authentication for discovery session optional */
	uint8_t			discovery_auth_optional;
	uint8_t			erl;
	uint8_t			is_boot_target;
} flashnode_sess_rec_t;

typedef struct flashnode_conn_rec {
	char			ipaddress[NI_MAXHOST];
	char			redirect_ipaddr[NI_MAXHOST];
	char			link_local_ipv6[NI_MAXHOST];
	unsigned		max_recv_dlength;
	unsigned		max_xmit_dlength;
	unsigned		max_segment_size;
	unsigned		tcp_xmit_wsf;
	unsigned		tcp_recv_wsf;
	uint32_t		stat_sn;
	uint32_t		exp_stat_sn;
	uint16_t		keepalive_tmo;
	uint16_t		port;
	uint16_t		local_port;
	uint16_t		ipv6_flow_lbl;
	/* Link local IPv6 address is assigned by firmware or driver */
	uint8_t			is_fw_assigned_ipv6;
	uint8_t			header_digest_en;
	uint8_t			data_digest_en;
	uint8_t			snack_req_en;
	/* tcp timestamp negotiation status */
	uint8_t			tcp_timestamp_stat;
	uint8_t			tcp_nagle_disable;
	/* tcp window scale factor */
	uint8_t			tcp_wsf_disable;
	uint8_t			tcp_timer_scale;
	uint8_t			tcp_timestamp_en;
	uint8_t			fragment_disable;
	uint8_t			ipv4_tos;
	uint8_t			ipv6_traffic_class;
} flashnode_conn_rec_t;

struct flashnode_rec {
	struct list_head	list;
	char			transport_name[ISCSI_TRANSPORT_NAME_MAXLEN];
	flashnode_sess_rec_t	sess;
	flashnode_conn_rec_t	conn[ISCSI_CONN_MAX];
};

extern int flashnode_info_print_flat(void *data, struct flashnode_rec *tgt,
				     uint32_t host_no, uint32_t flashnode_idx);
extern int iscsi_logout_flashnode_sid(struct iscsi_transport *t,
				      uint32_t host_no, uint32_t sid);
extern int flashnode_build_config(struct list_head *params,
				  struct flashnode_rec *flashnode,
				  struct iovec *iovs);
#endif