Commit 50309d38 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-xilinx-axienet-enable-adaptive-irq-coalescing-with-dim'

Sean Anderson says:

====================
net: xilinx: axienet: Report an error for bad coalesce settings
====================

Link: https://patch.msgid.link/20250116232954.2696930-1-sean.anderson@linux.dev


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents a26892ee 9d301a53
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -120,6 +120,9 @@
#define XAXIDMA_IRQ_ERROR_MASK		0x00004000 /* Error interrupt */
#define XAXIDMA_IRQ_ALL_MASK		0x00007000 /* All interrupts */

/* Constant to convert delay counts to microseconds */
#define XAXIDMA_DELAY_SCALE		(125ULL * USEC_PER_SEC)

/* Default TX/RX Threshold and delay timer values for SGDMA mode */
#define XAXIDMA_DFT_TX_THRESHOLD	24
#define XAXIDMA_DFT_TX_USEC		50
+21 −13
Original line number Diff line number Diff line
@@ -238,11 +238,8 @@ static u32 axienet_usec_to_timer(struct axienet_local *lp, u32 coalesce_usec)

	/* 1 Timeout Interval = 125 * (clock period of SG clock) */
	result = DIV64_U64_ROUND_CLOSEST((u64)coalesce_usec * clk_rate,
					 (u64)125000000);
	if (result > 255)
		result = 255;

	return result;
					 XAXIDMA_DELAY_SCALE);
	return min(result, FIELD_MAX(XAXIDMA_DELAY_MASK));
}

/**
@@ -2062,13 +2059,24 @@ axienet_ethtools_set_coalesce(struct net_device *ndev,
		return -EINVAL;
	}

	if (ecoalesce->rx_max_coalesced_frames)
	if (!ecoalesce->rx_max_coalesced_frames ||
	    !ecoalesce->tx_max_coalesced_frames) {
		NL_SET_ERR_MSG(extack, "frames must be non-zero");
		return -EINVAL;
	}

	if ((ecoalesce->rx_max_coalesced_frames > 1 &&
	     !ecoalesce->rx_coalesce_usecs) ||
	    (ecoalesce->tx_max_coalesced_frames > 1 &&
	     !ecoalesce->tx_coalesce_usecs)) {
		NL_SET_ERR_MSG(extack,
			       "usecs must be non-zero when frames is greater than one");
		return -EINVAL;
	}

	lp->coalesce_count_rx = ecoalesce->rx_max_coalesced_frames;
	if (ecoalesce->rx_coalesce_usecs)
	lp->coalesce_usec_rx = ecoalesce->rx_coalesce_usecs;
	if (ecoalesce->tx_max_coalesced_frames)
	lp->coalesce_count_tx = ecoalesce->tx_max_coalesced_frames;
	if (ecoalesce->tx_coalesce_usecs)
	lp->coalesce_usec_tx = ecoalesce->tx_coalesce_usecs;

	return 0;