Print this page
XXXX introduce drv_sectohz


 742         if (sc->req_ptr == NULL) {
 743                 goto alarm_return;
 744         }
 745 
 746         req_ptr = sc->req_ptr;
 747 
 748         req_ptr->alarm_action = PCP_ALARM_STATUS;
 749         req_ptr->alarm_id = alarm_type;
 750 
 751         send_msg.msg_type = PCP_ALARM_CONTROL;
 752         send_msg.sub_type = NULL;
 753         send_msg.msg_len = sizeof (tsal_pcp_alarm_req_t);
 754         send_msg.msg_data = (uint8_t *)req_ptr;
 755 
 756         /*
 757          * send the request, receive the response
 758          */
 759         if (tsal_pcp_send_recv(sc, &send_msg, &recv_msg,
 760             PCP_COMM_TIMEOUT) < 0) {
 761                 /* we either timed out or erred; either way try again */
 762                 (void) delay(PCP_COMM_TIMEOUT * drv_usectohz(1000000));
 763 
 764                 if (tsal_pcp_send_recv(sc, &send_msg, &recv_msg,
 765                     PCP_COMM_TIMEOUT) < 0) {
 766                         cmn_err(CE_WARN, "tsalarm: communication failure");
 767                         goto alarm_return;
 768                 }
 769         }
 770 
 771         /*
 772          * validate that this data was meant for us
 773          */
 774         if (recv_msg.msg_type != PCP_ALARM_CONTROL_R) {
 775                 cmn_err(CE_WARN, "tsalarm: unbound packet received");
 776                 goto alarm_return;
 777         }
 778 
 779         /*
 780          * verify that the Alarm action has taken place
 781          */
 782         resp_ptr = (tsal_pcp_alarm_resp_t *)recv_msg.msg_data;


 817         req_ptr = sc->req_ptr;
 818 
 819         if (new_state == ALARM_ON)
 820                 req_ptr->alarm_action = PCP_ALARM_ENABLE;
 821         else if (new_state == ALARM_OFF)
 822                 req_ptr->alarm_action = PCP_ALARM_DISABLE;
 823 
 824         req_ptr->alarm_id = alarm_type;
 825 
 826         send_msg.msg_type = PCP_ALARM_CONTROL;
 827         send_msg.sub_type = NULL;
 828         send_msg.msg_len = sizeof (tsal_pcp_alarm_req_t);
 829         send_msg.msg_data = (uint8_t *)req_ptr;
 830 
 831         /*
 832          * send the request, receive the response
 833          */
 834         if (tsal_pcp_send_recv(sc, &send_msg, &recv_msg,
 835             PCP_COMM_TIMEOUT) < 0) {
 836                 /* we either timed out or erred; either way try again */
 837                 (void) delay(PCP_COMM_TIMEOUT * drv_usectohz(1000000));
 838 
 839                 if (tsal_pcp_send_recv(sc, &send_msg, &recv_msg,
 840                     PCP_COMM_TIMEOUT) < 0) {
 841                         goto alarm_return;
 842                 }
 843         }
 844 
 845         /*
 846          * validate that this data was meant for us
 847          */
 848         if (recv_msg.msg_type != PCP_ALARM_CONTROL_R) {
 849                 cmn_err(CE_WARN, "tsalarm: unbound packet received");
 850                 goto alarm_return;
 851         }
 852 
 853         /*
 854          * verify that the Alarm action has taken place
 855          */
 856         resp_ptr = (tsal_pcp_alarm_resp_t *)recv_msg.msg_data;
 857         if (resp_ptr->status == PCP_ALARM_ERROR) {


1076                 default:
1077                         return (TSAL_PCP_ERROR);
1078         }
1079 
1080         /*
1081          * loop until all I/O done, try limit exceded, or real failure
1082          */
1083 
1084         rv = 0;
1085         datap = buf;
1086         while (rv < byte_cnt) {
1087                 io_sz = MIN((byte_cnt - rv), sc->mtu_size);
1088                 try_cnt = 0;
1089                 while ((n = (*func_ptr)(sc, datap, io_sz)) < 0) {
1090                         try_cnt++;
1091                         if (try_cnt > PCP_MAX_TRY_CNT) {
1092                                 rv = n;
1093                                 goto done;
1094                         }
1095                         /* waiting 5 secs. Do we need 5 Secs? */
1096                         (void) delay(PCP_GLVC_SLEEP * drv_usectohz(1000000));
1097                 } /* while trying the io operation */
1098 
1099                 if (n < 0) {
1100                         rv = n;
1101                         goto done;
1102                 }
1103                 rv += n;
1104                 datap += n;
1105         } /* while still have more data */
1106 
1107 done:
1108         if (rv == byte_cnt)
1109                 return (0);
1110         else
1111                 return (TSAL_PCP_ERROR);
1112 }
1113 
1114 /*
1115  * For peeking 'bytes_cnt' bytes in channel (glvc) buffers.
1116  * If data is available, the data is copied into 'buf'.




 742         if (sc->req_ptr == NULL) {
 743                 goto alarm_return;
 744         }
 745 
 746         req_ptr = sc->req_ptr;
 747 
 748         req_ptr->alarm_action = PCP_ALARM_STATUS;
 749         req_ptr->alarm_id = alarm_type;
 750 
 751         send_msg.msg_type = PCP_ALARM_CONTROL;
 752         send_msg.sub_type = NULL;
 753         send_msg.msg_len = sizeof (tsal_pcp_alarm_req_t);
 754         send_msg.msg_data = (uint8_t *)req_ptr;
 755 
 756         /*
 757          * send the request, receive the response
 758          */
 759         if (tsal_pcp_send_recv(sc, &send_msg, &recv_msg,
 760             PCP_COMM_TIMEOUT) < 0) {
 761                 /* we either timed out or erred; either way try again */
 762                 (void) delay(drv_sectohz(PCP_COMM_TIMEOUT));
 763 
 764                 if (tsal_pcp_send_recv(sc, &send_msg, &recv_msg,
 765                     PCP_COMM_TIMEOUT) < 0) {
 766                         cmn_err(CE_WARN, "tsalarm: communication failure");
 767                         goto alarm_return;
 768                 }
 769         }
 770 
 771         /*
 772          * validate that this data was meant for us
 773          */
 774         if (recv_msg.msg_type != PCP_ALARM_CONTROL_R) {
 775                 cmn_err(CE_WARN, "tsalarm: unbound packet received");
 776                 goto alarm_return;
 777         }
 778 
 779         /*
 780          * verify that the Alarm action has taken place
 781          */
 782         resp_ptr = (tsal_pcp_alarm_resp_t *)recv_msg.msg_data;


 817         req_ptr = sc->req_ptr;
 818 
 819         if (new_state == ALARM_ON)
 820                 req_ptr->alarm_action = PCP_ALARM_ENABLE;
 821         else if (new_state == ALARM_OFF)
 822                 req_ptr->alarm_action = PCP_ALARM_DISABLE;
 823 
 824         req_ptr->alarm_id = alarm_type;
 825 
 826         send_msg.msg_type = PCP_ALARM_CONTROL;
 827         send_msg.sub_type = NULL;
 828         send_msg.msg_len = sizeof (tsal_pcp_alarm_req_t);
 829         send_msg.msg_data = (uint8_t *)req_ptr;
 830 
 831         /*
 832          * send the request, receive the response
 833          */
 834         if (tsal_pcp_send_recv(sc, &send_msg, &recv_msg,
 835             PCP_COMM_TIMEOUT) < 0) {
 836                 /* we either timed out or erred; either way try again */
 837                 (void) delay(drv_sectohz(PCP_COMM_TIMEOUT));
 838 
 839                 if (tsal_pcp_send_recv(sc, &send_msg, &recv_msg,
 840                     PCP_COMM_TIMEOUT) < 0) {
 841                         goto alarm_return;
 842                 }
 843         }
 844 
 845         /*
 846          * validate that this data was meant for us
 847          */
 848         if (recv_msg.msg_type != PCP_ALARM_CONTROL_R) {
 849                 cmn_err(CE_WARN, "tsalarm: unbound packet received");
 850                 goto alarm_return;
 851         }
 852 
 853         /*
 854          * verify that the Alarm action has taken place
 855          */
 856         resp_ptr = (tsal_pcp_alarm_resp_t *)recv_msg.msg_data;
 857         if (resp_ptr->status == PCP_ALARM_ERROR) {


1076                 default:
1077                         return (TSAL_PCP_ERROR);
1078         }
1079 
1080         /*
1081          * loop until all I/O done, try limit exceded, or real failure
1082          */
1083 
1084         rv = 0;
1085         datap = buf;
1086         while (rv < byte_cnt) {
1087                 io_sz = MIN((byte_cnt - rv), sc->mtu_size);
1088                 try_cnt = 0;
1089                 while ((n = (*func_ptr)(sc, datap, io_sz)) < 0) {
1090                         try_cnt++;
1091                         if (try_cnt > PCP_MAX_TRY_CNT) {
1092                                 rv = n;
1093                                 goto done;
1094                         }
1095                         /* waiting 5 secs. Do we need 5 Secs? */
1096                         (void) delay(drv_sectohz(PCP_GLVC_SLEEP));
1097                 } /* while trying the io operation */
1098 
1099                 if (n < 0) {
1100                         rv = n;
1101                         goto done;
1102                 }
1103                 rv += n;
1104                 datap += n;
1105         } /* while still have more data */
1106 
1107 done:
1108         if (rv == byte_cnt)
1109                 return (0);
1110         else
1111                 return (TSAL_PCP_ERROR);
1112 }
1113 
1114 /*
1115  * For peeking 'bytes_cnt' bytes in channel (glvc) buffers.
1116  * If data is available, the data is copied into 'buf'.