Lines Matching defs:conn
47 * conn The connection
54 my_soo_write(connection_t *conn, struct uio *u)
64 rw_enter(&conn->c_sock_rw, RW_READER);
65 if (conn->c_sock == NULL) {
68 so = conn->c_sock->f_socket;
70 NULL, NULL, 0, conn->c_threadobj);
72 rw_exit(&conn->c_sock_rw);
77 DEBC(conn, 0, ("Write failed sock %p (ret: %d, req: %zu, resid: %zu)\n",
78 conn->c_sock, ret, resid, u->uio_resid));
79 handle_connection_error(conn, ISCSI_STATUS_SOCKET_ERROR, NO_LOGOUT);
99 connection_t *conn, *next;
104 (conn = sess->s_mru_connection) == NULL) {
108 next = conn;
114 } while (next != NULL && next != conn &&
148 connection_t *conn;
157 if ((conn = assign_connection(sess, FALSE)) == NULL) {
172 no_tm = send_logout(conn, oldconn, RECOVER_CONNECTION, TRUE);
175 DEBC(conn, 1, ("Time2Retain is zero, setting no_tm\n"));
182 DEBC(conn, 1, ("Time2Wait=%d, hz=%d, waiting...\n",
195 DEBC(conn, 1, ("Reassign_tasks: S%dC%d -> S%dC%d, no_tm=%d, pdus old %d + new %d\n",
196 sess->s_id, oldconn->c_id, sess->s_id, conn->c_id, no_tm,
197 oldconn->c_pducount, conn->c_pducount));
203 if ((pdu = get_pdu(conn, TRUE)) == NULL) {
204 DEBC(conn, 0, ("get_pdu failed, terminating=%d\n", conn->c_terminating));
219 pdu->pdu_connection = conn;
225 if (conn->c_DataDigest && pdu->pdu_save_uio.uio_iovcnt > 1) {
235 (conn->c_HeaderDigest) ? BHS_SIZE + 4 : BHS_SIZE;
240 ccb->ccb_connection = conn;
244 DEBC(conn, 1, ("CCB %p: Copied PDU %p to %p\n",
253 mutex_enter(&conn->c_lock);
258 conn->c_usecount++;
264 mutex_exit(&conn->c_lock);
268 DEBC(conn, 0, ("Error while copying PDUs in reassign_tasks!\n"));
288 TAILQ_FOREACH(ccb, &conn->c_ccbs_waiting, ccb_chain) {
290 rc = send_task_management(conn, ccb, NULL, TASK_REASSIGN);
300 DEBC(conn, 1, ("Resend Updating CmdSN - old %d, new %d\n",
310 DEBC(conn, 1, ("Reassign ccb %p, no_tm=%d, rc=%d\n",
328 connection_t *conn = (connection_t *) par;
335 sess = conn->c_session;
340 mutex_enter(&conn->c_lock);
341 while (!conn->c_terminating) {
342 while (!conn->c_terminating &&
343 (pdu = TAILQ_FIRST(&conn->c_pdus_to_send)) != NULL) {
344 TAILQ_REMOVE(&conn->c_pdus_to_send, pdu, pdu_send_chain);
346 mutex_exit(&conn->c_lock);
350 pdu->pdu_hdr.pduh_p.command.ExpStatSN = htonl(conn->c_StatSN_buf.ExpSN);
352 if (conn->c_HeaderDigest)
355 DEBC(conn, 99, ("Transmitting PDU CmdSN = %u, ExpStatSN = %u\n",
358 my_soo_write(conn, &pdu->pdu_uio);
360 mutex_enter(&conn->c_lock);
364 mutex_exit(&conn->c_lock);
368 mutex_enter(&conn->c_lock);
371 if (!conn->c_terminating)
372 cv_wait(&conn->c_conn_cv, &conn->c_lock);
374 mutex_exit(&conn->c_lock);
380 connection_timeout_stop(conn);
381 conn->c_idle_timeout_val = CONNECTION_IDLE_TIMEOUT;
383 fp = conn->c_sock;
389 DEBC(conn, 1, ("Closing Socket %p\n", conn->c_sock));
395 TAILQ_FOREACH_SAFE(ccb, &conn->c_ccbs_waiting, ccb_chain, nccb) {
397 DEBC(conn, 1, ("Terminating CCB %p (t=%p)\n",
399 wake_ccb(ccb, conn->c_terminating);
407 mutex_enter(&conn->c_lock);
408 while ((pdu = TAILQ_FIRST(&conn->c_pdus_to_send)) != NULL) {
409 TAILQ_REMOVE(&conn->c_pdus_to_send, pdu, pdu_send_chain);
411 mutex_exit(&conn->c_lock);
417 mutex_enter(&conn->c_lock);
419 mutex_exit(&conn->c_lock);
423 TAILQ_FIRST(&conn->c_ccbs_waiting) != NULL) {
425 reassign_tasks(conn);
426 } else if (!conn->c_destroy && conn->c_Time2Wait) {
427 DEBC(conn, 1, ("Time2Wait\n"));
428 kpause("Time2Wait", false, conn->c_Time2Wait * hz, NULL);
429 DEBC(conn, 1, ("Time2Wait\n"));
432 DEBC(conn, 1, ("%s\n", conn->c_destroy ? "TERMINATED" : "RECOVER"));
433 add_event(conn->c_destroy ? ISCSI_CONNECTION_TERMINATED
435 sess->s_id, conn->c_id, conn->c_terminating);
437 DEBC(conn, 1, ("Waiting for conn_idle\n"));
438 mutex_enter(&conn->c_lock);
439 if (!conn->c_destroy)
440 cv_timedwait(&conn->c_idle_cv, &conn->c_lock, CONNECTION_IDLE_TIMEOUT);
441 mutex_exit(&conn->c_lock);
442 DEBC(conn, 1, ("Waited for conn_idle, destroy = %d\n", conn->c_destroy));
444 } while (!conn->c_destroy);
447 mutex_enter(&conn->c_lock);
448 cv_broadcast(&conn->c_conn_cv);
449 mutex_exit(&conn->c_lock);
452 while ((ccb = TAILQ_FIRST(&conn->c_ccbs_waiting)) != NULL) {
454 wake_ccb(ccb, conn->c_terminating);
458 add_connection_cleanup(conn);
460 conn->c_sendproc = NULL;
461 DEBC(conn, 1, ("Send thread exits\n"));
483 connection_t *conn = pdu->pdu_connection;
496 DEBC(conn, 10, ("Send_pdu: CmdSN=%u ExpStatSN~%u ccb=%p, pdu=%p\n",
498 conn->c_StatSN_buf.ExpSN,
501 mutex_enter(&conn->c_lock);
517 TAILQ_INSERT_HEAD(&conn->c_pdus_to_send, pdu, pdu_send_chain);
519 TAILQ_INSERT_TAIL(&conn->c_pdus_to_send, pdu, pdu_send_chain);
521 cv_broadcast(&conn->c_conn_cv);
525 KASSERTMSG(ccb->ccb_connection == conn, "conn mismatch %p != %p\n", ccb->ccb_connection, conn);
530 mutex_exit(&conn->c_lock);
532 mutex_enter(&conn->c_lock);
535 DEBC(conn, 15, ("Send_pdu: ccb=%p cdisp=%d waiting\n",
537 cv_wait(&conn->c_ccb_cv, &conn->c_lock);
538 DEBC(conn, 15, ("Send_pdu: ccb=%p cdisp=%d returned\n",
543 mutex_exit(&conn->c_lock);
558 connection_t *conn = ccb->ccb_connection;
561 mutex_enter(&conn->c_lock);
563 mutex_exit(&conn->c_lock);
567 mutex_exit(&conn->c_lock);
573 DEBC(conn, 8, ("ReSend_pdu: CmdSN=%u ExpStatSN~%u ccb=%p, pdu=%p\n",
575 conn
578 mutex_enter(&conn->c_lock);
583 TAILQ_INSERT_HEAD(&conn->c_pdus_to_send, pdu, pdu_send_chain);
585 TAILQ_INSERT_TAIL(&conn->c_pdus_to_send, pdu, pdu_send_chain);
587 cv_broadcast(&conn->c_conn_cv);
588 mutex_exit(&conn->c_lock);
613 connection_t *conn = pdu->pdu_connection;
621 hlen = (conn->c_HeaderDigest) ? BHS_SIZE + 4 : BHS_SIZE;
650 if (conn->c_DataDigest) {
665 * conn The connection
671 init_login_pdu(connection_t *conn, ccb_t *ccb, pdu_t *ppdu, bool next)
679 mutex_enter(&conn->c_session->s_lock);
680 ccb->ccb_CmdSN = get_sernum(conn->c_session, ppdu);
681 mutex_exit(&conn->c_session->s_lock);
695 isid->TSIH = conn->c_session->s_TSIH;
697 hpdu->pduh_p.login_req.CID = htons(conn->c_id);
707 * conn The connection
713 negotiate_login(connection_t *conn, pdu_t *rx_pdu, ccb_t *tx_ccb)
729 session_t *sess = conn->c_session;
735 assemble_negotiation_parameters(conn, tx_ccb, rx_pdu, NULL);
740 DEBC(conn, 5, ("Login Successful!\n"));
745 tx_pdu = get_pdu(conn, TRUE);
753 rc = assemble_security_parameters(conn, tx_ccb, rx_pdu, tx_pdu);
760 if (conn->c_state == ST_SEC_FIN) {
768 rc = assemble_security_parameters(conn, tx_ccb, rx_pdu, tx_pdu);
780 rc = assemble_negotiation_parameters(conn, tx_ccb, rx_pdu, tx_pdu);
793 init_login_pdu(conn, tx_ccb, tx_pdu, next);
805 * conn The connection
812 init_text_pdu(connection_t *conn, ccb_t *ccb, pdu_t *ppdu, pdu_t *rx_pdu)
819 mutex_enter(&conn->c_session->s_lock);
820 ccb->ccb_CmdSN = get_sernum(conn->c_session, ppdu);
821 mutex_exit(&conn->c_session->s_lock);
839 * conn The connection
845 acknowledge_text(connection_t *conn, pdu_t *rx_pdu, ccb_t *tx_ccb)
849 tx_pdu = get_pdu(conn, TRUE);
855 init_login_pdu(conn, tx_ccb, tx_pdu, FALSE);
857 init_text_pdu(conn, tx_ccb, tx_pdu, rx_pdu);
869 * conn The connection
873 start_text_negotiation(connection_t *conn)
878 ccb = get_ccb(conn, TRUE);
881 pdu = get_pdu(conn, TRUE);
887 if (init_text_parameters(conn, ccb)) {
893 init_text_pdu(conn, ccb, pdu, NULL);
904 * conn The connection
910 negotiate_text(connection_t *conn, pdu_t *rx_pdu, ccb_t *tx_ccb)
917 handle_connection_error(conn, ISCSI_STATUS_PROTOCOL_ERROR,
928 tx_pdu = get_pdu(conn, TRUE);
932 rc = assemble_negotiation_parameters(conn, tx_ccb, rx_pdu, tx_pdu);
937 handle_connection_error(conn, rc, LOGOUT_CONNECTION);
939 init_text_pdu(conn, tx_ccb, tx_pdu, rx_pdu);
969 connection_t *conn;
973 conn = assign_connection(sess, TRUE);
974 if (conn == NULL || conn->c_terminating || conn->c_state != ST_FULL_FEATURE)
975 return (conn != NULL && conn->c_terminating) ? conn->c_terminating
978 ccb = get_ccb(conn, TRUE);
980 return conn->c_terminating;
981 pdu = get_pdu(conn, TRUE);
984 return conn->c_terminating;
995 init_text_pdu(conn, ccb, pdu, NULL);
1017 * conn The connection
1024 send_nop_out(connection_t *conn, pdu_t *rx_pdu)
1034 ppdu = get_pdu(conn, TRUE);
1038 ccb = get_ccb(conn, FALSE);
1043 ppdu = get_pdu(conn, FALSE);
1055 sess = conn->c_session;
1074 DEBC(conn, 10, ("Send NOP_Out CmdSN=%d, rx_pdu=%p\n", sn, rx_pdu));
1088 * conn The connection
1096 snack_missing(connection_t *conn, ccb_t *ccb, uint8_t type,
1102 ppdu = get_pdu(conn, TRUE);
1126 * conn The connection
1135 send_snack(connection_t *conn, pdu_t *rx_pdu, ccb_t *tx_ccb, uint8_t type)
1140 ppdu = get_pdu(conn, TRUE);
1189 * conn The connection
1196 send_login(connection_t *conn)
1202 DEBC(conn, 9, ("Send_login\n"));
1203 ccb = get_ccb(conn, TRUE);
1206 return conn->c_terminating;
1207 pdu = get_pdu(conn, TRUE);
1210 return conn->c_terminating;
1213 if ((rc = assemble_login_parameters(conn, ccb, pdu)) <= 0) {
1214 init_login_pdu(conn, ccb, pdu, !rc);
1232 * conn The connection
1241 send_logout(connection_t *conn, connection_t *refconn, int reason,
1248 DEBC(conn, 5, ("Send_logout\n"));
1249 ccb = get_ccb(conn, TRUE);
1252 return conn->c_terminating;
1253 ppdu = get_pdu(conn, TRUE);
1256 return conn->c_terminating;
1263 ccb->ccb_CmdSN = conn->c_session->s_CmdSN;
1269 if (refconn != conn) {
1272 conn->c_state = ST_LOGOUT_SENT;
1273 conn->c_loggedout = LOGOUT_SENT;
1293 * conn The connection
1302 send_task_management(connection_t *conn, ccb_t *ref_ccb, struct scsipi_xfer *xs,
1309 DEBC(conn, 5, ("Send_task_management, ref_ccb=%p, func = %d\n",
1312 if (function == TASK_REASSIGN && conn->c_session->s_ErrorRecoveryLevel < 2)
1315 ccb = get_ccb(conn, xs == NULL);
1318 DEBC(conn, 0, ("send_task_management, ref_ccb=%p, xs=%p, term=%d. No CCB\n",
1319 ref_ccb, xs, conn->c_terminating));
1320 return conn->c_terminating;
1322 ppdu = get_pdu(conn, xs == NULL);
1324 DEBC(conn, 0, ("send_task_management, ref_ccb=%p, xs=%p, term=%d. No PDU\n",
1325 ref_ccb, xs, conn->c_terminating));
1327 return conn->c_terminating;
1336 ccb->ccb_CmdSN = conn->c_session->s_CmdSN;
1365 * conn The connection
1372 send_data_out(connection_t *conn, pdu_t *rx_pdu, ccb_t *tx_ccb,
1379 KASSERT(conn->c_max_transfer != 0);
1385 offs = conn->c_max_firstimmed;
1386 totlen = min(conn->c_max_firstdata - offs, tx_ccb->ccb_data_len - offs);
1391 len = min(totlen, conn->c_max_transfer);
1393 tx_pdu = get_pdu(conn, waitok);
1395 DEBC(conn, 5, ("No PDU in send_data_out\n"));
1399 handle_connection_error(conn, ISCSI_STATUS_NO_RESOURCES, NO_LOGOUT);
1418 DEBC(conn, 10, ("Send DataOut: DataSN %d, len %d offs %x totlen %d\n",
1444 connection_t *conn = ccb->ccb_connection;
1459 if (conn->c_state != ST_FULL_FEATURE) {
1466 ppdu = get_pdu(conn, waitok);
1491 len = min(totlen, conn->c_max_firstimmed);
1494 totlen = conn->c_max_firstdata ? totlen - len : 0;
1515 DEBC(conn, 10, ("Send Command: CmdSN %d (%d), data_in %d, len %d, totlen %d\n",
1522 send_data_out(conn, NULL, ccb, disp, waitok);
1539 connection_t *conn;
1548 conn = assign_connection(session, waitok);
1550 if (conn == NULL || conn->c_terminating || conn->c_state != ST_FULL_FEATURE) {
1555 DEBC(conn, 10, ("run_xfer on dead connection\n"));
1562 if (send_task_management(conn, NULL, xs, TARGET_WARM_RESET)) {
1563 DEBC(conn, 0, ("send_task_management TARGET_WARM_RESET failed\n"));
1571 ccb = get_ccb(conn, waitok);
1574 DEBC(conn, 5, ("No CCB in run_xfer, %d in use.\n", conn->c_usecount));
1637 connection_t *conn;
1643 conn = (conn_id) ? find_connection(session, conn_id)
1646 if (conn == NULL || conn->c_terminating || conn->c_state != ST_FULL_FEATURE) {
1648 (conn != NULL) ? conn->c_state : -1));
1652 ccb = get_ccb(conn, TRUE);
1668 DEBC(conn, 10, ("IoCommand: cmd[1] = %x, cmdlen = %d\n",
1696 * conn The connection
1700 connection_timeout(connection_t *conn)
1702 if (++conn->c_num_timeouts > MAX_CONN_TIMEOUTS) {
1703 DEBC(conn, 1, ("connection timeout %d\n", conn->c_num_timeouts));
1704 handle_connection_error(conn, ISCSI_STATUS_TIMEOUT, NO_LOGOUT);
1706 if (conn->c_state == ST_FULL_FEATURE)
1707 send_nop_out(conn, NULL);
1709 connection_timeout_start(conn, CONNECTION_TIMEOUT);
1724 connection_t *conn = ccb->ccb_connection;
1726 if (conn == NULL) {
1736 DEBC(conn, 0, ("ccb_timeout: num=%d total=%d disp=%d\n",
1745 handle_connection_error(conn,
1750 snack_missing(conn, ccb, SNACK_DATA_NAK, 0, 0);
1753 snack_missing(conn, NULL, SNACK_STATUS_NAK, 0, 0);