net: dsa: tag_qca: return early if dev is not found
Christian Marangi
maintainerPATCH v2 1/5 net: dsa: tag_qca: return early if dev is not found
Currently checksum is recalculated and dsa tag stripped even if we later don't find the dev.
To improve code, exit early if we don't find the dev and skip additional operation on the skb since it will be freed anyway.
--- net/dsa/tag_qca.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/dsa/tag_qca.c +4 -4
@@ -75,10 +75,6 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev)return NULL ; } -/* Remove QCA tag and recalculate checksum */ -skb_pull_rcsum (skb,QCA_HDR_LEN ); -dsa_strip_etype_header (skb,QCA_HDR_LEN ); -/* Get source port information */ port =FIELD_GET (QCA_HDR_RECV_SOURCE_PORT , hdr);
@@ -86,6 +82,10 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev)if (!skb->dev)return NULL ; +/* Remove QCA tag and recalculate checksum */ +skb_pull_rcsum (skb,QCA_HDR_LEN ); +dsa_strip_etype_header (skb,QCA_HDR_LEN ); +return skb; }
Signature · 1 line
2.40.1
Christian Marangi
maintainerPATCH v2 2/5 net: dsa: qca8k: make learning configurable and keep off if standalone
Address learning should initially be turned off by the driver for port operation in standalone mode, then the DSA core handles changes to it via ds->ops->port_bridge_flags().
Currently this is not the case for qca8k where learning is enabled unconditionally in qca8k_setup for every user port.
Handle ports configured in standalone mode by making the learning configurable and not enabling it by default.
Implement .port_pre_bridge_flags and .port_bridge_flags dsa ops to enable learning for bridge that request it and tweak .port_stp_state_set to correctly disable learning when port is configured in standalone mode.
--- drivers/net/dsa/qca/qca8k-8xxx.c | 7 +++-- drivers/net/dsa/qca/qca8k-common.c | 48 ++++++++++++++++++++++++++++++ drivers/net/dsa/qca/qca8k.h | 6 ++++ 3 files changed, 58 insertions(+), 3 deletions(-)
drivers/net/dsa/qca/qca8k-8xxx.c +4 -3
@@ -1870,9 +1870,8 @@ qca8k_setup(struct dsa_switch *ds)if (ret)return ret; -/* Enable ARP Auto-learning by default */ - ret =regmap_set_bits (priv->regmap,QCA8K_PORT_LOOKUP_CTRL (i), -QCA8K_PORT_LOOKUP_LEARN ); + ret =regmap_clear_bits (priv->regmap,QCA8K_PORT_LOOKUP_CTRL (i), +QCA8K_PORT_LOOKUP_LEARN );if (ret)return ret;
@@ -1978,6 +1977,8 @@ static const struct dsa_switch_ops qca8k_switch_ops = { .port_change_mtu = qca8k_port_change_mtu, .port_max_mtu = qca8k_port_max_mtu, .port_stp_state_set = qca8k_port_stp_state_set, + .port_pre_bridge_flags = qca8k_port_pre_bridge_flags, + .port_bridge_flags = qca8k_port_bridge_flags, .port_bridge_join = qca8k_port_bridge_join, .port_bridge_leave = qca8k_port_bridge_leave, .port_fast_age = qca8k_port_fast_age,
drivers/net/dsa/qca/qca8k-common.c +48 -0
71 lines not on this page · raw message
drivers/net/dsa/qca/qca8k.h +6 -0
@@ -522,6 +522,12 @@ int qca8k_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e);/* Common bridge function */ void qca8k_port_stp_state_set (struct dsa_switch *ds,int port,u8 state); +int qca8k_port_pre_bridge_flags (struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack); +int qca8k_port_bridge_flags (struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack); int qca8k_port_bridge_join(struct dsa_switch *ds, int port, struct dsa_bridge bridge, bool *tx_fwd_offload,
Signature · 1 line
2.40.1
Christian Marangi
maintainerPATCH v2 3/5 net: dsa: qca8k: limit user ports access to the first CPU port on setup
In reply to Christian MarangiIn preparation for multi-CPU support, set CPU port LOOKUP MEMBER outside the port loop and setup the LOOKUP MEMBER mask for user ports only to the first CPU port.
This is to handle flooding condition where every CPU port is set as target and prevent packet duplication for unknown frames from user ports.
Secondary CPU port LOOKUP MEMBER mask will be setup later when port_change_master will be implemented.
--- drivers/net/dsa/qca/qca8k-8xxx.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/net/dsa/qca/qca8k-8xxx.c +6 -8
@@ -1850,18 +1850,16 @@ qca8k_setup(struct dsa_switch *ds)if (ret)return ret; +/* CPU port gets connected to all user ports of the switch */ + ret =qca8k_rmw (priv,QCA8K_PORT_LOOKUP_CTRL (cpu_port), +QCA8K_PORT_LOOKUP_MEMBER ,dsa_user_ports (ds)); +if (ret) +return ret; +/* Setup connection between CPU port & user ports * Configure specific switch configuration for ports */ for (i =0 ; i <QCA8K_NUM_PORTS ; i++) { -/* CPU port gets connected to all user ports of the switch */ -if (dsa_is_cpu_port (ds, i)) { - ret =qca8k_rmw (priv,QCA8K_PORT_LOOKUP_CTRL (i), -QCA8K_PORT_LOOKUP_MEMBER ,dsa_user_ports (ds)); -if (ret) -return ret; - } -/* Individual user ports get connected to CPU port only */ if (dsa_is_user_port (ds, i)) { ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(i),
Signature · 1 line
2.40.1
Christian Marangi
maintainerPATCH v2 4/5 net: dsa: qca8k: move qca8xxx hol fixup to separate function
In reply to Christian MarangiMove qca8xxx hol fixup to separate function to tidy things up and to permit using a more efficent loop in future patch.
--- drivers/net/dsa/qca/qca8k-8xxx.c | 78 +++++++++++++++++--------------- 1 file changed, 42 insertions(+), 36 deletions(-)
drivers/net/dsa/qca/qca8k-8xxx.c +42 -36
@@ -1756,6 +1756,46 @@ static int qca8k_connect_tag_protocol(struct dsa_switch *ds,return 0 ; } +static void qca8k_setup_hol_fixup (struct qca8k_priv *priv,int port) +{ +u32 mask; + +switch (port) { +/* The 2 CPU port and port 5 requires some different +* priority than any other ports. +*/ +case 0 : +case 5 : +case 6 : + mask =QCA8K_PORT_HOL_CTRL0_EG_PRI0 (0x3 ) | +QCA8K_PORT_HOL_CTRL0_EG_PRI1 (0x4 ) | +QCA8K_PORT_HOL_CTRL0_EG_PRI2 (0x4 ) | +QCA8K_PORT_HOL_CTRL0_EG_PRI3 (0x4 ) | +QCA8K_PORT_HOL_CTRL0_EG_PRI4 (0x6 ) | +QCA8K_PORT_HOL_CTRL0_EG_PRI5 (0x8 ) | +QCA8K_PORT_HOL_CTRL0_EG_PORT (0x1e ); +break ; +default : + mask =QCA8K_PORT_HOL_CTRL0_EG_PRI0 (0x3 ) | +QCA8K_PORT_HOL_CTRL0_EG_PRI1 (0x4 ) | +QCA8K_PORT_HOL_CTRL0_EG_PRI2 (0x6 ) | +QCA8K_PORT_HOL_CTRL0_EG_PRI3 (0x8 ) | +QCA8K_PORT_HOL_CTRL0_EG_PORT (0x19 ); + } +regmap_write (priv->regmap,QCA8K_REG_PORT_HOL_CTRL0 (port), mask); + + mask =QCA8K_PORT_HOL_CTRL1_ING (0x6 ) | +QCA8K_PORT_HOL_CTRL1_EG_PRI_BUF_EN | +QCA8K_PORT_HOL_CTRL1_EG_PORT_BUF_EN | +QCA8K_PORT_HOL_CTRL1_WRED_EN ; +regmap_update_bits (priv->regmap,QCA8K_REG_PORT_HOL_CTRL1 (port), +QCA8K_PORT_HOL_CTRL1_ING_BUF_MASK | +QCA8K_PORT_HOL_CTRL1_EG_PRI_BUF_EN | +QCA8K_PORT_HOL_CTRL1_EG_PORT_BUF_EN | +QCA8K_PORT_HOL_CTRL1_WRED_EN , + mask); +} +static int qca8k_setup (struct dsa_switch *ds) {
@@ -1895,42 +1935,8 @@ qca8k_setup(struct dsa_switch *ds)* missing settings to improve switch stability under load condition. * This problem is limited to qca8337 and other qca8k switch are not affected. */ -if (priv->switch_id ==QCA8K_ID_QCA8337 ) { -switch (i) { -/* The 2 CPU port and port 5 requires some different -* priority than any other ports. -*/ -case 0 : -case 5 : -case 6 : - mask =QCA8K_PORT_HOL_CTRL0_EG_PRI0 (0x3 ) | -QCA8K_PORT_HOL_CTRL0_EG_PRI1 (0x4 ) | -QCA8K_PORT_HOL_CTRL0_EG_PRI2 (0x4 ) | -QCA8K_PORT_HOL_CTRL0_EG_PRI3 (0x4 ) | -QCA8K_PORT_HOL_CTRL0_EG_PRI4 (0x6 ) | -QCA8K_PORT_HOL_CTRL0_EG_PRI5 (0x8 ) | -QCA8K_PORT_HOL_CTRL0_EG_PORT (0x1e ); -break ; -default : - mask =QCA8K_PORT_HOL_CTRL0_EG_PRI0 (0x3 ) | -QCA8K_PORT_HOL_CTRL0_EG_PRI1 (0x4 ) | -QCA8K_PORT_HOL_CTRL0_EG_PRI2 (0x6 ) | -QCA8K_PORT_HOL_CTRL0_EG_PRI3 (0x8 ) | -QCA8K_PORT_HOL_CTRL0_EG_PORT (0x19 ); - } -qca8k_write (priv,QCA8K_REG_PORT_HOL_CTRL0 (i), mask); - - mask =QCA8K_PORT_HOL_CTRL1_ING (0x6 ) | -QCA8K_PORT_HOL_CTRL1_EG_PRI_BUF_EN | -QCA8K_PORT_HOL_CTRL1_EG_PORT_BUF_EN | -QCA8K_PORT_HOL_CTRL1_WRED_EN ; -qca8k_rmw (priv,QCA8K_REG_PORT_HOL_CTRL1 (i), -QCA8K_PORT_HOL_CTRL1_ING_BUF_MASK | -QCA8K_PORT_HOL_CTRL1_EG_PRI_BUF_EN | -QCA8K_PORT_HOL_CTRL1_EG_PORT_BUF_EN | -QCA8K_PORT_HOL_CTRL1_WRED_EN , - mask); - } +if (priv->switch_id ==QCA8K_ID_QCA8337 ) +qca8k_setup_hol_fixup (priv, i); }/* Special GLOBAL_FC_THRESH value are needed for ar8327 switch */
Signature · 1 line
2.40.1
Simon Horman
reviewerRe: [net-next PATCH v2 4/5] net: dsa: qca8k: move qca8xxx hol fixup to separate function
Quoted 2 lines · Christian Marangi
Move qca8xxx hol fixup to separate function to tidy things up and to permit using a more efficent loop in future patch.
nit: efficent -> efficient
Christian Marangi
maintainerPATCH v2 5/5 net: dsa: qca8k: use dsa_for_each macro instead of for loop
In reply to Christian MarangiConvert for loop to dsa_for_each macro to save some redundant write on unconnected/unused port and tidy things up.
--- drivers/net/dsa/qca/qca8k-8xxx.c | 109 ++++++++++++++++--------------- 1 file changed, 57 insertions(+), 52 deletions(-)
drivers/net/dsa/qca/qca8k-8xxx.c +57 -52
@@ -1800,7 +1800,8 @@ static int qca8k_setup(struct dsa_switch *ds) {struct qca8k_priv *priv = ds->priv; -int cpu_port, ret, i; +int cpu_port, ret, port; +struct dsa_port *dp;u32 mask; cpu_port =qca8k_find_cpu_port (ds);
@@ -1855,27 +1856,31 @@ qca8k_setup(struct dsa_switch *ds)dev_warn (priv->dev,"mib init failed" );/* Initial setup of all ports */ -for (i =0 ; i <QCA8K_NUM_PORTS ; i++) { +dsa_switch_for_each_port (dp, ds) { + port = dp->index; +/* Disable forwarding by default on all ports */ - ret =qca8k_rmw (priv,QCA8K_PORT_LOOKUP_CTRL (i), + ret =qca8k_rmw (priv,QCA8K_PORT_LOOKUP_CTRL (port),QCA8K_PORT_LOOKUP_MEMBER ,0 );if (ret)return ret; -/* Enable QCA header mode on all cpu ports */ -if (dsa_is_cpu_port (ds, i)) { - ret =qca8k_write (priv,QCA8K_REG_PORT_HDR_CTRL (i), -FIELD_PREP (QCA8K_PORT_HDR_CTRL_TX_MASK ,QCA8K_PORT_HDR_CTRL_ALL ) | -FIELD_PREP (QCA8K_PORT_HDR_CTRL_RX_MASK ,QCA8K_PORT_HDR_CTRL_ALL )); -if (ret) { -dev_err (priv->dev,"failed enabling QCA header mode" ); -return ret; - } - } -/* Disable MAC by default on all user ports */ if (dsa_is_user_port (ds, i)) -qca8k_port_set_status (priv, i,0 ); +qca8k_port_set_status (priv, port,0 ); + } + +/* Enable QCA header mode on all cpu ports */ +dsa_switch_for_each_cpu_port (dp, ds) { + port = dp->index; + + ret =qca8k_write (priv,QCA8K_REG_PORT_HDR_CTRL (port), +FIELD_PREP (QCA8K_PORT_HDR_CTRL_TX_MASK ,QCA8K_PORT_HDR_CTRL_ALL ) | +FIELD_PREP (QCA8K_PORT_HDR_CTRL_RX_MASK ,QCA8K_PORT_HDR_CTRL_ALL )); +if (ret) { +dev_err (priv->dev,"failed enabling QCA header mode on port %d" , port); +return ret; + } }/* Forward all unknown frames to CPU port for Linux processing
@@ -1897,48 +1902,48 @@ qca8k_setup(struct dsa_switch *ds)return ret;/* Setup connection between CPU port & user ports -* Configure specific switch configuration for ports +* Individual user ports get connected to CPU port only */ -for (i =0 ; i <QCA8K_NUM_PORTS ; i++) { -/* Individual user ports get connected to CPU port only */ -if (dsa_is_user_port (ds, i)) { - ret =qca8k_rmw (priv,QCA8K_PORT_LOOKUP_CTRL (i), -QCA8K_PORT_LOOKUP_MEMBER , -BIT (cpu_port)); -if (ret) -return ret; - - ret =regmap_clear_bits (priv->regmap,QCA8K_PORT_LOOKUP_CTRL (i), -QCA8K_PORT_LOOKUP_LEARN ); -if (ret) -return ret; - -/* For port based vlans to work we need to set the -* default egress vid -*/ - ret =qca8k_rmw (priv,QCA8K_EGRESS_VLAN (i), -QCA8K_EGREES_VLAN_PORT_MASK (i), -QCA8K_EGREES_VLAN_PORT (i,QCA8K_PORT_VID_DEF )); -if (ret) -return ret; - - ret =qca8k_write (priv,QCA8K_REG_PORT_VLAN_CTRL0 (i), -QCA8K_PORT_VLAN_CVID (QCA8K_PORT_VID_DEF ) | -QCA8K_PORT_VLAN_SVID (QCA8K_PORT_VID_DEF )); -if (ret) -return ret; - } +dsa_switch_for_each_user_port (dp, ds) { + port = dp->index; -/* The port 5 of the qca8337 have some problem in flood condition. The -* original legacy driver had some specific buffer and priority settings -* for the different port suggested by the QCA switch team. Add this -* missing settings to improve switch stability under load condition. -* This problem is limited to qca8337 and other qca8k switch are not affected. + ret =qca8k_rmw (priv,QCA8K_PORT_LOOKUP_CTRL (port), +QCA8K_PORT_LOOKUP_MEMBER , +BIT (cpu_port)); +if (ret) +return ret; + + ret =regmap_clear_bits (priv->regmap,QCA8K_PORT_LOOKUP_CTRL (port), +QCA8K_PORT_LOOKUP_LEARN ); +if (ret) +return ret; + +/* For port based vlans to work we need to set the +* default egress vid */ -if (priv->switch_id ==QCA8K_ID_QCA8337 ) -qca8k_setup_hol_fixup (priv, i); + ret =qca8k_rmw (priv,QCA8K_EGRESS_VLAN (port), +QCA8K_EGREES_VLAN_PORT_MASK (port), +QCA8K_EGREES_VLAN_PORT (port,QCA8K_PORT_VID_DEF )); +if (ret) +return ret; + + ret =qca8k_write (priv,QCA8K_REG_PORT_VLAN_CTRL0 (port), +QCA8K_PORT_VLAN_CVID (QCA8K_PORT_VID_DEF ) | +QCA8K_PORT_VLAN_SVID (QCA8K_PORT_VID_DEF )); +if (ret) +return ret; } +/* The port 5 of the qca8337 have some problem in flood condition. The +* original legacy driver had some specific buffer and priority settings +* for the different port suggested by the QCA switch team. Add this +* missing settings to improve switch stability under load condition. +* This problem is limited to qca8337 and other qca8k switch are not affected. +*/ +if (priv->switch_id ==QCA8K_ID_QCA8337 ) +dsa_switch_for_each_available_port (dp, ds) +qca8k_setup_hol_fixup (priv, dp->index); +/* Special GLOBAL_FC_THRESH value are needed for ar8327 switch */ if (priv->switch_id ==QCA8K_ID_QCA8327 ) { mask = QCA8K_GLOBAL_FC_GOL_XON_THRES(288) |
Signature · 1 line
2.40.1
kernel test robot
build botRe: [net-next PATCH v2 5/5] net: dsa: qca8k: use dsa_for_each macro instead of for loop
kernel test robot noticed the following build errors:
Hi Christian,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/net-dsa-qca8k-make-learning-configurable-and-keep-off-if-standalone/20230729-195747 base: net-next/main patch link: https://lore.kernel.org/r/20230729115509.32601-5-ansuelsmth%40gmail.com patch subject: [net-next PATCH v2 5/5] net: dsa: qca8k: use dsa_for_each macro instead of for loop config: i386-randconfig-i006-20230729 (https://download.01.org/0day-ci/archive/20230730/[email protected]/config) compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce: (https://download.01.org/0day-ci/archive/20230730/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> drivers/net/dsa/qca/qca8k-8xxx.c:1869:28: error: use of undeclared identifier 'i'
if (dsa_is_user_port(ds, i))
^1 error generated.
vim +/i +1869 drivers/net/dsa/qca/qca8k-8xxx.c
1798
1799 static int
1800 qca8k_setup(struct dsa_switch *ds)
1801 {
1802 struct qca8k_priv *priv = ds->priv;
1803 int cpu_port, ret, port;
1804 struct dsa_port *dp;
1805 u32 mask;
1806
1807 cpu_port = qca8k_find_cpu_port(ds);
1808 if (cpu_port < 0) {
1809 dev_err(priv->dev, "No cpu port configured in both cpu port0 and port6");
1810 return cpu_port;
1811 }
1812
1813 /* Parse CPU port config to be later used in phy_link mac_config */
1814 ret = qca8k_parse_port_config(priv);
1815 if (ret)
1816 return ret;
1817
1818 ret = qca8k_setup_mdio_bus(priv);
1819 if (ret)
1820 return ret;
1821
1822 ret = qca8k_setup_of_pws_reg(priv);
1823 if (ret)
1824 return ret;
1825
1826 ret = qca8k_setup_mac_pwr_sel(priv);
1827 if (ret)
1828 return ret;
1829
1830 ret = qca8k_setup_led_ctrl(priv);
1831 if (ret)
1832 return ret;
1833
1834 qca8k_setup_pcs(priv, &priv->pcs_port_0, 0);
1835 qca8k_setup_pcs(priv, &priv->pcs_port_6, 6);
1836
1837 /* Make sure MAC06 is disabled */
1838 ret = regmap_clear_bits(priv->regmap, QCA8K_REG_PORT0_PAD_CTRL,
1839 QCA8K_PORT0_PAD_MAC06_EXCHANGE_EN);
1840 if (ret) {
1841 dev_err(priv->dev, "failed disabling MAC06 exchange");
1842 return ret;
1843 }
1844
1845 /* Enable CPU Port */
1846 ret = regmap_set_bits(priv->regmap, QCA8K_REG_GLOBAL_FW_CTRL0,
1847 QCA8K_GLOBAL_FW_CTRL0_CPU_PORT_EN);
1848 if (ret) {
1849 dev_err(priv->dev, "failed enabling CPU port");
1850 return ret;
1851 }
1852
1853 /* Enable MIB counters */
1854 ret = qca8k_mib_init(priv);
1855 if (ret)
1856 dev_warn(priv->dev, "mib init failed");
1857
1858 /* Initial setup of all ports */
1859 dsa_switch_for_each_port(dp, ds) {
1860 port = dp->index;
1861
1862 /* Disable forwarding by default on all ports */
1863 ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port),
1864 QCA8K_PORT_LOOKUP_MEMBER, 0);
1865 if (ret)
1866 return ret;
1867
1868 /* Disable MAC by default on all user ports */
> 1869 if (dsa_is_user_port(ds, i))
1870 qca8k_port_set_status(priv, port, 0);
1871 }
1872
1873 /* Enable QCA header mode on all cpu ports */
1874 dsa_switch_for_each_cpu_port(dp, ds) {
1875 port = dp->index;
1876
1877 ret = qca8k_write(priv, QCA8K_REG_PORT_HDR_CTRL(port),
1878 FIELD_PREP(QCA8K_PORT_HDR_CTRL_TX_MASK, QCA8K_PORT_HDR_CTRL_ALL) |
1879 FIELD_PREP(QCA8K_PORT_HDR_CTRL_RX_MASK, QCA8K_PORT_HDR_CTRL_ALL));
1880 if (ret) {
1881 dev_err(priv->dev, "failed enabling QCA header mode on port %d", port);
1882 return ret;
1883 }
1884 }
1885
1886 /* Forward all unknown frames to CPU port for Linux processing
1887 * Notice that in multi-cpu config only one port should be set
1888 * for igmp, unknown, multicast and broadcast packet
1889 */
1890 ret = qca8k_write(priv, QCA8K_REG_GLOBAL_FW_CTRL1,
1891 FIELD_PREP(QCA8K_GLOBAL_FW_CTRL1_IGMP_DP_MASK, BIT(cpu_port)) |
1892 FIELD_PREP(QCA8K_GLOBAL_FW_CTRL1_BC_DP_MASK, BIT(cpu_port)) |
1893 FIELD_PREP(QCA8K_GLOBAL_FW_CTRL1_MC_DP_MASK, BIT(cpu_port)) |
1894 FIELD_PREP(QCA8K_GLOBAL_FW_CTRL1_UC_DP_MASK, BIT(cpu_port)));
1895 if (ret)
1896 return ret;
1897
1898 /* CPU port gets connected to all user ports of the switch */
1899 ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(cpu_port),
1900 QCA8K_PORT_LOOKUP_MEMBER, dsa_user_ports(ds));
1901 if (ret)
1902 return ret;
1903
1904 /* Setup connection between CPU port & user ports
1905 * Individual user ports get connected to CPU port only
1906 */
1907 dsa_switch_for_each_user_port(dp, ds) {
1908 port = dp->index;
1909
1910 ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port),
1911 QCA8K_PORT_LOOKUP_MEMBER,
1912 BIT(cpu_port));
1913 if (ret)
1914 return ret;
1915
1916 ret = regmap_clear_bits(priv->regmap, QCA8K_PORT_LOOKUP_CTRL(port),
1917 QCA8K_PORT_LOOKUP_LEARN);
1918 if (ret)
1919 return ret;
1920
1921 /* For port based vlans to work we need to set the
1922 * default egress vid
1923 */
1924 ret = qca8k_rmw(priv, QCA8K_EGRESS_VLAN(port),
1925 QCA8K_EGREES_VLAN_PORT_MASK(port),
1926 QCA8K_EGREES_VLAN_PORT(port, QCA8K_PORT_VID_DEF));
1927 if (ret)
1928 return ret;
1929
1930 ret = qca8k_write(priv, QCA8K_REG_PORT_VLAN_CTRL0(port),
1931 QCA8K_PORT_VLAN_CVID(QCA8K_PORT_VID_DEF) |
1932 QCA8K_PORT_VLAN_SVID(QCA8K_PORT_VID_DEF));
1933 if (ret)
1934 return ret;
1935 }
1936
1937 /* The port 5 of the qca8337 have some problem in flood condition. The
1938 * original legacy driver had some specific buffer and priority settings
1939 * for the different port suggested by the QCA switch team. Add this
1940 * missing settings to improve switch stability under load condition.
1941 * This problem is limited to qca8337 and other qca8k switch are not affected.
1942 */
1943 if (priv->switch_id == QCA8K_ID_QCA8337)
1944 dsa_switch_for_each_available_port(dp, ds)
1945 qca8k_setup_hol_fixup(priv, dp->index);
1946
1947 /* Special GLOBAL_FC_THRESH value are needed for ar8327 switch */
1948 if (priv->switch_id == QCA8K_ID_QCA8327) {
1949 mask = QCA8K_GLOBAL_FC_GOL_XON_THRES(288) |
1950 QCA8K_GLOBAL_FC_GOL_XOFF_THRES(496);
1951 qca8k_rmw(priv, QCA8K_REG_GLOBAL_FC_THRESH,
1952 QCA8K_GLOBAL_FC_GOL_XON_THRES_MASK |
1953 QCA8K_GLOBAL_FC_GOL_XOFF_THRES_MASK,
1954 mask); 1955 }
1956
1957 /* Setup our port MTUs to match power on defaults */
1958 ret = qca8k_write(priv, QCA8K_MAX_FRAME_SIZE, ETH_FRAME_LEN + ETH_FCS_LEN);
1959 if (ret)
1960 dev_warn(priv->dev, "failed setting MTU settings");
1961
1962 /* Flush the FDB table */
1963 qca8k_fdb_flush(priv);
1964
1965 /* Set min a max ageing value supported */
1966 ds->ageing_time_min = 7000;
1967 ds->ageing_time_max = 458745000;
1968
1969 /* Set max number of LAGs supported */
1970 ds->num_lag_ids = QCA8K_NUM_LAGS;
1971
1972 return 0;
1973 }
1974
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [net-next PATCH v2 5/5] net: dsa: qca8k: use dsa_for_each macro instead of for loop
In reply to Christian Marangikernel test robot noticed the following build errors:
Hi Christian,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/net-dsa-qca8k-make-learning-configurable-and-keep-off-if-standalone/20230729-195747 base: net-next/main patch link: https://lore.kernel.org/r/20230729115509.32601-5-ansuelsmth%40gmail.com patch subject: [net-next PATCH v2 5/5] net: dsa: qca8k: use dsa_for_each macro instead of for loop config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20230730/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce: (https://download.01.org/0day-ci/archive/20230730/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/net/dsa/qca/qca8k-8xxx.c: In function 'qca8k_setup':
>> drivers/net/dsa/qca/qca8k-8xxx.c:1869:42: error: 'i' undeclared (first use in this function)
1869 | if (dsa_is_user_port(ds, i))
| ^ drivers/net/dsa/qca/qca8k-8xxx.c:1869:42: note: each undeclared identifier is reported only once for each function it appears in
vim +/i +1869 drivers/net/dsa/qca/qca8k-8xxx.c
1798
1799 static int
1800 qca8k_setup(struct dsa_switch *ds)
1801 {
1802 struct qca8k_priv *priv = ds->priv;
1803 int cpu_port, ret, port;
1804 struct dsa_port *dp;
1805 u32 mask;
1806
1807 cpu_port = qca8k_find_cpu_port(ds);
1808 if (cpu_port < 0) {
1809 dev_err(priv->dev, "No cpu port configured in both cpu port0 and port6");
1810 return cpu_port;
1811 }
1812
1813 /* Parse CPU port config to be later used in phy_link mac_config */
1814 ret = qca8k_parse_port_config(priv);
1815 if (ret)
1816 return ret;
1817
1818 ret = qca8k_setup_mdio_bus(priv);
1819 if (ret)
1820 return ret;
1821
1822 ret = qca8k_setup_of_pws_reg(priv);
1823 if (ret)
1824 return ret;
1825
1826 ret = qca8k_setup_mac_pwr_sel(priv);
1827 if (ret)
1828 return ret;
1829
1830 ret = qca8k_setup_led_ctrl(priv);
1831 if (ret)
1832 return ret;
1833
1834 qca8k_setup_pcs(priv, &priv->pcs_port_0, 0);
1835 qca8k_setup_pcs(priv, &priv->pcs_port_6, 6);
1836
1837 /* Make sure MAC06 is disabled */
1838 ret = regmap_clear_bits(priv->regmap, QCA8K_REG_PORT0_PAD_CTRL,
1839 QCA8K_PORT0_PAD_MAC06_EXCHANGE_EN);
1840 if (ret) {
1841 dev_err(priv->dev, "failed disabling MAC06 exchange");
1842 return ret;
1843 }
1844
1845 /* Enable CPU Port */
1846 ret = regmap_set_bits(priv->regmap, QCA8K_REG_GLOBAL_FW_CTRL0,
1847 QCA8K_GLOBAL_FW_CTRL0_CPU_PORT_EN);
1848 if (ret) {
1849 dev_err(priv->dev, "failed enabling CPU port");
1850 return ret;
1851 }
1852
1853 /* Enable MIB counters */
1854 ret = qca8k_mib_init(priv);
1855 if (ret)
1856 dev_warn(priv->dev, "mib init failed");
1857
1858 /* Initial setup of all ports */
1859 dsa_switch_for_each_port(dp, ds) {
1860 port = dp->index;
1861
1862 /* Disable forwarding by default on all ports */
1863 ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port),
1864 QCA8K_PORT_LOOKUP_MEMBER, 0);
1865 if (ret)
1866 return ret;
1867
1868 /* Disable MAC by default on all user ports */
> 1869 if (dsa_is_user_port(ds, i))
1870 qca8k_port_set_status(priv, port, 0);
1871 }
1872
1873 /* Enable QCA header mode on all cpu ports */
1874 dsa_switch_for_each_cpu_port(dp, ds) {
1875 port = dp->index;
1876
1877 ret = qca8k_write(priv, QCA8K_REG_PORT_HDR_CTRL(port),
1878 FIELD_PREP(QCA8K_PORT_HDR_CTRL_TX_MASK, QCA8K_PORT_HDR_CTRL_ALL) |
1879 FIELD_PREP(QCA8K_PORT_HDR_CTRL_RX_MASK, QCA8K_PORT_HDR_CTRL_ALL));
1880 if (ret) {
1881 dev_err(priv->dev, "failed enabling QCA header mode on port %d", port);
1882 return ret;
1883 }
1884 }
1885
1886 /* Forward all unknown frames to CPU port for Linux processing
1887 * Notice that in multi-cpu config only one port should be set
1888 * for igmp, unknown, multicast and broadcast packet
1889 */
1890 ret = qca8k_write(priv, QCA8K_REG_GLOBAL_FW_CTRL1,
1891 FIELD_PREP(QCA8K_GLOBAL_FW_CTRL1_IGMP_DP_MASK, BIT(cpu_port)) |
1892 FIELD_PREP(QCA8K_GLOBAL_FW_CTRL1_BC_DP_MASK, BIT(cpu_port)) |
1893 FIELD_PREP(QCA8K_GLOBAL_FW_CTRL1_MC_DP_MASK, BIT(cpu_port)) |
1894 FIELD_PREP(QCA8K_GLOBAL_FW_CTRL1_UC_DP_MASK, BIT(cpu_port)));
1895 if (ret)
1896 return ret;
1897
1898 /* CPU port gets connected to all user ports of the switch */
1899 ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(cpu_port),
1900 QCA8K_PORT_LOOKUP_MEMBER, dsa_user_ports(ds));
1901 if (ret)
1902 return ret;
1903
1904 /* Setup connection between CPU port & user ports
1905 * Individual user ports get connected to CPU port only
1906 */
1907 dsa_switch_for_each_user_port(dp, ds) {
1908 port = dp->index;
1909
1910 ret = qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port),
1911 QCA8K_PORT_LOOKUP_MEMBER,
1912 BIT(cpu_port));
1913 if (ret)
1914 return ret;
1915
1916 ret = regmap_clear_bits(priv->regmap, QCA8K_PORT_LOOKUP_CTRL(port),
1917 QCA8K_PORT_LOOKUP_LEARN);
1918 if (ret)
1919 return ret;
1920
1921 /* For port based vlans to work we need to set the
1922 * default egress vid
1923 */
1924 ret = qca8k_rmw(priv, QCA8K_EGRESS_VLAN(port),
1925 QCA8K_EGREES_VLAN_PORT_MASK(port),
1926 QCA8K_EGREES_VLAN_PORT(port, QCA8K_PORT_VID_DEF));
1927 if (ret)
1928 return ret;
1929
1930 ret = qca8k_write(priv, QCA8K_REG_PORT_VLAN_CTRL0(port),
1931 QCA8K_PORT_VLAN_CVID(QCA8K_PORT_VID_DEF) |
1932 QCA8K_PORT_VLAN_SVID(QCA8K_PORT_VID_DEF));
1933 if (ret)
1934 return ret;
1935 }
1936
1937 /* The port 5 of the qca8337 have some problem in flood condition. The
1938 * original legacy driver had some specific buffer and priority settings
1939 * for the different port suggested by the QCA switch team. Add this
1940 * missing settings to improve switch stability under load condition.
1941 * This problem is limited to qca8337 and other qca8k switch are not affected.
1942 */
1943 if (priv->switch_id == QCA8K_ID_QCA8337)
1944 dsa_switch_for_each_available_port(dp, ds)
1945 qca8k_setup_hol_fixup(priv, dp->index);
1946
1947 /* Special GLOBAL_FC_THRESH value are needed for ar8327 switch */
1948 if (priv->switch_id == QCA8K_ID_QCA8327) {
1949 mask = QCA8K_GLOBAL_FC_GOL_XON_THRES(288) |
1950 QCA8K_GLOBAL_FC_GOL_XOFF_THRES(496);
1951 qca8k_rmw(priv, QCA8K_REG_GLOBAL_FC_THRESH,
1952 QCA8K_GLOBAL_FC_GOL_XON_THRES_MASK |
1953 QCA8K_GLOBAL_FC_GOL_XOFF_THRES_MASK,
1954 mask); 1955 }
1956
1957 /* Setup our port MTUs to match power on defaults */
1958 ret = qca8k_write(priv, QCA8K_MAX_FRAME_SIZE, ETH_FRAME_LEN + ETH_FCS_LEN);
1959 if (ret)
1960 dev_warn(priv->dev, "failed setting MTU settings");
1961
1962 /* Flush the FDB table */
1963 qca8k_fdb_flush(priv);
1964
1965 /* Set min a max ageing value supported */
1966 ds->ageing_time_min = 7000;
1967 ds->ageing_time_max = 458745000;
1968
1969 /* Set max number of LAGs supported */
1970 ds->num_lag_ids = QCA8K_NUM_LAGS;
1971
1972 return 0;
1973 }
1974
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki