summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBogdan Purcareata <bogdan.purcareata@nxp.com>2017-08-28 08:08:53 (GMT)
committerXie Xiaobo <xiaobo.xie@nxp.com>2017-12-12 07:32:41 (GMT)
commit1cec7a035949d281bf2d9c82446ea0b076771492 (patch)
tree33ac1af31805c3189fe021867fd520170dea6cd8
parent7c1e36a10fd772dc29df94bf937d79692aa60eb0 (diff)
downloadlinux-1cec7a035949d281bf2d9c82446ea0b076771492.tar.xz
staging: fsl-dpaa2/eth: Get PFC config from HW
The dpaa2-eth PFC configuration is kept in a private driver variable. When getting PFC configuration via ieee_getpfc, get it straight from the Management Complex based on the Rx congestion notification setup. Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
-rw-r--r--drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 4cd8a8a..ca036fa 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -3009,8 +3009,37 @@ static int dpaa2_eth_dcbnl_ieee_getpfc(struct net_device *net_dev,
struct ieee_pfc *pfc)
{
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
+ struct dpni_congestion_notification_cfg notification_cfg;
+ struct dpni_link_state state;
+ int err, i;
pfc->pfc_cap = dpaa2_eth_tc_count(priv);
+
+ err = dpni_get_link_state(priv->mc_io, 0, priv->mc_token, &state);
+ if (err) {
+ netdev_err(net_dev, "ERROR %d getting link state", err);
+ return err;
+ }
+
+ if (!(state.options & DPNI_LINK_OPT_PFC_PAUSE))
+ return 0;
+
+ priv->pfc.pfc_en = 0;
+ for (i = 0; i < dpaa2_eth_tc_count(priv); i++) {
+ err = dpni_get_congestion_notification(priv->mc_io, 0,
+ priv->mc_token,
+ DPNI_QUEUE_RX,
+ i, &notification_cfg);
+ if (err) {
+ netdev_err(net_dev, "Error %d getting congestion notif",
+ err);
+ return err;
+ }
+
+ if (notification_cfg.threshold_entry)
+ priv->pfc.pfc_en |= 1 << i;
+ }
+
pfc->pfc_en = priv->pfc.pfc_en;
pfc->mbc = priv->pfc.mbc;
pfc->delay = priv->pfc.delay;