lib/nvmf/vfio_user.c
/*
 * Handles a write at offset 0x1000 or more; this is the non-mapped path when a
 * doorbell is written via access_bar0_fn().
 *
 * DSTRD is set to fixed value 0 for NVMf.
 *
 */
Handles a write at offset 0x1000 or more; this is the non-mapped path when a
doorbell is written via access_bar0_fn().

DSTRD is set to fixed value 0 for NVMf.
Handles a write at offset 0x1000 or more ; this is the non - mapped path when a doorbell is written via access_bar0_fn () . DSTRD is set to fixed value 0 for NVMf .
static int
handle_dbl_access(struct nvmf_vfio_user_ctrlr *ctrlr, uint32_t *buf,
		  const size_t count, loff_t pos, const bool is_write)
{
	assert(ctrlr != NULL);
	assert(buf != NULL);
	if (count != sizeof(uint32_t)) {
		SPDK_ERRLOG("%s: bad doorbell buffer size %ld\n",
			    ctrlr_id(ctrlr), count);
		errno = EINVAL;
		return -1;
	}
	pos -= NVMF_VFIO_USER_DOORBELLS_OFFSET;
	if ((pos & 0x3) != 0) {
		SPDK_ERRLOG("%s: bad doorbell offset %#lx\n", ctrlr_id(ctrlr), pos);
		errno = EINVAL;
		return -1;
	}
	pos >>= 2;
	if (pos >= NVMF_VFIO_USER_DEFAULT_MAX_QPAIRS_PER_CTRLR * 2) {
		SPDK_ERRLOG("%s: bad doorbell index %#lx\n", ctrlr_id(ctrlr), pos);
		errno = EINVAL;
		return -1;
	}
	if (is_write) {
		ctrlr->doorbells[pos] = *buf;
		spdk_wmb();
	} else {
		spdk_rmb();
		*buf = ctrlr->doorbells[pos];
	}
	return 0;
}
static int handle_dbl_access ( struct nvmf_vfio_user_ctrlr * ctrlr , uint32_t * buf , const size_t count , loff_t pos , const bool is_write ) { assert ( ctrlr != NULL ) ; assert ( buf != NULL ) ; if ( count != sizeof ( uint32_t ) ) { SPDK_ERRLOG ( " \n " , ctrlr_id ( ctrlr ) , count ) ; errno = EINVAL ; return -1 ; } pos -= NVMF_VFIO_USER_DOORBELLS_OFFSET ; if ( ( pos & 0x3 ) != 0 ) { SPDK_ERRLOG ( " \n " , ctrlr_id ( ctrlr ) , pos ) ; errno = EINVAL ; return -1 ; } pos >>= 2 ; if ( pos >= NVMF_VFIO_USER_DEFAULT_MAX_QPAIRS_PER_CTRLR * 2 ) { SPDK_ERRLOG ( " \n " , ctrlr_id ( ctrlr ) , pos ) ; errno = EINVAL ; return -1 ; } if ( is_write ) { ctrlr -> doorbells [ pos ] = * buf ; spdk_wmb ( ) ; } else { spdk_rmb ( ) ; * buf = ctrlr -> doorbells [ pos ] ; } return 0 ; }
Handles a write at offset 0x1000 or more; this is the non-mapped path when a
 doorbell is written via access_bar0_fn().
Handles a write at offset 0x1000 or more ; this is the non - mapped path when a doorbell is written via access_bar0_fn () .
/* pos must be dword aligned */ /* convert byte offset to array index */