Merge pull request #1816 from ez-lbz/fix/rxe-inline-list-overflow rxe: Prevent overflow in wr_set_inline_data_list() bound check
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ccd87f..3fe3fab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -84,7 +84,7 @@ set(PACKAGE_NAME "RDMA") # See Documentation/versioning.md -set(PACKAGE_VERSION "66.0") +set(PACKAGE_VERSION "67.0") # When this is changed the values in these files need changing too: # debian/control # debian/libibverbs1.symbols @@ -231,7 +231,11 @@ FIND_PACKAGE(PythonLibs ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} EXACT) elseif (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12") set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) - FIND_PACKAGE(Python 3 REQUIRED COMPONENTS Interpreter OPTIONAL_COMPONENTS Development) + if(NO_PYVERBS) + FIND_PACKAGE(Python 3 REQUIRED COMPONENTS Interpreter) + else() + FIND_PACKAGE(Python 3 REQUIRED COMPONENTS Interpreter OPTIONAL_COMPONENTS Development) + endif() set(PYTHON_EXECUTABLE ${Python_EXECUTABLE}) if(Python_Development_FOUND) set(PYTHONLIBS_FOUND ${Python_Development_FOUND}) @@ -804,6 +808,7 @@ # Providers if (HAVE_COHERENT_DMA) add_subdirectory(providers/bnxt_re) +add_subdirectory(providers/bnxt_re/man) add_subdirectory(providers/cxgb4) # NO SPARSE add_subdirectory(providers/efa) add_subdirectory(providers/efa/man)
diff --git a/debian/changelog b/debian/changelog index 0c35a53..5d12df7 100644 --- a/debian/changelog +++ b/debian/changelog
@@ -1,4 +1,4 @@ -rdma-core (66.0-1) unstable; urgency=medium +rdma-core (67.0-1) unstable; urgency=medium * New upstream release.
diff --git a/debian/ibverbs-providers.install b/debian/ibverbs-providers.install index 38d870e..2ee167b 100644 --- a/debian/ibverbs-providers.install +++ b/debian/ibverbs-providers.install
@@ -1,4 +1,5 @@ etc/libibverbs.d/ +usr/lib/*/libbnxt_re.so.* usr/lib/*/libefa.so.* usr/lib/*/libhns.so.* usr/lib/*/libibverbs/lib*-rdmav*.so
diff --git a/debian/ibverbs-providers.symbols b/debian/ibverbs-providers.symbols index 044b4c9..d193e0b 100644 --- a/debian/ibverbs-providers.symbols +++ b/debian/ibverbs-providers.symbols
@@ -1,3 +1,11 @@ +libbnxt_re.so.1 ibverbs-providers #MINVER# +* Build-Depends-Package: libibverbs-dev + BNXT_RE_1.1@BNXT_RE_1.1 64 + bnxt_re_dv_alloc_db_region@BNXT_RE_1.1 64 + bnxt_re_dv_create_cq@BNXT_RE_1.1 64 + bnxt_re_dv_create_qp@BNXT_RE_1.1 64 + bnxt_re_dv_free_db_region@BNXT_RE_1.1 64 + bnxt_re_dv_get_default_db_region@BNXT_RE_1.1 64 libmlx4.so.1 ibverbs-providers #MINVER# * Build-Depends-Package: libibverbs-dev MLX4_1.0@MLX4_1.0 15 @@ -224,3 +232,5 @@ ionic_dv_pd_set_udma_mask@IONIC_1.0 59 ionic_dv_pd_set_sqcmb@IONIC_1.0 59 ionic_dv_pd_set_rqcmb@IONIC_1.0 59 + IONIC_1.1@IONIC_1.1 66 + ionic_dv_create_qp_ex@IONIC_1.1 66
diff --git a/debian/libibnetdisc-dev.install b/debian/libibnetdisc-dev.install index bd5f4c7..9b4dde3 100644 --- a/debian/libibnetdisc-dev.install +++ b/debian/libibnetdisc-dev.install
@@ -2,12 +2,9 @@ usr/lib/*/libibnetdisc*.a usr/lib/*/libibnetdisc*.so usr/lib/*/pkgconfig/libibnetdisc.pc -usr/share/man/man3/ibnd_debug.3 usr/share/man/man3/ibnd_destroy_fabric.3 usr/share/man/man3/ibnd_discover_fabric.3 usr/share/man/man3/ibnd_find_node_dr.3 usr/share/man/man3/ibnd_find_node_guid.3 usr/share/man/man3/ibnd_iter_nodes.3 usr/share/man/man3/ibnd_iter_nodes_type.3 -usr/share/man/man3/ibnd_set_max_smps_on_wire.3 -usr/share/man/man3/ibnd_show_progress.3
diff --git a/debian/libibverbs-dev.install b/debian/libibverbs-dev.install index 141ad79..ecf6d36 100644 --- a/debian/libibverbs-dev.install +++ b/debian/libibverbs-dev.install
@@ -1,4 +1,6 @@ usr/include/infiniband/arch.h +usr/include/infiniband/bnxt_re-hsi.h +usr/include/infiniband/bnxt_re_dv.h usr/include/infiniband/efadv.h usr/include/infiniband/hnsdv.h usr/include/infiniband/ib_user_ioctl_verbs.h @@ -15,6 +17,8 @@ usr/include/infiniband/verbs.h usr/include/infiniband/verbs_api.h usr/lib/*/lib*-rdmav*.a +usr/lib/*/libbnxt_re.a +usr/lib/*/libbnxt_re.so usr/lib/*/libefa.a usr/lib/*/libefa.so usr/lib/*/libhns.a @@ -29,6 +33,7 @@ usr/lib/*/libmlx4.so usr/lib/*/libmlx5.a usr/lib/*/libmlx5.so +usr/lib/*/pkgconfig/libbnxt_re.pc usr/lib/*/pkgconfig/libefa.pc usr/lib/*/pkgconfig/libhns.pc usr/lib/*/pkgconfig/libibverbs.pc @@ -36,6 +41,7 @@ usr/lib/*/pkgconfig/libmana.pc usr/lib/*/pkgconfig/libmlx4.pc usr/lib/*/pkgconfig/libmlx5.pc +usr/share/man/man3/bnxt_re_dv*.3 usr/share/man/man3/efadv_*.3 usr/share/man/man3/hnsdv_*.3 usr/share/man/man3/ibv_* @@ -45,6 +51,7 @@ usr/share/man/man3/mlx4dv_*.3 usr/share/man/man3/mlx5dv_*.3 usr/share/man/man3/mult_to_ibv_rate.3 +usr/share/man/man7/bnxt_re_dv.7 usr/share/man/man7/efadv.7 usr/share/man/man7/hnsdv.7 usr/share/man/man7/ionicdv.7
diff --git a/debian/libibverbs1.symbols b/debian/libibverbs1.symbols index 3b74941..b1c0aa2 100644 --- a/debian/libibverbs1.symbols +++ b/debian/libibverbs1.symbols
@@ -16,6 +16,7 @@ IBVERBS_1.16@IBVERBS_1.16 62 IBVERBS_1.17@IBVERBS_1.17 64 IBVERBS_1.18@IBVERBS_1.18 65 + IBVERBS_1.19@IBVERBS_1.19 66 (symver)IBVERBS_PRIVATE_65 65 _ibv_query_comp_cntr_caps@IBVERBS_1.18 65 _ibv_query_gid_ex@IBVERBS_1.11 32 @@ -28,6 +29,7 @@ ibv_alloc_dmah@IBVERBS_1.15 59 ibv_alloc_pd@IBVERBS_1.0 1.1.6 ibv_alloc_pd@IBVERBS_1.1 1.1.6 + ibv_alloc_user_buf@IBVERBS_1.19 66 ibv_attach_mcast@IBVERBS_1.0 1.1.6 ibv_attach_mcast@IBVERBS_1.1 1.1.6 ibv_close_device@IBVERBS_1.0 1.1.6 @@ -73,6 +75,7 @@ ibv_free_buf@IBVERBS_1.17 64 ibv_free_device_list@IBVERBS_1.0 1.1.6 ibv_free_device_list@IBVERBS_1.1 1.1.6 + ibv_free_user_buf@IBVERBS_1.19 66 ibv_get_async_event@IBVERBS_1.0 1.1.6 ibv_get_async_event@IBVERBS_1.1 1.1.6 ibv_get_cq_event@IBVERBS_1.0 1.1.6
diff --git a/infiniband-diags/man/check_lft_balance.8.in.rst b/infiniband-diags/man/check_lft_balance.8.in.rst index 92b7a8a..76bb2db 100644 --- a/infiniband-diags/man/check_lft_balance.8.in.rst +++ b/infiniband-diags/man/check_lft_balance.8.in.rst
@@ -13,15 +13,18 @@ SYNOPSIS ======== -check_lft_balance.sh [-hRv] +check_lft_balance -l <lft-output> -i <ibnetdiscover-cache> [-e] [-v] DESCRIPTION =========== -check_lft_balance.sh is a script which checks for balancing in Infiniband +check_lft_balance is a script which checks for balancing in Infiniband unicast forwarding tables. It analyzes the output of -**dump_lfts(8)** and **iblinkinfo(8)** +**dump_lfts(8)** and an **ibnetdiscover** cache file + +On non-Debian distributions, the script is installed as +**check_lft_balance.pl**. OPTIONS ======= @@ -29,14 +32,18 @@ **-h** show help -**-R** - Recalculate dump_lfts information, ie do not use the cached - information. This option is slower but should be used if the diag - tools have not been used for some time or if there are other reasons to - believe that the fabric has changed. +**-l <lft-output>** + file containing the output of **dump_lfts(8)** (required) + +**-i <ibnetdiscover-cache>** + file containing the cache generated by **ibnetdiscover --cache** + (required) + +**-e** + turn on heuristic(s) to look at switch balances deeper **-v** - verbose output + verbose output, output all switches SEE ALSO ========
diff --git a/infiniband-diags/man/saquery.8.in.rst b/infiniband-diags/man/saquery.8.in.rst index 344d815..587dbb9 100644 --- a/infiniband-diags/man/saquery.8.in.rst +++ b/infiniband-diags/man/saquery.8.in.rst
@@ -184,7 +184,6 @@ ------------------- .. include:: common/opt_t.rst -.. include:: common/opt_o-outstanding_smps.rst .. include:: common/opt_node_name_map.rst .. include:: common/opt_z-config.rst @@ -202,7 +201,7 @@ DEPENDENCIES ============ -OpenSM (or other running SM/SA), libosmcomp, libibumad, libibmad +OpenSM (or other running SM/SA), libibumad, libibmad, libibnetdisc AUTHORS =======
diff --git a/kernel-boot/rdma_topo b/kernel-boot/rdma_topo index 9b280a8..3b2ffa5 100755 --- a/kernel-boot/rdma_topo +++ b/kernel-boot/rdma_topo
@@ -326,6 +326,7 @@ PCI_VDEVICE("MELLANOX", 0x1021): "cx_nic", # ConnectX-7 PCI_VDEVICE("MELLANOX", 0x1023): "cx_nic", # ConnectX-8 PCI_VDEVICE("MELLANOX", 0x1025): "cx_nic", # ConnectX-9 + PCI_VDEVICE("MELLANOX", 0x101E): "cx_vnic", # ConnectX-* VF PCI_VDEVICE("MELLANOX", 0xA2DC): "bf3_nic", # BlueField-3 PCI_VDEVICE("MELLANOX", 0x2100): "cx_dma", # ConnectX-8 DMA Controller PCI_VDEVICE("MELLANOX", 0x197B): "bf3_switch", # USP/DSP of a BF3 switch @@ -336,6 +337,11 @@ PCI_DEVICE_CLASS(0x060400): "bridge", # Generic PCI-PCI bridge / Root Port } +# USP/DSP hops in an NVCX complex, between an RP and a CX NIC / DMA / GPU. +NVCX_SWITCH_TYPES = {"cx_switch", "bridge"} + +CX_NIC_TYPES = {"cx_nic", "cx_vnic"} + dump_ignored = [ PCI_DEVICE_CLASS(0x060000), # Generic system peripheral @@ -397,13 +403,21 @@ self.children: Set[PCIDevice] = set() self.has_ats = False + @property + def is_vf(self) -> bool: + return self.device_type == "cx_vnic" + def finish_loading(self): """Do more expensive parsing operations""" - if self.device_type == "cx_nic" or self.device_type == "cx_dma": + if self.device_type in CX_NIC_TYPES or self.device_type == "cx_dma": self.vpd_v3, self.vpd_name, self.vpd_sn = parse_vpd(self.sysfs_device.vpd) - if "switch" in self.device_type or self.device_type.endswith("_rp"): + if ( + "switch" in self.device_type + or self.device_type.endswith("_rp") + or self.device_type == "bridge" + ): self.has_acs = self.get_acs_ctrl() is not None - if self.device_type == "cx_nic": + if self.device_type in CX_NIC_TYPES: self.has_ats = has_ats_cap(self.sysfs_device.config) def iterdownstream(self) -> Generator[PCIDevice, None, None]: @@ -440,45 +454,69 @@ class NVCX_Topo: class NIC(object): - def __init__(self, pfs: Set[PCIDevice]): - assert len(pfs) > 0 - self.pfs = pfs - self.parent = min(pfs, key=lambda pf: pf.bdf).parent - self.vpd_sn = min(pfs, key=lambda pf: pf.bdf).vpd_sn - if not all(pf.parent == self.parent for pf in pfs): - raise TopoUnexpectedError("All PFs of a NIC must have the same parent") - if not all(pf.vpd_sn == self.vpd_sn for pf in pfs): - raise TopoUnexpectedError("All PFs of a NIC must have the same VPD SN") + def __init__(self, fns: Set[PCIDevice]): + assert len(fns) > 0 + self.fns = fns + self.parent = min(fns, key=lambda fn: fn.bdf).parent + sns = {fn.vpd_sn for fn in fns if fn.vpd_sn} + if len(sns) > 1: + raise TopoUnexpectedError( + "All functions of a NIC must have the same VPD SN" + ) + self.vpd_sn = next(iter(sns)) if sns else None + if not all(fn.parent == self.parent for fn in fns): + raise TopoUnexpectedError( + "All functions of a NIC must have the same parent" + ) @property - def primary_pf(self) -> PCIDevice: - return min(self.pfs, key=lambda pf: pf.bdf) + def primary_fn(self) -> PCIDevice: + return min(self.fns, key=lambda fn: fn.bdf) + + def pfs(self) -> List[PCIDevice]: + return sorted( + (fn for fn in self.fns if not fn.is_vf), key=lambda x: x.bdf + ) + + def vfs(self) -> List[PCIDevice]: + return sorted((fn for fn in self.fns if fn.is_vf), key=lambda x: x.bdf) def to_dict(self) -> Dict[str, Any]: - return { + res: Dict[str, Any] = { "parent_bdf": str(self.parent.bdf) if self.parent else "UNKNOWN", - "ats": self.primary_pf.has_ats, - "pf_bdfs": [ - str(pf.bdf) for pf in sorted(self.pfs, key=lambda pf: pf.bdf) - ], + "ats": self.primary_fn.has_ats, } + pfs = self.pfs() + vfs = self.vfs() + if pfs: + res["pf_bdfs"] = [str(fn.bdf) for fn in pfs] + if vfs: + res["vf_bdfs"] = [str(fn.bdf) for fn in vfs] + return res - def str_single_pf(self) -> str: + def str_single_fn(self) -> str: res = "" - res += f"\tNIC ATS: {yesno(self.primary_pf.has_ats)}\n" + res += f"\tNIC ATS: {yesno(self.primary_fn.has_ats)}\n" subsystems: Dict[str, Set[str]] = collections.defaultdict(set) - for pf in self.pfs: - for k, v in pf.get_subsystems().items(): + vf_subsystems: Dict[str, Set[str]] = collections.defaultdict(set) + for fn in self.pfs(): + for k, v in fn.get_subsystems().items(): subsystems[k].update(v) + for fn in self.vfs(): + for k, v in fn.get_subsystems().items(): + vf_subsystems[k].update(v) res += print_list("RDMA device", subsystems["infiniband"]) + res += print_list("RDMA device VF", vf_subsystems["infiniband"]) res += print_list("Net device", subsystems["net"]) + res += print_list("Net device VF", vf_subsystems["net"]) return res[:-1] def __str__(self) -> str: parent_bdf = self.parent.bdf if self.parent else "UNKNOWN" res = f"RDMA NIC Parent={parent_bdf}\n" - res += print_list("NIC PCI device", [str(pf.bdf) for pf in self.pfs]) - res += self.str_single_pf() + res += print_list("NIC PCI device", [str(fn.bdf) for fn in self.pfs()]) + res += print_list("NIC PCI VF", [str(fn.bdf) for fn in self.vfs()]) + res += self.str_single_fn() return res class Board(object): @@ -486,7 +524,7 @@ def nic_sort_key(nic): if nic.parent: return (0, nic.parent.bdf) - return (1, nic.primary_pf.bdf) + return (1, nic.primary_fn.bdf) self.nics = sorted(nics, key=nic_sort_key) self.sn = next(iter(nics)).vpd_sn @@ -507,57 +545,79 @@ res += "\n" return res[:-1] - def __init__(self, pfs: Set[PCIDevice]): - assert len(pfs) > 0 + def __init__(self, fns: Set[PCIDevice]): + assert len(fns) > 0 - pfs_by_sn: Dict[Optional[str], Set[PCIDevice]] = collections.defaultdict(set) - for pf in pfs: - pfs_by_sn[pf.vpd_sn].add(pf) + fns_by_sn: Dict[Optional[str], Set[PCIDevice]] = collections.defaultdict(set) + orphans: List[PCIDevice] = [] + # VFs usually have no VPD, so they have no vpd_sn. Map each parent of a + # function that does have a serial to that serial, then attach orphans + # to the NIC/board with the same parent. Unmatched orphans stay in the + # None (UNKNOWN) board. + sn_by_parent: Dict[Optional[PCIDevice], str] = {} + for fn in fns: + if fn.vpd_sn: + fns_by_sn[fn.vpd_sn].add(fn) + existing_sn = sn_by_parent.get(fn.parent) + if existing_sn is not None and existing_sn != fn.vpd_sn: + raise TopoUnexpectedError( + "Multiple VPD SNs under the same NIC parent" + ) + sn_by_parent[fn.parent] = fn.vpd_sn + else: + orphans.append(fn) + + for fn in orphans: + sn = sn_by_parent.get(fn.parent) + fns_by_sn[sn].add(fn) boards = set() - for board_pfs in pfs_by_sn.values(): - pfs_by_nic: Dict[Optional[PCIDevice], Set[PCIDevice]] = ( + for board_fns in fns_by_sn.values(): + fns_by_nic: Dict[Optional[PCIDevice], Set[PCIDevice]] = ( collections.defaultdict(set) ) - for pf in board_pfs: - pfs_by_nic[pf.parent].add(pf) + for fn in board_fns: + fns_by_nic[fn.parent].add(fn) nics: Set[NVCX_Topo.NIC] = set() - for nic_pfs in pfs_by_nic.values(): - nics.add(NVCX_Topo.NIC(nic_pfs)) + for nic_fns in fns_by_nic.values(): + nics.add(NVCX_Topo.NIC(nic_fns)) boards.add(NVCX_Topo.Board(nics)) self.boards = sorted(boards, key=lambda b: b.sn or "") @property - def primary_pf(self) -> PCIDevice: - return min(self.pfs, key=lambda pf: pf.bdf) + def primary_fn(self) -> PCIDevice: + return min(self.fns, key=lambda fn: fn.bdf) @property - def pfs(self) -> Set[PCIDevice]: - return set(pf for board in self.boards for nic in board.nics for pf in nic.pfs) + def fns(self) -> Set[PCIDevice]: + return set(fn for board in self.boards for nic in board.nics for fn in nic.fns) def to_dict(self) -> Dict[str, Any]: - if len(self.pfs) == 1: - return { - "rdma_nic_pf_bdf": str(next(iter(self.pfs)).bdf), - "rdma_nic_ats": next(iter(self.pfs)).has_ats, - } + if len(self.fns) == 1: + fn = next(iter(self.fns)) + res: Dict[str, Any] = {"rdma_nic_ats": fn.has_ats} + if fn.is_vf: + res["rdma_nic_vf_bdf"] = str(fn.bdf) + else: + res["rdma_nic_pf_bdf"] = str(fn.bdf) + return res return { "rdma_nic_boards": [board.to_dict() for board in self.boards] } def topo_str_key(self) -> str: - if len(self.pfs) == 1: - return f"RDMA NIC={next(iter(self.pfs)).bdf}" + if len(self.fns) == 1: + return f"RDMA NIC={next(iter(self.fns)).bdf}" return "" def topo_str(self) -> str: - if len(self.pfs) == 1: - return self.boards[0].nics[0].str_single_pf() + if len(self.fns) == 1: + return self.boards[0].nics[0].str_single_fn() res = "" for board in self.boards: @@ -570,9 +630,23 @@ @property @abstractmethod def primary_nic(self) -> PCIDevice: - """Primary ConnectX PF for this complex.""" + """Primary ConnectX NIC function for this complex.""" pass + @property + @abstractmethod + def fns(self) -> Set[PCIDevice]: + """All ConnectX NIC functions for this complex.""" + pass + + def pfs(self) -> List[PCIDevice]: + """Physical ConnectX NIC functions, sorted by BDF.""" + return sorted((fn for fn in self.fns if not fn.is_vf), key=lambda x: x.bdf) + + def vfs(self) -> List[PCIDevice]: + """Virtual ConnectX NIC functions, sorted by BDF.""" + return sorted((fn for fn in self.fns if fn.is_vf), key=lambda x: x.bdf) + @abstractmethod def compute_acs(self, virt: Optional[bool]) -> Dict[PCIDevice, str]: """Computes the ACS values for this complex. @@ -611,13 +685,13 @@ class NVCX_DMA_Complex(NVCX_Complex): - """Hold the related PCI functions together. A complex includes a CX PF, a CX - DMA function, an GPU and related PCI switches in the DMA function - segment.""" + """Hold the related PCI functions together. A DMA complex includes CX NIC + functions, a CX DMA function, a GPU and related PCI switches in the DMA + function segment.""" - def __init__(self, cx_pfs: Set[PCIDevice], cx_dma: PCIDevice, nvgpu: PCIDevice): - self.cx_pfs = cx_pfs - {cx_dma} - self.cx_pf = sorted(self.cx_pfs, key=lambda x: x.bdf)[0] + def __init__(self, cx_fns: Set[PCIDevice], cx_dma: PCIDevice, nvgpu: PCIDevice): + self.cx_fns = cx_fns - {cx_dma} + self.cx_fn = sorted(self.cx_fns, key=lambda x: x.bdf)[0] self.cx_dma = cx_dma self.nvgpu = nvgpu @@ -636,13 +710,17 @@ # approach would be fine, but also the GPU/NIC/NVMe could be # consistently paired based on the physical layout. self.nvmes: Set[PCIDevice] = set() - for pdev in self.cx_pf.iterfulltree(): + for pdev in self.cx_fn.iterfulltree(): if pdev.device_type == "nvme": self.nvmes.add(pdev) @property def primary_nic(self) -> PCIDevice: - return self.cx_pf + return self.cx_fn + + @property + def fns(self) -> Set[PCIDevice]: + return self.cx_fns def __find_shared_usp(self) -> PCIDevice: """Find the USP that is shared by both devices, the immediate downstream @@ -655,9 +733,9 @@ for pdev in self.cx_dma.iterupstream_path(): if pdev in common_path: - assert pdev.device_type == "cx_switch" + assert pdev.device_type in NVCX_SWITCH_TYPES for i in pdev.children: - assert i.device_type == "cx_switch" + assert i.device_type in NVCX_SWITCH_TYPES return pdev def compute_acs(self, _: Optional[bool]) -> Dict[PCIDevice, str]: @@ -691,25 +769,39 @@ assert pdev.has_acs acs[pdev] = "xx111x0" + # Enable ACS for the rest of the devices in the complex. + for ep in itertools.chain({self.nvgpu}, self.cx_fns, self.nvmes): + for pdev in ep.iterupstream_path(): + if pdev not in acs and pdev.has_acs: + acs[pdev] = kernel_acs_isolated(pdev.device_type) + return acs def to_dict(self) -> Dict[str, Any]: - res = { - "rdma_nic_pf_bdf": str(self.cx_pf.bdf), - "rdma_dma_bdf": str(self.cx_dma.bdf), - "gpu_bdf": str(self.nvgpu.bdf), - "subsystems": {}, - } - devname = self.cx_pf.vpd_name + pfs = self.pfs() + vfs = self.vfs() + res: Dict[str, Any] = {} + if pfs: + res["rdma_nic_pf_bdf"] = str(pfs[0].bdf) + if vfs: + res["rdma_nic_vf_bdfs"] = [str(fn.bdf) for fn in vfs] + res["rdma_dma_bdf"] = str(self.cx_dma.bdf) + res["gpu_bdf"] = str(self.nvgpu.bdf) + res["subsystems"] = {} + devname = self.cx_fn.vpd_name if devname: - res["rdma_nic_vpd_name"] = self.cx_pf.vpd_name - if self.cx_pf.numa_node is not None: - res["numa_node"] = self.cx_pf.numa_node + res["rdma_nic_vpd_name"] = self.cx_fn.vpd_name + if self.cx_fn.numa_node is not None: + res["numa_node"] = self.cx_fn.numa_node if self.nvmes: - res["nvme_bdf"] = str(next(iter(self.nvmes)).bdf) + nvme_bdfs = [ + str(pdev.bdf) for pdev in sorted(self.nvmes, key=lambda x: x.bdf) + ] + res["nvme_bdf"] = nvme_bdfs[0] + res["nvme_bdfs"] = nvme_bdfs for pdev in sorted( - itertools.chain(self.cx_pfs, [self.nvgpu, self.cx_dma], self.nvmes), + itertools.chain(self.cx_fns, [self.nvgpu, self.cx_dma], self.nvmes), key=lambda x: x.bdf, ): subsys = pdev.get_subsystems() @@ -720,23 +812,31 @@ return res def __str__(self): - res = f"RDMA NIC={self.cx_pf.bdf}, GPU={self.nvgpu.bdf}, RDMA DMA Function={self.cx_dma.bdf}\n" - devname = self.cx_pf.vpd_name + res = f"RDMA NIC={self.cx_fn.bdf}, GPU={self.nvgpu.bdf}, RDMA DMA Function={self.cx_dma.bdf}\n" + devname = self.cx_fn.vpd_name if devname: res += f"\t{devname}\n" - if self.cx_pf.numa_node is not None: - res += f"\tNUMA Node: {self.cx_pf.numa_node}\n" + if self.cx_fn.numa_node is not None: + res += f"\tNUMA Node: {self.cx_fn.numa_node}\n" - if len(self.cx_pfs): - res += print_list("NIC PCI device", [str(I.bdf) for I in self.cx_pfs]) + pfs = self.pfs() + vfs = self.vfs() + res += print_list("NIC PCI device", [str(fn.bdf) for fn in pfs]) + res += print_list("NIC PCI VF", [str(fn.bdf) for fn in vfs]) subsystems: Dict[str, Set[str]] = collections.defaultdict(set) - for pdev in itertools.chain(self.cx_pfs, [self.nvgpu, self.cx_dma], self.nvmes): + vf_subsystems: Dict[str, Set[str]] = collections.defaultdict(set) + for pdev in itertools.chain(pfs, [self.nvgpu, self.cx_dma], self.nvmes): for k, v in pdev.get_subsystems().items(): subsystems[k].update(v) + for pdev in vfs: + for k, v in pdev.get_subsystems().items(): + vf_subsystems[k].update(v) res += print_list("RDMA device", subsystems["infiniband"]) + res += print_list("RDMA device VF", vf_subsystems["infiniband"]) res += print_list("Net device", subsystems["net"]) + res += print_list("Net device VF", vf_subsystems["net"]) res += print_list("DRM device", subsystems["drm"]) res += print_list("NVMe device", subsystems["nvme"]) @@ -764,98 +864,92 @@ self, root_port: PCIDevice, shared_usp: PCIDevice, - cx_pf: PCIDevice, - nvgpu: PCIDevice, + cx_fns: Set[PCIDevice], + nvgpus: Set[PCIDevice], ): self.root_port = root_port - self.cx_pf = cx_pf - self.nvgpu = nvgpu - self.cx_pf_dsp = None - self.nvgpu_dsp = None + self.cx_topo = NVCX_Topo(cx_fns) + self.nvgpus = nvgpus + self.cx_nic_dsp: Set[PCIDevice] = set() + self.nvgpu_dsps: Set[PCIDevice] = set() for dsp in shared_usp.children: for pdev in dsp.iterdownstream(): - if pdev.device_type == "cx_nic": - if self.cx_pf_dsp is not None: - raise TopoNotSupportedError( - f"Multiple CX NIC DSPs under the same shared switch" - ) - self.cx_pf_dsp = dsp + if pdev.device_type in CX_NIC_TYPES: + self.cx_nic_dsp.add(dsp) break if pdev.device_type == "nvgpu": - if self.nvgpu_dsp is not None: - raise TopoNotSupportedError( - f"Multiple GPU DSPs under the same shared switch" - ) - self.nvgpu_dsp = dsp + self.nvgpu_dsps.add(dsp) break - if not self.cx_pf_dsp: + if len(self.cx_nic_dsp) == 0: raise TopoUnexpectedError(f"CX NIC DSP not found in the topology") - if not self.nvgpu_dsp: + if len(self.nvgpu_dsps) == 0: raise TopoUnexpectedError(f"GPU DSP not found in the topology") @property def primary_nic(self) -> PCIDevice: - return self.cx_pf + return self.cx_topo.primary_fn + + @property + def fns(self) -> Set[PCIDevice]: + return self.cx_topo.fns def compute_acs(self, virt: Optional[bool]) -> Dict[PCIDevice, str]: - if not self.cx_pf_dsp.has_acs: - raise TopoUnexpectedError(f"CX NIC DSP {self.cx_pf_dsp.bdf} lacks ACS") - if not self.nvgpu_dsp.has_acs: - raise TopoUnexpectedError(f"GPU DSP {self.nvgpu_dsp.bdf} lacks ACS") + for dsp in self.cx_nic_dsp: + if not dsp.has_acs: + raise TopoUnexpectedError(f"CX NIC DSP {dsp.bdf} lacks ACS") + for dsp in self.nvgpu_dsps: + if not dsp.has_acs: + raise TopoUnexpectedError(f"GPU DSP {dsp.bdf} lacks ACS") if not self.root_port.has_acs: raise TopoUnexpectedError(f"Root port {self.root_port.bdf} lacks ACS") if virt is None: raise TopoUnexpectedError("Could not determine virt mode") + acs: Dict[PCIDevice, str] = {} if virt: - return { - # The DSPs of the NIC which is non DD in the shared switch should - # have the following enabled: - # bit-6 : ACS Direct Translated P2P - # bit-4 : ACS Upstream Forwarding - # bit-3 : ACS P2P Completion Redirect - # bit-2 : ACS P2P Request Redirect - # bit-0 : ACS Source Validation - self.cx_pf_dsp: "1x111x1", - # The DSPs of the GPU in the shared switch and the RP of the NIC/GPU - # should have the following enabled, matching the kernel default: - # bit-4 : ACS Upstream Forwarding - # bit-3 : ACS P2P Completion Redirect - # bit-2 : ACS P2P Request Redirect - # bit-0 : ACS Source Validation - self.nvgpu_dsp: kernel_acs_isolated(self.nvgpu_dsp.device_type), - self.root_port: kernel_acs_isolated(self.root_port.device_type), - } - else: - return { - # The DSPs of both the NIC and GPU in the shared switch and - # RPs of the NIC/GPU should have the following disabled: - # bit-4 : ACS Upstream Forwarding - # bit-3 : ACS P2P Completion Redirect - # bit-2 : ACS P2P Request Redirect - # bit-0 : ACS Source Validation - self.cx_pf_dsp: "xx000x0", - self.nvgpu_dsp: "xx000x0", - self.root_port: "xx000x0", - } + # The DSPs of the NICs which are not DD in the shared switch should + # have the following enabled: + # bit-6 : ACS Direct Translated P2P + # bit-4 : ACS Upstream Forwarding + # bit-3 : ACS P2P Completion Redirect + # bit-2 : ACS P2P Request Redirect + # bit-0 : ACS Source Validation + acs = {dsp: "1x111x1" for dsp in self.cx_nic_dsp} + + # Remaining ACS-capable bridges on the NIC/GPU paths: + # virt: match kernel default (ACS isolated) + # no-virt: disable ACS + leftover = ( + kernel_acs_isolated if virt else lambda _: "xx000x0" + ) + for ep in itertools.chain(self.nvgpus, self.cx_topo.fns): + for pdev in ep.iterupstream_path(): + if pdev not in acs and pdev.has_acs: + acs[pdev] = leftover(pdev.device_type) + + return acs def to_dict(self) -> Dict[str, Any]: - res = { - "rdma_nic_pf_bdf": str(self.cx_pf.bdf), - "gpu_bdf": str(self.nvgpu.bdf), - "subsystems": {}, - } - devname = self.cx_pf.vpd_name + res: Dict[str, Any] = {} + if len(self.nvgpus) == 1: + res["gpu_bdf"] = str(next(iter(self.nvgpus)).bdf) + else: + res["gpu_bdfs"] = [ + str(gpu.bdf) for gpu in sorted(self.nvgpus, key=lambda x: x.bdf) + ] + res["subsystems"] = {} + res.update(self.cx_topo.to_dict()) + devname = self.cx_topo.primary_fn.vpd_name if devname: - res["rdma_nic_vpd_name"] = self.cx_pf.vpd_name - if self.cx_pf.numa_node is not None: - res["numa_node"] = self.cx_pf.numa_node - res["rdma_nic_ats"] = self.cx_pf.has_ats + res["rdma_nic_vpd_name"] = devname + numa_node = self.cx_topo.primary_fn.numa_node + if numa_node is not None: + res["numa_node"] = numa_node for pdev in sorted( - itertools.chain([self.cx_pf, self.nvgpu]), + itertools.chain(self.cx_topo.fns, self.nvgpus), key=lambda x: x.bdf, ): subsys = pdev.get_subsystems() @@ -866,50 +960,67 @@ return res def __check_ats(self, virt: bool) -> bool: - status = "available" if self.cx_pf.has_ats else "not available" - msg = f"ATS capability for {self.cx_pf.device_type} {self.cx_pf.bdf} is {status}" + def check_one(dev: PCIDevice, virt: bool) -> bool: + status = "available" if dev.has_ats else "not available" + msg = f"ATS capability for {dev.device_type} {dev.bdf} is {status}" - if self.cx_pf.has_ats != virt: - check_fail(msg) - return False + if dev.has_ats != virt: + check_fail(msg) + return False - check_ok(msg) - return True + check_ok(msg) + return True + + return all( + [ + check_one(fn, virt) + for fn in sorted(self.cx_topo.fns, key=lambda x: x.bdf) + ] + ) def __check_iommu_group(self, virt: bool) -> bool: - cxpf = f"{self.cx_pf.device_type} {self.cx_pf.bdf}" - nvgpu = f"{self.nvgpu.device_type} {self.nvgpu.bdf}" - prefix = f"Kernel iommu_group for {cxpf} and {nvgpu}" + def check_one(fn: PCIDevice, nvgpu: PCIDevice, virt: bool) -> bool: + cxfn = f"{fn.device_type} {fn.bdf}" + gpu = f"{nvgpu.device_type} {nvgpu.bdf}" + prefix = f"Kernel iommu_group for {cxfn} and {gpu}" - equal = f"equal {self.cx_pf.iommu_group} == {self.nvgpu.iommu_group}" - not_equal = f"not equal {self.cx_pf.iommu_group} != {self.nvgpu.iommu_group}" + equal = f"equal {fn.iommu_group} == {nvgpu.iommu_group}" + not_equal = f"not equal {fn.iommu_group} != {nvgpu.iommu_group}" - if virt: - if self.cx_pf.iommu_group is None: - check_fail(f"Kernel iommu_group is missing for {cxpf}") - return False + if virt: + if fn.iommu_group is None: + check_fail(f"Kernel iommu_group is missing for {cxfn}") + return False - if self.nvgpu.iommu_group is None: - check_fail(f"Kernel iommu_group is missing for {nvgpu}") - return False + if nvgpu.iommu_group is None: + check_fail(f"Kernel iommu_group is missing for {gpu}") + return False - if self.cx_pf.iommu_group == self.nvgpu.iommu_group: - check_fail(f"{prefix} are {equal}") - return False + if fn.iommu_group == nvgpu.iommu_group: + check_fail(f"{prefix} are {equal}") + return False - check_ok(f"{prefix} are {not_equal}") - return True - else: - if self.cx_pf.iommu_group is None and self.nvgpu.iommu_group is None: - check_ok(f"{prefix} are not set") + check_ok(f"{prefix} are {not_equal}") + return True + else: + if fn.iommu_group is None and nvgpu.iommu_group is None: + check_ok(f"{prefix} are not set") + return True + + if fn.iommu_group != nvgpu.iommu_group: + check_fail(f"{prefix} are {not_equal}") + return False + + check_ok(f"{prefix} are {equal}") return True - if self.cx_pf.iommu_group != self.nvgpu.iommu_group: - check_fail(f"{prefix} are {not_equal}") - return False - - check_ok(f"{prefix} are {equal}") - return True + return all( + [ + check_one(fn, nvgpu, virt) + for nvgpu in sorted(self.nvgpus, key=lambda x: x.bdf) + for fn in sorted(self.cx_topo.fns, key=lambda x: x.bdf) + ] + ) def check(self, virt: Optional[bool]) -> bool: assert virt is not None @@ -918,21 +1029,29 @@ return res_ats and res_iommu_group def __str__(self): - res = f"RDMA NIC={self.cx_pf.bdf}, GPU={self.nvgpu.bdf}\n" - devname = self.cx_pf.vpd_name + res = "" + topo_str_key = self.cx_topo.topo_str_key() + if topo_str_key != "": + res = f"{topo_str_key}, " + + gpu_bdfs = ";".join( + str(gpu.bdf) for gpu in sorted(self.nvgpus, key=lambda x: x.bdf) + ) + res += f"GPU={gpu_bdfs}\n" + + devname = self.primary_nic.vpd_name if devname: res += f"\t{devname}\n" - if self.cx_pf.numa_node is not None: - res += f"\tNUMA Node: {self.cx_pf.numa_node}\n" + numa_node = self.cx_topo.primary_fn.numa_node + if numa_node is not None: + res += f"\tNUMA Node: {numa_node}\n" - res += f"\tNIC ATS: {yesno(self.cx_pf.has_ats)}\n" + res += f"{self.cx_topo.topo_str()}\n" subsystems: Dict[str, Set[str]] = collections.defaultdict(set) - for pdev in [self.cx_pf, self.nvgpu]: - for k, v in pdev.get_subsystems().items(): + for nvgpu in self.nvgpus: + for k, v in nvgpu.get_subsystems().items(): subsystems[k].update(v) - res += print_list("RDMA device", subsystems["infiniband"]) - res += print_list("Net device", subsystems["net"]) res += print_list("DRM device", subsystems["drm"]) res += print_list("NVMe device", subsystems["nvme"]) @@ -943,20 +1062,24 @@ def __init__( self, numa_node: int, - cx_pfs: Set[PCIDevice], + cx_fns: Set[PCIDevice], nvgpus: Set[PCIDevice], ): - if not cx_pfs: + if not cx_fns: raise TopoUnexpectedError("No CX NICs found in NUMA-based complex") if not nvgpus: raise TopoUnexpectedError("No GPUs found in NUMA-based complex") self.numa_node = numa_node self.nvgpus = nvgpus - self.cx_topo = NVCX_Topo(cx_pfs) + self.cx_topo = NVCX_Topo(cx_fns) @property def primary_nic(self) -> PCIDevice: - return self.cx_topo.primary_pf + return self.cx_topo.primary_fn + + @property + def fns(self) -> Set[PCIDevice]: + return self.cx_topo.fns def compute_acs(self, _: Optional[bool]) -> Dict[PCIDevice, str]: # All are connected to RPs, which are handled by PCITopo.compute_acs @@ -969,11 +1092,11 @@ "subsystems": {}, } res.update(self.cx_topo.to_dict()) - devname = self.cx_topo.primary_pf.vpd_name + devname = self.cx_topo.primary_fn.vpd_name if devname: res["rdma_nic_vpd_name"] = devname for pdev in sorted( - itertools.chain(self.cx_topo.pfs, self.nvgpus), + itertools.chain(self.cx_topo.fns, self.nvgpus), key=lambda x: x.bdf, ): subsystems = pdev.get_subsystems() @@ -984,7 +1107,7 @@ return res def __check_iommu_group(self) -> bool: - devs = [*self.cx_topo.pfs, *self.nvgpus] + devs = [*self.cx_topo.fns, *self.nvgpus] iommu_groups = [dev.iommu_group for dev in devs] devs_without_iommu_group = [dev for dev in devs if dev.iommu_group is None] if len(devs_without_iommu_group) > 0: @@ -1010,15 +1133,15 @@ def __check_ats(self) -> bool: result = True - for cx_pf in self.cx_topo.pfs: - if cx_pf.has_ats: + for cx_fn in sorted(self.cx_topo.fns, key=lambda x: x.bdf): + if cx_fn.has_ats: check_fail( - f"ATS capability for {cx_pf.device_type} {cx_pf.bdf} is available" + f"ATS capability for {cx_fn.device_type} {cx_fn.bdf} is available" ) result = False else: check_ok( - f"ATS capability for {cx_pf.device_type} {cx_pf.bdf} is not available" + f"ATS capability for {cx_fn.device_type} {cx_fn.bdf} is not available" ) return result @@ -1046,10 +1169,10 @@ return res[:-1] -def check_parent(pdev: PCIDevice, parent_type: str): +def check_parent(pdev: PCIDevice, parent_types: Set[str]): if not pdev or not pdev.parent: return None - if pdev.parent.device_type != parent_type: + if pdev.parent.device_type not in parent_types: return None return pdev.parent @@ -1067,7 +1190,7 @@ virt: Optional[bool] = None, autodetect_virt: bool = True, ): - if sysfs_dump: + if sysfs_dump is not None: sysfs_devices = self.__parse_dump(sysfs_dump) else: sysfs_devices = [SysfsDevice(fn) for fn in os.listdir(DEVDIR)] @@ -1098,16 +1221,12 @@ ): return self.TopoType.NUMA - found = { - "cx_switch": False, - "nvgpu": False, - "cx_nic": False, - } - for pdev in self.devices.values(): - if pdev.device_type not in found.keys(): - continue - found[pdev.device_type] = True - if all(found.values()): + types = {pdev.device_type for pdev in self.devices.values()} + if ( + types & NVCX_SWITCH_TYPES + and "nvgpu" in types + and types & CX_NIC_TYPES + ): return self.TopoType.INLINE raise TopoNotSupportedError() @@ -1153,7 +1272,11 @@ def __get_nvcx_complex(self, cx_dma: PCIDevice): """Match the topology for the switch complex using a CX DMA function and a - single GPU. It has two nested switches: + single GPU. The GPU and DMA share a switch. The GPU may hang off that + switch directly, or behind an extra nested switch: + + RP --> SW -> CX_DMA + -> GPU RP --> SW -> CX_DMA -> SW -> GPU @@ -1162,117 +1285,136 @@ if not cx_dma.vpd_v3: raise TopoUnexpectedError(f"CX DMA function {cx_dma} does not have a VPD V3 UUID") - # The DMA and PF are matched using the UUID from the VPD - cx_pfs = self.vpd_v3s.get(cx_dma.vpd_v3) - if cx_pfs is None: + # The DMA and NIC functions are matched using the UUID from the VPD + cx_fns = self.vpd_v3s.get(cx_dma.vpd_v3) + if cx_fns is None: raise TopoUnexpectedError( - f"CX DMA function {cx_dma} does not have a matching PF, V3 UUID matching failed" + f"CX DMA function {cx_dma} does not have a matching NIC function, V3 UUID matching failed" ) # Path from the DMA to the root port - cx_dma_dsp = check_parent(cx_dma, "cx_switch") - cx_usp = check_parent(cx_dma_dsp, "cx_switch") - grace_rp = check_parent(cx_usp, "grace_rp") - if not grace_rp: + dma_dsp = check_parent(cx_dma, NVCX_SWITCH_TYPES) + shared_usp = check_parent(dma_dsp, NVCX_SWITCH_TYPES) + rp = check_parent(shared_usp, {"grace_rp", "generic_rp"}) + if not rp: raise TopoUnexpectedError( f"CX DMA function {cx_dma} has an unrecognized upstream path" ) # Path from the GPU to the root port nvgpus = [ - pdev for pdev in grace_rp.iterdownstream() if pdev.device_type == "nvgpu" + pdev for pdev in rp.iterdownstream() if pdev.device_type == "nvgpu" ] if len(nvgpus) != 1: raise TopoUnexpectedError(f"CX DMA function {cx_dma} does not have a nearby GPU") nvgpu = nvgpus[0] - nvgpu_dsp2 = check_parent(nvgpu, "cx_switch") - nvgpu_usp2 = check_parent(nvgpu_dsp2, "cx_switch") - nvgpu_dsp1 = check_parent(nvgpu_usp2, "cx_switch") - if cx_usp != check_parent(nvgpu_dsp1, "cx_switch"): + if check_parent(nvgpu, NVCX_SWITCH_TYPES) is None: raise TopoNotSupportedError( f"CX DMA function {cx_dma} has an unrecognized upstream path from the GPU" ) # Sanity check there is nothing unexpected in the topology - alldevs = { - cx_dma, - cx_dma_dsp, - cx_usp, - nvgpu, - nvgpu_dsp2, - nvgpu_usp2, - nvgpu_dsp1, - } - topodevs = set(grace_rp.iterdownstream()) + alldevs = {cx_dma, nvgpu} + for pdev in (cx_dma, nvgpu): + for ancestor in pdev.iterupstream_path(): + alldevs.add(ancestor) + if ancestor == shared_usp: + break + topodevs = set(rp.iterdownstream()) if alldevs != topodevs: raise TopoUnexpectedError( f"CX DMA function {cx_dma} has unexpected PCI devices in the topology" ) - return NVCX_DMA_Complex(cx_pfs, cx_dma, nvgpu) + return NVCX_DMA_Complex(cx_fns, cx_dma, nvgpu) def __get_nvcx_inline_complex(self, nvgpu: PCIDevice): - """Match the topology for the inline complex using a GPU and a CX NIC. + """Match the topology for the inline complex using one or more GPUs and + CX NICs. + The GPUs and NICs share a switch. The GPUs may hang off that switch + directly, or behind an extra nested switch: + + RP --> SW -> CX_NIC + -> GPU RP --> SW -> CX_NIC -> SW -> GPU """ assert nvgpu.device_type == "nvgpu" - nvgpu_dsp2 = check_parent(nvgpu, "cx_switch") - nvgpu_usp2 = check_parent(nvgpu_dsp2, "cx_switch") - nvgpu_dsp1 = check_parent(nvgpu_usp2, "cx_switch") - shared_usp1 = check_parent(nvgpu_dsp1, "cx_switch") - if not shared_usp1: + if check_parent(nvgpu, NVCX_SWITCH_TYPES) is None: raise TopoNotSupportedError( f"GPU {nvgpu.bdf} has an unrecognized upstream path" ) - for pdev in shared_usp1.iterupstream_path(): - if pdev.device_type == "generic_rp": + # Lowest ancestor that also has a CX NIC downstream is the shared USP. + shared_usp = None + for pdev in nvgpu.iterupstream_path(): + if pdev.device_type not in NVCX_SWITCH_TYPES: + continue + if any(d.device_type in CX_NIC_TYPES for d in pdev.iterdownstream()): + shared_usp = pdev + break + if not shared_usp: + raise TopoNotSupportedError( + f"GPU {nvgpu.bdf} has an unrecognized upstream path" + ) + + for pdev in shared_usp.iterupstream_path(): + if pdev.device_type.endswith("_rp"): root_port = pdev break else: raise TopoUnexpectedError( - f"Could not find root port for shared USP {shared_usp1.bdf}" + f"Could not find root port for shared USP {shared_usp.bdf}" ) - for pdev in shared_usp1.iterdownstream(): - if pdev.device_type == "cx_nic": - cx_nic = pdev - break - else: + cx_fns = { + pdev + for pdev in shared_usp.iterdownstream() + if pdev.device_type in CX_NIC_TYPES + } + + if len(cx_fns) == 0: raise TopoUnexpectedError(f"GPU {nvgpu} does not have a nearby CX NIC") - return NVCX_Inline_Complex(root_port, shared_usp1, cx_nic, nvgpu) + nvgpus = { + pdev + for pdev in shared_usp.iterdownstream() + if pdev.device_type == "nvgpu" + } + + return NVCX_Inline_Complex(root_port, shared_usp, cx_fns, nvgpus) def __get_nvcx_numa_complex(self, numa_node: int): """Match the topology for the NUMA complex. All CX NICs and GPUs on the same NUMA node are part of the same complex. """ - cx_pfs = [ + cx_fns = [ pdev for pdev in self.devices.values() - if pdev.numa_node == numa_node and pdev.device_type == "cx_nic" + if pdev.numa_node == numa_node and pdev.device_type in CX_NIC_TYPES ] nvgpus = [ pdev for pdev in self.devices.values() if pdev.numa_node == numa_node and pdev.device_type == "nvgpu" ] - return NVCX_NUMA_Complex(numa_node, cx_pfs, nvgpus) + return NVCX_NUMA_Complex(numa_node, cx_fns, nvgpus) def __auto_detect_virt(self) -> bool: """Auto-detect if virtualization will be used on this system""" - first = self.nvcxs[0].primary_nic.has_ats - if not all(nvcx.primary_nic.has_ats == first for nvcx in self.nvcxs): + has_ats_values = set() + for nvcx in self.nvcxs: + for pdev in nvcx.fns: + has_ats_values.add(pdev.has_ats) + if len(has_ats_values) != 1: raise TopoNotSupportedError( "Could not auto-detect virtualization. CX NICs have different" " ATS settings. Try explicitly setting --virt or --no-virt." ) - - return first + return has_ats_values.pop() def __build_topo(self): """Collect cross-device information together and build the NVCX_Complex @@ -1289,10 +1431,12 @@ nvcx = self.__get_nvcx_complex(pdev) self.nvcxs.append(nvcx) elif self.type == self.TopoType.INLINE: + matched_nvgpus: Set[PCIDevice] = set() for pdev in self.devices.values(): - if pdev.device_type == "nvgpu": + if pdev.device_type == "nvgpu" and pdev not in matched_nvgpus: nvcx = self.__get_nvcx_inline_complex(pdev) self.nvcxs.append(nvcx) + matched_nvgpus.update(nvcx.nvgpus) elif self.type == self.TopoType.NUMA: numa_nodes = { pdev.numa_node @@ -1346,14 +1490,17 @@ return acs -def add_sysfs_dump_argument(parser): +def add_sysfs_dump_argument(parser, help_note: Optional[str] = None): + help_text = "Use a file produced by the rdma_topo dump command as input" + if help_note: + help_text = f"{help_text}. {help_note}" parser.add_argument( "-F", "--sysfs-dump-file", action="store", default=None, dest="sysfs_dump", - help="Use a file produced by the rdma_topo dump command as input", + help=help_text, ) @@ -1448,6 +1595,7 @@ help="Grub dropin file to use for the kernel command line", ) add_virt_argument(parser) + add_sysfs_dump_argument(parser, help_note="Requires -n/--dry-run") def cmd_write_grub_acs(args): @@ -1459,7 +1607,7 @@ removed. This command is intended for Debian style systems with a /etc/default/grub.d and update-grub command.""" try: - topo = PCITopo(None, args.virt) + topo = PCITopo(args.sysfs_dump, args.virt) except TopoNotSupportedError as e: if args.dry_run: raise @@ -1516,6 +1664,7 @@ help="Output the setpci commands to stdout and make no changes", ) add_virt_argument(parser) + add_sysfs_dump_argument(parser, help_note="Requires -n/--dry-run") def cmd_setpci_acs(args): @@ -1528,7 +1677,7 @@ NOTE: In this configuration unprivileged userspace can trigger platform RAS failures, use with caution! """ - topo = PCITopo(None, args.virt) + topo = PCITopo(args.sysfs_dump, args.virt) acs = topo.compute_acs() cmds: List[List[str]] = [] for pdev, acs in sorted(acs.items(), key=lambda x: x[0].bdf): @@ -1676,6 +1825,14 @@ # argparse will set 'func' to the cmd_* that executes this command args = parser.parse_args() + if ( + getattr(args, "sysfs_dump", None) is not None + and hasattr(args, "dry_run") + and not args.dry_run + ): + parser.error( + f"-F/--sysfs-dump-file requires -n/--dry-run for sub-command '{args.command}'" + ) try: args.func(args) except CommandError as e:
diff --git a/kernel-boot/rdma_topo_unit_test.py b/kernel-boot/rdma_topo_unit_test.py index 3482023..ff5bfc8 100644 --- a/kernel-boot/rdma_topo_unit_test.py +++ b/kernel-boot/rdma_topo_unit_test.py
@@ -76,6 +76,7 @@ dev.vpd_sn = vpd_sn dev.parent = parent dev.has_ats = has_ats + dev.is_vf = False dev.get_subsystems.return_value = subsystems or {} return dev @@ -90,7 +91,7 @@ def make_nic( - pf_bdfs: List[str], + fn_bdfs: List[str], parent_bdf: Optional[str] = None, vpd_sn: Optional[str] = None, has_ats: bool = False, @@ -102,7 +103,7 @@ make_dev( bdf, vpd_sn=vpd_sn, parent=parent, has_ats=has_ats, subsystems=subsystems ) - for bdf in pf_bdfs + for bdf in fn_bdfs ] return NVCX_Topo.NIC(set(devs)) @@ -117,7 +118,7 @@ nic = make_nic(["0000:00:01.0"], parent_bdf=None, vpd_sn=None) assert nic.parent is None assert nic.vpd_sn is None - assert len(nic.pfs) == 1 + assert len(nic.fns) == 1 def test_single_pf_with_parent_and_sn(self): nic = make_nic(["0000:00:01.0"], parent_bdf="0000:00:00.0", vpd_sn="SN123") @@ -130,7 +131,7 @@ parent_bdf="0000:00:00.0", vpd_sn="SN123", ) - assert len(nic.pfs) == 2 + assert len(nic.fns) == 2 def test_multi_pf_different_parent_raises(self): parent_a = make_parent("0000:00:00.0") @@ -149,17 +150,17 @@ # --------------------------------------------------------------------------- -# NVCX_Topo.NIC — primary_pf +# NVCX_Topo.NIC — primary_fn # --------------------------------------------------------------------------- -class TestNVCX_Topo_NIC_PrimaryPf: +class TestNVCX_Topo_NIC_PrimaryFn: def test_multi_pf_returns_min_bdf(self): parent = make_parent("0000:00:00.0") dev_lo = make_dev("0000:00:01.0", parent=parent, vpd_sn="SN") dev_hi = make_dev("0000:00:02.0", parent=parent, vpd_sn="SN") nic = NVCX_Topo.NIC({dev_lo, dev_hi}) - assert nic.primary_pf is dev_lo + assert nic.primary_fn is dev_lo # --------------------------------------------------------------------------- @@ -380,7 +381,7 @@ topo = NVCX_Topo({dev1, dev2}) assert len(topo.boards) == 1 assert len(topo.boards[0].nics) == 1 - assert len(topo.boards[0].nics[0].pfs) == 2 + assert len(topo.boards[0].nics[0].fns) == 2 def test_two_pfs_different_parent_same_sn_two_nics_one_board(self): parent_a = make_parent("0000:00:00.0") @@ -401,32 +402,32 @@ # --------------------------------------------------------------------------- -# NVCX_Topo — pfs / primary_pf +# NVCX_Topo — fns / primary_fn # --------------------------------------------------------------------------- -class TestNVCX_Topo_Pfs: - def test_pfs_returns_all_devs(self): +class TestNVCX_Topo_Fns: + def test_fns_returns_all_devs(self): parent = make_parent("0000:00:00.0") dev1 = make_dev("0000:00:01.0", vpd_sn="SN123", parent=parent) dev2 = make_dev("0000:00:02.0", vpd_sn="SN123", parent=parent) topo = NVCX_Topo({dev1, dev2}) - assert topo.pfs == {dev1, dev2} + assert topo.fns == {dev1, dev2} - def test_primary_pf_is_min_bdf(self): + def test_primary_fn_is_min_bdf(self): parent = make_parent("0000:00:00.0") dev_lo = make_dev("0000:00:01.0", vpd_sn="SN123", parent=parent) dev_hi = make_dev("0000:00:02.0", vpd_sn="SN123", parent=parent) topo = NVCX_Topo({dev_lo, dev_hi}) - assert topo.primary_pf is dev_lo + assert topo.primary_fn is dev_lo - def test_primary_pf_across_boards(self): + def test_primary_fn_across_boards(self): parent_a = make_parent("0000:00:00.0") parent_b = make_parent("0000:00:10.0") dev_lo = make_dev("0000:00:01.0", vpd_sn="SN1", parent=parent_a) dev_hi = make_dev("0000:00:11.0", vpd_sn="SN2", parent=parent_b) topo = NVCX_Topo({dev_lo, dev_hi}) - assert topo.primary_pf is dev_lo + assert topo.primary_fn is dev_lo # ---------------------------------------------------------------------------
diff --git a/kernel-headers/rdma/bnxt_re-abi.h b/kernel-headers/rdma/bnxt_re-abi.h index 856a1b3..15ed2a5 100644 --- a/kernel-headers/rdma/bnxt_re-abi.h +++ b/kernel-headers/rdma/bnxt_re-abi.h
@@ -250,7 +250,7 @@ struct bnxt_re_db_region { __u32 dpi; __u32 reserved; - __aligned_u64 umdbr; + __aligned_u64 reserved2; }; enum bnxt_re_obj_dbr_alloc_attrs {
diff --git a/kernel-headers/rdma/ionic-abi.h b/kernel-headers/rdma/ionic-abi.h index 2c70ac1..3d8d569 100644 --- a/kernel-headers/rdma/ionic-abi.h +++ b/kernel-headers/rdma/ionic-abi.h
@@ -22,6 +22,10 @@ #define IONIC_CMB_WC 8 #define IONIC_CMB_UC 16 +enum ionic_ctx_resp_comp_mask { + IONIC_CTX_CMASK_IONIC_FLAGS = 1 << 0, +}; + struct ionic_ctx_req { __u32 rsvd[2]; }; @@ -46,8 +50,9 @@ __u8 udma_count; __u8 expdb_mask; __u8 expdb_qtypes; + __u8 rcq_sign_bit; - __u8 rsvd2[3]; + __u16 comp_mask; __aligned_u64 phc_offset; }; @@ -85,6 +90,8 @@ __u8 rq_cmb; __u8 udma_mask; __u8 rsvd[3]; + __u32 ionic_flags; + __u32 rsvd_pad; }; struct ionic_qp_resp {
diff --git a/libibnetdisc/man/CMakeLists.txt b/libibnetdisc/man/CMakeLists.txt index 01457dd..0c785b8 100644 --- a/libibnetdisc/man/CMakeLists.txt +++ b/libibnetdisc/man/CMakeLists.txt
@@ -5,10 +5,7 @@ ) rdma_alias_man_pages( - ibnd_discover_fabric.3 ibnd_debug.3 ibnd_discover_fabric.3 ibnd_destroy_fabric.3 - ibnd_discover_fabric.3 ibnd_set_max_smps_on_wire.3 - ibnd_discover_fabric.3 ibnd_show_progress.3 ibnd_find_node_guid.3 ibnd_find_node_dr.3 ibnd_iter_nodes.3 ibnd_iter_nodes_type.3 )
diff --git a/libibnetdisc/man/ibnd_discover_fabric.3 b/libibnetdisc/man/ibnd_discover_fabric.3 index baa4c81..9634a38 100644 --- a/libibnetdisc/man/ibnd_discover_fabric.3 +++ b/libibnetdisc/man/ibnd_discover_fabric.3
@@ -1,65 +1,74 @@ .TH IBND_DISCOVER_FABRIC 3 "July 25, 2008" "OpenIB" "OpenIB Programmer's Manual" .SH "NAME" -ibnd_discover_fabric, ibnd_destroy_fabric, ibnd_debug ibnd_show_progress \- initialize ibnetdiscover library. +ibnd_discover_fabric, ibnd_destroy_fabric \- initialize ibnetdiscover library. .SH "SYNOPSIS" .nf .B #include <infiniband/ibnetdisc.h> .sp -.BI "ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port *ibmad_port, int timeout_ms, ib_portid_t *from, int hops)" -.BI "void ibnd_destroy_fabric(ibnd_fabric_t *fabric)" -.BI "void ibnd_debug(int i)" -.BI "void ibnd_show_progress(int i)" -.BI "int ibnd_set_max_smps_on_wire(int i)" +.BI "ibnd_fabric_t *ibnd_discover_fabric(char " "*ca_name" ", int " "ca_port" ", ib_portid_t " "*from" ", struct ibnd_config " "*config)" +.BI "void ibnd_destroy_fabric(ibnd_fabric_t " "*fabric)" .SH "DESCRIPTION" .B ibnd_discover_fabric() -Discover the fabric connected to the port specified by ibmad_port, using a timeout specified. The "from" and "hops" parameters are optional and allow one to scan part of a fabric by specifying a node "from" and a number of hops away from that node to scan, "hops". This gives the user a "sub-fabric" which is "centered" anywhere they chose. +Discover the fabric connected to the port specified by ca_name and ca_port. The "from" parameter is optional and allows one to scan part of a fabric by specifying a node "from", giving the user a "sub-fabric" which is "centered" anywhere they chose. The "config" parameter tunes the scan (see "struct ibnd_config" below). -ibmad_port must be opened with at least IB_SMI_CLASS and IB_SMI_DIRECT_CLASS -classes for ibnd_discover_fabric to work. +ca_name and ca_port may be NULL/0, in which case a default CA and port are used. + +.TP +.B struct ibnd_config +Configuration which tunes the scan. The following members are +recognized (a value of 0 selects the library default): +.RS +.TP +.B show_progress +Indicate that the library should print debug output which shows +its progress through the fabric. +.TP +.B max_smps +Set the number of SMP's which will be issued on the wire simultaneously. +.TP +.B max_hops +Limit the maximum number of hops scanned away from the "from" node. +.TP +.B timeout_ms +Timeout in milliseconds used for each SMP request. +.TP +.B retries +Number of retries for each SMP request. +.TP +.B mkey +MKey used for SMP requests requiring authorization. +.RE .B ibnd_destroy_fabric() free all memory and resources associated with the fabric. -.B ibnd_debug() -Set the debug level to be printed as library operations take place. - -.B ibnd_show_progress() -Indicate that the library should print debug output which shows it's progress -through the fabric. - -.B ibnd_set_max_smps_on_wire() -Set the number of SMP's which will be issued on the wire simultaneously. - .SH "RETURN VALUE" .B ibnd_discover_fabric() return NULL on failure, otherwise a valid ibnd_fabric_t object. -.B ibnd_destory_fabric(), ibnd_debug() +.B ibnd_destroy_fabric() NONE -.B ibnd_set_max_smps_on_wire() -The previous value is returned - .SH "EXAMPLES" .B Discover the entire fabric connected to device "mthca0", port 1. - int mgmt_classes[2] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS}; - struct ibmad_port *ibmad_port = mad_rpc_open_port(ca, ca_port, mgmt_classes, 2); - ibnd_fabric_t *fabric = ibnd_discover_fabric(ibmad_port, 100, NULL, 0); + struct ibnd_config cfg = { 0 }; + ibnd_fabric_t *fabric = ibnd_discover_fabric("mthca0", 1, NULL, &cfg); ... ibnd_destroy_fabric(fabric); - mad_rpc_close_port(ibmad_port); .B Discover only a single node and those nodes connected to it. + struct ibnd_config cfg = { .max_hops = 1 }; + ib_portid_t port_id = { 0 }; ... str2drpath(&(port_id.drpath), from, 0, 0); ... - ibnd_discover_fabric(ibmad_port, 100, &port_id, 1); + ibnd_discover_fabric("mthca0", 1, &port_id, &cfg); ... .SH "SEE ALSO" - libibmad, mad_rpc_open_port + libibmad, str2drpath .SH "AUTHORS" .TP Ira Weiny <weiny2@llnl.gov>
diff --git a/libibnetdisc/man/ibnd_iter_nodes.3 b/libibnetdisc/man/ibnd_iter_nodes.3 index 469f07b..e083dd9 100644 --- a/libibnetdisc/man/ibnd_iter_nodes.3 +++ b/libibnetdisc/man/ibnd_iter_nodes.3
@@ -5,8 +5,8 @@ .nf .B #include <infiniband/ibnetdisc.h> .sp -.BI "void ibnd_iter_nodes(ibnd_fabric_t *fabric, ibnd_iter_func_t func, void *user_data)" -.BI "void ibnd_iter_nodes_type(ibnd_fabric_t *fabric, ibnd_iter_func_t func, ibnd_node_type_t type, void *user_data)" +.BI "void ibnd_iter_nodes(ibnd_fabric_t *fabric, ibnd_iter_node_func_t func, void *user_data)" +.BI "void ibnd_iter_nodes_type(ibnd_fabric_t *fabric, ibnd_iter_node_func_t func, int node_type, void *user_data)" .SH "DESCRIPTION" .B ibnd_iter_nodes() Itterate through all the nodes in the fabric and call "func" on them.
diff --git a/libibumad/man/umad_free_ca_device_list.3.md b/libibumad/man/umad_free_ca_device_list.3.md index c12f6e3..efe9528 100644 --- a/libibumad/man/umad_free_ca_device_list.3.md +++ b/libibumad/man/umad_free_ca_device_list.3.md
@@ -24,7 +24,7 @@ # DESCRIPTION **umad_free_ca_device_list()** frees the *struct umad_device_node* -list and its values that allocated with umad_get_ca_namelist(). +list and its values that allocated with umad_get_ca_device_list(). The argument head is list of *struct umad_device_node* filled with local IB devices(CAs) names.
diff --git a/libibverbs/CMakeLists.txt b/libibverbs/CMakeLists.txt index 6fd823e..24413bc 100644 --- a/libibverbs/CMakeLists.txt +++ b/libibverbs/CMakeLists.txt
@@ -22,7 +22,7 @@ rdma_library(ibverbs "${CMAKE_CURRENT_BINARY_DIR}/libibverbs.map" # See Documentation/versioning.md - 1 1.18.${PACKAGE_VERSION} + 1 1.19.${PACKAGE_VERSION} all_providers.c cmd.c cmd_ah.c
diff --git a/libibverbs/driver.h b/libibverbs/driver.h index b3cd883..3507999 100644 --- a/libibverbs/driver.h +++ b/libibverbs/driver.h
@@ -893,4 +893,35 @@ cmdb->fallback_ioctl_only = 1; } +/** + * Like fill_attr_in_buf_umem(), but also describes plain user virtual + * address buffers (IB_UVERBS_BUFFER_TYPE_VA). The attribute is always added + * and is mandatory, so only use it where the caller requires UMEM attribute + * support from the kernel (e.g. direct verbs), never on generic paths. + * In case the length is 0, the buffer size is used. + */ +static inline void +fill_attr_in_buf_umem_va(struct ibv_command_buffer *cmdb, uint16_t attr_id, + struct ib_uverbs_buffer_desc *storage, + struct ibv_buf *buf, void *addr, size_t length) +{ + if (!buf) + return; + + if (buf->dmabuf_fd != -1) { + fill_attr_in_buf_umem(cmdb, attr_id, storage, buf, addr, + length); + return; + } + + *storage = (struct ib_uverbs_buffer_desc){ + .type = IB_UVERBS_BUFFER_TYPE_VA, + .fd = -1, + .addr = (uintptr_t)(addr ? addr : buf->addr), + .length = length ? length : buf->size, + }; + fill_attr_in_ptr(cmdb, attr_id, storage); + cmdb->fallback_ioctl_only = 1; +} + #endif /* INFINIBAND_DRIVER_H */
diff --git a/libibverbs/libibverbs.map.in b/libibverbs/libibverbs.map.in index e7a1598..f32c918 100644 --- a/libibverbs/libibverbs.map.in +++ b/libibverbs/libibverbs.map.in
@@ -199,6 +199,12 @@ ibv_set_err_comp_cntr; } IBVERBS_1.17; +IBVERBS_1.19 { + global: + ibv_alloc_user_buf; + ibv_free_user_buf; +} IBVERBS_1.18; + /* If any symbols in this stanza change ABI then the entire staza gets a new symbol version. See the top level CMakeLists.txt for this setting. */
diff --git a/libibverbs/man/CMakeLists.txt b/libibverbs/man/CMakeLists.txt index 0efe0b0..502e16a 100644 --- a/libibverbs/man/CMakeLists.txt +++ b/libibverbs/man/CMakeLists.txt
@@ -8,6 +8,7 @@ ibv_alloc_parent_domain.3 ibv_alloc_pd.3 ibv_alloc_td.3 + ibv_alloc_user_buf.3.md ibv_asyncwatch.1 ibv_attach_counters_point_flow.3.md ibv_attach_mcast.3.md @@ -93,6 +94,7 @@ ibv_alloc_buf.3 ibv_free_buf.3 ibv_alloc_buf.3 ibv_reg_buf_mr.3 ibv_alloc_buf.3 ibv_export_buf_dmabuf_fd.3 + ibv_alloc_user_buf.3 ibv_free_user_buf.3 ibv_alloc_dm.3 ibv_free_dm.3 ibv_alloc_dm.3 ibv_reg_dm_mr.3 ibv_alloc_dm.3 ibv_memcpy_to_dm.3
diff --git a/libibverbs/man/ibv_advise_mr.3.md b/libibverbs/man/ibv_advise_mr.3.md index a9c7aa6..a626f32 100644 --- a/libibverbs/man/ibv_advise_mr.3.md +++ b/libibverbs/man/ibv_advise_mr.3.md
@@ -65,7 +65,7 @@ *sg_list* : Pointer to the s/g array - When using IBV_ADVISE_OP_PREFETCH advise value, all the lkeys of all + When using IBV_ADVISE_MR_ADVICE_PREFETCH advise value, all the lkeys of all the scatter gather elements (SGEs) must be associated with ODP MRs (MRs that were registered with IBV_ACCESS_ON_DEMAND).
diff --git a/libibverbs/man/ibv_alloc_buf.3.md b/libibverbs/man/ibv_alloc_buf.3.md index 5409b3c..fb955b9 100644 --- a/libibverbs/man/ibv_alloc_buf.3.md +++ b/libibverbs/man/ibv_alloc_buf.3.md
@@ -109,6 +109,7 @@ # SEE ALSO **ibv_alloc_parent_domain**(3), +**ibv_alloc_user_buf**(3), **ibv_reg_mr**(3), **ibv_reg_mr_ex**(3), **ibv_reg_dmabuf_mr**(3)
diff --git a/libibverbs/man/ibv_alloc_dm.3 b/libibverbs/man/ibv_alloc_dm.3 index 5c66639..d626283 100644 --- a/libibverbs/man/ibv_alloc_dm.3 +++ b/libibverbs/man/ibv_alloc_dm.3
@@ -52,7 +52,7 @@ .BI "int ibv_memcpy_from_dm(void " "*host_addr" ", struct ibv_dm " "*dm" ", .BI " uint64_t " "dm_offset" ", size_t " "length" "); .sp -.I dm_offest +.I dm_offset is the byte offset from the beginning of the allocated device memory buffer to access. .sp .I host_addr @@ -79,7 +79,7 @@ .I dm the associated dm for this registration. .sp -.I dm_offest +.I dm_offset is the byte offset from the beginning of the allocated device memory buffer to register. .sp .I length
diff --git a/libibverbs/man/ibv_alloc_user_buf.3.md b/libibverbs/man/ibv_alloc_user_buf.3.md new file mode 100644 index 0000000..c70da9e --- /dev/null +++ b/libibverbs/man/ibv_alloc_user_buf.3.md
@@ -0,0 +1,98 @@ +--- +date: 2026-08-19 +footer: libibverbs +header: "Libibverbs Programmer's Manual" +layout: page +license: 'Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md' +section: 3 +title: ibv_alloc_user_buf +--- + +# NAME + +ibv_alloc_user_buf, ibv_free_user_buf - associate an ibv_buf with +application-owned memory + +# SYNOPSIS + +```c +#include <infiniband/verbs.h> + +struct ibv_buf *ibv_alloc_user_buf(struct ibv_pd *pd, void *addr, size_t size, + int dmabuf_fd); + +void ibv_free_user_buf(struct ibv_buf *buf); +``` + +# DESCRIPTION + +**ibv_alloc_user_buf()** associates an **ibv_buf** with memory the application +already owns, either a plain virtual address range or a DMA-buf. Unlike +**ibv_alloc_buf()**, no memory is allocated; *addr* must already be a valid +virtual address for that memory, and must remain valid for as long as the +returned handle is in use. + +**ibv_free_user_buf()** releases a handle returned by +**ibv_alloc_user_buf()**. It does not free or otherwise affect the +underlying memory; only the handle itself and any bookkeeping +**ibv_alloc_user_buf()** performed (such as fork protection) are released. + +The returned handle is meant for providers that accept an **ibv_buf** +directly without registering an MR, such as driver-specific control-buffer +descriptors. + +**Use of this API is discouraged.** Applications should allocate buffers with +**ibv_alloc_buf()** whenever possible. See NOTES below. + +# ARGUMENTS + +*pd* +: Protection domain the buffer is associated with. + +*addr* +: Application-owned virtual address of the buffer. + +*size* +: Size of the buffer in bytes. + +*dmabuf_fd* +: A DMA-buf file descriptor backing the buffer, or -1 if the buffer is + plain virtual memory at *addr*. + +*buf* +: Handle returned by **ibv_alloc_user_buf()**, to be released with + **ibv_free_user_buf()**. + +# NOTES + +**ibv_alloc_buf()** is the preferred way to obtain an **ibv_buf**. Its +allocation is selected by the provider for the protection domain, and therefore +accounts for platform requirements such as confidential computing (CoCo), where +memory may have to be allocated as unprotected/shared memory (see +**IBV_PARENT_DOMAIN_INIT_ATTR_ALLOW_CC_UNPROTECTED_ALLOC** in +**ibv_alloc_parent_domain**(3)). + +**ibv_alloc_user_buf()** bypasses this allocator abstraction. Neither +libibverbs nor the provider can verify or adjust memory the application +allocated itself, so the application is solely responsible for ensuring that +the memory is suitable for the device and for the platform it runs on (for +example, that it is usable by the device inside a CoCo guest). The application +generally does not have enough information to guarantee this in a portable +way. + +Use this API only when the memory must come from a source that +**ibv_alloc_buf()** cannot provide, such as an existing DMA-buf allocation +shared with another device or subsystem, or memory whose lifetime is managed by +the application. Otherwise, use **ibv_alloc_buf()**. + +# RETURN VALUE + +**ibv_alloc_user_buf()** returns a buffer handle on success, or NULL if the +request fails. + +**ibv_free_user_buf()** does not return a value. + +# SEE ALSO + +**ibv_alloc_buf**(3), +**ibv_alloc_parent_domain**(3)
diff --git a/libibverbs/man/ibv_create_flow_action.3.md b/libibverbs/man/ibv_create_flow_action.3.md index f0736ca..ecc6ac2 100644 --- a/libibverbs/man/ibv_create_flow_action.3.md +++ b/libibverbs/man/ibv_create_flow_action.3.md
@@ -149,24 +149,24 @@ *spi* : The value for the ESP Security Parameters Index. - It is only used for *IB_UVERBS_FLOW_ACTION_ESP_FLAGS_FULL_OFFLAOD*. + It is only used for *IB_UVERBS_FLOW_ACTION_ESP_FLAGS_FULL_OFFLOAD*. *seq* : The initial 32 lower bytes of the sequence number. This is the value of the ESP sequence number. - It is only used for *IB_UVERBS_FLOW_ACTION_ESP_FLAGS_FULL_OFFLAOD*. + It is only used for *IB_UVERBS_FLOW_ACTION_ESP_FLAGS_FULL_OFFLOAD*. *tfc_pad* : The length of Traffic Flow Confidentiality Padding as specified by RFC4303. If it is set to zero no additional padding is added. - It is only used for *IB_UVERBS_FLOW_ACTION_ESP_FLAGS_FULL_OFFLAOD*. + It is only used for *IB_UVERBS_FLOW_ACTION_ESP_FLAGS_FULL_OFFLOAD*. *hard_limit_pkts* : The hard lifetime of the SA measured in number of packets. As specified by RFC4301. After this limit is reached the action will drop future packets to prevent breaking the crypto. - It is only used for *IB_UVERBS_FLOW_ACTION_ESP_FLAGS_FULL_OFFLAOD*. + It is only used for *IB_UVERBS_FLOW_ACTION_ESP_FLAGS_FULL_OFFLOAD*. ## Inline Crypto Mode @@ -239,16 +239,16 @@ Setting this flag indicates that the bottom of the replay window is between 2^31 - 2^32. -## Key Material for AES GCM (*IBV_ACTION_ESP_KEYMAT_AES_GCM*) +## Key Material for AES GCM (*IBV_FLOW_ACTION_ESP_KEYMAT_AES_GCM*) The AES GCM crypto algorithm as defined by RFC4106. This struct is to be provided in *keymat_ptr* when *keymat_proto* is set to -*IBV_ACTION_ESP_KEYMAT_AES_GCM*. +*IBV_FLOW_ACTION_ESP_KEYMAT_AES_GCM*. ```c -struct ibv_flow_action_esp_aes_keymat_aes_gcm { +struct ib_uverbs_flow_action_esp_keymat_aes_gcm { uint64_t iv; - uint32_t iv_algo; /* Use enum ib_uverbs_flow_action_esp_aes_gcm_keymat_iv_algo */ + uint32_t iv_algo; /* Use enum ib_uverbs_flow_action_esp_keymat_aes_gcm_iv_algo */ uint32_t salt; uint32_t icv_len; @@ -293,15 +293,15 @@ bitmap will shift to represent this as in RFC6479. The replay window cannot shift more than 2^31 sequence numbers forward. -This struct is to be provided in *replay_ptr* when *reply_proto* is set to -*IBV_FLOW_ACTION_ESP_REPLAY_BMP*. In this mode reply_ptr and reply_len should +This struct is to be provided in *replay_ptr* when *replay_proto* is set to +*IBV_FLOW_ACTION_ESP_REPLAY_BMP*. In this mode replay_ptr and replay_len should point to a struct ibv_flow_action_esp_replay_bmp containing: *size* : The size of the bitmap. ## ESP Encapsulation -An *esp_encap* specification is required when *eps_attr* flags +An *esp_encap* specification is required when *esp_attr* flags *IB_UVERBS_FLOW_ACTION_ESP_FLAGS_TUNNEL* is set. It is used to provide the fields for the encapsulation header that is added/removed to/from packets. Tunnel and Transport mode are defined as in RFC4301. @@ -327,12 +327,12 @@ Upon success *ibv_create_flow_action_esp* will return a new *struct ibv_flow_action* object, on error NULL will be returned and errno will be set. -Upon success *ibv_modify_action_esp* will return 0. On error the value of -errno will be returned. If ibv_modify_flow_action fails, it is guaranteed that +Upon success *ibv_modify_flow_action_esp* will return 0. On error the value of +errno will be returned. If ibv_modify_flow_action_esp fails, it is guaranteed that the last action still holds. If it succeeds, there is a point in the future where the old action is applied on all packets until this point and the new one is applied on all packets from this point and on. # SEE ALSO -*ibv_create_flow(3)*, *ibv_destroy_action(3)*, *RFC 4106* +*ibv_create_flow(3)*, *ibv_destroy_flow_action(3)*, *RFC 4106*
diff --git a/libibverbs/man/ibv_query_device_ex.3 b/libibverbs/man/ibv_query_device_ex.3 index c7b6764..3f22237 100644 --- a/libibverbs/man/ibv_query_device_ex.3 +++ b/libibverbs/man/ibv_query_device_ex.3
@@ -48,15 +48,15 @@ }; struct ibv_odp_caps { - uint64_t general_odp_caps; /* Mask with enum ibv_odp_general_cap_bits */ + uint64_t general_caps; /* Mask with enum ibv_odp_general_caps */ struct { - uint32_t rc_odp_caps; /* Mask with enum ibv_odp_tranport_cap_bits to know which operations are supported. */ - uint32_t uc_odp_caps; /* Mask with enum ibv_odp_tranport_cap_bits to know which operations are supported. */ - uint32_t ud_odp_caps; /* Mask with enum ibv_odp_tranport_cap_bits to know which operations are supported. */ + uint32_t rc_odp_caps; /* Mask with enum ibv_odp_transport_cap_bits to know which operations are supported. */ + uint32_t uc_odp_caps; /* Mask with enum ibv_odp_transport_cap_bits to know which operations are supported. */ + uint32_t ud_odp_caps; /* Mask with enum ibv_odp_transport_cap_bits to know which operations are supported. */ } per_transport_caps; }; -enum ibv_odp_general_cap_bits { +enum ibv_odp_general_caps { IBV_ODP_SUPPORT = 1 << 0, /* On demand paging is supported */ IBV_ODP_SUPPORT_IMPLICIT = 1 << 1, /* Implicit on demand paging is supported */ };
diff --git a/libibverbs/man/ibv_read_counters.3.md b/libibverbs/man/ibv_read_counters.3.md index 74407b1..bf89bc7 100644 --- a/libibverbs/man/ibv_read_counters.3.md +++ b/libibverbs/man/ibv_read_counters.3.md
@@ -125,7 +125,7 @@ .flags = 0, }, .spec_eth = { - .type = IBV_EXP_FLOW_SPEC_ETH, + .type = IBV_FLOW_SPEC_ETH, .size = sizeof(struct ibv_flow_spec_eth), .val = FLOW_SPEC_ETH_MAC_VAL, .mask = FLOW_SPEC_ETH_MAC_MASK,
diff --git a/libibverbs/man/ibv_wr_post.3.md b/libibverbs/man/ibv_wr_post.3.md index 9cfac3a..d0bbc35 100644 --- a/libibverbs/man/ibv_wr_post.3.md +++ b/libibverbs/man/ibv_wr_post.3.md
@@ -258,7 +258,7 @@ *ibv_wr_set_inline_data_list()* : Copy send data from a list of buffers, logically concatenated together. Each buffer is specified by an element in an array of *struct - ibv_inl_data*. + ibv_data_buf*. ## Flags @@ -320,7 +320,7 @@ qpx->wr_id = my_wr_id_2; qpx->wr_flags = IBV_SEND_SIGNALED; ibv_wr_rdma_write_imm(qpx, rkey, remote_addr_2, htonl(0x1234)); -ibv_set_wr_sge(qpx, lkey, local_addr_2, length_2); +ibv_wr_set_sge(qpx, lkey, local_addr_2, length_2); /* Begin processing WRs */ ret = ibv_wr_complete(qpx);
diff --git a/libibverbs/verbs.c b/libibverbs/verbs.c index d694ad4..1959fcf 100644 --- a/libibverbs/verbs.c +++ b/libibverbs/verbs.c
@@ -470,6 +470,38 @@ get_ops(buf->pd->context)->free_buf(buf); } +struct ibv_buf *ibv_alloc_user_buf(struct ibv_pd *pd, void *addr, size_t size, + int dmabuf_fd) +{ + struct ibv_buf *buf; + int ret; + + ret = ibv_dontfork_range(addr, size); + if (ret) { + errno = ret; + return NULL; + } + + buf = calloc(1, sizeof(*buf)); + if (!buf) { + errno = ENOMEM; + ibv_dofork_range(addr, size); + return NULL; + } + + if (dmabuf_fd != -1) + ibv_buf_init_dmabuf(buf, pd, addr, size, dmabuf_fd); + else + ibv_buf_init(buf, pd, addr, size); + return buf; +} + +void ibv_free_user_buf(struct ibv_buf *buf) +{ + ibv_dofork_range(buf->addr, buf->size); + free(buf); +} + /* * Translate an ibv_buf handle into the concrete mr_init_attr fields so the * registration can proceed through the regular addr-based or fd-based path.
diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h index cad28af..e48cd80 100644 --- a/libibverbs/verbs.h +++ b/libibverbs/verbs.h
@@ -3356,6 +3356,36 @@ void *addr, size_t length, int access); /** + * ibv_alloc_user_buf - Associate an ibv_buf with application-owned memory + * @pd: Protection domain the buffer is associated with + * @addr: Application-owned virtual address of the buffer + * @size: Buffer size in bytes + * @dmabuf_fd: DMA-buf file descriptor, or -1 for plain virtual memory + * + * Unlike ibv_alloc_buf(), the memory is owned by the caller; it is not + * allocated here and is not freed by ibv_free_user_buf(). It must + * remain valid for as long as the returned handle is in use. + * + * The returned handle is meant for providers that accept a struct + * ibv_buf directly without registering an MR (e.g. driver-specific + * control-buffer descriptors). + * + * Returns a buffer handle on success, or NULL on failure with errno set. + */ +struct ibv_buf *ibv_alloc_user_buf(struct ibv_pd *pd, void *addr, size_t size, + int dmabuf_fd); + +/** + * ibv_free_user_buf - Release a handle created by ibv_alloc_user_buf + * @buf: Handle from ibv_alloc_user_buf() + * + * Does not free the underlying memory; only the ibv_buf handle and + * its bookkeeping (e.g. fork protection for VA-backed buffers) are + * released. + */ +void ibv_free_user_buf(struct ibv_buf *buf); + +/** * ibv_alloc_dmah - Allocate a dma handle */ struct ibv_dmah *ibv_alloc_dmah(struct ibv_context *context,
diff --git a/librdmacm/man/cmtime.1 b/librdmacm/man/cmtime.1 index 6af8fcc..581f8d8 100644 --- a/librdmacm/man/cmtime.1 +++ b/librdmacm/man/cmtime.1
@@ -106,7 +106,7 @@ set to blocking mode. Only supported in 1 client 1 server mode (-P 2). .TP \-t timeout_ms -Timeout in millseconds (ms) when resolving address or +Timeout in milliseconds (ms) when resolving address or route. (default 2000 - 2 seconds) .SH "EXAMPLES" One client connecting to one server:
diff --git a/librdmacm/man/rdma_create_ep.3 b/librdmacm/man/rdma_create_ep.3 index b1f3976..0f0156d 100644 --- a/librdmacm/man/rdma_create_ep.3 +++ b/librdmacm/man/rdma_create_ep.3
@@ -31,7 +31,7 @@ may use this call to allocate an rdma_cm_id based on the results. .P If the rdma_cm_id will be used on the active side of a connection, -meaning that res->ai_flag does not have RAI_PASSIVE set, rdma_create_ep +meaning that res->ai_flags does not have RAI_PASSIVE set, rdma_create_ep will automatically create a QP on the rdma_cm_id if qp_init_attr is not NULL. The QP will be associated with the specified protection domain, if provided, or a default protection domain if not. Users @@ -41,7 +41,7 @@ calls rdma_resolve_addr and rdma_resolve_route are not necessary. .P If the rdma_cm_id will be used on the passive side of a connection, -indicated by having res->ai_flag RAI_PASSIVE set, this call will save +indicated by having res->ai_flags RAI_PASSIVE set, this call will save the provided pd and qp_init_attr parameters. When a new connection request is retrieved by calling rdma_get_request, the rdma_cm_id associated with the new connection will automatically be associated
diff --git a/librdmacm/man/rdma_getaddrinfo.3 b/librdmacm/man/rdma_getaddrinfo.3 index 85fab26..de4debc 100644 --- a/librdmacm/man/rdma_getaddrinfo.3 +++ b/librdmacm/man/rdma_getaddrinfo.3
@@ -26,37 +26,9 @@ information needed to establish communication. Provides the RDMA functional equivalent to getaddrinfo. .SH "RETURN VALUE" -Returns 0 on success, or -1 on error (errno will be set to indicate the failure -reason), or one of the following nonzero error codes: -.IP "EAI_ADDRFAMILY" 12 -The specified network host does not have any network addresses in the -requested address family. -.IP "EAI_AGAIN" 12 -The name server returned a temporary failure indication. Try again later. -.IP "EAI_BADFLAGS" 12 -hints.ai_flags contains invalid flags. -.IP "EAI_FAIL" 12 -The name server returned a permanent failure indication. -.IP "EAI_FAMILY" 12 -The requested address family is not supported. -.IP "EAI_MEMORY" 12 -Out of memory. -.IP "EAI_NODATA" 12 -The specified network host exists, but does not have any network addresses -defined. -.IP "EAI_NONAME" 12 -The node or service is not known; or both node and service are NULL. -.IP "EAI_SERVICE" 12 -The requested service is not available for the requested QP type. It may be -available through another QP type. -.IP "EAI_QPTYPE" 12 -The requested socket type is not supported. This could occur, for example, -if hints.ai_qptype and hints.ai_port_space are inconsistent (e.g., IBV_QPT_UD -and RDMA_PS_TCP, respectively). -.IP "EAI_SYSTEM" 12 -Other system error, check errno for details. -The gai_strerror() function translates these error codes to a human readable -string, suitable for error reporting. +Returns 0 on success. On failure it returns either -1 with errno set to +indicate the internal error, or one of the nonzero EAI_* error codes +returned by getaddrinfo(3) if the node or service could not be resolved. .SH "NOTES" Either node, service, or hints must be provided. If hints are provided, the operation will be controlled by hints.ai_flags. If RAI_PASSIVE is
diff --git a/librdmacm/man/rdma_post_sendv.3 b/librdmacm/man/rdma_post_sendv.3 index 9b347b1..e1c888e 100644 --- a/librdmacm/man/rdma_post_sendv.3 +++ b/librdmacm/man/rdma_post_sendv.3
@@ -8,7 +8,7 @@ .B "int" rdma_post_sendv .BI "(struct rdma_cm_id *" id "," .BI "void *" context "," -.BI "struct ibv_sge *" slg "," +.BI "struct ibv_sge *" sgl "," .BI "int " nsge "," .BI "int " flags ");" .SH ARGUMENTS @@ -17,10 +17,10 @@ will be posted. .IP "context" 12 User-defined context associated with the request. -.IP "slg" 12 +.IP "sgl" 12 A scatter-gather list of memory buffers posted as a single request. .IP "nsge" 12 -The number of scatter-gather entries in the slg array. +The number of scatter-gather entries in the sgl array. .IP "flags" 12 Optional flags used to control the send operation. .SH "DESCRIPTION"
diff --git a/librdmacm/man/rsocket.7.in b/librdmacm/man/rsocket.7.in index 22c70b6..fc8f821 100644 --- a/librdmacm/man/rsocket.7.in +++ b/librdmacm/man/rsocket.7.in
@@ -153,8 +153,6 @@ This value is used to safe guard against potential application hangs in rpoll(). .P -max_events - maximum number of events for the epoll thread to handle for an epoll_instance. -.P All configuration files should contain a single integer value. Values may be set by issuing a command similar to the following example. .P
diff --git a/providers/bnxt_re/CMakeLists.txt b/providers/bnxt_re/CMakeLists.txt index 13ad287..a643122 100644 --- a/providers/bnxt_re/CMakeLists.txt +++ b/providers/bnxt_re/CMakeLists.txt
@@ -1,6 +1,20 @@ -rdma_provider(bnxt_re +rdma_shared_provider(bnxt_re bnxt_re.map + 1 1.1.${PACKAGE_VERSION} db.c main.c memory.c verbs.c + dv.c ) + +publish_headers(infiniband + bnxt_re-hsi.h + bnxt_re_dv.h +) + +rdma_pkg_config("bnxt_re" "libibverbs" "${CMAKE_THREAD_LIBS_INIT}") + +if (ENABLE_LTTNG AND LTTNGUST_FOUND) + target_include_directories(bnxt_re PUBLIC ".") + target_link_libraries(bnxt_re LINK_PRIVATE LTTng::UST) +endif()
diff --git a/providers/bnxt_re/bnxt_re-abi.h b/providers/bnxt_re/bnxt_re-abi.h index bccbaa3..45f44fd 100644 --- a/providers/bnxt_re/bnxt_re-abi.h +++ b/providers/bnxt_re/bnxt_re-abi.h
@@ -47,11 +47,11 @@ DECLARE_DRV_CMD(ubnxt_re_pd, IB_USER_VERBS_CMD_ALLOC_PD, empty, bnxt_re_pd_resp); -DECLARE_DRV_CMD(ubnxt_re_cq, IB_USER_VERBS_CMD_CREATE_CQ, +DECLARE_DRV_CMD(ubnxt_re_cq, IB_USER_VERBS_EX_CMD_CREATE_CQ, bnxt_re_cq_req, bnxt_re_cq_resp); DECLARE_DRV_CMD(ubnxt_re_resize_cq, IB_USER_VERBS_CMD_RESIZE_CQ, bnxt_re_resize_cq_req, empty); -DECLARE_DRV_CMD(ubnxt_re_qp, IB_USER_VERBS_CMD_CREATE_QP, +DECLARE_DRV_CMD(ubnxt_re_qp, IB_USER_VERBS_EX_CMD_CREATE_QP, bnxt_re_qp_req, bnxt_re_qp_resp); DECLARE_DRV_CMD(ubnxt_re_cntx, IB_USER_VERBS_CMD_GET_CONTEXT, bnxt_re_uctx_req, bnxt_re_uctx_resp); @@ -62,167 +62,6 @@ DECLARE_DRV_CMD(ubnxt_re_query_device_ex, IB_USER_VERBS_EX_CMD_QUERY_DEVICE, empty, bnxt_re_query_device_ex_resp); -enum bnxt_re_wr_opcode { - BNXT_RE_WR_OPCD_SEND = 0x00, - BNXT_RE_WR_OPCD_SEND_IMM = 0x01, - BNXT_RE_WR_OPCD_SEND_INVAL = 0x02, - BNXT_RE_WR_OPCD_RDMA_WRITE = 0x04, - BNXT_RE_WR_OPCD_RDMA_WRITE_IMM = 0x05, - BNXT_RE_WR_OPCD_RDMA_READ = 0x06, - BNXT_RE_WR_OPCD_ATOMIC_CS = 0x08, - BNXT_RE_WR_OPCD_ATOMIC_FA = 0x0B, - BNXT_RE_WR_OPCD_LOC_INVAL = 0x0C, - BNXT_RE_WR_OPCD_BIND = 0x0E, - BNXT_RE_WR_OPCD_RECV = 0x80, - BNXT_RE_WR_OPCD_INVAL = 0xFF -}; - -enum bnxt_re_wr_flags { - BNXT_RE_WR_FLAGS_INLINE = 0x10, - BNXT_RE_WR_FLAGS_SE = 0x08, - BNXT_RE_WR_FLAGS_UC_FENCE = 0x04, - BNXT_RE_WR_FLAGS_RD_FENCE = 0x02, - BNXT_RE_WR_FLAGS_SIGNALED = 0x01 -}; - -enum bnxt_re_wc_type { - BNXT_RE_WC_TYPE_SEND = 0x00, - BNXT_RE_WC_TYPE_RECV_RC = 0x01, - BNXT_RE_WC_TYPE_RECV_UD = 0x02, - BNXT_RE_WC_TYPE_RECV_RAW = 0x03, - BNXT_RE_WC_TYPE_TERM = 0x0E, - BNXT_RE_WC_TYPE_COFF = 0x0F -}; - -#define BNXT_RE_WC_OPCD_RECV 0x80 -enum bnxt_re_req_wc_status { - BNXT_RE_REQ_ST_OK = 0x00, - BNXT_RE_REQ_ST_BAD_RESP = 0x01, - BNXT_RE_REQ_ST_LOC_LEN = 0x02, - BNXT_RE_REQ_ST_LOC_QP_OP = 0x03, - BNXT_RE_REQ_ST_PROT = 0x04, - BNXT_RE_REQ_ST_MEM_OP = 0x05, - BNXT_RE_REQ_ST_REM_INVAL = 0x06, - BNXT_RE_REQ_ST_REM_ACC = 0x07, - BNXT_RE_REQ_ST_REM_OP = 0x08, - BNXT_RE_REQ_ST_RNR_NAK_XCED = 0x09, - BNXT_RE_REQ_ST_TRNSP_XCED = 0x0A, - BNXT_RE_REQ_ST_WR_FLUSH = 0x0B -}; - -enum bnxt_re_rsp_wc_status { - BNXT_RE_RSP_ST_OK = 0x00, - BNXT_RE_RSP_ST_LOC_ACC = 0x01, - BNXT_RE_RSP_ST_LOC_LEN = 0x02, - BNXT_RE_RSP_ST_LOC_PROT = 0x03, - BNXT_RE_RSP_ST_LOC_QP_OP = 0x04, - BNXT_RE_RSP_ST_MEM_OP = 0x05, - BNXT_RE_RSP_ST_REM_INVAL = 0x06, - BNXT_RE_RSP_ST_WR_FLUSH = 0x07, - BNXT_RE_RSP_ST_HW_FLUSH = 0x08 -}; - -enum bnxt_re_hdr_offset { - BNXT_RE_HDR_WT_MASK = 0xFF, - BNXT_RE_HDR_FLAGS_MASK = 0xFF, - BNXT_RE_HDR_FLAGS_SHIFT = 0x08, - BNXT_RE_HDR_WS_MASK = 0xFF, - BNXT_RE_HDR_WS_SHIFT = 0x10 -}; - -enum bnxt_re_db_que_type { - BNXT_RE_QUE_TYPE_SQ = 0x00, - BNXT_RE_QUE_TYPE_RQ = 0x01, - BNXT_RE_QUE_TYPE_SRQ = 0x02, - BNXT_RE_QUE_TYPE_SRQ_ARM = 0x03, - BNXT_RE_QUE_TYPE_CQ = 0x04, - BNXT_RE_QUE_TYPE_CQ_ARMSE = 0x05, - BNXT_RE_QUE_TYPE_CQ_ARMALL = 0x06, - BNXT_RE_QUE_TYPE_CQ_ARMENA = 0x07, - BNXT_RE_QUE_TYPE_SRQ_ARMENA = 0x08, - BNXT_RE_QUE_TYPE_CQ_CUT_ACK = 0x09, - BNXT_RE_PUSH_TYPE_START = 0x0C, - BNXT_RE_PUSH_TYPE_END = 0x0D, - BNXT_RE_QUE_TYPE_NULL = 0x0F -}; - -enum bnxt_re_db_mask { - BNXT_RE_DB_INDX_MASK = 0xFFFFFFUL, - BNXT_RE_DB_PILO_MASK = 0x0FFUL, - BNXT_RE_DB_PILO_SHIFT = 0x18, - BNXT_RE_DB_QID_MASK = 0xFFFFFUL, - BNXT_RE_DB_PIHI_MASK = 0xF00UL, - BNXT_RE_DB_PIHI_SHIFT = 0x0C, /* Because mask is 0xF00 */ - BNXT_RE_DB_TYP_MASK = 0x0FUL, - BNXT_RE_DB_TYP_SHIFT = 0x1C, - BNXT_RE_DB_VALID_SHIFT = 0x1A, - BNXT_RE_DB_EPOCH_SHIFT = 0x18, - BNXT_RE_DB_TOGGLE_SHIFT = 0x19, -}; - -enum bnxt_re_psns_mask { - BNXT_RE_PSNS_SPSN_MASK = 0xFFFFFF, - BNXT_RE_PSNS_OPCD_MASK = 0xFF, - BNXT_RE_PSNS_OPCD_SHIFT = 0x18, - BNXT_RE_PSNS_NPSN_MASK = 0xFFFFFF, - BNXT_RE_PSNS_FLAGS_MASK = 0xFF, - BNXT_RE_PSNS_FLAGS_SHIFT = 0x18 -}; - -enum bnxt_re_msns_mask { - BNXT_RE_SQ_MSN_SEARCH_START_PSN_MASK = 0xFFFFFFUL, - BNXT_RE_SQ_MSN_SEARCH_START_PSN_SHIFT = 0, - BNXT_RE_SQ_MSN_SEARCH_NEXT_PSN_MASK = 0xFFFFFF000000ULL, - BNXT_RE_SQ_MSN_SEARCH_NEXT_PSN_SHIFT = 0x18, - BNXT_RE_SQ_MSN_SEARCH_START_IDX_MASK = 0xFFFF000000000000ULL, - BNXT_RE_SQ_MSN_SEARCH_START_IDX_SHIFT = 0x30 -}; - -enum bnxt_re_bcqe_mask { - BNXT_RE_BCQE_PH_MASK = 0x01, - BNXT_RE_BCQE_TYPE_MASK = 0x0F, - BNXT_RE_BCQE_TYPE_SHIFT = 0x01, - BNXT_RE_BCQE_RESIZE_TOG_MASK = 0x03, - BNXT_RE_BCQE_RESIZE_TOG_SHIFT = 0x05, - BNXT_RE_BCQE_STATUS_MASK = 0xFF, - BNXT_RE_BCQE_STATUS_SHIFT = 0x08, - BNXT_RE_BCQE_FLAGS_MASK = 0xFFFFU, - BNXT_RE_BCQE_FLAGS_SHIFT = 0x10, - BNXT_RE_BCQE_RWRID_MASK = 0xFFFFFU, - BNXT_RE_BCQE_SRCQP_MASK = 0xFF, - BNXT_RE_BCQE_SRCQP_SHIFT = 0x18 -}; - -enum bnxt_re_rc_flags_mask { - BNXT_RE_RC_FLAGS_SRQ_RQ_MASK = 0x01, - BNXT_RE_RC_FLAGS_IMM_MASK = 0x02, - BNXT_RE_RC_FLAGS_IMM_SHIFT = 0x01, - BNXT_RE_RC_FLAGS_INV_MASK = 0x04, - BNXT_RE_RC_FLAGS_INV_SHIFT = 0x02, - BNXT_RE_RC_FLAGS_RDMA_MASK = 0x08, - BNXT_RE_RC_FLAGS_RDMA_SHIFT = 0x03 -}; - -enum bnxt_re_ud_flags_mask { - BNXT_RE_UD_FLAGS_SRQ_RQ_SFT = 0x00, - BNXT_RE_UD_FLAGS_SRQ_RQ_MASK = 0x01, - BNXT_RE_UD_FLAGS_IMM_MASK = 0x02, - BNXT_RE_UD_FLAGS_IMM_SFT = 0x01, - BNXT_RE_UD_FLAGS_IP_VER_MASK = 0x30, - BNXT_RE_UD_FLAGS_IP_VER_SFT = 0x4, - BNXT_RE_UD_FLAGS_META_MASK = 0x3C0, - BNXT_RE_UD_FLAGS_META_SFT = 0x6, - BNXT_RE_UD_FLAGS_EXT_META_MASK = 0xC00, - BNXT_RE_UD_FLAGS_EXT_META_SFT = 0x10, -}; - -enum bnxt_re_ud_cqe_mask { - BNXT_RE_UD_CQE_MAC_MASK = 0xFFFFFFFFFFFFULL, - BNXT_RE_UD_CQE_SRCQPLO_MASK = 0xFFFF, - BNXT_RE_UD_CQE_SRCQPLO_SHIFT = 0x30, - BNXT_RE_UD_CQE_LEN_MASK = 0x3FFFU, -}; - enum { BNXT_RE_COMP_MASK_UCNTX_WC_DPI_ENABLED = 0x01, BNXT_RE_COMP_MASK_UCNTX_DBR_PACING_ENABLED = 0x02, @@ -232,153 +71,4 @@ BNXT_RE_COMP_MASK_UCNTX_TOGGLE_MEM_UOBJ_SUPPORT = 0x20, }; -enum bnxt_re_que_flags_mask { - BNXT_RE_FLAG_EPOCH_TAIL_SHIFT = 0x0UL, - BNXT_RE_FLAG_EPOCH_HEAD_SHIFT = 0x1UL, - BNXT_RE_FLAG_EPOCH_TAIL_MASK = 0x1UL, - BNXT_RE_FLAG_EPOCH_HEAD_MASK = 0x2UL, -}; - -enum bnxt_re_db_epoch_flag_shift { - BNXT_RE_DB_EPOCH_TAIL_SHIFT = BNXT_RE_DB_EPOCH_SHIFT, - BNXT_RE_DB_EPOCH_HEAD_SHIFT = (BNXT_RE_DB_EPOCH_SHIFT - 1) -}; - -#define BNXT_RE_STATIC_WQE_MAX_SGE 0x06 - -enum bnxt_re_modes { - BNXT_RE_WQE_MODE_STATIC = 0x00, - BNXT_RE_WQE_MODE_VARIABLE = 0x01 -}; - -struct bnxt_re_db_hdr { - __le32 indx; - __le32 typ_qid; /* typ: 4, qid:20*/ -}; - -struct bnxt_re_bcqe { - __le32 flg_st_typ_ph; - __le32 qphi_rwrid; -}; - -struct bnxt_re_req_cqe { - __le64 qp_handle; - __le32 con_indx; /* 16 bits valid. */ - __le32 rsvd1; - __le64 rsvd2; -}; - -struct bnxt_re_rc_cqe { - __le32 length; - __le32 imm_key; - __le64 qp_handle; - __le64 mr_handle; -}; - -struct bnxt_re_ud_cqe { - __le32 length; /* 14 bits */ - __le32 immd; - __le64 qp_handle; - __le64 qplo_mac; /* 16:48*/ -}; - -struct bnxt_re_term_cqe { - __le64 qp_handle; - __le32 rq_sq_cidx; - __le32 rsvd; - __le64 rsvd1; -}; - -union lower_shdr { - __le64 qkey_len; - __le64 lkey_plkey; - __le64 rva; -}; - -struct bnxt_re_bsqe { - __le32 rsv_ws_fl_wt; - union { - __be32 imm_data; - __le32 key_immd; - }; - union lower_shdr lhdr; -}; - -struct bnxt_re_psns { - __le32 opc_spsn; - __le32 flg_npsn; -}; - -struct bnxt_re_psns_ext { - __u32 opc_spsn; - __u32 flg_npsn; - __u16 st_slot_idx; - __u16 rsvd0; - __u32 rsvd1; -}; - -/* sq_msn_search (size:64b/8B) */ -struct bnxt_re_msns { - __le64 start_idx_next_psn_start_psn; -}; - -struct bnxt_re_sge { - __le64 pa; - __le32 lkey; - __le32 length; -}; - -/* Cu+ max inline data */ -#define BNXT_RE_MAX_INLINE_SIZE 0x60 - -struct bnxt_re_send { - __le32 dst_qp; - __le32 avid; - __le64 rsvd; -}; - -struct bnxt_re_raw { - __le32 cfa_meta; - __le32 rsvd2; - __le64 rsvd3; -}; - -struct bnxt_re_rdma { - __le64 rva; - __le32 rkey; - __le32 rsvd2; -}; - -struct bnxt_re_atomic { - __le64 swp_dt; - __le64 cmp_dt; -}; - -struct bnxt_re_inval { - __le64 rsvd[2]; -}; - -struct bnxt_re_bind { - __le64 va; - __le64 len; /* only 40 bits are valid */ -}; - -struct bnxt_re_brqe { - __le32 rsv_ws_fl_wt; - __le32 rsvd; - __le32 wrid; - __le32 rsvd1; -}; - -struct bnxt_re_rqe { - __le64 rsvd[2]; -}; - -struct bnxt_re_srqe { - __le64 rsvd[2]; -}; - -struct bnxt_re_push_wqe { - __u64 addr[32]; -}; #endif
diff --git a/providers/bnxt_re/bnxt_re-hsi.h b/providers/bnxt_re/bnxt_re-hsi.h new file mode 100644 index 0000000..d5c9774 --- /dev/null +++ b/providers/bnxt_re/bnxt_re-hsi.h
@@ -0,0 +1,333 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* + * Broadcom NetXtreme-E User Space RoCE driver + * + * Copyright (c) 2015-2026, Broadcom. All rights reserved. The term + * Broadcom refers to Broadcom Limited and/or its subsidiaries. + */ + +#ifndef __BNXT_RE_HSI_H__ +#define __BNXT_RE_HSI_H__ + +#include <linux/types.h> + +#ifdef __cplusplus +extern "C" { +#endif + +enum bnxt_re_wr_opcode { + BNXT_RE_WR_OPCD_SEND = 0x00, + BNXT_RE_WR_OPCD_SEND_IMM = 0x01, + BNXT_RE_WR_OPCD_SEND_INVAL = 0x02, + BNXT_RE_WR_OPCD_RDMA_WRITE = 0x04, + BNXT_RE_WR_OPCD_RDMA_WRITE_IMM = 0x05, + BNXT_RE_WR_OPCD_RDMA_READ = 0x06, + BNXT_RE_WR_OPCD_ATOMIC_CS = 0x08, + BNXT_RE_WR_OPCD_ATOMIC_FA = 0x0B, + BNXT_RE_WR_OPCD_LOC_INVAL = 0x0C, + BNXT_RE_WR_OPCD_BIND = 0x0E, + BNXT_RE_WR_OPCD_RECV = 0x80, + BNXT_RE_WR_OPCD_INVAL = 0xFF +}; + +enum bnxt_re_wr_flags { + BNXT_RE_WR_FLAGS_INLINE = 0x10, + BNXT_RE_WR_FLAGS_SE = 0x08, + BNXT_RE_WR_FLAGS_UC_FENCE = 0x04, + BNXT_RE_WR_FLAGS_RD_FENCE = 0x02, + BNXT_RE_WR_FLAGS_SIGNALED = 0x01 +}; + +enum bnxt_re_wc_type { + BNXT_RE_WC_TYPE_SEND = 0x00, + BNXT_RE_WC_TYPE_RECV_RC = 0x01, + BNXT_RE_WC_TYPE_RECV_UD = 0x02, + BNXT_RE_WC_TYPE_RECV_RAW = 0x03, + BNXT_RE_WC_TYPE_TERM = 0x0E, + BNXT_RE_WC_TYPE_COFF = 0x0F +}; + +#define BNXT_RE_WC_OPCD_RECV 0x80 +enum bnxt_re_req_wc_status { + BNXT_RE_REQ_ST_OK = 0x00, + BNXT_RE_REQ_ST_BAD_RESP = 0x01, + BNXT_RE_REQ_ST_LOC_LEN = 0x02, + BNXT_RE_REQ_ST_LOC_QP_OP = 0x03, + BNXT_RE_REQ_ST_PROT = 0x04, + BNXT_RE_REQ_ST_MEM_OP = 0x05, + BNXT_RE_REQ_ST_REM_INVAL = 0x06, + BNXT_RE_REQ_ST_REM_ACC = 0x07, + BNXT_RE_REQ_ST_REM_OP = 0x08, + BNXT_RE_REQ_ST_RNR_NAK_XCED = 0x09, + BNXT_RE_REQ_ST_TRNSP_XCED = 0x0A, + BNXT_RE_REQ_ST_WR_FLUSH = 0x0B +}; + +enum bnxt_re_rsp_wc_status { + BNXT_RE_RSP_ST_OK = 0x00, + BNXT_RE_RSP_ST_LOC_ACC = 0x01, + BNXT_RE_RSP_ST_LOC_LEN = 0x02, + BNXT_RE_RSP_ST_LOC_PROT = 0x03, + BNXT_RE_RSP_ST_LOC_QP_OP = 0x04, + BNXT_RE_RSP_ST_MEM_OP = 0x05, + BNXT_RE_RSP_ST_REM_INVAL = 0x06, + BNXT_RE_RSP_ST_WR_FLUSH = 0x07, + BNXT_RE_RSP_ST_HW_FLUSH = 0x08 +}; + +enum bnxt_re_hdr_offset { + BNXT_RE_HDR_WT_MASK = 0xFF, + BNXT_RE_HDR_FLAGS_MASK = 0xFF, + BNXT_RE_HDR_FLAGS_SHIFT = 0x08, + BNXT_RE_HDR_WS_MASK = 0xFF, + BNXT_RE_HDR_WS_SHIFT = 0x10 +}; + +enum bnxt_re_db_que_type { + BNXT_RE_QUE_TYPE_SQ = 0x00, + BNXT_RE_QUE_TYPE_RQ = 0x01, + BNXT_RE_QUE_TYPE_SRQ = 0x02, + BNXT_RE_QUE_TYPE_SRQ_ARM = 0x03, + BNXT_RE_QUE_TYPE_CQ = 0x04, + BNXT_RE_QUE_TYPE_CQ_ARMSE = 0x05, + BNXT_RE_QUE_TYPE_CQ_ARMALL = 0x06, + BNXT_RE_QUE_TYPE_CQ_ARMENA = 0x07, + BNXT_RE_QUE_TYPE_SRQ_ARMENA = 0x08, + BNXT_RE_QUE_TYPE_CQ_CUT_ACK = 0x09, + BNXT_RE_PUSH_TYPE_START = 0x0C, + BNXT_RE_PUSH_TYPE_END = 0x0D, + BNXT_RE_QUE_TYPE_NULL = 0x0F +}; + +enum bnxt_re_db_mask { + BNXT_RE_DB_INDX_MASK = 0xFFFFFFUL, + BNXT_RE_DB_PILO_MASK = 0x0FFUL, + BNXT_RE_DB_PILO_SHIFT = 0x18, + BNXT_RE_DB_QID_MASK = 0xFFFFFUL, + BNXT_RE_DB_PIHI_MASK = 0xF00UL, + BNXT_RE_DB_PIHI_SHIFT = 0x0C, /* Because mask is 0xF00 */ + BNXT_RE_DB_TYP_MASK = 0x0FUL, + BNXT_RE_DB_TYP_SHIFT = 0x1C, + BNXT_RE_DB_VALID_SHIFT = 0x1A, + BNXT_RE_DB_EPOCH_SHIFT = 0x18, + BNXT_RE_DB_TOGGLE_SHIFT = 0x19, +}; + +enum bnxt_re_psns_mask { + BNXT_RE_PSNS_SPSN_MASK = 0xFFFFFF, + BNXT_RE_PSNS_OPCD_MASK = 0xFF, + BNXT_RE_PSNS_OPCD_SHIFT = 0x18, + BNXT_RE_PSNS_NPSN_MASK = 0xFFFFFF, + BNXT_RE_PSNS_FLAGS_MASK = 0xFF, + BNXT_RE_PSNS_FLAGS_SHIFT = 0x18 +}; + +enum bnxt_re_msns_mask { + BNXT_RE_SQ_MSN_SEARCH_START_PSN_MASK = 0xFFFFFFUL, + BNXT_RE_SQ_MSN_SEARCH_START_PSN_SHIFT = 0, + BNXT_RE_SQ_MSN_SEARCH_NEXT_PSN_MASK = 0xFFFFFF000000ULL, + BNXT_RE_SQ_MSN_SEARCH_NEXT_PSN_SHIFT = 0x18, + BNXT_RE_SQ_MSN_SEARCH_START_IDX_MASK = 0xFFFF000000000000ULL, + BNXT_RE_SQ_MSN_SEARCH_START_IDX_SHIFT = 0x30 +}; + +enum bnxt_re_bcqe_mask { + BNXT_RE_BCQE_PH_MASK = 0x01, + BNXT_RE_BCQE_TYPE_MASK = 0x0F, + BNXT_RE_BCQE_TYPE_SHIFT = 0x01, + BNXT_RE_BCQE_RESIZE_TOG_MASK = 0x03, + BNXT_RE_BCQE_RESIZE_TOG_SHIFT = 0x05, + BNXT_RE_BCQE_STATUS_MASK = 0xFF, + BNXT_RE_BCQE_STATUS_SHIFT = 0x08, + BNXT_RE_BCQE_FLAGS_MASK = 0xFFFFU, + BNXT_RE_BCQE_FLAGS_SHIFT = 0x10, + BNXT_RE_BCQE_RWRID_MASK = 0xFFFFFU, + BNXT_RE_BCQE_SRCQP_MASK = 0xFF, + BNXT_RE_BCQE_SRCQP_SHIFT = 0x18 +}; + +enum bnxt_re_rc_flags_mask { + BNXT_RE_RC_FLAGS_SRQ_RQ_MASK = 0x01, + BNXT_RE_RC_FLAGS_IMM_MASK = 0x02, + BNXT_RE_RC_FLAGS_IMM_SHIFT = 0x01, + BNXT_RE_RC_FLAGS_INV_MASK = 0x04, + BNXT_RE_RC_FLAGS_INV_SHIFT = 0x02, + BNXT_RE_RC_FLAGS_RDMA_MASK = 0x08, + BNXT_RE_RC_FLAGS_RDMA_SHIFT = 0x03 +}; + +enum bnxt_re_ud_flags_mask { + BNXT_RE_UD_FLAGS_SRQ_RQ_SFT = 0x00, + BNXT_RE_UD_FLAGS_SRQ_RQ_MASK = 0x01, + BNXT_RE_UD_FLAGS_IMM_MASK = 0x02, + BNXT_RE_UD_FLAGS_IMM_SFT = 0x01, + BNXT_RE_UD_FLAGS_IP_VER_MASK = 0x30, + BNXT_RE_UD_FLAGS_IP_VER_SFT = 0x4, + BNXT_RE_UD_FLAGS_META_MASK = 0x3C0, + BNXT_RE_UD_FLAGS_META_SFT = 0x6, + BNXT_RE_UD_FLAGS_EXT_META_MASK = 0xC00, + BNXT_RE_UD_FLAGS_EXT_META_SFT = 0x10, +}; + +enum bnxt_re_ud_cqe_mask { + BNXT_RE_UD_CQE_MAC_MASK = 0xFFFFFFFFFFFFULL, + BNXT_RE_UD_CQE_SRCQPLO_MASK = 0xFFFF, + BNXT_RE_UD_CQE_SRCQPLO_SHIFT = 0x30, + BNXT_RE_UD_CQE_LEN_MASK = 0x3FFFU, +}; + +enum bnxt_re_que_flags_mask { + BNXT_RE_FLAG_EPOCH_TAIL_SHIFT = 0x0UL, + BNXT_RE_FLAG_EPOCH_HEAD_SHIFT = 0x1UL, + BNXT_RE_FLAG_EPOCH_TAIL_MASK = 0x1UL, + BNXT_RE_FLAG_EPOCH_HEAD_MASK = 0x2UL, +}; + +enum bnxt_re_db_epoch_flag_shift { + BNXT_RE_DB_EPOCH_TAIL_SHIFT = BNXT_RE_DB_EPOCH_SHIFT, + BNXT_RE_DB_EPOCH_HEAD_SHIFT = (BNXT_RE_DB_EPOCH_SHIFT - 1) +}; + +#define BNXT_RE_STATIC_WQE_MAX_SGE 0x06 + +enum bnxt_re_modes { + BNXT_RE_WQE_MODE_STATIC = 0x00, + BNXT_RE_WQE_MODE_VARIABLE = 0x01 +}; + +struct bnxt_re_db_hdr { + __le32 indx; + __le32 typ_qid; /* typ: 4, qid:20*/ +}; + +struct bnxt_re_bcqe { + __le32 flg_st_typ_ph; + __le32 qphi_rwrid; +}; + +struct bnxt_re_req_cqe { + __le64 qp_handle; + __le32 con_indx; /* 16 bits valid. */ + __le32 rsvd1; + __le64 rsvd2; +}; + +struct bnxt_re_rc_cqe { + __le32 length; + __le32 imm_key; + __le64 qp_handle; + __le64 mr_handle; +}; + +struct bnxt_re_ud_cqe { + __le32 length; /* 14 bits */ + __le32 immd; + __le64 qp_handle; + __le64 qplo_mac; /* 16:48*/ +}; + +struct bnxt_re_term_cqe { + __le64 qp_handle; + __le32 rq_sq_cidx; + __le32 rsvd; + __le64 rsvd1; +}; + +union lower_shdr { + __le64 qkey_len; + __le64 lkey_plkey; + __le64 rva; +}; + +struct bnxt_re_bsqe { + __le32 rsv_ws_fl_wt; + union { + __be32 imm_data; + __le32 key_immd; + }; + union lower_shdr lhdr; +}; + +struct bnxt_re_psns { + __le32 opc_spsn; + __le32 flg_npsn; +}; + +struct bnxt_re_psns_ext { + __u32 opc_spsn; + __u32 flg_npsn; + __u16 st_slot_idx; + __u16 rsvd0; + __u32 rsvd1; +}; + +/* sq_msn_search (size:64b/8B) */ +struct bnxt_re_msns { + __le64 start_idx_next_psn_start_psn; +}; + +struct bnxt_re_sge { + __le64 pa; + __le32 lkey; + __le32 length; +}; + +/* Cu+ max inline data */ +#define BNXT_RE_MAX_INLINE_SIZE 0x60 + +struct bnxt_re_send { + __le32 dst_qp; + __le32 avid; + __le64 rsvd; +}; + +struct bnxt_re_raw { + __le32 cfa_meta; + __le32 rsvd2; + __le64 rsvd3; +}; + +struct bnxt_re_rdma { + __le64 rva; + __le32 rkey; + __le32 rsvd2; +}; + +struct bnxt_re_atomic { + __le64 swp_dt; + __le64 cmp_dt; +}; + +struct bnxt_re_inval { + __le64 rsvd[2]; +}; + +struct bnxt_re_bind { + __le64 va; + __le64 len; /* only 40 bits are valid */ +}; + +struct bnxt_re_brqe { + __le32 rsv_ws_fl_wt; + __le32 rsvd; + __le32 wrid; + __le32 rsvd1; +}; + +struct bnxt_re_rqe { + __le64 rsvd[2]; +}; + +struct bnxt_re_srqe { + __le64 rsvd[2]; +}; + +struct bnxt_re_push_wqe { + __u64 addr[32]; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* __BNXT_RE_HSI_H__ */
diff --git a/providers/bnxt_re/bnxt_re.map b/providers/bnxt_re/bnxt_re.map new file mode 100644 index 0000000..871031f --- /dev/null +++ b/providers/bnxt_re/bnxt_re.map
@@ -0,0 +1,11 @@ +/* Export symbols should be added below according to + Documentation/versioning.md document. */ +BNXT_RE_1.1 { + global: + bnxt_re_dv_alloc_db_region; + bnxt_re_dv_free_db_region; + bnxt_re_dv_get_default_db_region; + bnxt_re_dv_create_cq; + bnxt_re_dv_create_qp; + local: *; +};
diff --git a/providers/bnxt_re/bnxt_re_dv.h b/providers/bnxt_re/bnxt_re_dv.h new file mode 100644 index 0000000..220f237 --- /dev/null +++ b/providers/bnxt_re/bnxt_re_dv.h
@@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* + * Broadcom NetXtreme-E User Space RoCE driver + * + * Copyright (c) 2015-2026, Broadcom. All rights reserved. The term + * Broadcom refers to Broadcom Limited and/or its subsidiaries. + */ + +#ifndef __BNXT_RE_DV_H__ +#define __BNXT_RE_DV_H__ + +#include <stdint.h> +#include <infiniband/verbs.h> +#ifdef __cplusplus +extern "C" { +#endif + +struct bnxt_re_dv_db_region_attr { + uint32_t handle; + uint32_t dpi; + uint64_t *dbr; +}; + +struct bnxt_re_dv_cq_init_attr { + struct ibv_buf *umem_handle; /* handle from ibv_alloc_user_buf() */ + uint64_t umem_offset; /* offset into umem_handle */ + uint32_t ncqe; /* num cq entries */ +}; + +struct bnxt_re_dv_qp_init_attr { + /* Standard ibv params */ + enum ibv_qp_type qp_type; + uint32_t max_send_wr; + uint32_t max_recv_wr; + uint32_t max_send_sge; + uint32_t max_recv_sge; + uint32_t max_inline_data; + struct ibv_cq *send_cq; + struct ibv_cq *recv_cq; + struct ibv_srq *srq; + + /* DV params */ + uint64_t qp_handle; /* to match with cqe */ + void *dbr_handle; /* dbr_handle from alloc_dbr */ + struct ibv_buf *sq_umem_handle; /* handle from ibv_alloc_user_buf() */ + uint64_t sq_umem_offset; /* offset into umem */ + uint32_t sq_len; /* sq length including MSN area */ + uint32_t sq_slots; /* sq length in slots */ + struct ibv_buf *rq_umem_handle; /* handle from ibv_alloc_user_buf() */ + uint64_t rq_umem_offset; /* offset into umem */ + uint32_t sq_npsn; /* sq num psn entries */ + uint32_t rq_len; /* rq length */ + uint64_t comp_mask; /* compatibility mask for future updates */ +}; + +struct bnxt_re_dv_db_region_attr * +bnxt_re_dv_alloc_db_region(struct ibv_context *ctx); +int bnxt_re_dv_free_db_region(struct ibv_context *ctx, + struct bnxt_re_dv_db_region_attr *attr); +int bnxt_re_dv_get_default_db_region(struct ibv_context *ibvctx, + struct bnxt_re_dv_db_region_attr *out); +struct ibv_cq *bnxt_re_dv_create_cq(struct ibv_context *ibvctx, + struct bnxt_re_dv_cq_init_attr *cq_attr); +struct ibv_qp *bnxt_re_dv_create_qp(struct ibv_pd *pd, + struct bnxt_re_dv_qp_init_attr *qp_attr); +#ifdef __cplusplus +} +#endif +#endif /* __BNXT_RE_DV_H__ */
diff --git a/providers/bnxt_re/dv.c b/providers/bnxt_re/dv.c new file mode 100644 index 0000000..5be9a62 --- /dev/null +++ b/providers/bnxt_re/dv.c
@@ -0,0 +1,394 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +/* + * Broadcom NetXtreme-E User Space RoCE driver + * + * Copyright (c) 2015-2026, Broadcom. All rights reserved. The term + * Broadcom refers to Broadcom Limited and/or its subsidiaries. + */ + +#include <stdio.h> +#include <sys/mman.h> + +#include "main.h" +#include "bnxt_re-abi.h" +#include "bnxt_re_dv.h" +#include "./verbs.h" + +/* Returns details about the default Doorbell page for ucontext */ +int bnxt_re_dv_get_default_db_region(struct ibv_context *ibvctx, + struct bnxt_re_dv_db_region_attr *out) +{ + struct bnxt_re_context *cntx = to_bnxt_re_context(ibvctx); + struct bnxt_re_dv_db_region_attr attr = {}; + int ret; + + DECLARE_COMMAND_BUFFER(cmd, + BNXT_RE_OBJECT_DEFAULT_DBR, + BNXT_RE_METHOD_GET_DEFAULT_DBR, + 1); + + fill_attr_out_ptr(cmd, BNXT_RE_DEFAULT_DBR_ATTR, &attr); + + ret = execute_ioctl(ibvctx, cmd); + if (ret) + return ret; + + out->dbr = (uint64_t *)cntx->udpi.dbpage; + out->dpi = attr.dpi; + return 0; +} + +int bnxt_re_dv_free_db_region(struct ibv_context *ctx, + struct bnxt_re_dv_db_region_attr *attr) +{ + struct bnxt_re_dev *dev = to_bnxt_re_dev(ctx->device); + int ret; + + DECLARE_COMMAND_BUFFER(cmd, + BNXT_RE_OBJECT_DBR, + BNXT_RE_METHOD_DBR_FREE, + 1); + + if (attr->dbr != MAP_FAILED) + munmap(attr->dbr, dev->pg_size); + + fill_attr_in_obj(cmd, BNXT_RE_FREE_DBR_HANDLE, attr->handle); + + ret = execute_ioctl(ctx, cmd); + if (ret) { + errno = ret; + return ret; + } + + free(attr); + return 0; +} + +struct bnxt_re_dv_db_region_attr * +bnxt_re_dv_alloc_db_region(struct ibv_context *ctx) +{ + struct bnxt_re_dev *dev = to_bnxt_re_dev(ctx->device); + struct bnxt_re_dv_db_region_attr *out; + struct bnxt_re_db_region attr = {}; + struct ib_uverbs_attr *handle; + uint64_t mmap_offset = 0; + int ret; + + DECLARE_COMMAND_BUFFER(cmd, + BNXT_RE_OBJECT_DBR, + BNXT_RE_METHOD_DBR_ALLOC, + 3); + + out = calloc(1, sizeof(*out)); + if (!out) { + errno = ENOMEM; + return NULL; + } + + handle = fill_attr_out_obj(cmd, BNXT_RE_ALLOC_DBR_HANDLE); + fill_attr_out_ptr(cmd, BNXT_RE_ALLOC_DBR_ATTR, &attr); + fill_attr_out_ptr(cmd, BNXT_RE_ALLOC_DBR_OFFSET, &mmap_offset); + + ret = execute_ioctl(ctx, cmd); + if (ret) { + free(out); + errno = ret; + return NULL; + } + out->handle = read_attr_obj(BNXT_RE_ALLOC_DBR_HANDLE, handle); + out->dpi = attr.dpi; + + out->dbr = mmap(NULL, dev->pg_size, PROT_WRITE, + MAP_SHARED, ctx->cmd_fd, mmap_offset); + if (out->dbr == MAP_FAILED) { + bnxt_re_dv_free_db_region(ctx, out); + errno = ENOMEM; + return NULL; + } + + return out; +} + +static bool bnxt_re_dv_is_valid_buf(struct bnxt_re_dev *dev, + struct ibv_buf *buf, + uint64_t offset, uint32_t size) +{ + return ((offset == align(offset, dev->pg_size)) && + (offset + size <= buf->size)); +} + +static int bnxt_re_dv_create_cq_cmd(struct bnxt_re_dev *dev, + struct ibv_context *ibvctx, + struct bnxt_re_cq *cq, + struct bnxt_re_dv_cq_init_attr *cq_attr, + uint64_t comp_mask, + struct ubnxt_re_cq_resp *resp) +{ + struct bnxt_re_context *cntx = to_bnxt_re_context(ibvctx); + DECLARE_COMMAND_BUFFER(driver_attrs, UVERBS_OBJECT_CQ, + UVERBS_METHOD_CQ_CREATE, 1); + struct ib_uverbs_buffer_desc cq_buf_umem_desc; + struct ibv_cq_init_attr_ex cq_attr_ex = {}; + uint64_t offset = cq_attr->umem_offset; + struct ibv_buf *cq_buf = cq->cq_buf; + struct ubnxt_re_cq cmd = {}; + void *buf_addr; + uint32_t size; + int ret; + + size = cq_attr->ncqe * bnxt_re_get_cqe_sz(); + if (!bnxt_re_dv_is_valid_buf(dev, cq_buf, offset, size)) + return -EINVAL; + + cmd.cq_handle = (uintptr_t)cq; + cmd.comp_mask = comp_mask; + + buf_addr = (uint8_t *)cq_buf->addr + offset; + cmd.cq_va = (uintptr_t)buf_addr; + fill_attr_in_buf_umem_va(driver_attrs, UVERBS_ATTR_CREATE_CQ_BUF_UMEM, + &cq_buf_umem_desc, cq_buf, + buf_addr, size); + + cq_attr_ex.cqe = cq_attr->ncqe; + cq_attr_ex.comp_mask = 0; + cq_attr_ex.flags = 0; + + memset(resp, 0, sizeof(*resp)); + ret = ibv_cmd_create_cq_ex2(ibvctx, &cq_attr_ex, NULL, + &cq->verbs_cq, + &cmd.ibv_cmd, sizeof(cmd), + &resp->ibv_resp, + sizeof(*resp), 0, driver_attrs); + if (ret) + return ret; + + cq->cqid = resp->cqid; + cq->phase = resp->phase; + cq->udpi = &cntx->udpi; + cq->cntx = cntx; + cq->rand.seed = cq->cqid; + + return 0; +} + +struct ibv_cq *bnxt_re_dv_create_cq(struct ibv_context *ibvctx, + struct bnxt_re_dv_cq_init_attr *cq_attr) +{ + struct bnxt_re_dev *dev = to_bnxt_re_dev(ibvctx->device); + uint64_t comp_mask = BNXT_RE_CQ_FIXED_NUM_CQE_ENABLE; + struct ibv_buf *cq_buf = cq_attr->umem_handle; + struct ubnxt_re_cq_resp resp = {}; + struct bnxt_re_cq *cq; + int ret; + + if (!(dev->vdev.core_support & IB_UVERBS_CORE_SUPPORT_ROBUST_UDATA)) + return NULL; + + if (cq_attr->ncqe > dev->max_cq_depth) + return NULL; + + cq = calloc(1, (sizeof(*cq))); + if (!cq) + return NULL; + + cq->cq_buf = cq_buf; + ret = bnxt_re_dv_create_cq_cmd(dev, ibvctx, cq, cq_attr, comp_mask, &resp); + if (ret) + goto fail; + + cq->dv_cq_flags |= BNXT_DV_CQ_FLAGS_VALID; + return &cq->verbs_cq.cq; + +fail: + free(cq); + return NULL; +} + +static void bnxt_re_dv_init_ib_qp(struct ibv_context *ibvctx, + struct ibv_qp_init_attr_ex *attr, + struct bnxt_re_qp *qp) +{ + struct ibv_qp *ibvqp = qp->ibvqp; + + ibvqp->qp_num = qp->qpid; + ibvqp->context = ibvctx; + ibvqp->qp_context = attr->qp_context; + ibvqp->pd = attr->pd; + ibvqp->send_cq = attr->send_cq; + ibvqp->recv_cq = attr->recv_cq; + ibvqp->srq = attr->srq; + ibvqp->qp_type = attr->qp_type; + ibvqp->state = IBV_QPS_RESET; + ibvqp->events_completed = 0; + pthread_mutex_init(&ibvqp->mutex, NULL); + pthread_cond_init(&ibvqp->cond, NULL); +} + +static void bnxt_re_dv_init_qp(struct ibv_context *ibvctx, + struct ibv_qp_init_attr_ex *attr, + struct bnxt_re_qp *qp, + struct ubnxt_re_qp_resp *resp) +{ + struct bnxt_re_context *cntx = to_bnxt_re_context(ibvctx); + struct ibv_device_attr *devattr; + struct bnxt_re_qpcap *cap; + struct bnxt_re_dev *rdev; + + qp->qpid = resp->qpid; + qp->qptyp = attr->qp_type; + qp->qpst = IBV_QPS_RESET; + qp->scq = to_bnxt_re_cq(attr->send_cq); + qp->rcq = to_bnxt_re_cq(attr->recv_cq); + if (attr->srq) + qp->srq = to_bnxt_re_srq(attr->srq); + qp->rand.seed = qp->qpid; + qp->sq_psn = 0; + + rdev = cntx->rdev; + devattr = &rdev->devattr; + cap = &qp->cap; + cap->max_ssge = attr->cap.max_send_sge; + cap->max_rsge = attr->cap.max_recv_sge; + cap->max_inline = attr->cap.max_inline_data; + cap->sqsig = attr->sq_sig_all; + cap->is_atomic_cap = devattr->atomic_cap; + fque_init_node(&qp->snode); + fque_init_node(&qp->rnode); + + bnxt_re_dv_init_ib_qp(ibvctx, attr, qp); +} + +static void fill_ib_attr_from_dv_qp_attr(struct bnxt_re_dv_qp_init_attr *dv_qp_attr, + struct ibv_qp_init_attr *attr) +{ + attr->send_cq = dv_qp_attr->send_cq; + attr->recv_cq = dv_qp_attr->recv_cq; + attr->srq = dv_qp_attr->srq; + attr->cap.max_send_wr = dv_qp_attr->max_send_wr; + attr->cap.max_send_sge = dv_qp_attr->max_send_sge; + attr->qp_type = dv_qp_attr->qp_type; + attr->cap.max_inline_data = dv_qp_attr->max_inline_data; + attr->cap.max_recv_wr = dv_qp_attr->max_recv_wr; + attr->cap.max_recv_sge = dv_qp_attr->max_recv_sge; +} + +static int +bnxt_re_dv_create_qp_cmd(struct ibv_context *ibvctx, + struct bnxt_re_dv_qp_init_attr *dv_qp_attr, + struct ibv_qp_init_attr_ex *attr_ex, + struct ubnxt_re_qp_resp *resp, + struct bnxt_re_qp *qp) +{ + DECLARE_COMMAND_BUFFER_LINK(driver_attrs, UVERBS_OBJECT_QP, + UVERBS_METHOD_QP_CREATE, 3, NULL); + struct ib_uverbs_buffer_desc sq_buf_umem_desc, rq_buf_umem_desc; + struct bnxt_re_context *cntx = to_bnxt_re_context(ibvctx); + struct bnxt_re_dv_db_region_attr *db_attr = NULL; + struct ibv_buf *sq_buf = NULL; + struct ibv_buf *rq_buf = NULL; + struct ubnxt_re_qp req = {}; + void *buf_addr; + uint64_t offset; + uint32_t size; + int ret; + + req.qp_handle = dv_qp_attr->qp_handle; + + /* Setup SQ buffer attributes */ + sq_buf = dv_qp_attr->sq_umem_handle; + offset = dv_qp_attr->sq_umem_offset; + size = dv_qp_attr->sq_len; + if (!bnxt_re_dv_is_valid_buf(cntx->rdev, sq_buf, offset, size)) + return -EINVAL; + + req.sq_slots = dv_qp_attr->sq_slots; + req.sq_npsn = dv_qp_attr->sq_npsn; + buf_addr = (uint8_t *)sq_buf->addr + offset; + fill_attr_in_buf_umem_va(driver_attrs, UVERBS_ATTR_CREATE_QP_SQ_BUF_UMEM, + &sq_buf_umem_desc, sq_buf, + buf_addr, size); + /* Keep qpsva as fallback for kernels without SQ_BUF_UMEM support */ + req.qpsva = (uintptr_t)buf_addr; + + /* Setup RQ buffer attributes */ + if (!dv_qp_attr->srq) { + rq_buf = dv_qp_attr->rq_umem_handle; + offset = dv_qp_attr->rq_umem_offset; + size = dv_qp_attr->rq_len; + if (!bnxt_re_dv_is_valid_buf(cntx->rdev, rq_buf, offset, size)) + return -EINVAL; + + buf_addr = (uint8_t *)rq_buf->addr + offset; + fill_attr_in_buf_umem_va(driver_attrs, + UVERBS_ATTR_CREATE_QP_RQ_BUF_UMEM, + &rq_buf_umem_desc, rq_buf, + buf_addr, size); + /* Keep qprva as fallback for kernels without RQ_BUF_UMEM support */ + req.qprva = (uintptr_t)buf_addr; + } + + req.comp_mask = BNXT_RE_QP_REQ_MASK_FIXED_QUE_ATTR; + if (dv_qp_attr->dbr_handle) { + db_attr = dv_qp_attr->dbr_handle; + qp->dv_dpi.dbpage = (__u64 *)db_attr->dbr; + qp->dv_dpi.dpindx = db_attr->dpi; + qp->udpi = &qp->dv_dpi; + fill_attr_in_obj(driver_attrs, BNXT_RE_CREATE_QP_ATTR_DBR_HANDLE, + db_attr->handle); + } else { + qp->udpi = &cntx->udpi; + } + ret = ibv_cmd_create_qp_ex2(ibvctx, &qp->vqp, attr_ex, + &req.ibv_cmd, sizeof(req), + &resp->ibv_resp, sizeof(*resp), + driver_attrs); + if (ret) + return ret; + + return 0; +} + +struct ibv_qp *bnxt_re_dv_create_qp(struct ibv_pd *ibvpd, + struct bnxt_re_dv_qp_init_attr *dv_qp_attr) +{ + struct bnxt_re_context *cntx = to_bnxt_re_context(ibvpd->context); + struct bnxt_re_dev *dev = to_bnxt_re_dev(ibvpd->context->device); + struct ibv_qp_init_attr_ex attr_ex; + struct ibv_qp_init_attr attr = {}; + struct ubnxt_re_qp_resp resp = {}; + struct bnxt_re_qp *qp; + int rc; + + if (!(dev->vdev.core_support & IB_UVERBS_CORE_SUPPORT_ROBUST_UDATA)) + return NULL; + + if (dv_qp_attr->comp_mask) + return NULL; + + qp = malloc(sizeof(*qp)); + if (!qp) + return NULL; + + memset(qp, 0, sizeof(*qp)); + qp->ibvqp = &qp->vqp.qp; + qp->mem = NULL; + qp->cctx = &cntx->cctx; + qp->cntx = cntx; + qp->qpmode = cntx->wqe_mode & BNXT_RE_WQE_MODE_VARIABLE; + + dv_qp_attr->qp_handle = (uintptr_t)qp; + memset(&attr_ex, 0, sizeof(attr_ex)); + fill_ib_attr_from_dv_qp_attr(dv_qp_attr, &attr); + memcpy(&attr_ex, &attr, sizeof(attr)); + attr_ex.comp_mask = IBV_QP_INIT_ATTR_PD; + attr_ex.pd = ibvpd; + + rc = bnxt_re_dv_create_qp_cmd(ibvpd->context, dv_qp_attr, &attr_ex, &resp, qp); + if (rc) { + free(qp); + return NULL; + } + + bnxt_re_dv_init_qp(ibvpd->context, &attr_ex, qp, &resp); + return qp->ibvqp; +}
diff --git a/providers/bnxt_re/main.h b/providers/bnxt_re/main.h index 599d3ae..e11b71d 100644 --- a/providers/bnxt_re/main.h +++ b/providers/bnxt_re/main.h
@@ -50,6 +50,7 @@ #include <util/util.h> #include <infiniband/driver.h> #include <util/udma_barrier.h> +#include <infiniband/bnxt_re-hsi.h> #include "bnxt_re-abi.h" #include "memory.h" @@ -89,8 +90,13 @@ uint32_t pdid; }; +enum bnxt_dv_cq_flags { + BNXT_DV_CQ_FLAGS_NONE = 0, + BNXT_DV_CQ_FLAGS_VALID = 0x1, +}; + struct bnxt_re_cq { - struct ibv_cq ibvcq; + struct verbs_cq verbs_cq; uint32_t cqid; struct bnxt_re_context *cntx; struct bnxt_re_queue *cqq; @@ -109,6 +115,8 @@ uint8_t resize_tog; bool deffered_db_sup; uint32_t hw_cqes; + struct ibv_buf *cq_buf; + int dv_cq_flags; }; struct bnxt_re_push_buffer { @@ -234,6 +242,7 @@ uint8_t qptyp; struct bnxt_re_mem *mem; struct bnxt_re_wr_send_qp wr_sq; + struct bnxt_re_dpi dv_dpi; }; struct bnxt_re_mr { @@ -342,7 +351,7 @@ static inline struct bnxt_re_cq *to_bnxt_re_cq(struct ibv_cq *ibvcq) { - return container_of(ibvcq, struct bnxt_re_cq, ibvcq); + return container_of(ibvcq, struct bnxt_re_cq, verbs_cq.cq); } static inline struct bnxt_re_qp *to_bnxt_re_qp(struct ibv_qp *ibvqp)
diff --git a/providers/bnxt_re/man/CMakeLists.txt b/providers/bnxt_re/man/CMakeLists.txt new file mode 100644 index 0000000..6e4637d --- /dev/null +++ b/providers/bnxt_re/man/CMakeLists.txt
@@ -0,0 +1,8 @@ +rdma_man_pages( + bnxt_re_dv.7.md + bnxt_re_dv_alloc_db_region.3.md + bnxt_re_dv_free_db_region.3.md + bnxt_re_dv_get_default_db_region.3.md + bnxt_re_dv_create_cq.3.md + bnxt_re_dv_create_qp.3.md +)
diff --git a/providers/bnxt_re/man/bnxt_re_dv.7.md b/providers/bnxt_re/man/bnxt_re_dv.7.md new file mode 100644 index 0000000..a8701fd --- /dev/null +++ b/providers/bnxt_re/man/bnxt_re_dv.7.md
@@ -0,0 +1,68 @@ +--- +layout: page +title: BNXT_RE_DV +section: 7 +tagline: Verbs +date: 2025-06-17 +header: "Broadcom BNXT-RE Direct Verbs Manual" +footer: bnxt_re +--- + +# NAME + +bnxt_re_dv - Direct verbs for Broadcom RoCE (bnxt_re) devices + +# DESCRIPTION + +The libibverbs API is abstract and portable. For workloads that need to +manage some of the RDMA HW resources directly, the bnxt_re provider +exposes **direct verbs**. These are driver-specific routines that work +together with user-registered queue memory and optional doorbell regions. + +To use these new interfaces, include `<infiniband/bnxt_re_dv.h>` and link +against **libbnxt_re** (in addition to **libibverbs**). + +The following Direct Verbs are supported: + +**Doorbell regions** + +- **bnxt_re_dv_alloc_db_region**(3), **bnxt_re_dv_free_db_region**(3) allocate + and release extra doorbell mapping regions. +- **bnxt_re_dv_get_default_db_region**(3) returns the default doorbell page index + and user-mapped doorbell address for the context. + +**Completion queues** + +- **bnxt_re_dv_create_cq**(3) creates a CQ backed by a prior + **ibv_alloc_user_buf**(3) handle and offset. Such a CQ is destroyed like any + other CQ, using **ibv_destroy_cq**(3). + +Applications may create one large buffer with **ibv_alloc_user_buf**(3) and +pass different offsets (aligned to the device page size) and lengths when +creating individual CQs or QP rings. + +**Queue pairs** + +- **bnxt_re_dv_create_qp**(3) creates a QP whose SQ and RQ rings are backed by + prior **ibv_alloc_user_buf**(3) handles and offsets. An optional doorbell + region from **bnxt_re_dv_alloc_db_region**(3) may be supplied; if omitted + the context default is used. Such a QP is destroyed like any other QP, + using **ibv_destroy_qp**(3). Its attributes are modified using the standard + **ibv_modify_qp**(3). + +# SEE ALSO + +**verbs**(7), +**bnxt_re_dv_alloc_db_region**(3), +**bnxt_re_dv_free_db_region**(3), +**bnxt_re_dv_get_default_db_region**(3), +**bnxt_re_dv_create_cq**(3), +**bnxt_re_dv_create_qp**(3), +**ibv_alloc_user_buf**(3), +**ibv_modify_qp**(3) + +# AUTHORS + +Kalesh AP \<kalesh-anakkur.purayil@broadcom.com\>, +Sriharsha Basavapatna \<sriharsha.basavapatna@broadcom.com\>, +Selvin Xavier \<selvin.xavier@broadcom.com\>
diff --git a/providers/bnxt_re/man/bnxt_re_dv_alloc_db_region.3.md b/providers/bnxt_re/man/bnxt_re_dv_alloc_db_region.3.md new file mode 100644 index 0000000..3fd7d3b --- /dev/null +++ b/providers/bnxt_re/man/bnxt_re_dv_alloc_db_region.3.md
@@ -0,0 +1,63 @@ +--- +layout: page +title: bnxt_re_dv_alloc_db_region +section: 3 +tagline: Verbs +date: 2025-06-17 +header: "Broadcom BNXT-RE Direct Verbs Manual" +footer: bnxt_re +--- + +# NAME + +bnxt_re_dv_alloc_db_region - allocate an additional doorbell region + +# SYNOPSIS + +```c +#include <infiniband/bnxt_re_dv.h> + +struct bnxt_re_dv_db_region_attr * +bnxt_re_dv_alloc_db_region(struct ibv_context *ctx); +``` + +# DESCRIPTION + +**bnxt_re_dv_alloc_db_region**() allocates a new doorbell region for *ctx*. +The kernel returns a doorbell region handle and attributes; the library +memory-maps the doorbell page so the application can post doorbells using the +returned mapping. + +The returned pointer must be released with **bnxt_re_dv_free_db_region**(3). + +# ARGUMENTS + +*ctx* +: Verbs device context returned by **ibv_open_device**(3). Identifies the + device instance on which the new doorbell region is allocated. + +# RETURN VALUE + +On success, returns a pointer to a **struct bnxt_re_dv_db_region_attr** +with all fields filled in: + +```c +struct bnxt_re_dv_db_region_attr { + uint32_t handle; /* kernel handle for this doorbell region */ + uint32_t dpi; /* doorbell page index */ + uint64_t *dbr; /* mapped doorbell page (user virtual address) */ +}; +``` + +On failure, returns NULL and sets errno. + +# SEE ALSO + +**bnxt_re_dv**(7), +**bnxt_re_dv_free_db_region**(3), +**bnxt_re_dv_get_default_db_region**(3), +**ibv_open_device**(3) + +# AUTHOR + +Kalesh AP \<kalesh-anakkur.purayil@broadcom.com\>
diff --git a/providers/bnxt_re/man/bnxt_re_dv_create_cq.3.md b/providers/bnxt_re/man/bnxt_re_dv_create_cq.3.md new file mode 100644 index 0000000..6335a21 --- /dev/null +++ b/providers/bnxt_re/man/bnxt_re_dv_create_cq.3.md
@@ -0,0 +1,59 @@ +--- +layout: page +title: bnxt_re_dv_create_cq +section: 3 +tagline: Verbs +date: 2025-06-17 +header: "Broadcom BNXT-RE Direct Verbs Manual" +footer: bnxt_re +--- + +# NAME + +bnxt_re_dv_create_cq - create a completion queue using application-provided memory + +# SYNOPSIS + +```c +#include <infiniband/bnxt_re_dv.h> + +struct ibv_cq *bnxt_re_dv_create_cq(struct ibv_context *ibvctx, + struct bnxt_re_dv_cq_init_attr *cq_attr); + +struct bnxt_re_dv_cq_init_attr { + struct ibv_buf *umem_handle; /* handle from ibv_alloc_user_buf() */ + uint64_t umem_offset; /* byte offset into umem, page-aligned */ + uint32_t ncqe; /* number of CQ entries requested */ +}; +``` + +# DESCRIPTION + +**bnxt_re_dv_create_cq**() creates a completion queue using memory described +by **ibv_alloc_user_buf**(3). The **umem_handle** field must be the handle +returned by that function; **umem_offset** is the byte offset into that +buffer, aligned to the device page size; **ncqe** is the requested number +of CQEs. + +This call requires Linux kernel 7.2 or later; on older kernels it fails. + +A CQ created this way is destroyed like any other CQ, using +**ibv_destroy_cq**(3). + +# RETURN VALUE + +Returns a pointer to the created **ibv_cq** on success, or NULL on failure with +errno set. + +# SEE ALSO + +**bnxt_re_dv**(7), +**ibv_alloc_user_buf**(3), +**ibv_create_cq**(3), +**ibv_destroy_cq**(3) + +# AUTHORS + +Sriharsha Basavapatna \<sriharsha.basavapatna@broadcom.com\>, +Kalesh AP \<kalesh-anakkur.purayil@broadcom.com\>, +Selvin Xavier \<selvin.xavier@broadcom.com\>
diff --git a/providers/bnxt_re/man/bnxt_re_dv_create_qp.3.md b/providers/bnxt_re/man/bnxt_re_dv_create_qp.3.md new file mode 100644 index 0000000..a4fbfa0 --- /dev/null +++ b/providers/bnxt_re/man/bnxt_re_dv_create_qp.3.md
@@ -0,0 +1,100 @@ +--- +layout: page +title: bnxt_re_dv_create_qp +section: 3 +tagline: Verbs +date: 2026-06-05 +header: "Broadcom BNXT-RE Direct Verbs Manual" +footer: bnxt_re +--- + +# NAME + +bnxt_re_dv_create_qp - create a queue pair using application-provided memory + +# SYNOPSIS + +```c +#include <infiniband/bnxt_re_dv.h> + +struct ibv_qp *bnxt_re_dv_create_qp(struct ibv_pd *pd, + struct bnxt_re_dv_qp_init_attr *qp_attr); + +struct bnxt_re_dv_qp_init_attr { + /* Standard ibv parameters */ + enum ibv_qp_type qp_type; + uint32_t max_send_wr; + uint32_t max_recv_wr; + uint32_t max_send_sge; + uint32_t max_recv_sge; + uint32_t max_inline_data; + struct ibv_cq *send_cq; + struct ibv_cq *recv_cq; + struct ibv_srq *srq; /* NULL if not using an SRQ */ + + /* Direct verbs parameters */ + uint64_t qp_handle; /* opaque handle embedded in CQEs */ + void *dbr_handle; /* bnxt_re_dv_alloc_db_region() handle, + or NULL for the context default */ + struct ibv_buf *sq_umem_handle; /* handle from ibv_alloc_user_buf() */ + uint64_t sq_umem_offset; /* byte offset into SQ umem, page-aligned */ + uint32_t sq_len; /* SQ ring length in bytes (incl. MSN area) */ + uint32_t sq_slots; /* SQ depth in WQE slots */ + uint32_t sq_npsn; /* number of PSN entries */ + struct ibv_buf *rq_umem_handle; /* handle from ibv_alloc_user_buf() */ + uint64_t rq_umem_offset; /* byte offset into RQ umem, page-aligned */ + uint32_t rq_len; /* RQ ring length in bytes */ + uint64_t comp_mask; /* reserved, set to 0 */ +}; +``` + +# DESCRIPTION + +**bnxt_re_dv_create_qp**() creates a queue pair whose send queue (SQ) and +receive queue (RQ) rings are backed by memory described by +**ibv_alloc_user_buf**(3). This allows the application to manage QP ring +memory directly. + +**qp_handle** is an opaque value set by the library on successful return. It +is embedded in completion queue entries (CQEs) so the application can +correlate completions back to this QP. The application must not set this +field before the call; it is populated by the library. + +**sq_umem_handle** must be a handle returned by **ibv_alloc_user_buf**(3). +**sq_umem_offset** is the page-aligned byte offset into that buffer +where the SQ ring starts. **sq_len** must cover the full ring including the +MSN (message sequence number) area. **sq_slots** is the SQ depth in WQE +slots and **sq_npsn** is the number of PSN entries; both must be set by the +application based on the ring memory it has allocated. + +**rq_umem_handle** must be a handle returned by **ibv_alloc_user_buf**(3) +for the RQ ring. If **srq** is set, **rq_umem_handle** and **rq_umem_offset** +are ignored. + +If **dbr_handle** is NULL, the context's default doorbell page is used. +Otherwise it must be a pointer returned by **bnxt_re_dv_alloc_db_region**(3). + +This call requires Linux kernel 7.2 or later when **sq_umem_handle** is +provided; on older kernels it fails. + +A QP created this way is destroyed like any other QP, using +**ibv_destroy_qp**(3). + +# RETURN VALUE + +Returns a pointer to the created **ibv_qp** on success, or NULL on failure +with errno set. + +# SEE ALSO + +**bnxt_re_dv**(7), +**ibv_alloc_user_buf**(3), +**bnxt_re_dv_alloc_db_region**(3), +**ibv_create_qp**(3), +**ibv_destroy_qp**(3), +**ibv_modify_qp**(3) + +# AUTHORS + +Sriharsha Basavapatna \<sriharsha.basavapatna@broadcom.com\>, +Selvin Xavier \<selvin.xavier@broadcom.com\>
diff --git a/providers/bnxt_re/man/bnxt_re_dv_free_db_region.3.md b/providers/bnxt_re/man/bnxt_re_dv_free_db_region.3.md new file mode 100644 index 0000000..fb3bcc7 --- /dev/null +++ b/providers/bnxt_re/man/bnxt_re_dv_free_db_region.3.md
@@ -0,0 +1,46 @@ +--- +layout: page +title: bnxt_re_dv_free_db_region +section: 3 +tagline: Verbs +date: 2025-06-17 +header: "Broadcom BNXT-RE Direct Verbs Manual" +footer: bnxt_re +--- + +# NAME + +bnxt_re_dv_free_db_region - free a doorbell region allocated with bnxt_re_dv_alloc_db_region + +# SYNOPSIS + +```c +#include <infiniband/bnxt_re_dv.h> + +int bnxt_re_dv_free_db_region(struct ibv_context *ctx, + struct bnxt_re_dv_db_region_attr *attr); +``` + +# DESCRIPTION + +**bnxt_re_dv_free_db_region**() unmmaps the doorbell page, requests the driver to +free the region identified by *attr*, and frees the **bnxt_re_dv_db_region_attr** +structure. + +*attr* must be the pointer returned by **bnxt_re_dv_alloc_db_region**(3) for the +same *ctx*. + +# RETURN VALUE + +Returns 0 on success. On ioctl failure returns a non-zero error value and sets +**errno** to that value. + +# SEE ALSO + +**bnxt_re_dv**(7), +**bnxt_re_dv_alloc_db_region**(3), +**bnxt_re_dv_get_default_db_region**(3) + +# AUTHOR + +Kalesh AP \<kalesh-anakkur.purayil@broadcom.com\>
diff --git a/providers/bnxt_re/man/bnxt_re_dv_get_default_db_region.3.md b/providers/bnxt_re/man/bnxt_re_dv_get_default_db_region.3.md new file mode 100644 index 0000000..c233390 --- /dev/null +++ b/providers/bnxt_re/man/bnxt_re_dv_get_default_db_region.3.md
@@ -0,0 +1,53 @@ +--- +layout: page +title: bnxt_re_dv_get_default_db_region +section: 3 +tagline: Verbs +date: 2025-06-17 +header: "Broadcom BNXT-RE Direct Verbs Manual" +footer: bnxt_re +--- + +# NAME + +bnxt_re_dv_get_default_db_region - query the default doorbell region for a context + +# SYNOPSIS + +```c +#include <infiniband/bnxt_re_dv.h> + +int bnxt_re_dv_get_default_db_region(struct ibv_context *ibvctx, + struct bnxt_re_dv_db_region_attr *out); +``` + +# DESCRIPTION + +**bnxt_re_dv_get_default_db_region**() fills *out* with the default doorbell page +index (**dpi**) and a pointer (**dbr**) to the user-mapped doorbell page +already associated with the **ibv_context**. + +Unlike **bnxt_re_dv_alloc_db_region**(3), this does not allocate a new region. + +# ARGUMENTS + +*out* +: Output structure; **handle** is not used for the default region; **dbr** + and **dpi** are valid on success. + For the definition of **struct bnxt_re_dv_db_region_attr** and its members, see + **bnxt_re_dv_alloc_db_region**(3). + +# RETURN VALUE + +Returns 0 on success, or a negative error code on failure. + +# SEE ALSO + +**bnxt_re_dv**(7), +**bnxt_re_dv_alloc_db_region**(3), +**bnxt_re_dv_free_db_region**(3), +**ibv_open_device**(3) + +# AUTHOR + +Kalesh AP \<kalesh-anakkur.purayil@broadcom.com\>
diff --git a/providers/bnxt_re/memory.c b/providers/bnxt_re/memory.c index 30d972f..79e973a 100644 --- a/providers/bnxt_re/memory.c +++ b/providers/bnxt_re/memory.c
@@ -46,6 +46,13 @@ void bnxt_re_free_mem(struct bnxt_re_mem *mem) { + /* When a DV app allocates its own memory for objects, + * there is no bnxt_re_mem object associated. So just + * return when called from its destroy(). + */ + if (!mem) + return; + if (mem->va_head) { ibv_dofork_range(mem->va_head, mem->size); munmap(mem->va_head, mem->size);
diff --git a/providers/bnxt_re/memory.h b/providers/bnxt_re/memory.h index a0089ee..1a6858b 100644 --- a/providers/bnxt_re/memory.h +++ b/providers/bnxt_re/memory.h
@@ -97,7 +97,6 @@ uint32_t old_head; }; - /* Basic queue operation */ static inline void *bnxt_re_get_hwqe(struct bnxt_re_queue *que, uint32_t idx) {
diff --git a/providers/bnxt_re/verbs.c b/providers/bnxt_re/verbs.c index 00a6129..ca5fbe5 100644 --- a/providers/bnxt_re/verbs.c +++ b/providers/bnxt_re/verbs.c
@@ -54,6 +54,7 @@ #include "main.h" #include "verbs.h" +#include "bnxt_re_dv.h" static int bnxt_re_poll_one(struct bnxt_re_cq *cq, int nwc, struct ibv_wc *wc, uint32_t *resize); @@ -338,10 +339,11 @@ struct ibv_cq *bnxt_re_create_cq(struct ibv_context *ibvctx, int ncqe, struct ibv_comp_channel *channel, int vec) { - struct bnxt_re_cq *cq; - struct ubnxt_re_cq cmd = {}; - struct ubnxt_re_cq_resp resp; + struct ibv_cq_init_attr_ex cq_attr_ex = {}; struct bnxt_re_mmap_info minfo = {}; + struct ubnxt_re_cq_resp resp = {}; + struct ubnxt_re_cq cmd = {}; + struct bnxt_re_cq *cq; int ret; struct bnxt_re_context *cntx = to_bnxt_re_context(ibvctx); @@ -383,10 +385,15 @@ cmd.cq_va = (uintptr_t)cq->cqq->va; cmd.cq_handle = (uintptr_t)cq; - memset(&resp, 0, sizeof(resp)); - if (ibv_cmd_create_cq(ibvctx, ncqe, channel, vec, - &cq->ibvcq, &cmd.ibv_cmd, sizeof(cmd), - &resp.ibv_resp, sizeof(resp))) + cq_attr_ex.cqe = ncqe; + cq_attr_ex.channel = channel; + cq_attr_ex.comp_vector = vec; + if (ibv_cmd_create_cq_ex(ibvctx, &cq_attr_ex, NULL, + &cq->verbs_cq, + &cmd.ibv_cmd, + sizeof(cmd), + &resp.ibv_resp, + sizeof(resp), 0)) goto cmdfail; cq->cqid = resp.cqid; @@ -399,7 +406,7 @@ if (resp.comp_mask & BNXT_RE_CQ_TOGGLE_PAGE_SUPPORT) { minfo.type = BNXT_RE_CQ_TOGGLE_MEM; minfo.res_id = resp.cqid; - ret = bnxt_re_get_toggle_mem(ibvctx, &minfo, cq->ibvcq.handle, + ret = bnxt_re_get_toggle_mem(ibvctx, &minfo, cq->verbs_cq.cq.handle, &cq->mem_handle); if (ret) goto cmdfail; @@ -413,7 +420,7 @@ list_head_init(&cq->rfhead); list_head_init(&cq->prev_cq_head); - return &cq->ibvcq; + return &cq->verbs_cq.cq; cmdfail: bnxt_re_free_mem(cq->mem); fail: @@ -431,10 +438,10 @@ */ static void bnxt_re_resize_cq_complete(struct bnxt_re_cq *cq) { - struct bnxt_re_context *cntx = to_bnxt_re_context(cq->ibvcq.context); + struct bnxt_re_context *cntx = to_bnxt_re_context(cq->verbs_cq.cq.context); struct ibv_wc tmp_wc; - ibv_cmd_poll_cq(&cq->ibvcq, 1, &tmp_wc); + ibv_cmd_poll_cq(&cq->verbs_cq.cq, 1, &tmp_wc); bnxt_re_free_mem(cq->mem); cq->mem = cq->resize_mem; @@ -1106,7 +1113,7 @@ return dqed; } -static void bnxt_re_cleanup_cq(struct bnxt_re_qp *qp, struct bnxt_re_cq *cq) +void bnxt_re_cleanup_cq(struct bnxt_re_qp *qp, struct bnxt_re_cq *cq) { struct bnxt_re_queue *que = cq->cqq; struct bnxt_re_bcqe *hdr; @@ -1115,6 +1122,9 @@ void *cqe; int indx, type; + if (cq->dv_cq_flags & BNXT_DV_CQ_FLAGS_VALID) + return; + pthread_spin_lock(&que->qlock); for (indx = 0; indx < que->depth; indx++) { cqe = que->va + indx * bnxt_re_get_cqe_sz(); @@ -2124,8 +2134,9 @@ if (qp->qpmode == BNXT_RE_WQE_MODE_VARIABLE) req.sq_slots = qattr[BNXT_RE_QATTR_SQ_INDX].slots; - if (ibv_cmd_create_qp_ex(ibvctx, &qp->vqp, attr, - &req.ibv_cmd, sizeof(req), &resp.ibv_resp, sizeof(resp))) + if (ibv_cmd_create_qp_ex2(ibvctx, &qp->vqp, attr, + &req.ibv_cmd, sizeof(req), + &resp.ibv_resp, sizeof(resp), NULL)) goto fail; @@ -2202,11 +2213,13 @@ qp->qpst = attr->qp_state; /* transition to reset */ if (qp->qpst == IBV_QPS_RESET) { - qp->jsqq->hwque->head = 0; - qp->jsqq->hwque->tail = 0; + if (qp->jsqq) { + qp->jsqq->hwque->head = 0; + qp->jsqq->hwque->tail = 0; + qp->jsqq->start_idx = 0; + qp->jsqq->last_idx = 0; + } bnxt_re_cleanup_cq(qp, qp->scq); - qp->jsqq->start_idx = 0; - qp->jsqq->last_idx = 0; if (qp->jrqq) { qp->jrqq->hwque->head = 0; qp->jrqq->hwque->tail = 0;
diff --git a/providers/bnxt_re/verbs.h b/providers/bnxt_re/verbs.h index a04e9ba..3bf108b 100644 --- a/providers/bnxt_re/verbs.h +++ b/providers/bnxt_re/verbs.h
@@ -127,6 +127,8 @@ struct ibv_async_event *event); int bnxt_re_modify_qp_rate_limit(struct ibv_qp *qp, struct ibv_qp_rate_limit_attr *attr); +void bnxt_re_cleanup_cq(struct bnxt_re_qp *qp, + struct bnxt_re_cq *cq); static inline __le64 bnxt_re_update_msn_tbl(uint32_t st_idx, uint32_t npsn, uint32_t start_psn) {
diff --git a/providers/efa/verbs.c b/providers/efa/verbs.c index 25981f5..614542f 100644 --- a/providers/efa/verbs.c +++ b/providers/efa/verbs.c
@@ -481,7 +481,10 @@ return efa_wq_get_next_wrid_idx_locked(wq, wr_id) | wq->shifted_gen; } -static void efa_wq_cqe_finalize(struct efa_wq *wq, struct efa_io_cdesc_common *cqe) +static inline void efa_wq_cqe_finalize(struct efa_wq *wq, + struct efa_io_cdesc_common *cqe) ALWAYS_INLINE; +static inline void efa_wq_cqe_finalize(struct efa_wq *wq, + struct efa_io_cdesc_common *cqe) { if (wq->need_lock) pthread_spin_lock(&wq->wqlock);
diff --git a/providers/hns/hns_roce_u_hw_v2.c b/providers/hns/hns_roce_u_hw_v2.c index 20b95b8..acda771 100644 --- a/providers/hns/hns_roce_u_hw_v2.c +++ b/providers/hns/hns_roce_u_hw_v2.c
@@ -305,7 +305,7 @@ static void hns_roce_write512(uint64_t *dest, uint64_t *val) { - mmio_memcpy_x64(dest, val, sizeof(struct hns_roce_rc_sq_wqe)); + mmio_memcpy_x64(dest, val, 1 << HNS_ROCE_SQWQE_SHIFT); } static void hns_roce_write_dwqe(struct hns_roce_qp *qp, void *wqe)
diff --git a/providers/ionic/CMakeLists.txt b/providers/ionic/CMakeLists.txt index a28083f..795a100 100644 --- a/providers/ionic/CMakeLists.txt +++ b/providers/ionic/CMakeLists.txt
@@ -1,5 +1,5 @@ rdma_shared_provider(ionic libionic.map - 1 1.0.${PACKAGE_VERSION} + 1 1.1.${PACKAGE_VERSION} ionic.c ionic_verbs.c ionic_memory.c
diff --git a/providers/ionic/ionic.c b/providers/ionic/ionic.c index 6451aab..bd976d4 100644 --- a/providers/ionic/ionic.c +++ b/providers/ionic/ionic.c
@@ -78,6 +78,11 @@ ctx->sq_expdb = !!(resp.expdb_qtypes & IONIC_EXPDB_SQ); ctx->rq_expdb = !!(resp.expdb_qtypes & IONIC_EXPDB_RQ); + ctx->robust_udata = !!(verbs_get_device(ibdev)->core_support & + IB_UVERBS_CORE_SUPPORT_ROBUST_UDATA); + ctx->ionic_flags_supported = !!(resp.comp_mask & IONIC_CTX_CMASK_IONIC_FLAGS); + ctx->rcq_sign_bit = resp.rcq_sign_bit; + mask = (1u << ctx->pg_shift) - 1; ctx->dbpage_page = ionic_map_device(1u << ctx->pg_shift, cmd_fd, resp.dbell_offset & ~mask);
diff --git a/providers/ionic/ionic.h b/providers/ionic/ionic.h index cb1a8da..e49e223 100644 --- a/providers/ionic/ionic.h +++ b/providers/ionic/ionic.h
@@ -22,6 +22,7 @@ #include "ionic_memory.h" #include "ionic_queue.h" #include "ionic_table.h" +#include "ionic_dv.h" #include <stdio.h> #include <inttypes.h> @@ -45,6 +46,17 @@ #define IONIC_PD_TAG_CQ (IONIC_PD_TAG | 1) #define IONIC_PD_TAG_SQ (IONIC_PD_TAG | 2) #define IONIC_PD_TAG_RQ (IONIC_PD_TAG | 3) +#define IONIC_PD_TAG_RCQ (IONIC_PD_TAG | 4) + +#define IONIC_SET_UDATA(ctx, req, field, val) \ + ({ \ + int __rc = 0; \ + if ((ctx)->robust_udata) \ + (req)->field = (val); \ + else \ + __rc = ENOTSUP; \ + __rc; \ + }) enum { IONIC_CQ_SUPPORTED_WC_FLAGS = @@ -83,6 +95,18 @@ IBV_QP_EX_WITH_SEND_WITH_INV, }; +enum { + IONIC_QP_SUPPORTED_INIT_ATTR_MASK = + IONIC_QP_INIT_ATTR_MASK_FLAGS, + + IONIC_QP_SUPPORTED_INIT_ATTR_FLAGS = + IONIC_QP_INIT_ATTR_RCCL | + IONIC_QP_INIT_ATTR_RCCL_DATA | + IONIC_QP_INIT_ATTR_RCCL_RDFENCE | + IONIC_QP_INIT_ATTR_RCCL_RX_OFFLOAD | + IONIC_QP_INIT_ATTR_RCCL_RCQ, +}; + struct ionic_ctx { struct verbs_context vctx; @@ -102,6 +126,9 @@ uint8_t expdb_mask; bool sq_expdb; bool rq_expdb; + bool robust_udata; + bool ionic_flags_supported; + uint8_t rcq_sign_bit; void *dbpage_page; uint64_t *dbpage; @@ -196,6 +223,16 @@ struct ionic_rq_meta { struct ionic_rq_meta *next; uint64_t wrid; + struct { + uint64_t timestamp; + uint32_t seq; + uint32_t imm_rkey; + uint32_t sts_len; + uint8_t valid:1; + uint8_t ready:1; + uint8_t error:1; + uint8_t op; + } rcqe; }; struct ionic_rq { @@ -253,6 +290,7 @@ struct ibv_send_wr ex_wr; int ex_rc; bool sig_all; + bool rcq; }; struct ionic_ah { @@ -374,4 +412,8 @@ /* ionic_verbs.h */ void ionic_verbs_set_ops(struct ionic_ctx *ctx); +struct ibv_qp *ionic_create_qp_ex_common(struct ibv_context *ibctx, + struct ibv_qp_init_attr_ex *ex, + struct ionic_dv_qp_init_attr_ex *ionic_ex); + #endif /* IONIC_H */
diff --git a/providers/ionic/ionic_dv.c b/providers/ionic/ionic_dv.c index 738fcc3..92900dc 100644 --- a/providers/ionic/ionic_dv.c +++ b/providers/ionic/ionic_dv.c
@@ -105,3 +105,15 @@ return 0; } + +struct ibv_qp *ionic_dv_create_qp_ex(struct ibv_context *ibctx, + struct ibv_qp_init_attr_ex *ex, + struct ionic_dv_qp_init_attr_ex *ionic_ex) +{ + if (!is_ionic_ctx(ibctx)) { + errno = EINVAL; + return NULL; + } + + return ionic_create_qp_ex_common(ibctx, ex, ionic_ex); +}
diff --git a/providers/ionic/ionic_dv.h b/providers/ionic/ionic_dv.h index a11f5a2..d8efda8 100644 --- a/providers/ionic/ionic_dv.h +++ b/providers/ionic/ionic_dv.h
@@ -68,6 +68,35 @@ */ int ionic_dv_pd_set_rqcmb(struct ibv_pd *ibpd, bool enable, bool expdb, bool require); +enum ionic_qp_init_attr_mask { + IONIC_QP_INIT_ATTR_MASK_FLAGS = 1 << 0, +}; + +enum ionic_qp_init_attr_flags { + IONIC_QP_INIT_ATTR_RCCL = 1 << 16, + IONIC_QP_INIT_ATTR_RCCL_DATA = 1 << 17, + IONIC_QP_INIT_ATTR_RCCL_RDFENCE = 1 << 18, + IONIC_QP_INIT_ATTR_RCCL_RX_OFFLOAD = 1 << 19, + IONIC_QP_INIT_ATTR_RCCL_RCQ = 1 << 24, + IONIC_QP_INIT_ATTR_RCCL_P2P = 1 << 25, +}; + +struct ionic_dv_qp_init_attr_ex { + uint64_t comp_mask; + uint32_t flags; +}; + +/** + * ionic_dv_create_qp_ex - Create a queue pair with ionic-specific attributes. + * + * @ibctx - Device context. + * @ex - Standard QP init attributes. + * @ionic_ex - Ionic-specific QP init attributes (transport mode, rcq paths). + */ +struct ibv_qp *ionic_dv_create_qp_ex(struct ibv_context *ibctx, + struct ibv_qp_init_attr_ex *ex, + struct ionic_dv_qp_init_attr_ex *ionic_ex); + #ifdef __cplusplus } #endif
diff --git a/providers/ionic/ionic_fw.h b/providers/ionic/ionic_fw.h index 6598213..1d80163 100644 --- a/providers/ionic/ionic_fw.h +++ b/providers/ionic/ionic_fw.h
@@ -217,4 +217,48 @@ return spec; } +static inline uint32_t ionic_v1_rcqe_seq(uint32_t seq_opf) +{ + return seq_opf & IONIC_V1_CQE_RCQE_SEQ_MASK; +} + +static inline uint8_t ionic_v1_rcqe_op(uint32_t seq_opf) +{ + return seq_opf >> IONIC_V1_CQE_RCQE_OP_SHIFT; +} + +static inline bool ionic_v1_rcqe_valid(uint32_t seq_opf) +{ + return seq_opf & IONIC_V1_CQE_RCQE_FLAG_V; +} + +static inline bool ionic_v1_rcqe_ready(uint32_t seq_opf) +{ + return seq_opf & IONIC_V1_CQE_RCQE_FLAG_I; +} + +#define IONIC_RCQ_SIZE 4096 + +struct ionic_rcq_hdr { + __be32 seq; + __be32 ack; +}; + +struct ionic_rcq { + union { + uint8_t bytes[IONIC_RCQ_SIZE]; + struct ionic_rcq_hdr hdr; + }; +}; + +static inline uint32_t ionic_rcq_seq(struct ionic_rcq *rcq) +{ + return be32toh(rcq->hdr.seq) & IONIC_V1_CQE_RCQE_SEQ_MASK; +} + +static inline void ionic_rcq_ack(struct ionic_rcq *rcq, uint32_t ack) +{ + rcq->hdr.ack = htobe32(ack); +} + #endif /* IONIC_FW_H */
diff --git a/providers/ionic/ionic_fw_types.h b/providers/ionic/ionic_fw_types.h index b57f7f9..4653673 100644 --- a/providers/ionic/ionic_fw_types.h +++ b/providers/ionic/ionic_fw_types.h
@@ -70,22 +70,34 @@ __u8 data[32]; }; +struct ionic_v1_cqe_send { + __u8 rsvd[4]; + __be32 msg_msn; + __u8 rsvd2[8]; + __le64 npg_wqe_idx_timestamp; +}; + +struct ionic_v1_cqe_recv { + __le64 wqe_idx_timestamp; + __be32 src_qpn_op; + __u8 src_mac[6]; + __be16 vlan_tag; + __be32 imm_data_rkey; +}; + +struct ionic_v1_cqe_rcqe { + __be64 wqe_idx_timestamp; + __u8 rsvd[8]; + __be32 seq_op_flags; + __be32 imm_data_rkey; +}; + /* completion queue v1 cqe */ struct ionic_v1_cqe { union { - struct { - __le64 wqe_idx_timestamp; - __be32 src_qpn_op; - __u8 src_mac[6]; - __be16 vlan_tag; - __be32 imm_data_rkey; - } recv; - struct { - __u8 rsvd[4]; - __be32 msg_msn; - __u8 rsvd2[8]; - __le64 npg_wqe_idx_timestamp; - } send; + struct ionic_v1_cqe_send send; + struct ionic_v1_cqe_recv recv; + struct ionic_v1_cqe_rcqe rcqe; }; __be32 status_length; __be32 qid_type_flags; @@ -97,6 +109,14 @@ IONIC_V1_CQE_TIMESTAMP_SHIFT = 16, }; +/* bits for rcqe seq_op_flags */ +enum ionic_v1_cqe_rcqe_op_flag_bits { + IONIC_V1_CQE_RCQE_SEQ_MASK = 0xffffff, + IONIC_V1_CQE_RCQE_FLAG_V = 1u << 24, + IONIC_V1_CQE_RCQE_FLAG_I = 1u << 25, + IONIC_V1_CQE_RCQE_OP_SHIFT = 28, +}; + /* bits for cqe recv */ enum ionic_v1_cqe_src_qpn_bits { IONIC_V1_CQE_RECV_QPN_MASK = 0xffffff, @@ -126,7 +146,7 @@ IONIC_V1_CQE_TYPE_RECV = 1, IONIC_V1_CQE_TYPE_SEND_MSN = 2, IONIC_V1_CQE_TYPE_SEND_NPG = 3, - IONIC_V1_CQE_TYPE_RECV_INDIR = 4, + IONIC_V1_CQE_TYPE_RECV_RCQE = 4, }; /* v1 base wqe header */
diff --git a/providers/ionic/ionic_queue.c b/providers/ionic/ionic_queue.c index 28458a6..518a986 100644 --- a/providers/ionic/ionic_queue.c +++ b/providers/ionic/ionic_queue.c
@@ -9,6 +9,7 @@ #include "ionic.h" #include "ionic_queue.h" #include "ionic_memory.h" +#include "ionic_fw.h" static void ionic_queue_map(struct ionic_queue *q, struct ionic_pd *pd, uint64_t pd_tag, int stride) { @@ -65,6 +66,9 @@ q->size = BIT_ULL(q->depth_log2 + q->stride_log2); q->mask = BIT(q->depth_log2) - 1; + if (pd_tag == IONIC_PD_TAG_RCQ) + q->size += IONIC_RCQ_SIZE; + ionic_queue_map(q, pd, pd_tag, stride); if (!q->ptr) return errno;
diff --git a/providers/ionic/ionic_verbs.c b/providers/ionic/ionic_verbs.c index 1aa08f5..2e6e698 100644 --- a/providers/ionic/ionic_verbs.c +++ b/providers/ionic/ionic_verbs.c
@@ -1401,6 +1401,124 @@ } } +static int ionic_validate_rcq_wqe_idx(uint16_t prod, uint16_t cons, + uint16_t idx, uint16_t mask) +{ + return ((idx - cons) & mask) < ((prod - cons) & mask) ? 0 : -EIO; +} + +static void ionic_comp_rcqe(struct ionic_ctx *ctx, + struct ionic_qp *qp, + struct ionic_v1_cqe *cqe) +{ + struct ionic_rq_meta *meta; + uint64_t wqe_idx_timestamp; + uint32_t wqe_idx; + uint32_t seq_opf; + bool error; + int rc; + + seq_opf = be32toh(cqe->rcqe.seq_op_flags); + + if (!ionic_v1_rcqe_valid(seq_opf)) + return; + + wqe_idx_timestamp = be64toh(cqe->rcqe.wqe_idx_timestamp); + wqe_idx = wqe_idx_timestamp & IONIC_V1_CQE_WQE_IDX_MASK; + + if (unlikely(wqe_idx >> qp->rq.queue.depth_log2)) { + verbs_err(&ctx->vctx, "invalid wqe_idx %#x", wqe_idx); + return; + } + + rc = ionic_validate_rcq_wqe_idx(qp->rq.queue.prod, + qp->rq.queue.cons, + wqe_idx, + qp->rq.queue.mask); + if (rc) { + struct ionic_cq *cq = + to_ionic_vcq_cq(qp->vqp.qp.recv_cq, qp->udma_idx); + + verbs_err(&ctx->vctx, "wqe is not posted for rcqe seq %u rcqe idx %u qpid %u prod %u cons %u cqid %u", + ionic_v1_rcqe_seq(seq_opf), wqe_idx, + qp->qpid, qp->rq.queue.prod, qp->rq.queue.cons, cq->cqid); + return; + } + + meta = &qp->rq.meta[qp->rq.meta_idx[wqe_idx]]; + error = ionic_v1_cqe_error(cqe); + + meta->rcqe.valid = true; + meta->rcqe.error = error; + meta->rcqe.ready = ionic_v1_rcqe_ready(seq_opf); + meta->rcqe.op = ionic_v1_rcqe_op(seq_opf); + meta->rcqe.seq = ionic_v1_rcqe_seq(seq_opf); + meta->rcqe.imm_rkey = be32toh(cqe->rcqe.imm_data_rkey); + meta->rcqe.sts_len = be32toh(cqe->status_length); + meta->rcqe.timestamp = wqe_idx_timestamp >> IONIC_V1_CQE_TIMESTAMP_SHIFT; + + verbs_debug(&ctx->vctx, "received rcq_seq %u wqe idx %u", meta->rcqe.seq, wqe_idx); +} + +static int ionic_poll_rcq_recv(struct ionic_ctx *ctx, + struct ionic_cq *cq, + struct ionic_qp *qp, + struct ibv_wc *wc) +{ + struct ionic_v1_cqe cqe = {}; + struct ionic_rq_meta *meta; + uint64_t wqe_idx_timestamp; + struct ionic_rcq *rcq; + uint32_t rcq_seq; + + if (qp->rq.flush) + return 0; + + rcq = qp->rq.queue.ptr + qp->rq.queue.size - IONIC_RCQ_SIZE; + + rcq_seq = ionic_rcq_seq(rcq); + ionic_rcq_ack(rcq, rcq_seq); + + if (ionic_queue_empty(&qp->rq.queue)) + return 0; + + meta = &qp->rq.meta[qp->rq.meta_idx[qp->rq.queue.cons]]; + if (!meta->rcqe.valid) + return 0; + + if (!meta->rcqe.ready && ((rcq_seq - meta->rcqe.seq) & BIT(ctx->rcq_sign_bit))) + return -EAGAIN; + + verbs_debug(&ctx->vctx, "polled rcq_seq %u rcqe_seq %u sign %lu cons %u", + rcq_seq, meta->rcqe.seq, BIT(ctx->rcq_sign_bit), qp->rq.queue.cons); + + wqe_idx_timestamp = qp->rq.queue.cons | + (meta->rcqe.timestamp << IONIC_V1_CQE_TIMESTAMP_SHIFT); + cqe.recv.wqe_idx_timestamp = htole64(wqe_idx_timestamp); + cqe.recv.src_qpn_op = htobe32(meta->rcqe.op << IONIC_V1_CQE_RECV_OP_SHIFT); + cqe.recv.imm_data_rkey = htobe32(meta->rcqe.imm_rkey); + cqe.status_length = htobe32(meta->rcqe.sts_len); + + return ionic_poll_recv(ctx, cq, qp, &cqe, wc); +} + +static int ionic_poll_rcq_recv_many(struct ionic_ctx *ctx, struct ionic_cq *cq, + struct ionic_qp *qp, + struct ibv_wc *wc, int nwc) +{ + int rc = 0, npolled = 0; + + while (npolled < nwc) { + rc = ionic_poll_rcq_recv(ctx, cq, qp, wc + npolled); + if (rc <= 0) + break; + + npolled += rc; + } + + return npolled ?: rc; +} + static int ionic_poll_vcq_cq(struct ionic_ctx *ctx, struct ionic_cq *cq, int nwc, struct ibv_wc *wc) { @@ -1516,7 +1634,9 @@ break; - case IONIC_V1_CQE_TYPE_RECV_INDIR: + case IONIC_V1_CQE_TYPE_RECV_RCQE: + ionic_comp_rcqe(ctx, qp, cqe); + list_del(&qp->cq_poll_rq); list_add_tail(&cq->poll_rq, &qp->cq_poll_rq); break; @@ -1532,6 +1652,26 @@ cq->color = ionic_color_wrap(cq->q.prod, cq->color); } + /* poll out-of-order rcq completions for recv queue */ + list_for_each_safe(&cq->poll_rq, qp, qp_next, cq_poll_rq) { + if (npolled == nwc) + goto out; + + ionic_rq_spin_lock(qp); + rc = ionic_poll_rcq_recv_many(ctx, cq, qp, + wc + npolled, nwc - npolled); + ionic_rq_spin_unlock(qp); + + if (rc == 0) + list_del_init(&qp->cq_poll_rq); + else if (rc == -EAGAIN) + rc = 0; + else if (rc < 0) + goto out; + + npolled += rc; + } + /* lastly, flush send and recv queues */ if (likely(!cq->flush)) goto out; @@ -1726,18 +1866,19 @@ qp->sq.spec = ionic_v1_use_spec_sge(max_sge, ctx->spec); - if (qp->sq.cmb & IONIC_CMB_EXPDB) { - wqe_size = ionic_v1_send_wqe_min_size(max_sge, max_data, - qp->sq.spec, true); + wqe_size = ionic_v1_send_wqe_min_size(max_sge, max_data, + qp->sq.spec, false); - if (!ionic_expdb_wqe_size_supported(ctx, wqe_size)) + if (qp->sq.cmb & IONIC_CMB_EXPDB) { + uint32_t expdb_size = ionic_v1_send_wqe_min_size(max_sge, max_data, + qp->sq.spec, true); + + if (ionic_expdb_wqe_size_supported(ctx, expdb_size)) + wqe_size = expdb_size; + else qp->sq.cmb &= ~IONIC_CMB_EXPDB; } - if (!(qp->sq.cmb & IONIC_CMB_EXPDB)) - wqe_size = ionic_v1_send_wqe_min_size(max_sge, max_data, - qp->sq.spec, false); - rc = ionic_queue_init(&qp->sq.queue, pd, IONIC_PD_TAG_SQ, ctx->pg_shift, max_wr, wqe_size); if (rc) @@ -1798,19 +1939,25 @@ if (max_sge > ionic_v1_recv_wqe_max_sge(ctx->max_stride, 0, false)) return EINVAL; - pd_tag = IONIC_PD_TAG_RQ; + if (qp->rcq) { + pd_tag = IONIC_PD_TAG_RCQ; + qp->rq.cmb = 0; + } else { + pd_tag = IONIC_PD_TAG_RQ; + } qp->rq.spec = ionic_v1_use_spec_sge(max_sge, ctx->spec); - if (qp->rq.cmb & IONIC_CMB_EXPDB) { - wqe_size = ionic_v1_recv_wqe_min_size(max_sge, qp->rq.spec, true); + wqe_size = ionic_v1_recv_wqe_min_size(max_sge, qp->rq.spec, false); - if (!ionic_expdb_wqe_size_supported(ctx, wqe_size)) + if (qp->rq.cmb & IONIC_CMB_EXPDB) { + uint32_t expdb_size = ionic_v1_recv_wqe_min_size(max_sge, qp->rq.spec, true); + + if (ionic_expdb_wqe_size_supported(ctx, expdb_size)) + wqe_size = expdb_size; + else qp->rq.cmb &= ~IONIC_CMB_EXPDB; } - if (!(qp->rq.cmb & IONIC_CMB_EXPDB)) - wqe_size = ionic_v1_recv_wqe_min_size(max_sge, qp->rq.spec, false); - rc = ionic_queue_init(&qp->rq.queue, pd, pd_tag, ctx->pg_shift, max_wr, wqe_size); if (rc) goto err_rq; @@ -2135,17 +2282,45 @@ ionic_wr_set(qp, 0, 0, NULL); } -static struct ibv_qp *ionic_create_qp_ex(struct ibv_context *ibctx, - struct ibv_qp_init_attr_ex *ex) +struct ibv_qp *ionic_create_qp_ex_common(struct ibv_context *ibctx, + struct ibv_qp_init_attr_ex *ex, + struct ionic_dv_qp_init_attr_ex *ionic_ex) { struct ionic_ctx *ctx = to_ionic_ctx(ibctx); struct ionic_pd *pd = to_ionic_pd(ex->pd); - struct uionic_qp_resp resp; - struct uionic_qp req; + struct uionic_qp_resp resp = {}; + struct uionic_qp req = {}; struct ionic_qp *qp; struct ionic_cq *cq; int rc; + if (ionic_ex) { + if (!check_comp_mask(ionic_ex->comp_mask, + IONIC_QP_SUPPORTED_INIT_ATTR_MASK)) { + rc = ENOTSUP; + goto err_qp; + } + + if (ionic_ex->comp_mask & IONIC_QP_INIT_ATTR_MASK_FLAGS) { + if (!ctx->ionic_flags_supported || + !check_comp_mask(ionic_ex->flags, + IONIC_QP_SUPPORTED_INIT_ATTR_FLAGS)) { + rc = ENOTSUP; + goto err_qp; + } + + if ((ionic_ex->flags & IONIC_QP_INIT_ATTR_RCCL_RCQ) && + !ctx->rcq_sign_bit) { + rc = EINVAL; + goto err_qp; + } + + rc = IONIC_SET_UDATA(ctx, &req, ionic_flags, ionic_ex->flags); + if (rc) + goto err_qp; + } + } + if ((ex->comp_mask & IONIC_QP_REQUIRED_COMP_MASK) != IONIC_QP_REQUIRED_COMP_MASK) { rc = ENOTSUP; @@ -2186,6 +2361,7 @@ qp->has_rq = true; qp->lockfree = ex->pd ? ionic_pd_lockfree(ex->pd) : false; qp->sig_all = ex->sq_sig_all; + qp->rcq = ctx->rcq_sign_bit && (req.ionic_flags & IONIC_QP_INIT_ATTR_RCCL_RCQ); list_node_init(&qp->cq_poll_sq); list_node_init(&qp->cq_poll_rq); @@ -2328,6 +2504,12 @@ return NULL; } +static struct ibv_qp *ionic_create_qp_ex(struct ibv_context *ibctx, + struct ibv_qp_init_attr_ex *ex) +{ + return ionic_create_qp_ex_common(ibctx, ex, NULL); +} + static void ionic_flush_qp(struct ionic_ctx *ctx, struct ionic_qp *qp) { struct ionic_cq *cq; @@ -3229,6 +3411,7 @@ wqe->base.wqe_idx = htole64(qp->rq.queue.prod); wqe->base.num_sge_key = wr->num_sge; + memset(&meta->rcqe, 0, sizeof(meta->rcqe)); qp->rq.meta_idx[qp->rq.queue.prod] = meta - qp->rq.meta; @@ -3386,7 +3569,7 @@ struct ibv_ah_attr *attr) { struct ibv_pd *root_ibpd = to_ionic_root_ibpd(ibpd); - struct uionic_ah_resp resp; + struct uionic_ah_resp resp = {}; struct ionic_ah *ah; int rc;
diff --git a/providers/ionic/libionic.map b/providers/ionic/libionic.map index 3efca32..be963d7 100644 --- a/providers/ionic/libionic.map +++ b/providers/ionic/libionic.map
@@ -10,3 +10,8 @@ ionic_dv_pd_set_rqcmb; local: *; }; + +IONIC_1.1 { + global: + ionic_dv_create_qp_ex; +} IONIC_1.0;
diff --git a/providers/ionic/man/CMakeLists.txt b/providers/ionic/man/CMakeLists.txt index 2827560..d2460e5 100644 --- a/providers/ionic/man/CMakeLists.txt +++ b/providers/ionic/man/CMakeLists.txt
@@ -1,5 +1,6 @@ rdma_man_pages( ionicdv.7.md + ionic_dv_create_qp_ex.3.md ionic_dv_ctx_get_udma_count.3.md ionic_dv_ctx_get_udma_mask.3.md ionic_dv_pd_get_udma_mask.3.md
diff --git a/providers/ionic/man/ionic_dv_create_qp_ex.3.md b/providers/ionic/man/ionic_dv_create_qp_ex.3.md new file mode 100644 index 0000000..b8f0883 --- /dev/null +++ b/providers/ionic/man/ionic_dv_create_qp_ex.3.md
@@ -0,0 +1,138 @@ +--- +layout: page +title: IONIC_DV_CREATE_QP_EX +section: 3 +tagline: Verbs +date: 2025-06-23 +header: "Ionic Programmer's Manual" +footer: ionic +--- + +# NAME + +ionic_dv_create_qp_ex - Create a queue pair with ionic-specific attributes + +# SYNOPSIS + +```c +#include <infiniband/ionic_dv.h> + +struct ibv_qp *ionic_dv_create_qp_ex(struct ibv_context *ibctx, + struct ibv_qp_init_attr_ex *ex, + struct ionic_dv_qp_init_attr_ex *ionic_ex); +``` + +# DESCRIPTION + +**ionic_dv_create_qp_ex()** creates a queue pair (QP) with ionic-specific +driver properties. It extends the standard **ibv_create_qp_ex**(3) interface +with ionic-specific attributes for configuring RCCL (RC Collective) +operations and Reorder Completion Queue (RCQ) behavior. + +The caller specifies **IBV_QPT_RC** as the QP type in the standard *ex* +attributes. The returned QP always has *qp_type* == **IBV_QPT_RC**. + +# ARGUMENTS + +Please see *ibv_create_qp_ex(3)* man page for *ibctx* and *ex*. + +## ionic_ex + +```c +enum ionic_qp_init_attr_mask { + IONIC_QP_INIT_ATTR_MASK_FLAGS = 1 << 0, +}; + +enum ionic_qp_init_attr_flags { + IONIC_QP_INIT_ATTR_RCCL = 1 << 16, + IONIC_QP_INIT_ATTR_RCCL_DATA = 1 << 17, + IONIC_QP_INIT_ATTR_RCCL_RDFENCE = 1 << 18, + IONIC_QP_INIT_ATTR_RCCL_RX_OFFLOAD = 1 << 19, + IONIC_QP_INIT_ATTR_RCCL_RCQ = 1 << 24, +}; + +struct ionic_dv_qp_init_attr_ex { + uint64_t comp_mask; + uint32_t flags; +}; +``` + +*comp_mask* +: Bitmask specifying what fields in the structure are valid. + Composed of **ionic_dv_qp_init_attr_mask** values: + + **IONIC_QP_INIT_ATTR_MASK_FLAGS**: + Valid values in *flags*. + +*flags* +: A bitwise OR of the various values described below. Valid when + *comp_mask* includes **IONIC_QP_INIT_ATTR_MASK_FLAGS**. + + **IONIC_QP_INIT_ATTR_RCCL**: + Create an RCCL (RC Collective) QP type. + + **IONIC_QP_INIT_ATTR_RCCL_DATA**: + Enable RCCL data operations on this QP. + + **IONIC_QP_INIT_ATTR_RCCL_RDFENCE**: + Enable RCCL read fence operations on this QP. + + **IONIC_QP_INIT_ATTR_RCCL_RX_OFFLOAD**: + Enable RCCL receive offload operations on this QP. + + **IONIC_QP_INIT_ATTR_RCCL_RCQ**: + Enable Reorder Completion Queue (RCQ) for this QP. When + enabled, out-of-order receive completions are reordered + so that completions are delivered to the application in + order. + +# RETURN VALUE + +**ionic_dv_create_qp_ex()** returns a pointer to the created QP, or NULL +if the request fails (in which case *errno* is set to indicate the error). + +# NOTES + +The *ex->qp_type* field must be **IBV_QPT_RC**. The returned QP always +exposes *qp_type* == **IBV_QPT_RC** to the application. + +Compatibility is handled through the *comp_mask* field. Applications +should only set bits for fields they intend to use. Unknown bits in +*comp_mask* are reserved for future extensions. + +# EXAMPLES + +```c +struct ibv_qp_init_attr_ex qp_attr = { + .send_cq = cq, + .recv_cq = cq, + .cap = { + .max_send_wr = 64, + .max_recv_wr = 64, + .max_send_sge = 4, + .max_recv_sge = 4, + }, + .qp_type = IBV_QPT_RC, + .comp_mask = IBV_QP_INIT_ATTR_PD, + .pd = pd, +}; + +struct ionic_dv_qp_init_attr_ex ionic_attr = { + .comp_mask = IONIC_QP_INIT_ATTR_MASK_FLAGS, + .flags = IONIC_QP_INIT_ATTR_RCCL_RCQ, +}; + +struct ibv_qp *qp = ionic_dv_create_qp_ex(ctx, &qp_attr, &ionic_attr); +``` + +# SEE ALSO + +**ionicdv**(7), +**ibv_create_qp_ex**(3), +**ionic_dv_pd_set_udma_mask**(3), +**ionic_dv_pd_set_sqcmb**(3), +**ionic_dv_pd_set_rqcmb**(3) + +# AUTHORS + +Advanced Micro Devices, Inc.
diff --git a/providers/ionic/man/ionicdv.7.md b/providers/ionic/man/ionicdv.7.md index faf8006..4972f14 100644 --- a/providers/ionic/man/ionicdv.7.md +++ b/providers/ionic/man/ionicdv.7.md
@@ -45,8 +45,19 @@ **ionic_dv_pd_set_rqcmb**(3) to configure CMB preferences on a protection domain before creating queues. +## RCCL and RCQ + +Ionic devices support passing RCCL (RC Collective) flags and Reorder +Completion Queue (RCQ) selection from userspace to firmware at QP creation +time. RCCL flags control data, read fence, and receive offload capabilities +on RC queue pairs. RCQ reorders out-of-order receive completions so that +they are delivered to the application in order. Use +**ionic_dv_create_qp_ex**(3) to create a QP with these ionic-specific +attributes. + # SEE ALSO +**ionic_dv_create_qp_ex**(3), **ionic_dv_ctx_get_udma_count**(3), **ionic_dv_ctx_get_udma_mask**(3), **ionic_dv_pd_get_udma_mask**(3),
diff --git a/providers/irdma/defs.h b/providers/irdma/defs.h index fa522b7..1f4e6d6 100644 --- a/providers/irdma/defs.h +++ b/providers/irdma/defs.h
@@ -114,7 +114,7 @@ #define IRDMAQPSQ_REMSTAGINV GENMASK_ULL(31, 0) #define IRDMAQPSQ_DESTQKEY GENMASK_ULL(31, 0) #define IRDMAQPSQ_DESTQPN GENMASK_ULL(55, 32) -#define IRDMAQPSQ_AHID GENMASK_ULL(16, 0) +#define IRDMAQPSQ_AHID GENMASK_ULL(24, 0) #define IRDMAQPSQ_INLINEDATAFLAG BIT_ULL(57) #define IRDMA_INLINE_VALID_S 7
diff --git a/providers/irdma/osdep.h b/providers/irdma/osdep.h index c9ca5e0..0aa0c99 100644 --- a/providers/irdma/osdep.h +++ b/providers/irdma/osdep.h
@@ -15,10 +15,6 @@ #include <inttypes.h> #include <pthread.h> #include <endian.h> +#include <util/mmio.h> #include <infiniband/verbs.h> - -static inline void db_wr32(__u32 val, __u32 *wqe_word) -{ - *wqe_word = val; -} #endif /* IRDMA_OSDEP_H */
diff --git a/providers/irdma/uk.c b/providers/irdma/uk.c index 85eb735..571ccea 100644 --- a/providers/irdma/uk.c +++ b/providers/irdma/uk.c
@@ -117,7 +117,7 @@ /* valid bit is written before ringing doorbell */ udma_to_device_barrier(); - db_wr32(qp->qp_id, qp->wqe_alloc_db); + mmio_write32(qp->wqe_alloc_db, qp->qp_id); qp->initial_ring.head = qp->sq_ring.head; } @@ -209,6 +209,7 @@ qp->sq_wrtrk_array[*wqe_idx].wrid = info->wr_id; qp->sq_wrtrk_array[*wqe_idx].wr_len = total_size; qp->sq_wrtrk_array[*wqe_idx].quanta = quanta; + qp->sq_wrtrk_array[*wqe_idx].signaled = info->signaled; return wqe; } @@ -1252,7 +1253,7 @@ udma_to_device_barrier(); /* make sure WQE is populated before valid bit is set */ - db_wr32(cq->cq_id, cq->cqe_alloc_db); + mmio_write32(cq->cqe_alloc_db, cq->cq_id); } /** @@ -1481,6 +1482,10 @@ info->wr_id = qp->sq_wrtrk_array[wqe_idx].wrid; if (!info->comp_status) info->bytes_xfered = qp->sq_wrtrk_array[wqe_idx].wr_len; + if (!qp->sq_wrtrk_array[wqe_idx].signaled) { + ret_code = EFAULT; + goto exit; + } info->op_type = (__u8)FIELD_GET(IRDMACQ_OP, qword3); IRDMA_RING_SET_TAIL(qp->sq_ring, wqe_idx + qp->sq_wrtrk_array[wqe_idx].quanta); @@ -1508,6 +1513,10 @@ break; } } while (1); + + if (info->op_type == IRDMA_OP_TYPE_BIND_MW && + info->minor_err == FLUSH_PROT_ERR) + info->minor_err = FLUSH_MW_BIND_ERR; qp->sq_flush_seen = true; if (!IRDMA_RING_MORE_WORK(qp->sq_ring)) qp->sq_flush_complete = true; @@ -1887,6 +1896,9 @@ if (polarity != temp) break; + /* Ensure CQE contents are read after valid bit is checked */ + udma_from_device_barrier(); + get_64bit_val(cqe, 8, &comp_ctx); if ((void *)(uintptr_t)comp_ctx == q) set_64bit_val(cqe, 8, 0);
diff --git a/providers/irdma/user.h b/providers/irdma/user.h index 7460743..9882907 100644 --- a/providers/irdma/user.h +++ b/providers/irdma/user.h
@@ -488,7 +488,8 @@ __u64 wrid; __u32 wr_len; __u16 quanta; - __u8 reserved[2]; + __u8 signaled; + __u8 reserved[1]; }; struct irdma_qp_quanta {
diff --git a/providers/irdma/uverbs.c b/providers/irdma/uverbs.c index 3d1c136..55cf086 100644 --- a/providers/irdma/uverbs.c +++ b/providers/irdma/uverbs.c
@@ -1559,6 +1559,12 @@ info.max_rq_frag_cnt = attr->cap.max_recv_sge; info.max_inline_data = attr->cap.max_inline_data; info.abi_ver = iwvctx->abi_ver; + if (uk_attrs->hw_rev >= IRDMA_GEN_3) { + if (attr->qp_type == IBV_QPT_UD) + info.type = IRDMA_QP_TYPE_ROCE_UD; + else + info.type = IRDMA_QP_TYPE_ROCE_RC; + } status = irdma_uk_calc_depth_shift_sq(&info, &info.sq_depth, &info.sq_shift); if (status) { @@ -1946,7 +1952,10 @@ err = irdma_uk_rdma_read(&iwuqp->qp, &info, false, false); break; case IBV_WR_BIND_MW: - if (ib_qp->qp_type != IBV_QPT_RC) { + if (ib_qp->qp_type != IBV_QPT_RC || + (ib_wr->bind_mw.mw->type == IBV_MW_TYPE_1 && + ib_wr->bind_mw.bind_info.mw_access_flags & + IBV_ACCESS_ZERO_BASED)) { err = EINVAL; break; }
diff --git a/providers/mana/gdma.h b/providers/mana/gdma.h index 1f797c7..0c1dd83 100644 --- a/providers/mana/gdma.h +++ b/providers/mana/gdma.h
@@ -68,7 +68,7 @@ struct rdma_recv_oob { uint32_t psn_start:24; uint32_t reserved1:8; - uint32_t psn_range:24; + uint32_t msn:24; uint32_t reserved2:8; }; /* HW DATA */
diff --git a/providers/mana/mana.h b/providers/mana/mana.h index f629206..b4496cc 100644 --- a/providers/mana/mana.h +++ b/providers/mana/mana.h
@@ -18,6 +18,7 @@ #define INLINE_OOB_SMALL_SIZE 8 #define INLINE_OOB_LARGE_SIZE 24 +#define INLINE_OOB_EXTRA_LARGE_SIZE 32 #define GDMA_WQE_ALIGNMENT_UNIT_SIZE 32 @@ -73,9 +74,21 @@ return align(wqe_size, GDMA_WQE_ALIGNMENT_UNIT_SIZE); } -static inline uint32_t get_large_wqe_size(uint32_t sge) +static inline uint32_t get_large_fixed_wqe_size(uint32_t sge) { - uint32_t wqe_size = sge * SGE_SIZE + DMA_OOB_SIZE + INLINE_OOB_LARGE_SIZE; + uint32_t wqe_size = sge * SGE_SIZE + DMA_OOB_SIZE + INLINE_OOB_EXTRA_LARGE_SIZE; + + return roundup_pow_of_two(wqe_size); +} + +static inline uint32_t get_large_wqe_size(uint32_t sge, uint32_t wqe_size_in_bu) +{ + uint32_t wqe_size; + + if (wqe_size_in_bu) + return wqe_size_in_bu * GDMA_WQE_ALIGNMENT_UNIT_SIZE; + + wqe_size = sge * SGE_SIZE + DMA_OOB_SIZE + INLINE_OOB_LARGE_SIZE; return align(wqe_size, GDMA_WQE_ALIGNMENT_UNIT_SIZE); } @@ -108,6 +121,7 @@ uint32_t size; uint32_t prod_idx; uint32_t cons_idx; + uint8_t wqe_size_in_bu; void *db_page; void *buffer;
diff --git a/providers/mana/qp.c b/providers/mana/qp.c index 940c075..207d79d 100644 --- a/providers/mana/qp.c +++ b/providers/mana/qp.c
@@ -223,17 +223,17 @@ switch (type) { case USER_RNIC_SEND_QUEUE_REQUESTER: /* WQE must have at least one SGE */ - /* For write with imm we need one extra SGE */ - sges = max(1U, attr->cap.max_send_sge) + 1; - size = align_hw_size(attr->cap.max_send_wr * get_large_wqe_size(sges)); + sges = max(1U, attr->cap.max_send_sge); + size = align_hw_size(attr->cap.max_send_wr * get_large_fixed_wqe_size(sges)); break; case USER_RNIC_SEND_QUEUE_RESPONDER: if (attr->qp_type == IBV_QPT_RC) size = align_hw_size(MANA_PAGE_SIZE); break; case USER_RNIC_RECV_QUEUE_REQUESTER: + sges = max(1U, attr->cap.max_send_sge); if (attr->qp_type == IBV_QPT_RC) - size = align_hw_size(MANA_PAGE_SIZE); + size = align_hw_size(attr->cap.max_send_wr * get_wqe_size(sges)); break; case USER_RNIC_RECV_QUEUE_RESPONDER: /* WQE must have at least one SGE */ @@ -241,8 +241,8 @@ size = align_hw_size(attr->cap.max_recv_wr * get_wqe_size(sges)); break; case USER_RNIC_SEND_QUEUE_MM: - sges = 2; - size = align_hw_size(attr->cap.max_send_wr * get_large_wqe_size(sges)); + sges = 1; + size = align_hw_size(attr->cap.max_send_wr * get_large_fixed_wqe_size(sges)); break; default: return 0; @@ -257,6 +257,7 @@ static int mana_create_cmd_qp_rc(struct mana_qp *qp, struct ibv_pd *ibpd, struct ibv_qp_init_attr *attr) { + struct mana_context *ctx = to_mctx(ibpd->context); struct mana_ib_create_rc_qp_resp *qp_resp_drv; struct mana_create_rc_qp_resp qp_resp = {}; struct mana_ib_create_rc_qp *qp_cmd_drv; @@ -273,6 +274,13 @@ qp_cmd_drv->queue_size[i] = qp->rnic_qp.queues[i].size; } + if (ctx->comp_mask & MANA_IB_UCNTX_RC_EXT_SUPPORT) { + qp_cmd_drv->comp_mask |= MANA_IB_RC_QP_FIXED_WQE | MANA_IB_RC_MMQ_CREATE; + qp_cmd_drv->mmq_buf = + (uintptr_t)qp->rnic_qp.queues[USER_RNIC_SEND_QUEUE_MM].buffer; + qp_cmd_drv->mmq_size = qp->rnic_qp.queues[USER_RNIC_SEND_QUEUE_MM].size; + } + ret = ibv_cmd_create_qp(ibpd, &qp->ibqp.qp, attr, &qp_cmd.ibv_cmd, sizeof(qp_cmd), &qp_resp.ibv_resp, sizeof(qp_resp)); @@ -287,6 +295,8 @@ qp->rnic_qp.queues[i].id = qp_resp_drv->queue_id[i]; } + qp->rnic_qp.queues[USER_RNIC_SEND_QUEUE_MM].id = qp_resp_drv->mmq_id; + return 0; } @@ -356,6 +366,7 @@ struct ibv_qp_init_attr *attr) { struct mana_context *ctx = to_mctx(ibpd->context); + uint8_t wqe_size_in_bu; struct mana_qp *qp; int ret, i; @@ -399,6 +410,10 @@ } } + wqe_size_in_bu = get_large_fixed_wqe_size(max(1U, attr->cap.max_send_sge)) + / GDMA_WQE_ALIGNMENT_UNIT_SIZE; + qp->rnic_qp.queues[USER_RNIC_SEND_QUEUE_REQUESTER].wqe_size_in_bu = wqe_size_in_bu; + ret = mana_create_cmd_qp(qp, ibpd, attr); if (ret) { errno = ret;
diff --git a/providers/mana/wr.c b/providers/mana/wr.c index e4d7c38..3ea3941 100644 --- a/providers/mana/wr.c +++ b/providers/mana/wr.c
@@ -249,7 +249,7 @@ } total_sge = num_sge + (oob_sge ? 1 : 0); - wqe_size = get_large_wqe_size(total_sge); + wqe_size = get_large_wqe_size(total_sge, wq->wqe_size_in_bu); ret = gdma_get_current_wqe(wq, INLINE_OOB_LARGE_SIZE, wqe_size, wqe); if (ret) @@ -299,6 +299,7 @@ struct rdma_recv_oob recv_oob = {0}; recv_oob.psn_start = qp->sq_psn; + recv_oob.msn = qp->sq_ssn; ret = gdma_post_rq_wqe(mana_ib_get_rreq(qp), wr->sg_list, &recv_oob, num_sge, GDMA_WORK_REQ_CHECK_SN, &gdma_wqe); if (ret) {
diff --git a/providers/mlx5/dr_ste.c b/providers/mlx5/dr_ste.c index 4f88a4f..8f0ea56 100644 --- a/providers/mlx5/dr_ste.c +++ b/providers/mlx5/dr_ste.c
@@ -1148,12 +1148,13 @@ uint64_t *mask_buf, size_t mask_sz, bool clear) { uint8_t *data = (uint8_t *)mask_buf; - char tail_param[DEVX_ST_SZ_BYTES(dr_match_param)] = {}; + char tail_param[DEVX_ST_SZ_BYTES(dr_match_param)]; size_t param_location; void *buff; - if (match_criteria & DR_MATCHER_CRITERIA_OUTER) { + if ((match_criteria & DR_MATCHER_CRITERIA_OUTER) && mask_sz) { if (mask_sz < DEVX_ST_SZ_BYTES(dr_match_spec)) { + memset(tail_param, 0, sizeof(tail_param)); memcpy(tail_param, data, mask_sz); buff = tail_param; } else { @@ -1163,79 +1164,91 @@ } param_location = DEVX_ST_SZ_BYTES(dr_match_spec); - if (match_criteria & DR_MATCHER_CRITERIA_MISC) { - if (mask_sz < param_location + - DEVX_ST_SZ_BYTES(dr_match_set_misc)) { + if ((match_criteria & DR_MATCHER_CRITERIA_MISC) && + (mask_sz > param_location)) { + if (mask_sz >= + param_location + DEVX_ST_SZ_BYTES(dr_match_set_misc)) { + buff = data + param_location; + } else { + memset(tail_param, 0, sizeof(tail_param)); memcpy(tail_param, data + param_location, mask_sz - param_location); buff = tail_param; - } else { - buff = data + param_location; } dr_ste_copy_mask_misc(buff, &set_param->misc, clear); } param_location += DEVX_ST_SZ_BYTES(dr_match_set_misc); - if (match_criteria & DR_MATCHER_CRITERIA_INNER) { - if (mask_sz < param_location + - DEVX_ST_SZ_BYTES(dr_match_spec)) { + if ((match_criteria & DR_MATCHER_CRITERIA_INNER) && + (mask_sz > param_location)) { + if (mask_sz >= + param_location + DEVX_ST_SZ_BYTES(dr_match_spec)) { + buff = data + param_location; + } else { + memset(tail_param, 0, sizeof(tail_param)); memcpy(tail_param, data + param_location, mask_sz - param_location); buff = tail_param; - } else { - buff = data + param_location; } dr_ste_copy_mask_spec(buff, &set_param->inner, clear); } param_location += DEVX_ST_SZ_BYTES(dr_match_spec); - if (match_criteria & DR_MATCHER_CRITERIA_MISC2) { - if (mask_sz < param_location + - DEVX_ST_SZ_BYTES(dr_match_set_misc2)) { + if ((match_criteria & DR_MATCHER_CRITERIA_MISC2) && + (mask_sz > param_location)) { + if (mask_sz >= + param_location + DEVX_ST_SZ_BYTES(dr_match_set_misc2)) { + buff = data + param_location; + } else { + memset(tail_param, 0, sizeof(tail_param)); memcpy(tail_param, data + param_location, mask_sz - param_location); buff = tail_param; - } else { - buff = data + param_location; } dr_ste_copy_mask_misc2(buff, &set_param->misc2, clear); } param_location += DEVX_ST_SZ_BYTES(dr_match_set_misc2); - if (match_criteria & DR_MATCHER_CRITERIA_MISC3) { - if (mask_sz < param_location + - DEVX_ST_SZ_BYTES(dr_match_set_misc3)) { + if ((match_criteria & DR_MATCHER_CRITERIA_MISC3) && + (mask_sz > param_location)) { + if (mask_sz >= + param_location + DEVX_ST_SZ_BYTES(dr_match_set_misc3)) { + buff = data + param_location; + } else { + memset(tail_param, 0, sizeof(tail_param)); memcpy(tail_param, data + param_location, mask_sz - param_location); buff = tail_param; - } else { - buff = data + param_location; } dr_ste_copy_mask_misc3(buff, &set_param->misc3, clear); } param_location += DEVX_ST_SZ_BYTES(dr_match_set_misc3); - if (match_criteria & DR_MATCHER_CRITERIA_MISC4) { - if (mask_sz < param_location + - DEVX_ST_SZ_BYTES(dr_match_set_misc4)) { + if ((match_criteria & DR_MATCHER_CRITERIA_MISC4) && + (mask_sz > param_location)) { + if (mask_sz >= + param_location + DEVX_ST_SZ_BYTES(dr_match_set_misc4)) { + buff = data + param_location; + } else { + memset(tail_param, 0, sizeof(tail_param)); memcpy(tail_param, data + param_location, mask_sz - param_location); buff = tail_param; - } else { - buff = data + param_location; } dr_ste_copy_mask_misc4(buff, &set_param->misc4, clear); } param_location += DEVX_ST_SZ_BYTES(dr_match_set_misc4); - if (match_criteria & DR_MATCHER_CRITERIA_MISC5) { - if (mask_sz < param_location + - DEVX_ST_SZ_BYTES(dr_match_set_misc5)) { + if ((match_criteria & DR_MATCHER_CRITERIA_MISC5) && + (mask_sz > param_location)) { + if (mask_sz >= + param_location + DEVX_ST_SZ_BYTES(dr_match_set_misc5)) { + buff = data + param_location; + } else { + memset(tail_param, 0, sizeof(tail_param)); memcpy(tail_param, data + param_location, mask_sz - param_location); buff = tail_param; - } else { - buff = data + param_location; } dr_ste_copy_mask_misc5(buff, &set_param->misc5, clear); }
diff --git a/providers/mlx5/qp.c b/providers/mlx5/qp.c index b28273c..5e32589 100644 --- a/providers/mlx5/qp.c +++ b/providers/mlx5/qp.c
@@ -330,9 +330,9 @@ { struct mlx5_wqe_inline_seg *seg; void *addr; - int len; + uint32_t len; int i; - int inl = 0; + uint64_t inl = 0; void *qend = qp->sq.qend; int copy; int offset = sg_copy_ptr->offset;
diff --git a/providers/rxe/man/rxe.7 b/providers/rxe/man/rxe.7 index 474ffff..32495ed 100644 --- a/providers/rxe/man/rxe.7 +++ b/providers/rxe/man/rxe.7
@@ -24,10 +24,6 @@ Directory that holds RDMA device information. The format is the same as other RDMA devices. .TP -\fB/sys/module/rdma_rxe_net/parameters/mtu\fR -Write only file used to configure RoCE and Ethernet MTU values. - -.TP \fB/sys/module/rdma_rxe/parameters/max_ucontext\fR Read/Write file that sets a limit on the number of UCs allowed per RXE device.
diff --git a/redhat/rdma-core.spec b/redhat/rdma-core.spec index 0cada7f..d69fcde 100644 --- a/redhat/rdma-core.spec +++ b/redhat/rdma-core.spec
@@ -1,5 +1,5 @@ Name: rdma-core -Version: 66.0 +Version: 67.0 Release: 1%{?dist} Summary: RDMA core userspace libraries and daemons @@ -150,6 +150,8 @@ Summary: A library and drivers for direct userspace use of RDMA (InfiniBand/iWARP/RoCE) hardware Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig +Provides: libbnxt_re = %{version}-%{release} +Obsoletes: libbnxt_re < %{version}-%{release} Provides: libcxgb4 = %{version}-%{release} Obsoletes: libcxgb4 < %{version}-%{release} Provides: libefa = %{version}-%{release} @@ -466,6 +468,7 @@ %endif %{_libdir}/lib*.so %{_libdir}/pkgconfig/*.pc +%{_mandir}/man3/bnxt_re_dv* %{_mandir}/man3/efadv* %{_mandir}/man3/hnsdv* %{_mandir}/man3/ibv_* @@ -478,6 +481,7 @@ %{_mandir}/man3/manadv* %{_mandir}/man3/mlx5dv* %{_mandir}/man3/mlx4dv* +%{_mandir}/man7/bnxt_re_dv* %{_mandir}/man7/efadv* %{_mandir}/man7/hnsdv* %{_mandir}/man7/ionicdv* @@ -598,6 +602,7 @@ %files -n libibverbs %dir %{_sysconfdir}/libibverbs.d %dir %{_libdir}/libibverbs +%{_libdir}/libbnxt_re.so.* %{_libdir}/libefa.so.* %{_libdir}/libhns.so.* %{_libdir}/libibverbs*.so.* @@ -608,7 +613,7 @@ %{_libdir}/libmlx4.so.* %config(noreplace) %{_sysconfdir}/libibverbs.d/*.driver %doc %{_docdir}/%{name}/libibverbs.md -%{_prefix}/lib/sysusers.d/rdma.conf +%{_sysusersdir}/rdma.conf %files -n libibverbs-utils %{_bindir}/ibv_*
diff --git a/srp_daemon/srp_daemon_port@.service.in b/srp_daemon/srp_daemon_port@.service.in index 3d5a11e..7789598 100644 --- a/srp_daemon/srp_daemon_port@.service.in +++ b/srp_daemon/srp_daemon_port@.service.in
@@ -25,7 +25,7 @@ Type=simple ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/srp_daemon --systemd -e -c -n -j %I -R 60 MemoryDenyWriteExecute=yes -PrivateNetwork=yes +PrivateNetwork=no PrivateTmp=yes ProtectControlGroups=yes ProtectHome=yes
diff --git a/suse/rdma-core.spec b/suse/rdma-core.spec index 9a57aae..8d9b4b6 100644 --- a/suse/rdma-core.spec +++ b/suse/rdma-core.spec
@@ -28,7 +28,7 @@ %define git_ver %{nil} Name: rdma-core -Version: 66.0 +Version: 67.0 Release: 0 Summary: RDMA core userspace libraries and daemons License: BSD-2-Clause OR GPL-2.0-only @@ -46,6 +46,8 @@ %define ibnetdisc_major 5 %define mad_major 5 +%define bnxt_re_so_major 1 +%define bnxt_re_lname libbnxt_re%{bnxt_re_so_major} %define efa_lname libefa%{efa_so_major} %define hns_lname libhns%{hns_so_major} %define ionic_lname libionic%{ionic_so_major} @@ -163,6 +165,7 @@ Requires: %{umad_lname} = %{version}-%{release} Requires: %{verbs_lname} = %{version}-%{release} %if 0%{?dma_coherent} +Requires: %{bnxt_re_lname} = %{version}-%{release} Requires: %{efa_lname} = %{version}-%{release} Requires: %{hns_lname} = %{version}-%{release} Requires: %{ionic_lname} = %{version}-%{release} @@ -216,6 +219,7 @@ Obsoletes: libocrdma-rdmav2 < %{version}-%{release} Obsoletes: librxe-rdmav2 < %{version}-%{release} %if 0%{?dma_coherent} +Requires: %{bnxt_re_lname} = %{version}-%{release} Requires: %{efa_lname} = %{version}-%{release} Requires: %{hns_lname} = %{version}-%{release} Requires: %{ionic_lname} = %{version}-%{release} @@ -260,6 +264,13 @@ %description -n %verbs_lname This package contains the ibverbs runtime library. +%package -n %bnxt_re_lname +Summary: BNXT_RE runtime library +Group: System/Libraries + +%description -n %bnxt_re_lname +This package contains the bnxt_re runtime library. + %package -n %efa_lname Summary: EFA runtime library Group: System/Libraries @@ -377,7 +388,6 @@ %package -n %rdmacm_lname Summary: Userspace RDMA Connection Manager Group: System/Libraries -Requires: %{name} = %{version} Provides: librdmacm = %{version} Obsoletes: librdmacm < %{version} @@ -530,6 +540,7 @@ rm -rf %{buildroot}/%{_sbindir}/srp_daemon.sh %ldconfig_scriptlets -n %verbs_lname +%ldconfig_scriptlets -n %bnxt_re_lname %ldconfig_scriptlets -n %efa_lname %ldconfig_scriptlets -n %hns_lname %ldconfig_scriptlets -n %ionic_lname @@ -684,12 +695,14 @@ %{_mandir}/man3/*_to_ibv_rate.* %{_mandir}/man7/rdma_cm.* %if 0%{?dma_coherent} +%{_mandir}/man3/bnxt_re_dv* %{_mandir}/man3/efadv* %{_mandir}/man3/hnsdv* %{_mandir}/man3/ionic_dv* %{_mandir}/man3/manadv* %{_mandir}/man3/mlx5dv* %{_mandir}/man3/mlx4dv* +%{_mandir}/man7/bnxt_re_dv* %{_mandir}/man7/efadv* %{_mandir}/man7/hnsdv* %{_mandir}/man7/ionicdv* @@ -719,6 +732,9 @@ %{_libdir}/libibverbs*.so.* %if 0%{?dma_coherent} +%files -n %bnxt_re_lname +%{_libdir}/libbnxt_re*.so.* + %files -n %efa_lname %{_libdir}/libefa*.so.*
diff --git a/tests/run_tests.py b/tests/run_tests.py index 9d7edf2..318d152 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py
@@ -3,12 +3,16 @@ # Copyright (c) 2018, Mellanox Technologies. All rights reserved. See COPYING file from args_parser import parser +import importlib.util import unittest +import sys import os -from importlib.machinery import SourceFileLoader module_path = os.path.join(os.path.dirname(__file__), '__init__.py') -tests = SourceFileLoader('tests', module_path).load_module() +spec = importlib.util.spec_from_file_location('tests', module_path) +tests = importlib.util.module_from_spec(spec) +sys.modules['tests'] = tests +spec.loader.exec_module(tests) parser.parse_args() unittest.main(module=tests)
diff --git a/util/mmio.h b/util/mmio.h index df705de..fa12858 100644 --- a/util/mmio.h +++ b/util/mmio.h
@@ -258,7 +258,7 @@ #define mmio_memcpy_x64(dest, src, bytecount) \ ({ \ - if (__builtin_constant_p((bytecount) == 64)) \ + if (__builtin_constant_p(bytecount) && (bytecount) == 64) \ _mmio_memcpy_x64_64b((dest), (src)); \ else \ _mmio_memcpy_x64((dest), (src), (bytecount)); \
diff --git a/util/open_cdev.c b/util/open_cdev.c index a6c081a..325c47d 100644 --- a/util/open_cdev.c +++ b/util/open_cdev.c
@@ -30,6 +30,7 @@ * SOFTWARE. */ #define _GNU_SOURCE +#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> @@ -55,6 +56,7 @@ if (fstat(fd, &st) || !S_ISCHR(st.st_mode) || (cdev != 0 && st.st_rdev != cdev)) { close(fd); + errno = ENOENT; return -1; } return fd; @@ -134,13 +136,22 @@ int open_cdev(const char *devname_hint, dev_t cdev) { char *devpath; - int fd; + int fd, err; if (asprintf(&devpath, RDMA_CDEV_DIR "/%s", devname_hint) < 0) return -1; + errno = 0; fd = open_cdev_internal(devpath, cdev); + err = errno; free(devpath); - if (fd == -1 && cdev != 0) - return open_cdev_robust(devname_hint, cdev); + if (fd == -1 && cdev != 0 && err == ENOENT) { + fd = open_cdev_robust(devname_hint, cdev); + /* + * Report why the node could not be opened, not why the + * fallback failed. + */ + if (fd == -1) + errno = err; + } return fd; }