Lines Matching +full:enetc +full:- +full:mdio

1 // SPDX-License-Identifier: (GPL-2.0 OR MIT)
3 * Copyright 2018-2019 NXP
15 #include <linux/pcs-lynx.h>
18 #include <linux/mdio.h>
554 /* Port MAC 0 Internal MDIO bus through which the SerDes acting as an
663 /* Layer-3 Information */
669 /* Layer-4 Information */
900 /* soft-reset the switch core */ in vsc9959_reset()
906 dev_err(ocelot->dev, "timeout: switch core reset\n"); in vsc9959_reset()
916 dev_err(ocelot->dev, "timeout: switch sram init\n"); in vsc9959_reset()
928 * Bit 7-0: Value to be multiplied with unit
958 struct pci_dev *pdev = to_pci_dev(ocelot->dev); in vsc9959_mdio_bus_alloc()
961 struct device *dev = ocelot->dev; in vsc9959_mdio_bus_alloc()
970 felix->pcs = devm_kcalloc(dev, felix->info->num_ports, in vsc9959_mdio_bus_alloc()
973 if (!felix->pcs) { in vsc9959_mdio_bus_alloc()
975 return -ENOMEM; in vsc9959_mdio_bus_alloc()
990 dev_err(dev, "failed to allocate ENETC HW structure\n"); in vsc9959_mdio_bus_alloc()
996 return -ENOMEM; in vsc9959_mdio_bus_alloc()
998 bus->name = "VSC9959 internal MDIO bus"; in vsc9959_mdio_bus_alloc()
999 bus->read = enetc_mdio_read_c22; in vsc9959_mdio_bus_alloc()
1000 bus->write = enetc_mdio_write_c22; in vsc9959_mdio_bus_alloc()
1001 bus->read_c45 = enetc_mdio_read_c45; in vsc9959_mdio_bus_alloc()
1002 bus->write_c45 = enetc_mdio_write_c45; in vsc9959_mdio_bus_alloc()
1003 bus->parent = dev; in vsc9959_mdio_bus_alloc()
1004 mdio_priv = bus->priv; in vsc9959_mdio_bus_alloc()
1005 mdio_priv->hw = hw; in vsc9959_mdio_bus_alloc()
1009 mdio_priv->mdio_base = 0; in vsc9959_mdio_bus_alloc()
1010 snprintf(bus->id, MII_BUS_ID_SIZE, "%s-imdio", dev_name(dev)); in vsc9959_mdio_bus_alloc()
1015 dev_err(dev, "failed to register MDIO bus\n"); in vsc9959_mdio_bus_alloc()
1020 felix->imdio = bus; in vsc9959_mdio_bus_alloc()
1022 for (port = 0; port < felix->info->num_ports; port++) { in vsc9959_mdio_bus_alloc()
1023 struct ocelot_port *ocelot_port = ocelot->ports[port]; in vsc9959_mdio_bus_alloc()
1026 if (dsa_is_unused_port(felix->ds, port)) in vsc9959_mdio_bus_alloc()
1029 if (ocelot_port->phy_mode == PHY_INTERFACE_MODE_INTERNAL) in vsc9959_mdio_bus_alloc()
1032 phylink_pcs = lynx_pcs_create_mdiodev(felix->imdio, port); in vsc9959_mdio_bus_alloc()
1036 felix->pcs[port] = phylink_pcs; in vsc9959_mdio_bus_alloc()
1038 dev_info(dev, "Found PCS at internal MDIO address %d\n", port); in vsc9959_mdio_bus_alloc()
1049 for (port = 0; port < ocelot->num_phys_ports; port++) { in vsc9959_mdio_bus_free()
1050 struct phylink_pcs *phylink_pcs = felix->pcs[port]; in vsc9959_mdio_bus_free()
1055 mdiobus_unregister(felix->imdio); in vsc9959_mdio_bus_free()
1056 mdiobus_free(felix->imdio); in vsc9959_mdio_bus_free()
1076 return (gate_len_ns - VSC9959_TAS_MIN_GATE_LEN_NS) * PSEC_PER_NSEC; in vsc9959_tas_remaining_gate_len_ps()
1080 * of a cyclic tc-taprio schedule. If a gate is always open, the duration is
1101 n = taprio->num_entries; in vsc9959_tas_min_gate_lengths()
1111 entry = &taprio->entries[i % n]; in vsc9959_tas_min_gate_lengths()
1114 if (entry->gate_mask & BIT(tc)) { in vsc9959_tas_min_gate_lengths()
1115 gate_len[tc] += entry->interval; in vsc9959_tas_min_gate_lengths()
1201 if (!taprio || !taprio->max_sdu[tc]) in vsc9959_tas_tc_max_sdu()
1204 return taprio->max_sdu[tc] + ETH_HLEN + 2 * VLAN_HLEN + ETH_FCS_LEN; in vsc9959_tas_tc_max_sdu()
1215 struct ocelot_port *ocelot_port = ocelot->ports[port]; in vsc9959_tas_guard_bands_update()
1216 struct ocelot_mm_state *mm = &ocelot->mm[port]; in vsc9959_tas_guard_bands_update()
1226 lockdep_assert_held(&ocelot->fwd_domain_lock); in vsc9959_tas_guard_bands_update()
1228 taprio = ocelot_port->taprio; in vsc9959_tas_guard_bands_update()
1270 dev_dbg(ocelot->dev, in vsc9959_tas_guard_bands_update()
1285 if ((mm->active_preemptible_tcs & BIT(tc)) ? in vsc9959_tas_guard_bands_update()
1292 dev_dbg(ocelot->dev, in vsc9959_tas_guard_bands_update()
1303 * per-tc static guard band lengths, so it reduces the in vsc9959_tas_guard_bands_update()
1321 max_sdu -= 20; in vsc9959_tas_guard_bands_update()
1326 dev_info(ocelot->dev, in vsc9959_tas_guard_bands_update()
1340 ocelot->ops->cut_through_fwd(ocelot); in vsc9959_tas_guard_bands_update()
1346 struct ocelot_port *ocelot_port = ocelot->ports[port]; in vsc9959_sched_speed_set()
1367 mutex_lock(&ocelot->fwd_domain_lock); in vsc9959_sched_speed_set()
1374 if (ocelot_port->taprio) in vsc9959_sched_speed_set()
1377 mutex_unlock(&ocelot->fwd_domain_lock); in vsc9959_sched_speed_set()
1388 ocelot_ptp_gettime64(&ocelot->ptp_info, &ts); in vsc9959_new_base_time()
1393 u64 nr_of_cycles = current_time - base_time; in vsc9959_new_base_time()
1412 QSYS_GCL_CFG_REG_1_GATE_STATE(entry->gate_mask), in vsc9959_tas_gcl_set()
1414 ocelot_write(ocelot, entry->interval, QSYS_GCL_CFG_REG_2); in vsc9959_tas_gcl_set()
1420 struct ocelot_port *ocelot_port = ocelot->ports[port]; in vsc9959_qos_port_tas_set()
1425 mutex_lock(&ocelot->fwd_domain_lock); in vsc9959_qos_port_tas_set()
1427 if (taprio->cmd == TAPRIO_CMD_DESTROY) { in vsc9959_qos_port_tas_set()
1428 ocelot_port_mqprio(ocelot, port, &taprio->mqprio); in vsc9959_qos_port_tas_set()
1432 taprio_offload_free(ocelot_port->taprio); in vsc9959_qos_port_tas_set()
1433 ocelot_port->taprio = NULL; in vsc9959_qos_port_tas_set()
1437 mutex_unlock(&ocelot->fwd_domain_lock); in vsc9959_qos_port_tas_set()
1439 } else if (taprio->cmd != TAPRIO_CMD_REPLACE) { in vsc9959_qos_port_tas_set()
1440 ret = -EOPNOTSUPP; in vsc9959_qos_port_tas_set()
1444 ret = ocelot_port_mqprio(ocelot, port, &taprio->mqprio); in vsc9959_qos_port_tas_set()
1448 if (taprio->cycle_time > NSEC_PER_SEC || in vsc9959_qos_port_tas_set()
1449 taprio->cycle_time_extension >= NSEC_PER_SEC) { in vsc9959_qos_port_tas_set()
1450 ret = -EINVAL; in vsc9959_qos_port_tas_set()
1454 if (taprio->num_entries > VSC9959_TAS_GCL_ENTRY_MAX) { in vsc9959_qos_port_tas_set()
1455 ret = -ERANGE; in vsc9959_qos_port_tas_set()
1474 /* Hardware errata - Admin config could not be overwritten if in vsc9959_qos_port_tas_set()
1481 ret = -EBUSY; in vsc9959_qos_port_tas_set()
1495 vsc9959_new_base_time(ocelot, taprio->base_time, in vsc9959_qos_port_tas_set()
1496 taprio->cycle_time, &base_ts); in vsc9959_qos_port_tas_set()
1502 QSYS_PARAM_CFG_REG_3_LIST_LENGTH(taprio->num_entries), in vsc9959_qos_port_tas_set()
1504 ocelot_write(ocelot, taprio->cycle_time, QSYS_PARAM_CFG_REG_4); in vsc9959_qos_port_tas_set()
1505 ocelot_write(ocelot, taprio->cycle_time_extension, QSYS_PARAM_CFG_REG_5); in vsc9959_qos_port_tas_set()
1507 for (i = 0; i < taprio->num_entries; i++) in vsc9959_qos_port_tas_set()
1508 vsc9959_tas_gcl_set(ocelot, i, &taprio->entries[i]); in vsc9959_qos_port_tas_set()
1520 ocelot_port->taprio = taprio_offload_get(taprio); in vsc9959_qos_port_tas_set()
1523 mutex_unlock(&ocelot->fwd_domain_lock); in vsc9959_qos_port_tas_set()
1528 taprio->mqprio.qopt.num_tc = 0; in vsc9959_qos_port_tas_set()
1529 ocelot_port_mqprio(ocelot, port, &taprio->mqprio); in vsc9959_qos_port_tas_set()
1531 mutex_unlock(&ocelot->fwd_domain_lock); in vsc9959_qos_port_tas_set()
1544 mutex_lock(&ocelot->fwd_domain_lock); in vsc9959_tas_clock_adjust()
1546 for (port = 0; port < ocelot->num_phys_ports; port++) { in vsc9959_tas_clock_adjust()
1547 ocelot_port = ocelot->ports[port]; in vsc9959_tas_clock_adjust()
1548 taprio = ocelot_port->taprio; in vsc9959_tas_clock_adjust()
1557 /* Disable time-aware shaper */ in vsc9959_tas_clock_adjust()
1561 vsc9959_new_base_time(ocelot, taprio->base_time, in vsc9959_tas_clock_adjust()
1562 taprio->cycle_time, &base_ts); in vsc9959_tas_clock_adjust()
1577 /* Re-enable time-aware shaper */ in vsc9959_tas_clock_adjust()
1582 mutex_unlock(&ocelot->fwd_domain_lock); in vsc9959_tas_clock_adjust()
1588 struct ocelot *ocelot = ds->priv; in vsc9959_qos_port_cbs_set()
1589 int port_ix = port * 8 + cbs_qopt->queue; in vsc9959_qos_port_cbs_set()
1592 if (cbs_qopt->queue >= ds->num_tx_queues) in vsc9959_qos_port_cbs_set()
1593 return -EINVAL; in vsc9959_qos_port_cbs_set()
1595 if (!cbs_qopt->enable) { in vsc9959_qos_port_cbs_set()
1607 rate = DIV_ROUND_UP(cbs_qopt->idleslope, 100); in vsc9959_qos_port_cbs_set()
1611 burst = DIV_ROUND_UP(cbs_qopt->hicredit, 4096); in vsc9959_qos_port_cbs_set()
1633 switch (base->type) { in vsc9959_qos_query_caps()
1635 struct tc_mqprio_caps *caps = base->caps; in vsc9959_qos_query_caps()
1637 caps->validate_queue_counts = true; in vsc9959_qos_query_caps()
1642 struct tc_taprio_caps *caps = base->caps; in vsc9959_qos_query_caps()
1644 caps->supports_queue_max_sdu = true; in vsc9959_qos_query_caps()
1649 return -EOPNOTSUPP; in vsc9959_qos_query_caps()
1658 mutex_lock(&ocelot->fwd_domain_lock); in vsc9959_qos_port_mqprio()
1660 mutex_unlock(&ocelot->fwd_domain_lock); in vsc9959_qos_port_mqprio()
1669 struct ocelot *ocelot = ds->priv; in vsc9959_port_setup_tc()
1681 return -EOPNOTSUPP; in vsc9959_port_setup_tc()
1752 struct flow_dissector *dissector = rule->match.dissector; in vsc9959_stream_identify()
1754 if (dissector->used_keys & in vsc9959_stream_identify()
1759 return -EOPNOTSUPP; in vsc9959_stream_identify()
1761 if (flow_rule_match_has_control_flags(rule, f->common.extack)) in vsc9959_stream_identify()
1762 return -EOPNOTSUPP; in vsc9959_stream_identify()
1768 ether_addr_copy(stream->dmac, match.key->dst); in vsc9959_stream_identify()
1769 if (!is_zero_ether_addr(match.mask->src)) in vsc9959_stream_identify()
1770 return -EOPNOTSUPP; in vsc9959_stream_identify()
1772 return -EOPNOTSUPP; in vsc9959_stream_identify()
1779 if (match.mask->vlan_priority) in vsc9959_stream_identify()
1780 stream->prio = match.key->vlan_priority; in vsc9959_stream_identify()
1782 stream->prio = -1; in vsc9959_stream_identify()
1784 if (!match.mask->vlan_id) in vsc9959_stream_identify()
1785 return -EOPNOTSUPP; in vsc9959_stream_identify()
1786 stream->vid = match.key->vlan_id; in vsc9959_stream_identify()
1788 return -EOPNOTSUPP; in vsc9959_stream_identify()
1791 stream->id = f->cookie; in vsc9959_stream_identify()
1805 ether_addr_copy(mac, stream->dmac); in vsc9959_mact_stream_set()
1806 vid = stream->vid; in vsc9959_mact_stream_set()
1815 return -EOPNOTSUPP; in vsc9959_mact_stream_set()
1818 if ((stream->sfid_valid || stream->ssid_valid) && in vsc9959_mact_stream_set()
1822 sfid = stream->sfid_valid ? stream->sfid : -1; in vsc9959_mact_stream_set()
1823 ssid = stream->ssid_valid ? stream->ssid : -1; in vsc9959_mact_stream_set()
1838 if (ether_addr_equal(tmp->dmac, stream->dmac) && in vsc9959_stream_table_lookup()
1839 tmp->vid == stream->vid) in vsc9959_stream_table_lookup()
1855 return -ENOMEM; in vsc9959_stream_table_add()
1857 if (!stream->dummy) { in vsc9959_stream_table_add()
1865 list_add_tail(&stream_entry->list, stream_list); in vsc9959_stream_table_add()
1876 if (tmp->id == id) in vsc9959_stream_table_get()
1885 if (!stream->dummy) in vsc9959_stream_table_del()
1888 list_del(&stream->list); in vsc9959_stream_table_del()
1902 if (sfi->index > VSC9959_PSFP_SFID_MAX) in vsc9959_psfp_sfi_set()
1903 return -EINVAL; in vsc9959_psfp_sfi_set()
1905 if (!sfi->enable) { in vsc9959_psfp_sfi_set()
1906 ocelot_write(ocelot, ANA_TABLES_SFIDTIDX_SFID_INDEX(sfi->index), in vsc9959_psfp_sfi_set()
1917 if (sfi->sgid > VSC9959_PSFP_GATE_ID_MAX || in vsc9959_psfp_sfi_set()
1918 sfi->fmid > VSC9959_PSFP_POLICER_MAX) in vsc9959_psfp_sfi_set()
1919 return -EINVAL; in vsc9959_psfp_sfi_set()
1922 (sfi->sg_valid ? ANA_TABLES_SFIDTIDX_SGID_VALID : 0) | in vsc9959_psfp_sfi_set()
1923 ANA_TABLES_SFIDTIDX_SGID(sfi->sgid) | in vsc9959_psfp_sfi_set()
1924 (sfi->fm_valid ? ANA_TABLES_SFIDTIDX_POL_ENA : 0) | in vsc9959_psfp_sfi_set()
1925 ANA_TABLES_SFIDTIDX_POL_IDX(sfi->fmid) | in vsc9959_psfp_sfi_set()
1926 ANA_TABLES_SFIDTIDX_SFID_INDEX(sfi->index), in vsc9959_psfp_sfi_set()
1930 (sfi->prio_valid ? ANA_TABLES_SFIDACCESS_IGR_PRIO_MATCH_ENA : 0) | in vsc9959_psfp_sfi_set()
1931 ANA_TABLES_SFIDACCESS_IGR_PRIO(sfi->prio) | in vsc9959_psfp_sfi_set()
1932 ANA_TABLES_SFIDACCESS_MAX_SDU_LEN(sfi->maxsdu) | in vsc9959_psfp_sfi_set()
1974 return -ENOMEM; in vsc9959_psfp_sfi_list_add()
1976 refcount_set(&sfi_entry->refcount, 1); in vsc9959_psfp_sfi_list_add()
1984 vsc9959_psfp_sfidmask_set(ocelot, sfi->index, sfi->portmask); in vsc9959_psfp_sfi_list_add()
1986 list_add(&sfi_entry->list, pos); in vsc9959_psfp_sfi_list_add()
1999 psfp = &ocelot->psfp; in vsc9959_psfp_sfi_table_add()
2000 last = &psfp->sfi_list; in vsc9959_psfp_sfi_table_add()
2002 list_for_each_safe(pos, q, &psfp->sfi_list) { in vsc9959_psfp_sfi_table_add()
2004 if (sfi->sg_valid == tmp->sg_valid && in vsc9959_psfp_sfi_table_add()
2005 sfi->fm_valid == tmp->fm_valid && in vsc9959_psfp_sfi_table_add()
2006 sfi->portmask == tmp->portmask && in vsc9959_psfp_sfi_table_add()
2007 tmp->sgid == sfi->sgid && in vsc9959_psfp_sfi_table_add()
2008 tmp->fmid == sfi->fmid) { in vsc9959_psfp_sfi_table_add()
2009 sfi->index = tmp->index; in vsc9959_psfp_sfi_table_add()
2010 refcount_inc(&tmp->refcount); in vsc9959_psfp_sfi_table_add()
2014 if (tmp->index == insert) { in vsc9959_psfp_sfi_table_add()
2019 sfi->index = insert; in vsc9959_psfp_sfi_table_add()
2034 psfp = &ocelot->psfp; in vsc9959_psfp_sfi_table_add2()
2035 last = &psfp->sfi_list; in vsc9959_psfp_sfi_table_add2()
2037 list_for_each_safe(pos, q, &psfp->sfi_list) { in vsc9959_psfp_sfi_table_add2()
2040 if (tmp->index >= insert + 2) in vsc9959_psfp_sfi_table_add2()
2043 insert = tmp->index + 1; in vsc9959_psfp_sfi_table_add2()
2046 sfi->index = insert; in vsc9959_psfp_sfi_table_add2()
2052 sfi2->index = insert + 1; in vsc9959_psfp_sfi_table_add2()
2054 return vsc9959_psfp_sfi_list_add(ocelot, sfi2, last->next); in vsc9959_psfp_sfi_table_add2()
2063 if (tmp->index == index) in vsc9959_psfp_sfi_table_get()
2075 psfp = &ocelot->psfp; in vsc9959_psfp_sfi_table_del()
2077 list_for_each_entry_safe(tmp, n, &psfp->sfi_list, list) in vsc9959_psfp_sfi_table_del()
2078 if (tmp->index == index) { in vsc9959_psfp_sfi_table_del()
2079 z = refcount_dec_and_test(&tmp->refcount); in vsc9959_psfp_sfi_table_del()
2081 tmp->enable = 0; in vsc9959_psfp_sfi_table_del()
2083 list_del(&tmp->list); in vsc9959_psfp_sfi_table_del()
2093 sgi->index = entry->hw_index; in vsc9959_psfp_parse_gate()
2094 sgi->ipv_valid = (entry->gate.prio < 0) ? 0 : 1; in vsc9959_psfp_parse_gate()
2095 sgi->init_ipv = (sgi->ipv_valid) ? entry->gate.prio : 0; in vsc9959_psfp_parse_gate()
2096 sgi->basetime = entry->gate.basetime; in vsc9959_psfp_parse_gate()
2097 sgi->cycletime = entry->gate.cycletime; in vsc9959_psfp_parse_gate()
2098 sgi->num_entries = entry->gate.num_entries; in vsc9959_psfp_parse_gate()
2099 sgi->enable = 1; in vsc9959_psfp_parse_gate()
2101 memcpy(sgi->entries, entry->gate.entries, in vsc9959_psfp_parse_gate()
2102 entry->gate.num_entries * sizeof(struct action_gate_entry)); in vsc9959_psfp_parse_gate()
2119 if (sgi->index > VSC9959_PSFP_GATE_ID_MAX) in vsc9959_psfp_sgi_set()
2120 return -EINVAL; in vsc9959_psfp_sgi_set()
2122 ocelot_write(ocelot, ANA_SG_ACCESS_CTRL_SGID(sgi->index), in vsc9959_psfp_sgi_set()
2125 if (!sgi->enable) { in vsc9959_psfp_sgi_set()
2134 if (sgi->cycletime < VSC9959_PSFP_GATE_CYCLETIME_MIN || in vsc9959_psfp_sgi_set()
2135 sgi->cycletime > NSEC_PER_SEC) in vsc9959_psfp_sgi_set()
2136 return -EINVAL; in vsc9959_psfp_sgi_set()
2138 if (sgi->num_entries > VSC9959_PSFP_GATE_LIST_NUM) in vsc9959_psfp_sgi_set()
2139 return -EINVAL; in vsc9959_psfp_sgi_set()
2141 vsc9959_new_base_time(ocelot, sgi->basetime, sgi->cycletime, &base_ts); in vsc9959_psfp_sgi_set()
2148 (sgi->ipv_valid ? ANA_SG_CONFIG_REG_3_IPV_VALID : 0) | in vsc9959_psfp_sgi_set()
2149 ANA_SG_CONFIG_REG_3_INIT_IPV(sgi->init_ipv) | in vsc9959_psfp_sgi_set()
2151 ANA_SG_CONFIG_REG_3_LIST_LENGTH(sgi->num_entries) | in vsc9959_psfp_sgi_set()
2156 ocelot_write(ocelot, sgi->cycletime, ANA_SG_CONFIG_REG_4); in vsc9959_psfp_sgi_set()
2158 e = sgi->entries; in vsc9959_psfp_sgi_set()
2159 for (i = 0; i < sgi->num_entries; i++) { in vsc9959_psfp_sgi_set()
2187 psfp = &ocelot->psfp; in vsc9959_psfp_sgi_table_add()
2189 list_for_each_entry(tmp, &psfp->sgi_list, list) in vsc9959_psfp_sgi_table_add()
2190 if (tmp->index == sgi->index) { in vsc9959_psfp_sgi_table_add()
2191 refcount_inc(&tmp->refcount); in vsc9959_psfp_sgi_table_add()
2197 return -ENOMEM; in vsc9959_psfp_sgi_table_add()
2205 tmp->index = sgi->index; in vsc9959_psfp_sgi_table_add()
2206 refcount_set(&tmp->refcount, 1); in vsc9959_psfp_sgi_table_add()
2207 list_add_tail(&tmp->list, &psfp->sgi_list); in vsc9959_psfp_sgi_table_add()
2220 psfp = &ocelot->psfp; in vsc9959_psfp_sgi_table_del()
2222 list_for_each_entry_safe(tmp, n, &psfp->sgi_list, list) in vsc9959_psfp_sgi_table_del()
2223 if (tmp->index == index) { in vsc9959_psfp_sgi_table_del()
2224 z = refcount_dec_and_test(&tmp->refcount); in vsc9959_psfp_sgi_table_del()
2229 list_del(&tmp->list); in vsc9959_psfp_sgi_table_del()
2239 struct netlink_ext_ack *extack = f->common.extack; in vsc9959_psfp_filter_add()
2252 psfp = &ocelot->psfp; in vsc9959_psfp_filter_add()
2260 mutex_lock(&psfp->lock); in vsc9959_psfp_filter_add()
2262 flow_action_for_each(i, a, &f->rule->action) { in vsc9959_psfp_filter_add()
2263 switch (a->id) { in vsc9959_psfp_filter_add()
2265 size = struct_size(sgi, entries, a->gate.num_entries); in vsc9959_psfp_filter_add()
2268 ret = -ENOMEM; in vsc9959_psfp_filter_add()
2278 sfi.sgid = sgi->index; in vsc9959_psfp_filter_add()
2282 index = a->hw_index + VSC9959_PSFP_POLICER_BASE; in vsc9959_psfp_filter_add()
2284 ret = -EINVAL; in vsc9959_psfp_filter_add()
2288 rate = a->police.rate_bytes_ps; in vsc9959_psfp_filter_add()
2289 burst = rate * PSCHED_NS2TICKS(a->police.burst); in vsc9959_psfp_filter_add()
2300 sfi.maxsdu = a->police.mtu; in vsc9959_psfp_filter_add()
2303 mutex_unlock(&psfp->lock); in vsc9959_psfp_filter_add()
2304 return -EOPNOTSUPP; in vsc9959_psfp_filter_add()
2317 stream_entry = vsc9959_stream_table_lookup(&psfp->stream_list, &stream); in vsc9959_psfp_filter_add()
2319 if (stream_entry->ports & BIT(port)) { in vsc9959_psfp_filter_add()
2322 ret = -EEXIST; in vsc9959_psfp_filter_add()
2326 if (stream_entry->ports != BIT(stream_entry->port)) { in vsc9959_psfp_filter_add()
2329 ret = -EEXIST; in vsc9959_psfp_filter_add()
2333 stream_entry->ports |= BIT(port); in vsc9959_psfp_filter_add()
2334 stream.ports = stream_entry->ports; in vsc9959_psfp_filter_add()
2336 sfi_entry = vsc9959_psfp_sfi_table_get(&psfp->sfi_list, in vsc9959_psfp_filter_add()
2337 stream_entry->sfid); in vsc9959_psfp_filter_add()
2340 vsc9959_psfp_sfi_table_del(ocelot, stream_entry->sfid); in vsc9959_psfp_filter_add()
2342 old_sfi.portmask = stream_entry->ports; in vsc9959_psfp_filter_add()
2345 if (stream_entry->port > port) { in vsc9959_psfp_filter_add()
2348 stream_entry->dummy = true; in vsc9959_psfp_filter_add()
2357 stream_entry->sfid = old_sfi.index; in vsc9959_psfp_filter_add()
2366 ret = vsc9959_stream_table_add(ocelot, &psfp->stream_list, in vsc9959_psfp_filter_add()
2373 mutex_unlock(&psfp->lock); in vsc9959_psfp_filter_add()
2384 mutex_unlock(&psfp->lock); in vsc9959_psfp_filter_add()
2393 struct ocelot_psfp_list *psfp = &ocelot->psfp; in vsc9959_psfp_filter_del()
2396 mutex_lock(&psfp->lock); in vsc9959_psfp_filter_del()
2398 stream = vsc9959_stream_table_get(&psfp->stream_list, f->cookie); in vsc9959_psfp_filter_del()
2400 mutex_unlock(&psfp->lock); in vsc9959_psfp_filter_del()
2401 return -ENOMEM; in vsc9959_psfp_filter_del()
2404 sfi = vsc9959_psfp_sfi_table_get(&psfp->sfi_list, stream->sfid); in vsc9959_psfp_filter_del()
2406 mutex_unlock(&psfp->lock); in vsc9959_psfp_filter_del()
2407 return -ENOMEM; in vsc9959_psfp_filter_del()
2410 if (sfi->sg_valid) in vsc9959_psfp_filter_del()
2411 vsc9959_psfp_sgi_table_del(ocelot, sfi->sgid); in vsc9959_psfp_filter_del()
2413 if (sfi->fm_valid) in vsc9959_psfp_filter_del()
2414 ocelot_vcap_policer_del(ocelot, sfi->fmid); in vsc9959_psfp_filter_del()
2416 vsc9959_psfp_sfi_table_del(ocelot, stream->sfid); in vsc9959_psfp_filter_del()
2420 stream->sfid_valid = 0; in vsc9959_psfp_filter_del()
2423 stream_entry = vsc9959_stream_table_lookup(&psfp->stream_list, &tmp); in vsc9959_psfp_filter_del()
2425 stream_entry->ports = BIT(stream_entry->port); in vsc9959_psfp_filter_del()
2426 if (stream_entry->dummy) { in vsc9959_psfp_filter_del()
2427 stream_entry->dummy = false; in vsc9959_psfp_filter_del()
2430 vsc9959_psfp_sfidmask_set(ocelot, stream_entry->sfid, in vsc9959_psfp_filter_del()
2431 stream_entry->ports); in vsc9959_psfp_filter_del()
2434 mutex_unlock(&psfp->lock); in vsc9959_psfp_filter_del()
2442 struct felix_stream_filter_counters *s = &sfi->stats; in vsc9959_update_sfid_stats()
2444 u32 sfid = sfi->index; in vsc9959_update_sfid_stats()
2446 lockdep_assert_held(&ocelot->stat_view_lock); in vsc9959_update_sfid_stats()
2463 s->match += match; in vsc9959_update_sfid_stats()
2464 s->not_pass_gate += not_pass_gate; in vsc9959_update_sfid_stats()
2465 s->not_pass_sdu += not_pass_sdu; in vsc9959_update_sfid_stats()
2466 s->red += red; in vsc9959_update_sfid_stats()
2469 /* Caller must hold &ocelot->stat_view_lock */
2472 struct ocelot_psfp_list *psfp = &ocelot->psfp; in vsc9959_update_stats()
2475 mutex_lock(&psfp->lock); in vsc9959_update_stats()
2477 list_for_each_entry(sfi, &psfp->sfi_list, list) in vsc9959_update_stats()
2480 mutex_unlock(&psfp->lock); in vsc9959_update_stats()
2487 struct ocelot_psfp_list *psfp = &ocelot->psfp; in vsc9959_psfp_stats_get()
2492 stream = vsc9959_stream_table_get(&psfp->stream_list, f->cookie); in vsc9959_psfp_stats_get()
2494 return -ENOMEM; in vsc9959_psfp_stats_get()
2496 sfi = vsc9959_psfp_sfi_table_get(&psfp->sfi_list, stream->sfid); in vsc9959_psfp_stats_get()
2498 return -EINVAL; in vsc9959_psfp_stats_get()
2500 mutex_lock(&ocelot->stat_view_lock); in vsc9959_psfp_stats_get()
2504 s = &sfi->stats; in vsc9959_psfp_stats_get()
2505 stats->pkts = s->match; in vsc9959_psfp_stats_get()
2506 stats->drops = s->not_pass_gate + s->not_pass_sdu + s->red; in vsc9959_psfp_stats_get()
2510 mutex_unlock(&ocelot->stat_view_lock); in vsc9959_psfp_stats_get()
2517 struct ocelot_psfp_list *psfp = &ocelot->psfp; in vsc9959_psfp_init()
2519 INIT_LIST_HEAD(&psfp->stream_list); in vsc9959_psfp_init()
2520 INIT_LIST_HEAD(&psfp->sfi_list); in vsc9959_psfp_init()
2521 INIT_LIST_HEAD(&psfp->sgi_list); in vsc9959_psfp_init()
2522 mutex_init(&psfp->lock); in vsc9959_psfp_init()
2525 /* When using cut-through forwarding and the egress port runs at a higher data
2528 * The Felix switch implementation of cut-through forwarding does not check in
2530 * list of ports that have cut-through forwarding enabled on egress to only be
2537 struct dsa_switch *ds = felix->ds; in vsc9959_cut_through_fwd()
2540 lockdep_assert_held(&ocelot->fwd_domain_lock); in vsc9959_cut_through_fwd()
2542 for (port = 0; port < ocelot->num_phys_ports; port++) { in vsc9959_cut_through_fwd()
2543 struct ocelot_port *ocelot_port = ocelot->ports[port]; in vsc9959_cut_through_fwd()
2544 struct ocelot_mm_state *mm = &ocelot->mm[port]; in vsc9959_cut_through_fwd()
2545 int min_speed = ocelot_port->speed; in vsc9959_cut_through_fwd()
2549 /* Disable cut-through on ports that are down */ in vsc9959_cut_through_fwd()
2550 if (ocelot_port->speed <= 0) in vsc9959_cut_through_fwd()
2562 if (ocelot->npi >= 0) in vsc9959_cut_through_fwd()
2563 mask |= BIT(ocelot->npi); in vsc9959_cut_through_fwd()
2572 for_each_set_bit(other_port, &mask, ocelot->num_phys_ports) { in vsc9959_cut_through_fwd()
2575 other_ocelot_port = ocelot->ports[other_port]; in vsc9959_cut_through_fwd()
2576 if (other_ocelot_port->speed <= 0) in vsc9959_cut_through_fwd()
2579 if (min_speed > other_ocelot_port->speed) in vsc9959_cut_through_fwd()
2580 min_speed = other_ocelot_port->speed; in vsc9959_cut_through_fwd()
2583 /* Enable cut-through forwarding for all traffic classes that in vsc9959_cut_through_fwd()
2585 * bypassed in cut-through mode. Also exclude preemptible in vsc9959_cut_through_fwd()
2587 * reason, if sent as cut-through. in vsc9959_cut_through_fwd()
2589 if (ocelot_port->speed == min_speed) { in vsc9959_cut_through_fwd()
2590 val = GENMASK(7, 0) & ~mm->active_preemptible_tcs; in vsc9959_cut_through_fwd()
2602 dev_dbg(ocelot->dev, in vsc9959_cut_through_fwd()
2603 "port %d fwd mask 0x%lx speed %d min_speed %d, %s cut-through forwarding on TC mask 0x%x\n", in vsc9959_cut_through_fwd()
2604 port, mask, ocelot_port->speed, min_speed, in vsc9959_cut_through_fwd()
2626 struct pci_dev *pdev = to_pci_dev(ocelot->dev); in vsc9959_request_irq()
2628 return devm_request_threaded_irq(ocelot->dev, pdev->irq, NULL, in vsc9959_request_irq()
2630 "felix-intb", ocelot); in vsc9959_request_irq()
2678 struct device *dev = &pdev->dev; in felix_pci_probe()
2712 dsa_unregister_switch(felix->ds); in felix_pci_remove()
2724 dsa_switch_shutdown(felix->ds); in felix_pci_shutdown()