Commit 3aba35bb authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'lan966x-mqprio-taprio'



Horatiu Vultur says:

====================
net: lan966x: Add mqprio and taprio support

Add support for offloading QoS features with tc command to lan966x. The
offloaded QoS features are mqprio and taprio.

v1->v2:
- fix compilation warning
- rename lan966x_taprio_enable/disable to lan966x_taprio_add/del
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents f948ac23 e462b271
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -8,4 +8,5 @@ obj-$(CONFIG_LAN966X_SWITCH) += lan966x-switch.o
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_ptp.o lan966x_fdma.o lan966x_lag.o \
			lan966x_tc.o lan966x_mqprio.o lan966x_taprio.o
+9 −2
Original line number Diff line number Diff line
@@ -466,6 +466,7 @@ static const struct net_device_ops lan966x_port_netdev_ops = {
	.ndo_set_mac_address		= lan966x_port_set_mac_address,
	.ndo_get_port_parent_id		= lan966x_port_get_parent_id,
	.ndo_eth_ioctl			= lan966x_port_ioctl,
	.ndo_setup_tc			= lan966x_tc_setup,
};

bool lan966x_netdevice_check(const struct net_device *dev)
@@ -738,7 +739,8 @@ static int lan966x_probe_port(struct lan966x *lan966x, u32 p,
		return -EINVAL;

	dev = devm_alloc_etherdev_mqs(lan966x->dev,
				      sizeof(struct lan966x_port), 8, 1);
				      sizeof(struct lan966x_port),
				      NUM_PRIO_QUEUES, 1);
	if (!dev)
		return -ENOMEM;

@@ -754,7 +756,9 @@ static int lan966x_probe_port(struct lan966x *lan966x, u32 p,
	dev->netdev_ops = &lan966x_port_netdev_ops;
	dev->ethtool_ops = &lan966x_ethtool_ops;
	dev->features |= NETIF_F_HW_VLAN_CTAG_TX |
			 NETIF_F_HW_VLAN_STAG_TX;
			 NETIF_F_HW_VLAN_STAG_TX |
			 NETIF_F_HW_TC;
	dev->hw_features |= NETIF_F_HW_TC;
	dev->needed_headroom = IFH_LEN * sizeof(u32);

	eth_hw_addr_gen(dev, lan966x->base_mac, p + 1);
@@ -959,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)
@@ -1168,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);

+17 −0
Original line number Diff line number Diff line
@@ -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"
@@ -36,6 +37,7 @@

#define NUM_PHYS_PORTS			8
#define CPU_PORT			8
#define NUM_PRIO_QUEUES			8

/* Reserved PGIDs */
#define PGID_CPU			(PGID_AGGR - 6)
@@ -409,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);
@@ -445,6 +449,19 @@ void lan966x_port_ageing_set(struct lan966x_port *port,
			     unsigned long ageing_clock_t);
void lan966x_update_fwd_mask(struct lan966x *lan966x);

int lan966x_tc_setup(struct net_device *dev, enum tc_setup_type type,
		     void *type_data);

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,
+28 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0+

#include "lan966x_main.h"

int lan966x_mqprio_add(struct lan966x_port *port, u8 num_tc)
{
	u8 i;

	if (num_tc != NUM_PRIO_QUEUES) {
		netdev_err(port->dev, "Only %d tarffic classes supported\n",
			   NUM_PRIO_QUEUES);
		return -EINVAL;
	}

	netdev_set_num_tc(port->dev, num_tc);

	for (i = 0; i < num_tc; ++i)
		netdev_set_tc_queue(port->dev, i, 1, i);

	return 0;
}

int lan966x_mqprio_del(struct lan966x_port *port)
{
	netdev_reset_tc(port->dev);

	return 0;
}
+2 −0
Original line number Diff line number Diff line
@@ -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.
	 */
Loading