Line data Source code
1 : #ifndef HEADER_fd_src_discof_failover_fd_failover_bus_h 2 : #define HEADER_fd_src_discof_failover_fd_failover_bus_h 3 : 4 : /* The admin and failover tiles talk over the admin_failov and 5 : failov_admin links. The admin tile is the only adminctl poller. It 6 : forwards failover commands with a nonce and parks the adminctl slot 7 : until the response comes back, which for a handoff or promotion is 8 : when its outcome is known. The failover tile asks for identity 9 : switches the same way. Every frame is one fd_failover_bus_msg_t. 10 : Both links are reliable, so no frame is lost behind a busy tile. */ 11 : 12 : #include "../admin/fd_adminctl.h" 13 : 14 : #define FD_FAILOVER_BUS_PAYLOAD_MAX (256UL) 15 : 16 : /* bus message types */ 17 : 18 0 : #define FD_FAILOVER_BUS_SWITCH_REQ (1UL) /* failov to admin: fd_failover_switch_req_t */ 19 0 : #define FD_FAILOVER_BUS_SWITCH_RESP (2UL) /* admin to failov: fd_failover_switch_resp_t */ 20 0 : #define FD_FAILOVER_BUS_REQUEST (3UL) /* admin to failov: fd_adminctl_failover_req_t */ 21 0 : #define FD_FAILOVER_BUS_RESPONSE (4UL) /* failov to admin: the result of the command with the corresponding nonce and payload */ 22 0 : #define FD_FAILOVER_BUS_OPERATOR_ACTION (5UL) /* admin to failov: fd_failover_operator_t, set-identity ran */ 23 0 : #define FD_FAILOVER_BUS_STEP (6UL) /* failov to admin: a step of the command with that nonce, a cstr payload */ 24 : 25 0 : #define FD_FAILOVER_BUS_STEP_MAX (FD_ADMINCTL_STEP_MAX) 26 : 27 : /* result codes */ 28 : 29 0 : #define FD_FAILOVER_SWITCH_OK (0UL) 30 0 : #define FD_FAILOVER_SWITCH_ERR_DISABLED (1UL) 31 0 : #define FD_FAILOVER_SWITCH_ERR_STALE (2UL) 32 0 : #define FD_FAILOVER_SWITCH_ERR_AUTHORIZED_VOTER (3UL) /* the target is an authorized voter, nothing switched */ 33 : 34 : /* bus message structs */ 35 : 36 : struct fd_failover_operator { 37 : ulong epoch; 38 : uchar identity[ 32 ]; 39 : uchar failover_identity[ 32 ]; 40 : }; 41 : typedef struct fd_failover_operator fd_failover_operator_t; 42 : FD_STATIC_ASSERT( sizeof(fd_failover_operator_t)<=FD_FAILOVER_BUS_PAYLOAD_MAX, operator_fits ); 43 : 44 : struct fd_failover_switch_req { 45 : uchar identity[ 32 ]; /* public key of the identity to install */ 46 : ulong epoch; 47 : }; 48 : typedef struct fd_failover_switch_req fd_failover_switch_req_t; 49 : FD_STATIC_ASSERT( sizeof(fd_failover_switch_req_t)<=FD_FAILOVER_BUS_PAYLOAD_MAX, switch_req_fits ); 50 : 51 : struct fd_failover_switch_resp { 52 : ulong result; 53 : ulong history_watermark; 54 : fd_failover_operator_t operator; 55 : }; 56 : typedef struct fd_failover_switch_resp fd_failover_switch_resp_t; 57 : FD_STATIC_ASSERT( sizeof(fd_failover_switch_resp_t)<=FD_FAILOVER_BUS_PAYLOAD_MAX, switch_resp_fits ); 58 : 59 : /* bus message framing */ 60 : 61 : struct fd_failover_bus_msg { 62 : ulong nonce; /* per request, echoed on the response */ 63 : ulong result; /* the adminctl result for command responses */ 64 : uchar payload[ FD_FAILOVER_BUS_PAYLOAD_MAX ]; 65 : }; 66 : typedef struct fd_failover_bus_msg fd_failover_bus_msg_t; 67 : 68 0 : #define FD_FAILOVER_BUS_MTU (sizeof(fd_failover_bus_msg_t)) 69 : FD_STATIC_ASSERT( sizeof(fd_failover_bus_msg_t)==272UL, bus_layout ); 70 : 71 : FD_STATIC_ASSERT( sizeof(fd_adminctl_failover_req_t)<=FD_FAILOVER_BUS_PAYLOAD_MAX, command_fits ); 72 : FD_STATIC_ASSERT( FD_FAILOVER_BUS_STEP_MAX<=FD_FAILOVER_BUS_PAYLOAD_MAX, step_fits ); 73 : 74 : #endif /* HEADER_fd_src_discof_failover_fd_failover_bus_h */