summaryrefslogtreecommitdiffstats
path: root/net/core/ethtool.c
diff options
context:
space:
mode:
authorAlan Brady <alan.brady@intel.com>2017-10-05 14:53:40 -0700
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2017-10-17 10:48:51 -0700
commit5a6cd6de76ae78b651e7c36eba8b1da465d65f06 (patch)
treec9811c2b2602b081a541f65805a58ecb4b91a993 /net/core/ethtool.c
parent211b4c140a9de0a672a8f5c3cbaa3639ef507205 (diff)
downloadlinux-5a6cd6de76ae78b651e7c36eba8b1da465d65f06.tar.bz2
ethtool: add ethtool_intersect_link_masks
This function provides a way to intersect two link masks together to find the common ground between them. For example in i40e, the driver first generates link masks for what is supported by the PHY type. The driver then gets the link masks for what the NVM supports. The resulting intersection between them yields what can truly be supported. Signed-off-by: Alan Brady <alan.brady@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'net/core/ethtool.c')
-rw-r--r--net/core/ethtool.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 3228411ada0f..0c406306792a 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -403,6 +403,22 @@ static int __ethtool_set_flags(struct net_device *dev, u32 data)
return 0;
}
+/* Given two link masks, AND them together and save the result in dst. */
+void ethtool_intersect_link_masks(struct ethtool_link_ksettings *dst,
+ struct ethtool_link_ksettings *src)
+{
+ unsigned int size = BITS_TO_LONGS(__ETHTOOL_LINK_MODE_MASK_NBITS);
+ unsigned int idx = 0;
+
+ for (; idx < size; idx++) {
+ dst->link_modes.supported[idx] &=
+ src->link_modes.supported[idx];
+ dst->link_modes.advertising[idx] &=
+ src->link_modes.advertising[idx];
+ }
+}
+EXPORT_SYMBOL(ethtool_intersect_link_masks);
+
void ethtool_convert_legacy_u32_to_link_mode(unsigned long *dst,
u32 legacy_u32)
{