summaryrefslogtreecommitdiff
path: root/drivers/scsi/elx/libefc/efc_node.h
blob: e9c600ac45d55fbca50d45250a566a0c2cf820de (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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (C) 2021 Broadcom. All Rights Reserved. The term
 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
 */

#if !defined(__EFC_NODE_H__)
#define __EFC_NODE_H__
#include "scsi/fc/fc_ns.h"

#define EFC_NODEDB_PAUSE_FABRIC_LOGIN	(1 << 0)
#define EFC_NODEDB_PAUSE_NAMESERVER	(1 << 1)
#define EFC_NODEDB_PAUSE_NEW_NODES	(1 << 2)

#define MAX_ACC_REJECT_PAYLOAD	sizeof(struct fc_els_ls_rjt)

#define scsi_io_printf(io, fmt, ...) \
	efc_log_debug(io->efc, "[%s] [%04x][i:%04x t:%04x h:%04x]" fmt, \
	io->node->display_name, io->instance_index, io->init_task_tag, \
	io->tgt_task_tag, io->hw_tag, ##__VA_ARGS__)

static inline void
efc_node_evt_set(struct efc_sm_ctx *ctx, enum efc_sm_event evt,
		 const char *handler)
{
	struct efc_node *node = ctx->app;

	if (evt == EFC_EVT_ENTER) {
		strncpy(node->current_state_name, handler,
			sizeof(node->current_state_name));
	} else if (evt == EFC_EVT_EXIT) {
		strncpy(node->prev_state_name, node->current_state_name,
			sizeof(node->prev_state_name));
		strncpy(node->current_state_name, "invalid",
			sizeof(node->current_state_name));
	}
	node->prev_evt = node->current_evt;
	node->current_evt = evt;
}

/**
 * hold frames in pending frame list
 *
 * Unsolicited receive frames are held on the node pending frame list,
 * rather than being processed.
 */

static inline void
efc_node_hold_frames(struct efc_node *node)
{
	node->hold_frames = true;
}

/**
 * accept frames
 *
 * Unsolicited receive frames processed rather than being held on the node
 * pending frame list.
 */

static inline void
efc_node_accept_frames(struct efc_node *node)
{
	node->hold_frames = false;
}

/*
 * Node initiator/target enable defines
 * All combinations of the SLI port (nport) initiator/target enable,
 * and remote node initiator/target enable are enumerated.
 * ex: EFC_NODE_ENABLE_T_TO_IT decodes to target mode is enabled on SLI port
 * and I+T is enabled on remote node.
 */
enum efc_node_enable {
	EFC_NODE_ENABLE_x_TO_x,
	EFC_NODE_ENABLE_x_TO_T,
	EFC_NODE_ENABLE_x_TO_I,
	EFC_NODE_ENABLE_x_TO_IT,
	EFC_NODE_ENABLE_T_TO_x,
	EFC_NODE_ENABLE_T_TO_T,
	EFC_NODE_ENABLE_T_TO_I,
	EFC_NODE_ENABLE_T_TO_IT,
	EFC_NODE_ENABLE_I_TO_x,
	EFC_NODE_ENABLE_I_TO_T,
	EFC_NODE_ENABLE_I_TO_I,
	EFC_NODE_ENABLE_I_TO_IT,
	EFC_NODE_ENABLE_IT_TO_x,
	EFC_NODE_ENABLE_IT_TO_T,
	EFC_NODE_ENABLE_IT_TO_I,
	EFC_NODE_ENABLE_IT_TO_IT,
};

static inline enum efc_node_enable
efc_node_get_enable(struct efc_node *node)
{
	u32 retval = 0;

	if (node->nport->enable_ini)
		retval |= (1U << 3);
	if (node->nport->enable_tgt)
		retval |= (1U << 2);
	if (node->init)
		retval |= (1U << 1);
	if (node->targ)
		retval |= (1U << 0);
	return (enum efc_node_enable)retval;
}

int
efc_node_check_els_req(struct efc_sm_ctx *ctx,
		       enum efc_sm_event evt, void *arg,
		       u8 cmd, void (*efc_node_common_func)(const char *,
		       struct efc_sm_ctx *, enum efc_sm_event, void *),
		       const char *funcname);
int
efc_node_check_ns_req(struct efc_sm_ctx *ctx,
		      enum efc_sm_event evt, void *arg,
		      u16 cmd, void (*efc_node_common_func)(const char *,
		      struct efc_sm_ctx *, enum efc_sm_event, void *),
		      const char *funcname);
int
efc_node_attach(struct efc_node *node);
struct efc_node *
efc_node_alloc(struct efc_nport *nport, u32 port_id,
	       bool init, bool targ);
void
efc_node_free(struct efc_node *efc);
void
efc_node_update_display_name(struct efc_node *node);
void efc_node_post_event(struct efc_node *node, enum efc_sm_event evt,
			 void *arg);

void
__efc_node_shutdown(struct efc_sm_ctx *ctx,
		    enum efc_sm_event evt, void *arg);
void
__efc_node_wait_node_free(struct efc_sm_ctx *ctx,
			  enum efc_sm_event evt, void *arg);
void
__efc_node_wait_els_shutdown(struct efc_sm_ctx *ctx,
			     enum efc_sm_event evt, void *arg);
void
__efc_node_wait_ios_shutdown(struct efc_sm_ctx *ctx,
			     enum efc_sm_event evt, void *arg);
void
efc_node_save_sparms(struct efc_node *node, void *payload);
void
efc_node_transition(struct efc_node *node,
		    void (*state)(struct efc_sm_ctx *, enum efc_sm_event,
				  void *), void *data);
void
__efc_node_common(const char *funcname, struct efc_sm_ctx *ctx,
		  enum efc_sm_event evt, void *arg);

void
efc_node_initiate_cleanup(struct efc_node *node);

void
efc_node_build_eui_name(char *buf, u32 buf_len, uint64_t eui_name);

void
efc_node_pause(struct efc_node *node,
	       void (*state)(struct efc_sm_ctx *ctx,
			     enum efc_sm_event evt, void *arg));
void
__efc_node_paused(struct efc_sm_ctx *ctx,
		  enum efc_sm_event evt, void *arg);
int
efc_node_active_ios_empty(struct efc_node *node);
void
efc_node_send_ls_io_cleanup(struct efc_node *node);

int
efc_els_io_list_empty(struct efc_node *node, struct list_head *list);

void
efc_process_node_pending(struct efc_node *domain);

u64 efc_node_get_wwnn(struct efc_node *node);
struct efc_node *
efc_node_find(struct efc_nport *nport, u32 id);
void
efc_node_post_els_resp(struct efc_node *node, u32 evt, void *arg);
void
efc_node_recv_els_frame(struct efc_node *node, struct efc_hw_sequence *s);
void
efc_node_recv_ct_frame(struct efc_node *node, struct efc_hw_sequence *seq);
void
efc_node_recv_fcp_cmd(struct efc_node *node, struct efc_hw_sequence *seq);

#endif /* __EFC_NODE_H__ */