Exemplo n.º 1
0
int avila_get_npe_esa( 
   int index, 
   uint8_t *buf
   )
{

   char  npe_mac[6]= {0x00,0x00,0x00,0x00,0x00,0x00};
   extern char saved_command_line[];
   int i;
   int val;
   int retVal = -1;

   for ( i=0;i<strlen(saved_command_line);i++ )
   {
      int found = 0;
      if ( index )
      {
         if ( strncmp(saved_command_line+i,"NPE1",4)==0 )
         {
            found = 1;
         }
      }
      else
         if ( strncmp(saved_command_line+i,"NPE0",4)==0 )
         {
            found = 1;
         }
      if ( found )
      {
         //printk("Index = %i  %s\n", i,&saved_command_line[i] );
         sscanf(&saved_command_line[i+ 5],"0x%x",&val);   npe_mac[0]=val;
         sscanf(&saved_command_line[i+10],"0x%x",&val);   npe_mac[1]=val;
         sscanf(&saved_command_line[i+15],"0x%x",&val);   npe_mac[2]=val;
         sscanf(&saved_command_line[i+20],"0x%x",&val);   npe_mac[3]=val;
         sscanf(&saved_command_line[i+25],"0x%x",&val);   npe_mac[4]=val;
         sscanf(&saved_command_line[i+30],"0x%x",&val);   npe_mac[5]=val;
         print_deb("NPE%d address: %02X:%02X:%02X:%02X:%02X:%02X \n", index, npe_mac[0],npe_mac[1],npe_mac[2],npe_mac[3],npe_mac[4],npe_mac[5]);
         break;
      }
   }
   if ( i != strlen(saved_command_line) )
   {
      // We found a mac address.
      memcpy(buf,npe_mac,6);
      retVal = 0;
   }
   else
   {
      // We didn't find a mac address.
      print_deb("No NPE%d MAC address on command line\n", index);
      retVal = -1
   }
  return retVal;
}
int ti1610_ioctl_priv_proc_tl(tiwlan_req_t *req_data)
{
    struct net_device *dev = req_data->drv->netdev;
    tiioctl_req_t *req = (tiioctl_req_t *) req_data->u.req.p1;
    static unsigned int drv_started = 0;
	static UINT8 IoCompleteFlag ;

    ULONG *data = (ULONG *) req_data->u.req.p2;

    int res = -EINVAL;

    print_deb("priv_ioctl_proc(): cmd=%ld, data=%p (user_data=%lx), lenght=%ld\n",
                req->cmd, data, req->user_data_pointer, req->length);
    if( !drv_started && (req->cmd != TIWLN_DRIVER_STATUS_SET)) { /* Dm: Fix */
            return res;
    }
					
    switch( req->cmd ) {
        case TIWLN_DRIVER_STATUS_SET:
            if(*data)
                res = tiwlan_start_drv( (tiwlan_net_dev_t *)dev->priv );
            else
                res = tiwlan_stop_drv( (tiwlan_net_dev_t *)dev->priv );

            if( res == OK )
                    drv_started = !drv_started;
            break;

        case TIWLN_SEND_EAPOL_PACKET:
            res = os_sendPacket(dev, data, req->length);
            break;
#ifdef TI_DBG
        case TIWLN_DRIVER_DEBUG_PRINT:
                res = util_hal_debug_print(dev, data);
                break;
#endif /* TI_DBG */
        default:
		{
            res = DispatchCommand(&req_data->drv->adapter, req->cmd, &req->length, req->length, data,&IoCompleteFlag );
			/* If we do not have to send complete to user back then set the Falg to FALSE 
			The Complete will be sent from another contect of command completion from FW */
			if(IoCompleteFlag == FALSE)
			{
			   req_data->u.req.reply_expected = FALSE;
			   /****** TO DO - This solution will have a problem in case of two async ioctrls (in case of two utility adapters). ******/
			   /* Store the semaphore for later competion */
			   (req_data->drv->adapter).IoctlComp = &(req_data->u.req.comp);
			   /* Store the pointer of the result status for later competion */
			   (req_data->drv->adapter).pCompleteReply = &(req_data->u.reply);
			}

		}
    }
    return res;
}
Exemplo n.º 3
0
static int avila_get_ofdm_mac_addr(
   uint8_t *buf
   )
{
   static char  npe_mac[6]= {0x00,0x00,0x00,0x00,0x00,0x00};
   extern char saved_command_line[];
   int i;
   int val;

   for ( i=0;i<strlen(saved_command_line);i++ )
   {
      if ( strncmp(saved_command_line+i,"OFDM",4)==0 )
      {
         //printk("Index = %i  %s\n", i,&saved_command_line[i] );
         sscanf(&saved_command_line[i+ 5],"0x%x",&val);   npe_mac[0]= (uint8_t)val;
         sscanf(&saved_command_line[i+10],"0x%x",&val);   npe_mac[1]= (uint8_t)val;
         sscanf(&saved_command_line[i+15],"0x%x",&val);   npe_mac[2]= (uint8_t)val;
         sscanf(&saved_command_line[i+20],"0x%x",&val);   npe_mac[3]= (uint8_t)val;
         sscanf(&saved_command_line[i+25],"0x%x",&val);   npe_mac[4]= (uint8_t)val;
         sscanf(&saved_command_line[i+30],"0x%x",&val);   npe_mac[5]= (uint8_t)val;
         print_deb("OFDM address: %02X:%02X:%02X:%02X:%02X:%02X \n",npe_mac[0],npe_mac[1],npe_mac[2],npe_mac[3],npe_mac[4],npe_mac[5]);
         break;
      }
   }

   if ( i != strlen(saved_command_line) )
   {
      // We found mac address.
      memcpy(buf,npe_mac,6);
      retVal = 0;
   }
   else
   {
      // We didn't find mac address.
      print_deb("No OFDM MAC address on bootline\n");
      retVal = -1
   }
   return retVal;
}
Exemplo n.º 4
0
/**
 * @brief Save the npe mac address in eeprom.
 */
int eeprom_set_npe_esa ( 
   uint8_t *mac 
   )
{
   int i;
   for ( i = 0; i < EEPROM_ETHA_LEN; i++ )
   {
      print_deb("mac[%d] = 0x%x\n", i, mac[i]);
      ws_eeprom_write(EEPROM_ETHA_OFF + i, mac[i]);
      mdelay(100);
   }
   return 0;
}
Exemplo n.º 5
0
int util_hal_debug_print(struct net_device *dev, ULONG *data)
{
    hal_print_param_t *p = (hal_print_param_t *) data;
    UINT32 opt_data = 0;
    
    if( p->optional_param )
    {
        if( copy_from_user(&opt_data, p->optional_param, sizeof(opt_data) ) )
            return -EFAULT;
    }

    print_deb("HAL_DEBUG_PRINT: func_id=%d, param=%x\n", p->func_id, opt_data );
#ifdef TI_DBG    
    debugFunction(CONFIG_MGR(dev), p->func_id, &opt_data );
#endif
    return 0;
}
void print_priv_ioctl_params(struct net_device *dev, tiioctl_req_t *req, char *extra)
{
        print_deb(" priv_ioctl_params(*dev:%p,*req:%p, *extra:%p)\n", dev, req, extra);
        print_deb("   wrqu.point: user_data=%p, length=%ld, cmd=%ld\n", (void *) req->user_data_pointer,
                  req->length, req->cmd );
        print_deb("   wrqu dump: ");
        print_memory_dump((char *) req, sizeof(*req) );
        print_deb("\n");

        if( extra )
        {
                print_deb("   extra (%p) :", extra );
                print_memory_dump(extra, req->length );
                print_deb("\n");
        }
}
Exemplo n.º 7
0
void NdisReadConfiguration(OUT PNDIS_STATUS status,
			   OUT PNDIS_CONFIGURATION_PARAMETER * param_value,
			   IN NDIS_HANDLE config_handle,
			   IN PNDIS_STRING keyword,
			   IN NDIS_PARAMETER_TYPE param_type)
{
	char *name = keyword->Buffer;
	char *s, *buf = init_file, *end_buf = init_file + init_file_length;
	static int count = 0;

	*status = NDIS_STATUS_FAILURE;
	*param_value = pNdisParm;

	if (!count) {
		print_deb("\n++++++++++++\n%s+++++++++++\n", init_file);
		count++;
	}

	if (!name || !*name || !init_file || !init_file_length)
		return;

	memset(pNdisParm, 0, sizeof(NDIS_CONFIGURATION_PARAMETER));

	while (buf < end_buf) {
		buf = ltrim(buf);
		s = mem_str(buf, name, end_buf);
		if (!s)
			break;

		buf = ltrim(s + strlen(name));
		if (*buf == '=')
			buf++;
		else {
			/*print_err("\n...init_config err: delim not found (=): ** %s **\n", buf ); */
			buf = s + 1;	/*strlen(name); */
			continue;
		}
		buf = ltrim(buf);
		if (param_type == NdisParameterString) {
			char *remark = NULL;

			s = strchr(buf, '\n');
			if (!s)
				s = buf + strlen(buf);

			remark = memchr(buf, '#', s - buf);	/* skip remarks */
			if (remark) {
				do {	/* remove whitespace  */
					remark--;
				} while (*remark == ' ' || *remark == '\t');

				pNdisParm->ParameterData.StringData.Length =
				    remark - buf + 1;
			} else
				pNdisParm->ParameterData.StringData.Length =
				    s - buf;

			pNdisParm->ParameterData.StringData.Buffer =
			    (TI_UINT8 *) & pNdisParm->StringBuffer[0];
			pNdisParm->ParameterData.StringData.MaximumLength =
			    NDIS_MAX_STRING_LEN;
			if (!pNdisParm->ParameterData.StringData.Length >
			    NDIS_MAX_STRING_LEN) {
				*status = NDIS_STATUS_BUFFER_TOO_SHORT;
				return;
			}
			memcpy(pNdisParm->ParameterData.StringData.Buffer, buf,
			       pNdisParm->ParameterData.StringData.Length);
			print_info("NdisReadConfiguration(): %s = (%d)'%s'\n",
				   name,
				   pNdisParm->ParameterData.StringData.Length,
				   pNdisParm->ParameterData.StringData.Buffer);
		} else if (param_type == NdisParameterInteger) {
			char *end_p;
			pNdisParm->ParameterData.IntegerData =
			    simple_strtol(buf, &end_p, 0);
			if (end_p && *end_p && *end_p != ' ' && *end_p != '\n'
			    && *end_p != '\r' && *end_p != '\t') {
				print_err
				    ("\n...init_config: invalid int value for <%s> : %s\n",
				     name, buf);
				return;
			}
			/*print_deb(" NdisReadConfiguration(): buf = %p (%.20s)\n", buf, buf ); */
			print_info("NdisReadConfiguration(): %s = %d\n", name,
				   (TI_INT32) pNdisParm->ParameterData.
				   IntegerData);
		} else {
			print_err
			    ("NdisReadConfiguration(): unknow parameter type %d for %s\n",
			     param_type, name);
			return;
		}
		*status = NDIS_STATUS_SUCCESS;
		return;

	}
	return;
}
int ti1610_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
    tiioctl_req_t *req = (tiioctl_req_t *) &rq->ifr_ifru;
    char *extra, *kbuf = NULL;
    int res, aval_data_size = ((char *) req + sizeof(*req)) - (char *)&req->user_data_pointer;      /* = ~4 bytes */
    /*int is_get_cmd = (req->cmd_type & IOCTL_GET);*/

    print_deb("ti1610_do_ioctl(cmd=%lu(%s%s)) - user_data_pointer=0x%lx, len = %lu, aval_data_size=%d\n",
                req->cmd,
                (req->cmd_type & IOCTL_GET) ? "GET" : "", (req->cmd_type & IOCTL_SET) ? "SET" : "",
                req->user_data_pointer, req->length, aval_data_size );

	/* driver is already initialized */
	if ((req->cmd == TIWLN_SET_INIT_INFO) && (((tiwlan_net_dev_t *)dev->priv)->adapter.CoreHalCtx))
	{
		return 0;
	}

	if( req->length > aval_data_size )
    {
        if( req->user_data_pointer == 0 )
            return -EFAULT;

        print_deb("ti1610_do_ioctl() - alloc %ld bytes\n", req->length );
		kbuf = extra = os_memoryAlloc(NULL,req->length);
#ifdef TI_MEM_ALLOC_TRACE        
        os_printf("MTT:%s:%d ::kmalloc(%lu, %x) : %lu\n", __FUNCTION__, __LINE__, req->length, GFP_KERNEL, req->length);
#endif/*I_MEM_ALLOC_TRACE*/

        if( !extra )
            return -ENOBUFS;
        if( req->cmd_type & IOCTL_SET )
        {
            if( copy_from_user(extra, (void *) req->user_data_pointer, req->length) )
                return -EFAULT;
        }
        else {
            os_memoryZero( NULL, extra, req->length );
        }
    } else
            extra = (char *) &req->user_data_pointer;

    /* Driver initialization must be performed in process context.
       The rest is handled in the context of dedicated tasklet
    */
    if (req->cmd == TIWLN_SET_INIT_INFO)
    {
       tiwlan_dev_init_t *init_info = (tiwlan_dev_init_t *)extra;
       print_deb("TIWLN_SET_INIT_INFO: el=%d il=%d, fl=%d\n",
              init_info?init_info->eeprom_image_length:0,
              init_info?init_info->init_file_length:0,
              init_info?init_info->firmware_image_length:0 );
       res = tiwlan_init_drv((tiwlan_net_dev_t *)dev->priv, init_info);
    }

#ifdef DRIVER_PROFILING
    else if (req->cmd == TIWLAN_PROFILING_REPORT) 
    {
       res = tiwlan_profile_report((tiwlan_net_dev_t *)dev->priv);
    }
    else if (req->cmd == TIWLAN_PROFILING_CPU_ESTIMATOR_CMD) {
       /* get the command cpu estimator command parameter */
       unsigned int command_param = *((unsigned int *)extra);
       /* extract the command type which is the MSB byte of the command param*/
       unsigned int command_type = 0xFF & (command_param >> 24);
       /* extract the data of the command which are the 3 LSB bytes of the command param */
       unsigned int command_data = 0xFFFFFF & command_param;
       /* execute the command according to its type */
       switch (command_type) 
       {
       case TIWLAN_PROFILING_CPU_ESTIMATOR_CMD_START:
           res = tiwlan_profile_cpu_usage_estimator_start((tiwlan_net_dev_t *)dev->priv,
                                                          /* the data in this case is the estimator
                                                          resolution in milliseconds */
                                                          command_data * 1000);
           break;
       case TIWLAN_PROFILING_CPU_ESTIMATOR_CMD_STOP:
           res = tiwlan_profile_cpu_usage_estimator_stop((tiwlan_net_dev_t *)dev->priv);
           break;
       case TIWLAN_PROFILING_CPU_ESTIMATOR_CMD_RESET:
           res =tiwlan_profile_cpu_usage_estimator_reset((tiwlan_net_dev_t *)dev->priv);
           break;
       default:
           res = 0;
           printk("\n\n%s: cpu usage estimator unknow command: param = %x\n\n\n",
                     __FUNCTION__, command_param);
       }
    }