STRUCT DEVLINK_PORT_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

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 by devlink_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's ipsec_crypto capability. Should be used by device drivers to report the current state of ipsec_crypto capability of a function managed by the devlink port.
  • port_fn_ipsec_crypto_set β€” Callback used to set port function's ipsec_crypto capability. Should be used by device drivers to enable/disable ipsec_crypto capability of a function managed by the devlink port.
  • port_fn_ipsec_packet_get β€” Callback used to get port function's ipsec_packet capability. Should be used by device drivers to report the current state of ipsec_packet capability of a function managed by the devlink port.
  • port_fn_ipsec_packet_set β€” Callback used to set port function's ipsec_packet capability. Should be used by device drivers to enable/disable ipsec_packet capability 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 -EOPNOTSUPP if 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