Lines Matching full:hw
13 u16 ifcvf_set_vq_vector(struct ifcvf_hw *hw, u16 qid, int vector) in ifcvf_set_vq_vector() argument
15 struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; in ifcvf_set_vq_vector()
23 u16 ifcvf_set_config_vector(struct ifcvf_hw *hw, int vector) in ifcvf_set_config_vector() argument
25 struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; in ifcvf_set_config_vector()
32 static void __iomem *get_cap_addr(struct ifcvf_hw *hw, in get_cap_addr() argument
43 IFCVF_DBG(hw->pdev, 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()
72 u16 ifcvf_get_vq_size(struct ifcvf_hw *hw, u16 qid) in ifcvf_get_vq_size() argument
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()
85 u16 ifcvf_get_max_vq_size(struct ifcvf_hw *hw) in ifcvf_get_max_vq_size() argument
89 max_size = ifcvf_get_vq_size(hw, 0); in ifcvf_get_max_vq_size()
90 for (qid = 1; qid < hw->nr_vring; qid++) { in ifcvf_get_max_vq_size()
91 queue_size = ifcvf_get_vq_size(hw, qid); in ifcvf_get_max_vq_size()
102 int ifcvf_init_hw(struct ifcvf_hw *hw, struct pci_dev *pdev) in ifcvf_init_hw() argument
115 hw->pdev = pdev; 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()
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()
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()
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()
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()
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()
194 u8 ifcvf_get_status(struct ifcvf_hw *hw) in ifcvf_get_status() argument
196 return vp_ioread8(&hw->common_cfg->device_status); in ifcvf_get_status()
199 void ifcvf_set_status(struct ifcvf_hw *hw, u8 status) in ifcvf_set_status() argument
201 vp_iowrite8(status, &hw->common_cfg->device_status); in ifcvf_set_status()
204 void ifcvf_reset(struct ifcvf_hw *hw) in ifcvf_reset() argument
206 ifcvf_set_status(hw, 0); in ifcvf_reset()
207 while (ifcvf_get_status(hw)) in ifcvf_reset()
211 u64 ifcvf_get_hw_features(struct ifcvf_hw *hw) in ifcvf_get_hw_features() argument
213 struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; in ifcvf_get_hw_features()
229 u64 ifcvf_get_dev_features(struct ifcvf_hw *hw) in ifcvf_get_dev_features() argument
231 return hw->dev_features; in ifcvf_get_dev_features()
234 u64 ifcvf_get_driver_features(struct ifcvf_hw *hw) in ifcvf_get_driver_features() argument
236 struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; in ifcvf_get_driver_features()
251 int ifcvf_verify_min_features(struct ifcvf_hw *hw, u64 features) in ifcvf_verify_min_features() argument
254 IFCVF_ERR(hw->pdev, "VIRTIO_F_ACCESS_PLATFORM is not negotiated\n"); in ifcvf_verify_min_features()
261 u32 ifcvf_get_config_size(struct ifcvf_hw *hw) in ifcvf_get_config_size() argument
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()
288 void ifcvf_read_dev_config(struct ifcvf_hw *hw, u64 offset, in ifcvf_read_dev_config() argument
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()
305 void ifcvf_write_dev_config(struct ifcvf_hw *hw, u64 offset, in ifcvf_write_dev_config() argument
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()
317 void ifcvf_set_driver_features(struct ifcvf_hw *hw, u64 features) in ifcvf_set_driver_features() argument
319 struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; in ifcvf_set_driver_features()
328 u16 ifcvf_get_vq_state(struct ifcvf_hw *hw, u16 qid) in ifcvf_get_vq_state() argument
330 struct ifcvf_lm_cfg __iomem *lm_cfg = hw->lm_cfg; in ifcvf_get_vq_state()
338 int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u16 num) in ifcvf_set_vq_state() argument
340 struct ifcvf_lm_cfg __iomem *lm_cfg = hw->lm_cfg; in ifcvf_set_vq_state()
347 void ifcvf_set_vq_num(struct ifcvf_hw *hw, u16 qid, u32 num) in ifcvf_set_vq_num() argument
349 struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; in ifcvf_set_vq_num()
355 int ifcvf_set_vq_address(struct ifcvf_hw *hw, u16 qid, u64 desc_area, in ifcvf_set_vq_address() argument
358 struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; in ifcvf_set_vq_address()
371 bool ifcvf_get_vq_ready(struct ifcvf_hw *hw, u16 qid) in ifcvf_get_vq_ready() argument
373 struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; in ifcvf_get_vq_ready()
382 void ifcvf_set_vq_ready(struct ifcvf_hw *hw, u16 qid, bool ready) in ifcvf_set_vq_ready() argument
384 struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg; in ifcvf_set_vq_ready()
390 static void ifcvf_reset_vring(struct ifcvf_hw *hw) in ifcvf_reset_vring() argument
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()
397 ifcvf_set_vq_vector(hw, qid, VIRTIO_MSI_NO_VECTOR); in ifcvf_reset_vring()
401 static void ifcvf_reset_config_handler(struct ifcvf_hw *hw) in ifcvf_reset_config_handler() argument
403 hw->config_cb.callback = NULL; in ifcvf_reset_config_handler()
404 hw->config_cb.private = NULL; in ifcvf_reset_config_handler()
405 ifcvf_set_config_vector(hw, VIRTIO_MSI_NO_VECTOR); in ifcvf_reset_config_handler()
408 static void ifcvf_synchronize_irq(struct ifcvf_hw *hw) in ifcvf_synchronize_irq() argument
410 u32 nvectors = hw->num_msix_vectors; in ifcvf_synchronize_irq()
411 struct pci_dev *pdev = hw->pdev; in ifcvf_synchronize_irq()
421 void ifcvf_stop(struct ifcvf_hw *hw) in ifcvf_stop() argument
423 ifcvf_synchronize_irq(hw); in ifcvf_stop()
424 ifcvf_reset_vring(hw); in ifcvf_stop()
425 ifcvf_reset_config_handler(hw); in ifcvf_stop()
428 void ifcvf_notify_queue(struct ifcvf_hw *hw, u16 qid) in ifcvf_notify_queue() argument
430 vp_iowrite16(qid, hw->vring[qid].notify_addr); in ifcvf_notify_queue()