Lines Matching refs:port
108 typedef void (*ds_msg_handler_t)(ds_port_t *port, caddr_t buf, size_t len);
109 static void ds_handle_init_req(ds_port_t *port, caddr_t buf, size_t len);
110 static void ds_handle_init_ack(ds_port_t *port, caddr_t buf, size_t len);
111 static void ds_handle_init_nack(ds_port_t *port, caddr_t buf, size_t len);
112 static void ds_handle_reg_req(ds_port_t *port, caddr_t buf, size_t len);
113 static void ds_handle_reg_ack(ds_port_t *port, caddr_t buf, size_t len);
114 static void ds_handle_reg_nack(ds_port_t *port, caddr_t buf, size_t len);
115 static void ds_handle_unreg_req(ds_port_t *port, caddr_t buf, size_t len);
116 static void ds_handle_unreg_ack(ds_port_t *port, caddr_t buf, size_t len);
117 static void ds_handle_unreg_nack(ds_port_t *port, caddr_t buf, size_t len);
118 static void ds_handle_data(ds_port_t *port, caddr_t buf, size_t len);
119 static void ds_handle_nack(ds_port_t *port, caddr_t buf, size_t len);
146 static int ds_ldc_init(ds_port_t *port);
150 static int ds_recv_msg(ds_port_t *port, caddr_t msgp, size_t *sizep);
151 static void ds_handle_up_event(ds_port_t *port);
152 static void ds_handle_down_reset_events(ds_port_t *port);
157 static int ds_send_msg(ds_port_t *port, caddr_t msg, size_t msglen);
158 static int ds_send_reg_req(ds_svc_t *svc, ds_port_t *port);
159 static void ds_send_unreg_nack(ds_port_t *port, ds_svc_hdl_t bad_hdl);
160 static void ds_send_data_nack(ds_port_t *port, ds_svc_hdl_t bad_hdl);
168 static void ds_reset_svc(ds_svc_t *svc, ds_port_t *port);
169 static int ds_svc_register_onport(ds_svc_t *svc, ds_port_t *port);
171 static void ds_set_port_ready(ds_port_t *port, uint16_t major, uint16_t minor);
174 static void ds_port_reset(ds_port_t *port);
175 static ldc_status_t ds_update_ldc_state(ds_port_t *port);
195 ds_port_t *port);
197 ds_port_t *port);
240 ds_update_ldc_state(ds_port_t *port) in ds_update_ldc_state() argument
246 ASSERT(MUTEX_HELD(&port->lock)); in ds_update_ldc_state()
251 if ((rv = ldc_status(port->ldc.hdl, &ldc_state)) != 0) { in ds_update_ldc_state()
253 PORTID(port), __func__, ds_errno_to_str(rv, ebuf)); in ds_update_ldc_state()
254 ldc_state = port->ldc.state; in ds_update_ldc_state()
256 port->ldc.state = ldc_state; in ds_update_ldc_state()
263 ds_handle_down_reset_events(ds_port_t *port) in ds_handle_down_reset_events() argument
265 DS_DBG_LDC(CE_NOTE, "ds@%lx: %s: entered" DS_EOL, PORTID(port), in ds_handle_down_reset_events()
269 mutex_enter(&port->lock); in ds_handle_down_reset_events()
271 ds_sys_drain_events(port); in ds_handle_down_reset_events()
273 (void) ds_update_ldc_state(port); in ds_handle_down_reset_events()
276 ds_port_reset(port); in ds_handle_down_reset_events()
279 (void) ldc_up(port->ldc.hdl); in ds_handle_down_reset_events()
281 mutex_exit(&port->lock); in ds_handle_down_reset_events()
284 ds_handle_up_event(port); in ds_handle_down_reset_events()
286 DS_DBG_LDC(CE_NOTE, "ds@%lx: %s: exit" DS_EOL, PORTID(port), __func__); in ds_handle_down_reset_events()
290 ds_handle_up_event(ds_port_t *port) in ds_handle_up_event() argument
294 DS_DBG_LDC(CE_NOTE, "ds@%lx: %s: entered" DS_EOL, PORTID(port), in ds_handle_up_event()
297 mutex_enter(&port->lock); in ds_handle_up_event()
299 ldc_state = ds_update_ldc_state(port); in ds_handle_up_event()
301 mutex_exit(&port->lock); in ds_handle_up_event()
303 if ((ldc_state == LDC_UP) && IS_DS_PORT(port)) { in ds_handle_up_event()
307 ds_send_init_req(port); in ds_handle_up_event()
310 DS_DBG_LDC(CE_NOTE, "ds@%lx: %s: exit" DS_EOL, PORTID(port), __func__); in ds_handle_up_event()
316 ds_port_t *port = (ds_port_t *)arg; in ds_ldc_cb() local
320 PORTID(port), __func__, decode_ldc_events(event, evstring), in ds_ldc_cb()
325 DS_EOL, PORTID(port), __func__); in ds_ldc_cb()
330 ds_handle_down_reset_events(port); in ds_ldc_cb()
335 ds_handle_up_event(port); in ds_ldc_cb()
339 if (port->ldc.state != LDC_UP) { in ds_ldc_cb()
341 "port not up" DS_EOL, PORTID(port), __func__); in ds_ldc_cb()
345 if (ds_sys_dispatch_func(ds_handle_recv, port)) { in ds_ldc_cb()
347 " event", PORTID(port)); in ds_ldc_cb()
353 "not supported" DS_EOL, PORTID(port), __func__); in ds_ldc_cb()
358 "0x%llx" DS_EOL, PORTID(port), __func__, in ds_ldc_cb()
362 DS_DBG_LDC(CE_NOTE, "ds@%lx: %s: exit" DS_EOL, PORTID(port), __func__); in ds_ldc_cb()
368 ds_ldc_init(ds_port_t *port) in ds_ldc_init() argument
372 caddr_t ldc_cb_arg = (caddr_t)port; in ds_ldc_init()
375 ASSERT(MUTEX_HELD(&port->lock)); in ds_ldc_init()
378 PORTID(port), __func__, (u_longlong_t)port->ldc.id); in ds_ldc_init()
385 if ((rv = ldc_init(port->ldc.id, &ldc_attr, &port->ldc.hdl)) != 0) { in ds_ldc_init()
387 DS_EOL, PORTID(port), __func__, port->ldc.id, in ds_ldc_init()
392 rv = ldc_reg_callback(port->ldc.hdl, ds_ldc_cb, ldc_cb_arg); in ds_ldc_init()
395 DS_EOL, PORTID(port), __func__, ds_errno_to_str(rv, ebuf)); in ds_ldc_init()
399 ds_sys_ldc_init(port); in ds_ldc_init()
404 ds_ldc_fini(ds_port_t *port) in ds_ldc_fini() argument
409 ASSERT(port->state >= DS_PORT_LDC_INIT); in ds_ldc_fini()
410 ASSERT(MUTEX_HELD(&port->lock)); in ds_ldc_fini()
412 DS_DBG_LDC(CE_NOTE, "ds@%lx: %s: ldc_id=%ld" DS_EOL, PORTID(port), in ds_ldc_fini()
413 __func__, port->ldc.id); in ds_ldc_fini()
415 if ((rv = ldc_close(port->ldc.hdl)) != 0) { in ds_ldc_fini()
417 PORTID(port), __func__, ds_errno_to_str(rv, ebuf)); in ds_ldc_fini()
421 if ((rv = ldc_unreg_callback(port->ldc.hdl)) != 0) { in ds_ldc_fini()
423 DS_EOL, PORTID(port), __func__, ds_errno_to_str(rv, ebuf)); in ds_ldc_fini()
427 if ((rv = ldc_fini(port->ldc.hdl)) != 0) { in ds_ldc_fini()
429 PORTID(port), __func__, ds_errno_to_str(rv, ebuf)); in ds_ldc_fini()
433 port->ldc.id = (uint64_t)-1; in ds_ldc_fini()
434 port->ldc.hdl = NULL; in ds_ldc_fini()
435 port->ldc.state = 0; in ds_ldc_fini()
447 ds_recv_msg(ds_port_t *port, caddr_t msgp, size_t *sizep) in ds_recv_msg() argument
456 ASSERT(MUTEX_HELD(&port->rcv_lock)); in ds_recv_msg()
461 PORTID(port), bytes_req); in ds_recv_msg()
467 mutex_enter(&port->lock); in ds_recv_msg()
468 if (port->ldc.state == LDC_UP) { in ds_recv_msg()
469 rv = ldc_read(port->ldc.hdl, msgp, &nbytes); in ds_recv_msg()
472 mutex_exit(&port->lock); in ds_recv_msg()
478 PORTID(port), __func__, in ds_recv_msg()
486 PORTID(port), nbytes, retry_count); in ds_recv_msg()
504 " no data available" DS_EOL, PORTID(port)); in ds_recv_msg()
516 "message" DS_EOL, PORTID(port)); in ds_recv_msg()
529 ds_port_t *port = (ds_port_t *)arg; in ds_handle_recv() local
540 DS_DBG_LDC(CE_NOTE, "ds@%lx: %s..." DS_EOL, PORTID(port), __func__); in ds_handle_recv()
549 mutex_enter(&port->rcv_lock); in ds_handle_recv()
552 mutex_enter(&port->lock); in ds_handle_recv()
553 if (port->ldc.state == LDC_UP) { in ds_handle_recv()
554 rv = ldc_chkq(port->ldc.hdl, &hasdata); in ds_handle_recv()
557 mutex_exit(&port->lock); in ds_handle_recv()
562 PORTID(port), __func__); in ds_handle_recv()
573 if ((rv = ds_recv_msg(port, currp, &read_size)) != 0) { in ds_handle_recv()
585 DS_EOL, PORTID(port), read_size, DS_HDR_SZ); in ds_handle_recv()
601 PORTID(port), __func__, (int)read_size); in ds_handle_recv()
608 if ((rv = ds_recv_msg(port, currp, &read_size)) != 0) { in ds_handle_recv()
617 PORTID(port), __func__, (DS_HDR_SZ + read_size), in ds_handle_recv()
632 devent->port = port; in ds_handle_recv()
637 (void) ds_log_add_msg(DS_LOG_IN(port->id), msg, msglen); in ds_handle_recv()
641 "event handler", PORTID(port)); in ds_handle_recv()
646 mutex_exit(&port->rcv_lock); in ds_handle_recv()
650 ds_handle_down_reset_events(port); in ds_handle_recv()
653 DS_DBG_LDC(CE_NOTE, "ds@%lx: %s done" DS_EOL, PORTID(port), __func__); in ds_handle_recv()
661 ds_port_t *port; in ds_dispatch_event() local
663 port = event->port; in ds_dispatch_event()
669 PORTID(port), hdr->msg_type); in ds_dispatch_event()
671 (*ds_msg_handlers[hdr->msg_type])(port, event->buf, in ds_dispatch_event()
675 "type (%d)" DS_EOL, PORTID(port), hdr->msg_type); in ds_dispatch_event()
683 ds_send_msg(ds_port_t *port, caddr_t msg, size_t msglen) in ds_send_msg() argument
690 DS_DBG_LDC(CE_NOTE, "ds@%lx: %s msglen: %ld" DS_EOL, PORTID(port), in ds_send_msg()
694 (void) ds_log_add_msg(DS_LOG_OUT(port->id), (uint8_t *)msg, msglen); in ds_send_msg()
701 mutex_enter(&port->tx_lock); in ds_send_msg()
704 mutex_enter(&port->lock); in ds_send_msg()
705 if (port->ldc.state == LDC_UP) { in ds_send_msg()
706 rv = ldc_write(port->ldc.hdl, currp, &msglen); in ds_send_msg()
709 mutex_exit(&port->lock); in ds_send_msg()
712 mutex_exit(&port->tx_lock); in ds_send_msg()
714 ds_handle_down_reset_events, port); in ds_send_msg()
722 "remaining" DS_EOL, PORTID(port), rv, in ds_send_msg()
734 mutex_exit(&port->tx_lock); in ds_send_msg()
745 ds_handle_init_req(ds_port_t *port, caddr_t buf, size_t len) in ds_handle_init_req() argument
761 "length (%ld), expected %ld" DS_EOL, PORTID(port), len, in ds_handle_init_req()
769 PORTID(port), req->major_vers, req->minor_vers); in ds_handle_init_req()
791 PORTID(port), MIN(new_minor, req->minor_vers)); in ds_handle_init_req()
804 PORTID(port), new_major); in ds_handle_init_req()
810 (void) ds_send_msg(port, msg, msglen); in ds_handle_init_req()
814 ds_set_port_ready(port, req->major_vers, ack->minor_vers); in ds_handle_init_req()
819 ds_handle_init_ack(ds_port_t *port, caddr_t buf, size_t len) in ds_handle_init_ack() argument
830 "length (%ld), expected %ld" DS_EOL, PORTID(port), len, in ds_handle_init_ack()
837 mutex_enter(&port->lock); in ds_handle_init_ack()
839 if (port->state == DS_PORT_READY) { in ds_handle_init_ack()
841 PORTID(port)); in ds_handle_init_ack()
842 mutex_exit(&port->lock); in ds_handle_init_ack()
846 if (port->state != DS_PORT_INIT_REQ) { in ds_handle_init_ack()
848 DS_EOL, PORTID(port), port->state); in ds_handle_init_ack()
849 mutex_exit(&port->lock); in ds_handle_init_ack()
853 ver = &(ds_vers[port->ver_idx]); in ds_handle_init_ack()
856 mutex_exit(&port->lock); in ds_handle_init_ack()
859 PORTID(port), major, minor); in ds_handle_init_ack()
861 ds_set_port_ready(port, major, minor); in ds_handle_init_ack()
865 ds_handle_init_nack(ds_port_t *port, caddr_t buf, size_t len) in ds_handle_init_nack() argument
875 "length (%ld), expected %ld" DS_EOL, PORTID(port), len, in ds_handle_init_nack()
882 mutex_enter(&port->lock); in ds_handle_init_nack()
884 if (port->state != DS_PORT_INIT_REQ) { in ds_handle_init_nack()
886 DS_EOL, PORTID(port), port->state); in ds_handle_init_nack()
887 mutex_exit(&port->lock); in ds_handle_init_nack()
891 ver = &(ds_vers[port->ver_idx]); in ds_handle_init_nack()
894 DS_EOL, PORTID(port), ver->major, ver->minor, nack->major_vers); in ds_handle_init_nack()
899 DS_EOL, PORTID(port)); in ds_handle_init_nack()
900 mutex_exit(&port->lock); in ds_handle_init_nack()
909 for (idx = port->ver_idx; idx < DS_NUM_VER; idx++) { in ds_handle_init_nack()
919 "supported" DS_EOL, PORTID(port), nack->major_vers); in ds_handle_init_nack()
921 mutex_exit(&port->lock); in ds_handle_init_nack()
927 port->ver_idx = idx; in ds_handle_init_nack()
928 port->state = DS_PORT_LDC_INIT; in ds_handle_init_nack()
929 mutex_exit(&port->lock); in ds_handle_init_nack()
931 ds_send_init_req(port); in ds_handle_init_nack()
936 ds_find_svc_by_id_port(char *svc_id, int is_client, ds_port_t *port) in ds_find_svc_by_id_port() argument
953 if (port != NULL && svc->port == port) { in ds_find_svc_by_id_port()
966 ds_handle_reg_req(ds_port_t *port, caddr_t buf, size_t len) in ds_handle_reg_req() argument
985 PORTID(port), len, explen); in ds_handle_reg_req()
992 DS_EOL, PORTID(port), req->svc_id, req->major_vers, req->minor_vers, in ds_handle_reg_req()
997 DS_HDL_ISCLIENT(req->svc_handle) == 0, port); in ds_handle_reg_req()
1016 PORTID(port), req->svc_id); in ds_handle_reg_req()
1020 (void) ds_send_msg(port, msg, msglen); in ds_handle_reg_req()
1025 PORTID(port), req->svc_id, (u_longlong_t)svc->hdl); in ds_handle_reg_req()
1044 "client, state (%x)" DS_EOL, PORTID(port), in ds_handle_reg_req()
1051 "client" DS_EOL, PORTID(port), req->svc_id); in ds_handle_reg_req()
1057 PORTID(port), req->svc_id, svc->state); in ds_handle_reg_req()
1058 (void) ds_svc_unregister(svc, port); in ds_handle_reg_req()
1061 (void) ds_svc_port_up(svc, port); in ds_handle_reg_req()
1062 (void) ds_svc_register_onport(svc, port); in ds_handle_reg_req()
1082 "svc_portid: %d" DS_EOL, PORTID(port), req->svc_id, in ds_handle_reg_req()
1084 (int)(svc->port == NULL ? -1 : PORTID(svc->port))); in ds_handle_reg_req()
1090 if (svc->port != NULL && port == svc->port) { in ds_handle_reg_req()
1095 (void) ds_svc_unregister(svc, port); in ds_handle_reg_req()
1108 svc->port = port; in ds_handle_reg_req()
1134 DS_EOL, PORTID(port), svc->cap.svc_id, in ds_handle_reg_req()
1152 DS_EOL, PORTID(port), svc->cap.svc_id, new_major); in ds_handle_reg_req()
1156 (void) ds_send_msg(port, msg, msglen); in ds_handle_reg_req()
1161 ds_handle_reg_ack(ds_port_t *port, caddr_t buf, size_t len) in ds_handle_reg_ack() argument
1172 "length (%ld), expected %ld" DS_EOL, PORTID(port), len, in ds_handle_reg_ack()
1188 DS_EOL, PORTID(port), (u_longlong_t)ack->svc_handle); in ds_handle_reg_ack()
1195 PORTID(port), svc->state); in ds_handle_reg_ack()
1220 svc->port = port; in ds_handle_reg_ack()
1223 DS_EOL, PORTID(port), svc->cap.svc_id, svc->ver.major, in ds_handle_reg_ack()
1244 ds_port_is_ready(ds_port_t *port) in ds_port_is_ready() argument
1248 mutex_enter(&port->lock); in ds_port_is_ready()
1249 is_ready = (port->ldc.state == LDC_UP) && in ds_port_is_ready()
1250 (port->state == DS_PORT_READY); in ds_port_is_ready()
1251 mutex_exit(&port->lock); in ds_port_is_ready()
1258 ds_port_t *port; in ds_try_next_port() local
1289 port = &ds_ports[portid]; in ds_try_next_port()
1291 if (!ds_port_is_ready(port)) in ds_try_next_port()
1295 portid, __func__, (uint_t)(port->ldc.id)); in ds_try_next_port()
1299 if (ds_send_reg_req(svc, port) == 0) { in ds_try_next_port()
1309 ds_reset_svc(svc, port); in ds_try_next_port()
1314 ds_handle_reg_nack(ds_port_t *port, caddr_t buf, size_t len) in ds_handle_reg_nack() argument
1324 "length (%ld), expected %ld" DS_EOL, PORTID(port), len, in ds_handle_reg_nack()
1338 DS_EOL, PORTID(port), (u_longlong_t)nack->svc_handle); in ds_handle_reg_nack()
1348 DS_EOL, PORTID(port), (u_longlong_t)nack->svc_handle); in ds_handle_reg_nack()
1355 "invalid state (%d)" DS_EOL, PORTID(port), svc->cap.svc_id, in ds_handle_reg_nack()
1362 " for %s" DS_EOL, PORTID(port), svc->cap.svc_id); in ds_handle_reg_nack()
1363 ds_reset_svc(svc, port); in ds_handle_reg_nack()
1373 DS_EOL, PORTID(port), svc->cap.svc_id); in ds_handle_reg_nack()
1374 ds_reset_svc(svc, port); in ds_handle_reg_nack()
1376 ds_try_next_port(svc, PORTID(port) + 1); in ds_handle_reg_nack()
1381 DS_EOL, PORTID(port), svc->cap.svc_id, in ds_handle_reg_nack()
1399 DS_EOL, PORTID(port), svc->cap.svc_id, nack->major_vers); in ds_handle_reg_nack()
1400 ds_reset_svc(svc, port); in ds_handle_reg_nack()
1402 ds_try_next_port(svc, PORTID(port) + 1); in ds_handle_reg_nack()
1417 ds_handle_unreg_req(ds_port_t *port, caddr_t buf, size_t len) in ds_handle_unreg_req() argument
1431 "length (%ld), expected %ld" DS_EOL, PORTID(port), len, in ds_handle_unreg_req()
1442 ((svc = ds_find_clnt_svc_by_hdl_port(req->svc_handle, port)) in ds_handle_unreg_req()
1444 svc->port != port))) { in ds_handle_unreg_req()
1446 mutex_enter(&port->lock); in ds_handle_unreg_req()
1447 is_up = (port->ldc.state == LDC_UP); in ds_handle_unreg_req()
1448 mutex_exit(&port->lock); in ds_handle_unreg_req()
1452 DS_EOL, PORTID(port), (u_longlong_t)req->svc_handle); in ds_handle_unreg_req()
1453 ds_send_unreg_nack(port, req->svc_handle); in ds_handle_unreg_req()
1458 PORTID(port), svc->cap.svc_id, (u_longlong_t)req->svc_handle); in ds_handle_unreg_req()
1460 (void) ds_svc_unregister(svc, svc->port); in ds_handle_unreg_req()
1463 PORTID(port), svc->cap.svc_id, (u_longlong_t)req->svc_handle); in ds_handle_unreg_req()
1480 (void) ds_send_msg(port, msg, msglen); in ds_handle_unreg_req()
1486 ds_handle_unreg_ack(ds_port_t *port, caddr_t buf, size_t len) in ds_handle_unreg_ack() argument
1494 "length (%ld), expected %ld" DS_EOL, PORTID(port), len, in ds_handle_unreg_ack()
1502 PORTID(port), (u_longlong_t)ack->svc_handle); in ds_handle_unreg_ack()
1515 DS_EOL, PORTID(port), (u_longlong_t)ack->svc_handle); in ds_handle_unreg_ack()
1523 ds_handle_unreg_nack(ds_port_t *port, caddr_t buf, size_t len) in ds_handle_unreg_nack() argument
1531 "length (%ld), expected %ld" DS_EOL, PORTID(port), len, in ds_handle_unreg_nack()
1539 PORTID(port), (u_longlong_t)nack->svc_handle); in ds_handle_unreg_nack()
1552 DS_EOL, PORTID(port), (u_longlong_t)nack->svc_handle); in ds_handle_unreg_nack()
1560 ds_handle_data(ds_port_t *port, caddr_t buf, size_t len) in ds_handle_data() argument
1572 "(%ld), expected at least %ld" DS_EOL, PORTID(port), len, in ds_handle_data()
1587 if ((svc = ds_find_clnt_svc_by_hdl_port(data->svc_handle, port)) in ds_handle_data()
1592 DS_EOL, PORTID(port), in ds_handle_data()
1594 ds_send_data_nack(port, data->svc_handle); in ds_handle_data()
1602 PORTID(port), svc->cap.svc_id, (u_longlong_t)svc->hdl); in ds_handle_data()
1610 ds_handle_nack(ds_port_t *port, caddr_t buf, size_t len) in ds_handle_nack() argument
1619 "length (%ld), expected %ld" DS_EOL, PORTID(port), len, in ds_handle_nack()
1627 DS_EOL, PORTID(port), (u_longlong_t)nack->svc_handle, in ds_handle_nack()
1635 port)) == NULL) { in ds_handle_nack()
1643 " as invalid" DS_EOL, PORTID(port), in ds_handle_nack()
1646 (void) ds_svc_unregister(svc, svc->port); in ds_handle_nack()
1654 ds_send_init_req(ds_port_t *port) in ds_send_init_req() argument
1659 ds_ver_t *vers = &ds_vers[port->ver_idx]; in ds_send_init_req()
1661 mutex_enter(&port->lock); in ds_send_init_req()
1662 if (port->state != DS_PORT_LDC_INIT) { in ds_send_init_req()
1664 DS_EOL, PORTID(port), port->state); in ds_send_init_req()
1665 mutex_exit(&port->lock); in ds_send_init_req()
1668 mutex_exit(&port->lock); in ds_send_init_req()
1671 PORTID(port), vers->major, vers->minor); in ds_send_init_req()
1683 if (ds_send_msg(port, (caddr_t)hdr, msglen) == 0) { in ds_send_init_req()
1689 mutex_enter(&port->lock); in ds_send_init_req()
1690 if (port->state == DS_PORT_LDC_INIT) in ds_send_init_req()
1691 port->state = DS_PORT_INIT_REQ; in ds_send_init_req()
1692 mutex_exit(&port->lock); in ds_send_init_req()
1698 ds_send_reg_req(ds_svc_t *svc, ds_port_t *port) in ds_send_reg_req() argument
1711 "for svc '%s'" DS_EOL, PORTID(port), svc->state, in ds_send_reg_req()
1716 mutex_enter(&port->lock); in ds_send_reg_req()
1719 if (port->ldc.state != LDC_UP) { in ds_send_reg_req()
1722 DS_EOL, PORTID(port), port->ldc.id); in ds_send_reg_req()
1723 mutex_exit(&port->lock); in ds_send_reg_req()
1728 if (port->state != DS_PORT_READY) { in ds_send_reg_req()
1731 DS_EOL, PORTID(port)); in ds_send_reg_req()
1732 mutex_exit(&port->lock); in ds_send_reg_req()
1736 mutex_exit(&port->lock); in ds_send_reg_req()
1759 DS_EOL, PORTID(port), svc->cap.svc_id, ver->major, ver->minor, in ds_send_reg_req()
1762 if ((rv = ds_send_msg(port, msg, msglen)) != 0) { in ds_send_reg_req()
1763 svc->port = port; in ds_send_reg_req()
1783 ds_port_t *port = svc->port; in ds_send_unreg_req() local
1786 if (port == NULL) { in ds_send_unreg_req()
1792 mutex_enter(&port->lock); in ds_send_unreg_req()
1795 if (port->ldc.state != LDC_UP) { in ds_send_unreg_req()
1798 DS_EOL, PORTID(port), port->ldc.id); in ds_send_unreg_req()
1799 mutex_exit(&port->lock); in ds_send_unreg_req()
1804 if (port->state != DS_PORT_READY) { in ds_send_unreg_req()
1807 PORTID(port)); in ds_send_unreg_req()
1808 mutex_exit(&port->lock); in ds_send_unreg_req()
1812 mutex_exit(&port->lock); in ds_send_unreg_req()
1831 PORTID(port), (svc->cap.svc_id) ? svc->cap.svc_id : "NULL", in ds_send_unreg_req()
1834 if ((rv = ds_send_msg(port, msg, msglen)) != 0) { in ds_send_unreg_req()
1843 ds_send_unreg_nack(ds_port_t *port, ds_svc_hdl_t bad_hdl) in ds_send_unreg_nack() argument
1850 mutex_enter(&port->lock); in ds_send_unreg_nack()
1853 if (port->ldc.state != LDC_UP) { in ds_send_unreg_nack()
1856 DS_EOL, PORTID(port), port->ldc.id); in ds_send_unreg_nack()
1857 mutex_exit(&port->lock); in ds_send_unreg_nack()
1862 if (port->state != DS_PORT_READY) { in ds_send_unreg_nack()
1865 DS_EOL, PORTID(port)); in ds_send_unreg_nack()
1866 mutex_exit(&port->lock); in ds_send_unreg_nack()
1870 mutex_exit(&port->lock); in ds_send_unreg_nack()
1885 PORTID(port), (u_longlong_t)bad_hdl); in ds_send_unreg_nack()
1887 (void) ds_send_msg(port, msg, msglen); in ds_send_unreg_nack()
1892 ds_send_data_nack(ds_port_t *port, ds_svc_hdl_t bad_hdl) in ds_send_data_nack() argument
1899 mutex_enter(&port->lock); in ds_send_data_nack()
1902 if (port->ldc.state != LDC_UP) { in ds_send_data_nack()
1905 DS_EOL, PORTID(port), port->ldc.id); in ds_send_data_nack()
1906 mutex_exit(&port->lock); in ds_send_data_nack()
1911 if (port->state != DS_PORT_READY) { in ds_send_data_nack()
1914 PORTID(port)); in ds_send_data_nack()
1915 mutex_exit(&port->lock); in ds_send_data_nack()
1919 mutex_exit(&port->lock); in ds_send_data_nack()
1935 PORTID(port), (u_longlong_t)bad_hdl); in ds_send_data_nack()
1937 (void) ds_send_msg(port, msg, msglen); in ds_send_data_nack()
2108 ds_set_svc_port_tried(char *svc_id, ds_port_t *port) in ds_set_svc_port_tried() argument
2120 DS_PORTSET_ADD(svc->tried, PORTID(port)); in ds_set_svc_port_tried()
2125 ds_svc_register_onport(ds_svc_t *svc, ds_port_t *port) in ds_svc_register_onport() argument
2132 if (!DS_PORT_IN_SET(svc->avail, PORTID(port))) in ds_svc_register_onport()
2135 if (DS_PORT_IN_SET(svc->tried, PORTID(port))) in ds_svc_register_onport()
2138 if (!ds_port_is_ready(port)) in ds_svc_register_onport()
2144 DS_PORTSET_ADD(svc->tried, PORTID(port)); in ds_svc_register_onport()
2146 ds_set_svc_port_tried(svc->cap.svc_id, port); in ds_svc_register_onport()
2151 if (PORTID(port) == ds_sp_port_id) { in ds_svc_register_onport()
2156 if (ds_send_reg_req(svc, port) == 0) { in ds_svc_register_onport()
2163 ds_reset_svc(svc, port); in ds_svc_register_onport()
2185 ds_port_t *port; in ds_svc_register() local
2220 port = &ds_ports[idx]; in ds_svc_register()
2221 if (ds_svc_register_onport(svc, port)) { in ds_svc_register()
2233 ds_port_t *port = (ds_port_t *)arg; in ds_svc_unregister() local
2243 if (svc->port != port) { in ds_svc_unregister()
2247 if (port) { in ds_svc_unregister()
2249 " hdl=0x%09lx" DS_EOL, PORTID(port), svc->cap.svc_id, in ds_svc_unregister()
2258 ds_reset_svc(svc, port); in ds_svc_unregister()
2283 ds_port_t *port = (ds_port_t *)arg; in ds_svc_port_up() local
2290 DS_PORTSET_ADD(svc->avail, port->id); in ds_svc_port_up()
2291 DS_PORTSET_DEL(svc->tried, port->id); in ds_svc_port_up()
2297 ds_set_port_ready(ds_port_t *port, uint16_t major, uint16_t minor) in ds_set_port_ready() argument
2301 mutex_enter(&port->lock); in ds_set_port_ready()
2302 was_ready = (port->state == DS_PORT_READY); in ds_set_port_ready()
2304 port->state = DS_PORT_READY; in ds_set_port_ready()
2305 port->ver.major = major; in ds_set_port_ready()
2306 port->ver.minor = minor; in ds_set_port_ready()
2308 mutex_exit(&port->lock); in ds_set_port_ready()
2320 (void) ds_walk_svcs(ds_svc_port_up, port); in ds_set_port_ready()
2321 (void) ds_walk_svcs(ds_svc_register_onport_walker, port); in ds_set_port_ready()
2381 ds_reset_svc(ds_svc_t *svc, ds_port_t *port) in ds_reset_svc() argument
2390 svc->port = NULL; in ds_reset_svc()
2391 if (port) { in ds_reset_svc()
2392 DS_PORTSET_DEL(svc->avail, port->id); in ds_reset_svc()
2427 ds_port_reset(ds_port_t *port) in ds_port_reset() argument
2430 ASSERT(MUTEX_HELD(&port->lock)); in ds_port_reset()
2433 (void) ds_walk_svcs(ds_svc_unregister, port); in ds_port_reset()
2435 port->ver_idx = 0; in ds_port_reset()
2436 port->ver.major = 0; in ds_port_reset()
2437 port->ver.minor = 0; in ds_port_reset()
2438 port->state = DS_PORT_LDC_INIT; in ds_port_reset()
2669 if (svc->port) { in ds_unreg_hdl()
2673 (void) ds_svc_unregister(svc, svc->port); in ds_unreg_hdl()
2731 ds_port_t *port; in ds_cap_send() local
2763 if ((port = svc->port) == NULL) { in ds_cap_send()
2778 if (port->ldc.state != LDC_UP) { in ds_cap_send()
2805 " payload_len=%d" DS_EOL, PORTID(port), (u_longlong_t)svc->hdl, in ds_cap_send()
2809 if ((rv = ds_send_msg(port, msg, msglen)) != 0) { in ds_cap_send()
2818 ds_port_common_init(ds_port_t *port) in ds_port_common_init() argument
2822 if ((port->flags & DS_PORT_MUTEX_INITED) == 0) { in ds_port_common_init()
2823 mutex_init(&port->lock, NULL, MUTEX_DRIVER, NULL); in ds_port_common_init()
2824 mutex_init(&port->tx_lock, NULL, MUTEX_DRIVER, NULL); in ds_port_common_init()
2825 mutex_init(&port->rcv_lock, NULL, MUTEX_DRIVER, NULL); in ds_port_common_init()
2826 port->flags |= DS_PORT_MUTEX_INITED; in ds_port_common_init()
2829 port->state = DS_PORT_INIT; in ds_port_common_init()
2830 DS_PORTSET_ADD(ds_allports, port->id); in ds_port_common_init()
2832 ds_sys_port_init(port); in ds_port_common_init()
2834 mutex_enter(&port->lock); in ds_port_common_init()
2835 rv = ds_ldc_init(port); in ds_port_common_init()
2836 mutex_exit(&port->lock); in ds_port_common_init()
2842 ds_handle_up_event(port); in ds_port_common_init()
2847 ds_port_common_fini(ds_port_t *port) in ds_port_common_fini() argument
2849 ASSERT(MUTEX_HELD(&port->lock)); in ds_port_common_fini()
2851 port->state = DS_PORT_FREE; in ds_port_common_fini()
2853 DS_PORTSET_DEL(ds_allports, port->id); in ds_port_common_fini()
2855 ds_sys_port_fini(port); in ds_port_common_fini()
3145 svc->port = NULL; in ds_loopback_set_svc()
3151 lb_svc->port = NULL; in ds_loopback_set_svc()
3162 ds_find_clnt_svc_by_hdl_port(ds_svc_hdl_t hdl, ds_port_t *port) in ds_find_clnt_svc_by_hdl_port() argument
3168 PORTID(port), __func__, (u_longlong_t)hdl); in ds_find_clnt_svc_by_hdl_port()
3177 svc->svc_hdl == hdl && svc->port == port) { in ds_find_clnt_svc_by_hdl_port()
3179 "0x%llx: svc%d" DS_EOL, PORTID(port), __func__, in ds_find_clnt_svc_by_hdl_port()
3185 PORTID(port), __func__, (u_longlong_t)hdl); in ds_find_clnt_svc_by_hdl_port()
3208 newsvc->port = NULL; in ds_svc_clone()