Skip to content

Commit fc398be

Browse files
IoanaCiorneidavem330
authored andcommitted
net: dpaa2: add adaptive interrupt coalescing
Add support for adaptive interrupt coalescing to the dpaa2-eth driver. First of all, ETHTOOL_COALESCE_USE_ADAPTIVE_RX is defined as a supported coalesce parameter and the requested state is configured through the dpio APIs added in the previous patch. Besides the ethtool API interaction, we keep track of how many bytes and frames are dequeued per CDAN (Channel Data Availability Notification) and update the Net DIM instance through the dpaa2_io_update_net_dim() API. Signed-off-by: Ioana Ciornei <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 69651bd commit fc398be

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ static void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
533533

534534
percpu_stats->rx_packets++;
535535
percpu_stats->rx_bytes += dpaa2_fd_get_len(fd);
536+
ch->stats.bytes_per_cdan += dpaa2_fd_get_len(fd);
536537

537538
list_add_tail(&skb->list, ch->rx_list);
538539

@@ -641,6 +642,7 @@ static int dpaa2_eth_consume_frames(struct dpaa2_eth_channel *ch,
641642

642643
fq->stats.frames += cleaned;
643644
ch->stats.frames += cleaned;
645+
ch->stats.frames_per_cdan += cleaned;
644646

645647
/* A dequeue operation only pulls frames from a single queue
646648
* into the store. Return the frame queue as an out param.
@@ -1264,7 +1266,7 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
12641266

12651267
/* Tx confirmation frame processing routine */
12661268
static void dpaa2_eth_tx_conf(struct dpaa2_eth_priv *priv,
1267-
struct dpaa2_eth_channel *ch __always_unused,
1269+
struct dpaa2_eth_channel *ch,
12681270
const struct dpaa2_fd *fd,
12691271
struct dpaa2_eth_fq *fq)
12701272
{
@@ -1279,6 +1281,7 @@ static void dpaa2_eth_tx_conf(struct dpaa2_eth_priv *priv,
12791281
percpu_extras = this_cpu_ptr(priv->percpu_extras);
12801282
percpu_extras->tx_conf_frames++;
12811283
percpu_extras->tx_conf_bytes += fd_len;
1284+
ch->stats.bytes_per_cdan += fd_len;
12821285

12831286
/* Check frame errors in the FD field */
12841287
fd_errors = dpaa2_fd_get_ctrl(fd) & DPAA2_FD_TX_ERR_MASK;
@@ -1601,6 +1604,12 @@ static int dpaa2_eth_poll(struct napi_struct *napi, int budget)
16011604
}
16021605
} while (store_cleaned);
16031606

1607+
/* Update NET DIM with the values for this CDAN */
1608+
dpaa2_io_update_net_dim(ch->dpio, ch->stats.frames_per_cdan,
1609+
ch->stats.bytes_per_cdan);
1610+
ch->stats.frames_per_cdan = 0;
1611+
ch->stats.bytes_per_cdan = 0;
1612+
16041613
/* We didn't consume the entire budget, so finish napi and
16051614
* re-enable data availability notifications
16061615
*/

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@ struct dpaa2_eth_ch_stats {
384384
__u64 xdp_redirect;
385385
/* Must be last, does not show up in ethtool stats */
386386
__u64 frames;
387+
__u64 frames_per_cdan;
388+
__u64 bytes_per_cdan;
387389
};
388390

389391
/* Maximum number of queues associated with a DPNI */

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,7 @@ static int dpaa2_eth_get_coalesce(struct net_device *dev,
829829
struct dpaa2_io *dpio = priv->channel[0]->dpio;
830830

831831
dpaa2_io_get_irq_coalescing(dpio, &ic->rx_coalesce_usecs);
832+
ic->use_adaptive_rx_coalesce = dpaa2_io_get_adaptive_coalescing(dpio);
832833

833834
return 0;
834835
}
@@ -840,17 +841,21 @@ static int dpaa2_eth_set_coalesce(struct net_device *dev,
840841
{
841842
struct dpaa2_eth_priv *priv = netdev_priv(dev);
842843
struct dpaa2_io *dpio;
844+
int prev_adaptive;
843845
u32 prev_rx_usecs;
844846
int i, j, err;
845847

846848
/* Keep track of the previous value, just in case we fail */
847849
dpio = priv->channel[0]->dpio;
848850
dpaa2_io_get_irq_coalescing(dpio, &prev_rx_usecs);
851+
prev_adaptive = dpaa2_io_get_adaptive_coalescing(dpio);
849852

850853
/* Setup new value for rx coalescing */
851854
for (i = 0; i < priv->num_channels; i++) {
852855
dpio = priv->channel[i]->dpio;
853856

857+
dpaa2_io_set_adaptive_coalescing(dpio,
858+
ic->use_adaptive_rx_coalesce);
854859
err = dpaa2_io_set_irq_coalescing(dpio, ic->rx_coalesce_usecs);
855860
if (err)
856861
goto restore_rx_usecs;
@@ -863,13 +868,15 @@ static int dpaa2_eth_set_coalesce(struct net_device *dev,
863868
dpio = priv->channel[j]->dpio;
864869

865870
dpaa2_io_set_irq_coalescing(dpio, prev_rx_usecs);
871+
dpaa2_io_set_adaptive_coalescing(dpio, prev_adaptive);
866872
}
867873

868874
return err;
869875
}
870876

871877
const struct ethtool_ops dpaa2_ethtool_ops = {
872-
.supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS,
878+
.supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS |
879+
ETHTOOL_COALESCE_USE_ADAPTIVE_RX,
873880
.get_drvinfo = dpaa2_eth_get_drvinfo,
874881
.nway_reset = dpaa2_eth_nway_reset,
875882
.get_link = ethtool_op_get_link,

0 commit comments

Comments
 (0)