Skip to content

Commit 07beb16

Browse files
IoanaCiorneidavem330
authored andcommitted
dpaa2-eth: Keep congestion group taildrop enabled when PFC on
Leave congestion group taildrop enabled for all traffic classes when PFC is enabled. Notification threshold is low enough such that it will be hit first and this also ensures that FQs on traffic classes which are not PFC enabled won't drain the buffer pool. FQ taildrop threshold is kept disabled as long as any form of flow control is on. Since FQ taildrop works with bytes, not number of frames, we can't guarantee it will not interfere with the congestion notification mechanism for all frame sizes. Signed-off-by: Ioana Ciornei <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f395b69 commit 07beb16

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-dcb.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ static int dpaa2_eth_dcbnl_ieee_setpfc(struct net_device *net_dev,
6363
{
6464
struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
6565
struct dpni_link_cfg link_cfg = {0};
66+
bool tx_pause;
6667
int err;
6768

6869
if (pfc->mbc || pfc->delay)
@@ -75,8 +76,8 @@ static int dpaa2_eth_dcbnl_ieee_setpfc(struct net_device *net_dev,
7576
/* We allow PFC configuration even if it won't have any effect until
7677
* general pause frames are enabled
7778
*/
78-
if (!dpaa2_eth_rx_pause_enabled(priv->link_state.options) ||
79-
!dpaa2_eth_tx_pause_enabled(priv->link_state.options))
79+
tx_pause = dpaa2_eth_tx_pause_enabled(priv->link_state.options);
80+
if (!dpaa2_eth_rx_pause_enabled(priv->link_state.options) || !tx_pause)
8081
netdev_warn(net_dev, "Pause support must be enabled in order for PFC to work!\n");
8182

8283
link_cfg.rate = priv->link_state.rate;
@@ -97,6 +98,9 @@ static int dpaa2_eth_dcbnl_ieee_setpfc(struct net_device *net_dev,
9798
return err;
9899

99100
memcpy(&priv->pfc, pfc, sizeof(priv->pfc));
101+
priv->pfc_enabled = !!pfc->pfc_en;
102+
103+
dpaa2_eth_set_rx_taildrop(priv, tx_pause, priv->pfc_enabled);
100104

101105
return 0;
102106
}

drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,18 +1287,22 @@ static void disable_ch_napi(struct dpaa2_eth_priv *priv)
12871287
}
12881288
}
12891289

1290-
static void dpaa2_eth_set_rx_taildrop(struct dpaa2_eth_priv *priv,
1291-
bool tx_pause)
1290+
void dpaa2_eth_set_rx_taildrop(struct dpaa2_eth_priv *priv,
1291+
bool tx_pause, bool pfc)
12921292
{
12931293
struct dpni_taildrop td = {0};
12941294
struct dpaa2_eth_fq *fq;
12951295
int i, err;
12961296

1297+
/* FQ taildrop: threshold is in bytes, per frame queue. Enabled if
1298+
* flow control is disabled (as it might interfere with either the
1299+
* buffer pool depletion trigger for pause frames or with the group
1300+
* congestion trigger for PFC frames)
1301+
*/
12971302
td.enable = !tx_pause;
1298-
if (priv->rx_td_enabled == td.enable)
1299-
return;
1303+
if (priv->rx_fqtd_enabled == td.enable)
1304+
goto set_cgtd;
13001305

1301-
/* FQ taildrop: threshold is in bytes, per frame queue */
13021306
td.threshold = DPAA2_ETH_FQ_TAILDROP_THRESH;
13031307
td.units = DPNI_CONGESTION_UNIT_BYTES;
13041308

@@ -1316,9 +1320,20 @@ static void dpaa2_eth_set_rx_taildrop(struct dpaa2_eth_priv *priv,
13161320
}
13171321
}
13181322

1323+
priv->rx_fqtd_enabled = td.enable;
1324+
1325+
set_cgtd:
13191326
/* Congestion group taildrop: threshold is in frames, per group
13201327
* of FQs belonging to the same traffic class
1328+
* Enabled if general Tx pause disabled or if PFCs are enabled
1329+
* (congestion group threhsold for PFC generation is lower than the
1330+
* CG taildrop threshold, so it won't interfere with it; we also
1331+
* want frames in non-PFC enabled traffic classes to be kept in check)
13211332
*/
1333+
td.enable = !tx_pause || (tx_pause && pfc);
1334+
if (priv->rx_cgtd_enabled == td.enable)
1335+
return;
1336+
13221337
td.threshold = DPAA2_ETH_CG_TAILDROP_THRESH(priv);
13231338
td.units = DPNI_CONGESTION_UNIT_FRAMES;
13241339
for (i = 0; i < dpaa2_eth_tc_count(priv); i++) {
@@ -1332,7 +1347,7 @@ static void dpaa2_eth_set_rx_taildrop(struct dpaa2_eth_priv *priv,
13321347
}
13331348
}
13341349

1335-
priv->rx_td_enabled = td.enable;
1350+
priv->rx_cgtd_enabled = td.enable;
13361351
}
13371352

13381353
static int link_state_update(struct dpaa2_eth_priv *priv)
@@ -1353,7 +1368,7 @@ static int link_state_update(struct dpaa2_eth_priv *priv)
13531368
* only when pause frame generation is disabled.
13541369
*/
13551370
tx_pause = dpaa2_eth_tx_pause_enabled(state.options);
1356-
dpaa2_eth_set_rx_taildrop(priv, tx_pause);
1371+
dpaa2_eth_set_rx_taildrop(priv, tx_pause, priv->pfc_enabled);
13571372

13581373
/* When we manage the MAC/PHY using phylink there is no need
13591374
* to manually update the netif_carrier.

drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,8 @@ struct dpaa2_eth_priv {
436436
struct dpaa2_eth_drv_stats __percpu *percpu_extras;
437437

438438
u16 mc_token;
439-
u8 rx_td_enabled;
439+
u8 rx_fqtd_enabled;
440+
u8 rx_cgtd_enabled;
440441

441442
struct dpni_link_state link_state;
442443
bool do_link_poll;
@@ -448,6 +449,7 @@ struct dpaa2_eth_priv {
448449
struct dpaa2_eth_cls_rule *cls_rules;
449450
u8 rx_cls_enabled;
450451
u8 vlan_cls_enabled;
452+
u8 pfc_enabled;
451453
#ifdef CONFIG_FSL_DPAA2_ETH_DCB
452454
u8 dcbx_mode;
453455
struct ieee_pfc pfc;
@@ -584,6 +586,9 @@ int dpaa2_eth_cls_key_size(u64 key);
584586
int dpaa2_eth_cls_fld_off(int prot, int field);
585587
void dpaa2_eth_cls_trim_rule(void *key_mem, u64 fields);
586588

589+
void dpaa2_eth_set_rx_taildrop(struct dpaa2_eth_priv *priv,
590+
bool tx_pause, bool pfc);
591+
587592
extern const struct dcbnl_rtnl_ops dpaa2_eth_dcbnl_ops;
588593

589594
#endif /* __DPAA2_H */

0 commit comments

Comments
 (0)