felix.c (e90c9fcedc087c8ba1d34da88381838ed68bfb1c) | felix.c (21ce7f3e16fbf89faaf149cfe0f730edfc553914) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* Copyright 2019 NXP Semiconductors 3 */ 4#include <uapi/linux/if_bridge.h> 5#include <soc/mscc/ocelot_vcap.h> 6#include <soc/mscc/ocelot_qsys.h> 7#include <soc/mscc/ocelot_sys.h> 8#include <soc/mscc/ocelot_dev.h> 9#include <soc/mscc/ocelot_ana.h> | 1// SPDX-License-Identifier: GPL-2.0 2/* Copyright 2019 NXP Semiconductors 3 */ 4#include <uapi/linux/if_bridge.h> 5#include <soc/mscc/ocelot_vcap.h> 6#include <soc/mscc/ocelot_qsys.h> 7#include <soc/mscc/ocelot_sys.h> 8#include <soc/mscc/ocelot_dev.h> 9#include <soc/mscc/ocelot_ana.h> |
10#include <soc/mscc/ocelot_ptp.h> | |
11#include <soc/mscc/ocelot.h> 12#include <linux/packing.h> 13#include <linux/module.h> 14#include <linux/of_net.h> 15#include <linux/pci.h> 16#include <linux/of.h> 17#include <net/pkt_sched.h> 18#include <net/dsa.h> --- 377 unchanged lines hidden (view full) --- 396 sizeof(struct ocelot_port *), GFP_KERNEL); 397 if (!ocelot->ports) 398 return -ENOMEM; 399 400 ocelot->map = felix->info->map; 401 ocelot->stats_layout = felix->info->stats_layout; 402 ocelot->num_stats = felix->info->num_stats; 403 ocelot->shared_queue_sz = felix->info->shared_queue_sz; | 10#include <soc/mscc/ocelot.h> 11#include <linux/packing.h> 12#include <linux/module.h> 13#include <linux/of_net.h> 14#include <linux/pci.h> 15#include <linux/of.h> 16#include <net/pkt_sched.h> 17#include <net/dsa.h> --- 377 unchanged lines hidden (view full) --- 395 sizeof(struct ocelot_port *), GFP_KERNEL); 396 if (!ocelot->ports) 397 return -ENOMEM; 398 399 ocelot->map = felix->info->map; 400 ocelot->stats_layout = felix->info->stats_layout; 401 ocelot->num_stats = felix->info->num_stats; 402 ocelot->shared_queue_sz = felix->info->shared_queue_sz; |
403 ocelot->num_mact_rows = felix->info->num_mact_rows; |
|
404 ocelot->vcap_is2_keys = felix->info->vcap_is2_keys; 405 ocelot->vcap_is2_actions= felix->info->vcap_is2_actions; 406 ocelot->vcap = felix->info->vcap; 407 ocelot->ops = felix->info->ops; 408 409 port_phy_modes = kcalloc(num_phys_ports, sizeof(phy_interface_t), 410 GFP_KERNEL); 411 if (!port_phy_modes) --- 78 unchanged lines hidden (view full) --- 490 err = felix->info->mdio_bus_alloc(ocelot); 491 if (err < 0) 492 return err; 493 } 494 495 return 0; 496} 497 | 404 ocelot->vcap_is2_keys = felix->info->vcap_is2_keys; 405 ocelot->vcap_is2_actions= felix->info->vcap_is2_actions; 406 ocelot->vcap = felix->info->vcap; 407 ocelot->ops = felix->info->ops; 408 409 port_phy_modes = kcalloc(num_phys_ports, sizeof(phy_interface_t), 410 GFP_KERNEL); 411 if (!port_phy_modes) --- 78 unchanged lines hidden (view full) --- 490 err = felix->info->mdio_bus_alloc(ocelot); 491 if (err < 0) 492 return err; 493 } 494 495 return 0; 496} 497 |
498static struct ptp_clock_info ocelot_ptp_clock_info = { 499 .owner = THIS_MODULE, 500 .name = "felix ptp", 501 .max_adj = 0x7fffffff, 502 .n_alarm = 0, 503 .n_ext_ts = 0, 504 .n_per_out = OCELOT_PTP_PINS_NUM, 505 .n_pins = OCELOT_PTP_PINS_NUM, 506 .pps = 0, 507 .gettime64 = ocelot_ptp_gettime64, 508 .settime64 = ocelot_ptp_settime64, 509 .adjtime = ocelot_ptp_adjtime, 510 .adjfine = ocelot_ptp_adjfine, 511 .verify = ocelot_ptp_verify, 512 .enable = ocelot_ptp_enable, 513}; 514 | |
515/* Hardware initialization done here so that we can allocate structures with 516 * devm without fear of dsa_register_switch returning -EPROBE_DEFER and causing 517 * us to allocate structures twice (leak memory) and map PCI memory twice 518 * (which will not work). 519 */ 520static int felix_setup(struct dsa_switch *ds) 521{ 522 struct ocelot *ocelot = ds->priv; 523 struct felix *felix = ocelot_to_felix(ocelot); 524 int port, err; | 498/* Hardware initialization done here so that we can allocate structures with 499 * devm without fear of dsa_register_switch returning -EPROBE_DEFER and causing 500 * us to allocate structures twice (leak memory) and map PCI memory twice 501 * (which will not work). 502 */ 503static int felix_setup(struct dsa_switch *ds) 504{ 505 struct ocelot *ocelot = ds->priv; 506 struct felix *felix = ocelot_to_felix(ocelot); 507 int port, err; |
525 int tc; | |
526 527 err = felix_init_structs(felix, ds->num_ports); 528 if (err) 529 return err; 530 531 ocelot_init(ocelot); | 508 509 err = felix_init_structs(felix, ds->num_ports); 510 if (err) 511 return err; 512 513 ocelot_init(ocelot); |
532 if (ocelot->ptp) { 533 err = ocelot_init_timestamp(ocelot, &ocelot_ptp_clock_info); 534 if (err) { 535 dev_err(ocelot->dev, 536 "Timestamp initialization failed\n"); 537 ocelot->ptp = 0; 538 } 539 } | |
540 541 for (port = 0; port < ds->num_ports; port++) { 542 ocelot_init_port(ocelot, port); 543 544 /* Bring up the CPU port module and configure the NPI port */ 545 if (dsa_is_cpu_port(ds, port)) 546 ocelot_configure_cpu(ocelot, port, 547 OCELOT_TAG_PREFIX_NONE, 548 OCELOT_TAG_PREFIX_LONG); 549 } 550 551 /* Include the CPU port module in the forwarding mask for unknown 552 * unicast - the hardware default value for ANA_FLOODING_FLD_UNICAST 553 * excludes BIT(ocelot->num_phys_ports), and so does ocelot_init, since 554 * Ocelot relies on whitelisting MAC addresses towards PGID_CPU. 555 */ 556 ocelot_write_rix(ocelot, 557 ANA_PGID_PGID_PGID(GENMASK(ocelot->num_phys_ports, 0)), 558 ANA_PGID_PGID, PGID_UC); | 514 515 for (port = 0; port < ds->num_ports; port++) { 516 ocelot_init_port(ocelot, port); 517 518 /* Bring up the CPU port module and configure the NPI port */ 519 if (dsa_is_cpu_port(ds, port)) 520 ocelot_configure_cpu(ocelot, port, 521 OCELOT_TAG_PREFIX_NONE, 522 OCELOT_TAG_PREFIX_LONG); 523 } 524 525 /* Include the CPU port module in the forwarding mask for unknown 526 * unicast - the hardware default value for ANA_FLOODING_FLD_UNICAST 527 * excludes BIT(ocelot->num_phys_ports), and so does ocelot_init, since 528 * Ocelot relies on whitelisting MAC addresses towards PGID_CPU. 529 */ 530 ocelot_write_rix(ocelot, 531 ANA_PGID_PGID_PGID(GENMASK(ocelot->num_phys_ports, 0)), 532 ANA_PGID_PGID, PGID_UC); |
559 /* Setup the per-traffic class flooding PGIDs */ 560 for (tc = 0; tc < FELIX_NUM_TC; tc++) 561 ocelot_write_rix(ocelot, ANA_FLOODING_FLD_MULTICAST(PGID_MC) | 562 ANA_FLOODING_FLD_BROADCAST(PGID_MC) | 563 ANA_FLOODING_FLD_UNICAST(PGID_UC), 564 ANA_FLOODING, tc); | |
565 566 ds->mtu_enforcement_ingress = true; 567 /* It looks like the MAC/PCS interrupt register - PM0_IEVENT (0x8040) 568 * isn't instantiated for the Felix PF. 569 * In-band AN may take a few ms to complete, so we need to poll. 570 */ 571 ds->pcs_poll = true; 572 573 return 0; 574} 575 576static void felix_teardown(struct dsa_switch *ds) 577{ 578 struct ocelot *ocelot = ds->priv; 579 struct felix *felix = ocelot_to_felix(ocelot); 580 581 if (felix->info->mdio_bus_free) 582 felix->info->mdio_bus_free(ocelot); 583 | 533 534 ds->mtu_enforcement_ingress = true; 535 /* It looks like the MAC/PCS interrupt register - PM0_IEVENT (0x8040) 536 * isn't instantiated for the Felix PF. 537 * In-band AN may take a few ms to complete, so we need to poll. 538 */ 539 ds->pcs_poll = true; 540 541 return 0; 542} 543 544static void felix_teardown(struct dsa_switch *ds) 545{ 546 struct ocelot *ocelot = ds->priv; 547 struct felix *felix = ocelot_to_felix(ocelot); 548 549 if (felix->info->mdio_bus_free) 550 felix->info->mdio_bus_free(ocelot); 551 |
584 ocelot_deinit_timestamp(ocelot); | |
585 /* stop workqueue thread */ 586 ocelot_deinit(ocelot); 587} 588 589static int felix_hwtstamp_get(struct dsa_switch *ds, int port, 590 struct ifreq *ifr) 591{ 592 struct ocelot *ocelot = ds->priv; --- 175 unchanged lines hidden (view full) --- 768 const struct pci_device_id *id) 769{ 770 enum felix_instance instance = id->driver_data; 771 struct dsa_switch *ds; 772 struct ocelot *ocelot; 773 struct felix *felix; 774 int err; 775 | 552 /* stop workqueue thread */ 553 ocelot_deinit(ocelot); 554} 555 556static int felix_hwtstamp_get(struct dsa_switch *ds, int port, 557 struct ifreq *ifr) 558{ 559 struct ocelot *ocelot = ds->priv; --- 175 unchanged lines hidden (view full) --- 735 const struct pci_device_id *id) 736{ 737 enum felix_instance instance = id->driver_data; 738 struct dsa_switch *ds; 739 struct ocelot *ocelot; 740 struct felix *felix; 741 int err; 742 |
776 if (pdev->dev.of_node && !of_device_is_available(pdev->dev.of_node)) { 777 dev_info(&pdev->dev, "device is disabled, skipping\n"); 778 return -ENODEV; 779 } 780 | |
781 err = pci_enable_device(pdev); 782 if (err) { 783 dev_err(&pdev->dev, "device enable failed\n"); 784 goto err_pci_enable; 785 } 786 787 /* set up for high or low dma */ 788 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); --- 102 unchanged lines hidden --- | 743 err = pci_enable_device(pdev); 744 if (err) { 745 dev_err(&pdev->dev, "device enable failed\n"); 746 goto err_pci_enable; 747 } 748 749 /* set up for high or low dma */ 750 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); --- 102 unchanged lines hidden --- |