|
15 | 15 |
|
16 | 16 | #include <linux/bitmap.h>
|
17 | 17 | #include <linux/compat.h>
|
| 18 | +#include <linux/if_ether.h> |
18 | 19 | #include <linux/netlink.h>
|
19 | 20 | #include <uapi/linux/ethtool.h>
|
20 | 21 |
|
@@ -1001,6 +1002,47 @@ void ethtool_aggregate_pause_stats(struct net_device *dev,
|
1001 | 1002 | void ethtool_aggregate_rmon_stats(struct net_device *dev,
|
1002 | 1003 | struct ethtool_rmon_stats *rmon_stats);
|
1003 | 1004 |
|
| 1005 | +/** |
| 1006 | + * ethtool_mm_frag_size_add_to_min - Translate (standard) additional fragment |
| 1007 | + * size expressed as multiplier into (absolute) minimum fragment size |
| 1008 | + * value expressed in octets |
| 1009 | + * @val_add: Value of addFragSize multiplier |
| 1010 | + */ |
| 1011 | +static inline u32 ethtool_mm_frag_size_add_to_min(u32 val_add) |
| 1012 | +{ |
| 1013 | + return (ETH_ZLEN + ETH_FCS_LEN) * (1 + val_add) - ETH_FCS_LEN; |
| 1014 | +} |
| 1015 | + |
| 1016 | +/** |
| 1017 | + * ethtool_mm_frag_size_min_to_add - Translate (absolute) minimum fragment size |
| 1018 | + * expressed in octets into (standard) additional fragment size expressed |
| 1019 | + * as multiplier |
| 1020 | + * @val_min: Value of addFragSize variable in octets |
| 1021 | + * @val_add: Pointer where the standard addFragSize value is to be returned |
| 1022 | + * @extack: Netlink extended ack |
| 1023 | + * |
| 1024 | + * Translate a value in octets to one of 0, 1, 2, 3 according to the reverse |
| 1025 | + * application of the 802.3 formula 64 * (1 + addFragSize) - 4. To be called |
| 1026 | + * by drivers which do not support programming the minimum fragment size to a |
| 1027 | + * continuous range. Returns error on other fragment length values. |
| 1028 | + */ |
| 1029 | +static inline int ethtool_mm_frag_size_min_to_add(u32 val_min, u32 *val_add, |
| 1030 | + struct netlink_ext_ack *extack) |
| 1031 | +{ |
| 1032 | + u32 add_frag_size; |
| 1033 | + |
| 1034 | + for (add_frag_size = 0; add_frag_size < 4; add_frag_size++) { |
| 1035 | + if (ethtool_mm_frag_size_add_to_min(add_frag_size) == val_min) { |
| 1036 | + *val_add = add_frag_size; |
| 1037 | + return 0; |
| 1038 | + } |
| 1039 | + } |
| 1040 | + |
| 1041 | + NL_SET_ERR_MSG_MOD(extack, |
| 1042 | + "minFragSize required to be one of 60, 124, 188 or 252"); |
| 1043 | + return -EINVAL; |
| 1044 | +} |
| 1045 | + |
1004 | 1046 | /**
|
1005 | 1047 | * ethtool_sprintf - Write formatted string to ethtool string data
|
1006 | 1048 | * @data: Pointer to start of string to update
|
|
0 commit comments