1*a9643ea8Slogwang 2*a9643ea8Slogwang.. BSD LICENSE 3*a9643ea8Slogwang Copyright(c) 2015 Intel Corporation. All rights reserved. 4*a9643ea8Slogwang All rights reserved. 5*a9643ea8Slogwang 6*a9643ea8Slogwang Redistribution and use in source and binary forms, with or without 7*a9643ea8Slogwang modification, are permitted provided that the following conditions 8*a9643ea8Slogwang are met: 9*a9643ea8Slogwang 10*a9643ea8Slogwang * Redistributions of source code must retain the above copyright 11*a9643ea8Slogwang notice, this list of conditions and the following disclaimer. 12*a9643ea8Slogwang * Redistributions in binary form must reproduce the above copyright 13*a9643ea8Slogwang notice, this list of conditions and the following disclaimer in 14*a9643ea8Slogwang the documentation and/or other materials provided with the 15*a9643ea8Slogwang distribution. 16*a9643ea8Slogwang * Neither the name of Intel Corporation nor the names of its 17*a9643ea8Slogwang contributors may be used to endorse or promote products derived 18*a9643ea8Slogwang from this software without specific prior written permission. 19*a9643ea8Slogwang 20*a9643ea8Slogwang THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21*a9643ea8Slogwang "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22*a9643ea8Slogwang LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23*a9643ea8Slogwang A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24*a9643ea8Slogwang OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25*a9643ea8Slogwang SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26*a9643ea8Slogwang LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27*a9643ea8Slogwang DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28*a9643ea8Slogwang THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29*a9643ea8Slogwang (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30*a9643ea8Slogwang OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31*a9643ea8Slogwang 32*a9643ea8SlogwangEthtool Sample Application 33*a9643ea8Slogwang========================== 34*a9643ea8Slogwang 35*a9643ea8SlogwangThe Ethtool sample application shows an implementation of an 36*a9643ea8Slogwangethtool-like API and provides a console environment that allows 37*a9643ea8Slogwangits use to query and change Ethernet card parameters. The sample 38*a9643ea8Slogwangis based upon a simple L2 frame reflector. 39*a9643ea8Slogwang 40*a9643ea8SlogwangCompiling the Application 41*a9643ea8Slogwang------------------------- 42*a9643ea8Slogwang 43*a9643ea8SlogwangTo compile the application: 44*a9643ea8Slogwang 45*a9643ea8Slogwang#. Go to the sample application directory: 46*a9643ea8Slogwang 47*a9643ea8Slogwang .. code-block:: console 48*a9643ea8Slogwang 49*a9643ea8Slogwang export RTE_SDK=/path/to/rte_sdk 50*a9643ea8Slogwang cd ${RTE_SD}/examples/ethtool 51*a9643ea8Slogwang 52*a9643ea8Slogwang#. Set the target (a default target is used if not specified). For example: 53*a9643ea8Slogwang 54*a9643ea8Slogwang .. code-block:: console 55*a9643ea8Slogwang 56*a9643ea8Slogwang export RTE_TARGET=x86_64-native-linuxapp-gcc 57*a9643ea8Slogwang 58*a9643ea8Slogwang See the *DPDK Getting Started Guide* for possible RTE_TARGET values. 59*a9643ea8Slogwang 60*a9643ea8Slogwang#. Build the application: 61*a9643ea8Slogwang 62*a9643ea8Slogwang .. code-block:: console 63*a9643ea8Slogwang 64*a9643ea8Slogwang make 65*a9643ea8Slogwang 66*a9643ea8SlogwangRunning the Application 67*a9643ea8Slogwang----------------------- 68*a9643ea8Slogwang 69*a9643ea8SlogwangThe application requires an available core for each port, plus one. 70*a9643ea8SlogwangThe only available options are the standard ones for the EAL: 71*a9643ea8Slogwang 72*a9643ea8Slogwang.. code-block:: console 73*a9643ea8Slogwang 74*a9643ea8Slogwang ./ethtool-app/ethtool-app/${RTE_TARGET}/ethtool [EAL options] 75*a9643ea8Slogwang 76*a9643ea8SlogwangRefer to the *DPDK Getting Started Guide* for general information on 77*a9643ea8Slogwangrunning applications and the Environment Abstraction Layer (EAL) 78*a9643ea8Slogwangoptions. 79*a9643ea8Slogwang 80*a9643ea8SlogwangUsing the application 81*a9643ea8Slogwang--------------------- 82*a9643ea8Slogwang 83*a9643ea8SlogwangThe application is console-driven using the cmdline DPDK interface: 84*a9643ea8Slogwang 85*a9643ea8Slogwang.. code-block:: console 86*a9643ea8Slogwang 87*a9643ea8Slogwang EthApp> 88*a9643ea8Slogwang 89*a9643ea8SlogwangFrom this interface the available commands and descriptions of what 90*a9643ea8Slogwangthey do as as follows: 91*a9643ea8Slogwang 92*a9643ea8Slogwang* ``drvinfo``: Print driver info 93*a9643ea8Slogwang* ``eeprom``: Dump EEPROM to file 94*a9643ea8Slogwang* ``link``: Print port link states 95*a9643ea8Slogwang* ``macaddr``: Gets/sets MAC address 96*a9643ea8Slogwang* ``mtu``: Set NIC MTU 97*a9643ea8Slogwang* ``open``: Open port 98*a9643ea8Slogwang* ``pause``: Get/set port pause state 99*a9643ea8Slogwang* ``portstats``: Print port statistics 100*a9643ea8Slogwang* ``regs``: Dump port register(s) to file 101*a9643ea8Slogwang* ``ringparam``: Get/set ring parameters 102*a9643ea8Slogwang* ``rxmode``: Toggle port Rx mode 103*a9643ea8Slogwang* ``stop``: Stop port 104*a9643ea8Slogwang* ``validate``: Check that given MAC address is valid unicast address 105*a9643ea8Slogwang* ``vlan``: Add/remove VLAN id 106*a9643ea8Slogwang* ``quit``: Exit program 107*a9643ea8Slogwang 108*a9643ea8Slogwang 109*a9643ea8SlogwangExplanation 110*a9643ea8Slogwang----------- 111*a9643ea8Slogwang 112*a9643ea8SlogwangThe sample program has two parts: A background `packet reflector`_ 113*a9643ea8Slogwangthat runs on a slave core, and a foreground `Ethtool Shell`_ that 114*a9643ea8Slogwangruns on the master core. These are described below. 115*a9643ea8Slogwang 116*a9643ea8SlogwangPacket Reflector 117*a9643ea8Slogwang~~~~~~~~~~~~~~~~ 118*a9643ea8Slogwang 119*a9643ea8SlogwangThe background packet reflector is intended to demonstrate basic 120*a9643ea8Slogwangpacket processing on NIC ports controlled by the Ethtool shim. 121*a9643ea8SlogwangEach incoming MAC frame is rewritten so that it is returned to 122*a9643ea8Slogwangthe sender, using the port in question's own MAC address as the 123*a9643ea8Slogwangsource address, and is then sent out on the same port. 124*a9643ea8Slogwang 125*a9643ea8SlogwangEthtool Shell 126*a9643ea8Slogwang~~~~~~~~~~~~~ 127*a9643ea8Slogwang 128*a9643ea8SlogwangThe foreground part of the Ethtool sample is a console-based 129*a9643ea8Slogwanginterface that accepts commands as described in `using the 130*a9643ea8Slogwangapplication`_. Individual call-back functions handle the detail 131*a9643ea8Slogwangassociated with each command, which make use of the functions 132*a9643ea8Slogwangdefined in the `Ethtool interface`_ to the DPDK functions. 133*a9643ea8Slogwang 134*a9643ea8SlogwangEthtool interface 135*a9643ea8Slogwang----------------- 136*a9643ea8Slogwang 137*a9643ea8SlogwangThe Ethtool interface is built as a separate library, and implements 138*a9643ea8Slogwangthe following functions: 139*a9643ea8Slogwang 140*a9643ea8Slogwang- ``rte_ethtool_get_drvinfo()`` 141*a9643ea8Slogwang- ``rte_ethtool_get_regs_len()`` 142*a9643ea8Slogwang- ``rte_ethtool_get_regs()`` 143*a9643ea8Slogwang- ``rte_ethtool_get_link()`` 144*a9643ea8Slogwang- ``rte_ethtool_get_eeprom_len()`` 145*a9643ea8Slogwang- ``rte_ethtool_get_eeprom()`` 146*a9643ea8Slogwang- ``rte_ethtool_set_eeprom()`` 147*a9643ea8Slogwang- ``rte_ethtool_get_pauseparam()`` 148*a9643ea8Slogwang- ``rte_ethtool_set_pauseparam()`` 149*a9643ea8Slogwang- ``rte_ethtool_net_open()`` 150*a9643ea8Slogwang- ``rte_ethtool_net_stop()`` 151*a9643ea8Slogwang- ``rte_ethtool_net_get_mac_addr()`` 152*a9643ea8Slogwang- ``rte_ethtool_net_set_mac_addr()`` 153*a9643ea8Slogwang- ``rte_ethtool_net_validate_addr()`` 154*a9643ea8Slogwang- ``rte_ethtool_net_change_mtu()`` 155*a9643ea8Slogwang- ``rte_ethtool_net_get_stats64()`` 156*a9643ea8Slogwang- ``rte_ethtool_net_vlan_rx_add_vid()`` 157*a9643ea8Slogwang- ``rte_ethtool_net_vlan_rx_kill_vid()`` 158*a9643ea8Slogwang- ``rte_ethtool_net_set_rx_mode()`` 159*a9643ea8Slogwang- ``rte_ethtool_get_ringparam()`` 160*a9643ea8Slogwang- ``rte_ethtool_set_ringparam()`` 161