eth: fbnic: Configure RDE settings for pause frame
Subsystems (3)
PATCH 1/1 eth: fbnic: Configure RDE settings for pause frame
fbnic supports pause frames. When pause frames are enabled presumably user expects lossless operation from the NIC. Make sure we configure RDE (Rx DMA Engine) to DROP_NEVER mode to avoid discards due to delays in fetching Rx descriptors from the host.
While at it enable DROP_NEVER when NIC only has a single queue configured. In this case the NIC acts as a FIFO so there's no risk of head-of-line blocking other queues by making RDE wait. If pause is disabled this just moves the packet loss from the DMA engine to the Rx buffer.
Remove redundant call to fbnic_config_drop_mode_rcq(), introduced by commit 0cb4c0a13723 ("eth: fbnic: Implement Rx queue alloc/start/stop/free"). This call does not add value as fbnic_enable_rcq(), which is called immediately afterward, already handles this.
--- .../net/ethernet/meta/fbnic/fbnic_netdev.h | 2 ++ .../net/ethernet/meta/fbnic/fbnic_phylink.c | 8 +++++- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 26 ++++++++++++++++--- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 1 + 4 files changed, 32 insertions(+), 5 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic_netdev.h +2 -0
@@ -73,6 +73,8 @@ struct fbnic_net {/* Time stamping filter config */ struct kernel_hwtstamp_config hwtstamp_config; + +bool tx_pause; };int __fbnic_open (struct fbnic_net *fbn);
drivers/net/ethernet/meta/fbnic/fbnic_phylink.c +7 -1
@@ -36,8 +36,13 @@ int fbnic_phylink_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause) {struct fbnic_net *fbn =netdev_priv (netdev); +int err; + + err =phylink_ethtool_set_pauseparam (fbn->phylink, pause); +if (!err) + fbn->tx_pause = pause->tx_pause ? true : false; -return phylink_ethtool_set_pauseparam (fbn->phylink, pause); +return err; } static void
@@ -208,6 +213,7 @@ fbnic_phylink_mac_link_up(struct phylink_config *config,struct fbnic_net *fbn =netdev_priv (netdev);struct fbnic_dev *fbd = fbn->fbd; +fbnic_config_drop_mode (fbn, tx_pause); fbd->mac->link_up (fbd, tx_pause, rx_pause); }
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c +22 -4
@@ -2574,11 +2574,15 @@ static void fbnic_enable_bdq(struct fbnic_ring *hpq, struct fbnic_ring *ppq) }static void fbnic_config_drop_mode_rcq (struct fbnic_napi_vector *nv, -struct fbnic_ring *rcq) +struct fbnic_ring *rcq,bool tx_pause) { +struct fbnic_net *fbn =netdev_priv (nv->napi.dev);u32 drop_mode, rcq_ctl; - drop_mode =FBNIC_QUEUE_RDE_CTL0_DROP_IMMEDIATE ; +if (!tx_pause && fbn->num_rx_queues >1 ) + drop_mode =FBNIC_QUEUE_RDE_CTL0_DROP_IMMEDIATE ; +else + drop_mode =FBNIC_QUEUE_RDE_CTL0_DROP_NEVER ;/* Specify packet layout */ rcq_ctl = FIELD_PREP(FBNIC_QUEUE_RDE_CTL0_DROP_MODE_MASK, drop_mode) |
@@ -2588,6 +2592,21 @@ static void fbnic_config_drop_mode_rcq(struct fbnic_napi_vector *nv,fbnic_ring_wr32 (rcq,FBNIC_QUEUE_RDE_CTL0 , rcq_ctl); } +void fbnic_config_drop_mode (struct fbnic_net *fbn,bool tx_pause) +{ +int i, t; + +for (i =0 ; i < fbn->num_napi; i++) { +struct fbnic_napi_vector *nv = fbn->napi[i]; + +for (t =0 ; t < nv->rxt_count; t++) { +struct fbnic_q_triad *qt = &nv->qt[nv->txt_count + t]; + +fbnic_config_drop_mode_rcq (nv, &qt->cmpl, tx_pause); + } + } +} +static void fbnic_config_rim_threshold (struct fbnic_ring *rcq,u16 nv_idx,u32 rx_desc) {u32 threshold;
@@ -2637,7 +2656,7 @@ static void fbnic_enable_rcq(struct fbnic_napi_vector *nv,u32 hds_thresh = fbn->hds_thresh;u32 rcq_ctl =0 ; -fbnic_config_drop_mode_rcq (nv, rcq); +fbnic_config_drop_mode_rcq (nv, rcq, fbn->tx_pause);/* Force lower bound on MAX_HEADER_BYTES. Below this, all frames should * be split at L4. It would also result in the frames being split at
@@ -2700,7 +2719,6 @@ static void __fbnic_nv_enable(struct fbnic_napi_vector *nv) &nv->napi);fbnic_enable_bdq (&qt->sub0, &qt->sub1); -fbnic_config_drop_mode_rcq (nv, &qt->cmpl);fbnic_enable_rcq (nv, &qt->cmpl); } }
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h +1 -0
@@ -184,6 +184,7 @@ void fbnic_reset_netif_queues(struct fbnic_net *fbn);irqreturn_t fbnic_msix_clean_rings (int irq,void *data);void fbnic_napi_enable (struct fbnic_net *fbn);void fbnic_napi_disable (struct fbnic_net *fbn); +void fbnic_config_drop_mode (struct fbnic_net *fbn,bool tx_pause);void fbnic_enable (struct fbnic_net *fbn);void fbnic_disable (struct fbnic_net *fbn);void fbnic_flush (struct fbnic_net *fbn);
Signature · 1 line
2.47.3
drivers/net/ethernet/meta/fbnic/fbnic_phylink.c int fbnic_phylink_set_pauseparam(struct net_device *netdev, · line 43
Quoted 9 lines
drivers/net/ethernet/meta/fbnic/fbnic_phylink.c +5
-0@@ -36,8 +36,13 @@ int fbnic_phylink_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause) {struct fbnic_net *fbn =netdev_priv (netdev); +int err; + + err =phylink_ethtool_set_pauseparam (fbn->phylink, pause); +if (!err) + fbn->tx_pause = pause->tx_pause ? true : false;
You should store this away in mac_link_up. Pause can be negotiated. It could be the link partner does not want pause, does not support pause. When phylink calls .mac_link_up this has all been determined and you then know how to setup the hardware. Here is too early.
Andrew
Quoted 6 lines
You should store this away in
mac_link_up. Pause can be negotiated. It could be the link partner does not want pause, does not support pause. When phylink calls .mac_link_up this has all been determined and you then know how to setup the hardware. Here is too early.Andrew
Agreed. Even though fbnic currently does not support autoneg, moving this to .mac_link_up is the right approach. Thanks for the feedback.