1/*	$wasabi: iscsi_testlocal.h,v 1.5 2006/05/30 23:22:20 twagner Exp $ */
2/*	$NetBSD: iscsi_testlocal.h,v 1.2 2011/06/09 22:08:19 riz Exp $	*/
3
4/*-
5 * Copyright (c) 2006,2011 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Wasabi Systems, Inc.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 *    notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 *    notice, this list of conditions and the following disclaimer in the
18 *    documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32#ifndef _ISCSI_TESTLOCAL_H
33#define _ISCSI_TESTLOCAL_H
34
35#ifdef ISCSI_TEST_MODE
36
37typedef struct mod_desc_s
38{
39	TAILQ_ENTRY(mod_desc_s) link;
40	void *pdu_ptr;			/* get only */
41	iscsi_test_add_modification_parameters_t pars;
42	iscsi_pdu_mod_t mods[0];
43} mod_desc_t;
44
45
46typedef struct neg_desc_s
47{
48	TAILQ_ENTRY(neg_desc_s) link;
49	iscsi_test_negotiation_descriptor_t entry;
50} neg_desc_t;
51
52
53TAILQ_HEAD(mod_list_s, mod_desc_s);
54typedef struct mod_list_s mod_list_t;
55
56TAILQ_HEAD(neg_list_s, neg_desc_s);
57typedef struct neg_list_s neg_list_t;
58
59#define CNT_TX    0
60#define CNT_RX    1
61
62typedef struct test_pars_s
63{
64	TAILQ_ENTRY(test_pars_s) link;	/* links tests to be assigned */
65	uint32_t test_id;			/* Test ID */
66	connection_t *connection;	/* Attached Connection */
67	uint16_t options;			/* Test options */
68	uint8_t lose_random[2];	/* 0 disables, else mod value */
69	uint32_t r2t_val;			/* Used only if NEGOTIATE_R2T */
70	uint32_t maxburst_val;		/* Used only if NEGOTIATE_MAXBURST */
71	uint32_t firstburst_val;	/* Used only if NEGOTIATE_FIRSTBURST */
72	neg_list_t negs;			/* list of negotiation descriptors */
73	mod_list_t mods;			/* list of modification decriptors */
74	uint32_t pdu_count[INVALID_PDU + 1][2];	/* PDU counter */
75	uint32_t pdu_last[INVALID_PDU + 1][2];	/* last PDU counter */
76} test_pars_t;
77
78
79TAILQ_HEAD(test_pars_list_s, test_pars_s);
80typedef struct test_pars_list_s test_pars_list_t;
81
82void test_assign_connection(connection_t *);
83void test_remove_connection(connection_t *);
84
85#define TEST_INVALID_HEADER_CRC     -99
86#define TEST_READ_ERROR             1
87#define TEST_INVALID_DATA_CRC       -1
88
89int test_mode_rx(connection_t *, pdu_t *, int);
90int test_mode_tx(connection_t *, pdu_t *);
91
92void test_define(iscsi_test_define_parameters_t *);
93void test_add_neg(iscsi_test_add_negotiation_parameters_t *);
94void test_add_mod(struct proc *, iscsi_test_add_modification_parameters_t *);
95void test_send_pdu(struct proc *, iscsi_test_send_pdu_parameters_t *);
96void test_cancel(iscsi_test_cancel_parameters_t *);
97
98#define test_ccb_timeout(conn) ((conn->test_pars == NULL) ? 1 \
99      : !(conn->test_pars->options & ISCSITEST_OPT_DISABLE_CCB_TIMEOUT))
100
101#define test_conn_timeout(conn) ((conn->test_pars == NULL) ? 1 \
102      : !(conn->test_pars->options & ISCSITEST_OPT_DISABLE_CONN_TIMEOUT))
103
104#endif /* TEST_MODE */
105#endif /* TESTLOCAL_H */
106