Lines Matching refs:lmac
110 void cgx_write(struct cgx *cgx, u64 lmac, u64 offset, u64 val) in cgx_write() argument
112 writeq(val, cgx->reg_base + (lmac << cgx->mac_ops->lmac_offset) + in cgx_write()
116 u64 cgx_read(struct cgx *cgx, u64 lmac, u64 offset) in cgx_read() argument
118 return readq(cgx->reg_base + (lmac << cgx->mac_ops->lmac_offset) + in cgx_read()
122 struct lmac *lmac_pdata(u8 lmac_id, struct cgx *cgx) in lmac_pdata()
208 struct lmac *lmac = lmac_pdata(lmac_id, cgxd); in cgx_get_link_info() local
210 if (!lmac) in cgx_get_link_info()
213 *linfo = lmac->link_info; in cgx_get_link_info()
238 struct lmac *lmac = lmac_pdata(lmac_id, cgx_dev); in cgx_lmac_addr_set() local
253 index = id * lmac->mac_to_index_bmap.max; in cgx_lmac_addr_set()
297 struct lmac *lmac = lmac_pdata(lmac_id, cgx_dev); in cgx_lmac_addr_add() local
303 if (!lmac) in cgx_lmac_addr_add()
308 idx = rvu_alloc_rsrc(&lmac->mac_to_index_bmap); in cgx_lmac_addr_add()
314 index = id * lmac->mac_to_index_bmap.max + idx; in cgx_lmac_addr_add()
327 lmac->mcast_filters_count++; in cgx_lmac_addr_add()
328 } else if (!lmac->mcast_filters_count) { in cgx_lmac_addr_add()
340 struct lmac *lmac = lmac_pdata(lmac_id, cgx_dev); in cgx_lmac_addr_reset() local
345 if (!lmac) in cgx_lmac_addr_reset()
352 set_bit(0, lmac->mac_to_index_bmap.bmap); in cgx_lmac_addr_reset()
356 index = id * lmac->mac_to_index_bmap.max + index; in cgx_lmac_addr_reset()
376 struct lmac *lmac; in cgx_lmac_addr_update() local
380 lmac = lmac_pdata(lmac_id, cgx_dev); in cgx_lmac_addr_update()
381 if (!lmac) in cgx_lmac_addr_update()
386 if (index >= lmac->mac_to_index_bmap.max) in cgx_lmac_addr_update()
390 if (!test_bit(index, lmac->mac_to_index_bmap.bmap)) in cgx_lmac_addr_update()
395 index = id * lmac->mac_to_index_bmap.max + index; in cgx_lmac_addr_update()
408 struct lmac *lmac = lmac_pdata(lmac_id, cgx_dev); in cgx_lmac_addr_del() local
414 if (!lmac) in cgx_lmac_addr_del()
419 if (index >= lmac->mac_to_index_bmap.max) in cgx_lmac_addr_del()
426 rvu_free_rsrc(&lmac->mac_to_index_bmap, index); in cgx_lmac_addr_del()
430 index = id * lmac->mac_to_index_bmap.max + index; in cgx_lmac_addr_del()
437 lmac->mcast_filters_count--; in cgx_lmac_addr_del()
439 if (!lmac->mcast_filters_count) { in cgx_lmac_addr_del()
454 struct lmac *lmac = lmac_pdata(lmac_id, cgx_dev); in cgx_lmac_addr_max_entries_get() local
456 if (lmac) in cgx_lmac_addr_max_entries_get()
457 return lmac->mac_to_index_bmap.max; in cgx_lmac_addr_max_entries_get()
465 struct lmac *lmac = lmac_pdata(lmac_id, cgx_dev); in cgx_lmac_addr_get() local
475 index = id * lmac->mac_to_index_bmap.max; in cgx_lmac_addr_get()
559 struct lmac *lmac = lmac_pdata(lmac_id, cgx); in cgx_lmac_promisc_config() local
560 u16 max_dmac = lmac->mac_to_index_bmap.max; in cgx_lmac_promisc_config()
633 struct lmac *lmac; in cgx_lmac_enadis_rx_pause_fwding() local
639 lmac = lmac_pdata(lmac_id, cgx); in cgx_lmac_enadis_rx_pause_fwding()
640 if (!lmac) in cgx_lmac_enadis_rx_pause_fwding()
644 if (!bitmap_weight(lmac->rx_fc_pfvf_bmap.bmap, lmac->rx_fc_pfvf_bmap.max)) in cgx_lmac_enadis_rx_pause_fwding()
887 struct lmac *lmac; in verify_lmac_fc_cfg() local
889 lmac = lmac_pdata(lmac_id, cgx); in verify_lmac_fc_cfg()
890 if (!lmac) in verify_lmac_fc_cfg()
894 clear_bit(pfvf_idx, lmac->rx_fc_pfvf_bmap.bmap); in verify_lmac_fc_cfg()
896 set_bit(pfvf_idx, lmac->rx_fc_pfvf_bmap.bmap); in verify_lmac_fc_cfg()
899 clear_bit(pfvf_idx, lmac->tx_fc_pfvf_bmap.bmap); in verify_lmac_fc_cfg()
901 set_bit(pfvf_idx, lmac->tx_fc_pfvf_bmap.bmap); in verify_lmac_fc_cfg()
904 if (!rx_pause && bitmap_weight(lmac->rx_fc_pfvf_bmap.bmap, lmac->rx_fc_pfvf_bmap.max)) { in verify_lmac_fc_cfg()
910 if (!tx_pause && bitmap_weight(lmac->tx_fc_pfvf_bmap.bmap, lmac->tx_fc_pfvf_bmap.max)) { in verify_lmac_fc_cfg()
1009 int cgx_fwi_cmd_send(u64 req, u64 *resp, struct lmac *lmac) in cgx_fwi_cmd_send() argument
1011 struct cgx *cgx = lmac->cgx; in cgx_fwi_cmd_send()
1017 err = mutex_lock_interruptible(&lmac->cmd_lock); in cgx_fwi_cmd_send()
1022 cmd = cgx_read(cgx, lmac->lmac_id, CGX_COMMAND_REG); in cgx_fwi_cmd_send()
1032 lmac->cmd_pend = true; in cgx_fwi_cmd_send()
1035 cgx_write(cgx, lmac->lmac_id, CGX_COMMAND_REG, req); in cgx_fwi_cmd_send()
1038 if (!wait_event_timeout(lmac->wq_cmd_cmplt, !lmac->cmd_pend, in cgx_fwi_cmd_send()
1042 cgx->cgx_id, lmac->lmac_id, FIELD_GET(CMDREG_ID, req)); in cgx_fwi_cmd_send()
1049 *resp = lmac->resp; in cgx_fwi_cmd_send()
1052 mutex_unlock(&lmac->cmd_lock); in cgx_fwi_cmd_send()
1059 struct lmac *lmac; in cgx_fwi_cmd_generic() local
1062 lmac = lmac_pdata(lmac_id, cgx); in cgx_fwi_cmd_generic()
1063 if (!lmac) in cgx_fwi_cmd_generic()
1066 err = cgx_fwi_cmd_send(req, resp, lmac); in cgx_fwi_cmd_generic()
1234 struct lmac *lmac) in cgx_link_change_handler() argument
1237 struct cgx *cgx = lmac->cgx; in cgx_link_change_handler()
1244 link_status_user_format(lstat, &event.link_uinfo, cgx, lmac->lmac_id); in cgx_link_change_handler()
1248 event.lmac_id = lmac->lmac_id; in cgx_link_change_handler()
1251 lmac->link_info = event.link_uinfo; in cgx_link_change_handler()
1252 linfo = &lmac->link_info; in cgx_link_change_handler()
1258 spin_lock(&lmac->event_cb_lock); in cgx_link_change_handler()
1260 if (!lmac->event_cb.notify_link_chg) { in cgx_link_change_handler()
1262 cgx->cgx_id, lmac->lmac_id); in cgx_link_change_handler()
1265 cgx->cgx_id, lmac->lmac_id, err_type); in cgx_link_change_handler()
1268 cgx->cgx_id, lmac->lmac_id, in cgx_link_change_handler()
1273 if (lmac->event_cb.notify_link_chg(&event, lmac->event_cb.data)) in cgx_link_change_handler()
1276 spin_unlock(&lmac->event_cb_lock); in cgx_link_change_handler()
1303 struct lmac *lmac = data; in cgx_fwi_event_handler() local
1306 cgx = lmac->cgx; in cgx_fwi_event_handler()
1312 event = cgx_read(cgx, lmac->lmac_id, CGX_EVENT_REG); in cgx_fwi_event_handler()
1322 lmac->resp = event; in cgx_fwi_event_handler()
1330 cgx_link_change_handler(event, lmac); in cgx_fwi_event_handler()
1333 lmac->cmd_pend = false; in cgx_fwi_event_handler()
1334 wake_up_interruptible(&lmac->wq_cmd_cmplt); in cgx_fwi_event_handler()
1338 cgx_link_change_handler(event, lmac); in cgx_fwi_event_handler()
1346 cgx_write(lmac->cgx, lmac->lmac_id, CGX_EVENT_REG, 0); in cgx_fwi_event_handler()
1347 cgx_write(lmac->cgx, lmac->lmac_id, offset, clear_bit); in cgx_fwi_event_handler()
1358 struct lmac *lmac; in cgx_lmac_evh_register() local
1360 lmac = lmac_pdata(lmac_id, cgx); in cgx_lmac_evh_register()
1361 if (!lmac) in cgx_lmac_evh_register()
1364 lmac->event_cb = *cb; in cgx_lmac_evh_register()
1371 struct lmac *lmac; in cgx_lmac_evh_unregister() local
1375 lmac = lmac_pdata(lmac_id, cgx); in cgx_lmac_evh_unregister()
1376 if (!lmac) in cgx_lmac_evh_unregister()
1379 spin_lock_irqsave(&lmac->event_cb_lock, flags); in cgx_lmac_evh_unregister()
1380 lmac->event_cb.notify_link_chg = NULL; in cgx_lmac_evh_unregister()
1381 lmac->event_cb.data = NULL; in cgx_lmac_evh_unregister()
1382 spin_unlock_irqrestore(&lmac->event_cb_lock, flags); in cgx_lmac_evh_unregister()
1553 static int cgx_configure_interrupt(struct cgx *cgx, struct lmac *lmac, in cgx_configure_interrupt() argument
1567 free_irq(irq, lmac); in cgx_configure_interrupt()
1571 err = request_irq(irq, cgx_fwi_event_handler, 0, lmac->name, lmac); in cgx_configure_interrupt()
1576 cgx_write(cgx, lmac->lmac_id, offset, ena_bit); in cgx_configure_interrupt()
1603 struct lmac *lmac; in cgx_lmac_init() local
1620 lmac = kzalloc(sizeof(struct lmac), GFP_KERNEL); in cgx_lmac_init()
1621 if (!lmac) in cgx_lmac_init()
1623 lmac->name = kcalloc(1, sizeof("cgx_fwi_xxx_yyy"), GFP_KERNEL); in cgx_lmac_init()
1624 if (!lmac->name) { in cgx_lmac_init()
1628 sprintf(lmac->name, "cgx_fwi_%d_%d", cgx->cgx_id, i); in cgx_lmac_init()
1630 lmac->lmac_id = __ffs64(lmac_list); in cgx_lmac_init()
1631 lmac_list &= ~BIT_ULL(lmac->lmac_id); in cgx_lmac_init()
1633 lmac->lmac_id = i; in cgx_lmac_init()
1636 lmac->cgx = cgx; in cgx_lmac_init()
1637 lmac->mac_to_index_bmap.max = in cgx_lmac_init()
1639 err = rvu_alloc_bitmap(&lmac->mac_to_index_bmap); in cgx_lmac_init()
1644 set_bit(0, lmac->mac_to_index_bmap.bmap); in cgx_lmac_init()
1646 lmac->rx_fc_pfvf_bmap.max = 128; in cgx_lmac_init()
1647 err = rvu_alloc_bitmap(&lmac->rx_fc_pfvf_bmap); in cgx_lmac_init()
1651 lmac->tx_fc_pfvf_bmap.max = 128; in cgx_lmac_init()
1652 err = rvu_alloc_bitmap(&lmac->tx_fc_pfvf_bmap); in cgx_lmac_init()
1656 init_waitqueue_head(&lmac->wq_cmd_cmplt); in cgx_lmac_init()
1657 mutex_init(&lmac->cmd_lock); in cgx_lmac_init()
1658 spin_lock_init(&lmac->event_cb_lock); in cgx_lmac_init()
1659 err = cgx_configure_interrupt(cgx, lmac, lmac->lmac_id, false); in cgx_lmac_init()
1664 cgx->lmac_idmap[lmac->lmac_id] = lmac; in cgx_lmac_init()
1665 set_bit(lmac->lmac_id, &cgx->lmac_bmap); in cgx_lmac_init()
1666 cgx->mac_ops->mac_pause_frm_config(cgx, lmac->lmac_id, true); in cgx_lmac_init()
1672 rvu_free_bitmap(&lmac->tx_fc_pfvf_bmap); in cgx_lmac_init()
1674 rvu_free_bitmap(&lmac->rx_fc_pfvf_bmap); in cgx_lmac_init()
1676 rvu_free_bitmap(&lmac->mac_to_index_bmap); in cgx_lmac_init()
1678 kfree(lmac->name); in cgx_lmac_init()
1680 kfree(lmac); in cgx_lmac_init()
1686 struct lmac *lmac; in cgx_lmac_exit() local
1696 lmac = cgx->lmac_idmap[i]; in cgx_lmac_exit()
1697 if (!lmac) in cgx_lmac_exit()
1699 cgx->mac_ops->mac_pause_frm_config(cgx, lmac->lmac_id, false); in cgx_lmac_exit()
1700 cgx_configure_interrupt(cgx, lmac, lmac->lmac_id, true); in cgx_lmac_exit()
1701 kfree(lmac->mac_to_index_bmap.bmap); in cgx_lmac_exit()
1702 kfree(lmac->name); in cgx_lmac_exit()
1703 kfree(lmac); in cgx_lmac_exit()