Commit 58356eb3 authored by Vignesh Raghavendra's avatar Vignesh Raghavendra Committed by David S. Miller

net: ti: am65-cpsw-nuss: Add devlink support

AM65 NUSS ethernet switch on K3 devices can be configured to work either
in independent mac mode where each port acts as independent network
interface (multi mac) or switch mode.

Add devlink hooks to provide a way to switch b/w these modes.

Rationale to use devlink instead of defaulting to bridge mode is that
SoC use cases require to support multiple independent MAC ports with no
switching so that users can use software bridges with multi-mac
configuration (e.g: to support LAG, HSR/PRP, etc). Also, switching
between multi mac and switch mode requires significant Port and ALE
reconfiguration, therefore is easier to be made as part of mode change
devlink hooks. It also allows to keep user interface similar to what
was implemented for the previous generation of TI CPSW IP
(on AM33/AM43/AM57 SoCs).
Signed-off-by: default avatarVignesh Raghavendra <vigneshr@ti.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b4e18b29
.. SPDX-License-Identifier: GPL-2.0
==============================
am65-cpsw-nuss devlink support
==============================
This document describes the devlink features implemented by the ``am65-cpsw-nuss``
device driver.
Parameters
==========
The ``am65-cpsw-nuss`` driver implements the following driver-specific
parameters.
.. list-table:: Driver-specific parameters implemented
:widths: 5 5 5 85
* - Name
- Type
- Mode
- Description
* - ``switch_mode``
- Boolean
- runtime
- Enable switch mode
...@@ -45,3 +45,4 @@ parameters, info versions, and other features it supports. ...@@ -45,3 +45,4 @@ parameters, info versions, and other features it supports.
sja1105 sja1105
qed qed
ti-cpsw-switch ti-cpsw-switch
am65-nuss-cpsw-switch
...@@ -92,6 +92,7 @@ config TI_CPTS ...@@ -92,6 +92,7 @@ config TI_CPTS
config TI_K3_AM65_CPSW_NUSS config TI_K3_AM65_CPSW_NUSS
tristate "TI K3 AM654x/J721E CPSW Ethernet driver" tristate "TI K3 AM654x/J721E CPSW Ethernet driver"
depends on ARCH_K3 && OF && TI_K3_UDMA_GLUE_LAYER depends on ARCH_K3 && OF && TI_K3_UDMA_GLUE_LAYER
select NET_DEVLINK
select TI_DAVINCI_MDIO select TI_DAVINCI_MDIO
imply PHY_TI_GMII_SEL imply PHY_TI_GMII_SEL
depends on TI_K3_AM65_CPTS || !TI_K3_AM65_CPTS depends on TI_K3_AM65_CPTS || !TI_K3_AM65_CPTS
...@@ -105,6 +106,15 @@ config TI_K3_AM65_CPSW_NUSS ...@@ -105,6 +106,15 @@ config TI_K3_AM65_CPSW_NUSS
To compile this driver as a module, choose M here: the module To compile this driver as a module, choose M here: the module
will be called ti-am65-cpsw-nuss. will be called ti-am65-cpsw-nuss.
config TI_K3_AM65_CPSW_SWITCHDEV
bool "TI K3 AM654x/J721E CPSW Switch mode support"
depends on TI_K3_AM65_CPSW_NUSS
depends on NET_SWITCHDEV
help
This enables switchdev support for TI K3 CPSWxG Ethernet
Switch. Enable this driver to support hardware switch support for AM65
CPSW NUSS driver.
config TI_K3_AM65_CPTS config TI_K3_AM65_CPTS
tristate "TI K3 AM65x CPTS" tristate "TI K3 AM65x CPTS"
depends on ARCH_K3 && OF depends on ARCH_K3 && OF
......
This diff is collapsed.
...@@ -6,12 +6,14 @@ ...@@ -6,12 +6,14 @@
#ifndef AM65_CPSW_NUSS_H_ #ifndef AM65_CPSW_NUSS_H_
#define AM65_CPSW_NUSS_H_ #define AM65_CPSW_NUSS_H_
#include <linux/if_ether.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/soc/ti/k3-ringacc.h> #include <linux/soc/ti/k3-ringacc.h>
#include <net/devlink.h>
#include "am65-cpsw-qos.h" #include "am65-cpsw-qos.h"
struct am65_cpts; struct am65_cpts;
...@@ -22,6 +24,8 @@ struct am65_cpts; ...@@ -22,6 +24,8 @@ struct am65_cpts;
#define AM65_CPSW_MAX_RX_QUEUES 1 #define AM65_CPSW_MAX_RX_QUEUES 1
#define AM65_CPSW_MAX_RX_FLOWS 1 #define AM65_CPSW_MAX_RX_FLOWS 1
#define AM65_CPSW_PORT_VLAN_REG_OFFSET 0x014
struct am65_cpsw_slave_data { struct am65_cpsw_slave_data {
bool mac_only; bool mac_only;
struct cpsw_sl *mac_sl; struct cpsw_sl *mac_sl;
...@@ -32,6 +36,7 @@ struct am65_cpsw_slave_data { ...@@ -32,6 +36,7 @@ struct am65_cpsw_slave_data {
bool rx_pause; bool rx_pause;
bool tx_pause; bool tx_pause;
u8 mac_addr[ETH_ALEN]; u8 mac_addr[ETH_ALEN];
int port_vlan;
}; };
struct am65_cpsw_port { struct am65_cpsw_port {
...@@ -47,6 +52,7 @@ struct am65_cpsw_port { ...@@ -47,6 +52,7 @@ struct am65_cpsw_port {
bool tx_ts_enabled; bool tx_ts_enabled;
bool rx_ts_enabled; bool rx_ts_enabled;
struct am65_cpsw_qos qos; struct am65_cpsw_qos qos;
struct devlink_port devlink_port;
}; };
struct am65_cpsw_host { struct am65_cpsw_host {
...@@ -85,6 +91,15 @@ struct am65_cpsw_pdata { ...@@ -85,6 +91,15 @@ struct am65_cpsw_pdata {
const char *ale_dev_id; const char *ale_dev_id;
}; };
enum cpsw_devlink_param_id {
AM65_CPSW_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
AM65_CPSW_DL_PARAM_SWITCH_MODE,
};
struct am65_cpsw_devlink {
struct am65_cpsw_common *common;
};
struct am65_cpsw_common { struct am65_cpsw_common {
struct device *dev; struct device *dev;
struct device *mdio_dev; struct device *mdio_dev;
...@@ -117,6 +132,12 @@ struct am65_cpsw_common { ...@@ -117,6 +132,12 @@ struct am65_cpsw_common {
bool pf_p0_rx_ptype_rrobin; bool pf_p0_rx_ptype_rrobin;
struct am65_cpts *cpts; struct am65_cpts *cpts;
int est_enabled; int est_enabled;
bool is_emac_mode;
u16 br_members;
int default_vlan;
struct devlink *devlink;
unsigned char switch_id[MAX_PHYS_ITEM_ID_LEN];
}; };
struct am65_cpsw_ndev_stats { struct am65_cpsw_ndev_stats {
...@@ -131,6 +152,7 @@ struct am65_cpsw_ndev_priv { ...@@ -131,6 +152,7 @@ struct am65_cpsw_ndev_priv {
u32 msg_enable; u32 msg_enable;
struct am65_cpsw_port *port; struct am65_cpsw_port *port;
struct am65_cpsw_ndev_stats __percpu *stats; struct am65_cpsw_ndev_stats __percpu *stats;
bool offload_fwd_mark;
}; };
#define am65_ndev_to_priv(ndev) \ #define am65_ndev_to_priv(ndev) \
......
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