cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

efc_node.h (5297B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2/*
      3 * Copyright (C) 2021 Broadcom. All Rights Reserved. The term
      4 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
      5 */
      6
      7#if !defined(__EFC_NODE_H__)
      8#define __EFC_NODE_H__
      9#include "scsi/fc/fc_ns.h"
     10
     11#define EFC_NODEDB_PAUSE_FABRIC_LOGIN	(1 << 0)
     12#define EFC_NODEDB_PAUSE_NAMESERVER	(1 << 1)
     13#define EFC_NODEDB_PAUSE_NEW_NODES	(1 << 2)
     14
     15#define MAX_ACC_REJECT_PAYLOAD	sizeof(struct fc_els_ls_rjt)
     16
     17#define scsi_io_printf(io, fmt, ...) \
     18	efc_log_debug(io->efc, "[%s] [%04x][i:%04x t:%04x h:%04x]" fmt, \
     19	io->node->display_name, io->instance_index, io->init_task_tag, \
     20	io->tgt_task_tag, io->hw_tag, ##__VA_ARGS__)
     21
     22static inline void
     23efc_node_evt_set(struct efc_sm_ctx *ctx, enum efc_sm_event evt,
     24		 const char *handler)
     25{
     26	struct efc_node *node = ctx->app;
     27
     28	if (evt == EFC_EVT_ENTER) {
     29		strncpy(node->current_state_name, handler,
     30			sizeof(node->current_state_name));
     31	} else if (evt == EFC_EVT_EXIT) {
     32		strncpy(node->prev_state_name, node->current_state_name,
     33			sizeof(node->prev_state_name));
     34		strncpy(node->current_state_name, "invalid",
     35			sizeof(node->current_state_name));
     36	}
     37	node->prev_evt = node->current_evt;
     38	node->current_evt = evt;
     39}
     40
     41/**
     42 * hold frames in pending frame list
     43 *
     44 * Unsolicited receive frames are held on the node pending frame list,
     45 * rather than being processed.
     46 */
     47
     48static inline void
     49efc_node_hold_frames(struct efc_node *node)
     50{
     51	node->hold_frames = true;
     52}
     53
     54/**
     55 * accept frames
     56 *
     57 * Unsolicited receive frames processed rather than being held on the node
     58 * pending frame list.
     59 */
     60
     61static inline void
     62efc_node_accept_frames(struct efc_node *node)
     63{
     64	node->hold_frames = false;
     65}
     66
     67/*
     68 * Node initiator/target enable defines
     69 * All combinations of the SLI port (nport) initiator/target enable,
     70 * and remote node initiator/target enable are enumerated.
     71 * ex: EFC_NODE_ENABLE_T_TO_IT decodes to target mode is enabled on SLI port
     72 * and I+T is enabled on remote node.
     73 */
     74enum efc_node_enable {
     75	EFC_NODE_ENABLE_x_TO_x,
     76	EFC_NODE_ENABLE_x_TO_T,
     77	EFC_NODE_ENABLE_x_TO_I,
     78	EFC_NODE_ENABLE_x_TO_IT,
     79	EFC_NODE_ENABLE_T_TO_x,
     80	EFC_NODE_ENABLE_T_TO_T,
     81	EFC_NODE_ENABLE_T_TO_I,
     82	EFC_NODE_ENABLE_T_TO_IT,
     83	EFC_NODE_ENABLE_I_TO_x,
     84	EFC_NODE_ENABLE_I_TO_T,
     85	EFC_NODE_ENABLE_I_TO_I,
     86	EFC_NODE_ENABLE_I_TO_IT,
     87	EFC_NODE_ENABLE_IT_TO_x,
     88	EFC_NODE_ENABLE_IT_TO_T,
     89	EFC_NODE_ENABLE_IT_TO_I,
     90	EFC_NODE_ENABLE_IT_TO_IT,
     91};
     92
     93static inline enum efc_node_enable
     94efc_node_get_enable(struct efc_node *node)
     95{
     96	u32 retval = 0;
     97
     98	if (node->nport->enable_ini)
     99		retval |= (1U << 3);
    100	if (node->nport->enable_tgt)
    101		retval |= (1U << 2);
    102	if (node->init)
    103		retval |= (1U << 1);
    104	if (node->targ)
    105		retval |= (1U << 0);
    106	return (enum efc_node_enable)retval;
    107}
    108
    109int
    110efc_node_check_els_req(struct efc_sm_ctx *ctx,
    111		       enum efc_sm_event evt, void *arg,
    112		       u8 cmd, void (*efc_node_common_func)(const char *,
    113		       struct efc_sm_ctx *, enum efc_sm_event, void *),
    114		       const char *funcname);
    115int
    116efc_node_check_ns_req(struct efc_sm_ctx *ctx,
    117		      enum efc_sm_event evt, void *arg,
    118		      u16 cmd, void (*efc_node_common_func)(const char *,
    119		      struct efc_sm_ctx *, enum efc_sm_event, void *),
    120		      const char *funcname);
    121int
    122efc_node_attach(struct efc_node *node);
    123struct efc_node *
    124efc_node_alloc(struct efc_nport *nport, u32 port_id,
    125	       bool init, bool targ);
    126void
    127efc_node_free(struct efc_node *efc);
    128void
    129efc_node_update_display_name(struct efc_node *node);
    130void efc_node_post_event(struct efc_node *node, enum efc_sm_event evt,
    131			 void *arg);
    132
    133void
    134__efc_node_shutdown(struct efc_sm_ctx *ctx,
    135		    enum efc_sm_event evt, void *arg);
    136void
    137__efc_node_wait_node_free(struct efc_sm_ctx *ctx,
    138			  enum efc_sm_event evt, void *arg);
    139void
    140__efc_node_wait_els_shutdown(struct efc_sm_ctx *ctx,
    141			     enum efc_sm_event evt, void *arg);
    142void
    143__efc_node_wait_ios_shutdown(struct efc_sm_ctx *ctx,
    144			     enum efc_sm_event evt, void *arg);
    145void
    146efc_node_save_sparms(struct efc_node *node, void *payload);
    147void
    148efc_node_transition(struct efc_node *node,
    149		    void (*state)(struct efc_sm_ctx *, enum efc_sm_event,
    150				  void *), void *data);
    151void
    152__efc_node_common(const char *funcname, struct efc_sm_ctx *ctx,
    153		  enum efc_sm_event evt, void *arg);
    154
    155void
    156efc_node_initiate_cleanup(struct efc_node *node);
    157
    158void
    159efc_node_build_eui_name(char *buf, u32 buf_len, uint64_t eui_name);
    160
    161void
    162efc_node_pause(struct efc_node *node,
    163	       void (*state)(struct efc_sm_ctx *ctx,
    164			     enum efc_sm_event evt, void *arg));
    165void
    166__efc_node_paused(struct efc_sm_ctx *ctx,
    167		  enum efc_sm_event evt, void *arg);
    168int
    169efc_node_active_ios_empty(struct efc_node *node);
    170void
    171efc_node_send_ls_io_cleanup(struct efc_node *node);
    172
    173int
    174efc_els_io_list_empty(struct efc_node *node, struct list_head *list);
    175
    176void
    177efc_process_node_pending(struct efc_node *domain);
    178
    179u64 efc_node_get_wwnn(struct efc_node *node);
    180struct efc_node *
    181efc_node_find(struct efc_nport *nport, u32 id);
    182void
    183efc_node_post_els_resp(struct efc_node *node, u32 evt, void *arg);
    184void
    185efc_node_recv_els_frame(struct efc_node *node, struct efc_hw_sequence *s);
    186void
    187efc_node_recv_ct_frame(struct efc_node *node, struct efc_hw_sequence *seq);
    188void
    189efc_node_recv_fcp_cmd(struct efc_node *node, struct efc_hw_sequence *seq);
    190
    191#endif /* __EFC_NODE_H__ */