summaryrefslogtreecommitdiff
path: root/ethtool.c
AgeCommit message (Collapse)AuthorFilesLines
2012-06-13ethtool: Handle more errors when getting feature namesBen Hutchings1-2/+10
'ethtool -k eth0' generally works for unprivileged users, but in some kernel versions ETHTOOL_GSSET_INFO wrongly returns -EPERM. We need to fall back to the old offload operations in this case. Also, if we get some other error code, report that before exiting. Add regression test cases covering this and some other operations that may fail (which were already handled correctly). Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2012-06-02Change -k/-K options to use ETHTOOL_{G,S}FEATURESBen Hutchings1-92/+356
Rewrite the offload get and set functions to use the generic features API where available, while maintaining a similar output format. Add the long options --show-features and --features as additional aliases for -k and -K. Where there is exactly one named feature corresponding to an old offload name, show the feature using the old offload name. Where there are multiple features corresponding to an old offload name, show the features as a group, indented underneath it. Add some test cases to check that this works properly with or without the generic features API. (These may well be insufficient.) Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2012-06-02Report when offload feature changes are not exactly as requestedBen Hutchings1-20/+45
When an offload feature is enabled or disabled, this can change the state of other features that depend on it, or may itself be deferred if it depends on a feature that is disabled. Report when this happens, and fail if no offload features could be changed. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2012-06-02Regularise offload feature settingsBen Hutchings1-202/+89
This is partly preparation for use of the new net device features API, but is useful in its own right. Replace repetitive code for getting/setting offload flags with data- driven loops. This changes error messages to use the same long names for offload flags as in dump_offload(), and changes various exit codes to 1. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2012-06-01Add output file parameter to dump_hex() and make it externBen Hutchings1-9/+10
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2012-05-23Run tests in-processBen Hutchings1-6/+3
Wrap main(), exit(), and resource management so that ethtool commands can be tested without starting a new process and without leaking. This will allow deeper teesting that covers ioctl requests and responses. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2012-05-23ethtool: Addition of -m option to dump module eepromStuart Hodgson1-0/+87
The -m option now allows for retrieval of EEPROM information form a plug in module such as SFP+. This shows specific information about the type and capabilities of the module in use The format can be easily extended to support other modules types such as QSFP in future. Raw data dump is also supported. Signed-off-by: Stuart Hodgson <smhodgson@solarflare.com> Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2012-05-23ethtool: Split out printing of hex dataStuart Hodgson1-17/+18
Split out printing of hex data to common function from dump_regs and dump_eeprom. Ready for use by module eeprom dumping. Signed-off-by: Stuart Hodgson <smhodgson@solarflare.com> [bwh: Line up columns like the version in dump_eeprom(), not dump_regs()] Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2012-05-23Add the command to show the time stamping capabilities.Richard Cochran1-0/+104
Signed-off-by: Richard Cochran <richardcochran@gmail.com> [bwh: Rename the long option to '--show-time-stamping'] Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2012-01-21Merge RX NFC optionsBen Hutchings1-102/+76
Santwona Behera originally intended to extend the -n and -N options to cover querying and setting rules as well as flow hash options. However, his patch fell between the cracks and the ethtool utility got n-tuple support first, using the -u and -U options. When RX NFC rule support was finally added I insisted that it should not require different command syntax, so rules must be accessed through these options. The sets of valid argument lists following the -n and -u options are still non-overlapping, and similarly for the -N and -U options. Since the top level argument parser now supports arbitrary numbers of option aliases, we can merge these pairs together and achieve the original intent. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2012-01-20Move '--flash' down the list of optionsBen Hutchings1-3/+3
It doesn't make sense to to list it between the two RX NFC options in the online help. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2012-01-12rxclass: Use RX_CLS_LOC_{ANY,SPECIAL} in place of RX_CLS_LOC_UNSPECBen Hutchings1-1/+1
The macro RX_CLS_LOC_ANY is now defined in ethtool(-copy).h with the same intended semantics and same value as RX_CLS_LOC_UNSPEC. Change some equality tests to check for the flag RX_CLS_LOC_SPECIAL, to allow for future support of other special location value. Remove the special case for RX_CLS_LOC_UNSPEC in rxclass_print_nfc_rule(), since it is dead code. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-12-02Add support for querying and setting private flagsBen Hutchings1-2/+103
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-11-30Implement and use a generic get_stringset() functionBen Hutchings1-54/+67
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-11-03Rearrange definitions and remove unnecessary forward declarationsBen Hutchings1-243/+204
Most functions in ethtool.c are defined before use. The major exception is that the args array refers to a large number of functions defined after it. Move the args array and show_usage() functions down, and move a few other functions up. This leaves just one forward declaration in ethtool.c, which is unavoidable because show_usage() and args refer to each other. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-11-03Declare static variables const as appropriateBen Hutchings1-2/+2
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-11-03Change most static global variables into automatic variablesBen Hutchings1-260/+293
This is necessary preparation for in-process testing. It should also reduce the risk of some classes of bug by putting declaration and use closer together. Add parameters to various functions as necessary. Leave the global constants alone. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-11-03Replace global devname variable with a field in struct cmd_contextBen Hutchings1-13/+11
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-11-03Convert cmdline_msglvl into array of named flags; convert back at run-timeBen Hutchings1-35/+44
cmdline_msglvl is used both in do_gset() and do_sset(), but it refers to variables only used in do_sset(). I want to get rid of the global variables without duplicating the flag definitions. So separate out the flag definitions into a new structure and generate cmdline_msglvl from that at run-time. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-11-03Fix reference to cmdline_ring in do_schannels()Ben Hutchings1-1/+1
cmdline_ring and cmdline_channels have the same array size, so this just happened to work. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-11-03Support arbitrary numbers of option names for each modeBen Hutchings1-52/+58
Instead of supporting a single short and long option for each mode, take a string of options separated by "|" (matching the way they are displayed in online help). Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-11-03Move argument parsing to sub-command functionsBen Hutchings1-606/+382
Instead of doing most of the argument parsing in parse_cmdline(), find the sub-command and (if required) the device name in main() and do the rest in the sub-command handler function. Pass argc and argp around in struct cmd_context. This also tightens up argument parsing slightly: extraneous or missing arguments will now result in an error in a few cases where they were previously ignored. All test cases now pass. Replace sub-command dispatch in doit() with a function pointer in struct option. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-11-03Add test cases for command-line parsingBen Hutchings1-0/+5
Preparation for refactoring command-line parsing. All these test cases pass. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-11-01Encapsulate command context in a structureBen Hutchings1-245/+174
Replace the fd and ifr arguments to each sub-command handler with struct cmd_context. Change send_ioctl() to take a pointer to this context and a pointer to the ethtool_cmd or other structure. Use send_ioctl() consistently. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-11-01Use standard indentation for definition of struct option argsBen Hutchings1-138/+142
Also put the whole of the help string on a line of its own where necessary. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-11-01Fix format of help text for -f optionBen Hutchings1-2/+2
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-11-01Combine ethtool-{bitops,util}.h into internal.hBen Hutchings1-1/+1
ethtool-util.h contains all kinds of declarations, not just utility functions or macros. ethtool-bitops.h contains just a few extra definitions, and its only user also includes ethtool-util.h. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-10-28Report pause frame autonegotiation resultBen Hutchings1-6/+40
If pause frame autonegotiation is enabled and the driver reports the link partner's advertising flags, report the result of autonegotiation. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-10-17ethtool: add ETHTOOL_{G,S}CHANNEL support.Sucheta Chakraborty1-0/+120
Used to configure number of tx/ rx/ other channels. Reqd. man page changes are included. Signed-off-by: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com> Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-10-04ethtool: add support for external loopback.Sucheta Chakraborty1-2/+12
External loopback will be performed in addition to other offline tests. User need to pass new parameter "external_lb" for the same. Reqd. man page changes included. Signed-off-by: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com> [bwh: Report whether the external loopback test 'was', not 'is' executed. For compatibility, don't report this if not requested.] Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-07-14Correct parameter types for ethtool -e and ethtool -EBen Hutchings1-16/+24
All parameters to the underlying ethtool commands are unsigned, not signed. In particular, the 'magic' parameter to ethtool -E often has the most significant bit set and users should not have to provide it as a negative number. For ethtool -E, the value to be written is 8-bit, not 32-bit. Reported-by: Jens Rottmann <JRottmann@LiPPERTEmbedded.de> Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-06-06ethtool: Add support for 20G link speedYaniv Rosner1-1/+17
Signed-off-by: Yaniv Rosner <yanivr@broadcom.com>
2011-06-02Fix type mismatch for field width argument to fprintf()Ben Hutchings1-1/+1
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-06-02ethtool: Added FW dump supportAnirban Chakraborty1-1/+119
Added support to take FW dump via ethtool. Signed-off-by: Anirban Chakraborty <anirban.chakraborty@qlogic.com> Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-06-01Combine code to display supported and advertised link capabilitiesBen Hutchings1-59/+21
Rename dump_advertised() to dump_link_caps(), and change dump_supported() to call it instead of repeating nearly identical code. Add a separate prefix parameter and adjust indentation so that the output is unchanged except for added lines. Deleted unused parameter and variables. As an immediate benefit, this adds the display of supported pause frame use. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-06-01ethtool: mask out FLOW_EXTSebastian Pöhn1-0/+3
The FLOW_EXT bit must be masked out. Otherwise if e.g. vlan is set a driver receiving the ntuple may not detect the flow_type correctly! Signed-off-by: Sebastian Poehn <sebastian.poehn@belden.com> [bwh: Fixed spacing] Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-05-13ethtool: Treat positive return from ETHTOOL_SRXNTUPLE as successfulBen Hutchings1-3/+6
The sfc driver can currently return a positive value (the filter index) on success. This is a bug in the driver, but ethtool previously accepted it. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-05-13Add RX packet classification interfaceAlexander Duyck1-173/+227
This patch was originally introduced as: [PATCH 1/3] [ethtool] Add rx pkt classification interface Signed-off-by: Santwona Behera <santwona.behera@sun.com> http://patchwork.ozlabs.org/patch/23223/ I removed the local caching of rules. I dropped the use of regions as there were multiple issues found. A network flow classifier is defined using the exact same syntax as n-tuple, and the tool will correct for the fact that NFC uses the 1's compliment of the n-tuple mask. I also updated the ordering of new rules being added. All new rules will take the highest numbered open rule when no location is specified. I split out the addition of bitops and the updates to documentation into separate patches. This makes the total patch size a bit more manageable since the addition of NFC and the merging of it with n-tuple were combined into this patch. If we setup a rule and the device has the NTUPLE flag set we will first try to use set_rx_ntuple. If that fails with EOPNOTSUPP we then will attempt to use the network flow classifier rule insertion. Updated the output to make use of the updated network flow classifier extensions that have been accepted into the kernel. Merged the documentation update into this patch. In addition the documentation changes were made such that there is only one listing of the individual options and they are all listed as optional. Several fixes to address things such as the fact that we were maintaining the table logic even though we only need it for displaying all of the rules, or when adding a rule with no location specified. As such all of the logic for deleting or finding rules in the table has been removed. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> [bwh: Abbreviated the above commit message. Fixed a minor formatting error in the manual page additions.] Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-05-13Cleanup defines and header includes to address several issuesAlexander Duyck1-16/+1
This change is meant to address several issues. First it moves the check for ethtool-config.h into ethtool-util.h the reason for this change is so that any references to ethtool-util.h outside of ethtool.c will use the correct defines for the endian types. In addition I have pulled several headers that will be common to both ethtool.c and rxclass.c into the ethtool-util.h header file. I am also centralizing several macros that will be needed across multiple files when I implement the network flow classifier rules. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-05-13ethtool: remove strings based approach for displaying n-tupleAlexander Duyck1-44/+0
This change is meant to remove the strings based approach for displaying n-tuple filters. A follow-on patch will replace that functionality with a network flow classification based approach that will get the number of filters, get their locations, and then request and display them individually. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-04-27Add support for ESP as a separate protocol from AHAlexander Duyck1-9/+12
This change is mostly cosmetic. NIU had supported AH and ESP seperately. As such it is possible that a return value of ESP or AH may be returned for a has request instead of the AH_ESP combined value. To resolve that the inputs are combined for AH and ESP into the AH_ESP value and return values for AH and ESP will display the combined string info. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
2011-03-18ethtool: Report driver features described in struct ethtool_drvinfoBen Hutchings1-2/+10
ETHTOOL_GDRVINFO fills out struct ethtool_drvinfo with the size of the data returned by various other operations. The size should be non-zero if and only if the driver implements that operation. Therefore, we can report whether the driver supports certain operations without actually trying them (which may be expensive and disruptive). Do this in dump_drvinfo() rather than adding a separation operation. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-02-21ethtool: Add --version optionBen Hutchings1-0/+6
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-02-21ethtool: Indent the no-options usage line consistently with the othersBen Hutchings1-1/+2
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-02-21ethtool: Allow for long options with no short option and without a device nameBen Hutchings1-9/+14
Change loop conditions to check for a long option string. Generalise check for whether option requires a device name. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-02-21ethtool: Report an error if given an unrecognised optionBen Hutchings1-2/+3
Previously we would print full usage information and return 0. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-02-21ethtool: Split show_usage() into two functionsBen Hutchings1-71/+73
show_usage(0) and show_usage(1) now do unrelated things; split it into show_usage() and exit_bad_args(). Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-02-18ethtool: Don't silently ignore speed/duplex when autoneg is onBen Hutchings1-14/+31
When autonegotiation is enabled, drivers must determine link speed and duplex through the autonegotiation process and will generally ignore the speed and duplex specified in struct ethtool_cmd. Currently, if the user specifies autoneg on but does not specify the advertising mask then: - If the user specifies a recognised combination of speed and duplex, we set the advertising mask to the flag for that mode. (Currently only one mode is recognised per combination of speed and duplex.) - Otherwise, we advertise all recognised and supported modes. But we should also set the advertising mask if autoneg is *already* on. Also, we should be able to limit the advertised modes separately by speed and duplex. For now, we just warn if we fail to do that. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2011-01-10ethtool: Fix spelling and spacing in online helpBen Hutchings1-2/+2
Kelly Anderson <kelly@silka.with-linux.com> pointed out that the help for --show-nfc was missing a space between two words. I checked the rest of the help text with aspell and found one other error. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
2010-12-15ethtool: Remove suggested change of no-args behaviour from the TODO listBen Hutchings1-1/+1
ethtool can show information about many more settings than mii-tool. It would be useful to have the option to show certain settings for all interfaces, but this should not be restricted to the basic settings. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>