---
name: "ofw_graph_get_port_by_idx"
section: "9"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/ofw_graph"
---

# ofw\_graph\_get\_port\_by\_idx(9)

Helpers for the graph bindings

Part of [ofw\_graph(9)](/ofw_graph/9.md).

## NAME

**ofw\_graph**, **ofw\_graph\_get\_port\_by\_idx**, **ofw\_graph\_port\_get\_num\_endpoints**, **ofw\_graph\_get\_endpoint\_by\_idx**, **ofw\_graph\_get\_remote\_endpoint**, **ofw\_graph\_get\_remote\_parent**, **ofw\_graph\_get\_device\_by\_port\_ep** – Helpers for the graph bindings

## SYNOPSIS

**#include \<dev/ofw/openfirm.h\>**

**#include \<dev/ofw/ofw\_graph.h\>**

*phandle\_t*\

**ofw\_graph\_get\_port\_by\_idx**(*phandle\_t node*, *uint32\_t idx*);

*size\_t*\

**ofw\_graph\_port\_get\_num\_endpoints**(*phandle\_t port*);

*phandle\_t*\

**ofw\_graph\_get\_endpoint\_by\_idx**(*phandle\_t port*, *uint32\_t idx*);

*phandle\_t*\

**ofw\_graph\_get\_remote\_endpoint**(*phandle\_t endpoint*);

*phandle\_t*\

**ofw\_graph\_get\_remote\_parent**(*phandle\_t remote*);

*device\_t*\

**ofw\_graph\_get\_device\_by\_port\_ep**(*phandle\_t node*, *uint32\_t port\_id*, *uin32\_t ep\_id*);

## DESCRIPTION

The ofw\_graph functions are helpers to parse the DTS graph bindings

**ofw\_graph\_get\_port\_by\_idx**() return the port with id *idx*. It will first check node named *port@idx* and then fallback on checking the *ports* child for a child node matching the id. If no ports matching *idx* is found the function return 0.

**ofw\_graph\_port\_get\_num\_endpoints**() returns the number of endpoints a port node have.

**ofw\_graph\_get\_endpoint\_by\_idx**() return the endpoint with id *idx*. It will first check if there is a single child named *endpoint* and returns it if there is. If there is multiple endpoints it will check the *reg* property and returns the correct *phandle\_t* or 0 if none match.

**ofw\_graph\_get\_remote\_endpoint**() returns the *remote-endpoint* property if it exists or 0.

**ofw\_graph\_get\_remote\_parent**() returns the device node corresponding to the *remote-endpoint* phandle or 0 if none. **ofw\_graph\_get\_device\_by\_port\_ep**() returns the device associated with the port and endpoint or *NULL* if none. The device driver should have called **OF\_device\_register\_xref**() before.

## HISTORY

The **ofw\_graph** functions first appeared in FreeBSD 13.0. The **ofw\_graph** functions and manual page were written by Emmanuel Vadot ⟨*manu@FreeBSD.org*⟩.
