MV_VOID mvSocUnitMapPrint(MV_8* buf)
{
	int i, count;
	count = mvOsSPrintf(buf, "CPU core %d, SoC units in use:\n", whoAmI());
	for (i = 0; mv_res_table[i].cpuId != -1; i++) {
		if (mv_res_table[i].cpuId == whoAmI()) {
			count += mvOsSPrintf(buf+count, "%s ", mv_res_table[i].unitName);
		}
	}
}
Exemple #2
0
/*******************************************************************************
* mvBoardNameGet - Get Board name
*
* DESCRIPTION:
*       This function returns a string describing the board model and revision.
*       String is extracted from board I2C EEPROM.
*
* INPUT:
*       None.
*
* OUTPUT:
*       pNameBuff - Buffer to contain board name string. Minimum size 32 chars.
*
* RETURN:
*
*       MV_ERROR if informantion can not be read.
*******************************************************************************/
MV_STATUS mvBoardNameGet(char *pNameBuff)
{
	MV_U32 boardId= mvBoardIdGet();

	if (!((boardId >= BOARD_ID_BASE)&&(boardId < MV_MAX_BOARD_ID)))
	{
		mvOsSPrintf (pNameBuff, "Board unknown.\n");
		return MV_ERROR;

	}

	mvOsSPrintf (pNameBuff, "%s",BOARD_INFO(boardId)->boardName);

	return MV_OK;
}
static ssize_t cls_policy_get(struct device *dev,
				  struct device_attribute *attr, char *buf)
{
	int off = 0, mode = 0;
	const char *name = attr->attr.name, *str;
	if (!strcmp(name, "dscp_policy_get"))
		mode = nfp_dscp_policy_get();
	else if (!strcmp(name, "vlan_prio_policy_get"))
		mode = nfp_vlan_prio_policy_get();
	else if (!strcmp(name, "txq_policy_get"))
		mode = nfp_txq_policy_get();
	else if (!strcmp(name, "txp_policy_get"))
		mode = nfp_txp_policy_get();
	else if (!strcmp(name, "mh_policy_get"))
		mode = nfp_mh_policy_get();

	if (mode == 0)
		str = "highest";
	else if (mode == 1)
		str = "lowest";
	else if (mode == 2)
		str = "first";
	else
		str = "last";

	off += mvOsSPrintf(buf+off, "%s: %s\n", name, str);
	return off;
}
void mvBinToAscii(const MV_U8 *bin, char *asciiStr, int size)
{
    int i;

    for (i = 0; i < size; i++)
        mvOsSPrintf(&asciiStr[i * 2], "%c", bin[i]);

    asciiStr[i * 2] = '\0';
}
void mvBinToHex(const MV_U8 *bin, char *hexStr, int size)
{
    int i;

    for (i = 0; i < size; i++)
        mvOsSPrintf(&hexStr[i * 2], "%02x", bin[i]);

    hexStr[i * 2] = '\0';
}
void mvAsciiToHex(const char *asciiStr, char *hexStr)
{
    int i = 0;

    while (asciiStr[i] != 0) {
        mvOsSPrintf(&hexStr[i * 2], "%02x", asciiStr[i]);
        i++;
    }
    hexStr[i * 2] = 0;
}
static ssize_t tcam_show(struct device *dev, 
				  struct device_attribute *attr, char *buf)
{
	const char* name = attr->attr.name;
	unsigned int v, m;

	if (!capable(CAP_NET_ADMIN))
		return -EPERM;

	if (!strcmp(name, "t_port")) {	
		tcam_sw_get_port(&te, &v, &m);
		return mvOsSPrintf(buf, "value:0x%x mask:0x%x\n", v, m);
	}
	else if (!strcmp(name, "t_lookup")) {
		tcam_sw_get_lookup(&te, &v, &m);
		return mvOsSPrintf(buf, "value:0x%x mask:0x%x\n", v, m);
	}
	else if (!strcmp(name, "sw_dump")) 
		return tcam_sw_dump(&te, buf);
	else if (!strcmp(name, "hw_dump")) 
		return tcam_hw_dump(0);
	else if (!strcmp(name, "hw_dump_all")) 
		return tcam_hw_dump(1);
	else if (!strcmp(name, "hw_regs")) 
		mvNetaPncRegs();
	else if (!strcmp(name, "hw_hits")) 
		return tcam_hw_hits(buf);
#ifdef CONFIG_MV_ETH_PNC_AGING
	else if (!strcmp(name, "age_dump")) 
		mvPncAgingDump(0);
	else if (!strcmp(name, "age_dump_all")) 
		mvPncAgingDump(1);
	else if (!strcmp(name, "age_scan")) 
		mvPncAgingScannerDump();
	else if (!strcmp(name, "age_reset")) 
		mvPncAgingReset();
#endif /* CONFIG_MV_ETH_PNC_AGING */
	else if (!strcmp(name, "help")) 
		return tcam_help(buf);

	return 0;
}
static ssize_t vlan_help(struct device *dev,
				  struct device_attribute *attr, char *buf)
{
	int off = 0;

	off += mvOsSPrintf(buf+off, "cat                help      - print this help\n");
	off += mvOsSPrintf(buf+off, "echo if_name pvid  > pvid    - set PVID for ingress interface\n");
	off += mvOsSPrintf(buf+off, "echo if_name vid   > vid     - set VID for VLAN interface\n");
	off += mvOsSPrintf(buf+off, "echo if_name mode  > rx_mode - set VLAN <mode> for ingress interface\n");
	off += mvOsSPrintf(buf+off, "                             0 - transparent, 1 - drop untagged, 2 - drop tagged,\n");
	off += mvOsSPrintf(buf+off, "                             3 - drop unknown, 4 - drop untagged and unknown\n");
	off += mvOsSPrintf(buf+off, "echo if_name mode  > tx_mode - set VLAN <mode> for egress interface\n");
	off += mvOsSPrintf(buf+off, "                             0 - transparent, 1 - send untagged, 2 - send tagged\n");
#ifdef NFP_VLAN_LEARN
	off += mvOsSPrintf(buf+off, "echo [0 | 1]       > learn   - enable/disble NFP vlan dynamic learning\n");
	off += mvOsSPrintf(buf+off, "echo 1             > sync    - sync Linux vlan database to NFP database\n");
#endif

	return off;
}
/*******************************************************************************
* mvMacHexToStr - Convert MAC in hex format to string format.
*
* DESCRIPTION:
*		This function convert MAC in hex format to string format.
*
* INPUT:
*       macHex - MAC in hex format.
*
* OUTPUT:
*       macStr - MAC address string. String format is uu:vv:ww:xx:yy:zz.
*
* RETURN:
*       None.
*
*******************************************************************************/
MV_STATUS mvMacHexToStr(MV_U8 *macHex, char *macStr)
{
    int i;

    for (i = 0; i < MV_MAC_ADDR_SIZE; i++)
        mvOsSPrintf(&macStr[i * 3], "%02x:", macHex[i]);

    macStr[(i * 3) - 1] = '\0';

    return MV_OK;
}
/*******************************************************************************
* mvCpuNameGet - Get CPU name
*
* DESCRIPTION:
*       This function returns a string describing the CPU model and revision.
*
* INPUT:
*       None.
*
* OUTPUT:
*       pNameBuff - Buffer to contain board name string. Minimum size 32 chars.
*
* RETURN:
*       None.
*******************************************************************************/
MV_VOID mvCpuNameGet(char *pNameBuff)
{
    MV_U32 cpuModel;
    
    cpuModel = mvOsCpuPartGet();

    /* The CPU module is indicated in the Processor Version Register (PVR) */
    switch(cpuModel)
    {
        case CPU_PART_ARM926:
            mvOsSPrintf(pNameBuff, "%s (Rev %d)", "ARM926",mvOsCpuRevGet());
            break;
	case CPU_PART_ARM946:
		mvOsSPrintf(pNameBuff, "%s (Rev %d)", "ARM946",mvOsCpuRevGet());
		break;
        default:
            mvOsSPrintf(pNameBuff,"??? (0x%04x) (Rev %d)",cpuModel,mvOsCpuRevGet());
            break;
    }  /* switch  */

    return;
}
static ssize_t do_print_local_key(struct device *dev,
				  struct device_attribute *attr, char *buf)
{
	unsigned int off = 0;
	if (!key.init) {
		off += mvOsSPrintf(buf+off, "Print_local_key: local key is not initialized.\n");
		goto key_print_out;
	}
	off += mvOsSPrintf(buf+off, "Local key:\n");
	off += mvOsSPrintf(buf+off, "    family: IPv4\n");
	off += mvOsSPrintf(buf+off, "    sip: "MV_IPQUAD_FMT"\n", MV_IPQUAD(key.sip));
	off += mvOsSPrintf(buf+off, "    dip: "MV_IPQUAD_FMT"\n", MV_IPQUAD(key.dip));
	off += mvOsSPrintf(buf+off, "    sport: %hu\n", key.sport);
	off += mvOsSPrintf(buf+off, "    dport: %hu\n", key.dport);
	off += mvOsSPrintf(buf+off, "    proto: %hhu\n\n", key.proto);
key_print_out:
	return off;
}
static ssize_t nfp_help(char *buf)
{
	int off = 0;

	off += mvOsSPrintf(buf+off, "cat                    help    - print this help\n");
	off += mvOsSPrintf(buf+off, "cat                    stats   - print NFP_MGR statistics\n");
	off += mvOsSPrintf(buf+off, "cat                    dump    - print NFP databases\n");
	off += mvOsSPrintf(buf+off, "echo <0 | 1>         > nfp     - disable / enable NFP support\n");
	off += mvOsSPrintf(buf+off, "echo port            > pstats  - print NFP port statistics\n");
#ifdef CONFIG_MV_ETH_NFP_HWF
	off += mvOsSPrintf(buf+off, "echo rxp p txp txq   > hwf     - use <txp/txq> for NFP HWF flows from <rxp> to <p>\n"); 
#endif /* CONFIG_MV_ETH_NFP_HWF */
#ifdef NFP_SWF
	off += mvOsSPrintf(buf+off, "echo flow txp txq mh > swf_add - add entry to SWF engine\n");
	off += mvOsSPrintf(buf+off, "echo flow            > swf_del - delete entry to SWF engine\n");
#endif /* NFP_SWF */

	return off;
}
static ssize_t tcam_help(char *buf)
{
    int off = 0;
    
    off += mvOsSPrintf(buf+off, "cat <file>\n");
    off += mvOsSPrintf(buf+off, " sw_dump         - dump sw entry\n");
    off += mvOsSPrintf(buf+off, " hw_dump         - dump valid entries\n");
    off += mvOsSPrintf(buf+off, " hw_regs         - dump registers\n");
    off += mvOsSPrintf(buf+off, " hw_hits         - decode hit sequences\n");
    off += mvOsSPrintf(buf+off, " age_dump        - dump non-zero aging counters\n");
    off += mvOsSPrintf(buf+off, " age_dump_all    - dump all aging counters\n");
    off += mvOsSPrintf(buf+off, " age_scan        - dump aging Scanner log\n");
    off += mvOsSPrintf(buf+off, " age_reset       - reset all aging counters\n");
    
    off += mvOsSPrintf(buf+off, "echo a > <file>\n");
    off += mvOsSPrintf(buf+off, " hw_write        - write sw entry into tcam entry <a>\n");
    off += mvOsSPrintf(buf+off, " hw_read         - read tcam entry <a> into sw entry\n");
    off += mvOsSPrintf(buf+off, " hw_inv          - disable tcam entry <a>\n");
    off += mvOsSPrintf(buf+off, " hw_inv_all      - disable all tcam entries\n");
    off += mvOsSPrintf(buf+off, " hw_hits         - start recording for port <a>\n");
    off += mvOsSPrintf(buf+off, " age_clear       - clear aging counter for tcam entry <a>\n");
    off += mvOsSPrintf(buf+off, " age_cntr        - show aging counter for tcam entry <a>\n");
    off += mvOsSPrintf(buf+off, " s_rinfo         - set result info bit <a>\n");
    
    off += mvOsSPrintf(buf+off, "echo a b > <file>\n");
    off += mvOsSPrintf(buf+off, " t_offset_byte   - on offset <a> match value <b>\n");
    off += mvOsSPrintf(buf+off, " t_offset_mask   - on offset <a> use mask <b>\n");
    off += mvOsSPrintf(buf+off, " t_port          - match port value <a> with mask <b>\n");
    off += mvOsSPrintf(buf+off, " t_ainfo         - match ainfo value <a> with mask <b>\n");
    off += mvOsSPrintf(buf+off, " s_shift_update  - fill sram shift index <a> with value <b>\n");
    off += mvOsSPrintf(buf+off, " s_ainfo         - set ainfo value <a> with mask <b>\n");
    off += mvOsSPrintf(buf+off, " s_flowid        - fill sram flowid nibbles <b> from value <a>\n");
    off += mvOsSPrintf(buf+off, " s_flowid_nibble - fill sram flowid nibble <b> with value <a>\n");
    off += mvOsSPrintf(buf+off, " s_rinfo_extra   - set 2 bits value <a> to extra result info offset <b>\n");
    off += mvOsSPrintf(buf+off, " age_gr_set      - set group <b> of aging counter for tcam entry <a>\n");
    
    return off;
}
static ssize_t cls_help(struct device *dev,
				  struct device_attribute *attr, char *buf)
{
	int off = 0;
	off += mvOsSPrintf(buf+off, "cat                      help                 - print this help.\n");
	off += mvOsSPrintf(buf+off, "cat                      dscp_policy_get      - print policy of choosing dscp value.\n");
	off += mvOsSPrintf(buf+off, "cat                      vlan_prio_policy_get - print policy of choosing vlan priority value.\n");
	off += mvOsSPrintf(buf+off, "cat                      txq_policy_get       - print policy of choosing txq value.\n");
	off += mvOsSPrintf(buf+off, "cat                      txp_policy_get       - print policy of choosing txp value.\n");
	off += mvOsSPrintf(buf+off, "cat                      mh_policy_get        - print policy of choosing mh value.\n");
	off += mvOsSPrintf(buf+off, "echo [0 | 1 | 2 | 3]   > dscp_policy_set      - define policy of choosing dscp value.\n");
	off += mvOsSPrintf(buf+off, "echo [0 | 1 | 2 | 3]   > vlan_prio_policy_set - define policy of choosing vlan priority value.\n");
	off += mvOsSPrintf(buf+off, "echo [0 | 1 | 2 | 3]   > txq_policy_set       - define policy of choosing txq value.\n");
	off += mvOsSPrintf(buf+off, "echo [0 | 1 | 2 | 3]   > txp_policy_set       - define policy of choosing txp value.\n");
	off += mvOsSPrintf(buf+off, "echo [0 | 1 | 2 | 3]   > mh_policy_set        - define policy of choosing mh value.\n");

	off += mvOsSPrintf(buf+off, "\n\nParameters: 0 = highest , 1 = lowest , 2 = first , 3 = last.\n");
	return off;
}
static ssize_t hwf_nfp_debug_show(struct device *dev, struct device_attribute *attr, char *buf)
{
	unsigned int off = 0;
	MV_STATUS status;
	MV_U32 hit;
	MV_NFP_CT_KEY key;
	if (!strcmp(attr->attr.name, "first_get")) {
		status = nfp_ct_first_get(&key, &hit);
	} else if (!strcmp(attr->attr.name, "mostly_get")) {
		status = nfp_ct_mostly_used_get(&key, &hit);
	} else {
		status = nfp_ct_next_get(&key, &hit);
	}
	if (status != MV_OK) {
		off += mvOsSPrintf(buf+off,"No rules found.\n");
		return off;
	}
	if (key.family == AF_INET) {
		off += mvOsSPrintf(buf+off, "\nfamily: IPv4\n");
		off += mvOsSPrintf(buf+off, "sip: "MV_IPQUAD_FMT"\n", MV_IPQUAD(key.src_l3));
		off += mvOsSPrintf(buf+off, "dip: "MV_IPQUAD_FMT"\n", MV_IPQUAD(key.dst_l3));
	} else {
		off += mvOsSPrintf(buf+off, "\nfamily: IPv6\n");
		off += mvOsSPrintf(buf+off, "sip: "MV_IP6_FMT"\n", MV_IP6_ARG(key.src_l3));
		off += mvOsSPrintf(buf+off, "dip: "MV_IP6_FMT"\n", MV_IP6_ARG(key.dst_l3));
	}
	off += mvOsSPrintf(buf+off, "sport: %hu\n", key.sport);
	off += mvOsSPrintf(buf+off, "dport: %hu\n", key.dport);
	off += mvOsSPrintf(buf+off, "proto: %hhu\n\n", key.proto);
	off += mvOsSPrintf(buf+off, "hit counter: %d\n\n", hit);
	return off;
}
Exemple #16
0
static ssize_t mv_eth_help(char *buf)
{
	int off = 0;

	off += mvOsSPrintf(buf+off, "p, txp, txq, rxq, cpu, prio, gr, d, t, l, s - are dec numbers\n");
	off += mvOsSPrintf(buf+off, "v, tos, mask                                - are hex numbers\n");
	off += mvOsSPrintf(buf+off, "\n");

	off += sprintf(buf+off, "cat                ports           - show all ports info\n");
	off += sprintf(buf+off, "echo p d           > stack         - show pools stack for port <p>. d=0-brief, d=1-full\n");
	off += sprintf(buf+off, "echo p             > port          - show a port info\n");
	off += sprintf(buf+off, "echo p             > stats         - show a port statistics\n");
	off += sprintf(buf+off, "echo p txp         > cntrs         - show a port counters\n");
	off += sprintf(buf+off, "echo p             > tos           - show RX and TX TOS map for port <p>\n");
	off += sprintf(buf+off, "echo p             > mac           - show MAC info for port <p>\n");
	off += sprintf(buf+off, "echo p             > vprio         - show VLAN priority map for port <p>\n");
	off += sprintf(buf+off, "echo p             > napi          - show port NAPI groups: CPUs and RXQs\n");
	off += sprintf(buf+off, "echo p             > p_regs        - show port registers for <p>\n");
#ifdef MV_ETH_GMAC_NEW
	off += sprintf(buf+off, "echo p             > gmac_regs     - show gmac registers for <p>\n");
#endif /* MV_ETH_GMAC_NEW */
	off += sprintf(buf+off, "echo p rxq         > rxq_regs      - show RXQ registers for <p/rxq>\n");
	off += sprintf(buf+off, "echo p txp         > wrr_regs      - show WRR registers for <p/txp>\n");
	off += sprintf(buf+off, "echo p txp         > txp_regs      - show TX registers for <p/txp>\n");
	off += sprintf(buf+off, "echo p txp txq     > txq_regs      - show TXQ registers for <p/txp/txq>\n");
	off += sprintf(buf+off, "echo p rxq d       > rxq           - show RXQ descriptors ring for <p/rxq>. d=0-brief, d=1-full\n");
	off += sprintf(buf+off, "echo p txp txq d   > txq           - show TXQ descriptors ring for <p/txp/txq>. d=0-brief, d=1-full\n");
#ifdef CONFIG_MV_ETH_PNC
	off += sprintf(buf+off, "echo {0|1}         > pnc           - enable / disable PNC access\n");
#endif /* CONFIG_MV_ETH_PNC */
	off += sprintf(buf+off, "echo {0|1}         > skb           - enable / disable SKB recycle\n");
	off += sprintf(buf+off, "echo p {0|1}       > mh_en         - enable Marvell Header\n");
	off += sprintf(buf+off, "echo p {0|1}       > tx_nopad      - disable zero padding\n");
	off += sprintf(buf+off, "echo p v           > mh_2B         - set 2 bytes of Marvell Header\n");
	off += sprintf(buf+off, "echo p v           > tx_cmd        - set 4 bytes of TX descriptor offset 0xc\n");
	off += sprintf(buf+off, "echo p v           > debug         - bit0:rx, bit1:tx, bit2:isr, bit3:poll, bit4:dump\n");
	off += sprintf(buf+off, "echo p l s         > buf_num       - set number of long <l> and short <s> buffers allocated for port <p>\n");
	off += sprintf(buf+off, "echo p rxq tos     > rxq_tos       - set <rxq> for incoming IP packets with <tos>\n");
	off += sprintf(buf+off, "echo p gr mask     > cpu_group     - set <cpus mask>  for <port/napi group>.\n");
	off += sprintf(buf+off, "echo p gr mask     > rxq_group     - set  <rxqs mask> for <port/napi group>.\n");
	off += sprintf(buf+off, "echo p rxq prio    > rxq_vlan      - set <rxq> for incoming VLAN packets with <prio>\n");
	off += sprintf(buf+off, "echo p rxq d       > rxq_size      - set number of descriptors <d> for <port/rxq>.\n");
	off += sprintf(buf+off, "echo p rxq d       > rxq_pkts_coal - set RXQ interrupt coalesing. <d> - number of received packets\n");
	off += sprintf(buf+off, "echo p rxq d       > rxq_time_coal - set RXQ interrupt coalesing. <d> - time in microseconds\n");
	off += sprintf(buf+off, "echo p rxq t       > rxq_type      - set RXQ for different packet types. t=0-bpdu, 1-arp, 2-tcp, 3-udp\n");
	off += sprintf(buf+off, "echo p             > rx_reset      - reset RX part of the port <p>\n");
	off += sprintf(buf+off, "echo p txp         > txp_reset     - reset TX part of the port <p/txp>\n");
	off += sprintf(buf+off, "echo p txq cpu tos > txq_tos       - set <txq> for outgoing IP packets with <tos> handeled by <cpu>\n");
	off += sprintf(buf+off, "echo p txp txq cpu > txq_def       - set default <txp/txq> for packets sent to port <p> by <cpu>\n");
	off += sprintf(buf+off, "echo p txp {0|1}   > ejp           - enable/disable EJP mode for <port/txp>\n");
	off += sprintf(buf+off, "echo p txp d       > txp_rate      - set outgoing rate <d> in [kbps] for <port/txp>\n");
	off += sprintf(buf+off, "echo p txp d       > txp_burst     - set maximum burst <d> in [Bytes] for <port/txp>\n");
	off += sprintf(buf+off, "echo p txp txq d   > txq_rate      - set outgoing rate <d> in [kbps] for <port/txp/txq>\n");
	off += sprintf(buf+off, "echo p txp txq d   > txq_burst     - set maximum burst <d> in [Bytes] for <port/txp/txq>\n");
	off += sprintf(buf+off, "echo p txp txq d   > txq_wrr       - set outgoing WRR weight for <port/txp/txq>. <d=0> - fixed\n");
	off += sprintf(buf+off, "echo p txp txq d   > txq_size      - set number of descriptors <d> for <port/txp/txq>.\n");
	off += sprintf(buf+off, "echo p txp txq d   > txq_coal      - set TXP/TXQ interrupt coalesing. <d> - number of sent packets\n");
	off += sprintf(buf+off, "echo d             > tx_done       - set threshold <d> to start tx_done operations\n");
	off += sprintf(buf+off, "echo p d           > rx_weight     - set weight for the poll function; <d> - new weight, max val: 255\n");
	off += sprintf(buf+off, "echo p cpu mask    > txq_mask      - set cpu <cpu> accessible txq bitmap <mask>.\n");
	off += sprintf(buf+off, "echo p txp txq d   > txq_shared    - set/reset shared bit for <port/txp/txq>. <d> - 1/0 for set/reset.\n");
#ifdef CONFIG_MV_ETH_PNC_WOL
	off += sprintf(buf+off, "echo p wol         > wol_mode      - set port <p> pm mode. 0 wol, 1 suspend.\n");
#endif
	return off;
}