net/ethtool: introduce a new ioctl for per queue setting
Subsystems (4)
PATCH v2 1/5 net/ethtool: introduce a new ioctl for per queue setting
From: Kan Liang <[email protected]>
Introduce a new ioctl ETHTOOL_PERQUEUE for per queue parameters setting. The following patches will enable some SUB_COMMANDs for per queue setting.
---
Changes since V1:
- Checking the sub-command number to determine whether the command requires CAP_NET_ADMIN
- Refine the struct ethtool_per_queue_op and improve the comments
include/uapi/linux/ethtool.h | 17 +++++++++++++++++ net/core/ethtool.c | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+)
include/uapi/linux/ethtool.h +17 -0
@@ -1144,6 +1144,21 @@ enum ethtool_sfeatures_retval_bits {#define ETHTOOL_F_WISH (1 << ETHTOOL_F_WISH__BIT)#define ETHTOOL_F_COMPAT (1 << ETHTOOL_F_COMPAT__BIT) +#define MAX_NUM_QUEUE 4096 + +/** +* struct ethtool_per_queue_op - apply sub command to the queues in mask. +* @cmd: ETHTOOL_PERQUEUE +* @sub_command: the sub command which apply to each queues +* @queue_mask: Bitmap of the queues which sub command apply to +* @data: A complete command structure following for each of the queues addressed +*/ +struct ethtool_per_queue_op { +__u32 cmd; +__u32 sub_command; +unsigned long queue_mask[BITS_TO_LONGS (MAX_NUM_QUEUE )]; +char data[]; +};/* CMDs currently supported */ #define ETHTOOL_GSET 0x00000001/* Get settings. */
@@ -1226,6 +1241,8 @@ enum ethtool_sfeatures_retval_bits {#define ETHTOOL_GTUNABLE 0x00000048/* Get tunable configuration */ #define ETHTOOL_STUNABLE 0x00000049/* Set tunable configuration */ +#define ETHTOOL_PERQUEUE 0x0000004a/* Set per queue options */ +/* compatibility with older code */ #define SPARC_ETH_GSET ETHTOOL_GSET#define SPARC_ETH_SSET ETHTOOL_SSET
net/core/ethtool.c +18 -0
@@ -1748,6 +1748,20 @@ out:return ret; } +static int ethtool_set_per_queue (struct net_device *dev,void __user *useraddr) +{ +struct ethtool_per_queue_op per_queue_opt; + +if (copy_from_user (&per_queue_opt, useraddr,sizeof (per_queue_opt))) +return -EFAULT ; + +switch (per_queue_opt.sub_command) { + +default : +return -EOPNOTSUPP ; + }; +} +/* The main entry point in this file. Called from net/core/dev_ioctl.c */ int dev_ethtool (struct net *net,struct ifreq *ifr)
@@ -1799,6 +1813,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)case ETHTOOL_GEEE :case ETHTOOL_GTUNABLE :break ; +case ETHTOOL_PERQUEUE :default :if (!ns_capable (net->user_ns,CAP_NET_ADMIN ))return -EPERM ;
@@ -1991,6 +2006,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)case ETHTOOL_STUNABLE : rc =ethtool_set_tunable (dev, useraddr);break ; +case ETHTOOL_PERQUEUE : + rc =ethtool_set_per_queue (dev, useraddr); +break ;default : rc = -EOPNOTSUPP ; }
Signature · 1 line
1.8.3.1
PATCH v2 2/5 net/ethtool: support get coalesce per queue
From: Kan Liang <[email protected]>
This patch implements sub command ETHTOOL_GCOALESCE for ioctl ETHTOOL_PERQUEUE. It introduces an interface get_per_queue_coalesce to get coalesce of each masked queue from device driver. Then the interrupt coalescing parameters will be copied back to user space one by one.
---
Changes since V1:
- Use bitmap functions to parse queue mask
- Improve comments
include/linux/ethtool.h | 10 +++++++++- net/core/ethtool.c | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-)
include/linux/ethtool.h +9 -1
@@ -201,6 +201,13 @@ static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)* @get_module_eeprom: Get the eeprom information from the plug-in module * @get_eee: Get Energy-Efficient (EEE) supported and status. * @set_eee: Set EEE status (enable/disable) as well as LPI timers. +* @get_per_queue_coalesce: Get interrupt coalescing parameters per queue. +* It needs to do range check for the input queue number. Only if +* neither RX nor TX queue number is in the range, a negative error code +* returns. For the case that only RX or only TX is not in the range, +* zero should return. But related unavailable fields should be set to ~0, +* which indicates RX or TX is not in the range. +* Returns a negative error code or zero. * * All operations are optional (i.e. the function pointer may be set * to %NULL) and callers must take this into account. Callers must
@@ -279,7 +286,8 @@ struct ethtool_ops { const struct ethtool_tunable *, void *);int (*set_tunable)(struct net_device *,const struct ethtool_tunable *,const void *); - +int (*get_per_queue_coalesce)(struct net_device *,int , + struct ethtool_coalesce *); };#endif /* _LINUX_ETHTOOL_H */
net/core/ethtool.c +32 -2
@@ -1748,6 +1748,31 @@ out:return ret; } +static int ethtool_get_per_queue_coalesce (struct net_device *dev, +void __user *useraddr, +struct ethtool_per_queue_op *per_queue_opt) +{ +int bit, ret; + +if (!dev->ethtool_ops->get_per_queue_coalesce) +return -EOPNOTSUPP ; + + useraddr +=sizeof (*per_queue_opt); + +for_each_set_bit (bit, per_queue_opt->queue_mask,MAX_NUM_QUEUE ) { +struct ethtool_coalesce coalesce = { .cmd =ETHTOOL_GCOALESCE }; + + ret = dev->ethtool_ops->get_per_queue_coalesce (dev, bit, &coalesce); +if (ret !=0 ) +return ret; +if (copy_to_user (useraddr, &coalesce,sizeof (coalesce))) +return -EFAULT ; + useraddr +=sizeof (coalesce); + } + +return 0 ; +} +static int ethtool_set_per_queue (struct net_device *dev,void __user *useraddr) {struct ethtool_per_queue_op per_queue_opt;
@@ -1756,7 +1781,8 @@ static int ethtool_set_per_queue(struct net_device *dev, void __user *useraddr)return -EFAULT ;switch (per_queue_opt.sub_command) { - +case ETHTOOL_GCOALESCE : +return ethtool_get_per_queue_coalesce (dev, useraddr, &per_queue_opt);default :return -EOPNOTSUPP ; };
@@ -1768,7 +1794,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr) {struct net_device *dev =__dev_get_by_name (net, ifr->ifr_name);void __user *useraddr = ifr->ifr_data; -u32 ethcmd; +u32 ethcmd, sub_cmd;int rc;netdev_features_t old_features;
@@ -1814,6 +1840,10 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)case ETHTOOL_GTUNABLE :break ;case ETHTOOL_PERQUEUE : +if (copy_from_user (&sub_cmd, useraddr +sizeof (ethcmd),sizeof (sub_cmd))) +return -EFAULT ; +if (sub_cmd ==ETHTOOL_GCOALESCE ) +break ;default :if (!ns_capable (net->user_ns,CAP_NET_ADMIN ))return -EPERM ;
Signature · 1 line
1.8.3.1
PATCH v2 5/5 i40e/ethtool: support coalesce setting by queue
In reply to [email protected]From: Kan Liang <[email protected]>
This patch implements set_per_queue_coalesce for i40e driver. For i40e driver, only rx and tx usecs have per queue value. Usually, the queues number is the same as vectors number. Queue has its own vector. Changing these two parameters by setting specific vector only impact the specific queue. However, sometimes queues number is larger than vectors number. Some queues have to share a vector. For this case, setting the vector can impact all queues in the same vector.
Except rx and tx usecs, for other interrupt coalescing parameters, they are shared among queues. The change to one queue will impact all queues.
---
Changes since V1:
- Correct the way to find the vector for specific queue.
drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 46 +++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +41 -5
@@ -1905,8 +1905,9 @@ static int i40e_get_per_queue_coalesce(struct net_device *netdev, int queue,return __i40e_get_coalesce (netdev, ec, queue); } -static int i40e_set_coalesce (struct net_device *netdev, -struct ethtool_coalesce *ec) +static int __i40e_set_coalesce (struct net_device *netdev, +struct ethtool_coalesce *ec, +int queue) {struct i40e_netdev_priv *np =netdev_priv (netdev);struct i40e_q_vector *q_vector;
@@ -1914,6 +1915,7 @@ static int i40e_set_coalesce(struct net_device *netdev,struct i40e_pf *pf = vsi->back;struct i40e_hw *hw = &pf->hw;u16 vector; +u16 intrl;int i;if (ec->tx_max_coalesced_frames_irq || ec->rx_max_coalesced_frames_irq)
@@ -1968,14 +1970,35 @@ static int i40e_set_coalesce(struct net_device *netdev,else vsi->tx_itr_setting &= ~I40E_ITR_DYNAMIC ; -for (i =0 ; i < vsi->num_q_vectors; i++, vector++) { -u16 intrl =INTRL_USEC_TO_REG (vsi->int_rate_limit); +if (queue <0 ) { +for (i =0 ; i < vsi->num_q_vectors; i++, vector++) { + intrl =INTRL_USEC_TO_REG (vsi->int_rate_limit); + + q_vector = vsi->q_vectors[i]; + q_vector->rx.itr =ITR_TO_REG (vsi->rx_itr_setting); +wr32 (hw,I40E_PFINT_ITRN (0 , vector -1 ), q_vector->rx.itr); + q_vector->tx.itr =ITR_TO_REG (vsi->tx_itr_setting); +wr32 (hw,I40E_PFINT_ITRN (1 , vector -1 ), q_vector->tx.itr); +wr32 (hw,I40E_PFINT_RATEN (vector -1 ), intrl); +i40e_flush (hw); + } + }else { +if (queue >= vsi->num_queue_pairs) { +netif_info (pf, drv, netdev,"Invalid queue value, queue range is 0 - %d\n" , vsi->num_queue_pairs -1 ); +return -EINVAL ; + } + intrl =INTRL_USEC_TO_REG (vsi->int_rate_limit); - q_vector = vsi->q_vectors[i]; + q_vector = vsi->rx_rings[queue]->q_vector; + vector = vsi->base_vector + q_vector->v_idx; q_vector->rx.itr =ITR_TO_REG (vsi->rx_itr_setting);wr32 (hw,I40E_PFINT_ITRN (0 , vector -1 ), q_vector->rx.itr); + + q_vector = vsi->tx_rings[queue]->q_vector; + vector = vsi->base_vector + q_vector->v_idx; q_vector->tx.itr =ITR_TO_REG (vsi->tx_itr_setting);wr32 (hw,I40E_PFINT_ITRN (1 , vector -1 ), q_vector->tx.itr); +wr32 (hw,I40E_PFINT_RATEN (vector -1 ), intrl);i40e_flush (hw); }
@@ -1983,6 +2006,18 @@ static int i40e_set_coalesce(struct net_device *netdev,return 0 ; } +static int i40e_set_coalesce (struct net_device *netdev, +struct ethtool_coalesce *ec) +{ +return __i40e_set_coalesce (netdev, ec,-1 ); +} + +static int i40e_set_per_queue_coalesce (struct net_device *netdev,int queue, +struct ethtool_coalesce *ec) +{ +return __i40e_set_coalesce (netdev, ec, queue); +} +/** * i40e_get_rss_hash_opts - Get RSS hash Input Set for each flow type * @pf: pointer to the physical function struct
@@ -2844,6 +2879,7 @@ static const struct ethtool_ops i40e_ethtool_ops = { .get_priv_flags = i40e_get_priv_flags, .set_priv_flags = i40e_set_priv_flags, .get_per_queue_coalesce = i40e_get_per_queue_coalesce, + .set_per_queue_coalesce = i40e_set_per_queue_coalesce, };void i40e_set_ethtool_ops (struct net_device *netdev)
Signature · 1 line
1.8.3.1
PATCH v2 4/5 i40e/ethtool: support coalesce getting by queue
In reply to [email protected]From: Kan Liang <[email protected]>
This patch implements get_per_queue_coalesce for i40e driver. For i40e driver, only rx and tx usecs has per queue value. So only these two parameters are read from specific vectors. Usually, the queues number is the same as vectors number. Queue has its own vector. However, sometimes queues number is larger than vectors number. some queues have to share a vector. For this case, the last value assigned to any queues in the same vector is return.
Except rx and tx usecs, for other interrupt coalescing parameters, they are shared among queues. The values which are stored in vsi will be return.
---
Changes since V1:
- Correct the way to find the vector for specific queue.
drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 36 ++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +34 -2
@@ -1845,11 +1845,16 @@ static int i40e_set_phys_id(struct net_device *netdev,* 125us (8000 interrupts per second) == ITR(62) */ -static int i40e_get_coalesce (struct net_device *netdev, -struct ethtool_coalesce *ec) +static int __i40e_get_coalesce (struct net_device *netdev, +struct ethtool_coalesce *ec, +int queue) {struct i40e_netdev_priv *np =netdev_priv (netdev);struct i40e_vsi *vsi = np->vsi; +struct i40e_pf *pf = vsi->back; +struct i40e_hw *hw = &pf->hw; +struct i40e_q_vector *q_vector; +u16 vector; ec->tx_max_coalesced_frames_irq = vsi->work_limit; ec->rx_max_coalesced_frames_irq = vsi->work_limit;
@@ -1871,9 +1876,35 @@ static int i40e_get_coalesce(struct net_device *netdev, ec->rx_coalesce_usecs_high = vsi->int_rate_limit; ec->tx_coalesce_usecs_high = vsi->int_rate_limit; +if (queue >-1 ) { +if (queue >= vsi->num_queue_pairs) { +netif_info (pf, drv, netdev,"Invalid queue value, queue range is 0 - %d\n" , vsi->num_queue_pairs -1 ); +return -EINVAL ; + } + + q_vector = vsi->rx_rings[queue]->q_vector; + vector = vsi->base_vector + q_vector->v_idx; + ec->rx_coalesce_usecs =ITR_REG_TO_USEC (rd32 (hw,I40E_PFINT_ITRN (0 , vector -1 ))); + + q_vector = vsi->tx_rings[queue]->q_vector; + vector = vsi->base_vector + q_vector->v_idx; + ec->tx_coalesce_usecs =ITR_REG_TO_USEC (rd32 (hw,I40E_PFINT_ITRN (1 , vector -1 ))); + }return 0 ; } +static int i40e_get_coalesce (struct net_device *netdev, +struct ethtool_coalesce *ec) +{ +return __i40e_get_coalesce (netdev, ec,-1 ); +} + +static int i40e_get_per_queue_coalesce (struct net_device *netdev,int queue, +struct ethtool_coalesce *ec) +{ +return __i40e_get_coalesce (netdev, ec, queue); +} +static int i40e_set_coalesce (struct net_device *netdev,struct ethtool_coalesce *ec) {
@@ -2812,6 +2843,7 @@ static const struct ethtool_ops i40e_ethtool_ops = { .get_ts_info = i40e_get_ts_info, .get_priv_flags = i40e_get_priv_flags, .set_priv_flags = i40e_set_priv_flags, + .get_per_queue_coalesce = i40e_get_per_queue_coalesce, };void i40e_set_ethtool_ops (struct net_device *netdev)
Signature · 1 line
1.8.3.1
PATCH v2 3/5 net/ethtool: support set coalesce per queue
In reply to [email protected]From: Kan Liang <[email protected]>
This patch implements sub command ETHTOOL_SCOALESCE for ioctl ETHTOOL_PERQUEUE. It introduces an interface set_per_queue_coalesce to set coalesce of each masked queue to device driver. The wanted coalesce information are stored in "data" for each masked queue, which can copy from userspace.
If it fails to set coalesce to device driver, the value which already set to specific queue will be tried to rollback.
---
Changes since V1:
- Use bitmap functions to parse queue mask
- Improve comments
- Add rollback support
include/linux/ethtool.h | 8 +++++++ net/core/ethtool.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)
include/linux/ethtool.h +8 -0
@@ -208,6 +208,12 @@ static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)* zero should return. But related unavailable fields should be set to ~0, * which indicates RX or TX is not in the range. * Returns a negative error code or zero. +* @set_per_queue_coalesce: Set interrupt coalescing parameters per queue. +* It needs to do range check for the input queue number. Only if +* neither RX nor TX queue number is in the range, a negative error code +* returns. For the case that only RX or only TX is not in the range, +* zero should return. The related unavailable fields should be avoid. +* Returns a negative error code or zero. * * All operations are optional (i.e. the function pointer may be set * to %NULL) and callers must take this into account. Callers must
@@ -288,6 +294,8 @@ struct ethtool_ops { const struct ethtool_tunable *, const void *);int (*get_per_queue_coalesce)(struct net_device *,int ,struct ethtool_coalesce *); +int (*set_per_queue_coalesce)(struct net_device *,int , + struct ethtool_coalesce *); };#endif /* _LINUX_ETHTOOL_H */
net/core/ethtool.c +59 -0
71 lines not on this page · raw message
Signature · 1 line
1.8.3.1
RE: [PATCH V2 4/5] i40e/ethtool: support coalesce getting by queue
In reply to [email protected]drivers/net/ethernet/intel/i40e/i40e_ethtool.c static int i40e_get_coalesce(struct net_device *netdev, · line 1887
Quoted 5 lines
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +4
-0+ + q_vector = vsi->rx_rings[queue]->q_vector; + vector = vsi->base_vector + q_vector->v_idx; + ec->rx_coalesce_usecs =ITR_REG_TO_USEC (rd32 (hw,I40E_PFINT_ITRN (0 , vector -1 )));
Use I40E_RX_ITR rather than the hardcoded 0
drivers/net/ethernet/intel/i40e/i40e_ethtool.c static int i40e_get_coalesce(struct net_device *netdev, · line 1891
Quoted 4 lines
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +4
-0+ + q_vector = vsi->tx_rings[queue]->q_vector; + vector = vsi->base_vector + q_vector->v_idx; + ec->tx_coalesce_usecs =ITR_REG_TO_USEC (rd32 (hw,I40E_PFINT_ITRN (1 , vector -1 )));
Use I40E_TX_ITR rather than the hardcoded 1
Other than that, yes, this looks like the right translation to get to the itr register you want.
sln
RE: [PATCH V2 5/5] i40e/ethtool: support coalesce setting by queue
In reply to [email protected]Quoted 12 lines
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +7
-2-for (i =0 ; i < vsi->num_q_vectors; i++, vector++) { -u16 intrl =INTRL_USEC_TO_REG (vsi->int_rate_limit); +if (queue <0 ) { +for (i =0 ; i < vsi->num_q_vectors; i++, vector++) { + intrl =INTRL_USEC_TO_REG (vsi->int_rate_limit); + + q_vector = vsi->q_vectors[i]; + q_vector->rx.itr =ITR_TO_REG (vsi->rx_itr_setting); + wr32(hw, I40E_PFINT_ITRN(0, vector - 1), q_vector-Quoted 1 line
rx.itr);
(quoted diff) +2
-0+ q_vector->tx.itr = ITR_TO_REG(vsi->tx_itr_setting); + wr32(hw, I40E_PFINT_ITRN(1, vector - 1), q_vector-
Quoted 1 line
Quoted 1 line
tx.itr);
Use I40E_RX_ITR and I40E_TX_ITR rather than the hardcoded 0 and 1
Quoted 11 lines
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +6
-0+wr32 (hw,I40E_PFINT_RATEN (vector -1 ), intrl); +i40e_flush (hw); + } + }else { +if (queue >= vsi->num_queue_pairs) { + netif_info(pf, drv, netdev, "Invalid queue value, queuerange is 0 - %d\n",
vsi->num_queue_pairs- 1);drivers/net/ethernet/intel/i40e/i40e_ethtool.c +3
-0+return -EINVAL ; + } + intrl =INTRL_USEC_TO_REG (vsi->int_rate_limit);
drivers/net/ethernet/intel/i40e/i40e_ethtool.c static int i40e_set_coalesce(struct net_device *netdev, · line 2000
Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +5
-1- q_vector = vsi->q_vectors[i]; + q_vector = vsi->rx_rings[queue]->q_vector; + vector = vsi->base_vector + q_vector->v_idx; q_vector->rx.itr =ITR_TO_REG (vsi->rx_itr_setting);wr32 (hw,I40E_PFINT_ITRN (0 , vector -1 ), q_vector->rx.itr); + + q_vector = vsi->tx_rings[queue]->q_vector; + vector = vsi->base_vector + q_vector->v_idx; q_vector->tx.itr =ITR_TO_REG (vsi->tx_itr_setting);wr32 (hw,I40E_PFINT_ITRN (1 , vector -1 ), q_vector->tx.itr);
Of course, we should have had the I40E_RX_ITR and I40E_TX_ITR here to begin with.
This looks reasonable, but be aware that since there's no concept of queue-specific settings in the driver proper, these settings will get lost on the next reset - see i40e_vsi_configure_msix(). A reset can be driven by a number of things such as MTU changes, LLDP events, tx timeout recovery, promiscuous on/off, and various other configuration changes. This might not be acceptable for your needs.
sln
RE: [PATCH V2 5/5] i40e/ethtool: support coalesce setting by queue
Quoted 10 lines
This looks reasonable, but be aware that since there's no concept of queue-specific settings in the driver proper, these settings will get lost on the next reset - see
i40e_vsi_configure_msix(). A reset can be driven by a number of things such as MTU changes, LLDP events, tx timeout recovery, promiscuous on/off, and various other configuration changes. This might not be acceptable for your needs.
Yes, the reset could be an issue.
I guess we may make the concept of queue-specific settings for i40e by moving rx_itr_setting and tx_itr_setting to i40e_ring.
How about the patch as below?
The patch only move itr_setting from i40e_vsi to i40e_ring. There should be no behavior change.
------
drivers/net/ethernet/intel/i40e/i40e.h +0 -7
@@ -499,13 +499,6 @@ struct i40e_vsi {struct i40e_ring **tx_rings;u16 work_limit; -/* high bit set means dynamic, use accessor routines to read/write. -* hardware only supports 2us resolution for the ITR registers. -* these values always store the USER setting, and must be converted -* before programming to a register. -*/ -u16 rx_itr_setting; -u16 tx_itr_setting;u16 int_rate_limit;/* value in usecs */ u16 rss_table_size;/* HW RSS table size */
drivers/net/ethernet/intel/i40e/i40e_debugfs.c +10 -5
@@ -533,6 +533,10 @@ static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid)" rx_rings[%i]: vsi = %p, q_vector = %p\n" , i, rx_ring->vsi, rx_ring->q_vector); +dev_info (&pf->pdev->dev, +" rx_rings[%i]: rx_itr_setting = %d (%s)\n" , + i, rx_ring->rx_itr_setting, +ITR_IS_DYNAMIC (rx_ring->rx_itr_setting) ?"dynamic" :"fixed" ); }for (i =0 ; i < vsi->num_queue_pairs; i++) {struct i40e_ring *tx_ring =ACCESS_ONCE (vsi->tx_rings[i]);
@@ -583,14 +587,15 @@ static void i40e_dbg_dump_vsi_seid(struct i40e_pf *pf, int seid)dev_info (&pf->pdev->dev," tx_rings[%i]: DCB tc = %d\n" , i, tx_ring->dcb_tc); +dev_info (&pf->pdev->dev, +" tx_rings[%i]: tx_itr_setting = %d (%s)\n" , + i, tx_ring->tx_itr_setting, +ITR_IS_DYNAMIC (tx_ring->tx_itr_setting) ?"dynamic" :"fixed" ); }rcu_read_unlock ();dev_info (&pf->pdev->dev, -" work_limit = %d, rx_itr_setting = %d (%s), tx_itr_setting = %d (%s)\n" , - vsi->work_limit, vsi->rx_itr_setting, -ITR_IS_DYNAMIC (vsi->rx_itr_setting) ?"dynamic" :"fixed" , - vsi->tx_itr_setting, -ITR_IS_DYNAMIC (vsi->tx_itr_setting) ?"dynamic" :"fixed" ); +" work_limit = %d\n" , + vsi->work_limit);dev_info (&pf->pdev->dev," max_frame = %d, rx_hdr_len = %d, rx_buf_len = %d dtype = %d\n" , vsi->max_frame, vsi->rx_hdr_len, vsi->rx_buf_len, vsi->dtype);
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +62 -43
157 lines not on this page · raw message
drivers/net/ethernet/intel/i40e/i40e_main.c +6 -6
@@ -3098,11 +3098,11 @@ static void i40e_vsi_configure_msix(struct i40e_vsi *vsi)struct i40e_q_vector *q_vector = vsi->q_vectors[i]; q_vector->itr_countdown =ITR_COUNTDOWN_START ; - q_vector->rx.itr =ITR_TO_REG (vsi->rx_itr_setting); + q_vector->rx.itr =ITR_TO_REG (vsi->rx_rings[i]->rx_itr_setting); q_vector->rx.latency_range =I40E_LOW_LATENCY ;wr32 (hw,I40E_PFINT_ITRN (I40E_RX_ITR , vector -1 ), q_vector->rx.itr); - q_vector->tx.itr =ITR_TO_REG (vsi->tx_itr_setting); + q_vector->tx.itr =ITR_TO_REG (vsi->tx_rings[i]->tx_itr_setting); q_vector->tx.latency_range =I40E_LOW_LATENCY ;wr32 (hw,I40E_PFINT_ITRN (I40E_TX_ITR , vector -1 ), q_vector->tx.itr);
@@ -3194,10 +3194,10 @@ static void i40e_configure_msi_and_legacy(struct i40e_vsi *vsi)/* set the ITR configuration */ q_vector->itr_countdown =ITR_COUNTDOWN_START ; - q_vector->rx.itr =ITR_TO_REG (vsi->rx_itr_setting); + q_vector->rx.itr =ITR_TO_REG (vsi->rx_rings[0 ]->rx_itr_setting); q_vector->rx.latency_range =I40E_LOW_LATENCY ;wr32 (hw,I40E_PFINT_ITR0 (I40E_RX_ITR ), q_vector->rx.itr); - q_vector->tx.itr =ITR_TO_REG (vsi->tx_itr_setting); + q_vector->tx.itr =ITR_TO_REG (vsi->tx_rings[0 ]->tx_itr_setting); q_vector->tx.latency_range =I40E_LOW_LATENCY ;wr32 (hw,I40E_PFINT_ITR0 (I40E_TX_ITR ), q_vector->tx.itr);
@@ -7284,8 +7284,6 @@ static int i40e_vsi_mem_alloc(struct i40e_pf *pf, enum i40e_vsi_type type)set_bit (__I40E_DOWN, &vsi->state); vsi->flags =0 ; vsi->idx = vsi_idx; - vsi->rx_itr_setting = pf->rx_itr_default; - vsi->tx_itr_setting = pf->tx_itr_default; vsi->int_rate_limit =0 ; vsi->rss_table_size = (vsi->type ==I40E_VSI_MAIN ) ? pf->rss_table_size :64 ;
@@ -7454,6 +7452,7 @@ static int i40e_alloc_rings(struct i40e_vsi *vsi) tx_ring->flags =I40E_TXR_FLAGS_WB_ON_ITR ;if (vsi->back->flags &I40E_FLAG_OUTER_UDP_CSUM_CAPABLE ) tx_ring->flags |=I40E_TXR_FLAGS_OUTER_UDP_CSUM ; + tx_ring->tx_itr_setting = pf->tx_itr_default; vsi->tx_rings[i] = tx_ring; rx_ring = &tx_ring[1 ];
@@ -7470,6 +7469,7 @@ static int i40e_alloc_rings(struct i40e_vsi *vsi)set_ring_16byte_desc_enabled (rx_ring); elseclear_ring_16byte_desc_enabled (rx_ring ); + rx_ring->rx_itr_setting = pf->rx_itr_default; vsi->rx_rings[i] = rx_ring; }
drivers/net/ethernet/intel/i40e/i40e_txrx.c +5 -4
@@ -1810,6 +1810,7 @@ static inline void i40e_update_enable_itr(struct i40e_vsi *vsi,bool rx = false, tx = false;u32 rxval, txval;int vector; +int idx = q_vector->v_idx; vector = (q_vector->v_idx + vsi->base_vector);
@@ -1819,17 +1820,17 @@ static inline void i40e_update_enable_itr(struct i40e_vsi *vsi, rxval = txval =i40e_buildreg_itr (I40E_ITR_NONE ,0 );if (q_vector->itr_countdown >0 || - (!ITR_IS_DYNAMIC (vsi->rx_itr_setting) && - !ITR_IS_DYNAMIC (vsi->tx_itr_setting))) { + (!ITR_IS_DYNAMIC (vsi->rx_rings[idx]->rx_itr_setting) && + !ITR_IS_DYNAMIC (vsi->tx_rings[idx]->tx_itr_setting))) { goto enable_int; } -if (ITR_IS_DYNAMIC (vsi->rx_itr_setting)) { +if (ITR_IS_DYNAMIC (vsi->rx_rings[idx]->rx_itr_setting)) { rx =i40e_set_new_dynamic_itr (&q_vector->rx); rxval =i40e_buildreg_itr (I40E_RX_ITR , q_vector->rx.itr); } -if (ITR_IS_DYNAMIC (vsi->tx_itr_setting)) { +if (ITR_IS_DYNAMIC (vsi->tx_rings[idx]->tx_itr_setting)) { tx =i40e_set_new_dynamic_itr (&q_vector->tx); txval =i40e_buildreg_itr (I40E_TX_ITR , q_vector->tx.itr); }
drivers/net/ethernet/intel/i40e/i40e_txrx.h +8 -0
@@ -246,6 +246,14 @@ struct i40e_ring {u8 dcb_tc;/* Traffic class of ring */ u8 __iomem *tail; +/* high bit set means dynamic, use accessor routines to read/write. +* hardware only supports 2us resolution for the ITR registers. +* these values always store the USER setting, and must be converted +* before programming to a register. +*/ +u16 rx_itr_setting; +u16 tx_itr_setting; +u16 count;/* Number of descriptors */ u16 reg_idx;/* HW register index of the ring */ u16 rx_hdr_len;
RE: [PATCH V2 5/5] i40e/ethtool: support coalesce setting by queue
Quoted 12 lines
From: Liang, Kan
Quoted 3 lines
This looks reasonable, but be aware that since there's no concept of queue-specific settings in the driver proper, these settings will get
lost on
Quoted 1 line
the next reset - see
i40e_vsi_configure_msix(). A reset can be drivenby a
Quoted 4 lines
number of things such as MTU changes, LLDP events, tx timeout recovery, promiscuous on/off, and various other configuration changes. This might not be acceptable for your needs.
Quoted 9 lines
Yes, the reset could be an issue.
I guess we may make the concept of queue-specific settings for i40e by movingrx_itr_settingandtx_itr_settingtoi40e_ring.How about the patch as below?
The patch only moveitr_settingfromi40e_vsitoi40e_ring. There should be no behavior change.
Thanks, I finally had a chance to look through this. On an initial read-through, yes, this would probably take care of it.
sln