X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fethtool%2Flib%2Frte_ethtool.c;h=fabfcb2ba5a35d9611f694c6ec530cd0ac018954;hb=98a7ea332ba3da0f74ec951595d36a616165b255;hp=42e05f1fb17e8ebfa82a448f879224cefa8270cc;hpb=bda68ab9d1e73bda4d500fa6977e3d713f483de8;p=dpdk.git diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c index 42e05f1fb1..fabfcb2ba5 100644 --- a/examples/ethtool/lib/rte_ethtool.c +++ b/examples/ethtool/lib/rte_ethtool.c @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2010-2015 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2016 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -36,6 +36,9 @@ #include #include #include +#ifdef RTE_LIBRTE_IXGBE_PMD +#include +#endif #include "rte_ethtool.h" #define PKTPOOL_SIZE 512 @@ -46,13 +49,22 @@ int rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo) { struct rte_eth_dev_info dev_info; + struct rte_dev_reg_info reg_info; int n; + int ret; if (drvinfo == NULL) return -EINVAL; - if (!rte_eth_dev_is_valid_port(port_id)) - return -ENODEV; + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + + ret = rte_eth_dev_fw_version_get(port_id, drvinfo->fw_version, + sizeof(drvinfo->fw_version)); + if (ret < 0) + printf("firmware version get error: (%s)\n", strerror(-ret)); + else if (ret > 0) + printf("Insufficient fw version buffer size, " + "the minimum size should be %d\n", ret); memset(&dev_info, 0, sizeof(dev_info)); rte_eth_dev_info_get(port_id, &dev_info); @@ -61,12 +73,19 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo) dev_info.driver_name); snprintf(drvinfo->version, sizeof(drvinfo->version), "%s", rte_version()); - snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info), - "%04x:%02x:%02x.%x", - dev_info.pci_dev->addr.domain, dev_info.pci_dev->addr.bus, - dev_info.pci_dev->addr.devid, dev_info.pci_dev->addr.function); + if (dev_info.pci_dev) + snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info), + "%04x:%02x:%02x.%x", + dev_info.pci_dev->addr.domain, + dev_info.pci_dev->addr.bus, + dev_info.pci_dev->addr.devid, + dev_info.pci_dev->addr.function); + else + snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info), "N/A"); - n = rte_eth_dev_get_reg_length(port_id); + memset(®_info, 0, sizeof(reg_info)); + rte_eth_dev_get_reg_info(port_id, ®_info); + n = reg_info.length; if (n > 0) drvinfo->regdump_len = n; else @@ -87,12 +106,16 @@ rte_ethtool_get_drvinfo(uint8_t port_id, struct ethtool_drvinfo *drvinfo) int rte_ethtool_get_regs_len(uint8_t port_id) { - int count_regs; + struct rte_dev_reg_info reg_info; + int ret; - count_regs = rte_eth_dev_get_reg_length(port_id); - if (count_regs > 0) - return count_regs * sizeof(uint32_t); - return count_regs; + memset(®_info, 0, sizeof(reg_info)); + + ret = rte_eth_dev_get_reg_info(port_id, ®_info); + if (ret) + return ret; + + return reg_info.length * reg_info.width; } int @@ -120,8 +143,7 @@ rte_ethtool_get_link(uint8_t port_id) { struct rte_eth_link link; - if (!rte_eth_dev_is_valid_port(port_id)) - return -ENODEV; + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); rte_eth_link_get(port_id, &link); return link.link_status; } @@ -267,8 +289,7 @@ rte_ethtool_net_open(uint8_t port_id) int rte_ethtool_net_stop(uint8_t port_id) { - if (!rte_eth_dev_is_valid_port(port_id)) - return -ENODEV; + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); rte_eth_dev_stop(port_id); return 0; @@ -277,8 +298,7 @@ rte_ethtool_net_stop(uint8_t port_id) int rte_ethtool_net_get_mac_addr(uint8_t port_id, struct ether_addr *addr) { - if (!rte_eth_dev_is_valid_port(port_id)) - return -ENODEV; + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); if (addr == NULL) return -EINVAL; rte_eth_macaddr_get(port_id, addr); @@ -350,9 +370,12 @@ rte_ethtool_net_set_rx_mode(uint8_t port_id) num_vfs = dev_info.max_vfs; /* Set VF vf_rx_mode, VF unsupport status is discard */ - for (vf = 0; vf < num_vfs; vf++) - rte_eth_dev_set_vf_rxmode(port_id, vf, + for (vf = 0; vf < num_vfs; vf++) { +#ifdef RTE_LIBRTE_IXGBE_PMD + rte_pmd_ixgbe_set_vf_rxmode(port_id, vf, ETH_VMDQ_ACCEPT_UNTAG, 0); +#endif + } /* Enable Rx vlan filter, VF unspport status is discard */ rte_eth_dev_set_vlan_offload(port_id, ETH_VLAN_FILTER_MASK);