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

ice: Don't reject odd values of usecs set by user

Currently if a user sets an odd [tx|rx]-usecs value through ethtool,
the request is denied because the hardware is set to have an ITR
granularity of 2us. This caused poor customer experience. Fix this by
aligning to a register allowed value, which results in rounding down.
Also, print a once per ring container type message to be clear about
our intentions.

Also, change the ITR_TO_REG define to be the bitwise and of the ITR
setting and the ICE_ITR_MASK. This makes the purpose of ITR_TO_REG more
obvious.

Signed-off-by: Brett Creeley <brett.creeley@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

authored by

Brett Creeley and committed by
Jeff Kirsher
840f8ad0 33c4acbe

+39 -12
+38 -11
drivers/net/ethernet/intel/ice/ice_ethtool.c
··· 3489 3489 return -EINVAL; 3490 3490 } 3491 3491 3492 - /* hardware only supports an ITR granularity of 2us */ 3493 - if (coalesce_usecs % 2 != 0) { 3494 - netdev_info(vsi->netdev, "Invalid value, %s-usecs must be even\n", 3495 - c_type_str); 3496 - return -EINVAL; 3497 - } 3498 - 3499 3492 if (use_adaptive_coalesce) { 3500 3493 rc->itr_setting |= ICE_ITR_DYNAMIC; 3501 3494 } else { 3502 - /* store user facing value how it was set */ 3495 + /* save the user set usecs */ 3503 3496 rc->itr_setting = coalesce_usecs; 3504 - /* set to static and convert to value HW understands */ 3505 - rc->target_itr = 3506 - ITR_TO_REG(ITR_REG_ALIGN(rc->itr_setting)); 3497 + /* device ITR granularity is in 2 usec increments */ 3498 + rc->target_itr = ITR_REG_ALIGN(rc->itr_setting); 3507 3499 } 3508 3500 3509 3501 return 0; ··· 3589 3597 } 3590 3598 3591 3599 /** 3600 + * ice_print_if_odd_usecs - print message if user tries to set odd [tx|rx]-usecs 3601 + * @netdev: netdev used for print 3602 + * @itr_setting: previous user setting 3603 + * @use_adaptive_coalesce: if adaptive coalesce is enabled or being enabled 3604 + * @coalesce_usecs: requested value of [tx|rx]-usecs 3605 + * @c_type_str: either "rx" or "tx" to match user set field of [tx|rx]-usecs 3606 + */ 3607 + static void 3608 + ice_print_if_odd_usecs(struct net_device *netdev, u16 itr_setting, 3609 + u32 use_adaptive_coalesce, u32 coalesce_usecs, 3610 + const char *c_type_str) 3611 + { 3612 + if (use_adaptive_coalesce) 3613 + return; 3614 + 3615 + itr_setting = ITR_TO_REG(itr_setting); 3616 + 3617 + if (itr_setting != coalesce_usecs && (coalesce_usecs % 2)) 3618 + netdev_info(netdev, "User set %s-usecs to %d, device only supports even values. Rounding down and attempting to set %s-usecs to %d\n", 3619 + c_type_str, coalesce_usecs, c_type_str, 3620 + ITR_REG_ALIGN(coalesce_usecs)); 3621 + } 3622 + 3623 + /** 3592 3624 * __ice_set_coalesce - set ITR/INTRL values for the device 3593 3625 * @netdev: pointer to the netdev associated with this query 3594 3626 * @ec: ethtool structure to fill with driver's coalesce settings ··· 3632 3616 return -EINVAL; 3633 3617 3634 3618 if (q_num < 0) { 3619 + struct ice_q_vector *q_vector = vsi->q_vectors[0]; 3635 3620 int v_idx; 3621 + 3622 + if (q_vector) { 3623 + ice_print_if_odd_usecs(netdev, q_vector->rx.itr_setting, 3624 + ec->use_adaptive_rx_coalesce, 3625 + ec->rx_coalesce_usecs, "rx"); 3626 + 3627 + ice_print_if_odd_usecs(netdev, q_vector->tx.itr_setting, 3628 + ec->use_adaptive_tx_coalesce, 3629 + ec->tx_coalesce_usecs, "tx"); 3630 + } 3636 3631 3637 3632 ice_for_each_q_vector(vsi, v_idx) { 3638 3633 /* In some cases if DCB is configured the num_[rx|tx]q
+1 -1
drivers/net/ethernet/intel/ice/ice_txrx.h
··· 222 222 #define ICE_ITR_GRAN_S 1 /* ITR granularity is always 2us */ 223 223 #define ICE_ITR_GRAN_US BIT(ICE_ITR_GRAN_S) 224 224 #define ICE_ITR_MASK 0x1FFE /* ITR register value alignment mask */ 225 - #define ITR_REG_ALIGN(setting) __ALIGN_MASK(setting, ~ICE_ITR_MASK) 225 + #define ITR_REG_ALIGN(setting) ((setting) & ICE_ITR_MASK) 226 226 227 227 #define ICE_ITR_ADAPTIVE_MIN_INC 0x0002 228 228 #define ICE_ITR_ADAPTIVE_MIN_USECS 0x0002