drivers/net/phy/open_alliance_helpers.c
Source file repositories/reference/linux-study-clean/drivers/net/phy/open_alliance_helpers.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/phy/open_alliance_helpers.c- Extension
.c- Size
- 3009 bytes
- Lines
- 78
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
Dependency Surface
linux/bitfield.hlinux/ethtool_netlink.hopen_alliance_helpers.h
Detected Declarations
function Reflectionfunction availableexport oa_1000bt1_get_ethtool_cable_result_codeexport oa_1000bt1_get_tdr_distance
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* open_alliance_helpers.c - OPEN Alliance specific PHY diagnostic helpers
*
* This file contains helper functions for implementing advanced diagnostic
* features as specified by the OPEN Alliance for automotive Ethernet PHYs.
* These helpers include functionality for Time Delay Reflection (TDR), dynamic
* channel quality assessment, and other PHY diagnostics.
*
* For more information on the specifications, refer to the OPEN Alliance
* documentation: https://opensig.org/automotive-ethernet-specifications/
* Currently following specifications are partially or fully implemented:
* - Advanced diagnostic features for 1000BASE-T1 automotive Ethernet PHYs.
* TC12 - advanced PHY features.
* https://opensig.org/wp-content/uploads/2024/03/Advanced_PHY_features_for_automotive_Ethernet_v2.0_fin.pdf
*/
#include <linux/bitfield.h>
#include <linux/ethtool_netlink.h>
#include "open_alliance_helpers.h"
/**
* oa_1000bt1_get_ethtool_cable_result_code - Convert TDR status to ethtool
* result code
* @reg_value: Value read from the TDR register
*
* This function takes a register value from the HDD.TDR register and converts
* the TDR status to the corresponding ethtool cable test result code.
*
* Return: The appropriate ethtool result code based on the TDR status
*/
int oa_1000bt1_get_ethtool_cable_result_code(u16 reg_value)
{
u8 tdr_status = FIELD_GET(OA_1000BT1_HDD_TDR_STATUS_MASK, reg_value);
u8 dist_val = FIELD_GET(OA_1000BT1_HDD_TDR_DISTANCE_MASK, reg_value);
switch (tdr_status) {
case OA_1000BT1_HDD_TDR_STATUS_CABLE_OK:
return ETHTOOL_A_CABLE_RESULT_CODE_OK;
case OA_1000BT1_HDD_TDR_STATUS_OPEN:
return ETHTOOL_A_CABLE_RESULT_CODE_OPEN;
case OA_1000BT1_HDD_TDR_STATUS_SHORT:
return ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT;
case OA_1000BT1_HDD_TDR_STATUS_NOISE:
return ETHTOOL_A_CABLE_RESULT_CODE_NOISE;
default:
if (dist_val == OA_1000BT1_HDD_TDR_DISTANCE_RESOLUTION_NOT_POSSIBLE)
return ETHTOOL_A_CABLE_RESULT_CODE_RESOLUTION_NOT_POSSIBLE;
return ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC;
}
}
EXPORT_SYMBOL_GPL(oa_1000bt1_get_ethtool_cable_result_code);
/**
* oa_1000bt1_get_tdr_distance - Get distance to the main fault from TDR
* register value
* @reg_value: Value read from the TDR register
*
* This function takes a register value from the HDD.TDR register and extracts
* the distance to the main fault detected by the TDR feature. The distance is
* measured in centimeters and ranges from 0 to 3100 centimeters. If the
* distance is not available (0x3f), the function returns -ERANGE.
*
* Return: The distance to the main fault in centimeters, or -ERANGE if the
* resolution is not possible.
*/
int oa_1000bt1_get_tdr_distance(u16 reg_value)
{
u8 dist_val = FIELD_GET(OA_1000BT1_HDD_TDR_DISTANCE_MASK, reg_value);
if (dist_val == OA_1000BT1_HDD_TDR_DISTANCE_RESOLUTION_NOT_POSSIBLE)
return -ERANGE;
return dist_val * 100;
}
EXPORT_SYMBOL_GPL(oa_1000bt1_get_tdr_distance);
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/ethtool_netlink.h`, `open_alliance_helpers.h`.
- Detected declarations: `function Reflection`, `function available`, `export oa_1000bt1_get_ethtool_cable_result_code`, `export oa_1000bt1_get_tdr_distance`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration 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.