2019-11-14 22:03:27 +07:00
|
|
|
/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
|
|
|
|
/* Copyright (c) 2017 Microsemi Corporation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SOC_MSCC_OCELOT_H
|
|
|
|
#define _SOC_MSCC_OCELOT_H
|
|
|
|
|
|
|
|
#include <linux/ptp_clock_kernel.h>
|
|
|
|
#include <linux/net_tstamp.h>
|
|
|
|
#include <linux/if_vlan.h>
|
|
|
|
#include <linux/regmap.h>
|
|
|
|
#include <net/dsa.h>
|
|
|
|
|
net: dsa: felix: Allow unknown unicast traffic towards the CPU port module
Compared to other DSA switches, in the Ocelot cores, the RX filtering is
a much more important concern.
Firstly, the primary use case for Ocelot is non-DSA, so there isn't any
secondary Ethernet MAC [the DSA master's one] to implicitly drop frames
having a DMAC we are not interested in. So the switch driver itself
needs to install FDB entries towards the CPU port module (PGID_CPU) for
the MAC address of each switch port, in each VLAN installed on the port.
Every address that is not whitelisted is implicitly dropped. This is in
order to achieve a behavior similar to N standalone net devices.
Secondly, even in the secondary use case of DSA, such as illustrated by
Felix with the NPI port mode, that secondary Ethernet MAC is present,
but its RX filter is bypassed. This is because the DSA tags themselves
are placed before Ethernet, so the DMAC that the switch ports see is
not seen by the DSA master too (since it's shifter to the right).
So RX filtering is pretty important. A good RX filter won't bother the
CPU in case the switch port receives a frame that it's not interested
in, and there exists no other line of defense.
Ocelot is pretty strict when it comes to RX filtering: non-IP multicast
and broadcast traffic is allowed to go to the CPU port module, but
unknown unicast isn't. This means that traffic reception for any other
MAC addresses than the ones configured on each switch port net device
won't work. This includes use cases such as macvlan or bridging with a
non-Ocelot (so-called "foreign") interface. But this seems to be fine
for the scenarios that the Linux system embedded inside an Ocelot switch
is intended for - it is simply not interested in unknown unicast
traffic, as explained in Allan Nielsen's presentation [0].
On the other hand, the Felix DSA switch is integrated in more
general-purpose Linux systems, so it can't afford to drop that sort of
traffic in hardware, even if it will end up doing so later, in software.
Actually, unknown unicast means more for Felix than it does for Ocelot.
Felix doesn't attempt to perform the whitelisting of switch port MAC
addresses towards PGID_CPU at all, mainly because it is too complicated
to be feasible: while the MAC addresses are unique in Ocelot, by default
in DSA all ports are equal and inherited from the DSA master. This adds
into account the question of reference counting MAC addresses (delayed
ocelot_mact_forget), not to mention reference counting for the VLAN IDs
that those MAC addresses are installed in. This reference counting
should be done in the DSA core, and the fact that it wasn't needed so
far is due to the fact that the other DSA switches don't have the DSA
tag placed before Ethernet, so the DSA master is able to whitelist the
MAC addresses in hardware.
So this means that even regular traffic termination on a Felix switch
port happens through flooding (because neither Felix nor Ocelot learn
source MAC addresses from CPU-injected frames).
So far we've explained that whitelisting towards PGID_CPU:
- helps to reduce the likelihood of spamming the CPU with frames it
won't process very far anyway
- is implemented in the ocelot driver
- is sufficient for the ocelot use cases
- is not feasible in DSA
- breaks use cases in DSA, in the current status (whitelisting enabled
but no MAC address whitelisted)
So the proposed patch allows unknown unicast frames to be sent to the
CPU port module. This is done for the Felix DSA driver only, as Ocelot
seems to be happy without it.
[0]: https://www.youtube.com/watch?v=B1HhxEcU7Jg
Suggested-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:50:03 +07:00
|
|
|
/* Port Group IDs (PGID) are masks of destination ports.
|
|
|
|
*
|
|
|
|
* For L2 forwarding, the switch performs 3 lookups in the PGID table for each
|
|
|
|
* frame, and forwards the frame to the ports that are present in the logical
|
|
|
|
* AND of all 3 PGIDs.
|
|
|
|
*
|
|
|
|
* These PGID lookups are:
|
|
|
|
* - In one of PGID[0-63]: for the destination masks. There are 2 paths by
|
|
|
|
* which the switch selects a destination PGID:
|
|
|
|
* - The {DMAC, VID} is present in the MAC table. In that case, the
|
|
|
|
* destination PGID is given by the DEST_IDX field of the MAC table entry
|
|
|
|
* that matched.
|
|
|
|
* - The {DMAC, VID} is not present in the MAC table (it is unknown). The
|
|
|
|
* frame is disseminated as being either unicast, multicast or broadcast,
|
|
|
|
* and according to that, the destination PGID is chosen as being the
|
|
|
|
* value contained by ANA_FLOODING_FLD_UNICAST,
|
|
|
|
* ANA_FLOODING_FLD_MULTICAST or ANA_FLOODING_FLD_BROADCAST.
|
|
|
|
* The destination PGID can be an unicast set: the first PGIDs, 0 to
|
|
|
|
* ocelot->num_phys_ports - 1, or a multicast set: the PGIDs from
|
|
|
|
* ocelot->num_phys_ports to 63. By convention, a unicast PGID corresponds to
|
|
|
|
* a physical port and has a single bit set in the destination ports mask:
|
|
|
|
* that corresponding to the port number itself. In contrast, a multicast
|
|
|
|
* PGID will have potentially more than one single bit set in the destination
|
|
|
|
* ports mask.
|
|
|
|
* - In one of PGID[64-79]: for the aggregation mask. The switch classifier
|
|
|
|
* dissects each frame and generates a 4-bit Link Aggregation Code which is
|
|
|
|
* used for this second PGID table lookup. The goal of link aggregation is to
|
|
|
|
* hash multiple flows within the same LAG on to different destination ports.
|
|
|
|
* The first lookup will result in a PGID with all the LAG members present in
|
|
|
|
* the destination ports mask, and the second lookup, by Link Aggregation
|
|
|
|
* Code, will ensure that each flow gets forwarded only to a single port out
|
|
|
|
* of that mask (there are no duplicates).
|
|
|
|
* - In one of PGID[80-90]: for the source mask. The third time, the PGID table
|
|
|
|
* is indexed with the ingress port (plus 80). These PGIDs answer the
|
|
|
|
* question "is port i allowed to forward traffic to port j?" If yes, then
|
|
|
|
* BIT(j) of PGID 80+i will be found set. The third PGID lookup can be used
|
|
|
|
* to enforce the L2 forwarding matrix imposed by e.g. a Linux bridge.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Reserve some destination PGIDs at the end of the range:
|
|
|
|
* PGID_CPU: used for whitelisting certain MAC addresses, such as the addresses
|
|
|
|
* of the switch port net devices, towards the CPU port module.
|
|
|
|
* PGID_UC: the flooding destinations for unknown unicast traffic.
|
|
|
|
* PGID_MC: the flooding destinations for broadcast and non-IP multicast
|
|
|
|
* traffic.
|
|
|
|
* PGID_MCIPV4: the flooding destinations for IPv4 multicast traffic.
|
|
|
|
* PGID_MCIPV6: the flooding destinations for IPv6 multicast traffic.
|
|
|
|
*/
|
|
|
|
#define PGID_CPU 59
|
|
|
|
#define PGID_UC 60
|
|
|
|
#define PGID_MC 61
|
|
|
|
#define PGID_MCIPV4 62
|
|
|
|
#define PGID_MCIPV6 63
|
|
|
|
|
2020-06-21 18:46:02 +07:00
|
|
|
#define for_each_unicast_dest_pgid(ocelot, pgid) \
|
|
|
|
for ((pgid) = 0; \
|
|
|
|
(pgid) < (ocelot)->num_phys_ports; \
|
|
|
|
(pgid)++)
|
|
|
|
|
|
|
|
#define for_each_nonreserved_multicast_dest_pgid(ocelot, pgid) \
|
|
|
|
for ((pgid) = (ocelot)->num_phys_ports + 1; \
|
|
|
|
(pgid) < PGID_CPU; \
|
|
|
|
(pgid)++)
|
|
|
|
|
|
|
|
#define for_each_aggr_pgid(ocelot, pgid) \
|
|
|
|
for ((pgid) = PGID_AGGR; \
|
|
|
|
(pgid) < PGID_SRC; \
|
|
|
|
(pgid)++)
|
|
|
|
|
net: dsa: felix: Allow unknown unicast traffic towards the CPU port module
Compared to other DSA switches, in the Ocelot cores, the RX filtering is
a much more important concern.
Firstly, the primary use case for Ocelot is non-DSA, so there isn't any
secondary Ethernet MAC [the DSA master's one] to implicitly drop frames
having a DMAC we are not interested in. So the switch driver itself
needs to install FDB entries towards the CPU port module (PGID_CPU) for
the MAC address of each switch port, in each VLAN installed on the port.
Every address that is not whitelisted is implicitly dropped. This is in
order to achieve a behavior similar to N standalone net devices.
Secondly, even in the secondary use case of DSA, such as illustrated by
Felix with the NPI port mode, that secondary Ethernet MAC is present,
but its RX filter is bypassed. This is because the DSA tags themselves
are placed before Ethernet, so the DMAC that the switch ports see is
not seen by the DSA master too (since it's shifter to the right).
So RX filtering is pretty important. A good RX filter won't bother the
CPU in case the switch port receives a frame that it's not interested
in, and there exists no other line of defense.
Ocelot is pretty strict when it comes to RX filtering: non-IP multicast
and broadcast traffic is allowed to go to the CPU port module, but
unknown unicast isn't. This means that traffic reception for any other
MAC addresses than the ones configured on each switch port net device
won't work. This includes use cases such as macvlan or bridging with a
non-Ocelot (so-called "foreign") interface. But this seems to be fine
for the scenarios that the Linux system embedded inside an Ocelot switch
is intended for - it is simply not interested in unknown unicast
traffic, as explained in Allan Nielsen's presentation [0].
On the other hand, the Felix DSA switch is integrated in more
general-purpose Linux systems, so it can't afford to drop that sort of
traffic in hardware, even if it will end up doing so later, in software.
Actually, unknown unicast means more for Felix than it does for Ocelot.
Felix doesn't attempt to perform the whitelisting of switch port MAC
addresses towards PGID_CPU at all, mainly because it is too complicated
to be feasible: while the MAC addresses are unique in Ocelot, by default
in DSA all ports are equal and inherited from the DSA master. This adds
into account the question of reference counting MAC addresses (delayed
ocelot_mact_forget), not to mention reference counting for the VLAN IDs
that those MAC addresses are installed in. This reference counting
should be done in the DSA core, and the fact that it wasn't needed so
far is due to the fact that the other DSA switches don't have the DSA
tag placed before Ethernet, so the DSA master is able to whitelist the
MAC addresses in hardware.
So this means that even regular traffic termination on a Felix switch
port happens through flooding (because neither Felix nor Ocelot learn
source MAC addresses from CPU-injected frames).
So far we've explained that whitelisting towards PGID_CPU:
- helps to reduce the likelihood of spamming the CPU with frames it
won't process very far anyway
- is implemented in the ocelot driver
- is sufficient for the ocelot use cases
- is not feasible in DSA
- breaks use cases in DSA, in the current status (whitelisting enabled
but no MAC address whitelisted)
So the proposed patch allows unknown unicast frames to be sent to the
CPU port module. This is done for the Felix DSA driver only, as Ocelot
seems to be happy without it.
[0]: https://www.youtube.com/watch?v=B1HhxEcU7Jg
Suggested-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:50:03 +07:00
|
|
|
/* Aggregation PGIDs, one per Link Aggregation Code */
|
|
|
|
#define PGID_AGGR 64
|
|
|
|
|
|
|
|
/* Source PGIDs, one per physical port */
|
|
|
|
#define PGID_SRC 80
|
|
|
|
|
2019-11-14 22:03:27 +07:00
|
|
|
#define IFH_INJ_BYPASS BIT(31)
|
|
|
|
#define IFH_INJ_POP_CNT_DISABLE (3 << 28)
|
|
|
|
|
|
|
|
#define IFH_TAG_TYPE_C 0
|
|
|
|
#define IFH_TAG_TYPE_S 1
|
|
|
|
|
|
|
|
#define IFH_REW_OP_NOOP 0x0
|
|
|
|
#define IFH_REW_OP_DSCP 0x1
|
|
|
|
#define IFH_REW_OP_ONE_STEP_PTP 0x2
|
|
|
|
#define IFH_REW_OP_TWO_STEP_PTP 0x3
|
|
|
|
#define IFH_REW_OP_ORIGIN_PTP 0x5
|
|
|
|
|
|
|
|
#define OCELOT_TAG_LEN 16
|
|
|
|
#define OCELOT_SHORT_PREFIX_LEN 4
|
|
|
|
#define OCELOT_LONG_PREFIX_LEN 16
|
|
|
|
|
|
|
|
#define OCELOT_SPEED_2500 0
|
|
|
|
#define OCELOT_SPEED_1000 1
|
|
|
|
#define OCELOT_SPEED_100 2
|
|
|
|
#define OCELOT_SPEED_10 3
|
|
|
|
|
2020-04-20 09:46:49 +07:00
|
|
|
#define OCELOT_PTP_PINS_NUM 4
|
|
|
|
|
2019-11-14 22:03:27 +07:00
|
|
|
#define TARGET_OFFSET 24
|
|
|
|
#define REG_MASK GENMASK(TARGET_OFFSET - 1, 0)
|
|
|
|
#define REG(reg, offset) [reg & REG_MASK] = offset
|
|
|
|
|
|
|
|
#define REG_RESERVED_ADDR 0xffffffff
|
|
|
|
#define REG_RESERVED(reg) REG(reg, REG_RESERVED_ADDR)
|
|
|
|
|
|
|
|
enum ocelot_target {
|
|
|
|
ANA = 1,
|
|
|
|
QS,
|
|
|
|
QSYS,
|
|
|
|
REW,
|
|
|
|
SYS,
|
|
|
|
S2,
|
|
|
|
HSIO,
|
|
|
|
PTP,
|
|
|
|
GCB,
|
2020-07-13 23:57:01 +07:00
|
|
|
DEV_GMII,
|
2019-11-14 22:03:27 +07:00
|
|
|
TARGET_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ocelot_reg {
|
|
|
|
ANA_ADVLEARN = ANA << TARGET_OFFSET,
|
|
|
|
ANA_VLANMASK,
|
|
|
|
ANA_PORT_B_DOMAIN,
|
|
|
|
ANA_ANAGEFIL,
|
|
|
|
ANA_ANEVENTS,
|
|
|
|
ANA_STORMLIMIT_BURST,
|
|
|
|
ANA_STORMLIMIT_CFG,
|
|
|
|
ANA_ISOLATED_PORTS,
|
|
|
|
ANA_COMMUNITY_PORTS,
|
|
|
|
ANA_AUTOAGE,
|
|
|
|
ANA_MACTOPTIONS,
|
|
|
|
ANA_LEARNDISC,
|
|
|
|
ANA_AGENCTRL,
|
|
|
|
ANA_MIRRORPORTS,
|
|
|
|
ANA_EMIRRORPORTS,
|
|
|
|
ANA_FLOODING,
|
|
|
|
ANA_FLOODING_IPMC,
|
|
|
|
ANA_SFLOW_CFG,
|
|
|
|
ANA_PORT_MODE,
|
|
|
|
ANA_CUT_THRU_CFG,
|
|
|
|
ANA_PGID_PGID,
|
|
|
|
ANA_TABLES_ANMOVED,
|
|
|
|
ANA_TABLES_MACHDATA,
|
|
|
|
ANA_TABLES_MACLDATA,
|
|
|
|
ANA_TABLES_STREAMDATA,
|
|
|
|
ANA_TABLES_MACACCESS,
|
|
|
|
ANA_TABLES_MACTINDX,
|
|
|
|
ANA_TABLES_VLANACCESS,
|
|
|
|
ANA_TABLES_VLANTIDX,
|
|
|
|
ANA_TABLES_ISDXACCESS,
|
|
|
|
ANA_TABLES_ISDXTIDX,
|
|
|
|
ANA_TABLES_ENTRYLIM,
|
|
|
|
ANA_TABLES_PTP_ID_HIGH,
|
|
|
|
ANA_TABLES_PTP_ID_LOW,
|
|
|
|
ANA_TABLES_STREAMACCESS,
|
|
|
|
ANA_TABLES_STREAMTIDX,
|
|
|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
|
|
REW_PPT,
|
|
|
|
SYS_COUNT_RX_OCTETS = SYS << TARGET_OFFSET,
|
|
|
|
SYS_COUNT_RX_UNICAST,
|
|
|
|
SYS_COUNT_RX_MULTICAST,
|
|
|
|
SYS_COUNT_RX_BROADCAST,
|
|
|
|
SYS_COUNT_RX_SHORTS,
|
|
|
|
SYS_COUNT_RX_FRAGMENTS,
|
|
|
|
SYS_COUNT_RX_JABBERS,
|
|
|
|
SYS_COUNT_RX_CRC_ALIGN_ERRS,
|
|
|
|
SYS_COUNT_RX_SYM_ERRS,
|
|
|
|
SYS_COUNT_RX_64,
|
|
|
|
SYS_COUNT_RX_65_127,
|
|
|
|
SYS_COUNT_RX_128_255,
|
|
|
|
SYS_COUNT_RX_256_1023,
|
|
|
|
SYS_COUNT_RX_1024_1526,
|
|
|
|
SYS_COUNT_RX_1527_MAX,
|
|
|
|
SYS_COUNT_RX_PAUSE,
|
|
|
|
SYS_COUNT_RX_CONTROL,
|
|
|
|
SYS_COUNT_RX_LONGS,
|
|
|
|
SYS_COUNT_RX_CLASSIFIED_DROPS,
|
|
|
|
SYS_COUNT_TX_OCTETS,
|
|
|
|
SYS_COUNT_TX_UNICAST,
|
|
|
|
SYS_COUNT_TX_MULTICAST,
|
|
|
|
SYS_COUNT_TX_BROADCAST,
|
|
|
|
SYS_COUNT_TX_COLLISION,
|
|
|
|
SYS_COUNT_TX_DROPS,
|
|
|
|
SYS_COUNT_TX_PAUSE,
|
|
|
|
SYS_COUNT_TX_64,
|
|
|
|
SYS_COUNT_TX_65_127,
|
|
|
|
SYS_COUNT_TX_128_511,
|
|
|
|
SYS_COUNT_TX_512_1023,
|
|
|
|
SYS_COUNT_TX_1024_1526,
|
|
|
|
SYS_COUNT_TX_1527_MAX,
|
|
|
|
SYS_COUNT_TX_AGING,
|
|
|
|
SYS_RESET_CFG,
|
|
|
|
SYS_SR_ETYPE_CFG,
|
|
|
|
SYS_VLAN_ETYPE_CFG,
|
|
|
|
SYS_PORT_MODE,
|
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ANEVENTS_DEST_KNOWN,
|
|
|
|
ANA_ANEVENTS_BUCKET3_MATCH,
|
|
|
|
ANA_ANEVENTS_BUCKET2_MATCH,
|
|
|
|
ANA_ANEVENTS_BUCKET1_MATCH,
|
|
|
|
ANA_ANEVENTS_BUCKET0_MATCH,
|
|
|
|
ANA_ANEVENTS_CPU_OPERATION,
|
|
|
|
ANA_ANEVENTS_DMAC_LOOKUP,
|
|
|
|
ANA_ANEVENTS_SMAC_LOOKUP,
|
|
|
|
ANA_ANEVENTS_SEQ_GEN_ERR_0,
|
|
|
|
ANA_ANEVENTS_SEQ_GEN_ERR_1,
|
|
|
|
ANA_TABLES_MACACCESS_B_DOM,
|
|
|
|
ANA_TABLES_MACTINDX_BUCKET,
|
|
|
|
ANA_TABLES_MACTINDX_M_INDEX,
|
net: mscc: ocelot: convert QSYS_SWITCH_PORT_MODE and SYS_PORT_MODE to regfields
Currently Felix and Ocelot share the same bit layout in these per-port
registers, but Seville does not. So we need reg_fields for that.
Actually since these are per-port registers, we need to also specify the
number of ports, and register size per port, and use the regmap API for
multiple ports.
There's a more subtle point to be made about the other 2 register
fields:
- QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG
- QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE
which we are not writing any longer, for 2 reasons:
- Using the previous API (ocelot_write_rix), we were only writing 1 for
Felix and Ocelot, which was their hardware-default value, and which
there wasn't any intention in changing.
- In the case of SCH_NEXT_CFG, in fact Seville does not have this
register field at all, and therefore, if we want to have common code
we would be required to not write to it.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-13 23:57:03 +07:00
|
|
|
QSYS_SWITCH_PORT_MODE_PORT_ENA,
|
|
|
|
QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG,
|
|
|
|
QSYS_SWITCH_PORT_MODE_YEL_RSRVD,
|
|
|
|
QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE,
|
|
|
|
QSYS_SWITCH_PORT_MODE_TX_PFC_ENA,
|
|
|
|
QSYS_SWITCH_PORT_MODE_TX_PFC_MODE,
|
2019-11-14 22:03:27 +07:00
|
|
|
QSYS_TIMED_FRAME_ENTRY_TFRM_VLD,
|
|
|
|
QSYS_TIMED_FRAME_ENTRY_TFRM_FP,
|
|
|
|
QSYS_TIMED_FRAME_ENTRY_TFRM_PORTNO,
|
|
|
|
QSYS_TIMED_FRAME_ENTRY_TFRM_TM_SEL,
|
|
|
|
QSYS_TIMED_FRAME_ENTRY_TFRM_TM_T,
|
net: mscc: ocelot: convert QSYS_SWITCH_PORT_MODE and SYS_PORT_MODE to regfields
Currently Felix and Ocelot share the same bit layout in these per-port
registers, but Seville does not. So we need reg_fields for that.
Actually since these are per-port registers, we need to also specify the
number of ports, and register size per port, and use the regmap API for
multiple ports.
There's a more subtle point to be made about the other 2 register
fields:
- QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG
- QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE
which we are not writing any longer, for 2 reasons:
- Using the previous API (ocelot_write_rix), we were only writing 1 for
Felix and Ocelot, which was their hardware-default value, and which
there wasn't any intention in changing.
- In the case of SCH_NEXT_CFG, in fact Seville does not have this
register field at all, and therefore, if we want to have common code
we would be required to not write to it.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-13 23:57:03 +07:00
|
|
|
SYS_PORT_MODE_DATA_WO_TS,
|
|
|
|
SYS_PORT_MODE_INCL_INJ_HDR,
|
|
|
|
SYS_PORT_MODE_INCL_XTR_HDR,
|
|
|
|
SYS_PORT_MODE_INCL_HDR_ERR,
|
2019-11-14 22:03:27 +07:00
|
|
|
SYS_RESET_CFG_CORE_ENA,
|
|
|
|
SYS_RESET_CFG_MEM_ENA,
|
|
|
|
SYS_RESET_CFG_MEM_INIT,
|
|
|
|
GCB_SOFT_RST_SWC_RST,
|
2020-07-13 23:57:02 +07:00
|
|
|
GCB_MIIM_MII_STATUS_PENDING,
|
|
|
|
GCB_MIIM_MII_STATUS_BUSY,
|
2020-07-13 23:57:07 +07:00
|
|
|
SYS_PAUSE_CFG_PAUSE_START,
|
|
|
|
SYS_PAUSE_CFG_PAUSE_STOP,
|
|
|
|
SYS_PAUSE_CFG_PAUSE_ENA,
|
2019-11-14 22:03:27 +07:00
|
|
|
REGFIELD_MAX
|
|
|
|
};
|
|
|
|
|
2020-04-20 09:46:47 +07:00
|
|
|
enum ocelot_ptp_pins {
|
|
|
|
PTP_PIN_0,
|
|
|
|
PTP_PIN_1,
|
|
|
|
PTP_PIN_2,
|
|
|
|
PTP_PIN_3,
|
2019-11-14 22:03:27 +07:00
|
|
|
TOD_ACC_PIN
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ocelot_stat_layout {
|
|
|
|
u32 offset;
|
|
|
|
char name[ETH_GSTRING_LEN];
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ocelot_tag_prefix {
|
|
|
|
OCELOT_TAG_PREFIX_DISABLED = 0,
|
|
|
|
OCELOT_TAG_PREFIX_NONE,
|
|
|
|
OCELOT_TAG_PREFIX_SHORT,
|
|
|
|
OCELOT_TAG_PREFIX_LONG,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ocelot;
|
|
|
|
|
|
|
|
struct ocelot_ops {
|
|
|
|
int (*reset)(struct ocelot *ocelot);
|
2020-07-13 23:57:08 +07:00
|
|
|
u16 (*wm_enc)(u16 value);
|
2019-11-14 22:03:27 +07:00
|
|
|
};
|
|
|
|
|
2020-06-20 22:43:46 +07:00
|
|
|
struct ocelot_vcap_block {
|
net: mscc: ocelot: simplify tc-flower offload structures
The ocelot tc-flower offload binds a second flow block callback (apart
from the one for matchall) just because it uses a different block
private structure (ocelot_port_private for matchall, ocelot_port_block
for flower).
But ocelot_port_block just appears to be boilerplate, and doesn't help
with anything in particular at all, it's just useless glue between the
(global!) struct ocelot_acl_block *block pointer, and a per-netdevice
struct ocelot_port_private *priv.
So let's just simplify that, and make struct ocelot_port_private be the
private structure for the block offload. This makes us able to use the
same flow callback as in the case of matchall.
This also reveals that the struct ocelot_acl_block *block is used rather
strangely, as mentioned above: it is defined globally, allocated at
probe time, and freed at unbind time. So just move the structure to the
main ocelot structure, which gives further opportunity for
simplification.
Also get rid of backpointers from struct ocelot_acl_block and struct
ocelot_ace_rule back to struct ocelot, by reworking the function
prototypes, where necessary, to use a more DSA-friendly "struct ocelot
*ocelot, int port" format.
And finally, remove the debugging prints that were added during
development, since they provide no useful information at this point.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:31:06 +07:00
|
|
|
struct list_head rules;
|
|
|
|
int count;
|
2020-03-29 18:51:57 +07:00
|
|
|
int pol_lpr;
|
net: mscc: ocelot: simplify tc-flower offload structures
The ocelot tc-flower offload binds a second flow block callback (apart
from the one for matchall) just because it uses a different block
private structure (ocelot_port_private for matchall, ocelot_port_block
for flower).
But ocelot_port_block just appears to be boilerplate, and doesn't help
with anything in particular at all, it's just useless glue between the
(global!) struct ocelot_acl_block *block pointer, and a per-netdevice
struct ocelot_port_private *priv.
So let's just simplify that, and make struct ocelot_port_private be the
private structure for the block offload. This makes us able to use the
same flow callback as in the case of matchall.
This also reveals that the struct ocelot_acl_block *block is used rather
strangely, as mentioned above: it is defined globally, allocated at
probe time, and freed at unbind time. So just move the structure to the
main ocelot structure, which gives further opportunity for
simplification.
Also get rid of backpointers from struct ocelot_acl_block and struct
ocelot_ace_rule back to struct ocelot, by reworking the function
prototypes, where necessary, to use a more DSA-friendly "struct ocelot
*ocelot, int port" format.
And finally, remove the debugging prints that were added during
development, since they provide no useful information at this point.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:31:06 +07:00
|
|
|
};
|
|
|
|
|
2019-11-14 22:03:27 +07:00
|
|
|
struct ocelot_port {
|
|
|
|
struct ocelot *ocelot;
|
|
|
|
|
2020-07-13 23:57:01 +07:00
|
|
|
struct regmap *target;
|
2019-11-14 22:03:27 +07:00
|
|
|
|
net: mscc: ocelot: fix untagged packet drops when enslaving to vlan aware bridge
To rehash a previous explanation given in commit 1c44ce560b4d ("net:
mscc: ocelot: fix vlan_filtering when enslaving to bridge before link is
up"), the switch driver operates the in a mode where a single VLAN can
be transmitted as untagged on a particular egress port. That is the
"native VLAN on trunk port" use case.
The configuration for this native VLAN is driven in 2 ways:
- Set the egress port rewriter to strip the VLAN tag for the native
VID (as it is egress-untagged, after all).
- Configure the ingress port to drop untagged and priority-tagged
traffic, if there is no native VLAN. The intention of this setting is
that a trunk port with no native VLAN should not accept untagged
traffic.
Since both of the above configurations for the native VLAN should only
be done if VLAN awareness is requested, they are actually done from the
ocelot_port_vlan_filtering function, after the basic procedure of
toggling the VLAN awareness flag of the port.
But there's a problem with that simplistic approach: we are trying to
juggle with 2 independent variables from a single function:
- Native VLAN of the port - its value is held in port->vid.
- VLAN awareness state of the port - currently there are some issues
here, more on that later*.
The actual problem can be seen when enslaving the switch ports to a VLAN
filtering bridge:
0. The driver configures a pvid of zero for each port, when in
standalone mode. While the bridge configures a default_pvid of 1 for
each port that gets added as a slave to it.
1. The bridge calls ocelot_port_vlan_filtering with vlan_aware=true.
The VLAN-filtering-dependent portion of the native VLAN
configuration is done, considering that the native VLAN is 0.
2. The bridge calls ocelot_vlan_add with vid=1, pvid=true,
untagged=true. The native VLAN changes to 1 (change which gets
propagated to hardware).
3. ??? - nobody calls ocelot_port_vlan_filtering again, to reapply the
VLAN-filtering-dependent portion of the native VLAN configuration,
for the new native VLAN of 1. One can notice that after toggling "ip
link set dev br0 type bridge vlan_filtering 0 && ip link set dev br0
type bridge vlan_filtering 1", the new native VLAN finally makes it
through and untagged traffic finally starts flowing again. But
obviously that shouldn't be needed.
So it is clear that 2 independent variables need to both re-trigger the
native VLAN configuration. So we introduce the second variable as
ocelot_port->vlan_aware.
*Actually both the DSA Felix driver and the Ocelot driver already had
each its own variable:
- Ocelot: ocelot_port_private->vlan_aware
- Felix: dsa_port->vlan_filtering
but the common Ocelot library needs to work with a single, common,
variable, so there is some refactoring done to move the vlan_aware
property from the private structure into the common ocelot_port
structure.
Fixes: 97bb69e1e36e ("net: mscc: ocelot: break apart ocelot_vlan_port_apply")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-15 02:36:15 +07:00
|
|
|
bool vlan_aware;
|
|
|
|
|
2019-11-14 22:03:27 +07:00
|
|
|
/* Ingress default VLAN (pvid) */
|
|
|
|
u16 pvid;
|
|
|
|
|
|
|
|
/* Egress default VLAN (vid) */
|
|
|
|
u16 vid;
|
|
|
|
|
|
|
|
u8 ptp_cmd;
|
2019-11-27 14:27:57 +07:00
|
|
|
struct sk_buff_head tx_skbs;
|
2019-11-14 22:03:27 +07:00
|
|
|
u8 ts_id;
|
2020-01-06 08:34:15 +07:00
|
|
|
|
|
|
|
phy_interface_t phy_mode;
|
net: dsa: felix: create a template for the DSA tags on xmit
With this patch we try to kill 2 birds with 1 stone.
First of all, some switches that use tag_ocelot.c don't have the exact
same bitfield layout for the DSA tags. The destination ports field is
different for Seville VSC9953 for example. So the choices are to either
duplicate tag_ocelot.c into a new tag_seville.c (sub-optimal) or somehow
take into account a supposed ocelot->dest_ports_offset when packing this
field into the DSA injection header (again not ideal).
Secondly, tag_ocelot.c already needs to memset a 128-bit area to zero
and call some packing() functions of dubious performance in the
fastpath. And most of the values it needs to pack are pretty much
constant (BYPASS=1, SRC_PORT=CPU, DEST=port index). So it would be good
if we could improve that.
The proposed solution is to allocate a memory area per port at probe
time, initialize that with the statically defined bits as per chip
hardware revision, and just perform a simpler memcpy in the fastpath.
Other alternatives have been analyzed, such as:
- Create a separate tag_seville.c: too much code duplication for just 1
bit field difference.
- Create a separate DSA_TAG_PROTO_SEVILLE under tag_ocelot.c, just like
tag_brcm.c, which would have a separate .xmit function. Again, too
much code duplication for just 1 bit field difference.
- Allocate the template from the init function of the tag_ocelot.c
module, instead of from the driver: couldn't figure out a method of
accessing the correct port template corresponding to the correct
tagger in the .xmit function.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-13 23:57:04 +07:00
|
|
|
|
|
|
|
u8 *xmit_template;
|
2019-11-14 22:03:27 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ocelot {
|
|
|
|
struct device *dev;
|
|
|
|
|
|
|
|
const struct ocelot_ops *ops;
|
|
|
|
struct regmap *targets[TARGET_MAX];
|
|
|
|
struct regmap_field *regfields[REGFIELD_MAX];
|
|
|
|
const u32 *const *map;
|
|
|
|
const struct ocelot_stat_layout *stats_layout;
|
|
|
|
unsigned int num_stats;
|
|
|
|
|
|
|
|
int shared_queue_sz;
|
2020-05-04 05:20:26 +07:00
|
|
|
int num_mact_rows;
|
2019-11-14 22:03:27 +07:00
|
|
|
|
|
|
|
struct net_device *hw_bridge_dev;
|
|
|
|
u16 bridge_mask;
|
|
|
|
u16 bridge_fwd_mask;
|
|
|
|
|
|
|
|
struct ocelot_port **ports;
|
|
|
|
|
|
|
|
u8 base_mac[ETH_ALEN];
|
|
|
|
|
|
|
|
/* Keep track of the vlan port masks */
|
|
|
|
u32 vlan_mask[VLAN_N_VID];
|
|
|
|
|
net: mscc: ocelot: eliminate confusion between CPU and NPI port
Ocelot has the concept of a CPU port. The CPU port is represented in the
forwarding and the queueing system, but it is not a physical device. The
CPU port can either be accessed via register-based injection/extraction
(which is the case of Ocelot), via Frame-DMA (similar to the first one),
or "connected" to a physical Ethernet port (called NPI in the datasheet)
which is the case of the Felix DSA switch.
In Ocelot the CPU port is at index 11.
In Felix the CPU port is at index 6.
The CPU bit is treated special in the forwarding, as it is never cleared
from the forwarding port mask (once added to it). Other than that, it is
treated the same as a normal front port.
Both Felix and Ocelot should use the CPU port in the same way. This
means that Felix should not use the NPI port directly when forwarding to
the CPU, but instead use the CPU port.
This patch is fixing this such that Felix will use port 6 as its CPU
port, and just use the NPI port to carry the traffic.
Therefore, eliminate the "ocelot->cpu" variable which was holding the
index of the NPI port for Felix, and the index of the CPU port module
for Ocelot, so the variable was actually configuring different things
for different drivers and causing at least part of the confusion.
Also remove the "ocelot->num_cpu_ports" variable, which is the result of
another confusion. The 2 CPU ports mentioned in the datasheet are
because there are two frame extraction channels (register based or DMA
based). This is of no relevance to the driver at the moment, and
invisible to the analyzer module.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Suggested-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:50:02 +07:00
|
|
|
/* In tables like ANA:PORT and the ANA:PGID:PGID mask,
|
|
|
|
* the CPU is located after the physical ports (at the
|
|
|
|
* num_phys_ports index).
|
|
|
|
*/
|
2019-11-14 22:03:27 +07:00
|
|
|
u8 num_phys_ports;
|
|
|
|
|
2020-03-28 02:55:47 +07:00
|
|
|
int npi;
|
|
|
|
|
|
|
|
enum ocelot_tag_prefix inj_prefix;
|
|
|
|
enum ocelot_tag_prefix xtr_prefix;
|
|
|
|
|
2019-11-14 22:03:27 +07:00
|
|
|
u32 *lags;
|
|
|
|
|
|
|
|
struct list_head multicast;
|
|
|
|
|
2020-06-20 22:43:46 +07:00
|
|
|
struct ocelot_vcap_block block;
|
net: mscc: ocelot: simplify tc-flower offload structures
The ocelot tc-flower offload binds a second flow block callback (apart
from the one for matchall) just because it uses a different block
private structure (ocelot_port_private for matchall, ocelot_port_block
for flower).
But ocelot_port_block just appears to be boilerplate, and doesn't help
with anything in particular at all, it's just useless glue between the
(global!) struct ocelot_acl_block *block pointer, and a per-netdevice
struct ocelot_port_private *priv.
So let's just simplify that, and make struct ocelot_port_private be the
private structure for the block offload. This makes us able to use the
same flow callback as in the case of matchall.
This also reveals that the struct ocelot_acl_block *block is used rather
strangely, as mentioned above: it is defined globally, allocated at
probe time, and freed at unbind time. So just move the structure to the
main ocelot structure, which gives further opportunity for
simplification.
Also get rid of backpointers from struct ocelot_acl_block and struct
ocelot_ace_rule back to struct ocelot, by reworking the function
prototypes, where necessary, to use a more DSA-friendly "struct ocelot
*ocelot, int port" format.
And finally, remove the debugging prints that were added during
development, since they provide no useful information at this point.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:31:06 +07:00
|
|
|
|
2020-02-29 21:31:10 +07:00
|
|
|
const struct vcap_field *vcap_is2_keys;
|
|
|
|
const struct vcap_field *vcap_is2_actions;
|
2020-02-29 21:31:12 +07:00
|
|
|
const struct vcap_props *vcap;
|
2020-02-29 21:31:10 +07:00
|
|
|
|
2019-11-14 22:03:27 +07:00
|
|
|
/* Workqueue to check statistics for overflow with its lock */
|
|
|
|
struct mutex stats_lock;
|
|
|
|
u64 *stats;
|
|
|
|
struct delayed_work stats_work;
|
|
|
|
struct workqueue_struct *stats_queue;
|
|
|
|
|
|
|
|
u8 ptp:1;
|
|
|
|
struct ptp_clock *ptp_clock;
|
|
|
|
struct ptp_clock_info ptp_info;
|
|
|
|
struct hwtstamp_config hwtstamp_config;
|
|
|
|
/* Protects the PTP interface state */
|
|
|
|
struct mutex ptp_lock;
|
|
|
|
/* Protects the PTP clock */
|
|
|
|
spinlock_t ptp_clock_lock;
|
2020-04-20 09:46:49 +07:00
|
|
|
struct ptp_pin_desc ptp_pins[OCELOT_PTP_PINS_NUM];
|
2019-11-14 22:03:27 +07:00
|
|
|
};
|
|
|
|
|
2020-03-29 18:52:00 +07:00
|
|
|
struct ocelot_policer {
|
|
|
|
u32 rate; /* kilobit per second */
|
|
|
|
u32 burst; /* bytes */
|
|
|
|
};
|
|
|
|
|
2019-11-14 22:03:27 +07:00
|
|
|
#define ocelot_read_ix(ocelot, reg, gi, ri) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
|
|
|
|
#define ocelot_read_gix(ocelot, reg, gi) __ocelot_read_ix(ocelot, reg, reg##_GSZ * (gi))
|
|
|
|
#define ocelot_read_rix(ocelot, reg, ri) __ocelot_read_ix(ocelot, reg, reg##_RSZ * (ri))
|
|
|
|
#define ocelot_read(ocelot, reg) __ocelot_read_ix(ocelot, reg, 0)
|
|
|
|
|
|
|
|
#define ocelot_write_ix(ocelot, val, reg, gi, ri) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
|
|
|
|
#define ocelot_write_gix(ocelot, val, reg, gi) __ocelot_write_ix(ocelot, val, reg, reg##_GSZ * (gi))
|
|
|
|
#define ocelot_write_rix(ocelot, val, reg, ri) __ocelot_write_ix(ocelot, val, reg, reg##_RSZ * (ri))
|
|
|
|
#define ocelot_write(ocelot, val, reg) __ocelot_write_ix(ocelot, val, reg, 0)
|
|
|
|
|
|
|
|
#define ocelot_rmw_ix(ocelot, val, m, reg, gi, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi) + reg##_RSZ * (ri))
|
|
|
|
#define ocelot_rmw_gix(ocelot, val, m, reg, gi) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_GSZ * (gi))
|
|
|
|
#define ocelot_rmw_rix(ocelot, val, m, reg, ri) __ocelot_rmw_ix(ocelot, val, m, reg, reg##_RSZ * (ri))
|
|
|
|
#define ocelot_rmw(ocelot, val, m, reg) __ocelot_rmw_ix(ocelot, val, m, reg, 0)
|
|
|
|
|
net: mscc: ocelot: convert QSYS_SWITCH_PORT_MODE and SYS_PORT_MODE to regfields
Currently Felix and Ocelot share the same bit layout in these per-port
registers, but Seville does not. So we need reg_fields for that.
Actually since these are per-port registers, we need to also specify the
number of ports, and register size per port, and use the regmap API for
multiple ports.
There's a more subtle point to be made about the other 2 register
fields:
- QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG
- QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE
which we are not writing any longer, for 2 reasons:
- Using the previous API (ocelot_write_rix), we were only writing 1 for
Felix and Ocelot, which was their hardware-default value, and which
there wasn't any intention in changing.
- In the case of SCH_NEXT_CFG, in fact Seville does not have this
register field at all, and therefore, if we want to have common code
we would be required to not write to it.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-13 23:57:03 +07:00
|
|
|
#define ocelot_field_write(ocelot, reg, val) regmap_field_write((ocelot)->regfields[(reg)], (val))
|
|
|
|
#define ocelot_field_read(ocelot, reg, val) regmap_field_read((ocelot)->regfields[(reg)], (val))
|
|
|
|
#define ocelot_fields_write(ocelot, id, reg, val) regmap_fields_write((ocelot)->regfields[(reg)], (id), (val))
|
|
|
|
#define ocelot_fields_read(ocelot, id, reg, val) regmap_fields_read((ocelot)->regfields[(reg)], (id), (val))
|
|
|
|
|
2019-11-14 22:03:27 +07:00
|
|
|
/* I/O */
|
|
|
|
u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
|
|
|
|
void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);
|
|
|
|
u32 __ocelot_read_ix(struct ocelot *ocelot, u32 reg, u32 offset);
|
|
|
|
void __ocelot_write_ix(struct ocelot *ocelot, u32 val, u32 reg, u32 offset);
|
|
|
|
void __ocelot_rmw_ix(struct ocelot *ocelot, u32 val, u32 mask, u32 reg,
|
|
|
|
u32 offset);
|
|
|
|
|
|
|
|
/* Hardware initialization */
|
|
|
|
int ocelot_regfields_init(struct ocelot *ocelot,
|
|
|
|
const struct reg_field *const regfields);
|
|
|
|
struct regmap *ocelot_regmap_init(struct ocelot *ocelot, struct resource *res);
|
net: mscc: ocelot: eliminate confusion between CPU and NPI port
Ocelot has the concept of a CPU port. The CPU port is represented in the
forwarding and the queueing system, but it is not a physical device. The
CPU port can either be accessed via register-based injection/extraction
(which is the case of Ocelot), via Frame-DMA (similar to the first one),
or "connected" to a physical Ethernet port (called NPI in the datasheet)
which is the case of the Felix DSA switch.
In Ocelot the CPU port is at index 11.
In Felix the CPU port is at index 6.
The CPU bit is treated special in the forwarding, as it is never cleared
from the forwarding port mask (once added to it). Other than that, it is
treated the same as a normal front port.
Both Felix and Ocelot should use the CPU port in the same way. This
means that Felix should not use the NPI port directly when forwarding to
the CPU, but instead use the CPU port.
This patch is fixing this such that Felix will use port 6 as its CPU
port, and just use the NPI port to carry the traffic.
Therefore, eliminate the "ocelot->cpu" variable which was holding the
index of the NPI port for Felix, and the index of the CPU port module
for Ocelot, so the variable was actually configuring different things
for different drivers and causing at least part of the confusion.
Also remove the "ocelot->num_cpu_ports" variable, which is the result of
another confusion. The 2 CPU ports mentioned in the datasheet are
because there are two frame extraction channels (register based or DMA
based). This is of no relevance to the driver at the moment, and
invisible to the analyzer module.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Suggested-by: Allan W. Nielsen <allan.nielsen@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-29 21:50:02 +07:00
|
|
|
void ocelot_configure_cpu(struct ocelot *ocelot, int npi,
|
|
|
|
enum ocelot_tag_prefix injection,
|
|
|
|
enum ocelot_tag_prefix extraction);
|
2019-11-14 22:03:27 +07:00
|
|
|
int ocelot_init(struct ocelot *ocelot);
|
|
|
|
void ocelot_deinit(struct ocelot *ocelot);
|
|
|
|
void ocelot_init_port(struct ocelot *ocelot, int port);
|
|
|
|
|
|
|
|
/* DSA callbacks */
|
|
|
|
void ocelot_port_enable(struct ocelot *ocelot, int port,
|
|
|
|
struct phy_device *phy);
|
|
|
|
void ocelot_port_disable(struct ocelot *ocelot, int port);
|
|
|
|
void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data);
|
|
|
|
void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data);
|
|
|
|
int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset);
|
|
|
|
int ocelot_get_ts_info(struct ocelot *ocelot, int port,
|
|
|
|
struct ethtool_ts_info *info);
|
|
|
|
void ocelot_set_ageing_time(struct ocelot *ocelot, unsigned int msecs);
|
|
|
|
void ocelot_adjust_link(struct ocelot *ocelot, int port,
|
|
|
|
struct phy_device *phydev);
|
|
|
|
void ocelot_port_vlan_filtering(struct ocelot *ocelot, int port,
|
|
|
|
bool vlan_aware);
|
|
|
|
void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state);
|
|
|
|
int ocelot_port_bridge_join(struct ocelot *ocelot, int port,
|
|
|
|
struct net_device *bridge);
|
|
|
|
int ocelot_port_bridge_leave(struct ocelot *ocelot, int port,
|
|
|
|
struct net_device *bridge);
|
|
|
|
int ocelot_fdb_dump(struct ocelot *ocelot, int port,
|
|
|
|
dsa_fdb_dump_cb_t *cb, void *data);
|
|
|
|
int ocelot_fdb_add(struct ocelot *ocelot, int port,
|
net: mscc: ocelot: fix untagged packet drops when enslaving to vlan aware bridge
To rehash a previous explanation given in commit 1c44ce560b4d ("net:
mscc: ocelot: fix vlan_filtering when enslaving to bridge before link is
up"), the switch driver operates the in a mode where a single VLAN can
be transmitted as untagged on a particular egress port. That is the
"native VLAN on trunk port" use case.
The configuration for this native VLAN is driven in 2 ways:
- Set the egress port rewriter to strip the VLAN tag for the native
VID (as it is egress-untagged, after all).
- Configure the ingress port to drop untagged and priority-tagged
traffic, if there is no native VLAN. The intention of this setting is
that a trunk port with no native VLAN should not accept untagged
traffic.
Since both of the above configurations for the native VLAN should only
be done if VLAN awareness is requested, they are actually done from the
ocelot_port_vlan_filtering function, after the basic procedure of
toggling the VLAN awareness flag of the port.
But there's a problem with that simplistic approach: we are trying to
juggle with 2 independent variables from a single function:
- Native VLAN of the port - its value is held in port->vid.
- VLAN awareness state of the port - currently there are some issues
here, more on that later*.
The actual problem can be seen when enslaving the switch ports to a VLAN
filtering bridge:
0. The driver configures a pvid of zero for each port, when in
standalone mode. While the bridge configures a default_pvid of 1 for
each port that gets added as a slave to it.
1. The bridge calls ocelot_port_vlan_filtering with vlan_aware=true.
The VLAN-filtering-dependent portion of the native VLAN
configuration is done, considering that the native VLAN is 0.
2. The bridge calls ocelot_vlan_add with vid=1, pvid=true,
untagged=true. The native VLAN changes to 1 (change which gets
propagated to hardware).
3. ??? - nobody calls ocelot_port_vlan_filtering again, to reapply the
VLAN-filtering-dependent portion of the native VLAN configuration,
for the new native VLAN of 1. One can notice that after toggling "ip
link set dev br0 type bridge vlan_filtering 0 && ip link set dev br0
type bridge vlan_filtering 1", the new native VLAN finally makes it
through and untagged traffic finally starts flowing again. But
obviously that shouldn't be needed.
So it is clear that 2 independent variables need to both re-trigger the
native VLAN configuration. So we introduce the second variable as
ocelot_port->vlan_aware.
*Actually both the DSA Felix driver and the Ocelot driver already had
each its own variable:
- Ocelot: ocelot_port_private->vlan_aware
- Felix: dsa_port->vlan_filtering
but the common Ocelot library needs to work with a single, common,
variable, so there is some refactoring done to move the vlan_aware
property from the private structure into the common ocelot_port
structure.
Fixes: 97bb69e1e36e ("net: mscc: ocelot: break apart ocelot_vlan_port_apply")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-15 02:36:15 +07:00
|
|
|
const unsigned char *addr, u16 vid);
|
2019-11-14 22:03:27 +07:00
|
|
|
int ocelot_fdb_del(struct ocelot *ocelot, int port,
|
|
|
|
const unsigned char *addr, u16 vid);
|
|
|
|
int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid,
|
|
|
|
bool untagged);
|
|
|
|
int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid);
|
2019-11-20 15:23:14 +07:00
|
|
|
int ocelot_hwstamp_get(struct ocelot *ocelot, int port, struct ifreq *ifr);
|
|
|
|
int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr);
|
2019-11-20 15:23:16 +07:00
|
|
|
int ocelot_port_add_txtstamp_skb(struct ocelot_port *ocelot_port,
|
|
|
|
struct sk_buff *skb);
|
2019-11-20 15:23:15 +07:00
|
|
|
void ocelot_get_txtstamp(struct ocelot *ocelot);
|
2020-03-28 02:55:47 +07:00
|
|
|
void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu);
|
|
|
|
int ocelot_get_max_mtu(struct ocelot *ocelot, int port);
|
2020-03-29 18:52:00 +07:00
|
|
|
int ocelot_port_policer_add(struct ocelot *ocelot, int port,
|
|
|
|
struct ocelot_policer *pol);
|
|
|
|
int ocelot_port_policer_del(struct ocelot *ocelot, int port);
|
2020-02-29 21:31:14 +07:00
|
|
|
int ocelot_cls_flower_replace(struct ocelot *ocelot, int port,
|
|
|
|
struct flow_cls_offload *f, bool ingress);
|
|
|
|
int ocelot_cls_flower_destroy(struct ocelot *ocelot, int port,
|
|
|
|
struct flow_cls_offload *f, bool ingress);
|
|
|
|
int ocelot_cls_flower_stats(struct ocelot *ocelot, int port,
|
|
|
|
struct flow_cls_offload *f, bool ingress);
|
2020-06-21 18:46:01 +07:00
|
|
|
int ocelot_port_mdb_add(struct ocelot *ocelot, int port,
|
|
|
|
const struct switchdev_obj_port_mdb *mdb);
|
|
|
|
int ocelot_port_mdb_del(struct ocelot *ocelot, int port,
|
|
|
|
const struct switchdev_obj_port_mdb *mdb);
|
2019-11-14 22:03:27 +07:00
|
|
|
|
|
|
|
#endif
|