/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2021 Broadcom. All Rights Reserved. The term * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. */ #ifndef __EFCLIB_H__ #define __EFCLIB_H__ #include "scsi/fc/fc_els.h" #include "scsi/fc/fc_fs.h" #include "scsi/fc/fc_ns.h" #include "scsi/fc/fc_gs.h" #include "scsi/fc_frame.h" #include "../include/efc_common.h" #include "../libefc_sli/sli4.h" #define EFC_SERVICE_PARMS_LENGTH … #define EFC_NAME_LENGTH … #define EFC_SM_NAME_LENGTH … #define EFC_DISPLAY_BUS_INFO_LENGTH … #define EFC_WWN_LENGTH … #define EFC_FC_ELS_DEFAULT_RETRIES … /* Timeouts */ #define EFC_FC_ELS_SEND_DEFAULT_TIMEOUT … #define EFC_FC_FLOGI_TIMEOUT_SEC … #define EFC_SHUTDOWN_TIMEOUT_USEC … /* Return values for calls from base driver to libefc */ #define EFC_SCSI_CALL_COMPLETE … #define EFC_SCSI_CALL_ASYNC … /* Local port topology */ enum efc_nport_topology { … }; #define enable_target_rscn(efc) … enum efc_node_shutd_rsn { … }; enum efc_node_send_ls_acc { … }; #define EFC_LINK_STATUS_UP … #define EFC_LINK_STATUS_DOWN … enum efc_sm_event; /* State machine context header */ struct efc_sm_ctx { … }; /* Description of discovered Fabric Domain */ struct efc_domain_record { … }; /* Domain events */ enum efc_hw_domain_event { … }; /** * Fibre Channel port object * * @list_entry: nport list entry * @ref: reference count, each node takes a reference * @release: function to free nport object * @efc: pointer back to efc * @instance_index: unique instance index value * @display_name: port display name * @is_vport: Is NPIV port * @free_req_pending: pending request to free resources * @attached: mark attached if reg VPI succeeds * @p2p_winner: TRUE if we're the point-to-point winner * @domain: pointer back to domain * @wwpn: port wwpn * @wwnn: port wwnn * @tgt_data: target backend private port data * @ini_data: initiator backend private port data * @indicator: VPI * @fc_id: port FC address * @dma: memory for Service Parameters * @wwnn_str: wwpn string * @sli_wwpn: SLI provided wwpn * @sli_wwnn: SLI provided wwnn * @sm: nport state machine context * @lookup: fc_id to node lookup object * @enable_ini: SCSI initiator enabled for this port * @enable_tgt: SCSI target enabled for this port * @enable_rscn: port will be expecting RSCN * @shutting_down: nport in process of shutting down * @p2p_port_id: our port id for point-to-point * @topology: topology: fabric/p2p/unknown * @service_params: login parameters * @p2p_remote_port_id: remote node's port id for point-to-point */ struct efc_nport { … }; /** * Fibre Channel domain object * * This object is a container for the various SLI components needed * to connect to the domain of a FC or FCoE switch * @efc: pointer back to efc * @instance_index: unique instance index value * @display_name: Node display name * @nport_list: linked list of nports associated with this domain * @ref: Reference count, each nport takes a reference * @release: Function to free domain object * @ini_domain: initiator backend private domain data * @tgt_domain: target backend private domain data * @sm: state machine context * @fcf: FC Forwarder table index * @fcf_indicator: FCFI * @indicator: VFI * @nport_count: Number of nports allocated * @dma: memory for Service Parameters * @fcf_wwn: WWN for FCF/switch * @drvsm: driver domain sm context * @attached: set true after attach completes * @is_fc: is FC * @is_loop: is loop topology * @is_nlport: is public loop * @domain_found_pending:A domain found is pending, drec is updated * @req_domain_free: True if domain object should be free'd * @req_accept_frames: set in domain state machine to enable frames * @domain_notify_pend: Set in domain SM to avoid duplicate node event post * @pending_drec: Pending drec if a domain found is pending * @service_params: any nports service parameters * @flogi_service_params:Fabric/P2p service parameters from FLOGI * @lookup: d_id to node lookup object * @nport: Pointer to first (physical) SLI port */ struct efc_domain { … }; /** * Remote Node object * * This object represents a connection between the SLI port and another * Nx_Port on the fabric. Note this can be either a well known port such * as a F_Port (i.e. ff:ff:fe) or another N_Port. * @indicator: RPI * @fc_id: FC address * @attached: true if attached * @nport: associated SLI port * @node: associated node */ struct efc_remote_node { … }; /** * FC Node object * @efc: pointer back to efc structure * @display_name: Node display name * @nort: Assosiated nport pointer. * @hold_frames: hold incoming frames if true * @els_io_enabled: Enable allocating els ios for this node * @els_ios_lock: lock to protect the els ios list * @els_ios_list: ELS I/O's for this node * @ini_node: backend initiator private node data * @tgt_node: backend target private node data * @rnode: Remote node * @sm: state machine context * @evtdepth: current event posting nesting depth * @req_free: this node is to be free'd * @attached: node is attached (REGLOGIN complete) * @fcp_enabled: node is enabled to handle FCP * @rscn_pending: for name server node RSCN is pending * @send_plogi: send PLOGI accept, upon completion of node attach * @send_plogi_acc: TRUE if io_alloc() is enabled. * @send_ls_acc: type of LS acc to send * @ls_acc_io: SCSI IO for LS acc * @ls_acc_oxid: OX_ID for pending accept * @ls_acc_did: D_ID for pending accept * @shutdown_reason: reason for node shutdown * @sparm_dma_buf: service parameters buffer * @service_params: plogi/acc frame from remote device * @pend_frames_lock: lock for inbound pending frames list * @pend_frames: inbound pending frames list * @pend_frames_processed:count of frames processed in hold frames interval * @ox_id_in_use: used to verify one at a time us of ox_id * @els_retries_remaining:for ELS, number of retries remaining * @els_req_cnt: number of outstanding ELS requests * @els_cmpl_cnt: number of outstanding ELS completions * @abort_cnt: Abort counter for debugging purpos * @current_state_name: current node state * @prev_state_name: previous node state * @current_evt: current event * @prev_evt: previous event * @targ: node is target capable * @init: node is init capable * @refound: Handle node refound case when node is being deleted * @els_io_pend_list: list of pending (not yet processed) ELS IOs * @els_io_active_list: list of active (processed) ELS IOs * @nodedb_state: Node debugging, saved state * @gidpt_delay_timer: GIDPT delay timer * @time_last_gidpt_msec:Start time of last target RSCN GIDPT * @wwnn: remote port WWNN * @wwpn: remote port WWPN */ struct efc_node { … }; /** * NPIV port * * Collection of the information required to restore a virtual port across * link events * @wwnn: node name * @wwpn: port name * @fc_id: port id * @tgt_data: target backend pointer * @ini_data: initiator backend pointe * @nport: Used to match record after attaching for update * */ struct efc_vport { … }; #define node_printf(node, fmt, args...) … /* Node SM IO Context Callback structure */ struct efc_node_cb { … }; struct efc_hw_rq_buffer { … }; /** * FC sequence object * * Defines a general FC sequence object * @hw: HW that owns this sequence * @fcfi: FCFI associated with sequence * @header: Received frame header * @payload: Received frame header * @hw_priv: HW private context */ struct efc_hw_sequence { … }; enum efc_disc_io_type { … }; struct efc_io_els_params { … }; struct efc_io_ct_params { … }; efc_disc_io_param; struct efc_disc_io { … }; /* Return value indiacating the sequence can not be freed */ #define EFC_HW_SEQ_HOLD … /* Return value indiacating the sequence can be freed */ #define EFC_HW_SEQ_FREE … struct libefc_function_template { … }; #define EFC_LOG_LIB … #define EFC_LOG_NODE … #define EFC_LOG_PORT … #define EFC_LOG_DOMAIN … #define EFC_LOG_ELS … #define EFC_LOG_DOMAIN_SM … #define EFC_LOG_SM … /* efc library port structure */ struct efc { … }; /* * EFC library registration * **********************************/ int efcport_init(struct efc *efc); void efcport_destroy(struct efc *efc); /* * EFC Domain * **********************************/ int efc_domain_cb(void *arg, int event, void *data); void efc_register_domain_free_cb(struct efc *efc, void (*callback)(struct efc *efc, void *arg), void *arg); /* * EFC nport * **********************************/ void efc_nport_cb(void *arg, int event, void *data); struct efc_vport * efc_vport_create_spec(struct efc *efc, u64 wwnn, u64 wwpn, u32 fc_id, bool enable_ini, bool enable_tgt, void *tgt_data, void *ini_data); int efc_nport_vport_new(struct efc_domain *domain, u64 wwpn, u64 wwnn, u32 fc_id, bool ini, bool tgt, void *tgt_data, void *ini_data); int efc_nport_vport_del(struct efc *efc, struct efc_domain *domain, u64 wwpn, u64 wwnn); void efc_vport_del_all(struct efc *efc); /* * EFC Node * **********************************/ int efc_remote_node_cb(void *arg, int event, void *data); void efc_node_fcid_display(u32 fc_id, char *buffer, u32 buf_len); void efc_node_post_shutdown(struct efc_node *node, void *arg); u64 efc_node_get_wwpn(struct efc_node *node); /* * EFC FCP/ELS/CT interface * **********************************/ void efc_dispatch_frame(struct efc *efc, struct efc_hw_sequence *seq); void efc_disc_io_complete(struct efc_disc_io *io, u32 len, u32 status, u32 ext_status); /* * EFC SCSI INTERACTION LAYER * **********************************/ void efc_scsi_sess_reg_complete(struct efc_node *node, u32 status); void efc_scsi_del_initiator_complete(struct efc *efc, struct efc_node *node); void efc_scsi_del_target_complete(struct efc *efc, struct efc_node *node); void efc_scsi_io_list_empty(struct efc *efc, struct efc_node *node); #endif /* __EFCLIB_H__ */