Lines Matching +full:cap +full:- +full:get
1 // SPDX-License-Identifier: GPL-2.0-only
15 struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; in ifcvf_set_vq_vector()
17 vp_iowrite16(qid, &cfg->queue_select); in ifcvf_set_vq_vector()
18 vp_iowrite16(vector, &cfg->queue_msix_vector); in ifcvf_set_vq_vector()
20 return vp_ioread16(&cfg->queue_msix_vector); in ifcvf_set_vq_vector()
25 struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; in ifcvf_set_config_vector()
27 vp_iowrite16(vector, &cfg->msix_config); in ifcvf_set_config_vector()
29 return vp_ioread16(&cfg->msix_config); in ifcvf_set_config_vector()
33 struct virtio_pci_cap *cap) in get_cap_addr() argument
38 length = le32_to_cpu(cap->length); in get_cap_addr()
39 offset = le32_to_cpu(cap->offset); in get_cap_addr()
40 bar = cap->bar; in get_cap_addr()
43 IFCVF_DBG(hw->pdev, in get_cap_addr()
44 "Invalid bar number %u to get capabilities\n", bar); in get_cap_addr()
48 if (offset + length > pci_resource_len(hw->pdev, bar)) { in get_cap_addr()
49 IFCVF_DBG(hw->pdev, in get_cap_addr()
55 return hw->base[bar] + offset; in get_cap_addr()
76 if (qid >= hw->nr_vring) in ifcvf_get_vq_size()
79 vp_iowrite16(qid, &hw->common_cfg->queue_select); in ifcvf_get_vq_size()
80 queue_size = vp_ioread16(&hw->common_cfg->queue_size); in ifcvf_get_vq_size()
90 for (qid = 1; qid < hw->nr_vring; qid++) { in ifcvf_get_max_vq_size()
104 struct virtio_pci_cap cap; in ifcvf_init_hw() local
113 return -EIO; in ifcvf_init_hw()
115 hw->pdev = pdev; in ifcvf_init_hw()
118 ret = ifcvf_read_config_range(pdev, (u32 *)&cap, in ifcvf_init_hw()
119 sizeof(cap), pos); in ifcvf_init_hw()
122 "Failed to get PCI capability at %x\n", pos); in ifcvf_init_hw()
126 if (cap.cap_vndr != PCI_CAP_ID_VNDR) in ifcvf_init_hw()
129 switch (cap.cfg_type) { in ifcvf_init_hw()
131 hw->common_cfg = get_cap_addr(hw, &cap); in ifcvf_init_hw()
132 IFCVF_DBG(pdev, "hw->common_cfg = %p\n", in ifcvf_init_hw()
133 hw->common_cfg); in ifcvf_init_hw()
136 pci_read_config_dword(pdev, pos + sizeof(cap), in ifcvf_init_hw()
137 &hw->notify_off_multiplier); in ifcvf_init_hw()
138 hw->notify_bar = cap.bar; in ifcvf_init_hw()
139 hw->notify_base = get_cap_addr(hw, &cap); in ifcvf_init_hw()
140 hw->notify_base_pa = pci_resource_start(pdev, cap.bar) + in ifcvf_init_hw()
141 le32_to_cpu(cap.offset); in ifcvf_init_hw()
142 IFCVF_DBG(pdev, "hw->notify_base = %p\n", in ifcvf_init_hw()
143 hw->notify_base); in ifcvf_init_hw()
146 hw->isr = get_cap_addr(hw, &cap); in ifcvf_init_hw()
147 IFCVF_DBG(pdev, "hw->isr = %p\n", hw->isr); in ifcvf_init_hw()
150 hw->dev_cfg = get_cap_addr(hw, &cap); in ifcvf_init_hw()
151 hw->cap_dev_config_size = le32_to_cpu(cap.length); in ifcvf_init_hw()
152 IFCVF_DBG(pdev, "hw->dev_cfg = %p\n", hw->dev_cfg); in ifcvf_init_hw()
157 pos = cap.cap_next; in ifcvf_init_hw()
160 if (hw->common_cfg == NULL || hw->notify_base == NULL || in ifcvf_init_hw()
161 hw->isr == NULL || hw->dev_cfg == NULL) { in ifcvf_init_hw()
163 return -EIO; in ifcvf_init_hw()
166 hw->nr_vring = vp_ioread16(&hw->common_cfg->num_queues); in ifcvf_init_hw()
167 hw->vring = kzalloc(sizeof(struct vring_info) * hw->nr_vring, GFP_KERNEL); in ifcvf_init_hw()
168 if (!hw->vring) in ifcvf_init_hw()
169 return -ENOMEM; in ifcvf_init_hw()
171 for (i = 0; i < hw->nr_vring; i++) { in ifcvf_init_hw()
172 vp_iowrite16(i, &hw->common_cfg->queue_select); in ifcvf_init_hw()
173 notify_off = vp_ioread16(&hw->common_cfg->queue_notify_off); in ifcvf_init_hw()
174 hw->vring[i].notify_addr = hw->notify_base + in ifcvf_init_hw()
175 notify_off * hw->notify_off_multiplier; in ifcvf_init_hw()
176 hw->vring[i].notify_pa = hw->notify_base_pa + in ifcvf_init_hw()
177 notify_off * hw->notify_off_multiplier; in ifcvf_init_hw()
178 hw->vring[i].irq = -EINVAL; in ifcvf_init_hw()
181 hw->lm_cfg = hw->base[IFCVF_LM_BAR]; in ifcvf_init_hw()
185 hw->common_cfg, hw->notify_base, hw->isr, in ifcvf_init_hw()
186 hw->dev_cfg, hw->notify_off_multiplier); in ifcvf_init_hw()
188 hw->vqs_reused_irq = -EINVAL; in ifcvf_init_hw()
189 hw->config_irq = -EINVAL; in ifcvf_init_hw()
196 return vp_ioread8(&hw->common_cfg->device_status); in ifcvf_get_status()
201 vp_iowrite8(status, &hw->common_cfg->device_status); in ifcvf_set_status()
213 struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; in ifcvf_get_hw_features()
217 vp_iowrite32(0, &cfg->device_feature_select); in ifcvf_get_hw_features()
218 features_lo = vp_ioread32(&cfg->device_feature); in ifcvf_get_hw_features()
220 vp_iowrite32(1, &cfg->device_feature_select); in ifcvf_get_hw_features()
221 features_hi = vp_ioread32(&cfg->device_feature); in ifcvf_get_hw_features()
231 return hw->dev_features; in ifcvf_get_dev_features()
236 struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; in ifcvf_get_driver_features()
240 vp_iowrite32(0, &cfg->device_feature_select); in ifcvf_get_driver_features()
241 features_lo = vp_ioread32(&cfg->guest_feature); in ifcvf_get_driver_features()
243 vp_iowrite32(1, &cfg->device_feature_select); in ifcvf_get_driver_features()
244 features_hi = vp_ioread32(&cfg->guest_feature); in ifcvf_get_driver_features()
254 IFCVF_ERR(hw->pdev, "VIRTIO_F_ACCESS_PLATFORM is not negotiated\n"); in ifcvf_verify_min_features()
255 return -EINVAL; in ifcvf_verify_min_features()
265 u32 cap_size = hw->cap_dev_config_size; in ifcvf_get_config_size()
273 switch (hw->dev_type) { in ifcvf_get_config_size()
282 IFCVF_ERR(hw->pdev, "VIRTIO ID %u not supported\n", hw->dev_type); in ifcvf_get_config_size()
294 WARN_ON(offset + length > hw->config_size); in ifcvf_read_dev_config()
296 old_gen = vp_ioread8(&hw->common_cfg->config_generation); in ifcvf_read_dev_config()
299 *p++ = vp_ioread8(hw->dev_cfg + offset + i); in ifcvf_read_dev_config()
301 new_gen = vp_ioread8(&hw->common_cfg->config_generation); in ifcvf_read_dev_config()
312 WARN_ON(offset + length > hw->config_size); in ifcvf_write_dev_config()
314 vp_iowrite8(*p++, hw->dev_cfg + offset + i); in ifcvf_write_dev_config()
319 struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; in ifcvf_set_driver_features()
321 vp_iowrite32(0, &cfg->guest_feature_select); in ifcvf_set_driver_features()
322 vp_iowrite32((u32)features, &cfg->guest_feature); in ifcvf_set_driver_features()
324 vp_iowrite32(1, &cfg->guest_feature_select); in ifcvf_set_driver_features()
325 vp_iowrite32(features >> 32, &cfg->guest_feature); in ifcvf_set_driver_features()
330 struct ifcvf_lm_cfg __iomem *lm_cfg = hw->lm_cfg; in ifcvf_get_vq_state()
333 last_avail_idx = vp_ioread16(&lm_cfg->vq_state_region + qid * 2); in ifcvf_get_vq_state()
340 struct ifcvf_lm_cfg __iomem *lm_cfg = hw->lm_cfg; in ifcvf_set_vq_state()
342 vp_iowrite16(num, &lm_cfg->vq_state_region + qid * 2); in ifcvf_set_vq_state()
349 struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; in ifcvf_set_vq_num()
351 vp_iowrite16(qid, &cfg->queue_select); in ifcvf_set_vq_num()
352 vp_iowrite16(num, &cfg->queue_size); in ifcvf_set_vq_num()
358 struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; in ifcvf_set_vq_address()
360 vp_iowrite16(qid, &cfg->queue_select); in ifcvf_set_vq_address()
361 vp_iowrite64_twopart(desc_area, &cfg->queue_desc_lo, in ifcvf_set_vq_address()
362 &cfg->queue_desc_hi); in ifcvf_set_vq_address()
363 vp_iowrite64_twopart(driver_area, &cfg->queue_avail_lo, in ifcvf_set_vq_address()
364 &cfg->queue_avail_hi); in ifcvf_set_vq_address()
365 vp_iowrite64_twopart(device_area, &cfg->queue_used_lo, in ifcvf_set_vq_address()
366 &cfg->queue_used_hi); in ifcvf_set_vq_address()
373 struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; in ifcvf_get_vq_ready()
376 vp_iowrite16(qid, &cfg->queue_select); in ifcvf_get_vq_ready()
377 queue_enable = vp_ioread16(&cfg->queue_enable); in ifcvf_get_vq_ready()
384 struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; in ifcvf_set_vq_ready()
386 vp_iowrite16(qid, &cfg->queue_select); in ifcvf_set_vq_ready()
387 vp_iowrite16(ready, &cfg->queue_enable); in ifcvf_set_vq_ready()
394 for (qid = 0; qid < hw->nr_vring; qid++) { in ifcvf_reset_vring()
395 hw->vring[qid].cb.callback = NULL; in ifcvf_reset_vring()
396 hw->vring[qid].cb.private = NULL; in ifcvf_reset_vring()
403 hw->config_cb.callback = NULL; in ifcvf_reset_config_handler()
404 hw->config_cb.private = NULL; in ifcvf_reset_config_handler()
410 u32 nvectors = hw->num_msix_vectors; in ifcvf_synchronize_irq()
411 struct pci_dev *pdev = hw->pdev; in ifcvf_synchronize_irq()
430 vp_iowrite16(qid, hw->vring[qid].notify_addr); in ifcvf_notify_queue()