@@ -2849,6 +2849,58 @@ static void virtnet_cpu_notif_remove(struct virtnet_info *vi)
28492849 & vi -> node_dead );
28502850}
28512851
2852+ static int virtnet_send_ctrl_coal_vq_cmd (struct virtnet_info * vi ,
2853+ u16 vqn , u32 max_usecs , u32 max_packets )
2854+ {
2855+ struct scatterlist sgs ;
2856+
2857+ vi -> ctrl -> coal_vq .vqn = cpu_to_le16 (vqn );
2858+ vi -> ctrl -> coal_vq .coal .max_usecs = cpu_to_le32 (max_usecs );
2859+ vi -> ctrl -> coal_vq .coal .max_packets = cpu_to_le32 (max_packets );
2860+ sg_init_one (& sgs , & vi -> ctrl -> coal_vq , sizeof (vi -> ctrl -> coal_vq ));
2861+
2862+ if (!virtnet_send_command (vi , VIRTIO_NET_CTRL_NOTF_COAL ,
2863+ VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET ,
2864+ & sgs ))
2865+ return - EINVAL ;
2866+
2867+ return 0 ;
2868+ }
2869+
2870+ static int virtnet_send_rx_ctrl_coal_vq_cmd (struct virtnet_info * vi ,
2871+ u16 queue , u32 max_usecs ,
2872+ u32 max_packets )
2873+ {
2874+ int err ;
2875+
2876+ err = virtnet_send_ctrl_coal_vq_cmd (vi , rxq2vq (queue ),
2877+ max_usecs , max_packets );
2878+ if (err )
2879+ return err ;
2880+
2881+ vi -> rq [queue ].intr_coal .max_usecs = max_usecs ;
2882+ vi -> rq [queue ].intr_coal .max_packets = max_packets ;
2883+
2884+ return 0 ;
2885+ }
2886+
2887+ static int virtnet_send_tx_ctrl_coal_vq_cmd (struct virtnet_info * vi ,
2888+ u16 queue , u32 max_usecs ,
2889+ u32 max_packets )
2890+ {
2891+ int err ;
2892+
2893+ err = virtnet_send_ctrl_coal_vq_cmd (vi , txq2vq (queue ),
2894+ max_usecs , max_packets );
2895+ if (err )
2896+ return err ;
2897+
2898+ vi -> sq [queue ].intr_coal .max_usecs = max_usecs ;
2899+ vi -> sq [queue ].intr_coal .max_packets = max_packets ;
2900+
2901+ return 0 ;
2902+ }
2903+
28522904static void virtnet_get_ringparam (struct net_device * dev ,
28532905 struct ethtool_ringparam * ring ,
28542906 struct kernel_ethtool_ringparam * kernel_ring ,
@@ -2906,14 +2958,11 @@ static int virtnet_set_ringparam(struct net_device *dev,
29062958 * through the VIRTIO_NET_CTRL_NOTF_COAL_TX_SET command, or, if the driver
29072959 * did not set any TX coalescing parameters, to 0.
29082960 */
2909- err = virtnet_send_ctrl_coal_vq_cmd (vi , txq2vq ( i ) ,
2910- vi -> intr_coal_tx .max_usecs ,
2911- vi -> intr_coal_tx .max_packets );
2961+ err = virtnet_send_tx_ctrl_coal_vq_cmd (vi , i ,
2962+ vi -> intr_coal_tx .max_usecs ,
2963+ vi -> intr_coal_tx .max_packets );
29122964 if (err )
29132965 return err ;
2914-
2915- vi -> sq [i ].intr_coal .max_usecs = vi -> intr_coal_tx .max_usecs ;
2916- vi -> sq [i ].intr_coal .max_packets = vi -> intr_coal_tx .max_packets ;
29172966 }
29182967
29192968 if (ring -> rx_pending != rx_pending ) {
@@ -2922,14 +2971,11 @@ static int virtnet_set_ringparam(struct net_device *dev,
29222971 return err ;
29232972
29242973 /* The reason is same as the transmit virtqueue reset */
2925- err = virtnet_send_ctrl_coal_vq_cmd (vi , rxq2vq ( i ) ,
2926- vi -> intr_coal_rx .max_usecs ,
2927- vi -> intr_coal_rx .max_packets );
2974+ err = virtnet_send_rx_ctrl_coal_vq_cmd (vi , i ,
2975+ vi -> intr_coal_rx .max_usecs ,
2976+ vi -> intr_coal_rx .max_packets );
29282977 if (err )
29292978 return err ;
2930-
2931- vi -> rq [i ].intr_coal .max_usecs = vi -> intr_coal_rx .max_usecs ;
2932- vi -> rq [i ].intr_coal .max_packets = vi -> intr_coal_rx .max_packets ;
29332979 }
29342980 }
29352981
@@ -3334,48 +3380,24 @@ static int virtnet_send_notf_coal_cmds(struct virtnet_info *vi,
33343380 return 0 ;
33353381}
33363382
3337- static int virtnet_send_ctrl_coal_vq_cmd (struct virtnet_info * vi ,
3338- u16 vqn , u32 max_usecs , u32 max_packets )
3339- {
3340- struct scatterlist sgs ;
3341-
3342- vi -> ctrl -> coal_vq .vqn = cpu_to_le16 (vqn );
3343- vi -> ctrl -> coal_vq .coal .max_usecs = cpu_to_le32 (max_usecs );
3344- vi -> ctrl -> coal_vq .coal .max_packets = cpu_to_le32 (max_packets );
3345- sg_init_one (& sgs , & vi -> ctrl -> coal_vq , sizeof (vi -> ctrl -> coal_vq ));
3346-
3347- if (!virtnet_send_command (vi , VIRTIO_NET_CTRL_NOTF_COAL ,
3348- VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET ,
3349- & sgs ))
3350- return - EINVAL ;
3351-
3352- return 0 ;
3353- }
3354-
33553383static int virtnet_send_notf_coal_vq_cmds (struct virtnet_info * vi ,
33563384 struct ethtool_coalesce * ec ,
33573385 u16 queue )
33583386{
33593387 int err ;
33603388
3361- err = virtnet_send_ctrl_coal_vq_cmd (vi , rxq2vq ( queue ) ,
3362- ec -> rx_coalesce_usecs ,
3363- ec -> rx_max_coalesced_frames );
3389+ err = virtnet_send_rx_ctrl_coal_vq_cmd (vi , queue ,
3390+ ec -> rx_coalesce_usecs ,
3391+ ec -> rx_max_coalesced_frames );
33643392 if (err )
33653393 return err ;
33663394
3367- vi -> rq [queue ].intr_coal .max_usecs = ec -> rx_coalesce_usecs ;
3368- vi -> rq [queue ].intr_coal .max_packets = ec -> rx_max_coalesced_frames ;
3369-
3370- err = virtnet_send_ctrl_coal_vq_cmd (vi , txq2vq (queue ),
3371- ec -> tx_coalesce_usecs ,
3372- ec -> tx_max_coalesced_frames );
3395+ err = virtnet_send_tx_ctrl_coal_vq_cmd (vi , queue ,
3396+ ec -> tx_coalesce_usecs ,
3397+ ec -> tx_max_coalesced_frames );
33733398 if (err )
33743399 return err ;
33753400
3376- vi -> sq [queue ].intr_coal .max_usecs = ec -> tx_coalesce_usecs ;
3377- vi -> sq [queue ].intr_coal .max_packets = ec -> tx_max_coalesced_frames ;
3378-
33793401 return 0 ;
33803402}
33813403
0 commit comments