[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 12/15] hw/nvme: Initialize capability structures for prima
From: |
Klaus Jensen |
Subject: |
Re: [PATCH v4 12/15] hw/nvme: Initialize capability structures for primary/secondary controllers |
Date: |
Fri, 11 Feb 2022 08:47:59 +0100 |
On Jan 26 18:11, Lukasz Maniak wrote:
> From: Łukasz Gieryk <lukasz.gieryk@linux.intel.com>
>
> With four new properties:
> - sriov_v{i,q}_flexible,
> - sriov_max_v{i,q}_per_vf,
> one can configure the number of available flexible resources, as well as
> the limits. The primary and secondary controller capability structures
> are initialized accordingly.
>
> Since the number of available queues (interrupts) now varies between
> VF/PF, BAR size calculation is also adjusted.
>
> Signed-off-by: Łukasz Gieryk <lukasz.gieryk@linux.intel.com>
> ---
> hw/nvme/ctrl.c | 142 ++++++++++++++++++++++++++++++++++++++++---
> hw/nvme/nvme.h | 4 ++
> include/block/nvme.h | 5 ++
> 3 files changed, 144 insertions(+), 7 deletions(-)
>
> diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> index e101cb7d7c..551c8795f2 100644
> --- a/hw/nvme/ctrl.c
> +++ b/hw/nvme/ctrl.c
> @@ -6379,14 +6464,41 @@ static void nvme_init_state(NvmeCtrl *n)
> n->starttime_ms = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL);
> n->aer_reqs = g_new0(NvmeRequest *, n->params.aerl + 1);
>
> - list->numcntl = cpu_to_le16(n->params.sriov_max_vfs);
> - for (i = 0; i < n->params.sriov_max_vfs; i++) {
> + list->numcntl = cpu_to_le16(max_vfs);
> + for (i = 0; i < max_vfs; i++) {
> sctrl = &list->sec[i];
> sctrl->pcid = cpu_to_le16(n->cntlid);
> sctrl->vfn = cpu_to_le16(i + 1);
> }
>
> cap->cntlid = cpu_to_le16(n->cntlid);
> + cap->crt = NVME_CRT_VQ | NVME_CRT_VI;
> +
> + if (pci_is_vf(&n->parent_obj)) {
> + cap->vqprt = cpu_to_le16(1 + n->conf_ioqpairs);
> + } else {
> + cap->vqprt = cpu_to_le16(1 + n->params.max_ioqpairs -
> + n->params.sriov_vq_flexible);
> + cap->vqfrt = cpu_to_le32(n->params.sriov_vq_flexible);
> + cap->vqrfap = cap->vqfrt;
> + cap->vqgran = cpu_to_le16(NVME_VF_RES_GRANULARITY);
> + cap->vqfrsm = n->params.sriov_max_vq_per_vf ?
> + cpu_to_le16(n->params.sriov_max_vq_per_vf) :
> + cap->vqfrt / n->params.sriov_max_vfs;
Getting a division by zero on non-sriov enabled controllers here.
> + }
> +
> + if (pci_is_vf(&n->parent_obj)) {
> + cap->viprt = cpu_to_le16(n->conf_msix_qsize);
> + } else {
> + cap->viprt = cpu_to_le16(n->params.msix_qsize -
> + n->params.sriov_vi_flexible);
> + cap->vifrt = cpu_to_le32(n->params.sriov_vi_flexible);
> + cap->virfap = cap->vifrt;
> + cap->vigran = cpu_to_le16(NVME_VF_RES_GRANULARITY);
> + cap->vifrsm = n->params.sriov_max_vi_per_vf ?
> + cpu_to_le16(n->params.sriov_max_vi_per_vf) :
> + cap->vifrt / n->params.sriov_max_vfs;
Same here.
signature.asc
Description: PGP signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH v4 12/15] hw/nvme: Initialize capability structures for primary/secondary controllers,
Klaus Jensen <=