Skip to content

Commit

Permalink
net: lan966x: Add offload support for taprio
Browse files Browse the repository at this point in the history
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: Horatiu Vultur <horatiu.vultur@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Horatiu Vultur authored and David S. Miller committed Sep 23, 2022
1 parent 2a252a0 commit e462b27
Show file tree
Hide file tree
Showing 7 changed files with 560 additions and 3 deletions.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/microchip/lan966x/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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_vlan.o lan966x_fdb.o lan966x_mdb.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
3 changes: 3 additions & 0 deletions drivers/net/ethernet/microchip/lan966x/lan966x_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,8 @@ static void lan966x_init(struct lan966x *lan966x)
lan966x, ANA_ANAINTR);

spin_lock_init(&lan966x->tx_lock);

lan966x_taprio_init(lan966x);
}

static int lan966x_ram_init(struct lan966x *lan966x)
Expand Down Expand Up @@ -1172,6 +1174,7 @@ static int lan966x_remove(struct platform_device *pdev)
{
struct lan966x *lan966x = platform_get_drvdata(pdev);

lan966x_taprio_deinit(lan966x);
lan966x_fdma_deinit(lan966x);
lan966x_cleanup_ports(lan966x);

Expand Down
10 changes: 10 additions & 0 deletions drivers/net/ethernet/microchip/lan966x/lan966x_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/phy.h>
#include <linux/phylink.h>
#include <linux/ptp_clock_kernel.h>
#include <net/pkt_sched.h>
#include <net/switchdev.h>

#include "lan966x_regs.h"
Expand Down Expand Up @@ -410,6 +411,8 @@ void lan966x_ptp_txtstamp_release(struct lan966x_port *port,
struct sk_buff *skb);
irqreturn_t lan966x_ptp_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_change_mtu(struct lan966x *lan966x);
Expand Down Expand Up @@ -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_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[],
int id, int tinst, int tcnt,
int gbase, int ginst,
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/microchip/lan966x/lan966x_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ static void lan966x_port_link_up(struct lan966x_port *port)
break;
}

lan966x_taprio_speed_set(port, config->speed);

/* Also the GIGA_MODE_ENA(1) needs to be set regardless of the
* port speed for QSGMII ports.
*/
Expand Down
9 changes: 7 additions & 2 deletions drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,7 @@ static int lan966x_ptp_settime64(struct ptp_clock_info *ptp,
return 0;
}

static int lan966x_ptp_gettime64(struct ptp_clock_info *ptp,
struct timespec64 *ts)
int lan966x_ptp_gettime64(struct ptp_clock_info *ptp, struct timespec64 *ts)
{
struct lan966x_phc *phc = container_of(ptp, struct lan966x_phc, info);
struct lan966x *lan966x = phc->lan966x;
Expand Down Expand Up @@ -890,3 +889,9 @@ void lan966x_ptp_rxtstamp(struct lan966x *lan966x, struct sk_buff *skb,
shhwtstamps = skb_hwtstamps(skb);
shhwtstamps->hwtstamp = full_ts_in_ns;
}

u32 lan966x_ptp_get_period_ps(void)
{
/* This represents the system clock period in picoseconds */
return 15125;
}
Loading

0 comments on commit e462b27

Please sign in to comment.