Lines Matching refs:vdcp
142 static void vdc_switch_server(vdc_t *vdcp);
158 static int vdc_ver_negotiation(vdc_t *vdcp);
160 static int vdc_attr_negotiation(vdc_t *vdcp);
162 static int vdc_dring_negotiation(vdc_t *vdcp);
163 static int vdc_send_rdx(vdc_t *vdcp);
164 static int vdc_rdx_exchange(vdc_t *vdcp);
176 static int vdc_send_request(vdc_t *vdcp, int operation,
179 static int vdc_map_to_shared_dring(vdc_t *vdcp, int idx);
180 static int vdc_populate_descriptor(vdc_t *vdcp, int operation,
183 static int vdc_do_sync_op(vdc_t *vdcp, int operation, caddr_t addr,
190 static int vdc_wait_for_response(vdc_t *vdcp, vio_msg_t *msgp);
191 static int vdc_drain_response(vdc_t *vdcp, struct buf *buf);
193 static int vdc_populate_mem_hdl(vdc_t *vdcp, vdc_local_desc_t *ldep);
900 vdc_stop_ldc_connection(vdc_t *vdcp) in vdc_stop_ldc_connection() argument
904 ASSERT(vdcp != NULL); in vdc_stop_ldc_connection()
906 ASSERT(MUTEX_HELD(&vdcp->lock)); in vdc_stop_ldc_connection()
908 DMSG(vdcp, 0, ": Resetting connection to vDisk server : state %d\n", in vdc_stop_ldc_connection()
909 vdcp->state); in vdc_stop_ldc_connection()
911 status = ldc_down(vdcp->curr_server->ldc_handle); in vdc_stop_ldc_connection()
912 DMSG(vdcp, 0, "ldc_down() = %d\n", status); in vdc_stop_ldc_connection()
914 vdcp->initialized &= ~VDC_HANDSHAKE; in vdc_stop_ldc_connection()
915 DMSG(vdcp, 0, "initialized=%x\n", vdcp->initialized); in vdc_stop_ldc_connection()
1678 vdc_ver_negotiation(vdc_t *vdcp) in vdc_ver_negotiation() argument
1683 if (status = vdc_init_ver_negotiation(vdcp, vdc_version[0])) in vdc_ver_negotiation()
1687 mutex_exit(&vdcp->lock); in vdc_ver_negotiation()
1688 status = vdc_wait_for_response(vdcp, &vio_msg); in vdc_ver_negotiation()
1689 mutex_enter(&vdcp->lock); in vdc_ver_negotiation()
1691 DMSG(vdcp, 0, in vdc_ver_negotiation()
1693 vdcp->instance, status); in vdc_ver_negotiation()
1700 DMSG(vdcp, 0, "[%d] Invalid ver negotiation response\n", in vdc_ver_negotiation()
1701 vdcp->instance); in vdc_ver_negotiation()
1705 return (vdc_handle_ver_msg(vdcp, (vio_ver_msg_t *)&vio_msg)); in vdc_ver_negotiation()
1773 vdc_attr_negotiation(vdc_t *vdcp) in vdc_attr_negotiation() argument
1778 if (status = vdc_init_attr_negotiation(vdcp)) in vdc_attr_negotiation()
1782 mutex_exit(&vdcp->lock); in vdc_attr_negotiation()
1783 status = vdc_wait_for_response(vdcp, &vio_msg); in vdc_attr_negotiation()
1784 mutex_enter(&vdcp->lock); in vdc_attr_negotiation()
1786 DMSG(vdcp, 0, in vdc_attr_negotiation()
1788 vdcp->instance, status); in vdc_attr_negotiation()
1795 DMSG(vdcp, 0, "[%d] Invalid attr negotiation response\n", in vdc_attr_negotiation()
1796 vdcp->instance); in vdc_attr_negotiation()
1800 return (vdc_handle_attr_msg(vdcp, (vd_attr_msg_t *)&vio_msg)); in vdc_attr_negotiation()
1880 vdc_dring_negotiation(vdc_t *vdcp) in vdc_dring_negotiation() argument
1885 if (status = vdc_init_dring_negotiate(vdcp)) in vdc_dring_negotiation()
1889 mutex_exit(&vdcp->lock); in vdc_dring_negotiation()
1890 status = vdc_wait_for_response(vdcp, &vio_msg); in vdc_dring_negotiation()
1891 mutex_enter(&vdcp->lock); in vdc_dring_negotiation()
1893 DMSG(vdcp, 0, in vdc_dring_negotiation()
1895 " rv(%d)", vdcp->instance, status); in vdc_dring_negotiation()
1902 DMSG(vdcp, 0, "[%d] Invalid Dring negotiation response\n", in vdc_dring_negotiation()
1903 vdcp->instance); in vdc_dring_negotiation()
1907 return (vdc_handle_dring_reg_msg(vdcp, in vdc_dring_negotiation()
1925 vdc_send_rdx(vdc_t *vdcp) in vdc_send_rdx() argument
1938 msg.tag.vio_sid = vdcp->session_id; in vdc_send_rdx()
1939 status = vdc_send(vdcp, (caddr_t)&msg, &msglen); in vdc_send_rdx()
1941 DMSG(vdcp, 0, "[%d] Failed to send RDX message (%d)", in vdc_send_rdx()
1942 vdcp->instance, status); in vdc_send_rdx()
1962 vdc_handle_rdx(vdc_t *vdcp, vio_rdx_msg_t *msgp) in vdc_handle_rdx() argument
1964 _NOTE(ARGUNUSED(vdcp)) in vdc_handle_rdx()
1971 DMSG(vdcp, 1, "[%d] Got an RDX msg", vdcp->instance); in vdc_handle_rdx()
1989 vdc_rdx_exchange(vdc_t *vdcp) in vdc_rdx_exchange() argument
1994 if (status = vdc_send_rdx(vdcp)) in vdc_rdx_exchange()
1998 mutex_exit(&vdcp->lock); in vdc_rdx_exchange()
1999 status = vdc_wait_for_response(vdcp, &vio_msg); in vdc_rdx_exchange()
2000 mutex_enter(&vdcp->lock); in vdc_rdx_exchange()
2002 DMSG(vdcp, 0, "[%d] Failed waiting for RDX response, rv(%d)", in vdc_rdx_exchange()
2003 vdcp->instance, status); in vdc_rdx_exchange()
2010 DMSG(vdcp, 0, "[%d] Invalid RDX response\n", vdcp->instance); in vdc_rdx_exchange()
2014 return (vdc_handle_rdx(vdcp, (vio_rdx_msg_t *)&vio_msg)); in vdc_rdx_exchange()
2100 vdc_decode_tag(vdc_t *vdcp, vio_msg_t *msg) in vdc_decode_tag() argument
2135 DMSG(vdcp, 3, "(%x/%x/%x) message : (%s/%s/%s)\n", in vdc_decode_tag()
2410 srvr->vdcp = vdc; in vdc_init_ports()
2870 vdc_map_to_shared_dring(vdc_t *vdcp, int idx) in vdc_map_to_shared_dring() argument
2876 ldep = &(vdcp->local_dring[idx]); in vdc_map_to_shared_dring()
2880 rv = vdc_populate_mem_hdl(vdcp, ldep); in vdc_map_to_shared_dring()
2882 DMSG(vdcp, 0, "[%d] Cannot populate mem handle\n", in vdc_map_to_shared_dring()
2883 vdcp->instance); in vdc_map_to_shared_dring()
2894 dep->payload.req_id = VDC_GET_NEXT_REQ_ID(vdcp); in vdc_map_to_shared_dring()
2930 vdc_send_request(vdc_t *vdcp, int operation, caddr_t addr, in vdc_send_request() argument
2936 ASSERT(vdcp != NULL); in vdc_send_request()
2939 mutex_enter(&vdcp->lock); in vdc_send_request()
2955 VD_KSTAT_WAITQ_ENTER(vdcp); in vdc_send_request()
2963 rv = vdc_populate_descriptor(vdcp, operation, addr, in vdc_send_request()
2969 while (vdcp->state != VDC_STATE_RUNNING) { in vdc_send_request()
2972 if (vdcp->state == VDC_STATE_DETACH) { in vdc_send_request()
2992 if (vdcp->state == VDC_STATE_FAILED) { in vdc_send_request()
2993 vdcp->io_pending = B_TRUE; in vdc_send_request()
2994 cv_signal(&vdcp->io_pending_cv); in vdc_send_request()
2997 cv_wait(&vdcp->running_cv, &vdcp->lock); in vdc_send_request()
3000 if (vdcp->state == VDC_STATE_FAILED) { in vdc_send_request()
3006 } while (vdc_populate_descriptor(vdcp, operation, addr, in vdc_send_request()
3021 VD_KSTAT_WAITQ_TO_RUNQ(vdcp); in vdc_send_request()
3024 VD_UPDATE_ERR_STATS(vdcp, vd_transerrs); in vdc_send_request()
3026 VD_KSTAT_WAITQ_EXIT(vdcp); in vdc_send_request()
3032 mutex_exit(&vdcp->lock); in vdc_send_request()
3064 vdc_populate_descriptor(vdc_t *vdcp, int operation, caddr_t addr, in vdc_populate_descriptor() argument
3075 ASSERT(MUTEX_HELD(&vdcp->lock)); in vdc_populate_descriptor()
3076 vdcp->threads_pending++; in vdc_populate_descriptor()
3078 DMSG(vdcp, 2, ": dring_curr_idx = %d\n", vdcp->dring_curr_idx); in vdc_populate_descriptor()
3083 local_dep = &(vdcp->local_dring[idx]); in vdc_populate_descriptor()
3086 idx = vdcp->dring_curr_idx; in vdc_populate_descriptor()
3087 local_dep = &(vdcp->local_dring[idx]); in vdc_populate_descriptor()
3090 DMSG(vdcp, 2, "[%d]: dring full - waiting for space\n", in vdc_populate_descriptor()
3091 vdcp->instance); in vdc_populate_descriptor()
3092 cv_wait(&vdcp->dring_free_cv, &vdcp->lock); in vdc_populate_descriptor()
3093 if (vdcp->state == VDC_STATE_RUNNING || in vdc_populate_descriptor()
3094 vdcp->state == VDC_STATE_HANDLE_PENDING) { in vdc_populate_descriptor()
3097 vdcp->threads_pending--; in vdc_populate_descriptor()
3102 if (next_idx >= vdcp->dring_len) in vdc_populate_descriptor()
3104 vdcp->dring_curr_idx = next_idx; in vdc_populate_descriptor()
3120 rv = vdc_map_to_shared_dring(vdcp, idx); in vdc_populate_descriptor()
3123 DMSG(vdcp, 0, "[%d]: cannot bind memory - error\n", in vdc_populate_descriptor()
3124 vdcp->instance); in vdc_populate_descriptor()
3130 vdcp->threads_pending--; in vdc_populate_descriptor()
3133 DMSG(vdcp, 0, "[%d]: cannot bind memory - waiting ..\n", in vdc_populate_descriptor()
3134 vdcp->instance); in vdc_populate_descriptor()
3137 vdcp->dring_curr_idx = idx; in vdc_populate_descriptor()
3138 cv_wait(&vdcp->membind_cv, &vdcp->lock); in vdc_populate_descriptor()
3139 if (vdcp->state == VDC_STATE_RUNNING || in vdc_populate_descriptor()
3140 vdcp->state == VDC_STATE_HANDLE_PENDING) { in vdc_populate_descriptor()
3143 vdcp->threads_pending--; in vdc_populate_descriptor()
3151 VDC_INIT_DRING_DATA_MSG_IDS(dmsg, vdcp); in vdc_populate_descriptor()
3152 dmsg.dring_ident = vdcp->dring_ident; in vdc_populate_descriptor()
3155 vdcp->seq_num++; in vdc_populate_descriptor()
3157 DTRACE_PROBE2(populate, int, vdcp->instance, in vdc_populate_descriptor()
3159 DMSG(vdcp, 2, "ident=0x%lx, st=%u, end=%u, seq=%ld\n", in vdc_populate_descriptor()
3160 vdcp->dring_ident, dmsg.start_idx, dmsg.end_idx, dmsg.seq_num); in vdc_populate_descriptor()
3167 rv = vdc_send(vdcp, (caddr_t)&dmsg, &msglen); in vdc_populate_descriptor()
3182 DMSG(vdcp, 1, "sent via LDC: rv=%d\n", rv); in vdc_populate_descriptor()
3186 DMSG(vdcp, 0, "unexpected error, rv=%d\n", rv); in vdc_populate_descriptor()
3191 vdcp->threads_pending--; in vdc_populate_descriptor()
3348 vdc_do_sync_op(vdc_t *vdcp, int operation, caddr_t addr, size_t nbytes, in vdc_do_sync_op() argument
3358 mutex_enter(&vdcp->lock); in vdc_do_sync_op()
3359 vdcp->sync_op_cnt++; in vdc_do_sync_op()
3360 while (vdcp->sync_op_blocked && vdcp->state != VDC_STATE_DETACH) { in vdc_do_sync_op()
3363 vdcp->sync_op_cnt--; in vdc_do_sync_op()
3364 mutex_exit(&vdcp->lock); in vdc_do_sync_op()
3367 cv_wait(&vdcp->sync_blocked_cv, &vdcp->lock); in vdc_do_sync_op()
3371 if (vdcp->state == VDC_STATE_DETACH) { in vdc_do_sync_op()
3372 cv_broadcast(&vdcp->sync_blocked_cv); in vdc_do_sync_op()
3373 vdcp->sync_op_cnt--; in vdc_do_sync_op()
3374 mutex_exit(&vdcp->lock); in vdc_do_sync_op()
3379 vdcp->sync_op_blocked = B_TRUE; in vdc_do_sync_op()
3381 mutex_exit(&vdcp->lock); in vdc_do_sync_op()
3386 status = vdc_do_op(vdcp, operation, addr, nbytes, slice, offset, in vdc_do_sync_op()
3389 mutex_enter(&vdcp->lock); in vdc_do_sync_op()
3391 DMSG(vdcp, 2, ": operation returned %d\n", status); in vdc_do_sync_op()
3393 if (vdcp->state == VDC_STATE_DETACH) { in vdc_do_sync_op()
3397 vdcp->sync_op_blocked = B_FALSE; in vdc_do_sync_op()
3398 vdcp->sync_op_cnt--; in vdc_do_sync_op()
3401 cv_signal(&vdcp->sync_blocked_cv); in vdc_do_sync_op()
3403 mutex_exit(&vdcp->lock); in vdc_do_sync_op()
3643 vdc_populate_mem_hdl(vdc_t *vdcp, vdc_local_desc_t *ldep) in vdc_populate_mem_hdl() argument
3654 ASSERT(vdcp != NULL); in vdc_populate_mem_hdl()
3689 DMSG(vdcp, 0, "[%d] Misaligned address %p reallocating " in vdc_populate_mem_hdl()
3691 vdcp->instance, (void *)vaddr, (void *)ldep->align_addr, in vdc_populate_mem_hdl()
3701 DMSG(vdcp, 2, "[%d] bound mem handle; ncookies=%d\n", in vdc_populate_mem_hdl()
3702 vdcp->instance, dep->payload.ncookies); in vdc_populate_mem_hdl()
3704 DMSG(vdcp, 0, "[%d] Failed to bind LDC memory handle " in vdc_populate_mem_hdl()
3706 vdcp->instance, (void *)mhdl, (void *)vaddr, rv); in vdc_populate_mem_hdl()
3722 DMSG(vdcp, 0, "?[%d] Failed to get next cookie " in vdc_populate_mem_hdl()
3724 vdcp->instance, mhdl, i, rv); in vdc_populate_mem_hdl()
3760 vdc_t *vdc = srvr->vdcp; in vdc_handle_cb()
3874 vdc_wait_for_response(vdc_t *vdcp, vio_msg_t *msgp) in vdc_wait_for_response() argument
3879 ASSERT(vdcp != NULL); in vdc_wait_for_response()
3881 DMSG(vdcp, 1, "[%d] Entered\n", vdcp->instance); in vdc_wait_for_response()
3883 status = vdc_recv(vdcp, msgp, &nbytes); in vdc_wait_for_response()
3884 DMSG(vdcp, 3, "vdc_read() done.. status=0x%x size=0x%x\n", in vdc_wait_for_response()
3887 DMSG(vdcp, 0, "?[%d] Error %d reading LDC msg\n", in vdc_wait_for_response()
3888 vdcp->instance, status); in vdc_wait_for_response()
3893 DMSG(vdcp, 0, "?[%d] Expect %lu bytes; recv'd %lu\n", in vdc_wait_for_response()
3894 vdcp->instance, sizeof (vio_msg_tag_t), nbytes); in vdc_wait_for_response()
3898 DMSG(vdcp, 2, "[%d] (%x/%x/%x)\n", vdcp->instance, in vdc_wait_for_response()
3909 if ((msgp->tag.vio_sid != vdcp->session_id) && in vdc_wait_for_response()
3911 DMSG(vdcp, 0, "[%d] Invalid SID: received 0x%x, " in vdc_wait_for_response()
3913 vdcp->instance, msgp->tag.vio_sid, in vdc_wait_for_response()
3914 vdcp->session_id, in vdc_wait_for_response()
3939 vdc_resubmit_backup_dring(vdc_t *vdcp) in vdc_resubmit_backup_dring() argument
3948 ASSERT(MUTEX_NOT_HELD(&vdcp->lock)); in vdc_resubmit_backup_dring()
3949 ASSERT(vdcp->state == VDC_STATE_HANDLE_PENDING); in vdc_resubmit_backup_dring()
3951 if (vdcp->local_dring_backup == NULL) { in vdc_resubmit_backup_dring()
3956 DMSG(vdcp, 1, "restoring pending dring entries (len=%d, tail=%d)\n", in vdc_resubmit_backup_dring()
3957 vdcp->local_dring_backup_len, vdcp->local_dring_backup_tail); in vdc_resubmit_backup_dring()
3963 b_idx = vdcp->local_dring_backup_tail; in vdc_resubmit_backup_dring()
3964 for (count = 0; count < vdcp->local_dring_backup_len; count++) { in vdc_resubmit_backup_dring()
3966 curr_ldep = &(vdcp->local_dring_backup[b_idx]); in vdc_resubmit_backup_dring()
3971 DMSG(vdcp, 1, "resubmitting entry idx=%x\n", b_idx); in vdc_resubmit_backup_dring()
3973 rv = vdc_do_op(vdcp, curr_ldep->operation, in vdc_resubmit_backup_dring()
3981 DMSG(vdcp, 1, "[%d] resubmit entry %d failed\n", in vdc_resubmit_backup_dring()
3982 vdcp->instance, b_idx); in vdc_resubmit_backup_dring()
3997 if (++b_idx >= vdcp->local_dring_backup_len) in vdc_resubmit_backup_dring()
4002 dring_size = vdcp->local_dring_backup_len * in vdc_resubmit_backup_dring()
4003 sizeof (vdcp->local_dring_backup[0]); in vdc_resubmit_backup_dring()
4005 (void) kmem_free(vdcp->local_dring_backup, dring_size); in vdc_resubmit_backup_dring()
4007 vdcp->local_dring_backup = NULL; in vdc_resubmit_backup_dring()
4010 DTRACE_PROBE2(processed, int, processed, vdc_t *, vdcp); in vdc_resubmit_backup_dring()
4030 vdc_cancel_backup_dring(vdc_t *vdcp) in vdc_cancel_backup_dring() argument
4039 ASSERT(MUTEX_HELD(&vdcp->lock)); in vdc_cancel_backup_dring()
4040 ASSERT(vdcp->state == VDC_STATE_FAILED); in vdc_cancel_backup_dring()
4042 if (vdcp->local_dring_backup == NULL) { in vdc_cancel_backup_dring()
4047 DMSG(vdcp, 1, "cancelling pending dring entries (len=%d, tail=%d)\n", in vdc_cancel_backup_dring()
4048 vdcp->local_dring_backup_len, vdcp->local_dring_backup_tail); in vdc_cancel_backup_dring()
4054 b_idx = vdcp->local_dring_backup_tail; in vdc_cancel_backup_dring()
4055 for (count = 0; count < vdcp->local_dring_backup_len; count++) { in vdc_cancel_backup_dring()
4057 ldep = &(vdcp->local_dring_backup[b_idx]); in vdc_cancel_backup_dring()
4062 DMSG(vdcp, 1, "cancelling entry idx=%x\n", b_idx); in vdc_cancel_backup_dring()
4077 VD_UPDATE_ERR_STATS(vdcp, vd_softerrs); in vdc_cancel_backup_dring()
4078 VD_KSTAT_WAITQ_EXIT(vdcp); in vdc_cancel_backup_dring()
4086 if (++b_idx >= vdcp->local_dring_backup_len) in vdc_cancel_backup_dring()
4091 dring_size = vdcp->local_dring_backup_len * in vdc_cancel_backup_dring()
4092 sizeof (vdcp->local_dring_backup[0]); in vdc_cancel_backup_dring()
4094 (void) kmem_free(vdcp->local_dring_backup, dring_size); in vdc_cancel_backup_dring()
4096 vdcp->local_dring_backup = NULL; in vdc_cancel_backup_dring()
4098 DTRACE_PROBE2(cancelled, int, cancelled, vdc_t *, vdcp); in vdc_cancel_backup_dring()
4121 vdc_t *vdcp = (vdc_t *)arg; in vdc_connection_timeout() local
4123 mutex_enter(&vdcp->lock); in vdc_connection_timeout()
4125 vdcp->ctimeout_reached = B_TRUE; in vdc_connection_timeout()
4127 mutex_exit(&vdcp->lock); in vdc_connection_timeout()
4146 vdc_backup_local_dring(vdc_t *vdcp) in vdc_backup_local_dring() argument
4151 ASSERT(MUTEX_HELD(&vdcp->lock)); in vdc_backup_local_dring()
4152 ASSERT(vdcp->state == VDC_STATE_RESETTING); in vdc_backup_local_dring()
4160 if (vdcp->local_dring_backup != NULL) { in vdc_backup_local_dring()
4161 DMSG(vdcp, 1, "reusing local descriptor ring backup " in vdc_backup_local_dring()
4162 "(len=%d, tail=%d)\n", vdcp->local_dring_backup_len, in vdc_backup_local_dring()
4163 vdcp->local_dring_backup_tail); in vdc_backup_local_dring()
4175 if (!(vdcp->initialized & VDC_DRING_LOCAL)) in vdc_backup_local_dring()
4178 DMSG(vdcp, 1, "backing up the local descriptor ring (len=%d, " in vdc_backup_local_dring()
4179 "tail=%d)\n", vdcp->dring_len, vdcp->dring_curr_idx); in vdc_backup_local_dring()
4181 dring_size = vdcp->dring_len * sizeof (vdcp->local_dring[0]); in vdc_backup_local_dring()
4183 vdcp->local_dring_backup = kmem_alloc(dring_size, KM_SLEEP); in vdc_backup_local_dring()
4184 bcopy(vdcp->local_dring, vdcp->local_dring_backup, dring_size); in vdc_backup_local_dring()
4186 vdcp->local_dring_backup_tail = vdcp->dring_curr_idx; in vdc_backup_local_dring()
4187 vdcp->local_dring_backup_len = vdcp->dring_len; in vdc_backup_local_dring()
4194 b_idx = vdcp->local_dring_backup_tail; in vdc_backup_local_dring()
4195 for (count = 0; count < vdcp->local_dring_backup_len; count++) { in vdc_backup_local_dring()
4197 curr_ldep = &(vdcp->local_dring_backup[b_idx]); in vdc_backup_local_dring()
4202 VD_KSTAT_RUNQ_BACK_TO_WAITQ(vdcp); in vdc_backup_local_dring()
4206 if (++b_idx >= vdcp->local_dring_backup_len) in vdc_backup_local_dring()
4213 vdc_switch_server(vdc_t *vdcp) in vdc_switch_server() argument
4218 ASSERT(MUTEX_HELD(&vdcp->lock)); in vdc_switch_server()
4221 if (vdcp->num_servers == 1) { in vdc_switch_server()
4226 curr_server = vdcp->curr_server; in vdc_switch_server()
4228 (curr_server->next) ? curr_server->next : vdcp->server_list; in vdc_switch_server()
4234 DMSG(vdcp, 0, "[%d] Cannot bring channel down, port %ld\n", in vdc_switch_server()
4235 vdcp->instance, curr_server->id); in vdc_switch_server()
4240 vdcp->curr_server = new_server; in vdc_switch_server()
4242 DMSG(vdcp, 0, "[%d] Switched to next vdisk server, port@%ld, ldc@%ld\n", in vdc_switch_server()
4243 vdcp->instance, vdcp->curr_server->id, vdcp->curr_server->ldc_id); in vdc_switch_server()
4247 vdc_print_svc_status(vdc_t *vdcp) in vdc_print_svc_status() argument
4253 ASSERT(mutex_owned(&vdcp->lock)); in vdc_print_svc_status()
4255 svc_state = vdcp->curr_server->svc_state; in vdc_print_svc_status()
4257 if (vdcp->curr_server->log_state == svc_state) in vdc_print_svc_status()
4260 instance = vdcp->instance; in vdc_print_svc_status()
4261 ldc_id = vdcp->curr_server->ldc_id; in vdc_print_svc_status()
4262 port_id = vdcp->curr_server->id; in vdc_print_svc_status()
4295 vdcp->curr_server->log_state = svc_state; in vdc_print_svc_status()
4332 vdc_handshake_retry(vdc_t *vdcp, int hshake_cnt, int hattr_cnt) in vdc_handshake_retry() argument
4337 ASSERT(vdcp->lifecycle != VDC_LC_DETACHING); in vdc_handshake_retry()
4340 vdcp->curr_server->hshake_cnt = hshake_cnt; in vdc_handshake_retry()
4341 vdcp->curr_server->hattr_cnt = hattr_cnt; in vdc_handshake_retry()
4348 vdcp->curr_server->hattr_total = 0; in vdc_handshake_retry()
4350 vdcp->curr_server->hattr_total += hattr_cnt; in vdc_handshake_retry()
4356 if (vdcp->lifecycle == VDC_LC_ONLINE) in vdc_handshake_retry()
4363 if (vdcp->lifecycle == VDC_LC_ATTACHING) { in vdc_handshake_retry()
4365 for (srvr = vdcp->server_list; srvr != NULL; in vdc_handshake_retry()
4379 ASSERT(vdcp->lifecycle == VDC_LC_ONLINE_PENDING); in vdc_handshake_retry()
4386 for (srvr = vdcp->server_list; srvr != NULL; srvr = srvr->next) { in vdc_handshake_retry()
4397 return (hattr_total < vdcp->hattr_min); in vdc_handshake_retry()
4424 vdc_process_msg_thread(vdc_t *vdcp) in vdc_process_msg_thread() argument
4436 mutex_enter(&vdcp->lock); in vdc_process_msg_thread()
4438 ASSERT(vdcp->lifecycle == VDC_LC_ATTACHING); in vdc_process_msg_thread()
4442 #define Q(_s) (vdcp->state == _s) ? #_s : in vdc_process_msg_thread()
4443 DMSG(vdcp, 3, "state = %d (%s)\n", vdcp->state, in vdc_process_msg_thread()
4456 switch (vdcp->state) { in vdc_process_msg_thread()
4478 vdc_timeout : vdcp->curr_server->ctimeout; in vdc_process_msg_thread()
4481 tmid = timeout(vdc_connection_timeout, vdcp, in vdc_process_msg_thread()
4486 if (vdcp->lifecycle == VDC_LC_DETACHING) { in vdc_process_msg_thread()
4487 vdcp->state = VDC_STATE_DETACH; in vdc_process_msg_thread()
4492 if (vdcp->ctimeout_reached) { in vdc_process_msg_thread()
4495 vdcp->state = VDC_STATE_FAILED; in vdc_process_msg_thread()
4506 if (!vdc_handshake_retry(vdcp, hshake_cnt, in vdc_process_msg_thread()
4508 DMSG(vdcp, 0, "[%d] too many " in vdc_process_msg_thread()
4509 "handshakes", vdcp->instance); in vdc_process_msg_thread()
4510 vdcp->state = VDC_STATE_FAILED; in vdc_process_msg_thread()
4514 vdc_switch_server(vdcp); in vdc_process_msg_thread()
4523 status = vdc_start_ldc_connection(vdcp); in vdc_process_msg_thread()
4525 vdcp->state = VDC_STATE_INIT_WAITING; in vdc_process_msg_thread()
4527 vdcp->curr_server->svc_state = in vdc_process_msg_thread()
4529 vdc_print_svc_status(vdcp); in vdc_process_msg_thread()
4536 if (vdcp->curr_server->ldc_state == LDC_UP) { in vdc_process_msg_thread()
4537 vdcp->state = VDC_STATE_NEGOTIATE; in vdc_process_msg_thread()
4547 status = cv_timedwait(&vdcp->initwait_cv, &vdcp->lock, in vdc_process_msg_thread()
4550 vdcp->state == VDC_STATE_INIT_WAITING && in vdc_process_msg_thread()
4551 vdcp->curr_server->ldc_state != LDC_UP) { in vdc_process_msg_thread()
4553 vdcp->curr_server->svc_state = in vdc_process_msg_thread()
4555 vdc_print_svc_status(vdcp); in vdc_process_msg_thread()
4556 vdcp->state = VDC_STATE_INIT; in vdc_process_msg_thread()
4560 if (vdcp->state != VDC_STATE_INIT_WAITING) { in vdc_process_msg_thread()
4561 DMSG(vdcp, 0, in vdc_process_msg_thread()
4563 vdcp->state); in vdc_process_msg_thread()
4568 switch (status = vdc_ver_negotiation(vdcp)) { in vdc_process_msg_thread()
4572 DMSG(vdcp, 0, "ver negotiate failed (%d)..\n", in vdc_process_msg_thread()
4579 switch (status = vdc_attr_negotiation(vdcp)) { in vdc_process_msg_thread()
4583 DMSG(vdcp, 0, "attr negotiate failed (%d)..\n", in vdc_process_msg_thread()
4588 switch (status = vdc_dring_negotiation(vdcp)) { in vdc_process_msg_thread()
4592 DMSG(vdcp, 0, "dring negotiate failed (%d)..\n", in vdc_process_msg_thread()
4597 switch (status = vdc_rdx_exchange(vdcp)) { in vdc_process_msg_thread()
4599 vdcp->state = VDC_STATE_HANDLE_PENDING; in vdc_process_msg_thread()
4602 DMSG(vdcp, 0, "RDX xchg failed ..(%d)\n", in vdc_process_msg_thread()
4607 DMSG(vdcp, 0, "negotiation failed: resetting (%d)\n", in vdc_process_msg_thread()
4609 vdcp->state = VDC_STATE_RESETTING; in vdc_process_msg_thread()
4610 vdcp->self_reset = B_TRUE; in vdc_process_msg_thread()
4611 vdcp->curr_server->svc_state = VDC_SERVICE_FAILED; in vdc_process_msg_thread()
4612 vdc_print_svc_status(vdcp); in vdc_process_msg_thread()
4614 DMSG(vdcp, 0, "negotiation complete (state=0x%x)...\n", in vdc_process_msg_thread()
4615 vdcp->state); in vdc_process_msg_thread()
4620 DMSG(vdcp, 0, "[%d] connection to service domain is up", in vdc_process_msg_thread()
4621 vdcp->instance); in vdc_process_msg_thread()
4622 vdcp->curr_server->svc_state = VDC_SERVICE_CONNECTED; in vdc_process_msg_thread()
4624 mutex_exit(&vdcp->lock); in vdc_process_msg_thread()
4630 if (vdcp->num_servers > 1 && in vdc_process_msg_thread()
4631 vdc_eio_check(vdcp, 0) != 0) { in vdc_process_msg_thread()
4632 mutex_enter(&vdcp->lock); in vdc_process_msg_thread()
4633 vdcp->curr_server->svc_state = in vdc_process_msg_thread()
4635 vdcp->state = VDC_STATE_FAULTED; in vdc_process_msg_thread()
4642 vdcp->ctimeout_reached = B_FALSE; in vdc_process_msg_thread()
4648 (void) vdc_setup_devid(vdcp); in vdc_process_msg_thread()
4650 status = vdc_resubmit_backup_dring(vdcp); in vdc_process_msg_thread()
4652 mutex_enter(&vdcp->lock); in vdc_process_msg_thread()
4655 vdcp->state = VDC_STATE_RESETTING; in vdc_process_msg_thread()
4656 vdcp->self_reset = B_TRUE; in vdc_process_msg_thread()
4657 vdcp->curr_server->svc_state = in vdc_process_msg_thread()
4659 vdc_print_svc_status(vdcp); in vdc_process_msg_thread()
4661 vdcp->state = VDC_STATE_RUNNING; in vdc_process_msg_thread()
4672 vdc_print_svc_status(vdcp); in vdc_process_msg_thread()
4675 for (srvr = vdcp->server_list; srvr != NULL; in vdc_process_msg_thread()
4683 vdcp->state = VDC_STATE_RESETTING; in vdc_process_msg_thread()
4684 vdcp->self_reset = B_TRUE; in vdc_process_msg_thread()
4686 vdcp->state = VDC_STATE_FAILED; in vdc_process_msg_thread()
4703 vdcp->instance); in vdc_process_msg_thread()
4706 if (vdcp->lifecycle == VDC_LC_ATTACHING) { in vdc_process_msg_thread()
4707 vdcp->lifecycle = VDC_LC_ONLINE_PENDING; in vdc_process_msg_thread()
4708 vdcp->hattr_min = vdc_hattr_min_initial; in vdc_process_msg_thread()
4710 vdcp->hattr_min = vdc_hattr_min; in vdc_process_msg_thread()
4720 cv_broadcast(&vdcp->running_cv); in vdc_process_msg_thread()
4721 vdc_cancel_backup_dring(vdcp); in vdc_process_msg_thread()
4724 while (!vdcp->io_pending) in vdc_process_msg_thread()
4725 cv_wait(&vdcp->io_pending_cv, &vdcp->lock); in vdc_process_msg_thread()
4733 for (srvr = vdcp->server_list; srvr != NULL; in vdc_process_msg_thread()
4744 vdcp->ctimeout_reached = B_FALSE; in vdc_process_msg_thread()
4746 vdcp->state = VDC_STATE_RESETTING; in vdc_process_msg_thread()
4747 vdcp->self_reset = B_TRUE; in vdc_process_msg_thread()
4753 if (vdcp->lifecycle == VDC_LC_DETACHING) { in vdc_process_msg_thread()
4754 vdcp->state = VDC_STATE_DETACH; in vdc_process_msg_thread()
4758 vdcp->lifecycle = VDC_LC_ONLINE; in vdc_process_msg_thread()
4762 "recovered", vdcp->instance); in vdc_process_msg_thread()
4770 cv_broadcast(&vdcp->running_cv); in vdc_process_msg_thread()
4773 if (vdcp->failfast_interval != 0 || in vdc_process_msg_thread()
4774 vdcp->num_servers > 1) in vdc_process_msg_thread()
4775 cv_signal(&vdcp->eio_cv); in vdc_process_msg_thread()
4778 if (vdcp->ownership & VDC_OWNERSHIP_WANTED) in vdc_process_msg_thread()
4779 vdcp->ownership |= VDC_OWNERSHIP_RESET; in vdc_process_msg_thread()
4780 cv_signal(&vdcp->ownership_cv); in vdc_process_msg_thread()
4782 vdcp->curr_server->svc_state = VDC_SERVICE_ONLINE; in vdc_process_msg_thread()
4783 vdc_print_svc_status(vdcp); in vdc_process_msg_thread()
4785 mutex_exit(&vdcp->lock); in vdc_process_msg_thread()
4789 status = vdc_wait_for_response(vdcp, &msg); in vdc_process_msg_thread()
4792 DMSG(vdcp, 1, "[%d] new pkt(s) available\n", in vdc_process_msg_thread()
4793 vdcp->instance); in vdc_process_msg_thread()
4794 status = vdc_process_data_msg(vdcp, &msg); in vdc_process_msg_thread()
4796 DMSG(vdcp, 1, "[%d] process_data_msg " in vdc_process_msg_thread()
4797 "returned err=%d\n", vdcp->instance, in vdc_process_msg_thread()
4804 mutex_enter(&vdcp->lock); in vdc_process_msg_thread()
4807 for (srvr = vdcp->server_list; srvr != NULL; in vdc_process_msg_thread()
4819 vdc_print_svc_status(vdcp); in vdc_process_msg_thread()
4821 vdcp->state = VDC_STATE_RESETTING; in vdc_process_msg_thread()
4822 vdcp->self_reset = B_TRUE; in vdc_process_msg_thread()
4837 DMSG(vdcp, 0, "Initiating channel reset " in vdc_process_msg_thread()
4838 "(pending = %d)\n", (int)vdcp->threads_pending); in vdc_process_msg_thread()
4840 if (vdcp->self_reset) { in vdc_process_msg_thread()
4841 DMSG(vdcp, 0, in vdc_process_msg_thread()
4843 vdcp->instance); in vdc_process_msg_thread()
4844 status = vdc_stop_ldc_connection(vdcp); in vdc_process_msg_thread()
4845 vdcp->self_reset = B_FALSE; in vdc_process_msg_thread()
4852 while (vdcp->threads_pending) { in vdc_process_msg_thread()
4853 cv_broadcast(&vdcp->membind_cv); in vdc_process_msg_thread()
4854 cv_broadcast(&vdcp->dring_free_cv); in vdc_process_msg_thread()
4855 mutex_exit(&vdcp->lock); in vdc_process_msg_thread()
4858 mutex_enter(&vdcp->lock); in vdc_process_msg_thread()
4861 ASSERT(vdcp->threads_pending == 0); in vdc_process_msg_thread()
4864 ASSERT(vdcp->read_state != VDC_READ_WAITING); in vdc_process_msg_thread()
4866 vdcp->read_state = VDC_READ_IDLE; in vdc_process_msg_thread()
4867 vdcp->io_pending = B_FALSE; in vdc_process_msg_thread()
4873 vdc_eio_unqueue(vdcp, 0, B_FALSE); in vdc_process_msg_thread()
4875 vdc_backup_local_dring(vdcp); in vdc_process_msg_thread()
4878 vdc_destroy_descriptor_ring(vdcp); in vdc_process_msg_thread()
4881 vdcp->state = VDC_STATE_INIT; in vdc_process_msg_thread()
4886 DMSG(vdcp, 0, "[%d] Reset thread exit cleanup ..\n", in vdc_process_msg_thread()
4887 vdcp->instance); in vdc_process_msg_thread()
4890 mutex_exit(&vdcp->lock); in vdc_process_msg_thread()
4895 mutex_enter(&vdcp->lock); in vdc_process_msg_thread()
4901 cv_broadcast(&vdcp->running_cv); in vdc_process_msg_thread()
4903 while (vdcp->sync_op_cnt > 0) { in vdc_process_msg_thread()
4904 cv_broadcast(&vdcp->sync_blocked_cv); in vdc_process_msg_thread()
4905 mutex_exit(&vdcp->lock); in vdc_process_msg_thread()
4908 mutex_enter(&vdcp->lock); in vdc_process_msg_thread()
4911 mutex_exit(&vdcp->lock); in vdc_process_msg_thread()
4913 DMSG(vdcp, 0, "[%d] Msg processing thread exiting ..\n", in vdc_process_msg_thread()
4914 vdcp->instance); in vdc_process_msg_thread()
4946 vdc_process_data_msg(vdc_t *vdcp, vio_msg_t *msg) in vdc_process_data_msg() argument
4958 ASSERT(vdcp != NULL); in vdc_process_data_msg()
4960 mutex_enter(&vdcp->lock); in vdc_process_data_msg()
4967 if ((start >= vdcp->dring_len) || in vdc_process_data_msg()
4968 (end >= vdcp->dring_len) || (end < -1)) { in vdc_process_data_msg()
4974 VD_UPDATE_ERR_STATS(vdcp, vd_softerrs); in vdc_process_data_msg()
4975 DMSG(vdcp, 0, "[%d] Bogus ACK data : start %d, end %d\n", in vdc_process_data_msg()
4976 vdcp->instance, start, end); in vdc_process_data_msg()
4977 mutex_exit(&vdcp->lock); in vdc_process_data_msg()
4984 switch (vdc_verify_seq_num(vdcp, dring_msg)) { in vdc_process_data_msg()
4988 mutex_exit(&vdcp->lock); in vdc_process_data_msg()
4996 VD_UPDATE_ERR_STATS(vdcp, vd_softerrs); in vdc_process_data_msg()
4997 DMSG(vdcp, 0, "[%d] invalid seqno\n", vdcp->instance); in vdc_process_data_msg()
4998 mutex_exit(&vdcp->lock); in vdc_process_data_msg()
5008 VD_UPDATE_ERR_STATS(vdcp, vd_softerrs); in vdc_process_data_msg()
5010 DMSG(vdcp, 0, "[%d] DATA NACK\n", vdcp->instance); in vdc_process_data_msg()
5011 mutex_exit(&vdcp->lock); in vdc_process_data_msg()
5020 VD_UPDATE_ERR_STATS(vdcp, vd_protoerrs); in vdc_process_data_msg()
5021 mutex_exit(&vdcp->lock); in vdc_process_data_msg()
5025 DMSG(vdcp, 1, ": start %d end %d\n", start, end); in vdc_process_data_msg()
5028 ldep = &vdcp->local_dring[idx]; in vdc_process_data_msg()
5030 DMSG(vdcp, 1, ": state 0x%x\n", ldep->dep->hdr.dstate); in vdc_process_data_msg()
5044 DMSG(vdcp, 1, "I/O status=%d\n", status); in vdc_process_data_msg()
5047 DMSG(vdcp, 1, in vdc_process_data_msg()
5059 ((vdcp->num_servers > 1 && in vdc_process_data_msg()
5061 (vdcp->failfast_interval != 0 && in vdc_process_data_msg()
5066 (void) vdc_eio_queue(vdcp, idx); in vdc_process_data_msg()
5071 VD_UPDATE_IO_STATS(vdcp, op, in vdc_process_data_msg()
5074 VD_UPDATE_ERR_STATS(vdcp, vd_softerrs); in vdc_process_data_msg()
5076 VD_KSTAT_RUNQ_EXIT(vdcp); in vdc_process_data_msg()
5079 (void) vdc_depopulate_descriptor(vdcp, idx); in vdc_process_data_msg()
5085 mutex_exit(&vdcp->lock); in vdc_process_data_msg()
5088 DTRACE_PROBE2(processed, int, 1, vdc_t *, vdcp); in vdc_process_data_msg()