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

ixgbe: Fix interrupt configuration for 82599

The interrupt models using EITR have changed in 82599. The way the register
is laid out, the change is transparent to some of the existing code.
However, some of it isn't. This patch fixes all the cases where EITR
handling is different than 82598.

Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jesse Brandeburg and committed by
David S. Miller
509ee935 40dcd79a

+71 -31
+4 -2
drivers/net/ixgbe/ixgbe.h
··· 189 189 }; 190 190 191 191 /* Helper macros to switch between ints/sec and what the register uses. 192 - * And yes, it's the same math going both ways. 192 + * And yes, it's the same math going both ways. The lowest value 193 + * supported by all of the ixgbe hardware is 8. 193 194 */ 194 195 #define EITR_INTS_PER_SEC_TO_REG(_eitr) \ 195 - ((_eitr) ? (1000000000 / ((_eitr) * 256)) : 0) 196 + ((_eitr) ? (1000000000 / ((_eitr) * 256)) : 8) 196 197 #define EITR_REG_TO_INTS_PER_SEC EITR_INTS_PER_SEC_TO_REG 197 198 198 199 #define IXGBE_DESC_UNUSED(R) \ ··· 367 366 extern int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter); 368 367 void ixgbe_napi_add_all(struct ixgbe_adapter *adapter); 369 368 void ixgbe_napi_del_all(struct ixgbe_adapter *adapter); 369 + extern void ixgbe_write_eitr(struct ixgbe_adapter *, int, u32); 370 370 371 371 #endif /* _IXGBE_H_ */
+14 -7
drivers/net/ixgbe/ixgbe_ethtool.c
··· 977 977 struct ethtool_coalesce *ec) 978 978 { 979 979 struct ixgbe_adapter *adapter = netdev_priv(netdev); 980 - struct ixgbe_hw *hw = &adapter->hw; 981 980 int i; 982 981 983 982 if (ec->tx_max_coalesced_frames_irq) 984 983 adapter->tx_ring[0].work_limit = ec->tx_max_coalesced_frames_irq; 985 984 986 985 if (ec->rx_coalesce_usecs > 1) { 986 + /* check the limits */ 987 + if ((1000000/ec->rx_coalesce_usecs > IXGBE_MAX_INT_RATE) || 988 + (1000000/ec->rx_coalesce_usecs < IXGBE_MIN_INT_RATE)) 989 + return -EINVAL; 990 + 987 991 /* store the value in ints/second */ 988 992 adapter->eitr_param = 1000000/ec->rx_coalesce_usecs; 989 993 990 994 /* static value of interrupt rate */ 991 995 adapter->itr_setting = adapter->eitr_param; 992 - /* clear the lower bit */ 996 + /* clear the lower bit as its used for dynamic state */ 993 997 adapter->itr_setting &= ~1; 994 998 } else if (ec->rx_coalesce_usecs == 1) { 995 999 /* 1 means dynamic mode */ 996 1000 adapter->eitr_param = 20000; 997 1001 adapter->itr_setting = 1; 998 1002 } else { 999 - /* any other value means disable eitr, which is best 1000 - * served by setting the interrupt rate very high */ 1001 - adapter->eitr_param = 3000000; 1003 + /* 1004 + * any other value means disable eitr, which is best 1005 + * served by setting the interrupt rate very high 1006 + */ 1007 + adapter->eitr_param = IXGBE_MAX_INT_RATE; 1002 1008 adapter->itr_setting = 0; 1003 1009 } 1004 1010 1005 1011 for (i = 0; i < adapter->num_msix_vectors - NON_Q_VECTORS; i++) { 1006 1012 struct ixgbe_q_vector *q_vector = &adapter->q_vector[i]; 1007 1013 if (q_vector->txr_count && !q_vector->rxr_count) 1014 + /* tx vector gets half the rate */ 1008 1015 q_vector->eitr = (adapter->eitr_param >> 1); 1009 1016 else 1010 1017 /* rx only or mixed */ 1011 1018 q_vector->eitr = adapter->eitr_param; 1012 - IXGBE_WRITE_REG(hw, IXGBE_EITR(i), 1013 - EITR_INTS_PER_SEC_TO_REG(q_vector->eitr)); 1019 + ixgbe_write_eitr(adapter, i, 1020 + EITR_INTS_PER_SEC_TO_REG(q_vector->eitr)); 1014 1021 } 1015 1022 1016 1023 return 0;
+43 -21
drivers/net/ixgbe/ixgbe_main.c
··· 808 808 /* if this is a tx only vector halve the interrupt rate */ 809 809 if (q_vector->txr_count && !q_vector->rxr_count) 810 810 q_vector->eitr = (adapter->eitr_param >> 1); 811 - else 811 + else if (q_vector->rxr_count) 812 812 /* rx only */ 813 813 q_vector->eitr = adapter->eitr_param; 814 814 815 + /* 816 + * since ths is initial set up don't need to call 817 + * ixgbe_write_eitr helper 818 + */ 815 819 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EITR(v_idx), 816 820 EITR_INTS_PER_SEC_TO_REG(q_vector->eitr)); 817 821 } ··· 900 896 return retval; 901 897 } 902 898 899 + /** 900 + * ixgbe_write_eitr - write EITR register in hardware specific way 901 + * @adapter: pointer to adapter struct 902 + * @v_idx: vector index into q_vector array 903 + * @itr_reg: new value to be written in *register* format, not ints/s 904 + * 905 + * This function is made to be called by ethtool and by the driver 906 + * when it needs to update EITR registers at runtime. Hardware 907 + * specific quirks/differences are taken care of here. 908 + */ 909 + void ixgbe_write_eitr(struct ixgbe_adapter *adapter, int v_idx, u32 itr_reg) 910 + { 911 + struct ixgbe_hw *hw = &adapter->hw; 912 + if (adapter->hw.mac.type == ixgbe_mac_82598EB) { 913 + /* must write high and low 16 bits to reset counter */ 914 + itr_reg |= (itr_reg << 16); 915 + } else if (adapter->hw.mac.type == ixgbe_mac_82599EB) { 916 + /* 917 + * set the WDIS bit to not clear the timer bits and cause an 918 + * immediate assertion of the interrupt 919 + */ 920 + itr_reg |= IXGBE_EITR_CNT_WDIS; 921 + } 922 + IXGBE_WRITE_REG(hw, IXGBE_EITR(v_idx), itr_reg); 923 + } 924 + 903 925 static void ixgbe_set_itr_msix(struct ixgbe_q_vector *q_vector) 904 926 { 905 927 struct ixgbe_adapter *adapter = q_vector->adapter; 906 - struct ixgbe_hw *hw = &adapter->hw; 907 928 u32 new_itr; 908 929 u8 current_itr, ret_itr; 909 930 int i, r_idx, v_idx = ((void *)q_vector - (void *)(adapter->q_vector)) / ··· 983 954 984 955 if (new_itr != q_vector->eitr) { 985 956 u32 itr_reg; 957 + 958 + /* save the algorithm value here, not the smoothed one */ 959 + q_vector->eitr = new_itr; 986 960 /* do an exponential smoothing */ 987 961 new_itr = ((q_vector->eitr * 90)/100) + ((new_itr * 10)/100); 988 - q_vector->eitr = new_itr; 989 962 itr_reg = EITR_INTS_PER_SEC_TO_REG(new_itr); 990 - if (adapter->hw.mac.type == ixgbe_mac_82599EB) 991 - /* Resolution is 2 usec on 82599, so halve the rate */ 992 - itr_reg >>= 1; 993 - /* must write high and low 16 bits to reset counter */ 994 - DPRINTK(TX_ERR, DEBUG, "writing eitr(%d): %08X\n", v_idx, 995 - itr_reg); 996 - IXGBE_WRITE_REG(hw, IXGBE_EITR(v_idx), itr_reg | (itr_reg)<<16); 963 + ixgbe_write_eitr(adapter, v_idx, itr_reg); 997 964 } 998 965 999 966 return; ··· 1166 1141 /* If all Rx work done, exit the polling mode */ 1167 1142 if (work_done < budget) { 1168 1143 napi_complete(napi); 1169 - if (adapter->itr_setting & 3) 1144 + if (adapter->itr_setting & 1) 1170 1145 ixgbe_set_itr_msix(q_vector); 1171 1146 if (!test_bit(__IXGBE_DOWN, &adapter->state)) 1172 1147 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, rx_ring->v_idx); ··· 1215 1190 /* If all Rx work done, exit the polling mode */ 1216 1191 if (work_done < budget) { 1217 1192 napi_complete(napi); 1218 - if (adapter->itr_setting & 3) 1193 + if (adapter->itr_setting & 1) 1219 1194 ixgbe_set_itr_msix(q_vector); 1220 1195 if (!test_bit(__IXGBE_DOWN, &adapter->state)) 1221 1196 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, enable_mask); ··· 1385 1360 1386 1361 static void ixgbe_set_itr(struct ixgbe_adapter *adapter) 1387 1362 { 1388 - struct ixgbe_hw *hw = &adapter->hw; 1389 1363 struct ixgbe_q_vector *q_vector = adapter->q_vector; 1390 1364 u8 current_itr; 1391 1365 u32 new_itr = q_vector->eitr; ··· 1419 1395 1420 1396 if (new_itr != q_vector->eitr) { 1421 1397 u32 itr_reg; 1398 + 1399 + /* save the algorithm value here, not the smoothed one */ 1400 + q_vector->eitr = new_itr; 1422 1401 /* do an exponential smoothing */ 1423 1402 new_itr = ((q_vector->eitr * 90)/100) + ((new_itr * 10)/100); 1424 - q_vector->eitr = new_itr; 1425 1403 itr_reg = EITR_INTS_PER_SEC_TO_REG(new_itr); 1426 - if (adapter->hw.mac.type == ixgbe_mac_82599EB) 1427 - /* Resolution is 2 usec on 82599, so halve the rate */ 1428 - itr_reg >>= 1; 1429 - /* must write high and low 16 bits to reset counter */ 1430 - IXGBE_WRITE_REG(hw, IXGBE_EITR(0), itr_reg | (itr_reg)<<16); 1404 + ixgbe_write_eitr(adapter, 0, itr_reg); 1431 1405 } 1432 1406 1433 1407 return; ··· 1723 1701 0xA54F2BEC, 0xEA49AF7C, 0xE214AD3D, 0xB855AABE, 1724 1702 0x6A3E67EA, 0x14364D17, 0x3BED200D}; 1725 1703 u32 fctrl, hlreg0; 1726 - u32 reta = 0, mrqc; 1704 + u32 reta = 0, mrqc = 0; 1727 1705 u32 rdrxctl; 1728 1706 int rx_buf_len; 1729 1707 ··· 2611 2589 /* If budget not fully consumed, exit the polling mode */ 2612 2590 if (work_done < budget) { 2613 2591 napi_complete(napi); 2614 - if (adapter->itr_setting & 3) 2592 + if (adapter->itr_setting & 1) 2615 2593 ixgbe_set_itr(adapter); 2616 2594 if (!test_bit(__IXGBE_DOWN, &adapter->state)) 2617 2595 ixgbe_irq_enable(adapter);
+10 -1
drivers/net/ixgbe/ixgbe_type.h
··· 98 98 #define IXGBE_EIMS_EX(_i) (0x00AA0 + (_i) * 4) 99 99 #define IXGBE_EIMC_EX(_i) (0x00AB0 + (_i) * 4) 100 100 #define IXGBE_EIAM_EX(_i) (0x00AD0 + (_i) * 4) 101 + /* 102 + * 82598 EITR is 16 bits but set the limits based on the max 103 + * supported by all ixgbe hardware. 82599 EITR is only 12 bits, 104 + * with the lower 3 always zero. 105 + */ 106 + #define IXGBE_MAX_INT_RATE 488281 107 + #define IXGBE_MIN_INT_RATE 956 108 + #define IXGBE_MAX_EITR 0x00000FF8 109 + #define IXGBE_MIN_EITR 8 101 110 #define IXGBE_EITR(_i) (((_i) <= 23) ? (0x00820 + ((_i) * 4)) : \ 102 111 (0x012300 + (((_i) - 24) * 4))) 103 - #define IXGBE_EITR_ITR_INT_MASK 0x00000FFF 112 + #define IXGBE_EITR_ITR_INT_MASK 0x00000FF8 104 113 #define IXGBE_EITR_LLI_MOD 0x00008000 105 114 #define IXGBE_EITR_CNT_WDIS 0x80000000 106 115 #define IXGBE_IVAR(_i) (0x00900 + ((_i) * 4)) /* 24 at 0x900-0x960 */