Struct kernel::net::phy::Device

source ·
#[repr(transparent)]
pub struct Device(/* private fields */);
Expand description

An instance of a PHY device.

Wraps the kernel’s struct phy_device.

A Device instance is created when a callback in Driver is executed. A PHY driver executes Driver’s methods during the callback.

Invariants

Referencing a phy_device using this struct asserts that you are in a context where all methods defined on this struct are safe to call.

Implementations§

source§

impl Device

source

pub fn phy_id(&self) -> u32

Gets the id of the PHY.

source

pub fn state(&self) -> DeviceState

Gets the state of PHY state machine states.

Gets the current link state.

It returns true if the link is up.

source

pub fn is_autoneg_enabled(&self) -> bool

Gets the current auto-negotiation configuration.

It returns true if auto-negotiation is enabled.

source

pub fn is_autoneg_completed(&self) -> bool

Gets the current auto-negotiation state.

It returns true if auto-negotiation is completed.

source

pub fn set_speed(&mut self, speed: u32)

Sets the speed of the PHY.

source

pub fn set_duplex(&mut self, mode: DuplexMode)

Sets duplex mode.

source

pub fn read(&mut self, regnum: u16) -> Result<u16>

Reads a given C22 PHY register.

source

pub fn write(&mut self, regnum: u16, val: u16) -> Result

Writes a given C22 PHY register.

source

pub fn read_paged(&mut self, page: u16, regnum: u16) -> Result<u16>

Reads a paged register.

source

pub fn resolve_aneg_linkmode(&mut self)

Resolves the advertisements into PHY settings.

source

pub fn genphy_soft_reset(&mut self) -> Result

Executes software reset the PHY via BMCR_RESET bit.

source

pub fn init_hw(&mut self) -> Result

Initializes the PHY.

source

pub fn start_aneg(&mut self) -> Result

Starts auto-negotiation.

source

pub fn genphy_resume(&mut self) -> Result

Resumes the PHY via BMCR_PDOWN bit.

source

pub fn genphy_suspend(&mut self) -> Result

Suspends the PHY via BMCR_PDOWN bit.

source

pub fn genphy_read_status(&mut self) -> Result<u16>

Checks the link status and updates current link state.

Updates the link status.

source

pub fn genphy_read_lpa(&mut self) -> Result

Reads link partner ability.

source

pub fn genphy_read_abilities(&mut self) -> Result

Reads PHY abilities.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Device

§

impl !Send for Device

§

impl !Sync for Device

§

impl !Unpin for Device

§

impl UnwindSafe for Device

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, E> Init<T, E> for T

source§

unsafe fn __init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, E> PinInit<T, E> for T

source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.