class Session

Defined at line 90 of file ../../src/connectivity/network/drivers/network-device/device/session.h

A client session with a network device interface.

Session will spawn a thread that will handle the fuchsia.hardware.network.Session FIDL control

plane calls and service the Tx FIFO associated with the client session.

It is invalid to destroy a Session that has outstanding buffers, that is, buffers that are

currently owned by the interface's Rx or Tx queues.

Public Methods

void ~Session ()

Defined at line 118 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

zx::result<std::pair<std::unique_ptr<Session>, netdev::wire::Fifos>> Create (async_dispatcher_t * dispatcher, netdev::wire::SessionInfo & info, fidl::StringView name, DeviceInterface * parent)

Creates a new session with the provided parameters.

The session will service fuchsia.hardware.network.Session FIDL calls on the provided `control`

channel.

All control plane calls are operated on the provided `dispatcher`, and a dedicated thread will

be spawned to handle data fast path operations (tx data plane).

Returns the session and its data path FIFOs.

Defined at line 72 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

bool IsPrimary ()

Defined at line 42 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

bool IsListen ()

Defined at line 38 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

bool IsPaused ()

Defined at line 46 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

bool AllowRxLeaseDelegation ()

Defined at line 48 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

bool ShouldTakeOverPrimary (const Session * current_primary)

Checks if this session is eligible to take over the primary session from `current_primary`.

`current_primary` can be null, meaning there's no current primary session.

Defined at line 52 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

void AssertParentControlLock (DeviceInterface & parent)

Helper functions with TA annotations that bridges the gap between parent's locks and local

locking requirements; TA is not otherwise able to tell that the |parent| and |parent_| are the

same entity.

Defined at line 123 of file ../../src/connectivity/network/drivers/network-device/device/session.h

void AssertParentControlLockShared (DeviceInterface & parent)

Defined at line 127 of file ../../src/connectivity/network/drivers/network-device/device/session.h

void AssertParentRxLock (DeviceInterface & parent)

Defined at line 131 of file ../../src/connectivity/network/drivers/network-device/device/session.h

void AssertParentTxLock (DeviceInterface & parent)

Defined at line 135 of file ../../src/connectivity/network/drivers/network-device/device/session.h

void TxTaken ()

Defined at line 189 of file ../../src/connectivity/network/drivers/network-device/device/session.h

void RxTaken ()

Defined at line 190 of file ../../src/connectivity/network/drivers/network-device/device/session.h

void StopRx ()

Defined at line 191 of file ../../src/connectivity/network/drivers/network-device/device/session.h

bool ShouldDestroy ()

Defined at line 192 of file ../../src/connectivity/network/drivers/network-device/device/session.h

const fbl::RefPtr<RefCountedFifo> & rx_fifo ()

Defined at line 203 of file ../../src/connectivity/network/drivers/network-device/device/session.h

const zx::fifo & tx_fifo ()

Defined at line 204 of file ../../src/connectivity/network/drivers/network-device/device/session.h

const char * name ()

Defined at line 205 of file ../../src/connectivity/network/drivers/network-device/device/session.h

bool IsDying ()

Defined at line 207 of file ../../src/connectivity/network/drivers/network-device/device/session.h

void InstallTx ()

Installs session tx listeners. Panics if called twice.

Defined at line 276 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

void UninstallTx ()

Uninstalls session tx listeners. Must be called before destroying if

|InstallTx| was called. No-op if |InstallTx| was not called.

Defined at line 283 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

void Attach (AttachRequestView request, AttachCompleter::Sync & _completer)

FIDL interface implementation:

Defined at line 620 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

void Detach (DetachRequestView request, DetachCompleter::Sync & _completer)

Defined at line 630 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

void Close (CloseCompleter::Sync & _completer)

Defined at line 639 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

void WatchDelegatedRxLease (WatchDelegatedRxLeaseCompleter::Sync & completer)

Defined at line 641 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

zx_status_t AttachPort (const netdev::wire::PortId & port_id, cpp20::span<const netdev::wire::FrameType> frame_types)

Defined at line 521 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

zx_status_t DetachPort (const netdev::wire::PortId & port_id)

Defined at line 565 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

void MarkTxReturnResult (uint16_t descriptor, zx_status_t status)

Sets the return code for a tx descriptor.

Defined at line 659 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

void ReturnTxDescriptors (const uint16_t * descriptors, size_t count)

Returns tx descriptors to the session client.

Defined at line 687 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

void Kill ()

Signals the session thread to stop servicing the session channel and FIFOs.

When the session thread is finished, it notifies the DeviceInterface parent through

`NotifyDeadSession`.

Defined at line 760 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

zx_status_t LoadRxDescriptors (RxQueue::SessionTransaction & transact)

Loads rx descriptors into the provided session transaction, fetching more from the rx FIFO if

needed.

Defined at line 744 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

zx_status_t FillRxSpace (uint16_t descriptor_index, fuchsia_hardware_network_driver::wire::RxSpaceBuffer * buff)

Sets the data in the space buffer `buff` to region described by `descriptor_index`.

Defined at line 770 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

bool CompleteRx (const RxFrameInfo & frame_info)

Completes rx for a single frame described by `frame_info`.

Returns true if the buffers comprising `frame_info` can immediately be reused.

Defined at line 801 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

bool CompleteRxWith (const Session & owner, const RxFrameInfo & frame_info)

Completes rx by copying the data from another session into one of this session's available rx

buffers.

Returns true iff the frame information was enqueued in the session rx queue.

Defined at line 834 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

bool CompleteUnfulfilledRx ()

Marks a single rx space buffer as complete, but does not consume it as it was unfulfilled.

Returns true iff the session is active and space buffers can be reused.

Defined at line 970 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

bool ListenFromTx (const Session & owner, uint16_t owner_index)

Copies data from a tx frame from another session into one of this session's available rx

buffers.

Defined at line 975 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

void CommitRx ()

Commits pending rx buffers, sending them back to the session client.

Defined at line 1097 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

bool IsSubscribedToFrameType (uint8_t port, netdev::wire::FrameType frame_type)

Returns true iff the session is subscribed to frame_type on port.

Defined at line 1128 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

bool OnPortDestroyed (uint8_t port_id)

Notifies session of port destruction.

Returns true iff the session should be stopped after detaching from the port.

Defined at line 607 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

void SetDataVmo (uint8_t vmo_id, DataVmoStore::StoredVmo * vmo)

Sets the internal references to the data VMO.

Must only be called when the Session hasn't yet been allocated a VMO id, will abort otherwise.

Defined at line 1141 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

uint8_t ClearDataVmo ()

Clears internal references to data VMO, returning the vmo_id that was associated with this

session.

Defined at line 1148 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

zx_status_t FetchTx (TxQueue::SessionTransaction & transaction)

Fetch tx descriptors from the FIFO and queue them in the parent |DeviceInterface|'s TxQueue.

Defined at line 291 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

void Bind (fidl::ServerEnd<netdev::Session> channel)

Binds |channel| to this session. Must only be called once.

Defined at line 203 of file ../../src/connectivity/network/drivers/network-device/device/session.cc

void DelegateRxLease (netdev::DelegatedRxLease lease)

Delegates an rx lease to this session. The lease is assumed to be already

fulfilled during rx queue processing, the hold until frame is updated to

the latest frame delivered to this session and the lease is delegated up.

Defined at line 257 of file ../../src/connectivity/network/drivers/network-device/device/session.cc