Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Sanitise ethtool.h and mii.h for userspace.

They shouldn't be using 'u32' et al in structures which are used for
communication with userspace. Switch to the proper types (__u32 etc).

Signed-off-by: David Woodhouse <dwmw2@infradead.org>

authored by

David Woodhouse and committed by
David Woodhouse
c3ce7e20 56142536

+101 -98
+86 -83
include/linux/ethtool.h
··· 15 15 16 16 /* This should work for both 32 and 64 bit userland. */ 17 17 struct ethtool_cmd { 18 - u32 cmd; 19 - u32 supported; /* Features this interface supports */ 20 - u32 advertising; /* Features this interface advertises */ 21 - u16 speed; /* The forced speed, 10Mb, 100Mb, gigabit */ 22 - u8 duplex; /* Duplex, half or full */ 23 - u8 port; /* Which connector port */ 24 - u8 phy_address; 25 - u8 transceiver; /* Which transceiver to use */ 26 - u8 autoneg; /* Enable or disable autonegotiation */ 27 - u32 maxtxpkt; /* Tx pkts before generating tx int */ 28 - u32 maxrxpkt; /* Rx pkts before generating rx int */ 29 - u32 reserved[4]; 18 + __u32 cmd; 19 + __u32 supported; /* Features this interface supports */ 20 + __u32 advertising; /* Features this interface advertises */ 21 + __u16 speed; /* The forced speed, 10Mb, 100Mb, gigabit */ 22 + __u8 duplex; /* Duplex, half or full */ 23 + __u8 port; /* Which connector port */ 24 + __u8 phy_address; 25 + __u8 transceiver; /* Which transceiver to use */ 26 + __u8 autoneg; /* Enable or disable autonegotiation */ 27 + __u32 maxtxpkt; /* Tx pkts before generating tx int */ 28 + __u32 maxrxpkt; /* Rx pkts before generating rx int */ 29 + __u32 reserved[4]; 30 30 }; 31 31 32 32 #define ETHTOOL_BUSINFO_LEN 32 33 33 /* these strings are set to whatever the driver author decides... */ 34 34 struct ethtool_drvinfo { 35 - u32 cmd; 35 + __u32 cmd; 36 36 char driver[32]; /* driver short name, "tulip", "eepro100" */ 37 37 char version[32]; /* driver version string */ 38 38 char fw_version[32]; /* firmware version string, if applicable */ ··· 40 40 /* For PCI devices, use pci_name(pci_dev). */ 41 41 char reserved1[32]; 42 42 char reserved2[16]; 43 - u32 n_stats; /* number of u64's from ETHTOOL_GSTATS */ 44 - u32 testinfo_len; 45 - u32 eedump_len; /* Size of data from ETHTOOL_GEEPROM (bytes) */ 46 - u32 regdump_len; /* Size of data from ETHTOOL_GREGS (bytes) */ 43 + __u32 n_stats; /* number of u64's from ETHTOOL_GSTATS */ 44 + __u32 testinfo_len; 45 + __u32 eedump_len; /* Size of data from ETHTOOL_GEEPROM (bytes) */ 46 + __u32 regdump_len; /* Size of data from ETHTOOL_GREGS (bytes) */ 47 47 }; 48 48 49 49 #define SOPASS_MAX 6 50 50 /* wake-on-lan settings */ 51 51 struct ethtool_wolinfo { 52 - u32 cmd; 53 - u32 supported; 54 - u32 wolopts; 55 - u8 sopass[SOPASS_MAX]; /* SecureOn(tm) password */ 52 + __u32 cmd; 53 + __u32 supported; 54 + __u32 wolopts; 55 + __u8 sopass[SOPASS_MAX]; /* SecureOn(tm) password */ 56 56 }; 57 57 58 58 /* for passing single values */ 59 59 struct ethtool_value { 60 - u32 cmd; 61 - u32 data; 60 + __u32 cmd; 61 + __u32 data; 62 62 }; 63 63 64 64 /* for passing big chunks of data */ 65 65 struct ethtool_regs { 66 - u32 cmd; 67 - u32 version; /* driver-specific, indicates different chips/revs */ 68 - u32 len; /* bytes */ 69 - u8 data[0]; 66 + __u32 cmd; 67 + __u32 version; /* driver-specific, indicates different chips/revs */ 68 + __u32 len; /* bytes */ 69 + __u8 data[0]; 70 70 }; 71 71 72 72 /* for passing EEPROM chunks */ 73 73 struct ethtool_eeprom { 74 - u32 cmd; 75 - u32 magic; 76 - u32 offset; /* in bytes */ 77 - u32 len; /* in bytes */ 78 - u8 data[0]; 74 + __u32 cmd; 75 + __u32 magic; 76 + __u32 offset; /* in bytes */ 77 + __u32 len; /* in bytes */ 78 + __u8 data[0]; 79 79 }; 80 80 81 81 /* for configuring coalescing parameters of chip */ 82 82 struct ethtool_coalesce { 83 - u32 cmd; /* ETHTOOL_{G,S}COALESCE */ 83 + __u32 cmd; /* ETHTOOL_{G,S}COALESCE */ 84 84 85 85 /* How many usecs to delay an RX interrupt after 86 86 * a packet arrives. If 0, only rx_max_coalesced_frames 87 87 * is used. 88 88 */ 89 - u32 rx_coalesce_usecs; 89 + __u32 rx_coalesce_usecs; 90 90 91 91 /* How many packets to delay an RX interrupt after 92 92 * a packet arrives. If 0, only rx_coalesce_usecs is ··· 94 94 * to zero as this would cause RX interrupts to never be 95 95 * generated. 96 96 */ 97 - u32 rx_max_coalesced_frames; 97 + __u32 rx_max_coalesced_frames; 98 98 99 99 /* Same as above two parameters, except that these values 100 100 * apply while an IRQ is being serviced by the host. Not 101 101 * all cards support this feature and the values are ignored 102 102 * in that case. 103 103 */ 104 - u32 rx_coalesce_usecs_irq; 105 - u32 rx_max_coalesced_frames_irq; 104 + __u32 rx_coalesce_usecs_irq; 105 + __u32 rx_max_coalesced_frames_irq; 106 106 107 107 /* How many usecs to delay a TX interrupt after 108 108 * a packet is sent. If 0, only tx_max_coalesced_frames 109 109 * is used. 110 110 */ 111 - u32 tx_coalesce_usecs; 111 + __u32 tx_coalesce_usecs; 112 112 113 113 /* How many packets to delay a TX interrupt after 114 114 * a packet is sent. If 0, only tx_coalesce_usecs is ··· 116 116 * to zero as this would cause TX interrupts to never be 117 117 * generated. 118 118 */ 119 - u32 tx_max_coalesced_frames; 119 + __u32 tx_max_coalesced_frames; 120 120 121 121 /* Same as above two parameters, except that these values 122 122 * apply while an IRQ is being serviced by the host. Not 123 123 * all cards support this feature and the values are ignored 124 124 * in that case. 125 125 */ 126 - u32 tx_coalesce_usecs_irq; 127 - u32 tx_max_coalesced_frames_irq; 126 + __u32 tx_coalesce_usecs_irq; 127 + __u32 tx_max_coalesced_frames_irq; 128 128 129 129 /* How many usecs to delay in-memory statistics 130 130 * block updates. Some drivers do not have an in-memory 131 131 * statistic block, and in such cases this value is ignored. 132 132 * This value must not be zero. 133 133 */ 134 - u32 stats_block_coalesce_usecs; 134 + __u32 stats_block_coalesce_usecs; 135 135 136 136 /* Adaptive RX/TX coalescing is an algorithm implemented by 137 137 * some drivers to improve latency under low packet rates and ··· 140 140 * not implemented by the driver causes these values to be 141 141 * silently ignored. 142 142 */ 143 - u32 use_adaptive_rx_coalesce; 144 - u32 use_adaptive_tx_coalesce; 143 + __u32 use_adaptive_rx_coalesce; 144 + __u32 use_adaptive_tx_coalesce; 145 145 146 146 /* When the packet rate (measured in packets per second) 147 147 * is below pkt_rate_low, the {rx,tx}_*_low parameters are 148 148 * used. 149 149 */ 150 - u32 pkt_rate_low; 151 - u32 rx_coalesce_usecs_low; 152 - u32 rx_max_coalesced_frames_low; 153 - u32 tx_coalesce_usecs_low; 154 - u32 tx_max_coalesced_frames_low; 150 + __u32 pkt_rate_low; 151 + __u32 rx_coalesce_usecs_low; 152 + __u32 rx_max_coalesced_frames_low; 153 + __u32 tx_coalesce_usecs_low; 154 + __u32 tx_max_coalesced_frames_low; 155 155 156 156 /* When the packet rate is below pkt_rate_high but above 157 157 * pkt_rate_low (both measured in packets per second) the ··· 162 162 * is above pkt_rate_high, the {rx,tx}_*_high parameters are 163 163 * used. 164 164 */ 165 - u32 pkt_rate_high; 166 - u32 rx_coalesce_usecs_high; 167 - u32 rx_max_coalesced_frames_high; 168 - u32 tx_coalesce_usecs_high; 169 - u32 tx_max_coalesced_frames_high; 165 + __u32 pkt_rate_high; 166 + __u32 rx_coalesce_usecs_high; 167 + __u32 rx_max_coalesced_frames_high; 168 + __u32 tx_coalesce_usecs_high; 169 + __u32 tx_max_coalesced_frames_high; 170 170 171 171 /* How often to do adaptive coalescing packet rate sampling, 172 172 * measured in seconds. Must not be zero. 173 173 */ 174 - u32 rate_sample_interval; 174 + __u32 rate_sample_interval; 175 175 }; 176 176 177 177 /* for configuring RX/TX ring parameters */ 178 178 struct ethtool_ringparam { 179 - u32 cmd; /* ETHTOOL_{G,S}RINGPARAM */ 179 + __u32 cmd; /* ETHTOOL_{G,S}RINGPARAM */ 180 180 181 181 /* Read only attributes. These indicate the maximum number 182 182 * of pending RX/TX ring entries the driver will allow the 183 183 * user to set. 184 184 */ 185 - u32 rx_max_pending; 186 - u32 rx_mini_max_pending; 187 - u32 rx_jumbo_max_pending; 188 - u32 tx_max_pending; 185 + __u32 rx_max_pending; 186 + __u32 rx_mini_max_pending; 187 + __u32 rx_jumbo_max_pending; 188 + __u32 tx_max_pending; 189 189 190 190 /* Values changeable by the user. The valid values are 191 191 * in the range 1 to the "*_max_pending" counterpart above. 192 192 */ 193 - u32 rx_pending; 194 - u32 rx_mini_pending; 195 - u32 rx_jumbo_pending; 196 - u32 tx_pending; 193 + __u32 rx_pending; 194 + __u32 rx_mini_pending; 195 + __u32 rx_jumbo_pending; 196 + __u32 tx_pending; 197 197 }; 198 198 199 199 /* for configuring link flow control parameters */ 200 200 struct ethtool_pauseparam { 201 - u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */ 201 + __u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */ 202 202 203 203 /* If the link is being auto-negotiated (via ethtool_cmd.autoneg 204 204 * being true) the user may set 'autonet' here non-zero to have the ··· 210 210 * then {rx,tx}_pause force the driver to use/not-use pause 211 211 * flow control. 212 212 */ 213 - u32 autoneg; 214 - u32 rx_pause; 215 - u32 tx_pause; 213 + __u32 autoneg; 214 + __u32 rx_pause; 215 + __u32 tx_pause; 216 216 }; 217 217 218 218 #define ETH_GSTRING_LEN 32 ··· 223 223 224 224 /* for passing string sets for data tagging */ 225 225 struct ethtool_gstrings { 226 - u32 cmd; /* ETHTOOL_GSTRINGS */ 227 - u32 string_set; /* string set id e.c. ETH_SS_TEST, etc*/ 228 - u32 len; /* number of strings in the string set */ 229 - u8 data[0]; 226 + __u32 cmd; /* ETHTOOL_GSTRINGS */ 227 + __u32 string_set; /* string set id e.c. ETH_SS_TEST, etc*/ 228 + __u32 len; /* number of strings in the string set */ 229 + __u8 data[0]; 230 230 }; 231 231 232 232 enum ethtool_test_flags { ··· 236 236 237 237 /* for requesting NIC test and getting results*/ 238 238 struct ethtool_test { 239 - u32 cmd; /* ETHTOOL_TEST */ 240 - u32 flags; /* ETH_TEST_FL_xxx */ 241 - u32 reserved; 242 - u32 len; /* result length, in number of u64 elements */ 243 - u64 data[0]; 239 + __u32 cmd; /* ETHTOOL_TEST */ 240 + __u32 flags; /* ETH_TEST_FL_xxx */ 241 + __u32 reserved; 242 + __u32 len; /* result length, in number of u64 elements */ 243 + __u64 data[0]; 244 244 }; 245 245 246 246 /* for dumping NIC-specific statistics */ 247 247 struct ethtool_stats { 248 - u32 cmd; /* ETHTOOL_GSTATS */ 249 - u32 n_stats; /* number of u64's being returned */ 250 - u64 data[0]; 248 + __u32 cmd; /* ETHTOOL_GSTATS */ 249 + __u32 n_stats; /* number of u64's being returned */ 250 + __u64 data[0]; 251 251 }; 252 252 253 253 struct ethtool_perm_addr { 254 - u32 cmd; /* ETHTOOL_GPERMADDR */ 255 - u32 size; 256 - u8 data[0]; 254 + __u32 cmd; /* ETHTOOL_GPERMADDR */ 255 + __u32 size; 256 + __u8 data[0]; 257 257 }; 258 + 259 + #ifdef __KERNEL__ 258 260 259 261 struct net_device; 260 262 ··· 373 371 u32 (*get_ufo)(struct net_device *); 374 372 int (*set_ufo)(struct net_device *, u32); 375 373 }; 374 + #endif /* __KERNEL__ */ 376 375 377 376 /* CMDs currently supported */ 378 377 #define ETHTOOL_GSET 0x00000001 /* Get settings. */
+15 -15
include/linux/mii.h
··· 9 9 #define __LINUX_MII_H__ 10 10 11 11 #include <linux/types.h> 12 - #include <linux/if.h> 13 12 14 13 /* Generic MII registers. */ 15 14 ··· 135 136 #define LPA_1000FULL 0x0800 /* Link partner 1000BASE-T full duplex */ 136 137 #define LPA_1000HALF 0x0400 /* Link partner 1000BASE-T half duplex */ 137 138 139 + /* This structure is used in all SIOCxMIIxxx ioctl calls */ 140 + struct mii_ioctl_data { 141 + __u16 phy_id; 142 + __u16 reg_num; 143 + __u16 val_in; 144 + __u16 val_out; 145 + }; 146 + 147 + #ifdef __KERNEL__ 148 + 149 + #include <linux/if.h> 150 + 151 + struct ethtool_cmd; 152 + 138 153 struct mii_if_info { 139 154 int phy_id; 140 155 int advertising; ··· 164 151 void (*mdio_write) (struct net_device *dev, int phy_id, int location, int val); 165 152 }; 166 153 167 - struct ethtool_cmd; 168 - struct mii_ioctl_data; 169 - 170 154 extern int mii_link_ok (struct mii_if_info *mii); 171 155 extern int mii_nway_restart (struct mii_if_info *mii); 172 156 extern int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd); ··· 176 166 extern int generic_mii_ioctl(struct mii_if_info *mii_if, 177 167 struct mii_ioctl_data *mii_data, int cmd, 178 168 unsigned int *duplex_changed); 179 - 180 - 181 - 182 - /* This structure is used in all SIOCxMIIxxx ioctl calls */ 183 - struct mii_ioctl_data { 184 - u16 phy_id; 185 - u16 reg_num; 186 - u16 val_in; 187 - u16 val_out; 188 - }; 189 169 190 170 191 171 static inline struct mii_ioctl_data *if_mii(struct ifreq *rq) ··· 235 235 return 0; 236 236 } 237 237 238 - 238 + #endif /* __KERNEL__ */ 239 239 #endif /* __LINUX_MII_H__ */