Lines Matching refs:pdev

106 	struct pcifront_device *pdev;
113 struct pcifront_device *pdev = NULL;
120 xenbus_dev_fatal(pdev->xdev, err, "Error scanning pci device instance number");
124 pdev = (struct pcifront_device *)malloc(sizeof(struct pcifront_device), M_DEVBUF, M_NOWAIT);
125 if (pdev == NULL) {
130 pdev->unit = unit;
131 pdev->xdev = xdev;
132 pdev->ref_cnt = 1;
134 pdev->sh_info = (struct xen_pci_sharedinfo *)malloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT);
135 if (pdev->sh_info == NULL) {
136 free(pdev, M_DEVBUF);
137 pdev = NULL;
142 pdev->sh_info->flags = 0;
144 xdev->data = pdev;
146 mtx_init(&pdev->sh_info_lock, "info_lock", "pci shared dev info lock", MTX_DEF);
148 pdev->evtchn = INVALID_EVTCHN;
149 pdev->gnt_ref = INVALID_GRANT_REF;
151 STAILQ_INSERT_TAIL(&pdev_list, pdev, next);
153 DPRINTF("Allocated pdev @ 0x%p (unit=%d)\n", pdev, unit);
156 return pdev;
161 get_pdev(struct pcifront_device *pdev)
163 pdev->ref_cnt++;
168 put_pdev(struct pcifront_device *pdev)
170 if (--pdev->ref_cnt > 0)
173 DPRINTF("freeing pdev @ 0x%p (ref_cnt=%d)\n", pdev, pdev->ref_cnt);
175 if (pdev->evtchn != INVALID_EVTCHN)
176 xenbus_free_evtchn(pdev->xdev, pdev->evtchn);
178 if (pdev->gnt_ref != INVALID_GRANT_REF)
179 gnttab_end_foreign_access(pdev->gnt_ref, 0, (void *)pdev->sh_info);
181 pdev->xdev->data = NULL;
183 free(pdev, M_DEVBUF);
189 pcifront_publish_info(struct pcifront_device *pdev)
194 err = xenbus_grant_ring(pdev->xdev, virt_to_mfn(pdev->sh_info));
200 pdev->gnt_ref = err;
202 err = xenbus_alloc_evtchn(pdev->xdev, &pdev->evtchn);
209 xenbus_dev_fatal(pdev->xdev, err,
215 err = xenbus_printf(trans, pdev->xdev->nodename,
216 "pci-op-ref", "%u", pdev->gnt_ref);
218 err = xenbus_printf(trans, pdev->xdev->nodename,
219 "event-channel", "%u", pdev->evtchn);
221 err = xenbus_printf(trans, pdev->xdev->nodename,
224 err = xenbus_switch_state(pdev->xdev, trans,
229 xenbus_dev_fatal(pdev->xdev, err,
237 xenbus_dev_fatal(pdev->xdev, err,
249 pcifront_connect(struct pcifront_device *pdev)
262 pdev->ndev = BUS_ADD_CHILD(nexus, 0, "xpcife", pdev->unit);
263 if (!pdev->ndev) {
264 WPRINTF("could not create xpcife%d!\n", pdev->unit);
267 get_pdev(pdev);
268 device_set_ivars(pdev->ndev, pdev);
271 xenbus_switch_state(pdev->xdev, NULL, XenbusStateConnected);
273 printf("pcifront: connected to %s\n", pdev->xdev->nodename);
276 device_probe_and_attach(pdev->ndev);
284 pcifront_disconnect(struct pcifront_device *pdev)
289 prev_state = xenbus_read_driver_state(pdev->xdev->nodename);
292 err = xenbus_switch_state(pdev->xdev, NULL, XenbusStateClosing);
307 struct pcifront_device *pdev;
311 if ((pdev = alloc_pdev(xdev)) == NULL)
314 err = pcifront_publish_info(pdev);
318 put_pdev(pdev);
337 struct pcifront_device *pdev = xdev->data;
342 pcifront_disconnect(pdev);
347 pcifront_disconnect(pdev);
352 pcifront_connect(pdev);
362 do_pci_op(struct pcifront_device *pdev, struct xen_pci_op *op)
365 struct xen_pci_op *active_op = &pdev->sh_info->op;
366 evtchn_port_t port = pdev->evtchn;
369 mtx_lock(&pdev->sh_info_lock);
375 set_bit(_XEN_PCIF_active, (unsigned long *)&pdev->sh_info->flags);
384 (_XEN_PCIF_active, (unsigned long *)&pdev->sh_info->flags)) {
392 (unsigned long *)&pdev->sh_info->flags);
402 mtx_unlock(&pdev->sh_info_lock);
441 struct pcifront_device *pdev = (struct pcifront_device *)device_get_ivars(dev);
442 DPRINTF("xpcife probe (unit=%d)\n", pdev->unit);
451 struct pcifront_device *pdev = (struct pcifront_device *)device_get_ivars(dev);
456 DPRINTF("xpcife attach (unit=%d)\n", pdev->unit);
458 err = xenbus_scanf(NULL, pdev->xdev->otherend,
463 xenbus_dev_fatal(pdev->xdev, err,
478 err = xenbus_scanf(NULL, pdev->xdev->otherend, str,
483 xenbus_dev_fatal(pdev->xdev, err,
488 if (domain != pdev->xdev->otherend_id) {
490 xenbus_dev_fatal(pdev->xdev, err,
491 "Domain mismatch %d != %d", domain, pdev->xdev->otherend_id);
498 xenbus_dev_fatal(pdev->xdev, err,
543 struct pcifront_device *pdev = (struct pcifront_device *)device_get_ivars(device_get_parent(dev));
547 sc->domain = pdev->xdev->otherend_id;
549 sc->pdev = pdev;
603 err = do_pci_op(sc->pdev, &op);
631 err = do_pci_op(sc->pdev, &op);