drivers/net/phy/sfp.c
Source file repositories/reference/linux-study-clean/drivers/net/phy/sfp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/phy/sfp.c- Extension
.c- Size
- 89657 bytes
- Lines
- 3476
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/debugfs.hlinux/delay.hlinux/gpio/consumer.hlinux/hwmon.hlinux/i2c.hlinux/interrupt.hlinux/jiffies.hlinux/mdio/mdio-i2c.hlinux/module.hlinux/mutex.hlinux/of.hlinux/phy.hlinux/platform_device.hlinux/rtnetlink.hlinux/slab.hlinux/unaligned.hlinux/workqueue.hsfp.h
Detected Declarations
struct sff_datastruct sfpfunction sfp_schedule_pollfunction sff_module_supportedfunction sfp_module_supportedfunction sfp_fixup_long_startupfunction sfp_fixup_ignore_losfunction sfp_fixup_ignore_tx_faultfunction sfp_fixup_ignore_tx_fault_and_losfunction sfp_fixup_ignore_hwfunction sfp_fixup_nokiafunction sfp_fixup_10gbaset_30mfunction sfp_fixup_rollballfunction sfp_fixup_rollball_wait4sfunction sfp_fixup_fs_10gtfunction sfp_fixup_halny_gsfpfunction sfp_fixup_potronfunction sfp_fixup_rollball_ccfunction sfp_quirk_2500basexfunction sfp_quirk_disable_autonegfunction sfp_quirk_oem_2_5gfunction sfp_quirk_ubnt_uf_instantfunction sfp_strlenfunction sfp_matchfunction sfp_gpio_get_statefunction sff_gpio_get_statefunction sfp_gpio_set_statefunction sfp_i2c_readfunction sfp_i2c_writefunction sfp_smbus_readfunction sfp_smbus_writefunction sfp_i2c_configurefunction i2c_check_functionalityfunction sfp_i2c_mdiobus_createfunction sfp_i2c_mdiobus_destroyfunction sfp_readfunction identifierfunction sfp_i2c_get_statefunction sfp_writefunction sfp_modify_u8function sfp_soft_get_statefunction sfp_soft_set_statefunction sfp_soft_start_pollfunction sfp_soft_stop_pollfunction sfp_get_statefunction sfp_set_statefunction sfp_mod_statefunction sfp_check
Annotated Snippet
struct sff_data {
unsigned int gpios;
bool (*module_supported)(const struct sfp_eeprom_id *id);
};
struct sfp {
struct device *dev;
struct i2c_adapter *i2c;
struct mii_bus *i2c_mii;
struct sfp_bus *sfp_bus;
enum mdio_i2c_proto mdio_protocol;
struct phy_device *mod_phy;
const struct sff_data *type;
size_t i2c_max_block_size;
size_t i2c_block_size;
u32 max_power_mW;
unsigned int (*get_state)(struct sfp *);
void (*set_state)(struct sfp *, unsigned int);
int (*read)(struct sfp *, bool, u8, void *, size_t);
int (*write)(struct sfp *, bool, u8, void *, size_t);
struct gpio_desc *gpio[GPIO_MAX];
int gpio_irq[GPIO_MAX];
bool need_poll;
/* I2C-probed presence, for boards without a MOD_DEF0 GPIO.
* Access rules: st_mutex held (updated from the poll/state machine).
*/
bool i2c_present;
u8 i2c_present_nak;
unsigned long i2c_present_next;
/* Access rules:
* state_hw_drive: st_mutex held
* state_hw_mask: st_mutex held
* state_soft_mask: st_mutex held
* state: st_mutex held unless reading input bits
*/
struct mutex st_mutex; /* Protects state */
unsigned int state_hw_drive;
unsigned int state_hw_mask;
unsigned int state_soft_mask;
unsigned int state_ignore_mask;
unsigned int state;
struct delayed_work poll;
struct delayed_work timeout;
struct mutex sm_mutex; /* Protects state machine */
unsigned char sm_mod_state;
unsigned char sm_mod_tries_init;
unsigned char sm_mod_tries;
unsigned char sm_dev_state;
unsigned short sm_state;
unsigned char sm_fault_retries;
unsigned char sm_phy_retries;
struct sfp_eeprom_id id;
unsigned int module_power_mW;
unsigned int module_t_start_up;
unsigned int module_t_wait;
unsigned int phy_t_retry;
unsigned int rate_kbd;
unsigned int rs_threshold_kbd;
unsigned int rs_state_mask;
bool have_a2;
const struct sfp_quirk *quirk;
#if IS_ENABLED(CONFIG_HWMON)
struct sfp_diag diag;
struct delayed_work hwmon_probe;
unsigned int hwmon_tries;
struct device *hwmon_dev;
char *hwmon_name;
#endif
#if IS_ENABLED(CONFIG_DEBUG_FS)
struct dentry *debugfs_dir;
#endif
};
static void sfp_schedule_poll(struct sfp *sfp)
{
mod_delayed_work(system_percpu_wq, &sfp->poll, SFP_POLL_INTERVAL);
}
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/hwmon.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/jiffies.h`, `linux/mdio/mdio-i2c.h`.
- Detected declarations: `struct sff_data`, `struct sfp`, `function sfp_schedule_poll`, `function sff_module_supported`, `function sfp_module_supported`, `function sfp_fixup_long_startup`, `function sfp_fixup_ignore_los`, `function sfp_fixup_ignore_tx_fault`, `function sfp_fixup_ignore_tx_fault_and_los`, `function sfp_fixup_ignore_hw`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.