Lines Matching refs:ethsw

34 static struct dpaa2_switch_fdb *dpaa2_switch_fdb_get_unused(struct ethsw_core *ethsw)  in dpaa2_switch_fdb_get_unused()  argument
38 for (i = 0; i < ethsw->sw_attr.num_ifs; i++) in dpaa2_switch_fdb_get_unused()
39 if (!ethsw->fdbs[i].in_use) in dpaa2_switch_fdb_get_unused()
40 return &ethsw->fdbs[i]; in dpaa2_switch_fdb_get_unused()
45 dpaa2_switch_filter_block_get_unused(struct ethsw_core *ethsw) in dpaa2_switch_filter_block_get_unused() argument
49 for (i = 0; i < ethsw->sw_attr.num_ifs; i++) in dpaa2_switch_filter_block_get_unused()
50 if (!ethsw->filter_blocks[i].in_use) in dpaa2_switch_filter_block_get_unused()
51 return &ethsw->filter_blocks[i]; in dpaa2_switch_filter_block_get_unused()
125 static void dpaa2_switch_fdb_get_flood_cfg(struct ethsw_core *ethsw, u16 fdb_id, in dpaa2_switch_fdb_get_flood_cfg() argument
136 for (j = 0; j < ethsw->sw_attr.num_ifs; j++) { in dpaa2_switch_fdb_get_flood_cfg()
137 if (!ethsw->ports[j]) in dpaa2_switch_fdb_get_flood_cfg()
139 if (ethsw->ports[j]->fdb->fdb_id != fdb_id) in dpaa2_switch_fdb_get_flood_cfg()
142 if (type == DPSW_BROADCAST && ethsw->ports[j]->bcast_flood) in dpaa2_switch_fdb_get_flood_cfg()
143 cfg->if_id[i++] = ethsw->ports[j]->idx; in dpaa2_switch_fdb_get_flood_cfg()
144 else if (type == DPSW_FLOODING && ethsw->ports[j]->ucast_flood) in dpaa2_switch_fdb_get_flood_cfg()
145 cfg->if_id[i++] = ethsw->ports[j]->idx; in dpaa2_switch_fdb_get_flood_cfg()
149 cfg->if_id[i++] = ethsw->sw_attr.num_ifs; in dpaa2_switch_fdb_get_flood_cfg()
156 static int dpaa2_switch_fdb_set_egress_flood(struct ethsw_core *ethsw, u16 fdb_id) in dpaa2_switch_fdb_set_egress_flood() argument
162 dpaa2_switch_fdb_get_flood_cfg(ethsw, fdb_id, DPSW_BROADCAST, &flood_cfg); in dpaa2_switch_fdb_set_egress_flood()
163 err = dpsw_set_egress_flood(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_fdb_set_egress_flood()
166 dev_err(ethsw->dev, "dpsw_set_egress_flood() = %d\n", err); in dpaa2_switch_fdb_set_egress_flood()
171 dpaa2_switch_fdb_get_flood_cfg(ethsw, fdb_id, DPSW_FLOODING, &flood_cfg); in dpaa2_switch_fdb_set_egress_flood()
172 err = dpsw_set_egress_flood(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_fdb_set_egress_flood()
175 dev_err(ethsw->dev, "dpsw_set_egress_flood() = %d\n", err); in dpaa2_switch_fdb_set_egress_flood()
194 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_add_vlan() local
199 err = dpsw_vlan_add(ethsw->mc_io, 0, in dpaa2_switch_add_vlan()
200 ethsw->dpsw_handle, vid, &vcfg); in dpaa2_switch_add_vlan()
202 dev_err(ethsw->dev, "dpsw_vlan_add err %d\n", err); in dpaa2_switch_add_vlan()
205 ethsw->vlans[vid] = ETHSW_VLAN_MEMBER; in dpaa2_switch_add_vlan()
231 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_port_set_pvid() local
237 err = dpsw_if_get_tci(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_port_set_pvid()
249 err = dpsw_if_disable(ethsw->mc_io, 0, in dpaa2_switch_port_set_pvid()
250 ethsw->dpsw_handle, in dpaa2_switch_port_set_pvid()
258 err = dpsw_if_set_tci(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_port_set_pvid()
272 ret = dpsw_if_enable(ethsw->mc_io, 0, in dpaa2_switch_port_set_pvid()
273 ethsw->dpsw_handle, in dpaa2_switch_port_set_pvid()
287 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_port_add_vlan() local
304 err = dpsw_vlan_add_if(ethsw->mc_io, 0, ethsw->dpsw_handle, vid, &vcfg); in dpaa2_switch_port_add_vlan()
313 err = dpsw_vlan_add_if_untagged(ethsw->mc_io, 0, in dpaa2_switch_port_add_vlan()
314 ethsw->dpsw_handle, in dpaa2_switch_port_add_vlan()
380 static int dpaa2_switch_dellink(struct ethsw_core *ethsw, u16 vid) in dpaa2_switch_dellink() argument
385 if (!ethsw->vlans[vid]) in dpaa2_switch_dellink()
388 err = dpsw_vlan_remove(ethsw->mc_io, 0, ethsw->dpsw_handle, vid); in dpaa2_switch_dellink()
390 dev_err(ethsw->dev, "dpsw_vlan_remove err %d\n", err); in dpaa2_switch_dellink()
393 ethsw->vlans[vid] = 0; in dpaa2_switch_dellink()
395 for (i = 0; i < ethsw->sw_attr.num_ifs; i++) { in dpaa2_switch_dellink()
396 ppriv_local = ethsw->ports[i]; in dpaa2_switch_dellink()
647 static void dpaa2_switch_enable_ctrl_if_napi(struct ethsw_core *ethsw) in dpaa2_switch_enable_ctrl_if_napi() argument
655 ethsw->napi_users++; in dpaa2_switch_enable_ctrl_if_napi()
658 if (ethsw->napi_users > 1) in dpaa2_switch_enable_ctrl_if_napi()
662 napi_enable(&ethsw->fq[i].napi); in dpaa2_switch_enable_ctrl_if_napi()
665 static void dpaa2_switch_disable_ctrl_if_napi(struct ethsw_core *ethsw) in dpaa2_switch_disable_ctrl_if_napi() argument
673 ethsw->napi_users--; in dpaa2_switch_disable_ctrl_if_napi()
674 if (ethsw->napi_users) in dpaa2_switch_disable_ctrl_if_napi()
678 napi_disable(&ethsw->fq[i].napi); in dpaa2_switch_disable_ctrl_if_napi()
684 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_port_open() local
704 dpaa2_switch_enable_ctrl_if_napi(ethsw); in dpaa2_switch_port_open()
717 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_port_stop() local
736 dpaa2_switch_disable_ctrl_if_napi(ethsw); in dpaa2_switch_port_stop()
830 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_fdb_iterate() local
841 fdb_dump_size = ethsw->sw_attr.max_fdb_entries * sizeof(fdb_entry); in dpaa2_switch_fdb_iterate()
855 err = dpsw_fdb_dump(ethsw->mc_io, 0, ethsw->dpsw_handle, fdb_id, in dpaa2_switch_fdb_iterate()
968 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_port_set_mac_addr() local
974 if (!(ethsw->features & ETHSW_FEATURE_MAC_ADDR)) in dpaa2_switch_port_set_mac_addr()
978 err = dpsw_if_get_port_mac_addr(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_port_set_mac_addr()
1006 static void dpaa2_switch_free_fd(const struct ethsw_core *ethsw, in dpaa2_switch_free_fd() argument
1009 struct device *dev = ethsw->dev; in dpaa2_switch_free_fd()
1015 skbh = dpaa2_iova_to_virt(ethsw->iommu_domain, fd_addr); in dpaa2_switch_free_fd()
1028 static int dpaa2_switch_build_single_fd(struct ethsw_core *ethsw, in dpaa2_switch_build_single_fd() argument
1032 struct device *dev = ethsw->dev; in dpaa2_switch_build_single_fd()
1077 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_port_tx() local
1111 err = dpaa2_switch_build_single_fd(ethsw, skb, &fd); in dpaa2_switch_port_tx()
1125 dpaa2_switch_free_fd(ethsw, &fd); in dpaa2_switch_port_tx()
1185 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_port_acl_tbl_bind() local
1195 err = dpsw_acl_add_if(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_port_acl_tbl_bind()
1212 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_port_acl_tbl_unbind() local
1222 err = dpsw_acl_remove_if(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_port_acl_tbl_unbind()
1270 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_port_block_unbind() local
1294 new_block = dpaa2_switch_filter_block_get_unused(ethsw); in dpaa2_switch_port_block_unbind()
1303 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_setup_tc_block_bind() local
1311 ethsw); in dpaa2_switch_setup_tc_block_bind()
1321 ethsw, filter_block, NULL); in dpaa2_switch_setup_tc_block_bind()
1353 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_setup_tc_block_unbind() local
1360 ethsw); in dpaa2_switch_setup_tc_block_unbind()
1494 struct ethsw_core *ethsw = dev_get_drvdata(dev); in dpaa2_switch_irq0_handler_thread() local
1499 err = dpsw_get_irq_status(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_irq0_handler_thread()
1507 port_priv = ethsw->ports[if_id]; in dpaa2_switch_irq0_handler_thread()
1524 err = dpsw_clear_irq_status(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_irq0_handler_thread()
1535 struct ethsw_core *ethsw = dev_get_drvdata(dev); in dpaa2_switch_setup_irqs() local
1551 err = dpsw_set_irq_enable(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_setup_irqs()
1569 err = dpsw_set_irq_mask(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_setup_irqs()
1576 err = dpsw_set_irq_enable(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_setup_irqs()
1595 struct ethsw_core *ethsw = dev_get_drvdata(dev); in dpaa2_switch_teardown_irqs() local
1598 err = dpsw_set_irq_enable(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_teardown_irqs()
1608 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_port_set_learning() local
1617 err = dpsw_if_set_learning_mode(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_port_set_learning()
1657 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_port_flood() local
1665 return dpaa2_switch_fdb_set_egress_flood(ethsw, port_priv->fdb->fdb_id); in dpaa2_switch_port_flood()
1751 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_port_vlans_add() local
1752 struct dpsw_attr *attr = &ethsw->sw_attr; in dpaa2_switch_port_vlans_add()
1762 err = dpsw_get_attributes(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_port_vlans_add()
1763 &ethsw->sw_attr); in dpaa2_switch_port_vlans_add()
1772 err = dpsw_get_attributes(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_port_vlans_add()
1773 &ethsw->sw_attr); in dpaa2_switch_port_vlans_add()
1857 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_port_del_vlan() local
1878 err = dpsw_vlan_remove_if_untagged(ethsw->mc_io, 0, in dpaa2_switch_port_del_vlan()
1879 ethsw->dpsw_handle, in dpaa2_switch_port_del_vlan()
1890 err = dpsw_vlan_remove_if(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_port_del_vlan()
1902 for (i = 0; i < ethsw->sw_attr.num_ifs; i++) { in dpaa2_switch_port_del_vlan()
1903 if (ethsw->ports[i] && in dpaa2_switch_port_del_vlan()
1904 ethsw->ports[i]->vlans[vid] & ETHSW_VLAN_MEMBER) in dpaa2_switch_port_del_vlan()
1908 ethsw->vlans[vid] &= ~ETHSW_VLAN_GLOBAL; in dpaa2_switch_port_del_vlan()
1910 err = dpaa2_switch_dellink(ethsw, vid); in dpaa2_switch_port_del_vlan()
1989 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_port_bridge_join() local
2021 err = dpaa2_switch_fdb_set_egress_flood(ethsw, port_priv->fdb->fdb_id); in dpaa2_switch_port_bridge_join()
2071 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_port_bridge_leave() local
2103 err = dpaa2_switch_fdb_set_egress_flood(ethsw, port_priv->fdb->fdb_id); in dpaa2_switch_port_bridge_leave()
2108 err = dpaa2_switch_fdb_set_egress_flood(ethsw, old_fdb->fdb_id); in dpaa2_switch_port_bridge_leave()
2267 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_port_event() local
2303 queue_work(ethsw->workqueue, &switchdev_work->work); in dpaa2_switch_port_event()
2351 static struct sk_buff *dpaa2_switch_build_linear_skb(struct ethsw_core *ethsw, in dpaa2_switch_build_linear_skb() argument
2357 struct device *dev = ethsw->dev; in dpaa2_switch_build_linear_skb()
2361 fd_vaddr = dpaa2_iova_to_virt(ethsw->iommu_domain, addr); in dpaa2_switch_build_linear_skb()
2375 ethsw->buf_count--; in dpaa2_switch_build_linear_skb()
2383 dpaa2_switch_free_fd(fq->ethsw, fd); in dpaa2_switch_tx_conf()
2389 struct ethsw_core *ethsw = fq->ethsw; in dpaa2_switch_rx() local
2400 if (if_id >= ethsw->sw_attr.num_ifs) { in dpaa2_switch_rx()
2401 dev_err(ethsw->dev, "Frame received from unknown interface!\n"); in dpaa2_switch_rx()
2404 port_priv = ethsw->ports[if_id]; in dpaa2_switch_rx()
2415 skb = dpaa2_switch_build_linear_skb(ethsw, fd); in dpaa2_switch_rx()
2432 dev_info(ethsw->dev, "__skb_vlan_pop() returned %d", err); in dpaa2_switch_rx()
2448 dpaa2_switch_free_fd(ethsw, fd); in dpaa2_switch_rx()
2451 static void dpaa2_switch_detect_features(struct ethsw_core *ethsw) in dpaa2_switch_detect_features() argument
2453 ethsw->features = 0; in dpaa2_switch_detect_features()
2455 if (ethsw->major > 8 || (ethsw->major == 8 && ethsw->minor >= 6)) in dpaa2_switch_detect_features()
2456 ethsw->features |= ETHSW_FEATURE_MAC_ADDR; in dpaa2_switch_detect_features()
2459 static int dpaa2_switch_setup_fqs(struct ethsw_core *ethsw) in dpaa2_switch_setup_fqs() argument
2462 struct device *dev = ethsw->dev; in dpaa2_switch_setup_fqs()
2466 err = dpsw_ctrl_if_get_attributes(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_setup_fqs()
2473 ethsw->fq[i].fqid = ctrl_if_attr.rx_fqid; in dpaa2_switch_setup_fqs()
2474 ethsw->fq[i].ethsw = ethsw; in dpaa2_switch_setup_fqs()
2475 ethsw->fq[i++].type = DPSW_QUEUE_RX; in dpaa2_switch_setup_fqs()
2477 ethsw->fq[i].fqid = ctrl_if_attr.tx_err_conf_fqid; in dpaa2_switch_setup_fqs()
2478 ethsw->fq[i].ethsw = ethsw; in dpaa2_switch_setup_fqs()
2479 ethsw->fq[i++].type = DPSW_QUEUE_TX_ERR_CONF; in dpaa2_switch_setup_fqs()
2487 static void dpaa2_switch_free_bufs(struct ethsw_core *ethsw, u64 *buf_array, int count) in dpaa2_switch_free_bufs() argument
2489 struct device *dev = ethsw->dev; in dpaa2_switch_free_bufs()
2494 vaddr = dpaa2_iova_to_virt(ethsw->iommu_domain, buf_array[i]); in dpaa2_switch_free_bufs()
2504 static int dpaa2_switch_add_bufs(struct ethsw_core *ethsw, u16 bpid) in dpaa2_switch_add_bufs() argument
2506 struct device *dev = ethsw->dev; in dpaa2_switch_add_bufs()
2548 dpaa2_switch_free_bufs(ethsw, buf_array, i); in dpaa2_switch_add_bufs()
2566 static int dpaa2_switch_refill_bp(struct ethsw_core *ethsw) in dpaa2_switch_refill_bp() argument
2568 int *count = &ethsw->buf_count; in dpaa2_switch_refill_bp()
2574 new_count = dpaa2_switch_add_bufs(ethsw, ethsw->bpid); in dpaa2_switch_refill_bp()
2591 static int dpaa2_switch_seed_bp(struct ethsw_core *ethsw) in dpaa2_switch_seed_bp() argument
2596 count = &ethsw->buf_count; in dpaa2_switch_seed_bp()
2597 *count += dpaa2_switch_add_bufs(ethsw, ethsw->bpid); in dpaa2_switch_seed_bp()
2606 static void dpaa2_switch_drain_bp(struct ethsw_core *ethsw) in dpaa2_switch_drain_bp() argument
2612 ret = dpaa2_io_service_acquire(NULL, ethsw->bpid, in dpaa2_switch_drain_bp()
2615 dev_err(ethsw->dev, in dpaa2_switch_drain_bp()
2619 dpaa2_switch_free_bufs(ethsw, buf_array, ret); in dpaa2_switch_drain_bp()
2624 static int dpaa2_switch_setup_dpbp(struct ethsw_core *ethsw) in dpaa2_switch_setup_dpbp() argument
2627 struct device *dev = ethsw->dev; in dpaa2_switch_setup_dpbp()
2641 ethsw->dpbp_dev = dpbp_dev; in dpaa2_switch_setup_dpbp()
2643 err = dpbp_open(ethsw->mc_io, 0, dpbp_dev->obj_desc.id, in dpaa2_switch_setup_dpbp()
2650 err = dpbp_reset(ethsw->mc_io, 0, dpbp_dev->mc_handle); in dpaa2_switch_setup_dpbp()
2656 err = dpbp_enable(ethsw->mc_io, 0, dpbp_dev->mc_handle); in dpaa2_switch_setup_dpbp()
2662 err = dpbp_get_attributes(ethsw->mc_io, 0, dpbp_dev->mc_handle, in dpaa2_switch_setup_dpbp()
2674 err = dpsw_ctrl_if_set_pools(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_setup_dpbp()
2680 ethsw->bpid = dpbp_attrs.id; in dpaa2_switch_setup_dpbp()
2685 dpbp_disable(ethsw->mc_io, 0, dpbp_dev->mc_handle); in dpaa2_switch_setup_dpbp()
2688 dpbp_close(ethsw->mc_io, 0, dpbp_dev->mc_handle); in dpaa2_switch_setup_dpbp()
2694 static void dpaa2_switch_free_dpbp(struct ethsw_core *ethsw) in dpaa2_switch_free_dpbp() argument
2696 dpbp_disable(ethsw->mc_io, 0, ethsw->dpbp_dev->mc_handle); in dpaa2_switch_free_dpbp()
2697 dpbp_close(ethsw->mc_io, 0, ethsw->dpbp_dev->mc_handle); in dpaa2_switch_free_dpbp()
2698 fsl_mc_object_free(ethsw->dpbp_dev); in dpaa2_switch_free_dpbp()
2701 static int dpaa2_switch_alloc_rings(struct ethsw_core *ethsw) in dpaa2_switch_alloc_rings() argument
2706 ethsw->fq[i].store = in dpaa2_switch_alloc_rings()
2708 ethsw->dev); in dpaa2_switch_alloc_rings()
2709 if (!ethsw->fq[i].store) { in dpaa2_switch_alloc_rings()
2710 dev_err(ethsw->dev, "dpaa2_io_store_create failed\n"); in dpaa2_switch_alloc_rings()
2712 dpaa2_io_store_destroy(ethsw->fq[i].store); in dpaa2_switch_alloc_rings()
2720 static void dpaa2_switch_destroy_rings(struct ethsw_core *ethsw) in dpaa2_switch_destroy_rings() argument
2725 dpaa2_io_store_destroy(ethsw->fq[i].store); in dpaa2_switch_destroy_rings()
2741 dev_err(fq->ethsw->dev, "dpaa2_io_service_pull err %d", err); in dpaa2_switch_pull_fq()
2749 struct ethsw_core *ethsw = fq->ethsw; in dpaa2_switch_store_consume() local
2759 dev_err_once(ethsw->dev, in dpaa2_switch_store_consume()
2792 dpaa2_switch_refill_bp(fq->ethsw); in dpaa2_switch_poll()
2828 static int dpaa2_switch_setup_dpio(struct ethsw_core *ethsw) in dpaa2_switch_setup_dpio() argument
2835 nctx = &ethsw->fq[i].nctx; in dpaa2_switch_setup_dpio()
2842 nctx->id = ethsw->fq[i].fqid; in dpaa2_switch_setup_dpio()
2845 err = dpaa2_io_service_register(NULL, nctx, ethsw->dev); in dpaa2_switch_setup_dpio()
2858 err = dpsw_ctrl_if_set_queue(ethsw->mc_io, 0, in dpaa2_switch_setup_dpio()
2859 ethsw->dpsw_handle, in dpaa2_switch_setup_dpio()
2860 ethsw->fq[i].type, in dpaa2_switch_setup_dpio()
2869 dpaa2_io_service_deregister(NULL, nctx, ethsw->dev); in dpaa2_switch_setup_dpio()
2872 dpaa2_io_service_deregister(NULL, &ethsw->fq[j].nctx, in dpaa2_switch_setup_dpio()
2873 ethsw->dev); in dpaa2_switch_setup_dpio()
2878 static void dpaa2_switch_free_dpio(struct ethsw_core *ethsw) in dpaa2_switch_free_dpio() argument
2883 dpaa2_io_service_deregister(NULL, &ethsw->fq[i].nctx, in dpaa2_switch_free_dpio()
2884 ethsw->dev); in dpaa2_switch_free_dpio()
2887 static int dpaa2_switch_ctrl_if_setup(struct ethsw_core *ethsw) in dpaa2_switch_ctrl_if_setup() argument
2892 err = dpaa2_switch_setup_fqs(ethsw); in dpaa2_switch_ctrl_if_setup()
2897 err = dpaa2_switch_setup_dpbp(ethsw); in dpaa2_switch_ctrl_if_setup()
2901 err = dpaa2_switch_alloc_rings(ethsw); in dpaa2_switch_ctrl_if_setup()
2905 err = dpaa2_switch_setup_dpio(ethsw); in dpaa2_switch_ctrl_if_setup()
2909 err = dpaa2_switch_seed_bp(ethsw); in dpaa2_switch_ctrl_if_setup()
2913 err = dpsw_ctrl_if_enable(ethsw->mc_io, 0, ethsw->dpsw_handle); in dpaa2_switch_ctrl_if_setup()
2915 dev_err(ethsw->dev, "dpsw_ctrl_if_enable err %d\n", err); in dpaa2_switch_ctrl_if_setup()
2922 dpaa2_switch_drain_bp(ethsw); in dpaa2_switch_ctrl_if_setup()
2924 dpaa2_switch_free_dpio(ethsw); in dpaa2_switch_ctrl_if_setup()
2926 dpaa2_switch_destroy_rings(ethsw); in dpaa2_switch_ctrl_if_setup()
2928 dpaa2_switch_free_dpbp(ethsw); in dpaa2_switch_ctrl_if_setup()
2933 static void dpaa2_switch_remove_port(struct ethsw_core *ethsw, in dpaa2_switch_remove_port() argument
2936 struct ethsw_port_priv *port_priv = ethsw->ports[port_idx]; in dpaa2_switch_remove_port()
2942 ethsw->ports[port_idx] = NULL; in dpaa2_switch_remove_port()
2948 struct ethsw_core *ethsw = dev_get_drvdata(dev); in dpaa2_switch_init() local
2955 ethsw->dev_id = sw_dev->obj_desc.id; in dpaa2_switch_init()
2957 err = dpsw_open(ethsw->mc_io, 0, ethsw->dev_id, &ethsw->dpsw_handle); in dpaa2_switch_init()
2963 err = dpsw_get_attributes(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_init()
2964 &ethsw->sw_attr); in dpaa2_switch_init()
2970 err = dpsw_get_api_version(ethsw->mc_io, 0, in dpaa2_switch_init()
2971 &ethsw->major, in dpaa2_switch_init()
2972 &ethsw->minor); in dpaa2_switch_init()
2979 if (ethsw->major < DPSW_MIN_VER_MAJOR || in dpaa2_switch_init()
2980 (ethsw->major == DPSW_MIN_VER_MAJOR && in dpaa2_switch_init()
2981 ethsw->minor < DPSW_MIN_VER_MINOR)) { in dpaa2_switch_init()
2983 ethsw->major, ethsw->minor); in dpaa2_switch_init()
2988 if (!dpaa2_switch_supports_cpu_traffic(ethsw)) { in dpaa2_switch_init()
2993 dpaa2_switch_detect_features(ethsw); in dpaa2_switch_init()
2995 err = dpsw_reset(ethsw->mc_io, 0, ethsw->dpsw_handle); in dpaa2_switch_init()
3004 for (i = 0; i < ethsw->sw_attr.num_ifs; i++) { in dpaa2_switch_init()
3005 err = dpsw_if_disable(ethsw->mc_io, 0, ethsw->dpsw_handle, i); in dpaa2_switch_init()
3011 err = dpsw_if_set_stp(ethsw->mc_io, 0, ethsw->dpsw_handle, i, in dpaa2_switch_init()
3024 err = dpsw_vlan_remove_if_untagged(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_init()
3033 err = dpsw_if_set_tci(ethsw->mc_io, 0, ethsw->dpsw_handle, i, &tci_cfg); in dpaa2_switch_init()
3039 err = dpsw_vlan_remove_if(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_init()
3047 err = dpsw_vlan_remove(ethsw->mc_io, 0, ethsw->dpsw_handle, DEFAULT_VLAN_ID); in dpaa2_switch_init()
3053 ethsw->workqueue = alloc_ordered_workqueue("%s_%d_ordered", in dpaa2_switch_init()
3055 ethsw->sw_attr.id); in dpaa2_switch_init()
3056 if (!ethsw->workqueue) { in dpaa2_switch_init()
3061 err = dpsw_fdb_remove(ethsw->mc_io, 0, ethsw->dpsw_handle, 0); in dpaa2_switch_init()
3065 err = dpaa2_switch_ctrl_if_setup(ethsw); in dpaa2_switch_init()
3072 destroy_workqueue(ethsw->workqueue); in dpaa2_switch_init()
3075 dpsw_close(ethsw->mc_io, 0, ethsw->dpsw_handle); in dpaa2_switch_init()
3107 struct ethsw_core *ethsw = port_priv->ethsw_data; in dpaa2_switch_port_init() local
3117 err = dpsw_if_get_attributes(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_port_init()
3126 fdb_cfg.num_fdb_entries = ethsw->sw_attr.max_fdb_entries / ethsw->sw_attr.num_ifs; in dpaa2_switch_port_init()
3127 err = dpsw_fdb_add(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_port_init()
3135 fdb = dpaa2_switch_fdb_get_unused(ethsw); in dpaa2_switch_port_init()
3150 err = dpaa2_switch_fdb_set_egress_flood(ethsw, port_priv->fdb->fdb_id); in dpaa2_switch_port_init()
3156 err = dpsw_acl_add(ethsw->mc_io, 0, ethsw->dpsw_handle, in dpaa2_switch_port_init()
3163 filter_block = dpaa2_switch_filter_block_get_unused(ethsw); in dpaa2_switch_port_init()
3164 filter_block->ethsw = ethsw; in dpaa2_switch_port_init()
3182 static void dpaa2_switch_ctrl_if_teardown(struct ethsw_core *ethsw) in dpaa2_switch_ctrl_if_teardown() argument
3184 dpsw_ctrl_if_disable(ethsw->mc_io, 0, ethsw->dpsw_handle); in dpaa2_switch_ctrl_if_teardown()
3185 dpaa2_switch_free_dpio(ethsw); in dpaa2_switch_ctrl_if_teardown()
3186 dpaa2_switch_destroy_rings(ethsw); in dpaa2_switch_ctrl_if_teardown()
3187 dpaa2_switch_drain_bp(ethsw); in dpaa2_switch_ctrl_if_teardown()
3188 dpaa2_switch_free_dpbp(ethsw); in dpaa2_switch_ctrl_if_teardown()
3194 struct ethsw_core *ethsw = dev_get_drvdata(dev); in dpaa2_switch_teardown() local
3197 dpaa2_switch_ctrl_if_teardown(ethsw); in dpaa2_switch_teardown()
3199 destroy_workqueue(ethsw->workqueue); in dpaa2_switch_teardown()
3201 err = dpsw_close(ethsw->mc_io, 0, ethsw->dpsw_handle); in dpaa2_switch_teardown()
3209 struct ethsw_core *ethsw; in dpaa2_switch_remove() local
3214 ethsw = dev_get_drvdata(dev); in dpaa2_switch_remove()
3218 dpsw_disable(ethsw->mc_io, 0, ethsw->dpsw_handle); in dpaa2_switch_remove()
3220 for (i = 0; i < ethsw->sw_attr.num_ifs; i++) { in dpaa2_switch_remove()
3221 port_priv = ethsw->ports[i]; in dpaa2_switch_remove()
3223 dpaa2_switch_remove_port(ethsw, i); in dpaa2_switch_remove()
3226 kfree(ethsw->fdbs); in dpaa2_switch_remove()
3227 kfree(ethsw->filter_blocks); in dpaa2_switch_remove()
3228 kfree(ethsw->ports); in dpaa2_switch_remove()
3232 fsl_mc_portal_free(ethsw->mc_io); in dpaa2_switch_remove()
3234 kfree(ethsw); in dpaa2_switch_remove()
3241 static int dpaa2_switch_probe_port(struct ethsw_core *ethsw, in dpaa2_switch_probe_port() argument
3245 struct device *dev = ethsw->dev; in dpaa2_switch_probe_port()
3257 port_priv->ethsw_data = ethsw; in dpaa2_switch_probe_port()
3278 ethsw->ports[port_idx] = port_priv; in dpaa2_switch_probe_port()
3308 ethsw->ports[port_idx] = NULL; in dpaa2_switch_probe_port()
3316 struct ethsw_core *ethsw; in dpaa2_switch_probe() local
3320 ethsw = kzalloc(sizeof(*ethsw), GFP_KERNEL); in dpaa2_switch_probe()
3322 if (!ethsw) in dpaa2_switch_probe()
3325 ethsw->dev = dev; in dpaa2_switch_probe()
3326 ethsw->iommu_domain = iommu_get_domain_for_dev(dev); in dpaa2_switch_probe()
3327 dev_set_drvdata(dev, ethsw); in dpaa2_switch_probe()
3330 &ethsw->mc_io); in dpaa2_switch_probe()
3343 ethsw->ports = kcalloc(ethsw->sw_attr.num_ifs, sizeof(*ethsw->ports), in dpaa2_switch_probe()
3345 if (!(ethsw->ports)) { in dpaa2_switch_probe()
3350 ethsw->fdbs = kcalloc(ethsw->sw_attr.num_ifs, sizeof(*ethsw->fdbs), in dpaa2_switch_probe()
3352 if (!ethsw->fdbs) { in dpaa2_switch_probe()
3357 ethsw->filter_blocks = kcalloc(ethsw->sw_attr.num_ifs, in dpaa2_switch_probe()
3358 sizeof(*ethsw->filter_blocks), in dpaa2_switch_probe()
3360 if (!ethsw->filter_blocks) { in dpaa2_switch_probe()
3365 for (i = 0; i < ethsw->sw_attr.num_ifs; i++) { in dpaa2_switch_probe()
3366 err = dpaa2_switch_probe_port(ethsw, i); in dpaa2_switch_probe()
3376 netif_napi_add(ethsw->ports[0]->netdev, &ethsw->fq[i].napi, in dpaa2_switch_probe()
3387 ethsw->mirror_port = ethsw->sw_attr.num_ifs; in dpaa2_switch_probe()
3392 for (i = 0; i < ethsw->sw_attr.num_ifs; i++) { in dpaa2_switch_probe()
3393 err = register_netdev(ethsw->ports[i]->netdev); in dpaa2_switch_probe()
3404 unregister_netdev(ethsw->ports[i]->netdev); in dpaa2_switch_probe()
3407 dpsw_disable(ethsw->mc_io, 0, ethsw->dpsw_handle); in dpaa2_switch_probe()
3410 dpaa2_switch_remove_port(ethsw, i); in dpaa2_switch_probe()
3411 kfree(ethsw->filter_blocks); in dpaa2_switch_probe()
3413 kfree(ethsw->fdbs); in dpaa2_switch_probe()
3415 kfree(ethsw->ports); in dpaa2_switch_probe()
3421 fsl_mc_portal_free(ethsw->mc_io); in dpaa2_switch_probe()
3424 kfree(ethsw); in dpaa2_switch_probe()