Lines Matching refs:pdsfc
43 struct pdsfc_dev *pdsfc = container_of(uctx->fwctl, struct pdsfc_dev, fwctl); in pdsfc_open_uctx() local
46 pdsfc_uctx->uctx_caps = pdsfc->caps; in pdsfc_open_uctx()
69 static int pdsfc_identify(struct pdsfc_dev *pdsfc) in pdsfc_identify() argument
71 struct device *dev = &pdsfc->fwctl.dev; in pdsfc_identify()
93 err = pds_client_adminq_cmd(pdsfc->padev, &cmd, sizeof(cmd), &comp, 0); in pdsfc_identify()
98 pdsfc->ident = *ident; in pdsfc_identify()
105 static void pdsfc_free_endpoints(struct pdsfc_dev *pdsfc) in pdsfc_free_endpoints() argument
107 struct device *dev = &pdsfc->fwctl.dev; in pdsfc_free_endpoints()
111 if (!pdsfc->endpoints) in pdsfc_free_endpoints()
114 num_endpoints = le32_to_cpu(pdsfc->endpoints->num_entries); in pdsfc_free_endpoints()
115 for (i = 0; pdsfc->endpoint_info && i < num_endpoints; i++) in pdsfc_free_endpoints()
116 mutex_destroy(&pdsfc->endpoint_info[i].lock); in pdsfc_free_endpoints()
117 vfree(pdsfc->endpoint_info); in pdsfc_free_endpoints()
118 pdsfc->endpoint_info = NULL; in pdsfc_free_endpoints()
120 pdsfc->endpoints, pdsfc->endpoints_pa); in pdsfc_free_endpoints()
121 pdsfc->endpoints = NULL; in pdsfc_free_endpoints()
122 pdsfc->endpoints_pa = DMA_MAPPING_ERROR; in pdsfc_free_endpoints()
125 static void pdsfc_free_operations(struct pdsfc_dev *pdsfc) in pdsfc_free_operations() argument
127 struct device *dev = &pdsfc->fwctl.dev; in pdsfc_free_operations()
131 num_endpoints = le32_to_cpu(pdsfc->endpoints->num_entries); in pdsfc_free_operations()
133 struct pdsfc_rpc_endpoint_info *ei = &pdsfc->endpoint_info[i]; in pdsfc_free_operations()
144 static struct pds_fwctl_query_data *pdsfc_get_endpoints(struct pdsfc_dev *pdsfc, in pdsfc_get_endpoints() argument
147 struct device *dev = &pdsfc->fwctl.dev; in pdsfc_get_endpoints()
170 err = pds_client_adminq_cmd(pdsfc->padev, &cmd, sizeof(cmd), &comp, 0); in pdsfc_get_endpoints()
183 static int pdsfc_init_endpoints(struct pdsfc_dev *pdsfc) in pdsfc_init_endpoints() argument
189 pdsfc->endpoints = pdsfc_get_endpoints(pdsfc, &pdsfc->endpoints_pa); in pdsfc_init_endpoints()
190 if (IS_ERR(pdsfc->endpoints)) in pdsfc_init_endpoints()
191 return PTR_ERR(pdsfc->endpoints); in pdsfc_init_endpoints()
193 num_endpoints = le32_to_cpu(pdsfc->endpoints->num_entries); in pdsfc_init_endpoints()
194 pdsfc->endpoint_info = vcalloc(num_endpoints, in pdsfc_init_endpoints()
195 sizeof(*pdsfc->endpoint_info)); in pdsfc_init_endpoints()
196 if (!pdsfc->endpoint_info) { in pdsfc_init_endpoints()
197 pdsfc_free_endpoints(pdsfc); in pdsfc_init_endpoints()
201 ep_entry = (struct pds_fwctl_query_data_endpoint *)pdsfc->endpoints->entries; in pdsfc_init_endpoints()
203 mutex_init(&pdsfc->endpoint_info[i].lock); in pdsfc_init_endpoints()
204 pdsfc->endpoint_info[i].endpoint = le32_to_cpu(ep_entry[i].id); in pdsfc_init_endpoints()
210 static struct pds_fwctl_query_data *pdsfc_get_operations(struct pdsfc_dev *pdsfc, in pdsfc_get_operations() argument
214 struct device *dev = &pdsfc->fwctl.dev; in pdsfc_get_operations()
241 err = pds_client_adminq_cmd(pdsfc->padev, &cmd, sizeof(cmd), &comp, 0); in pdsfc_get_operations()
280 static int pdsfc_validate_rpc(struct pdsfc_dev *pdsfc, in pdsfc_validate_rpc() argument
286 struct device *dev = &pdsfc->fwctl.dev; in pdsfc_validate_rpc()
293 if (rpc->in.len > le32_to_cpu(pdsfc->ident.max_req_sz)) { in pdsfc_validate_rpc()
295 rpc->in.len, le32_to_cpu(pdsfc->ident.max_req_sz)); in pdsfc_validate_rpc()
299 if (rpc->out.len > le32_to_cpu(pdsfc->ident.max_resp_sz)) { in pdsfc_validate_rpc()
301 rpc->out.len, le32_to_cpu(pdsfc->ident.max_resp_sz)); in pdsfc_validate_rpc()
305 num_entries = le32_to_cpu(pdsfc->endpoints->num_entries); in pdsfc_validate_rpc()
307 if (pdsfc->endpoint_info[i].endpoint == rpc->in.ep) { in pdsfc_validate_rpc()
308 ep_info = &pdsfc->endpoint_info[i]; in pdsfc_validate_rpc()
322 operations = pdsfc_get_operations(pdsfc, in pdsfc_validate_rpc()
352 struct pdsfc_dev *pdsfc = container_of(uctx->fwctl, struct pdsfc_dev, fwctl); in pdsfc_fw_rpc() local
364 err = pdsfc_validate_rpc(pdsfc, rpc, scope); in pdsfc_fw_rpc()
422 err = pds_client_adminq_cmd(pdsfc->padev, &cmd, sizeof(cmd), &comp, 0); in pdsfc_fw_rpc()
478 struct pdsfc_dev *pdsfc; in pdsfc_probe() local
481 pdsfc = fwctl_alloc_device(&padev->vf_pdev->dev, &pdsfc_ops, in pdsfc_probe()
483 if (!pdsfc) in pdsfc_probe()
485 pdsfc->padev = padev; in pdsfc_probe()
487 err = pdsfc_identify(pdsfc); in pdsfc_probe()
489 fwctl_put(&pdsfc->fwctl); in pdsfc_probe()
493 err = pdsfc_init_endpoints(pdsfc); in pdsfc_probe()
495 fwctl_put(&pdsfc->fwctl); in pdsfc_probe()
499 pdsfc->caps = PDS_FWCTL_QUERY_CAP | PDS_FWCTL_SEND_CAP; in pdsfc_probe()
501 err = fwctl_register(&pdsfc->fwctl); in pdsfc_probe()
503 pdsfc_free_endpoints(pdsfc); in pdsfc_probe()
504 fwctl_put(&pdsfc->fwctl); in pdsfc_probe()
508 auxiliary_set_drvdata(adev, pdsfc); in pdsfc_probe()
515 struct pdsfc_dev *pdsfc = auxiliary_get_drvdata(adev); in pdsfc_remove() local
517 fwctl_unregister(&pdsfc->fwctl); in pdsfc_remove()
518 pdsfc_free_operations(pdsfc); in pdsfc_remove()
519 pdsfc_free_endpoints(pdsfc); in pdsfc_remove()
521 fwctl_put(&pdsfc->fwctl); in pdsfc_remove()