Exemplo n.º 1
0
sw_error_t
cmd_show_fdb(a_uint32_t *arg_val)
{
    sw_error_t rtn;
    a_uint32_t cnt = 0;
    fal_fdb_op_t    *fdb_op    = (fal_fdb_op_t *)    (ioctl_buf + sizeof(sw_error_t) / 4);
    fal_fdb_entry_t *fdb_entry = (fal_fdb_entry_t *) (ioctl_buf + sizeof(sw_error_t) / 4 + sizeof(fal_fdb_op_t) / 4);

    aos_mem_zero(fdb_op,    sizeof (fal_fdb_op_t));
    aos_mem_zero(fdb_entry, sizeof (fal_fdb_entry_t));
    arg_val[0] = SW_API_FDB_EXTEND_FIRST;

    while (1)
    {
        arg_val[1] = (a_uint32_t) ioctl_buf;
        arg_val[2] = get_devid();
        arg_val[3] = (a_uint32_t) fdb_op;
        arg_val[4] = (a_uint32_t) fdb_entry;

        rtn = cmd_exec_api(arg_val);
        if ((SW_OK != rtn)  || (SW_OK != (sw_error_t) (*ioctl_buf)))
        {
            break;
        }
        arg_val[0] = SW_API_FDB_EXTEND_NEXT;
        cnt++;
    }

    if((rtn != SW_OK) && (rtn != SW_NO_MORE))
        cmd_print_error(rtn);
    else
        dprintf("\ntotal %d entries\n", cnt);

    return SW_OK;
}
Exemplo n.º 2
0
sw_error_t
cmd_show_fdb(a_uint32_t *arg_val)
{
    sw_error_t rtn;
    a_uint32_t cnt = 0;
    fal_fdb_entry_t *fdb_entry = (fal_fdb_entry_t *) (ioctl_buf + 2);

    memset(fdb_entry, 0, sizeof (fal_fdb_entry_t));
    arg_val[0] = SW_API_FDB_ITERATE;
    *(ioctl_buf + 1) = 0;

    while (1)
    {
        arg_val[1] = (a_uint32_t) ioctl_buf;
        arg_val[2] = get_devid();
        arg_val[3] = (a_uint32_t) (ioctl_buf + 1);
        arg_val[4] = (a_uint32_t) fdb_entry;

        rtn = cmd_exec_api(arg_val);
        if ((SW_OK != rtn)  || (SW_OK != (sw_error_t) (*ioctl_buf)))
        {
            break;
        }
        cnt++;
    }

    if((rtn != SW_OK) && (rtn != SW_NO_MORE))
        cmd_print_error(rtn);
    else
        dprintf("\ntotal %d entries\n", cnt);

    return SW_OK;
}
Exemplo n.º 3
0
sw_error_t
cmd_show_napt(a_uint32_t *arg_val)
{
    sw_error_t rtn;
    a_uint32_t cnt = 0;
    fal_napt_entry_t *napt_entry = (fal_napt_entry_t *) (ioctl_buf + sizeof(sw_error_t) / 4);

    aos_mem_zero(napt_entry, sizeof (fal_napt_entry_t));
    napt_entry->entry_id = FAL_NEXT_ENTRY_FIRST_ID;
    arg_val[0] = SW_API_NAPT_NEXT;

    while (1)
    {
        arg_val[1] = (a_uint32_t) ioctl_buf;
        arg_val[2] = get_devid();
        arg_val[3] = 0;
        arg_val[4] = (a_uint32_t) napt_entry;

        rtn = cmd_exec_api(arg_val);
        if ((SW_OK != rtn)  || (SW_OK != (sw_error_t) (*ioctl_buf)))
        {
            break;
        }
        cnt++;
    }

    if((rtn != SW_OK) && (rtn != SW_NO_MORE))
        cmd_print_error(rtn);
    else
        dprintf("\ntotal %d entries\n", cnt);

    return SW_OK;
}
Exemplo n.º 4
0
sw_error_t
cmd_show_vlan(a_uint32_t *arg_val)
{
    sw_error_t rtn;
    a_uint32_t rtn_size = 1 ,tmp_vid = 0, cnt = 0;
    fal_vlan_t *vlan_entry = (fal_vlan_t *) (ioctl_buf + rtn_size);

    while (1)
    {
        arg_val[0] = SW_API_VLAN_NEXT;
        arg_val[1] = (a_uint32_t) ioctl_buf;
        arg_val[2] = get_devid();
        arg_val[3] = tmp_vid;
        arg_val[4] = (a_uint32_t) vlan_entry;

        rtn = cmd_exec_api(arg_val);
        if ((SW_OK != rtn)  || (SW_OK != (sw_error_t) (*ioctl_buf)))
        {
            break;
        }

        tmp_vid = vlan_entry->vid;
        cnt++;
    }

    if((rtn != SW_OK) && (rtn != SW_NO_MORE))
        cmd_print_error(rtn);
    else
        dprintf("\ntotal %d entries\n", cnt);

    return SW_OK;
}
Exemplo n.º 5
0
sw_error_t
cmd_show_resv_fdb(a_uint32_t *arg_val)
{
    sw_error_t rtn;
    a_uint32_t cnt = 0;
    a_uint32_t  *iterator  = ioctl_buf + 1;
    fal_fdb_entry_t *entry = (fal_fdb_entry_t *) (ioctl_buf + 2);

    *iterator = 0;
    while (1)
    {
        arg_val[0] = SW_API_FDB_RESV_ITERATE;
        arg_val[1] = (a_uint32_t) ioctl_buf;
        arg_val[2] = get_devid();
        arg_val[3] = (a_uint32_t) iterator;
        arg_val[4] = (a_uint32_t) entry;

        rtn = cmd_exec_api(arg_val);
        if ((SW_OK != rtn)  || (SW_OK != (sw_error_t) (*ioctl_buf)))
        {
            break;
        }
        cnt++;
        dprintf("\n");
    }

    if((rtn != SW_OK) && (rtn != SW_NO_MORE))
        cmd_print_error(rtn);
    else
        dprintf("\ntotal %d entries\n", cnt);

    return SW_OK;
}
Exemplo n.º 6
0
static int
cmd_exec(a_uint32_t *arg_val, int cmd_index, int cmd_index_sub)
{
    a_uint32_t api_id = arg_val[0];
    sw_error_t rtn;

    if( api_id < SW_API_MAX )
    {
        rtn = cmd_exec_api(arg_val);

    }
    else if ((api_id > SW_API_MAX ) && (api_id < SW_CMD_MAX))
    {
        if (GCMD_SUB_FUNC(cmd_index, cmd_index_sub))
            rtn = GCMD_SUB_FUNC(cmd_index, cmd_index_sub)(arg_val);
    }
    else
    {
        rtn = SW_BAD_PARAM;
    }

    if(rtn != SW_OK)
        cmd_print_error(rtn);
    else
        dprintf("\noperate done.\n\n");

    return 0;
}
Exemplo n.º 7
0
static sw_error_t
cmd_api_output(sw_api_param_t *pp, a_uint32_t nr_param, a_uint32_t * args)
{
    a_uint16_t i;
    a_uint32_t *pbuf;
    a_uint16_t rtn_size = 1;
    sw_error_t rtn = (sw_error_t) (*ioctl_buf);
    sw_api_param_t *pptmp = NULL;

    if (rtn != SW_OK)
    {
        cmd_print_error(rtn);
        return rtn;
    }

    pbuf = ioctl_buf + rtn_size;
    for (i = 0; i < nr_param; i++)
    {
        pptmp = pp + i;
        if (pptmp->param_type & SW_PARAM_PTR)
        {

            if (pptmp->param_type & SW_PARAM_OUT)
            {

                sw_data_type_t *data_type;
                if (!(data_type = cmd_data_type_find(pptmp->data_type)))
                    return SW_NO_SUCH;

                if (data_type->show_func)
                {
                    data_type->show_func(pptmp->param_name, pbuf, pptmp->data_size);
                }
                else
                {
                    dprintf("\n Error, not define output print function!");
                }
            }

            if ((pbuf - ioctl_buf +
                    (pptmp->data_size + 3) / 4) > (IOCTL_BUF_SIZE/4))
                return SW_NO_RESOURCE;

            pbuf += (pptmp->data_size + 3) / 4;

        }
    }
    return SW_OK;
}
Exemplo n.º 8
0
static a_uint32_t *
cmd_parse(char *cmd_str, int *cmd_index, int *cmd_index_sub)
{
    int cmd_nr = 0;
    a_uint32_t *arg_val = ioctl_argp;
    char *tmp_str[CMDSTR_ARGS_MAX];

    if (cmd_str == NULL)
        return NULL;

    memset(arg_val, 0, CMDSTR_ARGS_MAX * sizeof (a_uint32_t));

    /* split string into array */
    if ((tmp_str[cmd_nr] = (void *) strtok(cmd_str, " ")) == NULL)
        return NULL;

    /*handle help */
    if (!strcasecmp(tmp_str[cmd_nr], "help"))
    {
        dprintf("input ? get help\n\n");
        return NULL;
    }

    while (tmp_str[cmd_nr])
    {
        if (++cmd_nr == 3)
            break;
        tmp_str[cmd_nr] = (void *) strtok(NULL, " ");
    }

    /*commond string lookup */
    int cmd_depth = cmd_lookup(tmp_str, cmd_index, cmd_index_sub);

    if (*cmd_index == GCMD_DESC_NO_MATCH || *cmd_index_sub == GCMD_DESC_NO_MATCH)
    {
        dprintf("invalid or incomplete command.\n\n");
        return NULL;
    }

    /*parse param */
    cmd_nr = 0;
    if (cmd_depth == 2)
    {
        tmp_str[cmd_nr] = tmp_str[2];
        cmd_nr++;
    }

    tmp_str[cmd_nr] = (void *) strtok(NULL, " ");
    while (tmp_str[cmd_nr])
    {
        if (++cmd_nr == CMDSTR_ARGS_MAX)
            break;
        tmp_str[cmd_nr] = (void *) strtok(NULL, " ");
    }

    arg_val[0] = GCMD_SUB_API(*cmd_index, *cmd_index_sub);
    arg_val[1] = (a_uint32_t) ioctl_buf;

    int rtn_code;
    if (arg_val[0] < SW_API_MAX)
    {
        /*api command parse */
        rtn_code = cmd_parse_api(tmp_str, arg_val);

    }
    else if (arg_val[0] > SW_API_MAX)
    {
        /*user command parse */
        rtn_code = cmd_parse_sw(tmp_str, arg_val);

    }
    else
    {
        rtn_code = SW_BAD_PARAM;
    }

    if(rtn_code != SW_OK)
    {
        cmd_print_error(rtn_code);

        if(rtn_code == SW_BAD_PARAM)
            cmd_print_usage(*cmd_index, *cmd_index_sub);

        return NULL;
    }

    return arg_val;
}
Exemplo n.º 9
0
sw_error_t
cmd_show_fdb(a_uint32_t *arg_val)
{
    if (ssdk_cfg.init_cfg.chip_type == CHIP_ISIS) {
	    sw_error_t rtn;
	    a_uint32_t cnt = 0;
	    fal_fdb_op_t    *fdb_op    = (fal_fdb_op_t *)    (ioctl_buf + sizeof(sw_error_t) / 4);
	    fal_fdb_entry_t *fdb_entry = (fal_fdb_entry_t *) (ioctl_buf + sizeof(sw_error_t) / 4 + sizeof(fal_fdb_op_t) / 4);

	    aos_mem_zero(fdb_op,    sizeof (fal_fdb_op_t));
	    aos_mem_zero(fdb_entry, sizeof (fal_fdb_entry_t));
	    arg_val[0] = SW_API_FDB_EXTEND_FIRST;

	    while (1)
	    {
	        arg_val[1] = (a_uint32_t) ioctl_buf;
	        arg_val[2] = get_devid();
	        arg_val[3] = (a_uint32_t) fdb_op;
	        arg_val[4] = (a_uint32_t) fdb_entry;

	        rtn = cmd_exec_api(arg_val);
	        if ((SW_OK != rtn)  || (SW_OK != (sw_error_t) (*ioctl_buf)))
	        {
	            break;
	        }
	        arg_val[0] = SW_API_FDB_EXTEND_NEXT;
	        cnt++;
	    }

	    if((rtn != SW_OK) && (rtn != SW_NO_MORE))
	        cmd_print_error(rtn);
	    else
	        dprintf("\ntotal %d entries\n", cnt);
    }else if ((ssdk_cfg.init_cfg.chip_type == CHIP_ISISC) ||
		(ssdk_cfg.init_cfg.chip_type == CHIP_DESS)) {
	    sw_error_t rtn;
	    a_uint32_t cnt = 0;
	    fal_fdb_op_t    *fdb_op    = (fal_fdb_op_t *)    (ioctl_buf + sizeof(sw_error_t) / 4);
	    fal_fdb_entry_t *fdb_entry = (fal_fdb_entry_t *) (ioctl_buf + sizeof(sw_error_t) / 4 + sizeof(fal_fdb_op_t) / 4);

	    aos_mem_zero(fdb_op,    sizeof (fal_fdb_op_t));
	    aos_mem_zero(fdb_entry, sizeof (fal_fdb_entry_t));
	    arg_val[0] = SW_API_FDB_EXTEND_FIRST;

	    while (1)
	    {
	        arg_val[1] = (a_uint32_t) ioctl_buf;
	        arg_val[2] = get_devid();
	        arg_val[3] = (a_uint32_t) fdb_op;
	        arg_val[4] = (a_uint32_t) fdb_entry;

	        rtn = cmd_exec_api(arg_val);
	        if ((SW_OK != rtn)  || (SW_OK != (sw_error_t) (*ioctl_buf)))
	        {
	            break;
	        }
	        arg_val[0] = SW_API_FDB_EXTEND_NEXT;
	        cnt++;
	    }

	    if((rtn != SW_OK) && (rtn != SW_NO_MORE))
	        cmd_print_error(rtn);
	    else
	        dprintf("\ntotal %d entries\n", cnt);
    }else if (ssdk_cfg.init_cfg.chip_type == CHIP_SHIVA) {
	    sw_error_t rtn;
	    a_uint32_t cnt = 0;
	    fal_fdb_entry_t *fdb_entry = (fal_fdb_entry_t *) (ioctl_buf + 2);

	    memset(fdb_entry, 0, sizeof (fal_fdb_entry_t));
	    arg_val[0] = SW_API_FDB_ITERATE;
	    *(ioctl_buf + 1) = 0;

	    while (1)
	    {
	        arg_val[1] = (a_uint32_t) ioctl_buf;
	        arg_val[2] = get_devid();
	        arg_val[3] = (a_uint32_t) (ioctl_buf + 1);
	        arg_val[4] = (a_uint32_t) fdb_entry;

	        rtn = cmd_exec_api(arg_val);
	        if ((SW_OK != rtn)  || (SW_OK != (sw_error_t) (*ioctl_buf)))
	        {
	            break;
	        }
	        cnt++;
	    }

	    if((rtn != SW_OK) && (rtn != SW_NO_MORE))
	        cmd_print_error(rtn);
	    else
	        dprintf("\ntotal %d entries\n", cnt);
    }else {
	    sw_error_t rtn;
	    a_uint32_t rtn_size = 1, cnt = 0;
	    fal_fdb_entry_t *fdb_entry = (fal_fdb_entry_t *) (ioctl_buf + rtn_size);

	    memset(fdb_entry, 0, sizeof (fal_fdb_entry_t));
	    arg_val[0] = SW_API_FDB_FIRST;

	    while (1)
	    {
	        arg_val[1] = (a_uint32_t) ioctl_buf;
	        arg_val[2] = get_devid();
	        arg_val[3] = (a_uint32_t) fdb_entry;

	        rtn = cmd_exec_api(arg_val);
	        if ((SW_OK != rtn)  || (SW_OK != (sw_error_t) (*ioctl_buf)))
	        {
	            break;
	        }
	        arg_val[0] = SW_API_FDB_NEXT;
	        cnt++;
	    }

	    if((rtn != SW_OK) && (rtn != SW_NO_MORE))
	        cmd_print_error(rtn);
	    else
	        dprintf("\ntotal %d entries\n", cnt);
    }

    return SW_OK;
}
Exemplo n.º 10
0
sw_error_t
cmd_show_vlan(a_uint32_t *arg_val)
{
    if (ssdk_cfg.init_cfg.chip_type == CHIP_ISIS) {
	    sw_error_t rtn;
	    a_uint32_t rtn_size = 1 ,tmp_vid = FAL_NEXT_ENTRY_FIRST_ID, cnt = 0;
	    fal_vlan_t *vlan_entry = (fal_vlan_t *) (ioctl_buf + rtn_size);

	    while (1)
	    {
	        arg_val[0] = SW_API_VLAN_NEXT;
	        arg_val[1] = (a_uint32_t) ioctl_buf;
	        arg_val[2] = get_devid();
	        arg_val[3] = tmp_vid;
	        arg_val[4] = (a_uint32_t) vlan_entry;

	        rtn = cmd_exec_api(arg_val);
	        if ((SW_OK != rtn)  || (SW_OK != (sw_error_t) (*ioctl_buf)))
	        {
	            break;
	        }

	        tmp_vid = vlan_entry->vid;
	        cnt++;
	    }

	    if((rtn != SW_OK) && (rtn != SW_NO_MORE))
	        cmd_print_error(rtn);
	    else
	        dprintf("\ntotal %d entries\n", cnt);
    }else if ((ssdk_cfg.init_cfg.chip_type == CHIP_ISISC) ||
		(ssdk_cfg.init_cfg.chip_type == CHIP_DESS)) {
	    sw_error_t rtn;
	    a_uint32_t rtn_size = 1 ,tmp_vid = FAL_NEXT_ENTRY_FIRST_ID, cnt = 0;
	    fal_vlan_t *vlan_entry = (fal_vlan_t *) (ioctl_buf + rtn_size);

	    while (1)
	    {
	        arg_val[0] = SW_API_VLAN_NEXT;
	        arg_val[1] = (a_uint32_t) ioctl_buf;
	        arg_val[2] = get_devid();
	        arg_val[3] = tmp_vid;
	        arg_val[4] = (a_uint32_t) vlan_entry;

	        rtn = cmd_exec_api(arg_val);
	        if ((SW_OK != rtn)  || (SW_OK != (sw_error_t) (*ioctl_buf)))
	        {
	            break;
	        }

	        tmp_vid = vlan_entry->vid;
	        cnt++;
	    }

	    if((rtn != SW_OK) && (rtn != SW_NO_MORE))
	        cmd_print_error(rtn);
	    else
	        dprintf("\ntotal %d entries\n", cnt);
    } else {
	    sw_error_t rtn;
	    a_uint32_t rtn_size = 1 ,tmp_vid = 0, cnt = 0;
	    fal_vlan_t *vlan_entry = (fal_vlan_t *) (ioctl_buf + rtn_size);

	    while (1)
	    {
	        arg_val[0] = SW_API_VLAN_NEXT;
	        arg_val[1] = (a_uint32_t) ioctl_buf;
	        arg_val[2] = get_devid();
	        arg_val[3] = tmp_vid;
	        arg_val[4] = (a_uint32_t) vlan_entry;

	        rtn = cmd_exec_api(arg_val);
	        if ((SW_OK != rtn)  || (SW_OK != (sw_error_t) (*ioctl_buf)))
	        {
	            break;
	        }

	        tmp_vid = vlan_entry->vid;
	        cnt++;
	    }

	    if((rtn != SW_OK) && (rtn != SW_NO_MORE))
	        cmd_print_error(rtn);
	    else
	        dprintf("\ntotal %d entries\n", cnt);
	}

    return SW_OK;
}