include/linux/mii.h
Source file repositories/reference/linux-study-clean/include/linux/mii.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/mii.h- Extension
.h- Size
- 15882 bytes
- Lines
- 585
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/if.hlinux/linkmode.huapi/linux/mii.h
Detected Declarations
struct ethtool_cmdstruct mii_if_infofunction mii_nway_resultfunction mii_duplexfunction ethtool_adv_to_mii_adv_tfunction linkmode_adv_to_mii_adv_tfunction mii_adv_to_ethtool_adv_tfunction ethtool_adv_to_mii_ctrl1000_tfunction linkmode_adv_to_mii_ctrl1000_tfunction mii_ctrl1000_to_ethtool_adv_tfunction mii_lpa_to_ethtool_lpa_tfunction mii_stat1000_to_ethtool_lpa_tfunction mii_stat1000_mod_linkmode_lpa_tfunction ethtool_adv_to_mii_adv_xfunction mii_adv_to_ethtool_adv_xfunction mii_adv_mod_linkmode_adv_tfunction mii_adv_to_linkmode_adv_tfunction mii_lpa_to_linkmode_lpa_tfunction mii_lpa_mod_linkmode_lpa_tfunction mii_ctrl1000_mod_linkmode_adv_tfunction linkmode_adv_to_lcl_adv_tfunction mii_lpa_mod_linkmode_xfunction linkmode_adv_to_mii_adv_xfunction mii_advertise_flowctrlfunction mii_resolve_flowctrl_fdxfunction mii_bmcr_encode_fixed
Annotated Snippet
struct mii_if_info {
int phy_id;
int advertising;
int phy_id_mask;
int reg_num_mask;
unsigned int full_duplex : 1; /* is full duplex? */
unsigned int force_media : 1; /* is autoneg. disabled? */
unsigned int supports_gmii : 1; /* are GMII registers supported? */
struct net_device *dev;
int (*mdio_read) (struct net_device *dev, int phy_id, int location);
void (*mdio_write) (struct net_device *dev, int phy_id, int location, int val);
};
extern int mii_link_ok (struct mii_if_info *mii);
extern int mii_nway_restart (struct mii_if_info *mii);
extern void mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd);
extern void mii_ethtool_get_link_ksettings(
struct mii_if_info *mii, struct ethtool_link_ksettings *cmd);
extern int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd);
extern int mii_ethtool_set_link_ksettings(
struct mii_if_info *mii, const struct ethtool_link_ksettings *cmd);
extern int mii_check_gmii_support(struct mii_if_info *mii);
extern void mii_check_link (struct mii_if_info *mii);
extern unsigned int mii_check_media (struct mii_if_info *mii,
unsigned int ok_to_print,
unsigned int init_media);
extern int generic_mii_ioctl(struct mii_if_info *mii_if,
struct mii_ioctl_data *mii_data, int cmd,
unsigned int *duplex_changed);
static inline struct mii_ioctl_data *if_mii(struct ifreq *rq)
{
return (struct mii_ioctl_data *) &rq->ifr_ifru;
}
/**
* mii_nway_result
* @negotiated: value of MII ANAR and'd with ANLPAR
*
* Given a set of MII abilities, check each bit and returns the
* currently supported media, in the priority order defined by
* IEEE 802.3u. We use LPA_xxx constants but note this is not the
* value of LPA solely, as described above.
*
* The one exception to IEEE 802.3u is that 100baseT4 is placed
* between 100T-full and 100T-half. If your phy does not support
* 100T4 this is fine. If your phy places 100T4 elsewhere in the
* priority order, you will need to roll your own function.
*/
static inline unsigned int mii_nway_result (unsigned int negotiated)
{
unsigned int ret;
if (negotiated & LPA_100FULL)
ret = LPA_100FULL;
else if (negotiated & LPA_100BASE4)
ret = LPA_100BASE4;
else if (negotiated & LPA_100HALF)
ret = LPA_100HALF;
else if (negotiated & LPA_10FULL)
ret = LPA_10FULL;
else
ret = LPA_10HALF;
return ret;
}
/**
* mii_duplex
* @duplex_lock: Non-zero if duplex is locked at full
* @negotiated: value of MII ANAR and'd with ANLPAR
*
* A small helper function for a common case. Returns one
* if the media is operating or locked at full duplex, and
* returns zero otherwise.
*/
static inline unsigned int mii_duplex (unsigned int duplex_lock,
unsigned int negotiated)
{
if (duplex_lock)
return 1;
if (mii_nway_result(negotiated) & LPA_DUPLEX)
return 1;
return 0;
}
/**
Annotation
- Immediate include surface: `linux/if.h`, `linux/linkmode.h`, `uapi/linux/mii.h`.
- Detected declarations: `struct ethtool_cmd`, `struct mii_if_info`, `function mii_nway_result`, `function mii_duplex`, `function ethtool_adv_to_mii_adv_t`, `function linkmode_adv_to_mii_adv_t`, `function mii_adv_to_ethtool_adv_t`, `function ethtool_adv_to_mii_ctrl1000_t`, `function linkmode_adv_to_mii_ctrl1000_t`, `function mii_ctrl1000_to_ethtool_adv_t`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.