Lines Matching refs:hwdev

51 static int parse_capability(struct hinic_hwdev *hwdev,  in parse_capability()  argument
54 struct hinic_cap *nic_cap = &hwdev->nic_cap; in parse_capability()
57 if (!HINIC_IS_VF(hwdev->hwif) && dev_cap->intr_type != INTR_MSIX_TYPE) in parse_capability()
60 num_aeqs = HINIC_HWIF_NUM_AEQS(hwdev->hwif); in parse_capability()
61 num_ceqs = HINIC_HWIF_NUM_CEQS(hwdev->hwif); in parse_capability()
62 num_irqs = HINIC_HWIF_NUM_IRQS(hwdev->hwif); in parse_capability()
70 if (!HINIC_IS_VF(hwdev->hwif)) in parse_capability()
78 if (!HINIC_IS_VF(hwdev->hwif)) { in parse_capability()
83 hwdev->port_id = dev_cap->port_id; in parse_capability()
96 struct hinic_hwdev *hwdev = &pfhwdev->hwdev; in get_capability() local
97 struct hinic_hwif *hwif = hwdev->hwif; in get_capability()
113 return parse_capability(hwdev, &dev_cap); in get_capability()
122 static int get_dev_cap(struct hinic_hwdev *hwdev) in get_dev_cap() argument
124 struct hinic_hwif *hwif = hwdev->hwif; in get_dev_cap()
133 pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev); in get_dev_cap()
154 static int init_msix(struct hinic_hwdev *hwdev) in init_msix() argument
156 struct hinic_hwif *hwif = hwdev->hwif; in init_msix()
167 hwdev->msix_entries = devm_kcalloc(&pdev->dev, nr_irqs, in init_msix()
168 sizeof(*hwdev->msix_entries), in init_msix()
170 if (!hwdev->msix_entries) in init_msix()
174 hwdev->msix_entries[i].entry = i; in init_msix()
176 err = pci_enable_msix_exact(pdev, hwdev->msix_entries, nr_irqs); in init_msix()
189 static void disable_msix(struct hinic_hwdev *hwdev) in disable_msix() argument
191 struct hinic_hwif *hwif = hwdev->hwif; in disable_msix()
208 int hinic_port_msg_cmd(struct hinic_hwdev *hwdev, enum hinic_port_cmd cmd, in hinic_port_msg_cmd() argument
213 pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev); in hinic_port_msg_cmd()
220 int hinic_hilink_msg_cmd(struct hinic_hwdev *hwdev, enum hinic_hilink_cmd cmd, in hinic_hilink_msg_cmd() argument
226 pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev); in hinic_hilink_msg_cmd()
239 static int init_fw_ctxt(struct hinic_hwdev *hwdev) in init_fw_ctxt() argument
241 struct hinic_hwif *hwif = hwdev->hwif; in init_fw_ctxt()
250 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_FWCTXT_INIT, in init_fw_ctxt()
270 static int set_hw_ioctxt(struct hinic_hwdev *hwdev, unsigned int sq_depth, in set_hw_ioctxt() argument
273 struct hinic_hwif *hwif = hwdev->hwif; in set_hw_ioctxt()
291 pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev); in set_hw_ioctxt()
299 static int wait_for_outbound_state(struct hinic_hwdev *hwdev) in wait_for_outbound_state() argument
302 struct hinic_hwif *hwif = hwdev->hwif; in wait_for_outbound_state()
320 static int wait_for_db_state(struct hinic_hwdev *hwdev) in wait_for_db_state() argument
322 struct hinic_hwif *hwif = hwdev->hwif; in wait_for_db_state()
347 static int clear_io_resources(struct hinic_hwdev *hwdev) in clear_io_resources() argument
350 struct hinic_hwif *hwif = hwdev->hwif; in clear_io_resources()
360 pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev); in clear_io_resources()
381 static int set_resources_state(struct hinic_hwdev *hwdev, in set_resources_state() argument
385 struct hinic_hwif *hwif = hwdev->hwif; in set_resources_state()
391 pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev); in set_resources_state()
407 static int get_base_qpn(struct hinic_hwdev *hwdev, u16 *base_qpn) in get_base_qpn() argument
410 struct hinic_hwif *hwif = hwdev->hwif; in get_base_qpn()
417 err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_GLOBAL_QPN, in get_base_qpn()
438 int hinic_hwdev_ifup(struct hinic_hwdev *hwdev, u16 sq_depth, u16 rq_depth) in hinic_hwdev_ifup() argument
440 struct hinic_func_to_io *func_to_io = &hwdev->func_to_io; in hinic_hwdev_ifup()
441 struct hinic_cap *nic_cap = &hwdev->nic_cap; in hinic_hwdev_ifup()
442 struct hinic_hwif *hwif = hwdev->hwif; in hinic_hwdev_ifup()
450 err = get_base_qpn(hwdev, &base_qpn); in hinic_hwdev_ifup()
459 ceq_msix_entries = &hwdev->msix_entries[num_aeqs]; in hinic_hwdev_ifup()
460 func_to_io->hwdev = hwdev; in hinic_hwdev_ifup()
473 sq_msix_entries = &hwdev->msix_entries[num_aeqs + num_ceqs]; in hinic_hwdev_ifup()
474 rq_msix_entries = &hwdev->msix_entries[num_aeqs + num_ceqs + num_qps]; in hinic_hwdev_ifup()
483 err = wait_for_db_state(hwdev); in hinic_hwdev_ifup()
489 err = set_hw_ioctxt(hwdev, sq_depth, rq_depth); in hinic_hwdev_ifup()
510 void hinic_hwdev_ifdown(struct hinic_hwdev *hwdev) in hinic_hwdev_ifdown() argument
512 struct hinic_func_to_io *func_to_io = &hwdev->func_to_io; in hinic_hwdev_ifdown()
513 struct hinic_cap *nic_cap = &hwdev->nic_cap; in hinic_hwdev_ifdown()
515 clear_io_resources(hwdev); in hinic_hwdev_ifdown()
528 void hinic_hwdev_cb_register(struct hinic_hwdev *hwdev, in hinic_hwdev_cb_register() argument
538 pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev); in hinic_hwdev_cb_register()
553 void hinic_hwdev_cb_unregister(struct hinic_hwdev *hwdev, in hinic_hwdev_cb_unregister() argument
556 struct hinic_hwif *hwif = hwdev->hwif; in hinic_hwdev_cb_unregister()
564 pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev); in hinic_hwdev_cb_unregister()
592 struct hinic_hwdev *hwdev; in nic_mgmt_msg_handler() local
597 hwdev = &pfhwdev->hwdev; in nic_mgmt_msg_handler()
598 hwif = hwdev->hwif; in nic_mgmt_msg_handler()
632 dev_err(&pfhwdev->hwdev.hwif->pdev->dev, in hinic_comm_recv_mgmt_self_cmd_reg()
649 dev_err(&pfhwdev->hwdev.hwif->pdev->dev, "Unregister recv mgmt process failed, cmd: 0x%x\n", in hinic_comm_recv_mgmt_self_cmd_unreg()
672 dev_warn(&pfhwdev->hwdev.hwif->pdev->dev, in comm_mgmt_msg_handler()
677 (&pfhwdev->hwdev, buf_in, in_size, in comm_mgmt_msg_handler()
685 dev_warn(&pfhwdev->hwdev.hwif->pdev->dev, "Received unknown mgmt cpu event: 0x%x\n", in comm_mgmt_msg_handler()
696 struct hinic_hwdev *hwdev = dev; in pf_fault_event_handler() local
699 dev_err(&hwdev->hwif->pdev->dev, "Invalid fault event report, length: %d, should be %zu\n", in pf_fault_event_handler()
704 if (!hwdev->devlink_dev || IS_ERR_OR_NULL(hwdev->devlink_dev->hw_fault_reporter)) in pf_fault_event_handler()
707 devlink_health_report(hwdev->devlink_dev->hw_fault_reporter, in pf_fault_event_handler()
716 struct hinic_hwdev *hwdev = dev; in mgmt_watchdog_timeout_event_handler() local
719 dev_err(&hwdev->hwif->pdev->dev, "Invalid mgmt watchdog report, length: %d, should be %zu\n", in mgmt_watchdog_timeout_event_handler()
724 if (!hwdev->devlink_dev || IS_ERR_OR_NULL(hwdev->devlink_dev->fw_fault_reporter)) in mgmt_watchdog_timeout_event_handler()
727 devlink_health_report(hwdev->devlink_dev->fw_fault_reporter, in mgmt_watchdog_timeout_event_handler()
739 struct hinic_hwdev *hwdev = &pfhwdev->hwdev; in init_pfhwdev() local
740 struct hinic_hwif *hwif = hwdev->hwif; in init_pfhwdev()
750 err = hinic_func_to_func_init(hwdev); in init_pfhwdev()
770 hinic_register_vf_mbox_cb(hwdev, HINIC_MOD_L2NIC, in init_pfhwdev()
775 hinic_devlink_register(hwdev->devlink_dev); in init_pfhwdev()
785 struct hinic_hwdev *hwdev = &pfhwdev->hwdev; in free_pfhwdev() local
787 hinic_devlink_unregister(hwdev->devlink_dev); in free_pfhwdev()
788 hinic_set_pf_action(hwdev->hwif, HINIC_PF_MGMT_INIT); in free_pfhwdev()
790 if (!HINIC_IS_VF(hwdev->hwif)) { in free_pfhwdev()
800 hinic_unregister_vf_mbox_cb(hwdev, HINIC_MOD_L2NIC); in free_pfhwdev()
803 hinic_func_to_func_free(hwdev); in free_pfhwdev()
808 static int hinic_l2nic_reset(struct hinic_hwdev *hwdev) in hinic_l2nic_reset() argument
815 pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev); in hinic_l2nic_reset()
817 l2nic_reset.func_id = HINIC_HWIF_FUNC_IDX(hwdev->hwif); in hinic_l2nic_reset()
826 …dev_err(&hwdev->hwif->pdev->dev, "Failed to reset L2NIC resources, err: %d, status: 0x%x, out_size… in hinic_l2nic_reset()
834 static int hinic_get_interrupt_cfg(struct hinic_hwdev *hwdev, in hinic_get_interrupt_cfg() argument
841 if (!hwdev || !interrupt_info) in hinic_get_interrupt_cfg()
844 pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev); in hinic_get_interrupt_cfg()
846 interrupt_info->func_id = HINIC_HWIF_FUNC_IDX(hwdev->hwif); in hinic_get_interrupt_cfg()
853 …dev_err(&hwdev->hwif->pdev->dev, "Failed to get interrupt config, err: %d, status: 0x%x, out size:… in hinic_get_interrupt_cfg()
861 int hinic_set_interrupt_cfg(struct hinic_hwdev *hwdev, in hinic_set_interrupt_cfg() argument
869 if (!hwdev) in hinic_set_interrupt_cfg()
872 pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev); in hinic_set_interrupt_cfg()
874 interrupt_info->func_id = HINIC_HWIF_FUNC_IDX(hwdev->hwif); in hinic_set_interrupt_cfg()
876 err = hinic_get_interrupt_cfg(hwdev, &temp_info); in hinic_set_interrupt_cfg()
888 …dev_err(&hwdev->hwif->pdev->dev, "Failed to get interrupt config, err: %d, status: 0x%x, out size:… in hinic_set_interrupt_cfg()
908 struct hinic_hwdev *hwdev; in hinic_init_hwdev() local
928 hwdev = &pfhwdev->hwdev; in hinic_init_hwdev()
929 hwdev->hwif = hwif; in hinic_init_hwdev()
930 hwdev->devlink_dev = devlink_priv(devlink); in hinic_init_hwdev()
931 hwdev->devlink_dev->hwdev = hwdev; in hinic_init_hwdev()
933 err = init_msix(hwdev); in hinic_init_hwdev()
939 err = wait_for_outbound_state(hwdev); in hinic_init_hwdev()
947 err = hinic_aeqs_init(&hwdev->aeqs, hwif, num_aeqs, in hinic_init_hwdev()
949 hwdev->msix_entries); in hinic_init_hwdev()
961 err = hinic_l2nic_reset(hwdev); in hinic_init_hwdev()
965 err = get_dev_cap(hwdev); in hinic_init_hwdev()
971 mutex_init(&hwdev->func_to_io.nic_cfg.cfg_mutex); in hinic_init_hwdev()
973 err = hinic_vf_func_init(hwdev); in hinic_init_hwdev()
979 err = init_fw_ctxt(hwdev); in hinic_init_hwdev()
985 err = set_resources_state(hwdev, HINIC_RES_ACTIVE); in hinic_init_hwdev()
991 return hwdev; in hinic_init_hwdev()
995 hinic_vf_func_free(hwdev); in hinic_init_hwdev()
1002 hinic_aeqs_free(&hwdev->aeqs); in hinic_init_hwdev()
1005 disable_msix(hwdev); in hinic_init_hwdev()
1019 void hinic_free_hwdev(struct hinic_hwdev *hwdev) in hinic_free_hwdev() argument
1021 struct hinic_pfhwdev *pfhwdev = container_of(hwdev, in hinic_free_hwdev()
1023 hwdev); in hinic_free_hwdev()
1025 set_resources_state(hwdev, HINIC_RES_CLEAN); in hinic_free_hwdev()
1027 hinic_vf_func_free(hwdev); in hinic_free_hwdev()
1031 hinic_aeqs_free(&hwdev->aeqs); in hinic_free_hwdev()
1033 disable_msix(hwdev); in hinic_free_hwdev()
1035 hinic_free_hwif(hwdev->hwif); in hinic_free_hwdev()
1044 int hinic_hwdev_num_qps(struct hinic_hwdev *hwdev) in hinic_hwdev_num_qps() argument
1046 struct hinic_cap *nic_cap = &hwdev->nic_cap; in hinic_hwdev_num_qps()
1058 struct hinic_sq *hinic_hwdev_get_sq(struct hinic_hwdev *hwdev, int i) in hinic_hwdev_get_sq() argument
1060 struct hinic_func_to_io *func_to_io = &hwdev->func_to_io; in hinic_hwdev_get_sq()
1063 if (i >= hinic_hwdev_num_qps(hwdev)) in hinic_hwdev_get_sq()
1076 struct hinic_rq *hinic_hwdev_get_rq(struct hinic_hwdev *hwdev, int i) in hinic_hwdev_get_rq() argument
1078 struct hinic_func_to_io *func_to_io = &hwdev->func_to_io; in hinic_hwdev_get_rq()
1081 if (i >= hinic_hwdev_num_qps(hwdev)) in hinic_hwdev_get_rq()
1094 int hinic_hwdev_msix_cnt_set(struct hinic_hwdev *hwdev, u16 msix_index) in hinic_hwdev_msix_cnt_set() argument
1096 return hinic_msix_attr_cnt_clear(hwdev->hwif, msix_index); in hinic_hwdev_msix_cnt_set()
1111 int hinic_hwdev_msix_set(struct hinic_hwdev *hwdev, u16 msix_index, in hinic_hwdev_msix_set() argument
1116 return hinic_msix_attr_set(hwdev->hwif, msix_index, in hinic_hwdev_msix_set()
1131 int hinic_hwdev_hw_ci_addr_set(struct hinic_hwdev *hwdev, struct hinic_sq *sq, in hinic_hwdev_hw_ci_addr_set() argument
1135 struct hinic_hwif *hwif = hwdev->hwif; in hinic_hwdev_hw_ci_addr_set()
1152 pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev); in hinic_hwdev_hw_ci_addr_set()
1167 void hinic_hwdev_set_msix_state(struct hinic_hwdev *hwdev, u16 msix_index, in hinic_hwdev_set_msix_state() argument
1170 hinic_set_msix_state(hwdev->hwif, msix_index, flag); in hinic_hwdev_set_msix_state()
1173 int hinic_get_board_info(struct hinic_hwdev *hwdev, in hinic_get_board_info() argument
1180 if (!hwdev || !board_info) in hinic_get_board_info()
1183 pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev); in hinic_get_board_info()
1190 dev_err(&hwdev->hwif->pdev->dev, in hinic_get_board_info()