• Vladimir Oltean's avatar
    net: dsa: felix: update destinations of existing traps with ocelot-8021q · 99348004
    Vladimir Oltean authored
    Historically, the felix DSA driver has installed special traps such that
    PTP over L2 works with the ocelot-8021q tagging protocol; commit
    0a6f17c6 ("net: dsa: tag_ocelot_8021q: add support for PTP
    timestamping") has the details.
    
    Then the ocelot switch library also gained more comprehensive support
    for PTP traps through commit 96ca08c0 ("net: mscc: ocelot: set up
    traps for PTP packets").
    
    Right now, PTP over L2 works using ocelot-8021q via the traps it has set
    for itself, but nothing else does. Consolidating the two code blocks
    would make ocelot-8021q gain support for PTP over L4 and tc-flower
    traps, and at the same time avoid some code and TCAM duplication.
    
    The traps are similar in intent, but different in execution, so some
    explanation is required. The traps set up by felix_setup_mmio_filtering()
    are VCAP IS1 filters, which have a PAG that chains them to a VCAP IS2
    filter, and the IS2 is where the 'trap' action resides. The traps set up
    by ocelot_trap_add(), on the other hand, have a single filter, in VCAP
    IS2. The reason for chaining VCAP IS1 and IS2 in Felix was to ensure
    that the hardcoded traps take precedence and cannot be overridden by the
    Ocelot switch library.
    
    So in principle, the PTP traps needed for ocelot-8021q in the Felix
    driver can rely on ocelot_trap_add(), but the filters need to be patched
    to account for a quirk that LS1028A has: the quirk_no_xtr_irq described
    in commit 0a6f17c6 ("net: dsa: tag_ocelot_8021q: add support for PTP
    timestamping"). Live-patching is done by iterating through the trap list
    every time we know it has been updated, and transforming a trap into a
    redirect + CPU copy if ocelot-8021q is in use.
    
    Making the DSA ocelot-8021q tagger work with the Ocelot traps means we
    can eliminate the dedicated OCELOT_VCAP_IS1_TAG_8021Q_PTP_MMIO and
    OCELOT_VCAP_IS2_TAG_8021Q_PTP_MMIO cookies. To minimize the patch delta,
    OCELOT_VCAP_IS2_MRP_TRAP takes the place of OCELOT_VCAP_IS2_TAG_8021Q_PTP_MMIO
    (the alternative would have been to left-shift all cookie numbers by 1).
    Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    99348004
felix.c 44.5 KB