Lines Matching refs:lmac

41 struct lmac {  struct
59 struct lmac *lmac_idmap[MAX_LMAC_PER_CGX]; argument
84 static void cgx_write(struct cgx *cgx, u64 lmac, u64 offset, u64 val) in cgx_write() argument
86 writeq(val, cgx->reg_base + (lmac << 18) + offset); in cgx_write()
89 static u64 cgx_read(struct cgx *cgx, u64 lmac, u64 offset) in cgx_read() argument
91 return readq(cgx->reg_base + (lmac << 18) + offset); in cgx_read()
94 static inline struct lmac *lmac_pdata(u8 lmac_id, struct cgx *cgx) in lmac_pdata()
149 struct lmac *lmac = lmac_pdata(lmac_id, cgxd); in cgx_get_link_info() local
151 if (!lmac) in cgx_get_link_info()
154 *linfo = lmac->link_info; in cgx_get_link_info()
325 static int cgx_fwi_cmd_send(u64 req, u64 *resp, struct lmac *lmac) in cgx_fwi_cmd_send() argument
327 struct cgx *cgx = lmac->cgx; in cgx_fwi_cmd_send()
333 err = mutex_lock_interruptible(&lmac->cmd_lock); in cgx_fwi_cmd_send()
338 cmd = cgx_read(cgx, lmac->lmac_id, CGX_COMMAND_REG); in cgx_fwi_cmd_send()
348 lmac->cmd_pend = true; in cgx_fwi_cmd_send()
351 cgx_write(cgx, lmac->lmac_id, CGX_COMMAND_REG, req); in cgx_fwi_cmd_send()
354 if (!wait_event_timeout(lmac->wq_cmd_cmplt, !lmac->cmd_pend, in cgx_fwi_cmd_send()
358 cgx->cgx_id, lmac->lmac_id); in cgx_fwi_cmd_send()
365 *resp = lmac->resp; in cgx_fwi_cmd_send()
368 mutex_unlock(&lmac->cmd_lock); in cgx_fwi_cmd_send()
376 struct lmac *lmac; in cgx_fwi_cmd_generic() local
379 lmac = lmac_pdata(lmac_id, cgx); in cgx_fwi_cmd_generic()
380 if (!lmac) in cgx_fwi_cmd_generic()
383 err = cgx_fwi_cmd_send(req, resp, lmac); in cgx_fwi_cmd_generic()
439 struct lmac *lmac) in cgx_link_change_handler() argument
442 struct cgx *cgx = lmac->cgx; in cgx_link_change_handler()
449 link_status_user_format(lstat, &event.link_uinfo, cgx, lmac->lmac_id); in cgx_link_change_handler()
453 event.lmac_id = lmac->lmac_id; in cgx_link_change_handler()
456 lmac->link_info = event.link_uinfo; in cgx_link_change_handler()
457 linfo = &lmac->link_info; in cgx_link_change_handler()
460 spin_lock(&lmac->event_cb_lock); in cgx_link_change_handler()
462 if (!lmac->event_cb.notify_link_chg) { in cgx_link_change_handler()
464 cgx->cgx_id, lmac->lmac_id); in cgx_link_change_handler()
467 cgx->cgx_id, lmac->lmac_id, err_type); in cgx_link_change_handler()
470 cgx->cgx_id, lmac->lmac_id, in cgx_link_change_handler()
475 if (lmac->event_cb.notify_link_chg(&event, lmac->event_cb.data)) in cgx_link_change_handler()
478 spin_unlock(&lmac->event_cb_lock); in cgx_link_change_handler()
557 struct lmac *lmac = data; in cgx_fwi_event_handler() local
561 cgx = lmac->cgx; in cgx_fwi_event_handler()
563 event = cgx_read(cgx, lmac->lmac_id, CGX_EVENT_REG); in cgx_fwi_event_handler()
573 lmac->resp = event; in cgx_fwi_event_handler()
581 cgx_link_change_handler(event, lmac); in cgx_fwi_event_handler()
584 lmac->cmd_pend = false; in cgx_fwi_event_handler()
585 wake_up_interruptible(&lmac->wq_cmd_cmplt); in cgx_fwi_event_handler()
589 cgx_link_change_handler(event, lmac); in cgx_fwi_event_handler()
597 cgx_write(lmac->cgx, lmac->lmac_id, CGX_EVENT_REG, 0); in cgx_fwi_event_handler()
598 cgx_write(lmac->cgx, lmac->lmac_id, CGXX_CMRX_INT, FW_CGX_INT); in cgx_fwi_event_handler()
609 struct lmac *lmac; in cgx_lmac_evh_register() local
611 lmac = lmac_pdata(lmac_id, cgx); in cgx_lmac_evh_register()
612 if (!lmac) in cgx_lmac_evh_register()
615 lmac->event_cb = *cb; in cgx_lmac_evh_register()
623 struct lmac *lmac; in cgx_lmac_evh_unregister() local
627 lmac = lmac_pdata(lmac_id, cgx); in cgx_lmac_evh_unregister()
628 if (!lmac) in cgx_lmac_evh_unregister()
631 spin_lock_irqsave(&lmac->event_cb_lock, flags); in cgx_lmac_evh_unregister()
632 lmac->event_cb.notify_link_chg = NULL; in cgx_lmac_evh_unregister()
633 lmac->event_cb.data = NULL; in cgx_lmac_evh_unregister()
634 spin_unlock_irqrestore(&lmac->event_cb_lock, flags); in cgx_lmac_evh_unregister()
716 struct lmac *lmac; in cgx_lmac_init() local
724 lmac = kcalloc(1, sizeof(struct lmac), GFP_KERNEL); in cgx_lmac_init()
725 if (!lmac) in cgx_lmac_init()
727 lmac->name = kcalloc(1, sizeof("cgx_fwi_xxx_yyy"), GFP_KERNEL); in cgx_lmac_init()
728 if (!lmac->name) in cgx_lmac_init()
730 sprintf(lmac->name, "cgx_fwi_%d_%d", cgx->cgx_id, i); in cgx_lmac_init()
731 lmac->lmac_id = i; in cgx_lmac_init()
732 lmac->cgx = cgx; in cgx_lmac_init()
733 init_waitqueue_head(&lmac->wq_cmd_cmplt); in cgx_lmac_init()
734 mutex_init(&lmac->cmd_lock); in cgx_lmac_init()
735 spin_lock_init(&lmac->event_cb_lock); in cgx_lmac_init()
738 cgx_fwi_event_handler, 0, lmac->name, lmac); in cgx_lmac_init()
743 cgx_write(cgx, lmac->lmac_id, CGXX_CMRX_INT_ENA_W1S, in cgx_lmac_init()
747 cgx->lmac_idmap[i] = lmac; in cgx_lmac_init()
755 struct lmac *lmac; in cgx_lmac_exit() local
766 lmac = cgx->lmac_idmap[i]; in cgx_lmac_exit()
767 if (!lmac) in cgx_lmac_exit()
769 free_irq(pci_irq_vector(cgx->pdev, CGX_LMAC_FWI + i * 9), lmac); in cgx_lmac_exit()
770 kfree(lmac->name); in cgx_lmac_exit()
771 kfree(lmac); in cgx_lmac_exit()