755
756 /* Free the session */
757 static void
758 rds_destroy_session(rds_session_t *sp)
759 {
760 rds_ep_t *ep;
761 rds_bufpool_t *pool;
762
763 ASSERT((sp->session_state == RDS_SESSION_STATE_CLOSED) ||
764 (sp->session_state == RDS_SESSION_STATE_FAILED) ||
765 (sp->session_state == RDS_SESSION_STATE_FINI) ||
766 (sp->session_state == RDS_SESSION_STATE_PASSIVE_CLOSING));
767
768 rw_enter(&sp->session_lock, RW_READER);
769 RDS_DPRINTF2("rds_destroy_session", "SP(%p) State: %d", sp,
770 sp->session_state);
771 while (!((sp->session_state == RDS_SESSION_STATE_CLOSED) ||
772 (sp->session_state == RDS_SESSION_STATE_FAILED) ||
773 (sp->session_state == RDS_SESSION_STATE_FINI))) {
774 rw_exit(&sp->session_lock);
775 delay(drv_usectohz(1000000));
776 rw_enter(&sp->session_lock, RW_READER);
777 RDS_DPRINTF2("rds_destroy_session", "SP(%p) State: %d WAITING "
778 "ON SESSION", sp, sp->session_state);
779 }
780 rw_exit(&sp->session_lock);
781
782 /* data channel */
783 ep = &sp->session_dataep;
784
785 /* send pool locks */
786 pool = &ep->ep_sndpool;
787 cv_destroy(&pool->pool_cv);
788 mutex_destroy(&pool->pool_lock);
789
790 /* recv pool locks */
791 pool = &ep->ep_rcvpool;
792 cv_destroy(&pool->pool_cv);
793 mutex_destroy(&pool->pool_lock);
794 mutex_destroy(&ep->ep_recvqp.qp_lock);
795
846 * a re-connect.
847 */
848 RDS_DPRINTF2("rds_failover_session",
849 "SP(%p) has become passive", sp);
850 rw_exit(&sp->session_lock);
851 return;
852 }
853 sp->session_failover = 1;
854 sp_state = sp->session_state;
855 rw_exit(&sp->session_lock);
856
857 /*
858 * The session is in ERROR state but close both channels
859 * for a clean start.
860 */
861 if (sp_state == RDS_SESSION_STATE_ERROR) {
862 rds_session_close(sp, IBT_BLOCKING, 1);
863 }
864
865 /* wait 1 sec before re-connecting */
866 delay(drv_usectohz(1000000));
867
868 do {
869 ibt_ip_path_attr_t ipattr;
870 ibt_ip_addr_t dstip;
871
872 /* The ipaddr should be in the network order */
873 myip = sp->session_myip;
874 remip = sp->session_remip;
875 ret = rds_sc_path_lookup(&myip, &remip);
876 if (ret == 0) {
877 RDS_DPRINTF2(LABEL, "Path not found (0x%x 0x%x)",
878 myip, remip);
879 }
880 /* check if we have (new) path from the source to destination */
881 lgid.gid_prefix = 0;
882 lgid.gid_guid = 0;
883 rgid.gid_prefix = 0;
884 rgid.gid_guid = 0;
885
886 bzero(&ipattr, sizeof (ibt_ip_path_attr_t));
890 ipattr.ipa_src_ip.family = AF_INET;
891 ipattr.ipa_src_ip.un.ip4addr = myip;
892 ipattr.ipa_ndst = 1;
893 ipattr.ipa_max_paths = 1;
894 RDS_DPRINTF2(LABEL, "ibt_get_ip_paths: 0x%x <-> 0x%x ",
895 myip, remip);
896 ret = ibt_get_ip_paths(rdsib_statep->rds_ibhdl,
897 IBT_PATH_NO_FLAGS, &ipattr, &sp->session_pinfo, NULL, NULL);
898 if (ret == IBT_SUCCESS) {
899 RDS_DPRINTF2(LABEL, "ibt_get_ip_paths success");
900 lgid = sp->session_pinfo.
901 pi_prim_cep_path.cep_adds_vect.av_sgid;
902 rgid = sp->session_pinfo.
903 pi_prim_cep_path.cep_adds_vect.av_dgid;
904 break;
905 }
906
907 RDS_DPRINTF2(LABEL, "ibt_get_ip_paths failed, ret: %d ", ret);
908
909 /* wait 1 sec before re-trying */
910 delay(drv_usectohz(1000000));
911 cnt++;
912 } while (cnt < 5);
913
914 if (ret != IBT_SUCCESS) {
915 rw_enter(&sp->session_lock, RW_WRITER);
916 if (sp->session_type == RDS_SESSION_ACTIVE) {
917 rds_session_fini(sp);
918 sp->session_state = RDS_SESSION_STATE_FAILED;
919 sp->session_failover = 0;
920 RDS_DPRINTF3("rds_failover_session",
921 "SP(%p) State RDS_SESSION_STATE_FAILED", sp);
922 } else {
923 RDS_DPRINTF2("rds_failover_session",
924 "SP(%p) has become passive", sp);
925 }
926 rw_exit(&sp->session_lock);
927 return;
928 }
929
930 RDS_DPRINTF2(LABEL, "lgid: %llx:%llx rgid: %llx:%llx",
1098
1099 /*
1100 * Can be called:
1101 * 1. on driver detach
1102 * 2. on taskq thread
1103 * arg is always NULL
1104 */
1105 /* ARGSUSED */
1106 void
1107 rds_close_sessions(void *arg)
1108 {
1109 rds_session_t *sp, *spnextp;
1110
1111 RDS_DPRINTF2("rds_close_sessions", "Enter");
1112
1113 /* wait until all the buffers are freed by the sockets */
1114 while (RDS_GET_RXPKTS_PEND() != 0) {
1115 /* wait one second and try again */
1116 RDS_DPRINTF2("rds_close_sessions", "waiting on "
1117 "pending packets", RDS_GET_RXPKTS_PEND());
1118 delay(drv_usectohz(1000000));
1119 }
1120 RDS_DPRINTF2("rds_close_sessions", "No more RX packets pending");
1121
1122 /* close all the sessions */
1123 rw_enter(&rdsib_statep->rds_sessionlock, RW_WRITER);
1124 sp = rdsib_statep->rds_sessionlistp;
1125 while (sp) {
1126 rw_enter(&sp->session_lock, RW_WRITER);
1127 RDS_DPRINTF2("rds_close_sessions", "SP(%p) State: %d", sp,
1128 sp->session_state);
1129 rds_close_this_session(sp, 2);
1130 rw_exit(&sp->session_lock);
1131 sp = sp->session_nextp;
1132 }
1133
1134 sp = rdsib_statep->rds_sessionlistp;
1135 rdsib_statep->rds_sessionlistp = NULL;
1136 rdsib_statep->rds_nsessions = 0;
1137 rw_exit(&rdsib_statep->rds_sessionlock);
1138
|
755
756 /* Free the session */
757 static void
758 rds_destroy_session(rds_session_t *sp)
759 {
760 rds_ep_t *ep;
761 rds_bufpool_t *pool;
762
763 ASSERT((sp->session_state == RDS_SESSION_STATE_CLOSED) ||
764 (sp->session_state == RDS_SESSION_STATE_FAILED) ||
765 (sp->session_state == RDS_SESSION_STATE_FINI) ||
766 (sp->session_state == RDS_SESSION_STATE_PASSIVE_CLOSING));
767
768 rw_enter(&sp->session_lock, RW_READER);
769 RDS_DPRINTF2("rds_destroy_session", "SP(%p) State: %d", sp,
770 sp->session_state);
771 while (!((sp->session_state == RDS_SESSION_STATE_CLOSED) ||
772 (sp->session_state == RDS_SESSION_STATE_FAILED) ||
773 (sp->session_state == RDS_SESSION_STATE_FINI))) {
774 rw_exit(&sp->session_lock);
775 delay(drv_sectohz(1));
776 rw_enter(&sp->session_lock, RW_READER);
777 RDS_DPRINTF2("rds_destroy_session", "SP(%p) State: %d WAITING "
778 "ON SESSION", sp, sp->session_state);
779 }
780 rw_exit(&sp->session_lock);
781
782 /* data channel */
783 ep = &sp->session_dataep;
784
785 /* send pool locks */
786 pool = &ep->ep_sndpool;
787 cv_destroy(&pool->pool_cv);
788 mutex_destroy(&pool->pool_lock);
789
790 /* recv pool locks */
791 pool = &ep->ep_rcvpool;
792 cv_destroy(&pool->pool_cv);
793 mutex_destroy(&pool->pool_lock);
794 mutex_destroy(&ep->ep_recvqp.qp_lock);
795
846 * a re-connect.
847 */
848 RDS_DPRINTF2("rds_failover_session",
849 "SP(%p) has become passive", sp);
850 rw_exit(&sp->session_lock);
851 return;
852 }
853 sp->session_failover = 1;
854 sp_state = sp->session_state;
855 rw_exit(&sp->session_lock);
856
857 /*
858 * The session is in ERROR state but close both channels
859 * for a clean start.
860 */
861 if (sp_state == RDS_SESSION_STATE_ERROR) {
862 rds_session_close(sp, IBT_BLOCKING, 1);
863 }
864
865 /* wait 1 sec before re-connecting */
866 delay(drv_sectohz(1));
867
868 do {
869 ibt_ip_path_attr_t ipattr;
870 ibt_ip_addr_t dstip;
871
872 /* The ipaddr should be in the network order */
873 myip = sp->session_myip;
874 remip = sp->session_remip;
875 ret = rds_sc_path_lookup(&myip, &remip);
876 if (ret == 0) {
877 RDS_DPRINTF2(LABEL, "Path not found (0x%x 0x%x)",
878 myip, remip);
879 }
880 /* check if we have (new) path from the source to destination */
881 lgid.gid_prefix = 0;
882 lgid.gid_guid = 0;
883 rgid.gid_prefix = 0;
884 rgid.gid_guid = 0;
885
886 bzero(&ipattr, sizeof (ibt_ip_path_attr_t));
890 ipattr.ipa_src_ip.family = AF_INET;
891 ipattr.ipa_src_ip.un.ip4addr = myip;
892 ipattr.ipa_ndst = 1;
893 ipattr.ipa_max_paths = 1;
894 RDS_DPRINTF2(LABEL, "ibt_get_ip_paths: 0x%x <-> 0x%x ",
895 myip, remip);
896 ret = ibt_get_ip_paths(rdsib_statep->rds_ibhdl,
897 IBT_PATH_NO_FLAGS, &ipattr, &sp->session_pinfo, NULL, NULL);
898 if (ret == IBT_SUCCESS) {
899 RDS_DPRINTF2(LABEL, "ibt_get_ip_paths success");
900 lgid = sp->session_pinfo.
901 pi_prim_cep_path.cep_adds_vect.av_sgid;
902 rgid = sp->session_pinfo.
903 pi_prim_cep_path.cep_adds_vect.av_dgid;
904 break;
905 }
906
907 RDS_DPRINTF2(LABEL, "ibt_get_ip_paths failed, ret: %d ", ret);
908
909 /* wait 1 sec before re-trying */
910 delay(drv_sectohz(1));
911 cnt++;
912 } while (cnt < 5);
913
914 if (ret != IBT_SUCCESS) {
915 rw_enter(&sp->session_lock, RW_WRITER);
916 if (sp->session_type == RDS_SESSION_ACTIVE) {
917 rds_session_fini(sp);
918 sp->session_state = RDS_SESSION_STATE_FAILED;
919 sp->session_failover = 0;
920 RDS_DPRINTF3("rds_failover_session",
921 "SP(%p) State RDS_SESSION_STATE_FAILED", sp);
922 } else {
923 RDS_DPRINTF2("rds_failover_session",
924 "SP(%p) has become passive", sp);
925 }
926 rw_exit(&sp->session_lock);
927 return;
928 }
929
930 RDS_DPRINTF2(LABEL, "lgid: %llx:%llx rgid: %llx:%llx",
1098
1099 /*
1100 * Can be called:
1101 * 1. on driver detach
1102 * 2. on taskq thread
1103 * arg is always NULL
1104 */
1105 /* ARGSUSED */
1106 void
1107 rds_close_sessions(void *arg)
1108 {
1109 rds_session_t *sp, *spnextp;
1110
1111 RDS_DPRINTF2("rds_close_sessions", "Enter");
1112
1113 /* wait until all the buffers are freed by the sockets */
1114 while (RDS_GET_RXPKTS_PEND() != 0) {
1115 /* wait one second and try again */
1116 RDS_DPRINTF2("rds_close_sessions", "waiting on "
1117 "pending packets", RDS_GET_RXPKTS_PEND());
1118 delay(drv_sectohz(1));
1119 }
1120 RDS_DPRINTF2("rds_close_sessions", "No more RX packets pending");
1121
1122 /* close all the sessions */
1123 rw_enter(&rdsib_statep->rds_sessionlock, RW_WRITER);
1124 sp = rdsib_statep->rds_sessionlistp;
1125 while (sp) {
1126 rw_enter(&sp->session_lock, RW_WRITER);
1127 RDS_DPRINTF2("rds_close_sessions", "SP(%p) State: %d", sp,
1128 sp->session_state);
1129 rds_close_this_session(sp, 2);
1130 rw_exit(&sp->session_lock);
1131 sp = sp->session_nextp;
1132 }
1133
1134 sp = rdsib_statep->rds_sessionlistp;
1135 rdsib_statep->rds_sessionlistp = NULL;
1136 rdsib_statep->rds_nsessions = 0;
1137 rw_exit(&rdsib_statep->rds_sessionlock);
1138
|