/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2003-2009 Silicon Graphics International Corp.4* Copyright (c) 2011 Spectra Logic Corporation5* Copyright (c) 2015 Alexander Motin <[email protected]>6* All rights reserved.7*8* Redistribution and use in source and binary forms, with or without9* modification, are permitted provided that the following conditions10* are met:11* 1. Redistributions of source code must retain the above copyright12* notice, this list of conditions, and the following disclaimer,13* without modification.14* 2. Redistributions in binary form must reproduce at minimum a disclaimer15* substantially similar to the "NO WARRANTY" disclaimer below16* ("Disclaimer") and any redistribution must be conditioned upon17* including a substantially similar Disclaimer requirement for further18* binary redistribution.19*20* NO WARRANTY21* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS22* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT23* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR24* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT25* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL26* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS27* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)28* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,29* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING30* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE31* POSSIBILITY OF SUCH DAMAGES.32*33* $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_ha.h#1 $34*/3536#ifndef _CTL_HA_H_37#define _CTL_HA_H_3839#include <sys/queue.h>4041/*42* CTL High Availability Modes:43*44* CTL_HA_MODE_ACT_STBY: Commands are serialized to the master side.45* No media access commands on slave side (Standby).46* CTL_HA_MODE_SER_ONLY: Commands are serialized to the master side.47* Media can be accessed on both sides.48* CTL_HA_MODE_XFER: Commands and data are forwarded to the49* master side for execution.50*/51typedef enum {52CTL_HA_MODE_ACT_STBY,53CTL_HA_MODE_SER_ONLY,54CTL_HA_MODE_XFER55} ctl_ha_mode;5657/*58* Communication channel IDs for various system components. This is to59* make sure one CTL instance talks with another, one ZFS instance talks60* with another, etc.61*/62typedef enum {63CTL_HA_CHAN_CTL,64CTL_HA_CHAN_DATA,65CTL_HA_CHAN_MAX66} ctl_ha_channel;6768/*69* HA communication event notification. These are events generated by the70* HA communication subsystem.71*72* CTL_HA_EVT_MSG_RECV: Message received by the other node.73* CTL_HA_EVT_LINK_CHANGE: Communication channel status changed.74*/75typedef enum {76CTL_HA_EVT_NONE,77CTL_HA_EVT_MSG_RECV,78CTL_HA_EVT_LINK_CHANGE,79CTL_HA_EVT_MAX80} ctl_ha_event;8182typedef enum {83CTL_HA_STATUS_WAIT,84CTL_HA_STATUS_SUCCESS,85CTL_HA_STATUS_ERROR,86CTL_HA_STATUS_INVALID,87CTL_HA_STATUS_DISCONNECT,88CTL_HA_STATUS_BUSY,89CTL_HA_STATUS_MAX90} ctl_ha_status;9192typedef enum {93CTL_HA_DT_CMD_READ,94CTL_HA_DT_CMD_WRITE,95} ctl_ha_dt_cmd;9697struct ctl_ha_dt_req;9899typedef void (*ctl_ha_dt_cb)(struct ctl_ha_dt_req *);100101struct ctl_ha_dt_req {102ctl_ha_dt_cmd command;103void *context;104ctl_ha_dt_cb callback;105int ret;106uint32_t size;107uint8_t *local;108uint8_t *remote;109TAILQ_ENTRY(ctl_ha_dt_req) links;110};111112struct ctl_softc;113ctl_ha_status ctl_ha_msg_init(struct ctl_softc *softc);114void ctl_ha_msg_shutdown(struct ctl_softc *softc);115ctl_ha_status ctl_ha_msg_destroy(struct ctl_softc *softc);116117typedef void (*ctl_evt_handler)(ctl_ha_channel channel, ctl_ha_event event,118int param);119void ctl_ha_register_evthandler(ctl_ha_channel channel,120ctl_evt_handler handler);121122ctl_ha_status ctl_ha_msg_register(ctl_ha_channel channel,123ctl_evt_handler handler);124ctl_ha_status ctl_ha_msg_recv(ctl_ha_channel channel, void *addr,125size_t len, int wait);126ctl_ha_status ctl_ha_msg_send(ctl_ha_channel channel, const void *addr,127size_t len, int wait);128ctl_ha_status ctl_ha_msg_send2(ctl_ha_channel channel, const void *addr,129size_t len, const void *addr2, size_t len2, int wait);130ctl_ha_status ctl_ha_msg_abort(ctl_ha_channel channel);131ctl_ha_status ctl_ha_msg_deregister(ctl_ha_channel channel);132133struct ctl_ha_dt_req * ctl_dt_req_alloc(void);134void ctl_dt_req_free(struct ctl_ha_dt_req *req);135ctl_ha_status ctl_dt_single(struct ctl_ha_dt_req *req);136137typedef enum {138CTL_HA_LINK_OFFLINE = 0x00,139CTL_HA_LINK_UNKNOWN = 0x01,140CTL_HA_LINK_ONLINE = 0x02141} ctl_ha_link_state;142143#endif /* _CTL_HA_H_ */144145146