hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/include/linux/ethtool.h
....@@ -18,8 +18,6 @@
1818 #include <linux/android_kabi.h>
1919 #include <uapi/linux/ethtool.h>
2020
21
-#ifdef CONFIG_COMPAT
22
-
2321 struct compat_ethtool_rx_flow_spec {
2422 u32 flow_type;
2523 union ethtool_flow_union h_u;
....@@ -36,10 +34,8 @@
3634 compat_u64 data;
3735 struct compat_ethtool_rx_flow_spec fs;
3836 u32 rule_cnt;
39
- u32 rule_locs[0];
37
+ u32 rule_locs[];
4038 };
41
-
42
-#endif /* CONFIG_COMPAT */
4339
4440 #include <linux/rculist.h>
4541
....@@ -87,6 +83,22 @@
8783 u32 ethtool_op_get_link(struct net_device *dev);
8884 int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *eti);
8985
86
+
87
+/**
88
+ * struct ethtool_link_ext_state_info - link extended state and substate.
89
+ */
90
+struct ethtool_link_ext_state_info {
91
+ enum ethtool_link_ext_state link_ext_state;
92
+ union {
93
+ enum ethtool_link_ext_substate_autoneg autoneg;
94
+ enum ethtool_link_ext_substate_link_training link_training;
95
+ enum ethtool_link_ext_substate_link_logical_mismatch link_logical_mismatch;
96
+ enum ethtool_link_ext_substate_bad_signal_integrity bad_signal_integrity;
97
+ enum ethtool_link_ext_substate_cable_issue cable_issue;
98
+ u8 __link_ext_substate;
99
+ };
100
+};
101
+
90102 /**
91103 * ethtool_rxfh_indir_default - get default value for RX flow hash indirection
92104 * @index: Index in RX flow hash indirection table
....@@ -98,10 +110,6 @@
98110 {
99111 return index % n_rx_rings;
100112 }
101
-
102
-/* number of link mode bits/ulongs handled internally by kernel */
103
-#define __ETHTOOL_LINK_MODE_MASK_NBITS \
104
- (__ETHTOOL_LINK_MODE_LAST + 1)
105113
106114 /* declare a link mode bitmap */
107115 #define __ETHTOOL_DECLARE_LINK_MODE_MASK(name) \
....@@ -161,7 +169,6 @@
161169 #define ethtool_link_ksettings_test_link_mode(ptr, name, mode) \
162170 test_bit(ETHTOOL_LINK_MODE_ ## mode ## _BIT, (ptr)->link_modes.name)
163171
164
-#ifdef CONFIG_ETHTOOL
165172 extern int
166173 __ethtool_get_link_ksettings(struct net_device *dev,
167174 struct ethtool_link_ksettings *link_ksettings);
....@@ -182,44 +189,79 @@
182189 /* return false if src had higher bits set. lower bits always updated. */
183190 bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32,
184191 const unsigned long *src);
185
-#else
186
-static inline int
187
-__ethtool_get_link_ksettings(struct net_device *dev,
188
- struct ethtool_link_ksettings *link_ksettings)
189
-{
190
- return 0;
191
-}
192192
193
-static inline
194
-void ethtool_intersect_link_masks(struct ethtool_link_ksettings *dst,
195
- struct ethtool_link_ksettings *src)
196
-{
197
-}
193
+#define ETHTOOL_COALESCE_RX_USECS BIT(0)
194
+#define ETHTOOL_COALESCE_RX_MAX_FRAMES BIT(1)
195
+#define ETHTOOL_COALESCE_RX_USECS_IRQ BIT(2)
196
+#define ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ BIT(3)
197
+#define ETHTOOL_COALESCE_TX_USECS BIT(4)
198
+#define ETHTOOL_COALESCE_TX_MAX_FRAMES BIT(5)
199
+#define ETHTOOL_COALESCE_TX_USECS_IRQ BIT(6)
200
+#define ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ BIT(7)
201
+#define ETHTOOL_COALESCE_STATS_BLOCK_USECS BIT(8)
202
+#define ETHTOOL_COALESCE_USE_ADAPTIVE_RX BIT(9)
203
+#define ETHTOOL_COALESCE_USE_ADAPTIVE_TX BIT(10)
204
+#define ETHTOOL_COALESCE_PKT_RATE_LOW BIT(11)
205
+#define ETHTOOL_COALESCE_RX_USECS_LOW BIT(12)
206
+#define ETHTOOL_COALESCE_RX_MAX_FRAMES_LOW BIT(13)
207
+#define ETHTOOL_COALESCE_TX_USECS_LOW BIT(14)
208
+#define ETHTOOL_COALESCE_TX_MAX_FRAMES_LOW BIT(15)
209
+#define ETHTOOL_COALESCE_PKT_RATE_HIGH BIT(16)
210
+#define ETHTOOL_COALESCE_RX_USECS_HIGH BIT(17)
211
+#define ETHTOOL_COALESCE_RX_MAX_FRAMES_HIGH BIT(18)
212
+#define ETHTOOL_COALESCE_TX_USECS_HIGH BIT(19)
213
+#define ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGH BIT(20)
214
+#define ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL BIT(21)
198215
199
-static inline
200
-void ethtool_convert_legacy_u32_to_link_mode(unsigned long *dst,
201
- u32 legacy_u32)
202
-{
203
-}
216
+#define ETHTOOL_COALESCE_USECS \
217
+ (ETHTOOL_COALESCE_RX_USECS | ETHTOOL_COALESCE_TX_USECS)
218
+#define ETHTOOL_COALESCE_MAX_FRAMES \
219
+ (ETHTOOL_COALESCE_RX_MAX_FRAMES | ETHTOOL_COALESCE_TX_MAX_FRAMES)
220
+#define ETHTOOL_COALESCE_USECS_IRQ \
221
+ (ETHTOOL_COALESCE_RX_USECS_IRQ | ETHTOOL_COALESCE_TX_USECS_IRQ)
222
+#define ETHTOOL_COALESCE_MAX_FRAMES_IRQ \
223
+ (ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ | \
224
+ ETHTOOL_COALESCE_TX_MAX_FRAMES_IRQ)
225
+#define ETHTOOL_COALESCE_USE_ADAPTIVE \
226
+ (ETHTOOL_COALESCE_USE_ADAPTIVE_RX | ETHTOOL_COALESCE_USE_ADAPTIVE_TX)
227
+#define ETHTOOL_COALESCE_USECS_LOW_HIGH \
228
+ (ETHTOOL_COALESCE_RX_USECS_LOW | ETHTOOL_COALESCE_TX_USECS_LOW | \
229
+ ETHTOOL_COALESCE_RX_USECS_HIGH | ETHTOOL_COALESCE_TX_USECS_HIGH)
230
+#define ETHTOOL_COALESCE_MAX_FRAMES_LOW_HIGH \
231
+ (ETHTOOL_COALESCE_RX_MAX_FRAMES_LOW | \
232
+ ETHTOOL_COALESCE_TX_MAX_FRAMES_LOW | \
233
+ ETHTOOL_COALESCE_RX_MAX_FRAMES_HIGH | \
234
+ ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGH)
235
+#define ETHTOOL_COALESCE_PKT_RATE_RX_USECS \
236
+ (ETHTOOL_COALESCE_USE_ADAPTIVE_RX | \
237
+ ETHTOOL_COALESCE_RX_USECS_LOW | ETHTOOL_COALESCE_RX_USECS_HIGH | \
238
+ ETHTOOL_COALESCE_PKT_RATE_LOW | ETHTOOL_COALESCE_PKT_RATE_HIGH | \
239
+ ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL)
204240
205
-static inline
206
-bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32,
207
- const unsigned long *src)
208
-{
209
- return false;
210
-}
211
-#endif
241
+#define ETHTOOL_STAT_NOT_SET (~0ULL)
242
+
243
+/**
244
+ * struct ethtool_pause_stats - statistics for IEEE 802.3x pause frames
245
+ * @tx_pause_frames: transmitted pause frame count. Reported to user space
246
+ * as %ETHTOOL_A_PAUSE_STAT_TX_FRAMES.
247
+ *
248
+ * Equivalent to `30.3.4.2 aPAUSEMACCtrlFramesTransmitted`
249
+ * from the standard.
250
+ *
251
+ * @rx_pause_frames: received pause frame count. Reported to user space
252
+ * as %ETHTOOL_A_PAUSE_STAT_RX_FRAMES. Equivalent to:
253
+ *
254
+ * Equivalent to `30.3.4.3 aPAUSEMACCtrlFramesReceived`
255
+ * from the standard.
256
+ */
257
+struct ethtool_pause_stats {
258
+ u64 tx_pause_frames;
259
+ u64 rx_pause_frames;
260
+};
212261
213262 /**
214263 * struct ethtool_ops - optional netdev operations
215
- * @get_settings: DEPRECATED, use %get_link_ksettings/%set_link_ksettings
216
- * API. Get various device settings including Ethernet link
217
- * settings. The @cmd parameter is expected to have been cleared
218
- * before get_settings is called. Returns a negative error code
219
- * or zero.
220
- * @set_settings: DEPRECATED, use %get_link_ksettings/%set_link_ksettings
221
- * API. Set various device settings including Ethernet link
222
- * settings. Returns a negative error code or zero.
264
+ * @supported_coalesce_params: supported types of interrupt coalescing.
223265 * @get_drvinfo: Report driver/device information. Should only set the
224266 * @driver, @version, @fw_version and @bus_info fields. If not
225267 * implemented, the @driver and @bus_info fields will be filled in
....@@ -237,6 +279,11 @@
237279 * @get_link: Report whether physical link is up. Will only be called if
238280 * the netdev is up. Should usually be set to ethtool_op_get_link(),
239281 * which uses netif_carrier_ok().
282
+ * @get_link_ext_state: Report link extended state. Should set link_ext_state and
283
+ * link_ext_substate (link_ext_substate of 0 means link_ext_substate is unknown,
284
+ * do not attach ext_substate attribute to netlink message). If link_ext_state
285
+ * and link_ext_substate are unknown, return -ENODATA. If not implemented,
286
+ * link_ext_state and link_ext_substate will not be sent to userspace.
240287 * @get_eeprom: Read data from the device EEPROM.
241288 * Should fill in the magic field. Don't need to check len for zero
242289 * or wraparound. Fill in the data argument with the eeprom values
....@@ -248,10 +295,14 @@
248295 * or zero.
249296 * @get_coalesce: Get interrupt coalescing parameters. Returns a negative
250297 * error code or zero.
251
- * @set_coalesce: Set interrupt coalescing parameters. Returns a negative
252
- * error code or zero.
298
+ * @set_coalesce: Set interrupt coalescing parameters. Supported coalescing
299
+ * types should be set in @supported_coalesce_params.
300
+ * Returns a negative error code or zero.
253301 * @get_ringparam: Report ring sizes
254302 * @set_ringparam: Set ring sizes. Returns a negative error code or zero.
303
+ * @get_pause_stats: Report pause frame statistics. Drivers must not zero
304
+ * statistics which they don't report. The stats structure is initialized
305
+ * to ETHTOOL_STAT_NOT_SET indicating driver does not report statistics.
255306 * @get_pauseparam: Report pause parameters
256307 * @set_pauseparam: Set pause parameters. Returns a negative error code
257308 * or zero.
....@@ -301,6 +352,15 @@
301352 * will remain unchanged.
302353 * Returns a negative error code or zero. An error code must be returned
303354 * if at least one unsupported change was requested.
355
+ * @get_rxfh_context: Get the contents of the RX flow hash indirection table,
356
+ * hash key, and/or hash function assiciated to the given rss context.
357
+ * Returns a negative error code or zero.
358
+ * @set_rxfh_context: Create, remove and configure RSS contexts. Allows setting
359
+ * the contents of the RX flow hash indirection table, hash key, and/or
360
+ * hash function associated to the given context. Arguments which are set
361
+ * to %NULL or zero will remain unchanged.
362
+ * Returns a negative error code or zero. An error code must be returned
363
+ * if at least one unsupported change was requested.
304364 * @get_channels: Get number of channels.
305365 * @set_channels: Set number of channels. Returns a negative error code or
306366 * zero.
....@@ -324,21 +384,19 @@
324384 * @set_per_queue_coalesce: Set interrupt coalescing parameters per queue.
325385 * It must check that the given queue number is valid. If neither a RX nor
326386 * a TX queue has this number, return -EINVAL. If only a RX queue or a TX
327
- * queue has this number, ignore the inapplicable fields.
387
+ * queue has this number, ignore the inapplicable fields. Supported
388
+ * coalescing types should be set in @supported_coalesce_params.
328389 * Returns a negative error code or zero.
329
- * @get_link_ksettings: When defined, takes precedence over the
330
- * %get_settings method. Get various device settings
331
- * including Ethernet link settings. The %cmd and
332
- * %link_mode_masks_nwords fields should be ignored (use
333
- * %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter), any
334
- * change to them will be overwritten by kernel. Returns a
335
- * negative error code or zero.
336
- * @set_link_ksettings: When defined, takes precedence over the
337
- * %set_settings method. Set various device settings including
338
- * Ethernet link settings. The %cmd and %link_mode_masks_nwords
339
- * fields should be ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS
340
- * instead of the latter), any change to them will be overwritten
341
- * by kernel. Returns a negative error code or zero.
390
+ * @get_link_ksettings: Get various device settings including Ethernet link
391
+ * settings. The %cmd and %link_mode_masks_nwords fields should be
392
+ * ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter),
393
+ * any change to them will be overwritten by kernel. Returns a negative
394
+ * error code or zero.
395
+ * @set_link_ksettings: Set various device settings including Ethernet link
396
+ * settings. The %cmd and %link_mode_masks_nwords fields should be
397
+ * ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter),
398
+ * any change to them will be overwritten by kernel. Returns a negative
399
+ * error code or zero.
342400 * @get_fecparam: Get the network device Forward Error Correction parameters.
343401 * @set_fecparam: Set the network device Forward Error Correction parameters.
344402 * @get_ethtool_phy_stats: Return extended statistics about the PHY device.
....@@ -358,8 +416,7 @@
358416 * of the generic netdev features interface.
359417 */
360418 struct ethtool_ops {
361
- int (*get_settings)(struct net_device *, struct ethtool_cmd *);
362
- int (*set_settings)(struct net_device *, struct ethtool_cmd *);
419
+ u32 supported_coalesce_params;
363420 void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *);
364421 int (*get_regs_len)(struct net_device *);
365422 void (*get_regs)(struct net_device *, struct ethtool_regs *, void *);
....@@ -369,6 +426,8 @@
369426 void (*set_msglevel)(struct net_device *, u32);
370427 int (*nway_reset)(struct net_device *);
371428 u32 (*get_link)(struct net_device *);
429
+ int (*get_link_ext_state)(struct net_device *,
430
+ struct ethtool_link_ext_state_info *);
372431 int (*get_eeprom_len)(struct net_device *);
373432 int (*get_eeprom)(struct net_device *,
374433 struct ethtool_eeprom *, u8 *);
....@@ -380,6 +439,8 @@
380439 struct ethtool_ringparam *);
381440 int (*set_ringparam)(struct net_device *,
382441 struct ethtool_ringparam *);
442
+ void (*get_pause_stats)(struct net_device *dev,
443
+ struct ethtool_pause_stats *pause_stats);
383444 void (*get_pauseparam)(struct net_device *,
384445 struct ethtool_pauseparam*);
385446 int (*set_pauseparam)(struct net_device *,
....@@ -441,10 +502,69 @@
441502 struct ethtool_fecparam *);
442503 void (*get_ethtool_phy_stats)(struct net_device *,
443504 struct ethtool_stats *, u64 *);
505
+ int (*get_phy_tunable)(struct net_device *,
506
+ const struct ethtool_tunable *, void *);
507
+ int (*set_phy_tunable)(struct net_device *,
508
+ const struct ethtool_tunable *, const void *);
444509
445510 ANDROID_KABI_RESERVE(1);
446511 ANDROID_KABI_RESERVE(2);
447512 ANDROID_KABI_RESERVE(3);
448513 ANDROID_KABI_RESERVE(4);
449514 };
515
+
516
+int ethtool_check_ops(const struct ethtool_ops *ops);
517
+
518
+struct ethtool_rx_flow_rule {
519
+ struct flow_rule *rule;
520
+ unsigned long priv[];
521
+};
522
+
523
+struct ethtool_rx_flow_spec_input {
524
+ const struct ethtool_rx_flow_spec *fs;
525
+ u32 rss_ctx;
526
+};
527
+
528
+struct ethtool_rx_flow_rule *
529
+ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input);
530
+void ethtool_rx_flow_rule_destroy(struct ethtool_rx_flow_rule *rule);
531
+
532
+bool ethtool_virtdev_validate_cmd(const struct ethtool_link_ksettings *cmd);
533
+int ethtool_virtdev_set_link_ksettings(struct net_device *dev,
534
+ const struct ethtool_link_ksettings *cmd,
535
+ u32 *dev_speed, u8 *dev_duplex);
536
+
537
+struct netlink_ext_ack;
538
+struct phy_device;
539
+struct phy_tdr_config;
540
+
541
+/**
542
+ * struct ethtool_phy_ops - Optional PHY device options
543
+ * @get_sset_count: Get number of strings that @get_strings will write.
544
+ * @get_strings: Return a set of strings that describe the requested objects
545
+ * @get_stats: Return extended statistics about the PHY device.
546
+ * @start_cable_test - Start a cable test
547
+ * @start_cable_test_tdr - Start a Time Domain Reflectometry cable test
548
+ *
549
+ * All operations are optional (i.e. the function pointer may be set to %NULL)
550
+ * and callers must take this into account. Callers must hold the RTNL lock.
551
+ */
552
+struct ethtool_phy_ops {
553
+ int (*get_sset_count)(struct phy_device *dev);
554
+ int (*get_strings)(struct phy_device *dev, u8 *data);
555
+ int (*get_stats)(struct phy_device *dev,
556
+ struct ethtool_stats *stats, u64 *data);
557
+ int (*start_cable_test)(struct phy_device *phydev,
558
+ struct netlink_ext_ack *extack);
559
+ int (*start_cable_test_tdr)(struct phy_device *phydev,
560
+ struct netlink_ext_ack *extack,
561
+ const struct phy_tdr_config *config);
562
+};
563
+
564
+/**
565
+ * ethtool_set_ethtool_phy_ops - Set the ethtool_phy_ops singleton
566
+ * @ops: Ethtool PHY operations to set
567
+ */
568
+void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops);
569
+
450570 #endif /* _LINUX_ETHTOOL_H */