ntb_peer_resource_idx(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… ntb_peer_resource_idx

okay bestie, welcome to the Kernel API Manual ✨ β€” this one's a little function from the Linux kernel with a big "graph theory but make it hardware" energy. It's ntb_peer_resource_idx, and it's about to hand you a resource index like it's passing you the aux cord. πŸŽ€


✨ NAME ✨

ntb_peer_resource_idx β€” get a resource index for a given peer idx πŸ¦‹


🌸 SYNOPSIS 🌸

int ntb_peer_resource_idx (struct ntb_dev *ntb , int pidx );

πŸ’– ARGUMENTS πŸ’–

  • ntb β€” the NTB device context. like, your whole device's vibe check. 🫢
  • pidx β€” the peer port index. which peer are we talking about, babe?

πŸ”₯ DESCRIPTION πŸ”₯

so picture this: you're constructing a graph of peers, right? and every single remote peer has to use a different resource index (mw, doorbell, etc) to talk to each other peer. it's giving assigned seating at a wedding. no cap. πŸ’€

In a two peer system, this function should always return 0, so that resource 0 points to the remote peer on both ports. simple. iconic. chef's kiss. πŸ‘‘

In a 5 peer system, this function will return the following matrix:

       pidx  port    0    1    2    3    4 0              0    0    1    2    3
       1              0    1    1    2    3 2              0    1    2    2
       3 3              0    1    2    3    3

For example, if this function is used to program peer's memory windows, port 0 will program MW 0 on all it's peers to point to itself. port 1 will program MW 0 in port 0 to point to itself and MW 1 on all other ports. etc. etc. slay. 🌈

For the legacy two host case, ntb_port_number and ntb_peer_port_number both return zero, and therefore this function will always return zero. so MW 0 on each host would be programmed to point to the other host. lowkey elegant ngl. ✨


⭐ RETURN ⭐

the resource index to use for that peer. that's it, that's the tea. πŸ“


πŸ¦‹ SEE ALSO πŸ¦‹

Kernel file ./include/linux/ntb.h

enum ntb_topo(9), enum ntb_speed(9), enum ntb_width(9), enum ntb_default_port(9), struct ntb_client_ops(9), struct ntb_ctx_ops(9), struct ntb_dev_ops(9), struct ntb_client(9), struct ntb_dev(9), ntb_register_client(9), ntb_unregister_client(9), ntb_register_device(9), ntb_unregister_device(9), ntb_set_ctx(9), ntb_clear_ctx(9), ntb_link_event(9), ntb_db_event(9), ntb_msg_event(9), ntb_default_port_number(9), ntb_default_peer_port_count(9), ntb_default_peer_port_number(9), ntb_default_peer_port_idx(9), ntb_port_number(9), ntb_peer_port_count(9), ntb_peer_port_number(9), ntb_logical_port_number(9), ntb_peer_logical_port_number(9), ntb_peer_port_idx(9), ntb_link_is_up(9), ntb_link_enable(9), ntb_link_disable(9), ntb_mw_count(9), ntb_mw_get_align(9), ntb_mw_set_trans(9), ntb_mw_clear_trans(9), ntb_peer_mw_count(9), ntb_peer_mw_get_addr(9), ntb_peer_mw_set_trans(9), ntb_peer_mw_clear_trans(9), ntb_db_is_unsafe(9), ntb_db_valid_mask(9), ntb_db_vector_count(9), ntb_db_vector_mask(9), ntb_db_read(9), ntb_db_set(9), ntb_db_clear(9), ntb_db_read_mask(9), ntb_db_set_mask(9), ntb_db_clear_mask(9), ntb_peer_db_addr(9), ntb_peer_db_read(9), ntb_peer_db_set(9), ntb_peer_db_clear(9), ntb_peer_db_read_mask(9), ntb_peer_db_set_mask(9), ntb_peer_db_clear_mask(9), ntb_spad_is_unsafe(9), ntb_spad_count(9), ntb_spad_read(9), ntb_spad_write(9), ntb_peer_spad_addr(9), ntb_peer_spad_read(9), ntb_peer_spad_write(9), ntb_msg_count(9), ntb_msg_inbits(9), ntb_msg_outbits(9), ntb_msg_read_sts(9), ntb_msg_clear_sts(9), ntb_msg_set_mask(9), ntb_msg_clear_mask(9), ntb_msg_read(9), ntb_peer_msg_write(9), ntb_get_dma_dev(9), ntb_peer_highest_mw_idx(9)


okay that's the whole page bestie, go program some memory windows πŸ’œ

this one ships straight out of ./include/linux, dated October 2026 β€” mwah, see u in the next manpage πŸ§šβ€β™€οΈπŸ’…

πŸ“¦ where this page comes from