Commit e462b271 authored by Horatiu Vultur's avatar Horatiu Vultur Committed by David S. Miller

net: lan966x: Add offload support for taprio

Lan966x switch supports time-based egress shaping in hardware
according to IEEE 802.1Qbv. Add support for TAS configuration on
egress port of lan966x switch.
Signed-off-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2a252a0b
...@@ -9,4 +9,4 @@ lan966x-switch-objs := lan966x_main.o lan966x_phylink.o lan966x_port.o \ ...@@ -9,4 +9,4 @@ lan966x-switch-objs := lan966x_main.o lan966x_phylink.o lan966x_port.o \
lan966x_mac.o lan966x_ethtool.o lan966x_switchdev.o \ lan966x_mac.o lan966x_ethtool.o lan966x_switchdev.o \
lan966x_vlan.o lan966x_fdb.o lan966x_mdb.o \ lan966x_vlan.o lan966x_fdb.o lan966x_mdb.o \
lan966x_ptp.o lan966x_fdma.o lan966x_lag.o \ lan966x_ptp.o lan966x_fdma.o lan966x_lag.o \
lan966x_tc.o lan966x_mqprio.o lan966x_tc.o lan966x_mqprio.o lan966x_taprio.o
...@@ -963,6 +963,8 @@ static void lan966x_init(struct lan966x *lan966x) ...@@ -963,6 +963,8 @@ static void lan966x_init(struct lan966x *lan966x)
lan966x, ANA_ANAINTR); lan966x, ANA_ANAINTR);
spin_lock_init(&lan966x->tx_lock); spin_lock_init(&lan966x->tx_lock);
lan966x_taprio_init(lan966x);
} }
static int lan966x_ram_init(struct lan966x *lan966x) static int lan966x_ram_init(struct lan966x *lan966x)
...@@ -1172,6 +1174,7 @@ static int lan966x_remove(struct platform_device *pdev) ...@@ -1172,6 +1174,7 @@ static int lan966x_remove(struct platform_device *pdev)
{ {
struct lan966x *lan966x = platform_get_drvdata(pdev); struct lan966x *lan966x = platform_get_drvdata(pdev);
lan966x_taprio_deinit(lan966x);
lan966x_fdma_deinit(lan966x); lan966x_fdma_deinit(lan966x);
lan966x_cleanup_ports(lan966x); lan966x_cleanup_ports(lan966x);
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/phylink.h> #include <linux/phylink.h>
#include <linux/ptp_clock_kernel.h> #include <linux/ptp_clock_kernel.h>
#include <net/pkt_sched.h>
#include <net/switchdev.h> #include <net/switchdev.h>
#include "lan966x_regs.h" #include "lan966x_regs.h"
...@@ -410,6 +411,8 @@ void lan966x_ptp_txtstamp_release(struct lan966x_port *port, ...@@ -410,6 +411,8 @@ void lan966x_ptp_txtstamp_release(struct lan966x_port *port,
struct sk_buff *skb); struct sk_buff *skb);
irqreturn_t lan966x_ptp_irq_handler(int irq, void *args); irqreturn_t lan966x_ptp_irq_handler(int irq, void *args);
irqreturn_t lan966x_ptp_ext_irq_handler(int irq, void *args); irqreturn_t lan966x_ptp_ext_irq_handler(int irq, void *args);
u32 lan966x_ptp_get_period_ps(void);
int lan966x_ptp_gettime64(struct ptp_clock_info *ptp, struct timespec64 *ts);
int lan966x_fdma_xmit(struct sk_buff *skb, __be32 *ifh, struct net_device *dev); int lan966x_fdma_xmit(struct sk_buff *skb, __be32 *ifh, struct net_device *dev);
int lan966x_fdma_change_mtu(struct lan966x *lan966x); int lan966x_fdma_change_mtu(struct lan966x *lan966x);
...@@ -452,6 +455,13 @@ int lan966x_tc_setup(struct net_device *dev, enum tc_setup_type type, ...@@ -452,6 +455,13 @@ int lan966x_tc_setup(struct net_device *dev, enum tc_setup_type type,
int lan966x_mqprio_add(struct lan966x_port *port, u8 num_tc); int lan966x_mqprio_add(struct lan966x_port *port, u8 num_tc);
int lan966x_mqprio_del(struct lan966x_port *port); int lan966x_mqprio_del(struct lan966x_port *port);
void lan966x_taprio_init(struct lan966x *lan966x);
void lan966x_taprio_deinit(struct lan966x *lan966x);
int lan966x_taprio_add(struct lan966x_port *port,
struct tc_taprio_qopt_offload *qopt);
int lan966x_taprio_del(struct lan966x_port *port);
int lan966x_taprio_speed_set(struct lan966x_port *port, int speed);
static inline void __iomem *lan_addr(void __iomem *base[], static inline void __iomem *lan_addr(void __iomem *base[],
int id, int tinst, int tcnt, int id, int tinst, int tcnt,
int gbase, int ginst, int gbase, int ginst,
......
...@@ -165,6 +165,8 @@ static void lan966x_port_link_up(struct lan966x_port *port) ...@@ -165,6 +165,8 @@ static void lan966x_port_link_up(struct lan966x_port *port)
break; break;
} }
lan966x_taprio_speed_set(port, config->speed);
/* Also the GIGA_MODE_ENA(1) needs to be set regardless of the /* Also the GIGA_MODE_ENA(1) needs to be set regardless of the
* port speed for QSGMII ports. * port speed for QSGMII ports.
*/ */
......
...@@ -464,8 +464,7 @@ static int lan966x_ptp_settime64(struct ptp_clock_info *ptp, ...@@ -464,8 +464,7 @@ static int lan966x_ptp_settime64(struct ptp_clock_info *ptp,
return 0; return 0;
} }
static int lan966x_ptp_gettime64(struct ptp_clock_info *ptp, int lan966x_ptp_gettime64(struct ptp_clock_info *ptp, struct timespec64 *ts)
struct timespec64 *ts)
{ {
struct lan966x_phc *phc = container_of(ptp, struct lan966x_phc, info); struct lan966x_phc *phc = container_of(ptp, struct lan966x_phc, info);
struct lan966x *lan966x = phc->lan966x; struct lan966x *lan966x = phc->lan966x;
...@@ -890,3 +889,9 @@ void lan966x_ptp_rxtstamp(struct lan966x *lan966x, struct sk_buff *skb, ...@@ -890,3 +889,9 @@ void lan966x_ptp_rxtstamp(struct lan966x *lan966x, struct sk_buff *skb,
shhwtstamps = skb_hwtstamps(skb); shhwtstamps = skb_hwtstamps(skb);
shhwtstamps->hwtstamp = full_ts_in_ns; shhwtstamps->hwtstamp = full_ts_in_ns;
} }
u32 lan966x_ptp_get_period_ps(void)
{
/* This represents the system clock period in picoseconds */
return 15125;
}
This diff is collapsed.
...@@ -15,6 +15,13 @@ static int lan966x_tc_setup_qdisc_mqprio(struct lan966x_port *port, ...@@ -15,6 +15,13 @@ static int lan966x_tc_setup_qdisc_mqprio(struct lan966x_port *port,
lan966x_mqprio_del(port); lan966x_mqprio_del(port);
} }
static int lan966x_tc_setup_qdisc_taprio(struct lan966x_port *port,
struct tc_taprio_qopt_offload *taprio)
{
return taprio->enable ? lan966x_taprio_add(port, taprio) :
lan966x_taprio_del(port);
}
int lan966x_tc_setup(struct net_device *dev, enum tc_setup_type type, int lan966x_tc_setup(struct net_device *dev, enum tc_setup_type type,
void *type_data) void *type_data)
{ {
...@@ -23,6 +30,8 @@ int lan966x_tc_setup(struct net_device *dev, enum tc_setup_type type, ...@@ -23,6 +30,8 @@ int lan966x_tc_setup(struct net_device *dev, enum tc_setup_type type,
switch (type) { switch (type) {
case TC_SETUP_QDISC_MQPRIO: case TC_SETUP_QDISC_MQPRIO:
return lan966x_tc_setup_qdisc_mqprio(port, type_data); return lan966x_tc_setup_qdisc_mqprio(port, type_data);
case TC_SETUP_QDISC_TAPRIO:
return lan966x_tc_setup_qdisc_taprio(port, type_data);
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment