As explained in this paper ASPLOS'22 The benefits of general-purpose on-NIC memory
You can see the code in the artifact at: https://github.com/BorisPis/nicmem-asplos22-artifact
In essence, there's an API exposed in upstream rdma-core's libibverbs that exposes it, and you can see the dpdk patches for an example.