Example #1
0
int
nrx_wxevent_threshold(const char *type_str, void *data, size_t len)
{
   we_vir_trig_data_t *p = (we_vir_trig_data_t *)data;
   struct net_device *dev = WiFiEngine_GetAdapter();

  DE_BUG_ON(len != sizeof(*p), "Size don't agree");

   switch(p->type) {
      case WE_TRIG_TYPE_IND:
         send_nrx_event(dev, "%s,id=%#x,value=%#x", type_str, p->trig_id, p->value);
         break;
      case WE_TRIG_TYPE_CANCEL:
         send_nrx_event(dev, "CANCEL,%s,id=%#x,reason=%#x", type_str, p->trig_id, p->reason);
         break;
      default: 
         panic("Unknown type");
         break;
   }

   return WIFI_ENGINE_SUCCESS;
}
Example #2
0
int
nrx_wxevent_mibtrig(void *data, size_t len)
{
   we_vir_trig_data_t *p = (we_vir_trig_data_t *)data;
   struct net_device *dev = WiFiEngine_GetAdapter();
   
   DE_BUG_ON(len != sizeof(*p), "Size don't agree");
   
   switch(p->type) {
      case WE_TRIG_TYPE_IND:
         nrx_wxevent_mibtrig_ind(dev, p->trig_id, p->value);
         break;
      case WE_TRIG_TYPE_CANCEL:
         nrx_wxevent_mibtrig_cancel(dev, p->trig_id, p->reason);
         break;
      default: 
         panic("Unknown type");
         break;
   }

   return WIFI_ENGINE_SUCCESS;
}
/*!
 * @brief Handles packet received when core dump is enabled.
 *
 * @param pkt Received packet.
 *
 * @return 
 * - Always returns WIFI_ENGINE_SUCCESS
 */
void WiFiEngine_HandleCoreDumpPkt(char* pkt)
{
   size_t size;
   unsigned char *msg =  NULL;
   
   if (!WES_TEST_FLAG(WES_FLAG_HW_PRESENT)) 
      return;
   
   switch(core_dump_state)
   {
      case W4_SCB_ERROR_CFM:
      {
         unsigned char tx_desc[TX_DESC_SIZE];
         hic_message_context_t msg_ref;
         uint8_t  messageId;
         uint8_t  messageType;
         Blob_t blob;
         Mlme_CreateMessageContext(msg_ref);

         INIT_BLOB(&blob, pkt, 1500); /* XXX */
         /* Remove HIC header and add type/id info to msg_ref */
         packer_HIC_Unpack(&msg_ref, &blob); 
         messageId = msg_ref.msg_id;
         messageType = msg_ref.msg_type;
         msg_ref.packed = NULL;
         Mlme_ReleaseMessageContext(msg_ref);

         if((messageType == HIC_MESSAGE_TYPE_CTRL) && (messageId == HIC_CTRL_SCB_ERROR_CFM))
            {
               /* Handle confirm message */         
               if(handleSCBErrorCfm(pkt) == 0) 
               {

                  /* SCB_ERROR_CFM has error code 0, this means that firmware.
                   * is executing "normally" (no scb error has occured).
                   * However a command timeout has occured so it would be nice
                   * to force firmware in scb error and try to get a core dump.
                   */
                  DE_TRACE_STATIC(TR_ALWAYS,"Cancel timer\n");
                  DriverEnvironment_CancelTimer(wifiEngineState.cmd_timer_id);
                  DE_TRACE_STATIC(TR_ALWAYS,"Suicide requested\n");  
                  sendCommitSuicideRequest();
                  wifiEngineState.core_dump_state = WEI_CORE_DUMP_DISABLED;
                  return;
               }


            if(m_ext_ctx) 
            {
               /* Coredump already started */
               DriverEnvironment_Core_Dump_Abort(
                                          registry.network.basic.enableCoredump, 
                                          registry.network.basic.restartTargetAfterCoredump,
                                          m_objId,
                                          m_errCode, 
                                          &m_ext_ctx);
            } 
            else 
            {
               DriverEnvironment_indicate(WE_IND_CORE_DUMP_START, NULL, 0);
            }
            DriverEnvironment_Core_Dump_Started(
                                          registry.network.basic.enableCoredump, 
                                          registry.network.basic.restartTargetAfterCoredump,
                                          m_objId,
                                          m_errCode, 
                                          dump_total_size(dump_address_table),
                                          dump_total_size(dump_address_table),
                                          &m_ext_ctx);

            /* Turn off traces */
            //trace_mask &= ~(TR_CMD | TR_NOISE | TR_PS | TR_HIGH_RES | TR_DATA );
            trace_mask = 0;

            DriverEnvironment_Enable_Boot();

            /* This is to prevent command timeout logic to re-start the timer */
            WES_SET_FLAG(WES_FLAG_CMD_TIMEOUT_RUNNING);

            /* Initiate physical bm-descriptor to point to tx-descriptors */
            createDataReq_u32(&msg, StartDescriptorAddress, 
                              StartTxBmDesc + OFFSET_TO_POINTER_BM_DESC, &size);
            /* Clear any pending flags and flush queue*/
            wifiEngineState.cmdReplyPending = 0;
            wei_clear_cmd_queue();
            
            wei_send_cmd_raw((char *)msg, size);

            /* Initiate targets tx-descriptor to be used */
            createTxDescriptor(tx_desc);
            createDataReq(&msg, tx_desc, sizeof(tx_desc),
                          StartDescriptorAddress, &size);
            /* Clear any pending flags and flush queue*/
            wifiEngineState.cmdReplyPending = 0;
            wei_clear_cmd_queue();
            wei_send_cmd_raw((char *)msg, size);

            core_dump_state = W4_MEMORY_DUMP;
            /*
             * if m_ext_ctx==NULL we are not interested in the coredump and can restart the target directly
             * Not sure of how to do this in a safe way so will go ahead with the coredump anyway for now and fix this later 
             */
            if(m_ext_ctx==NULL) { 
               trace_mask = old_trace_mask; 
               DriverEnvironment_Core_Dump_Complete(
                                                FALSE,
                                                registry.network.basic.restartTargetAfterCoredump,
                                                m_objId,
                                                m_errCode, 
                                                &m_ext_ctx);
               DriverEnvironment_indicate(WE_IND_CORE_DUMP_COMPLETE, NULL, 0);
               DriverEnvironment_CancelTimer(wifiEngineState.cmd_timer_id);
               WES_CLEAR_FLAG(WES_FLAG_CMD_TIMEOUT_RUNNING);
               return;
            }

            currentRegion = dump_address_table;
            currentAddress = dump_region_start(currentRegion);

            getNextBlock(currentAddress);
         }
         else
         {
            DE_TRACE_INT2(TR_ALWAYS, "unexpected message %u.%u\n",
                          messageType,
                          messageId); 
         }
      }
      break;

      case W4_MEMORY_DUMP:
      {
         uint32_t len;
         /* Store recevied packet in a file */
         
         len = HIC_MESSAGE_LENGTH_GET(pkt);
         /* Move beyond size */ 
         pkt += 2;
         len -= 2;
         
         /* Write dumpfile header (for nrx600 coredumps) */
         if (dump_address_table == dump_address_table_nrx600
             && m_ext_ctx
             && currentAddress == dump_region_start(currentRegion)) {
            DriverEnvironment_Core_Dump_Write(m_ext_ctx, 
                                              (char *)currentRegion, 
                                              sizeof(*currentRegion));
         }
         
         len = DE_MIN(len, dump_region_end(currentRegion) - currentAddress);
         /* Copy to buffer */
         if (m_ext_ctx) {
            DriverEnvironment_Core_Dump_Write(m_ext_ctx, pkt, len);
         }

         currentAddress += len;

         if(currentAddress >= dump_region_end(currentRegion)) {
            /* end of region, skip forward */
            currentRegion++;
            currentAddress = dump_region_start(currentRegion);
            if(dump_region_size(currentRegion) == 0) {
               /* Complete - Start store data on a file and restart driver */
               trace_mask = old_trace_mask;
               DE_TRACE_STATIC(TR_ALWAYS,"Coredump complete - cancel timer\n");
               DriverEnvironment_CancelTimer(wifiEngineState.cmd_timer_id);
               WES_CLEAR_FLAG(WES_FLAG_CMD_TIMEOUT_RUNNING);
               DriverEnvironment_Core_Dump_Complete(registry.network.basic.enableCoredump && m_ext_ctx != NULL, /* see driverenv.h */
                                                    registry.network.basic.restartTargetAfterCoredump,
                                                    m_objId,
                                                    m_errCode, 
                                                    &m_ext_ctx);
               DriverEnvironment_indicate(WE_IND_CORE_DUMP_COMPLETE, NULL, 0);
               return;
            }
         }
         getNextBlock(currentAddress);
      }
      break;

      default:
         DE_BUG_ON(TRUE, "Invalid core dump state\n");
         break;
   }
}