1 From a893019278e8030fbe251cdaa9d93b8257d1c083 Mon Sep 17 00:00:00 2001
2 From: Ioana Radulescu <ruxandra.radulescu@nxp.com>
3 Date: Thu, 5 Sep 2019 19:31:32 +0300
4 Subject: [PATCH] dpaa2-eth: Add DCB ops
6 Add a skeleton implementation of DCB PFC ops. Actual hardware
7 configuration to be added in further commits.
9 Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
11 drivers/net/ethernet/freescale/dpaa2/Kconfig | 9 +++
12 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 84 ++++++++++++++++++++++++
13 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h | 5 ++
14 3 files changed, 98 insertions(+)
16 --- a/drivers/net/ethernet/freescale/dpaa2/Kconfig
17 +++ b/drivers/net/ethernet/freescale/dpaa2/Kconfig
18 @@ -8,6 +8,15 @@ config FSL_DPAA2_ETH
19 The driver manages network objects discovered on the Freescale
23 +config FSL_DPAA2_ETH_DCB
24 + bool "Data Center Bridging (DCB) Support"
28 + Enable Priority-Based Flow Control (PFC) support in the driver
31 config FSL_DPAA2_PTP_CLOCK
32 tristate "Freescale DPAA2 PTP Clock"
33 depends on FSL_DPAA2_ETH && PTP_1588_CLOCK_QORIQ
34 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
35 +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
36 @@ -3614,6 +3614,81 @@ static void del_ch_napi(struct dpaa2_eth
40 +#ifdef CONFIG_FSL_DPAA2_ETH_DCB
41 +static int dpaa2_eth_dcbnl_ieee_getpfc(struct net_device *net_dev,
42 + struct ieee_pfc *pfc)
44 + struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
46 + memcpy(pfc, &priv->pfc, sizeof(priv->pfc));
47 + pfc->pfc_cap = dpaa2_eth_tc_count(priv);
52 +static int dpaa2_eth_dcbnl_ieee_setpfc(struct net_device *net_dev,
53 + struct ieee_pfc *pfc)
55 + struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
57 + if (pfc->mbc || pfc->delay)
60 + /* If same PFC enabled mask, nothing to do */
61 + if (priv->pfc.pfc_en == pfc->pfc_en)
64 + memcpy(&priv->pfc, pfc, sizeof(priv->pfc));
69 +static u8 dpaa2_eth_dcbnl_getdcbx(struct net_device *net_dev)
71 + struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
73 + return priv->dcbx_mode;
76 +static u8 dpaa2_eth_dcbnl_setdcbx(struct net_device *net_dev, u8 mode)
78 + struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
80 + priv->dcbx_mode = mode;
84 +static u8 dpaa2_eth_dcbnl_getcap(struct net_device *net_dev, int capid, u8 *cap)
86 + struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
89 + case DCB_CAP_ATTR_PFC:
92 + case DCB_CAP_ATTR_PFC_TCS:
93 + *cap = 1 << (dpaa2_eth_tc_count(priv) - 1);
95 + case DCB_CAP_ATTR_DCBX:
96 + *cap = priv->dcbx_mode;
106 +const struct dcbnl_rtnl_ops dpaa2_eth_dcbnl_ops = {
107 + .ieee_getpfc = dpaa2_eth_dcbnl_ieee_getpfc,
108 + .ieee_setpfc = dpaa2_eth_dcbnl_ieee_setpfc,
109 + .getdcbx = dpaa2_eth_dcbnl_getdcbx,
110 + .setdcbx = dpaa2_eth_dcbnl_setdcbx,
111 + .getcap = dpaa2_eth_dcbnl_getcap,
115 static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev)
118 @@ -3703,6 +3778,15 @@ static int dpaa2_eth_probe(struct fsl_mc
120 goto err_alloc_rings;
122 +#ifdef CONFIG_FSL_DPAA2_ETH_DCB
123 + if (dpaa2_eth_has_pause_support(priv) && priv->vlan_cls_enabled) {
124 + priv->dcbx_mode = DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_IEEE;
125 + net_dev->dcbnl_ops = &dpaa2_eth_dcbnl_ops;
127 + dev_dbg(dev, "PFC not supported\n");
131 err = setup_irqs(dpni_dev);
133 netdev_warn(net_dev, "Failed to set link interrupt, fall back to polling\n");
134 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h
135 +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h
137 #ifndef __DPAA2_ETH_H
138 #define __DPAA2_ETH_H
140 +#include <linux/dcbnl.h>
141 #include <linux/netdevice.h>
142 #include <linux/if_vlan.h>
143 #include <linux/fsl/mc.h>
144 @@ -423,6 +424,10 @@ struct dpaa2_eth_priv {
145 struct dpaa2_eth_cls_rule *cls_rules;
148 +#ifdef CONFIG_FSL_DPAA2_ETH_DCB
150 + struct ieee_pfc pfc;
152 struct bpf_prog *xdp_prog;
153 #ifdef CONFIG_DEBUG_FS
154 struct dpaa2_debugfs dbg;