History

ethtool: add speed/duplex validation functions

Add functions which check if the speed/duplex are defined.

Nikolay Aleksandrov committed 10 years ago

Commit 103a8ad1 parent 13340a01 file · +34 −0Browse files

Showing the changes to include/uapi (1 of 1 file). Show all

Unified · Split

include/uapi/linux/ethtool.h+34−0
@@ -1319,11 +1319,45 @@ enum ethtool_sfeatures_retval_bits { · 1318 unmodified lines
1319 1319
1320#define SPEED_UNKNOWN -11320#define SPEED_UNKNOWN -1
1321 1321
1322static inline int ethtool_validate_speed(__u32 speed)
1323{
1324 switch (speed) {
1325 case SPEED_10:
1326 case SPEED_100:
1327 case SPEED_1000:
1328 case SPEED_2500:
1329 case SPEED_5000:
1330 case SPEED_10000:
1331 case SPEED_20000:
1332 case SPEED_25000:
1333 case SPEED_40000:
1334 case SPEED_50000:
1335 case SPEED_56000:
1336 case SPEED_100000:
1337 case SPEED_UNKNOWN:
1338 return 1;
1339 }
1340
1341 return 0;
1342}
1343
1322/* Duplex, half or full. */1344/* Duplex, half or full. */
1323#define DUPLEX_HALF 0x001345#define DUPLEX_HALF 0x00
1324#define DUPLEX_FULL 0x011346#define DUPLEX_FULL 0x01
1325#define DUPLEX_UNKNOWN 0xff1347#define DUPLEX_UNKNOWN 0xff
1326 1348
1349static inline int ethtool_validate_duplex(__u8 duplex)
1350{
1351 switch (duplex) {
1352 case DUPLEX_HALF:
1353 case DUPLEX_FULL:
1354 case DUPLEX_UNKNOWN:
1355 return 1;
1356 }
1357
1358 return 0;
1359}
1360
1327/* Which connector port. */1361/* Which connector port. */
1328#define PORT_TP 0x001362#define PORT_TP 0x00
1329#define PORT_AUI 0x011363#define PORT_AUI 0x01

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t