/* Wait for IPsec negotiation, then try to login the iSCSI session again. */
EFI_STATUS IScsiSessionReLogin(IN ISCSI_SESSION *Session)
/* Wait for IPsec negotiation, then try to login the iSCSI session again. */
EFI_STATUS IScsiSessionReLogin(IN ISCSI_SESSION *Session)
{
  EFI_STATUS  Status;
  EFI_STATUS  TimerStatus;
  EFI_EVENT   Timer;
  Status = gBS->CreateEvent (EVT_TIMER, TPL_CALLBACK, NULL, NULL, &Timer);
  if (EFI_ERROR (Status)) {
    return Status;
  }
  Status = gBS->SetTimer (
                  Timer,
                  TimerRelative,
                  ISCSI_WAIT_IPSEC_TIMEOUT
                  );
  if (EFI_ERROR (Status)) {
    gBS->CloseEvent (Timer);
    return Status;
  }
  do {
    TimerStatus = gBS->CheckEvent (Timer);
    if (!EFI_ERROR (TimerStatus)) {
      Status = IScsiSessionLogin (Session);
    }
  } while (TimerStatus == EFI_NOT_READY);
  gBS->CloseEvent (Timer);
  return Status;
}