Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: Jakub Kicinski <kuba@kernel.org>

+24 -13
+3
drivers/net/ethernet/xilinx/xilinx_axienet.h
··· 120 120 #define XAXIDMA_IRQ_ERROR_MASK 0x00004000 /* Error interrupt */ 121 121 #define XAXIDMA_IRQ_ALL_MASK 0x00007000 /* All interrupts */ 122 122 123 + /* Constant to convert delay counts to microseconds */ 124 + #define XAXIDMA_DELAY_SCALE (125ULL * USEC_PER_SEC) 125 + 123 126 /* Default TX/RX Threshold and delay timer values for SGDMA mode */ 124 127 #define XAXIDMA_DFT_TX_THRESHOLD 24 125 128 #define XAXIDMA_DFT_TX_USEC 50
+21 -13
drivers/net/ethernet/xilinx/xilinx_axienet_main.c
··· 238 238 239 239 /* 1 Timeout Interval = 125 * (clock period of SG clock) */ 240 240 result = DIV64_U64_ROUND_CLOSEST((u64)coalesce_usec * clk_rate, 241 - (u64)125000000); 242 - if (result > 255) 243 - result = 255; 244 - 245 - return result; 241 + XAXIDMA_DELAY_SCALE); 242 + return min(result, FIELD_MAX(XAXIDMA_DELAY_MASK)); 246 243 } 247 244 248 245 /** ··· 2059 2062 return -EINVAL; 2060 2063 } 2061 2064 2062 - if (ecoalesce->rx_max_coalesced_frames) 2063 - lp->coalesce_count_rx = ecoalesce->rx_max_coalesced_frames; 2064 - if (ecoalesce->rx_coalesce_usecs) 2065 - lp->coalesce_usec_rx = ecoalesce->rx_coalesce_usecs; 2066 - if (ecoalesce->tx_max_coalesced_frames) 2067 - lp->coalesce_count_tx = ecoalesce->tx_max_coalesced_frames; 2068 - if (ecoalesce->tx_coalesce_usecs) 2069 - lp->coalesce_usec_tx = ecoalesce->tx_coalesce_usecs; 2065 + if (!ecoalesce->rx_max_coalesced_frames || 2066 + !ecoalesce->tx_max_coalesced_frames) { 2067 + NL_SET_ERR_MSG(extack, "frames must be non-zero"); 2068 + return -EINVAL; 2069 + } 2070 + 2071 + if ((ecoalesce->rx_max_coalesced_frames > 1 && 2072 + !ecoalesce->rx_coalesce_usecs) || 2073 + (ecoalesce->tx_max_coalesced_frames > 1 && 2074 + !ecoalesce->tx_coalesce_usecs)) { 2075 + NL_SET_ERR_MSG(extack, 2076 + "usecs must be non-zero when frames is greater than one"); 2077 + return -EINVAL; 2078 + } 2079 + 2080 + lp->coalesce_count_rx = ecoalesce->rx_max_coalesced_frames; 2081 + lp->coalesce_usec_rx = ecoalesce->rx_coalesce_usecs; 2082 + lp->coalesce_count_tx = ecoalesce->tx_max_coalesced_frames; 2083 + lp->coalesce_usec_tx = ecoalesce->tx_coalesce_usecs; 2070 2084 2071 2085 return 0; 2072 2086 }