Lines Matching refs:ndev
80 static void write_to_ucd_unit(struct nitrox_device *ndev, u32 ucode_size, in write_to_ucd_unit() argument
104 nitrox_write_csr(ndev, offset, block_num); in write_to_ucd_unit()
111 nitrox_write_csr(ndev, offset, data); in write_to_ucd_unit()
119 static int nitrox_load_fw(struct nitrox_device *ndev) in nitrox_load_fw() argument
133 dev_info(DEV(ndev), "Loading firmware \"%s\"\n", fw_name); in nitrox_load_fw()
135 ret = request_firmware(&fw, fw_name, DEV(ndev)); in nitrox_load_fw()
137 dev_err(DEV(ndev), "failed to get firmware %s\n", fw_name); in nitrox_load_fw()
145 dev_err(DEV(ndev), "Invalid ucode size: %u for firmware %s\n", in nitrox_load_fw()
153 memcpy(&ndev->hw.fw_name[0][0], ucode->version, (VERSION_LEN - 2)); in nitrox_load_fw()
154 ndev->hw.fw_name[0][VERSION_LEN - 1] = '\0'; in nitrox_load_fw()
157 write_to_ucd_unit(ndev, ucode_size, ucode_data, 0); in nitrox_load_fw()
163 nitrox_write_csr(ndev, offset, (~0ULL)); in nitrox_load_fw()
177 for (i = 0; i < ndev->hw.se_cores; i++) { in nitrox_load_fw()
179 nitrox_write_csr(ndev, offset, core_2_eid_val.value); in nitrox_load_fw()
184 dev_info(DEV(ndev), "Loading firmware \"%s\"\n", fw_name); in nitrox_load_fw()
186 ret = request_firmware(&fw, fw_name, DEV(ndev)); in nitrox_load_fw()
188 dev_err(DEV(ndev), "failed to get firmware %s\n", fw_name); in nitrox_load_fw()
196 dev_err(DEV(ndev), "Invalid ucode size: %u for firmware %s\n", in nitrox_load_fw()
204 memcpy(&ndev->hw.fw_name[1][0], ucode->version, (VERSION_LEN - 2)); in nitrox_load_fw()
205 ndev->hw.fw_name[1][VERSION_LEN - 1] = '\0'; in nitrox_load_fw()
208 write_to_ucd_unit(ndev, ucode_size, ucode_data, 2); in nitrox_load_fw()
215 nitrox_write_csr(ndev, offset, aqm_grp_execmask_lo.value); in nitrox_load_fw()
218 nitrox_write_csr(ndev, offset, aqm_grp_execmask_hi.value); in nitrox_load_fw()
232 for (i = 0; i < ndev->hw.ae_cores; i++) { in nitrox_load_fw()
234 nitrox_write_csr(ndev, offset, core_2_eid_val.value); in nitrox_load_fw()
244 static int nitrox_add_to_devlist(struct nitrox_device *ndev) in nitrox_add_to_devlist() argument
249 INIT_LIST_HEAD(&ndev->list); in nitrox_add_to_devlist()
250 refcount_set(&ndev->refcnt, 1); in nitrox_add_to_devlist()
254 if (dev == ndev) { in nitrox_add_to_devlist()
259 ndev->idx = num_devices++; in nitrox_add_to_devlist()
260 list_add_tail(&ndev->list, &ndevlist); in nitrox_add_to_devlist()
271 static void nitrox_remove_from_devlist(struct nitrox_device *ndev) in nitrox_remove_from_devlist() argument
274 list_del(&ndev->list); in nitrox_remove_from_devlist()
281 struct nitrox_device *ndev; in nitrox_get_first_device() local
284 list_for_each_entry(ndev, &ndevlist, list) { in nitrox_get_first_device()
285 if (nitrox_ready(ndev)) in nitrox_get_first_device()
289 if (&ndev->list == &ndevlist) in nitrox_get_first_device()
292 refcount_inc(&ndev->refcnt); in nitrox_get_first_device()
295 return ndev; in nitrox_get_first_device()
298 void nitrox_put_device(struct nitrox_device *ndev) in nitrox_put_device() argument
300 if (!ndev) in nitrox_put_device()
303 refcount_dec(&ndev->refcnt); in nitrox_put_device()
327 static int nitrox_pf_sw_init(struct nitrox_device *ndev) in nitrox_pf_sw_init() argument
331 err = nitrox_common_sw_init(ndev); in nitrox_pf_sw_init()
335 err = nitrox_register_interrupts(ndev); in nitrox_pf_sw_init()
337 nitrox_common_sw_cleanup(ndev); in nitrox_pf_sw_init()
342 static void nitrox_pf_sw_cleanup(struct nitrox_device *ndev) in nitrox_pf_sw_cleanup() argument
344 nitrox_unregister_interrupts(ndev); in nitrox_pf_sw_cleanup()
345 nitrox_common_sw_cleanup(ndev); in nitrox_pf_sw_cleanup()
352 static int nitrox_bist_check(struct nitrox_device *ndev) in nitrox_bist_check() argument
358 value += nitrox_read_csr(ndev, EMU_BIST_STATUSX(i)); in nitrox_bist_check()
359 value += nitrox_read_csr(ndev, EFL_CORE_BIST_REGX(i)); in nitrox_bist_check()
361 value += nitrox_read_csr(ndev, UCD_BIST_STATUS); in nitrox_bist_check()
362 value += nitrox_read_csr(ndev, NPS_CORE_BIST_REG); in nitrox_bist_check()
363 value += nitrox_read_csr(ndev, NPS_CORE_NPC_BIST_REG); in nitrox_bist_check()
364 value += nitrox_read_csr(ndev, NPS_PKT_SLC_BIST_REG); in nitrox_bist_check()
365 value += nitrox_read_csr(ndev, NPS_PKT_IN_BIST_REG); in nitrox_bist_check()
366 value += nitrox_read_csr(ndev, POM_BIST_REG); in nitrox_bist_check()
367 value += nitrox_read_csr(ndev, BMI_BIST_REG); in nitrox_bist_check()
368 value += nitrox_read_csr(ndev, EFL_TOP_BIST_STAT); in nitrox_bist_check()
369 value += nitrox_read_csr(ndev, BMO_BIST_REG); in nitrox_bist_check()
370 value += nitrox_read_csr(ndev, LBC_BIST_STATUS); in nitrox_bist_check()
371 value += nitrox_read_csr(ndev, PEM_BIST_STATUSX(0)); in nitrox_bist_check()
377 static int nitrox_pf_hw_init(struct nitrox_device *ndev) in nitrox_pf_hw_init() argument
381 err = nitrox_bist_check(ndev); in nitrox_pf_hw_init()
383 dev_err(&ndev->pdev->dev, "BIST check failed\n"); in nitrox_pf_hw_init()
387 nitrox_get_hwinfo(ndev); in nitrox_pf_hw_init()
389 nitrox_config_nps_core_unit(ndev); in nitrox_pf_hw_init()
390 nitrox_config_aqm_unit(ndev); in nitrox_pf_hw_init()
391 nitrox_config_nps_pkt_unit(ndev); in nitrox_pf_hw_init()
392 nitrox_config_pom_unit(ndev); in nitrox_pf_hw_init()
393 nitrox_config_efl_unit(ndev); in nitrox_pf_hw_init()
395 nitrox_config_bmi_unit(ndev); in nitrox_pf_hw_init()
396 nitrox_config_bmo_unit(ndev); in nitrox_pf_hw_init()
398 nitrox_config_lbc_unit(ndev); in nitrox_pf_hw_init()
399 nitrox_config_rand_unit(ndev); in nitrox_pf_hw_init()
402 err = nitrox_load_fw(ndev); in nitrox_pf_hw_init()
406 nitrox_config_emu_unit(ndev); in nitrox_pf_hw_init()
422 struct nitrox_device *ndev; in nitrox_probe() local
458 ndev = kzalloc(sizeof(*ndev), GFP_KERNEL); in nitrox_probe()
459 if (!ndev) { in nitrox_probe()
464 pci_set_drvdata(pdev, ndev); in nitrox_probe()
465 ndev->pdev = pdev; in nitrox_probe()
468 nitrox_add_to_devlist(ndev); in nitrox_probe()
470 ndev->hw.vendor_id = pdev->vendor; in nitrox_probe()
471 ndev->hw.device_id = pdev->device; in nitrox_probe()
472 ndev->hw.revision_id = pdev->revision; in nitrox_probe()
474 ndev->timeout = msecs_to_jiffies(CMD_TIMEOUT); in nitrox_probe()
475 ndev->node = dev_to_node(&pdev->dev); in nitrox_probe()
476 if (ndev->node == NUMA_NO_NODE) in nitrox_probe()
477 ndev->node = 0; in nitrox_probe()
479 ndev->bar_addr = ioremap(pci_resource_start(pdev, 0), in nitrox_probe()
481 if (!ndev->bar_addr) { in nitrox_probe()
486 ndev->nr_queues = min_t(u32, MAX_PF_QUEUES, num_online_cpus()); in nitrox_probe()
487 ndev->qlen = qlen; in nitrox_probe()
489 err = nitrox_pf_sw_init(ndev); in nitrox_probe()
493 err = nitrox_pf_hw_init(ndev); in nitrox_probe()
497 nitrox_debugfs_init(ndev); in nitrox_probe()
500 atomic64_set(&ndev->stats.posted, 0); in nitrox_probe()
501 atomic64_set(&ndev->stats.completed, 0); in nitrox_probe()
502 atomic64_set(&ndev->stats.dropped, 0); in nitrox_probe()
504 atomic_set(&ndev->state, __NDEV_READY); in nitrox_probe()
515 nitrox_debugfs_exit(ndev); in nitrox_probe()
516 atomic_set(&ndev->state, __NDEV_NOT_READY); in nitrox_probe()
520 nitrox_pf_sw_cleanup(ndev); in nitrox_probe()
522 nitrox_remove_from_devlist(ndev); in nitrox_probe()
523 kfree(ndev); in nitrox_probe()
537 struct nitrox_device *ndev = pci_get_drvdata(pdev); in nitrox_remove() local
539 if (!ndev) in nitrox_remove()
542 if (!refcount_dec_and_test(&ndev->refcnt)) { in nitrox_remove()
543 dev_err(DEV(ndev), "Device refcnt not zero (%d)\n", in nitrox_remove()
544 refcount_read(&ndev->refcnt)); in nitrox_remove()
548 dev_info(DEV(ndev), "Removing Device %x:%x\n", in nitrox_remove()
549 ndev->hw.vendor_id, ndev->hw.device_id); in nitrox_remove()
551 atomic_set(&ndev->state, __NDEV_NOT_READY); in nitrox_remove()
555 nitrox_remove_from_devlist(ndev); in nitrox_remove()
562 nitrox_debugfs_exit(ndev); in nitrox_remove()
563 nitrox_pf_sw_cleanup(ndev); in nitrox_remove()
565 iounmap(ndev->bar_addr); in nitrox_remove()
566 kfree(ndev); in nitrox_remove()