As we know we can use ethtool -k to get features of Ethernet devices, and we can use ethtool -K to change the featueres' status.
I want to change some features of Ethernet devices in my C program.
I want to use ioctl with ETHTOOL_SFEATURES to do this:
#define ETHTOOL_SFEATURES 0x0000003b /* Change device offload settings */
I think maybe I need to pass an argument of struct ethtool_sfeatures to ioctl:
/**
* struct ethtool_set_features_block - block with request for 32 features
* @valid: mask of features to be changed
* @requested: values of features to be changed
*/
struct ethtool_set_features_block {
__u32 valid;
__u32 requested;
};
/**
* struct ethtool_sfeatures - command to request change in device's features
* @cmd: command number = %ETHTOOL_SFEATURES
* @size: array size of the features[] array
* @features: feature change masks
*/
struct ethtool_sfeatures {
__u32 cmd;
__u32 size;
struct ethtool_set_features_block features[0];
};
But I don't know what the valid of ethtool_set_features_block should be and I don't know what does the mask mean in comments.
I tried to compile ethtool with -g and debug when I use ethtool -K to change a feature, and I can get a mask, but I want to know if the mask would be different in different computer or in different Ethernet devices?
Maybe I should try to get mask of features every time before changing it so that I won't use mask which may be wrong?
User contributions licensed under CC BY-SA 3.0