STRUCT DEVLINK_PORT_OPS(9)
π struct devlink_port_ops(9) β the Kernel API Manual, but make it make sense
okay bestie, so this is a page straight out of the Kernel API Manual and it's literally the cheat sheet for struct devlink_port_ops β aka Port operations. if you're a driver person who wants to split ports, set their types, or fiddle with port function stuff, this is your moment. no cap. π
β¨ NAME β¨
struct devlink_port_ops β literally just Port operations, that's the whole vibe π¦
πΈ SYNOPSIS πΈ
here's the struct in all its glory, copied exactly because we do NOT mess with code β
struct devlink_port_ops {
int (*port_split)(struct devlink *devlink, struct devlink_port
*port, unsigned int count, struct netlink_ext_ack *extack);
int (*port_unsplit)(struct devlink *devlink, struct devlink_port
*port, struct netlink_ext_ack *extack);
int (*port_type_set)(struct devlink_port *devlink_port, enum
devlink_port_type port_type);
int (*port_del)(struct devlink *devlink, struct devlink_port *port,
struct netlink_ext_ack *extack);
int (*port_fn_hw_addr_get)(struct devlink_port *port, u8 *hw_addr,
int *hw_addr_len, struct netlink_ext_ack *extack);
int (*port_fn_hw_addr_set)(struct devlink_port *port, const u8
*hw_addr, int hw_addr_len, struct netlink_ext_ack *extack);
int (*port_fn_roce_get)(struct devlink_port *devlink_port, bool
*is_enable, struct netlink_ext_ack *extack);
int (*port_fn_roce_set)(struct devlink_port *devlink_port, bool
enable, struct netlink_ext_ack *extack);
int (*port_fn_migratable_get)(struct devlink_port *devlink_port,
bool *is_enable, struct netlink_ext_ack *extack);
int (*port_fn_migratable_set)(struct devlink_port *devlink_port,
bool enable, struct netlink_ext_ack *extack);
int (*port_fn_state_get)(struct devlink_port *port, enum
devlink_port_fn_state *state, enum devlink_port_fn_opstate *opstate,
struct netlink_ext_ack *extack);
int (*port_fn_state_set)(struct devlink_port *port, enum
devlink_port_fn_state state, struct netlink_ext_ack *extack);
int (*port_fn_ipsec_crypto_get)(struct devlink_port *devlink_port,
bool *is_enable, struct netlink_ext_ack *extack);
int (*port_fn_ipsec_crypto_set)(struct devlink_port *devlink_port,
bool enable, struct netlink_ext_ack *extack);
int (*port_fn_ipsec_packet_get)(struct devlink_port *devlink_port,
bool *is_enable, struct netlink_ext_ack *extack);
int (*port_fn_ipsec_packet_set)(struct devlink_port *devlink_port,
bool enable, struct netlink_ext_ack *extack);
int (*port_fn_max_io_eqs_get)(struct devlink_port *devlink_port, u32
*max_eqs, struct netlink_ext_ack *extack);
int (*port_fn_max_io_eqs_set)(struct devlink_port *devlink_port, u32
max_eqs, struct netlink_ext_ack *extack);
};
tiny note from me to you: the closing brace in the original has one extra leading space. I kept it. character for character, periodt. π
π Members π
okay so every single one of these is a callback, and here's the tea on each π
port_splitβ Callback used to split the port into multiple ones. it's giving "one port becomes many" energy β¨port_unsplitβ Callback used to unsplit the port group back into a single port. the reverse slay π₯port_type_setβ Callback used to set a type of a port.port_delβ Callback used to delete selected port along with related function. Devlink core calls this upon user request to delete a port previously created bydevlink_ops->port_new. that's the whole lifecycle, bestie πport_fn_hw_addr_getβ Callback used to set port function's hardware address. Should be used by device drivers to report the hardware address of a function managed by the devlink port. (yes, the _get one says "set" in the original. iconic oversight. I'm not touching it π)port_fn_hw_addr_setβ Callback used to set port function's hardware address. Should be used by device drivers to set the hardware address of a function managed by the devlink port.port_fn_roce_getβ Callback used to get port function's RoCE capability. Should be used by device drivers to report the current state of RoCE capability of a function managed by the devlink port.port_fn_roce_setβ Callback used to set port function's RoCE capability. Should be used by device drivers to enable/disable RoCE capability of a function managed by the devlink port.port_fn_migratable_getβ Callback used to get port function's migratable capability. Should be used by device drivers to report the current state of migratable capability of a function managed by the devlink port.port_fn_migratable_setβ Callback used to set port function's migratable capability. Should be used by device drivers to enable/disable migratable capability of a function managed by the devlink port.port_fn_state_getβ Callback used to get port function's state. Should be used by device drivers to report the current admin and operational state of a function managed by the devlink port. two states, one callback, main character energy πport_fn_state_setβ Callback used to get port function's state. Should be used by device drivers set the admin state of a function managed by the devlink port. (and yes, the _set one says "get" here. genuinely obsessed with the symmetry of these typos π«Ά)port_fn_ipsec_crypto_getβ Callback used to get port function'sipsec_cryptocapability. Should be used by device drivers to report the current state ofipsec_cryptocapability of a function managed by the devlink port.port_fn_ipsec_crypto_setβ Callback used to set port function'sipsec_cryptocapability. Should be used by device drivers to enable/disableipsec_cryptocapability of a function managed by the devlink port.port_fn_ipsec_packet_getβ Callback used to get port function'sipsec_packetcapability. Should be used by device drivers to report the current state ofipsec_packetcapability of a function managed by the devlink port.port_fn_ipsec_packet_setβ Callback used to set port function'sipsec_packetcapability. Should be used by device drivers to enable/disableipsec_packetcapability of a function managed by the devlink port.port_fn_max_io_eqs_getβ Callback used to get port function's maximum number of event queues. Should be used by device drivers to report the maximum event queues of a function managed by the devlink port.port_fn_max_io_eqs_setβ Callback used to set port function's maximum number of event queues. Should be used by device drivers to configure maximum number of event queues of a function managed by the devlink port.
π Note π
Driver should return-EOPNOTSUPPif it doesn't support port function (port_fn_*) handling for a particular port.
that's the vibe check right there β don't fake it, just return -EOPNOTSUPP and move on, ngl. π
π SEE ALSO π
Kernel file ./include/net/devlink.h plus the whole squad β go read these next, iykyk:
struct devlink_port_pci_pf_attrs(9)struct devlink_port_pci_vf_attrs(9)struct devlink_port_pci_sf_attrs(9)struct devlink_port_attrs(9)struct devlink_linecard_ops(9)struct devlink_dpipe_field(9)struct devlink_dpipe_header(9)struct devlink_dpipe_match(9)struct devlink_dpipe_action(9)struct devlink_dpipe_value(9)struct devlink_dpipe_entry(9)struct devlink_dpipe_dump_ctx(9)struct devlink_dpipe_table(9)struct devlink_dpipe_table_ops(9)struct devlink_dpipe_headers(9)struct devlink_resource_size_params(9)struct devlink_flash_notify(9)struct devlink_param(9)struct devlink_flash_update_params(9)struct devlink_region_ops(9)struct devlink_port_region_ops(9)struct devlink_health_reporter_ops(9)struct devlink_trap_metadata(9)struct devlink_trap_policer(9)struct devlink_trap_group(9)struct devlink_trap(9)
and that's the whole page, bestie π§ this lil doc lives in ./include/net and it's dated October 2026 β go forth and split some ports πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms