Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * link caps internal header, for link modes <-> capabilities <-> interfaces
4 * conversions.
5 */
6
7#ifndef __PHY_CAPS_H
8#define __PHY_CAPS_H
9
10#include <linux/ethtool.h>
11#include <linux/phy.h>
12
13enum {
14 LINK_CAPA_10HD = 0,
15 LINK_CAPA_10FD,
16 LINK_CAPA_100HD,
17 LINK_CAPA_100FD,
18 LINK_CAPA_1000HD,
19 LINK_CAPA_1000FD,
20 LINK_CAPA_2500FD,
21 LINK_CAPA_5000FD,
22 LINK_CAPA_10000FD,
23 LINK_CAPA_20000FD,
24 LINK_CAPA_25000FD,
25 LINK_CAPA_40000FD,
26 LINK_CAPA_50000FD,
27 LINK_CAPA_56000FD,
28 LINK_CAPA_100000FD,
29 LINK_CAPA_200000FD,
30 LINK_CAPA_400000FD,
31 LINK_CAPA_800000FD,
32 LINK_CAPA_1600000FD,
33
34 __LINK_CAPA_MAX,
35};
36
37#define LINK_CAPA_ALL GENMASK((__LINK_CAPA_MAX - 1), 0)
38
39struct link_capabilities {
40 int speed;
41 unsigned int duplex;
42 __ETHTOOL_DECLARE_LINK_MODE_MASK(linkmodes);
43};
44
45int __init phy_caps_init(void);
46
47size_t phy_caps_speeds(unsigned int *speeds, size_t size,
48 unsigned long *linkmodes);
49void phy_caps_linkmode_max_speed(u32 max_speed, unsigned long *linkmodes);
50bool phy_caps_valid(int speed, int duplex, const unsigned long *linkmodes);
51void phy_caps_linkmodes(unsigned long caps, unsigned long *linkmodes);
52unsigned long phy_caps_from_interface(phy_interface_t interface);
53
54const struct link_capabilities *
55phy_caps_lookup_by_linkmode(const unsigned long *linkmodes);
56
57const struct link_capabilities *
58phy_caps_lookup_by_linkmode_rev(const unsigned long *linkmodes, bool fdx_only);
59
60const struct link_capabilities *
61phy_caps_lookup(int speed, unsigned int duplex, const unsigned long *supported,
62 bool exact);
63
64#endif /* __PHY_CAPS_H */