Reviewed, Ack
Mathi.

> -----Original Message-----
> From: Alex Jones [mailto:ajo...@genband.com]
> Sent: Tuesday, November 24, 2015 8:59 PM
> To: Mathivanan Naickan Palanivelu
> Cc: opensaf-devel@lists.sourceforge.net
> Subject: [PATCH 1 of 1] plm: handle ATCA M7 state (communication lost)
> better [#1601]
> 
>  osaf/libs/common/plmsv/include/plms.h            |    2 +-
>  osaf/services/saf/plmsv/plms/hpi_intf/plms_hsm.c |  115
> ++++++++++++++++++++--
> osaf/services/saf/plmsv/plms/plms_he_pres_fsm.c  |  102
> +++++++++++++++++++-
>  osaf/services/saf/plmsv/plms/plms_proc.c         |    2 +-
>  4 files changed, 205 insertions(+), 16 deletions(-)
> 
> 
> If blade is removed from the chassis very quickly such that no hot swap event
> is sent by HPI (shelf manager puts the state to M7), PLM never sets
> "management lost" readiness state.
> 
> According to HPI-B.03.02-XTCA, RESOURCE event is used for transitions to
> and from M7. PLM does not currently handle a RESOURCE_FAILURE event,
> and so it doesn't set "management lost" readiness state in the above case.
> 
> Solution is to pass up the RESOURCE event, so that the HE state machine can
> set "management lost" readiness state.
> 
> diff --git a/osaf/libs/common/plmsv/include/plms.h
> b/osaf/libs/common/plmsv/include/plms.h
> --- a/osaf/libs/common/plmsv/include/plms.h
> +++ b/osaf/libs/common/plmsv/include/plms.h
> @@ -568,7 +568,7 @@ SaUint32T plms_he_deactivate(PLMS_ENTITY
> SaUint32T plms_he_reset(PLMS_ENTITY *,SaUint32T,SaUint32T,SaUint32T);
> SaUint32T plms_he_oos_to_np_process(PLMS_ENTITY *);  SaUint32T
> plms_he_insvc_to_np_process(PLMS_ENTITY *); -SaUint32T
> plms_hpi_hs_evt_process(PLMS_EVT *);
> +SaUint32T plms_hpi_evt_process(PLMS_EVT *);
> 
>  /* Function declaration from plms_plmc.c*/  SaUint32T
> plms_ee_unlock(PLMS_ENTITY *,SaUint32T,SaUint32T); diff --git
> a/osaf/services/saf/plmsv/plms/hpi_intf/plms_hsm.c
> b/osaf/services/saf/plmsv/plms/hpi_intf/plms_hsm.c
> --- a/osaf/services/saf/plmsv/plms/hpi_intf/plms_hsm.c
> +++ b/osaf/services/saf/plmsv/plms/hpi_intf/plms_hsm.c
> @@ -58,6 +58,8 @@ static SaUint32T hsm_send_hotswap_event(
>                                       SaHpiHsStateT hotswap_state,
>                                       SaHpiHsStateT prev_hotswap_state,
>                                       SaUint32T  retriev_idr_info);
> +static SaUint32T hsm_send_resource_event(const SaHpiRptEntryT
> *rpt_entry,
> +                                     const SaHpiEventT *event);
>  SaUint32T hsm_correct_length(SaHpiIdrFieldT *thisfield);  SaUint32T
> hsm_get_idr_info(SaHpiRptEntryT  *rpt_entry,
>                          PLMS_INV_DATA  *inv_data);
> @@ -538,7 +540,7 @@ static void *plms_hsm(void)
>                       if (event.EventType == SAHPI_ET_HOTSWAP) {
>                               state =
> event.EventDataUnion.HotSwapEvent.HotSwapState;
>                       }
> -                     else {
> +                     else if (event.EventType != SAHPI_ET_RESOURCE) {
>                               rc = saHpiHotSwapStateGet(cb-
> >session_id,rpt_entry.ResourceId,&state);
>                               if( SA_OK != rc )
>                               {
> @@ -585,17 +587,31 @@ static void *plms_hsm(void)
>                       continue;
> 
> 
> -             /* If it is a resource restore event( communication lost and
> -             got restored immediately ) ,retrieve the hotswap state after
> -             communication is restored */
> -             if (event.EventType == SAHPI_ET_RESOURCE){
> -
>       if(event.EventDataUnion.ResourceEvent.ResourceEventType
> -                             == SAHPI_RESE_RESOURCE_RESTORED){
> -                     hsm_send_hotswap_event(&rpt_entry,
> -                     hotswap_state_model, state,
> -
>       event.EventDataUnion.HotSwapEvent.PreviousHotSwapState,
> -                     retriev_idr_info);
> +             /* handle surprise extraction/reinsertion, etc */
> +             if (event.EventType == SAHPI_ET_RESOURCE) {
> +                     hsm_send_resource_event(&rpt_entry, &event);
> 
> +                     /*
> +                      * send a hotswap event if communication has been
> +                      * restored, with updated state
> +                      */
> +                     if
> (event.EventDataUnion.ResourceEvent.ResourceEventType
> +                             == SAHPI_RESE_RESOURCE_RESTORED)
> +                     {
> +                             rc = saHpiHotSwapStateGet(cb->session_id,
> +
>       rpt_entry.ResourceId,
> +                                                     &state);
> +
> +                             if (SA_OK != rc) {
> +
>       LOG_ER("HSM:saHpiHotSwapStateGet failed for res with state model
> as:%d and ret val:%d", hotswap_state_model,rc);
> +                                     continue;
> +                             }
> +
> +                             hsm_send_hotswap_event(&rpt_entry,
> +                                             hotswap_state_model,
> +                                             state,
> +                                             0,
> +                                             true);
>                       }
>               }
> 
> @@ -1036,6 +1052,83 @@ static SaUint32T hsm_send_hotswap_event(
>       TRACE_LEAVE();
>       return rc;
>  }
> +/*********************************************************
> **********//**
> + * @brief     Sends resource event to PLM main thread
> + *
> + *
> + * @param[in]        rpt_entry
> + * @param[in]   retriev_idr_info
> + *
> + * @return   NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE
> +*********************************************************
> **************
> +/ static SaUint32T hsm_send_resource_event(const SaHpiRptEntryT
> +*rpt_entry,
> +                                     const SaHpiEventT *event)
> +{
> +     PLMS_CB            *cb = plms_cb;
> +     PLMS_EVT           *plms_evt = NULL;
> +     PLMS_EVT_REQ       req_evt;
> +     SaHpiEntityPathT   entity_path;
> +     SaInt8T            *entity_path_str = NULL;
> +     SaUint32T          i, rc;
> +
> +     TRACE_ENTER();
> +
> +     if(NULL == rpt_entry){
> +             LOG_ER("Invalid rpt_entry");
> +             return NCSCC_RC_FAILURE;
> +     }
> +
> +     /* Get the entity path */
> +     memset(&entity_path, 0, sizeof(SaHpiEntityPathT));
> +     for( i=0;  i < SAHPI_MAX_ENTITY_PATH; i++ ) {
> +             entity_path.Entry[i] = rpt_entry->ResourceEntity.Entry[i];
> +
> +             /* Stop copying when we see SAHPI_ENT_ROOT */
> +             if (rpt_entry->ResourceEntity.Entry[i].EntityType ==
> +                     SAHPI_ENT_ROOT)
> +                     break;
> +     }
> +
> +     memset(&req_evt, 0, sizeof(PLMS_EVT_REQ));
> +
> +     req_evt.req_type = PLMS_HPI_EVT_T;
> +     req_evt.hpi_evt.sa_hpi_evt = *event;
> +
> +
> +     /* convert SaHpiEntityPathT to string format */
> +     rc = convert_entitypath_to_string(&entity_path,&entity_path_str);
> +     if(NCSCC_RC_FAILURE == rc){
> +             /* Log */
> +             return NCSCC_RC_FAILURE;
> +     }
> +     req_evt.hpi_evt.entity_path =  entity_path_str;
> +
> +     /* Copy entity key to req_evt*/
> +     memcpy(&req_evt.hpi_evt.epath_key, &entity_path,
> sizeof(entity_path));
> +
> +     plms_evt = (PLMS_EVT *)malloc(sizeof(PLMS_EVT));
> +     if(NULL == plms_evt){
> +             LOG_ER("Memory allocation failed ret:%s",strerror(errno));
> +             assert(0);
> +     }
> +     memset(plms_evt, 0, sizeof(PLMS_EVT));
> +     plms_evt->req_res = PLMS_REQ;
> +     plms_evt->req_evt = req_evt;
> +
> +     TRACE("Sending Resource_event for res:%u entity:%s  Type:%u \n",
> +             rpt_entry->ResourceId,
> +             entity_path_str,
> +             event-
> >EventDataUnion.ResourceEvent.ResourceEventType);
> +
> +     /*  post event to PLM mailbox */
> +     rc = m_NCS_IPC_SEND(&cb->mbx,(NCSCONTEXT)plms_evt,
> +                     MDS_SEND_PRIORITY_MEDIUM);
> +     if (rc != NCSCC_RC_SUCCESS)
> +                 LOG_ER("m_NCS_IPC_SEND failed error %u", rc);
> +
> +     TRACE_LEAVE();
> +     return rc;
> +}
> 
> 
> /**********************************************************
> *************
>   * @brief     This function retrieves Inventory Data  Record (IDR) for
> diff --git a/osaf/services/saf/plmsv/plms/plms_he_pres_fsm.c
> b/osaf/services/saf/plmsv/plms/plms_he_pres_fsm.c
> --- a/osaf/services/saf/plmsv/plms/plms_he_pres_fsm.c
> +++ b/osaf/services/saf/plmsv/plms/plms_he_pres_fsm.c
> @@ -68,6 +68,8 @@ static SaUint32T plms_inspending_mngt_fl  static
> SaUint32T plms_deact_resp_mngt_flag_clear(PLMS_ENTITY *);  static
> SaUint32T plms_act_resp_mngt_flag_clear(PLMS_ENTITY *);
> 
> +static SaUint32T plms_hpi_hs_evt_process(PLMS_EVT *); static SaUint32T
> +plms_hpi_resource_evt_process(PLMS_EVT *);
> 
> 
> /**********************************************************
> ********************
>  @brief               : Initializes the HE presence state FSM function 
> pointers.
> @@ -3057,8 +3059,34 @@ static SaUint32T plms_adm_cnxt_clean_up(
>       return ret_err;
>  }
> 
> /**********************************************************
> ********************
> -@brief               : Process HPI hot swap events. This function is called
> from the
> -             MBX. This function does the following things
> +@brief               : Process HPI events. This function is called from the
> MBX.
> +
> +@param[in]   : evt - PLMS_EVT representation of the HPI event.
> +
> +@return              : NCSCC_RC_FAILURE/NCSCC_RC_SUCCESS
> +*********************************************************
> **************
> +*******/ SaUint32T plms_hpi_evt_process(PLMS_EVT *evt) {
> +     SaUint32T rc = NCSCC_RC_FAILURE;
> +
> +     TRACE_ENTER();
> +
> +     if (evt->req_evt.hpi_evt.sa_hpi_evt.EventType ==
> SAHPI_ET_HOTSWAP)
> +             rc = plms_hpi_hs_evt_process(evt);
> +     else if (evt->req_evt.hpi_evt.sa_hpi_evt.EventType ==
> SAHPI_ET_RESOURCE)
> +             rc = plms_hpi_resource_evt_process(evt);
> +     else {
> +             LOG_ER("Unknown HPI event received: %i",
> +                     evt->req_evt.hpi_evt.sa_hpi_evt.EventType);
> +     }
> +
> +     TRACE_LEAVE();
> +
> +     return rc;
> +}
> +
> +/*********************************************************
> *********************
> +@brief               : Process HPI hot swap events. This function does the
> following things
>               1. If the HE is verified i.e. the transition is not from M0, 
> then
>               call the required FSM function.
>               2. If the HE is yet to be verified and the hot swap event is M2
> @@ -3075,7 +3103,7 @@ static SaUint32T plms_adm_cnxt_clean_up(
> 
>  @return              : NCSCC_RC_FAILURE/NCSCC_RC_SUCCESS
> 
> **********************************************************
> ********************/
> -SaUint32T plms_hpi_hs_evt_process(PLMS_EVT *evt)
> +static SaUint32T plms_hpi_hs_evt_process(PLMS_EVT *evt)
>  {
>       SaUint32T ret_err = NCSCC_RC_FAILURE;
>       PLMS_EPATH_TO_ENTITY_MAP_INFO *epath_to_ent; @@ -3293,6
> +3321,74 @@ SaUint32T plms_hpi_hs_evt_process(PLMS_E
>       TRACE_LEAVE2("Return Val: %d",ret_err);
>       return ret_err;
>  }
> +
> +/*********************************************************
> *********************
> +@brief               : Process HPI resource events. This function does the
> following things
> +             1. Handle SAHPI_RESE_RESOURCE_FAILURE event, and set
> management lost
> +             2. Handle SAHPI_RESE_RESOURCE_RESTORED, and clear
> management lost
> +
> +@param[in]   : evt - PLMS_EVT representation of the RESOURCE event.
> +
> +@return              : NCSCC_RC_FAILURE/NCSCC_RC_SUCCESS
> +*********************************************************
> **************
> +*******/ static SaUint32T plms_hpi_resource_evt_process(PLMS_EVT
> *evt)
> +{
> +     SaUint32T rc = NCSCC_RC_SUCCESS;
> +     PLMS_HPI_EVT *hpi_evt = &(evt->req_evt.hpi_evt);
> +
> +     TRACE_ENTER2("Entity: %s, resource type: %d",
> +             hpi_evt->entity_path,
> +             hpi_evt-
> >sa_hpi_evt.EventDataUnion.ResourceEvent.ResourceEventType);
> +
> +     do {
> +             PLMS_EPATH_TO_ENTITY_MAP_INFO *epath_to_ent;
> +             PLMS_ENTITY *ent;
> +             PLMS_CB *cb = plms_cb;
> +
> +             if (cb->ha_state == SA_AMF_HA_STANDBY) {
> +                     TRACE_LEAVE2("Ignoring the event as current role is
> standby");
> +                     break;
> +             }
> +
> +             epath_to_ent = (PLMS_EPATH_TO_ENTITY_MAP_INFO
> *)ncs_patricia_tree_get(
> +                                             &(cb-
> >epath_to_entity_map_info),
> +                                             (SaUint8T *)&(hpi_evt-
> >epath_key));
> +
> +             if (NULL == epath_to_ent) {
> +                     LOG_ER("Received RESOURCE event %i for unknown
> resource %s",
> +                             hpi_evt-
> >sa_hpi_evt.EventDataUnion.ResourceEvent.ResourceEventType,
> +                             hpi_evt->entity_path);
> +
> +                     break;
> +             }
> +
> +             ent = epath_to_ent->plms_entity;
> +
> +             if (hpi_evt-
> >sa_hpi_evt.EventDataUnion.ResourceEvent.ResourceEventType ==
> +                     SAHPI_RESE_RESOURCE_FAILURE)
> +             {
> +                     plms_readiness_flag_mark_unmark(ent,
> +
>       SA_PLM_RF_MANAGEMENT_LOST,
> +                                                     SA_TRUE,
> +                                                     NULL,
> +
>       SA_NTF_MANAGEMENT_OPERATION,
> +
>       SA_PLM_NTFID_STATE_CHANGE_ROOT);
> +             }
> +             else if (hpi_evt-
> >sa_hpi_evt.EventDataUnion.ResourceEvent.ResourceEventType ==
> +                     SAHPI_RESE_RESOURCE_RESTORED)
> +             {
> +                     plms_readiness_flag_mark_unmark(ent,
> +
>       SA_PLM_RF_MANAGEMENT_LOST,
> +                                                     SA_FALSE,
> +                                                     NULL,
> +
>       SA_NTF_MANAGEMENT_OPERATION,
> +
>       SA_PLM_NTFID_STATE_CHANGE_ROOT);
> +             }
> +     } while (false);
> +
> +     TRACE_LEAVE2("Return Val: %d", rc);
> +     return rc;
> +}
> 
> /**********************************************************
> ********************
>  @brief               : Verifies the HE.
>               1. Verifies configured entity paths against hpi published.
> diff --git a/osaf/services/saf/plmsv/plms/plms_proc.c
> b/osaf/services/saf/plmsv/plms/plms_proc.c
> --- a/osaf/services/saf/plmsv/plms/plms_proc.c
> +++ b/osaf/services/saf/plmsv/plms/plms_proc.c
> @@ -2144,7 +2144,7 @@ SaUint32T plms_process_event()
>                               plms_imm_adm_op_req_process(plm_evt);
>                               break;
>                       case PLMS_HPI_EVT_T:
> -                             plms_hpi_hs_evt_process(plm_evt);
> +                             plms_hpi_evt_process(plm_evt);
>                               break;
>                       case PLMS_AGENT_LIB_REQ_EVT_T:
>                               plms_process_agent_lib_req(plm_evt);
> 

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to