Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (C) 2021 Broadcom. All Rights Reserved. The term
0004  * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
0005  */
0006 
0007 #if !defined(__EFC_NODE_H__)
0008 #define __EFC_NODE_H__
0009 #include "scsi/fc/fc_ns.h"
0010 
0011 #define EFC_NODEDB_PAUSE_FABRIC_LOGIN   (1 << 0)
0012 #define EFC_NODEDB_PAUSE_NAMESERVER (1 << 1)
0013 #define EFC_NODEDB_PAUSE_NEW_NODES  (1 << 2)
0014 
0015 #define MAX_ACC_REJECT_PAYLOAD  sizeof(struct fc_els_ls_rjt)
0016 
0017 #define scsi_io_printf(io, fmt, ...) \
0018     efc_log_debug(io->efc, "[%s] [%04x][i:%04x t:%04x h:%04x]" fmt, \
0019     io->node->display_name, io->instance_index, io->init_task_tag, \
0020     io->tgt_task_tag, io->hw_tag, ##__VA_ARGS__)
0021 
0022 static inline void
0023 efc_node_evt_set(struct efc_sm_ctx *ctx, enum efc_sm_event evt,
0024          const char *handler)
0025 {
0026     struct efc_node *node = ctx->app;
0027 
0028     if (evt == EFC_EVT_ENTER) {
0029         strncpy(node->current_state_name, handler,
0030             sizeof(node->current_state_name));
0031     } else if (evt == EFC_EVT_EXIT) {
0032         strncpy(node->prev_state_name, node->current_state_name,
0033             sizeof(node->prev_state_name));
0034         strncpy(node->current_state_name, "invalid",
0035             sizeof(node->current_state_name));
0036     }
0037     node->prev_evt = node->current_evt;
0038     node->current_evt = evt;
0039 }
0040 
0041 /**
0042  * hold frames in pending frame list
0043  *
0044  * Unsolicited receive frames are held on the node pending frame list,
0045  * rather than being processed.
0046  */
0047 
0048 static inline void
0049 efc_node_hold_frames(struct efc_node *node)
0050 {
0051     node->hold_frames = true;
0052 }
0053 
0054 /**
0055  * accept frames
0056  *
0057  * Unsolicited receive frames processed rather than being held on the node
0058  * pending frame list.
0059  */
0060 
0061 static inline void
0062 efc_node_accept_frames(struct efc_node *node)
0063 {
0064     node->hold_frames = false;
0065 }
0066 
0067 /*
0068  * Node initiator/target enable defines
0069  * All combinations of the SLI port (nport) initiator/target enable,
0070  * and remote node initiator/target enable are enumerated.
0071  * ex: EFC_NODE_ENABLE_T_TO_IT decodes to target mode is enabled on SLI port
0072  * and I+T is enabled on remote node.
0073  */
0074 enum efc_node_enable {
0075     EFC_NODE_ENABLE_x_TO_x,
0076     EFC_NODE_ENABLE_x_TO_T,
0077     EFC_NODE_ENABLE_x_TO_I,
0078     EFC_NODE_ENABLE_x_TO_IT,
0079     EFC_NODE_ENABLE_T_TO_x,
0080     EFC_NODE_ENABLE_T_TO_T,
0081     EFC_NODE_ENABLE_T_TO_I,
0082     EFC_NODE_ENABLE_T_TO_IT,
0083     EFC_NODE_ENABLE_I_TO_x,
0084     EFC_NODE_ENABLE_I_TO_T,
0085     EFC_NODE_ENABLE_I_TO_I,
0086     EFC_NODE_ENABLE_I_TO_IT,
0087     EFC_NODE_ENABLE_IT_TO_x,
0088     EFC_NODE_ENABLE_IT_TO_T,
0089     EFC_NODE_ENABLE_IT_TO_I,
0090     EFC_NODE_ENABLE_IT_TO_IT,
0091 };
0092 
0093 static inline enum efc_node_enable
0094 efc_node_get_enable(struct efc_node *node)
0095 {
0096     u32 retval = 0;
0097 
0098     if (node->nport->enable_ini)
0099         retval |= (1U << 3);
0100     if (node->nport->enable_tgt)
0101         retval |= (1U << 2);
0102     if (node->init)
0103         retval |= (1U << 1);
0104     if (node->targ)
0105         retval |= (1U << 0);
0106     return (enum efc_node_enable)retval;
0107 }
0108 
0109 int
0110 efc_node_check_els_req(struct efc_sm_ctx *ctx,
0111                enum efc_sm_event evt, void *arg,
0112                u8 cmd, void (*efc_node_common_func)(const char *,
0113                struct efc_sm_ctx *, enum efc_sm_event, void *),
0114                const char *funcname);
0115 int
0116 efc_node_check_ns_req(struct efc_sm_ctx *ctx,
0117               enum efc_sm_event evt, void *arg,
0118               u16 cmd, void (*efc_node_common_func)(const char *,
0119               struct efc_sm_ctx *, enum efc_sm_event, void *),
0120               const char *funcname);
0121 int
0122 efc_node_attach(struct efc_node *node);
0123 struct efc_node *
0124 efc_node_alloc(struct efc_nport *nport, u32 port_id,
0125            bool init, bool targ);
0126 void
0127 efc_node_free(struct efc_node *efc);
0128 void
0129 efc_node_update_display_name(struct efc_node *node);
0130 void efc_node_post_event(struct efc_node *node, enum efc_sm_event evt,
0131              void *arg);
0132 
0133 void
0134 __efc_node_shutdown(struct efc_sm_ctx *ctx,
0135             enum efc_sm_event evt, void *arg);
0136 void
0137 __efc_node_wait_node_free(struct efc_sm_ctx *ctx,
0138               enum efc_sm_event evt, void *arg);
0139 void
0140 __efc_node_wait_els_shutdown(struct efc_sm_ctx *ctx,
0141                  enum efc_sm_event evt, void *arg);
0142 void
0143 __efc_node_wait_ios_shutdown(struct efc_sm_ctx *ctx,
0144                  enum efc_sm_event evt, void *arg);
0145 void
0146 efc_node_save_sparms(struct efc_node *node, void *payload);
0147 void
0148 efc_node_transition(struct efc_node *node,
0149             void (*state)(struct efc_sm_ctx *, enum efc_sm_event,
0150                   void *), void *data);
0151 void
0152 __efc_node_common(const char *funcname, struct efc_sm_ctx *ctx,
0153           enum efc_sm_event evt, void *arg);
0154 
0155 void
0156 efc_node_initiate_cleanup(struct efc_node *node);
0157 
0158 void
0159 efc_node_build_eui_name(char *buf, u32 buf_len, uint64_t eui_name);
0160 
0161 void
0162 efc_node_pause(struct efc_node *node,
0163            void (*state)(struct efc_sm_ctx *ctx,
0164                  enum efc_sm_event evt, void *arg));
0165 void
0166 __efc_node_paused(struct efc_sm_ctx *ctx,
0167           enum efc_sm_event evt, void *arg);
0168 int
0169 efc_node_active_ios_empty(struct efc_node *node);
0170 void
0171 efc_node_send_ls_io_cleanup(struct efc_node *node);
0172 
0173 int
0174 efc_els_io_list_empty(struct efc_node *node, struct list_head *list);
0175 
0176 void
0177 efc_process_node_pending(struct efc_node *domain);
0178 
0179 u64 efc_node_get_wwnn(struct efc_node *node);
0180 struct efc_node *
0181 efc_node_find(struct efc_nport *nport, u32 id);
0182 void
0183 efc_node_post_els_resp(struct efc_node *node, u32 evt, void *arg);
0184 void
0185 efc_node_recv_els_frame(struct efc_node *node, struct efc_hw_sequence *s);
0186 void
0187 efc_node_recv_ct_frame(struct efc_node *node, struct efc_hw_sequence *seq);
0188 void
0189 efc_node_recv_fcp_cmd(struct efc_node *node, struct efc_hw_sequence *seq);
0190 
0191 #endif /* __EFC_NODE_H__ */