net: mscc: ocelot: annotate which traps need PTP timestamping
authorVladimir Oltean <vladimir.oltean@nxp.com>
Wed, 16 Feb 2022 14:30:11 +0000 (16:30 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 17 Feb 2022 14:06:51 +0000 (14:06 +0000)
The ocelot switch library does not need this information, but the felix
DSA driver does.

As a reminder, the VSC9959 switch in LS1028A doesn't have an IRQ line
for packet extraction, so to be notified that a PTP packet needs to be
dequeued, it receives that packet also over Ethernet, by setting up a
packet trap. The Felix driver needs to install special kinds of traps
for packets in need of RX timestamps, such that the packets are
replicated both over Ethernet and over the CPU port module.

But the Ocelot switch library sets up more than one trap for PTP event
messages; it also traps PTP general messages, MRP control messages etc.
Those packets don't need PTP timestamps, so there's no reason for the
Felix driver to send them to the CPU port module.

By knowing which traps need PTP timestamps, the Felix driver can
adjust the traps installed using ocelot_trap_add() such that only those
will actually get delivered to the CPU port module.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mscc/ocelot.c
drivers/net/ethernet/mscc/ocelot.h
drivers/net/ethernet/mscc/ocelot_mrp.c
include/soc/mscc/ocelot_vcap.h

index 5356d93169435353285d2e2663ba6feb0a91cefe..26f8cf235504dd73fc508bae8cf0e839a524dbee 100644 (file)
@@ -1468,7 +1468,8 @@ ocelot_populate_ipv6_ptp_general_trap_key(struct ocelot_vcap_filter *trap)
        trap->key.ipv6.dport.mask = 0xffff;
 }
 
-int ocelot_trap_add(struct ocelot *ocelot, int port, unsigned long cookie,
+int ocelot_trap_add(struct ocelot *ocelot, int port,
+                   unsigned long cookie, bool take_ts,
                    void (*populate)(struct ocelot_vcap_filter *f))
 {
        struct ocelot_vcap_block *block_vcap_is2;
@@ -1495,6 +1496,7 @@ int ocelot_trap_add(struct ocelot *ocelot, int port, unsigned long cookie,
                trap->action.cpu_copy_ena = true;
                trap->action.mask_mode = OCELOT_MASK_MODE_PERMIT_DENY;
                trap->action.port_mask = 0;
+               trap->take_ts = take_ts;
                list_add_tail(&trap->trap_list, &ocelot->traps);
                new = true;
        }
@@ -1543,7 +1545,7 @@ static int ocelot_l2_ptp_trap_add(struct ocelot *ocelot, int port)
 {
        unsigned long l2_cookie = OCELOT_VCAP_IS2_L2_PTP_TRAP(ocelot);
 
-       return ocelot_trap_add(ocelot, port, l2_cookie,
+       return ocelot_trap_add(ocelot, port, l2_cookie, true,
                               ocelot_populate_l2_ptp_trap_key);
 }
 
@@ -1560,12 +1562,12 @@ static int ocelot_ipv4_ptp_trap_add(struct ocelot *ocelot, int port)
        unsigned long ipv4_ev_cookie = OCELOT_VCAP_IS2_IPV4_EV_PTP_TRAP(ocelot);
        int err;
 
-       err = ocelot_trap_add(ocelot, port, ipv4_ev_cookie,
+       err = ocelot_trap_add(ocelot, port, ipv4_ev_cookie, true,
                              ocelot_populate_ipv4_ptp_event_trap_key);
        if (err)
                return err;
 
-       err = ocelot_trap_add(ocelot, port, ipv4_gen_cookie,
+       err = ocelot_trap_add(ocelot, port, ipv4_gen_cookie, false,
                              ocelot_populate_ipv4_ptp_general_trap_key);
        if (err)
                ocelot_trap_del(ocelot, port, ipv4_ev_cookie);
@@ -1590,12 +1592,12 @@ static int ocelot_ipv6_ptp_trap_add(struct ocelot *ocelot, int port)
        unsigned long ipv6_ev_cookie = OCELOT_VCAP_IS2_IPV6_EV_PTP_TRAP(ocelot);
        int err;
 
-       err = ocelot_trap_add(ocelot, port, ipv6_ev_cookie,
+       err = ocelot_trap_add(ocelot, port, ipv6_ev_cookie, true,
                              ocelot_populate_ipv6_ptp_event_trap_key);
        if (err)
                return err;
 
-       err = ocelot_trap_add(ocelot, port, ipv6_gen_cookie,
+       err = ocelot_trap_add(ocelot, port, ipv6_gen_cookie, false,
                              ocelot_populate_ipv6_ptp_general_trap_key);
        if (err)
                ocelot_trap_del(ocelot, port, ipv6_ev_cookie);
index 674043cd9088f864897c31a41829da56aca71c01..5277c4b53af4f747f01c32d611b7f6507cfdd639 100644 (file)
@@ -103,7 +103,8 @@ int ocelot_port_devlink_init(struct ocelot *ocelot, int port,
                             enum devlink_port_flavour flavour);
 void ocelot_port_devlink_teardown(struct ocelot *ocelot, int port);
 
-int ocelot_trap_add(struct ocelot *ocelot, int port, unsigned long cookie,
+int ocelot_trap_add(struct ocelot *ocelot, int port,
+                   unsigned long cookie, bool take_ts,
                    void (*populate)(struct ocelot_vcap_filter *f));
 int ocelot_trap_del(struct ocelot *ocelot, int port, unsigned long cookie);
 
index 68fa833f4aaa85628a038efa56064471fe040c38..142e897ea2af1c65974ca9056471ff3afd6c76a3 100644 (file)
@@ -92,7 +92,7 @@ static int ocelot_mrp_trap_add(struct ocelot *ocelot, int port)
 {
        unsigned long cookie = OCELOT_VCAP_IS2_MRP_TRAP(ocelot);
 
-       return ocelot_trap_add(ocelot, port, cookie,
+       return ocelot_trap_add(ocelot, port, cookie, false,
                               ocelot_populate_mrp_trap_key);
 }
 
index 69b3d880302d8cccdb0793500aaba3c09eb6fd40..50af64e2ca3c76404ead039443de068221a6a9b5 100644 (file)
@@ -695,6 +695,7 @@ struct ocelot_vcap_filter {
        struct ocelot_vcap_action action;
        struct ocelot_vcap_stats stats;
        /* For VCAP IS1 and IS2 */
+       bool take_ts;
        unsigned long ingress_port_mask;
        /* For VCAP ES0 */
        struct ocelot_vcap_port ingress_port;