net/ethtool: introduce a new ioctl for per queue setting
Subsystems (4)
PATCH v3 1/6 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
No changes since V2
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 v3 2/6 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
No changes since V2
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
Re: [PATCH V3 2/6] net/ethtool: support get coalesce per queue
On Thu, 2016-01-14 at 09:08 -0500, [email protected] wrote:
[...]
net/core/ethtool.c int dev_ethtool(struct net *net, struct ifreq *ifr) · line 1846
Quoted 8 lines
(quoted diff) +0
-0@@ -1814,6 +1840,10 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)case
ETHTOOL_GTUNABLE:
break;
caseETHTOOL_PERQUEUE:net/core/ethtool.c +4
-0+if (copy_from_user (&sub_cmd, useraddr +sizeof (ethcmd),sizeof (sub_cmd))) +return -EFAULT ; +if (sub_cmd ==ETHTOOL_GCOALESCE ) +break ;
ETHTOOL_PERQUEUE should be handled before the containing switch(), so we can then apply the switch() to sub_cmd; something like this:
if (ethcmd == ETHTOOL_PERQUEUE) {
if (copy_from_user(&sub_cmd, useraddr + sizeof(ethcmd), sizeof(sub_cmd)))
return -EFAULT;
} else {
sub_cmd = ethcmd;
}
switch (sub_cmd) {
...
}Ben.
Quoted 3 lines
default:
if (!ns_capable(net->user_ns,CAP_NET_ADMIN)) return-EPERM;
Signature · 3 lines
Ben Hutchings
Theory and practice are closer in theory than in practice.
- John Levine, moderator of comp.compilersPATCH v3 3/6 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
No changes since V2
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 V3 3/6] net/ethtool: support set coalesce per queue
On Thu, 2016-01-14 at 09:08 -0500, [email protected] wrote:
[...]
Quoted 10 lines
net/core/ethtool.c +0
-0@@ -1773,6 +1773,63 @@ static int ethtool_get_per_queue_coalesce(struct net_device *dev, return 0; }net/core/ethtool.c +4
-0+static int ethtool_set_per_queue_coalesce (struct net_device *dev, + void __user *useraddr, + struct ethtool_per_queue_op *per_queue_opt) +{
net/core/ethtool.c static int ethtool_get_per_queue_coalesce(struct net_device *dev, · line 1789
Quoted 10 lines
net/core/ethtool.c +10
-0+int bit, i, ret =0 ; +int queue_num =bitmap_weight (per_queue_opt->queue_mask,MAX_NUM_QUEUE ); +struct ethtool_coalesce *backup =NULL , *tmp =NULL ; +bool rollback = true; + +if (!dev->ethtool_ops->set_per_queue_coalesce) +return -EOPNOTSUPP ; + +if (!dev->ethtool_ops->get_per_queue_coalesce) + rollback = false;
I think that get_per_queue_coalesce should be a required operation. Why would a driver not implement both?
Then there's no need to make the rollback code conditional.
net/core/ethtool.c static int ethtool_get_per_queue_coalesce(struct net_device *dev, · line 1794
Quoted 4 lines
net/core/ethtool.c +4
-0+ useraddr +=sizeof (*per_queue_opt); + +if (rollback) + tmp = backup =kmalloc (queue_num *sizeof (*backup),GFP_KERNEL );
Use kmalloc_array() as it checks for overflow (shouldn't be possible here, but it's best to check).
net/core/ethtool.c static int ethtool_get_per_queue_coalesce(struct net_device *dev, · line 1801
Quoted 6 lines
net/core/ethtool.c +6
-0+for_each_set_bit (bit, per_queue_opt->queue_mask,MAX_NUM_QUEUE ) { +struct ethtool_coalesce coalesce; + +if (rollback) { +if (dev->ethtool_ops->get_per_queue_coalesce (dev, bit, tmp)) { + ret = -EFAULT ;
This should propagate the error code from get_per_queue_coalesce rather than substituting EFAULT.
Quoted 12 lines
net/core/ethtool.c +12
-0+ goto roll_back; + } + tmp +=sizeof (struct ethtool_coalesce ); + } + +if (copy_from_user (&coalesce, useraddr,sizeof (coalesce))) { + ret = -EFAULT ; + goto roll_back; + } + + ret = dev->ethtool_ops->set_per_queue_coalesce (dev, bit, &coalesce); +if (ret !=0 )
net/core/ethtool.c static int ethtool_get_per_queue_coalesce(struct net_device *dev, · line 1823
Quoted 10 lines
net/core/ethtool.c +10
-0+ goto roll_back; + + useraddr +=sizeof (coalesce); + } + +roll_back: +if (rollback) { +if (ret !=0 ) { + tmp = backup; +for_each_set_bit (i, per_queue_opt->queue_mask, bit -1 ) {
The upper bound is excluded so it should be bit, not bit - 1.
Ben.
Quoted 8 lines
net/core/ethtool.c +8
-0+ dev->ethtool_ops->set_per_queue_coalesce (dev, i, tmp); + tmp +=sizeof (struct ethtool_coalesce ); + } + } +kfree (backup); + } +return ret; +}
[...]
Signature · 3 lines
Ben Hutchings
Theory and practice are closer in theory than in practice.
- John Levine, moderator of comp.compilersPATCH v3 4/6 i40e: queue-specific settings for interrupt moderation
In reply to [email protected]From: Kan Liang <[email protected]>
For i40e driver, each vector has its own ITR register. However, there are no concept of queue-specific settings in the driver proper. Only global variable is used to store ITR values. That will cause problems especially when resetting the vector. The specific ITR values could be lost.
This patch move rx_itr_setting and tx_itr_setting to i40e_ring to store specific ITR register for each queue.i40e_get_coalesce and i40e_set_coalesce are also modified accordingly to support queue-specific settings. To make it compatible with old ethtool, if user doesn't specify the queue number, i40e_get_coalesce will return queue 0's value. While i40e_set_coalesce will apply value to all queues.
---
new file since V2
drivers/net/ethernet/intel/i40e/i40e.h | 7 -- drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 15 ++- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 142 ++++++++++++++++--------- drivers/net/ethernet/intel/i40e/i40e_main.c | 12 +-- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 9 +- drivers/net/ethernet/intel/i40e/i40e_txrx.h | 8 ++ 6 files changed, 123 insertions(+), 70 deletions(-)
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 +94 -48
191 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;
Signature · 1 line
1.8.3.1
RE: [PATCH V3 4/6] i40e: queue-specific settings for interrupt moderation
Quoted 14 lines
From: Kan Liang <[email protected]>
For i40e driver, each vector has its own ITR register. However, there are no concept of queue-specific settings in the driver proper. Only global variable is used to store ITR values. That will cause problems especially when resetting the vector. The specific ITR values could be lost.
This patch moverx_itr_settingandtx_itr_settingtoi40e_ringto store specific ITR register for each queue.i40e_get_coalesceandi40e_set_coalesceare also modified accordingly to support queue-specific settings. To make it compatible with old ethtool, if user doesn't specify the queue number,i40e_get_coalescewill return queue 0's value. Whilei40e_set_coalescewill apply value to all queues.
Quoted 3 lines
Signed-off-by Kan Liang <[email protected]>---
PATCH v3 5/6 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.
---
Changes since V1:
- Correct the way to find the vector for specific queue.
Changes since V2:
- Move the code per queue coalesce getting to patch 4.
drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +7 -0
@@ -1894,6 +1894,12 @@ static int i40e_get_coalesce(struct net_device *netdev,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 void i40e_set_itr_per_queue (struct i40e_vsi *vsi,struct ethtool_coalesce *ec,int queue)
@@ -2858,6 +2864,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 v3 6/6 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.
---
Changes since V1:
- Correct the way to find the vector for specific queue.
Changes since V2:
- Move the code per queue coalesce setting to patch 4.
drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +7 -0
@@ -2004,6 +2004,12 @@ static int i40e_set_coalesce(struct net_device *netdev,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
@@ -2865,6 +2871,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
On Thu, 2016-01-14 at 09:08 -0500, [email protected] wrote:
[...]
Quoted 9 lines
include/uapi/linux/ethtool.h +0
-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)include/uapi/linux/ethtool.h +3
-0+#define MAX_NUM_QUEUE 4096 + +/**
include/uapi/linux/ethtool.h enum ethtool_sfeatures_retval_bits { · line 1159
Quoted 10 lines
include/uapi/linux/ethtool.h +10
-0+* 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 )];
[...]
I thought we already agreed that this won't work for 32-bit userland on a big-endian 64-bit kernel?
Ben.
Signature · 3 lines
Ben Hutchings
Theory and practice are closer in theory than in practice.
- John Levine, moderator of comp.compilersQuoted 25 lines · On Thu, 2016-01-14 at 09:08 -0500, [email protected] wrote:
[...]
include/uapi/linux/ethtool.h enum ethtool_sfeatures_retval_bits { · line 1150
Quoted 10 lines
include/uapi/linux/ethtool.h +4
-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.
include/uapi/linux/ethtool.h enum ethtool_sfeatures_retval_bits {
Quoted 8 lines
include/uapi/linux/ethtool.h +8
-0+* @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)];
[...]
Quoted 2 lines
I thought we already agreed that this won't work for 32-bit userland on a big-endian 64-bit kernel?
I found David Decotigny's patch. https://lkml.org/lkml/2015/12/14/728
But it looks like it is not merged yet.
Any idea when it will be merged to net-next or net?
So I can build my patch on top of his patch.
Thanks,
Kan
Quoted 7 lines
Ben.
--
Ben Hutchings
Theory and practice are closer in theory than in practice.
- John Levine, moderator of comp.compilers
I have a v6 ready, didn't have a chance to test + send it for review. will try to get done with it by tomorrow morning (PST).
Quoted 43 lines · Kan
Quoted 22 lines · On Thu, 2016-01-14 at 09:08 -0500, [email protected] wrote:
[...]
include/uapi/linux/ethtool.h enum ethtool_sfeatures_retval_bits { · line 1150
Quoted 10 lines
include/uapi/linux/ethtool.h +4
-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.
include/uapi/linux/ethtool.h enum ethtool_sfeatures_retval_bits {
Quoted 8 lines
include/uapi/linux/ethtool.h +8
-0+* @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 Quoted 5 lines
queue_mask[BITS_TO_LONGS(MAX_NUM_QUEUE)];
[...]I thought we already agreed that this won't work for 32-bit userland on a big-endian 64-bit kernel?
I found David Decotigny's patch. https://lkml.org/lkml/2015/12/14/728
But it looks like it is not merged yet.
Any idea when it will be merged to net-next or net?
So I can build my patch on top of his patch.Thanks,
KanQuoted 7 lines
Ben.
--
Ben Hutchings
Theory and practice are closer in theory than in practice.
- John Levine, moderator of comp.compilers