From patchwork Thu Aug 1 13:23:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heng Qi X-Patchwork-Id: 13750526 X-Patchwork-Delegate: kuba@kernel.org Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1657016DC02 for ; Thu, 1 Aug 2024 13:23:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.99 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722518631; cv=none; b=ahjdNHCLkoc1MpSfu0N/fF/xl+vAqmUIKo1sirq42Cc16xFGLbEhui678Ib1isIvtaCoQtb09i8PGCswgLKwt+IvIUR+SG6OquId8+zr8IG/mHefu3dHv2o4Xdzkdl2E8KJWyweIGYv794Syb5BG+cI4xhK0cC9pwB8krf1ob4c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722518631; c=relaxed/simple; bh=pxAMgUl6RpgEzddwp0OuSLVZnmbZKSASw1sE3RPnW5A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=j6JTwvlF0MU1+Kf0fNFj5Ztsg+PB83aF4j7w67tCQaWP2Bh2922RBt7abzZCsOfi+jt2M2nIUxR4SLKbqaL1EF4wPYx83NlPIGJsAxKF0WVpd1FNnsW8bVvNA3oKLRSnoCmTCd0rREzbjKkPIIMQ/AcGcl247Yekk6ULDBf8yP0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=bUjp3cXX; arc=none smtp.client-ip=115.124.30.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="bUjp3cXX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1722518621; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=nmlezCt3y4sHPiSBV8DTZAgWvKS3ESvpRmOQCDwrnNQ=; b=bUjp3cXXWg/lvCir4fkpVeV3G3hTN590HU4FhC2Gku7bKQ+ad1XUNUl8GZlayE4ympVqdC1+BFXgyLnrVqd/vVD/d7hxssykkeDj8kuiTH69ucwC6m3sAKcFaYegLi/B6dLXEC83eYPzLtSecj1RiKEmGyibDsvejORQDlxSfgM= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033068173054;MF=hengqi@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0WBtoWuU_1722518620; Received: from localhost(mailfrom:hengqi@linux.alibaba.com fp:SMTPD_---0WBtoWuU_1722518620) by smtp.aliyun-inc.com; Thu, 01 Aug 2024 21:23:40 +0800 From: Heng Qi To: netdev@vger.kernel.org, Jason Wang , "Michael S. Tsirkin" Cc: virtualization@lists.linux.dev, Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , =?utf-8?q?Eugenio_P=C3=A9rez?= , Xuan Zhuo Subject: [PATCH net v4 1/2] virtio-net: check feature before configuring the vq coalescing command Date: Thu, 1 Aug 2024 21:23:37 +0800 Message-Id: <20240801132338.107025-2-hengqi@linux.alibaba.com> X-Mailer: git-send-email 2.32.0.3.g01195cf9f In-Reply-To: <20240801132338.107025-1-hengqi@linux.alibaba.com> References: <20240801132338.107025-1-hengqi@linux.alibaba.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Virtio spec says: The driver MUST have negotiated the VIRTIO_NET_F_VQ_NOTF_COAL feature when issuing commands VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET and VIRTIO_NET_CTRL_NOTF_COAL_VQ_GET. So we add the feature negotiation check to virtnet_send_{r,t}x_ctrl_coal_vq_cmd as a basis for the next bugfix patch. Suggested-by: Michael S. Tsirkin Signed-off-by: Heng Qi Acked-by: Jason Wang --- v2->v3: - Break out the feature check and the fix into separate patches. drivers/net/virtio_net.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 0383a3e136d6..b1176be8fcfd 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -3658,6 +3658,9 @@ static int virtnet_send_rx_ctrl_coal_vq_cmd(struct virtnet_info *vi, { int err; + if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_VQ_NOTF_COAL)) + return -EOPNOTSUPP; + err = virtnet_send_ctrl_coal_vq_cmd(vi, rxq2vq(queue), max_usecs, max_packets); if (err) @@ -3675,6 +3678,9 @@ static int virtnet_send_tx_ctrl_coal_vq_cmd(struct virtnet_info *vi, { int err; + if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_VQ_NOTF_COAL)) + return -EOPNOTSUPP; + err = virtnet_send_ctrl_coal_vq_cmd(vi, txq2vq(queue), max_usecs, max_packets); if (err) From patchwork Thu Aug 1 13:23:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Heng Qi X-Patchwork-Id: 13750527 X-Patchwork-Delegate: kuba@kernel.org Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F358B1A255A for ; Thu, 1 Aug 2024 13:23:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722518631; cv=none; b=Vapdauis+/fr8P0/SmwHfteyN0aNX/52djbm82q/HEL5AxMPsh+CGbMLbckJEmJvxwqmmFBV83PhaYem4mv/aH//xCAEGmRwCa/t8ZGnHM7nKh3GIVaIduY6Vo2qHJJ7Sr0k5mW+o5W0Or2RQWGKyq/2MOJ8+8U4IApSeeyNmMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722518631; c=relaxed/simple; bh=wuruu1gVyucbxUH3Qf7G/JYs6iQmFD1AW8zZkd5bSFg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=gn4RJt+DKp7nhovFglZ/C0UWKoFoW8CWoPeHctaT1SBZ7hIJB9l6JSayI6vKVVuZirScmLNN0O+Cac3nFGxlAfaDxAckqIfwyRzNsdZTPon27EvrA+H/tuRMWpGU4aGJO8SPC/9DujMfrtKwXuQBQQL4q3TLkgfOTl98oQCA8jI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=yCGnYMuS; arc=none smtp.client-ip=115.124.30.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="yCGnYMuS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1722518622; h=From:To:Subject:Date:Message-Id:MIME-Version:Content-Type; bh=21Crsi8z2e5Y5WnMRGR745jK4syZ6mZ6kO+JL+4hvkM=; b=yCGnYMuSZXjuCaq1bncHoe0RkMIkRI1iU4kyM9AZcHohAKU+xHKs0xQ8mkq156FeRoeubU5CzQfgd9wp3HEFSyH5dU+uxJPTg0VIb7nLswYmuOam7MARt/HVHPohh0ZJXFIvVgnDLPYGQQkhiP7QRpdstjZY8aIUT+I+BuznPkk= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R581e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037067111;MF=hengqi@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0WBtsEFx_1722518621; Received: from localhost(mailfrom:hengqi@linux.alibaba.com fp:SMTPD_---0WBtsEFx_1722518621) by smtp.aliyun-inc.com; Thu, 01 Aug 2024 21:23:42 +0800 From: Heng Qi To: netdev@vger.kernel.org, Jason Wang , "Michael S. Tsirkin" Cc: virtualization@lists.linux.dev, Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , =?utf-8?q?Eugenio_P=C3=A9rez?= , Xuan Zhuo Subject: [PATCH net v4 2/2] virtio-net: unbreak vq resizing when coalescing is not negotiated Date: Thu, 1 Aug 2024 21:23:38 +0800 Message-Id: <20240801132338.107025-3-hengqi@linux.alibaba.com> X-Mailer: git-send-email 2.32.0.3.g01195cf9f In-Reply-To: <20240801132338.107025-1-hengqi@linux.alibaba.com> References: <20240801132338.107025-1-hengqi@linux.alibaba.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Don't break the resize action if the vq coalescing feature named VIRTIO_NET_F_VQ_NOTF_COAL is not negotiated. Fixes: f61fe5f081cf ("virtio-net: fix the vq coalescing setting for vq resize") Signed-off-by: Heng Qi Reviewed-by: Xuan Zhuo Acked-by: Eugenio Pé rez Acked-by: Jason Wang --- v3->v4: - Add a comment. v2->v3: - Break out the feature check and the fix into separate patches. v1->v2: - Rephrase the subject. - Put the feature check inside the virtnet_send_{r,t}x_ctrl_coal_vq_cmd(). drivers/net/virtio_net.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index b1176be8fcfd..3f10c72743e9 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -3749,7 +3749,11 @@ static int virtnet_set_ringparam(struct net_device *dev, err = virtnet_send_tx_ctrl_coal_vq_cmd(vi, i, vi->intr_coal_tx.max_usecs, vi->intr_coal_tx.max_packets); - if (err) + + /* Don't break the tx resize action if the vq coalescing is not + * supported. The same is true for rx resize below. + */ + if (err && err != -EOPNOTSUPP) return err; } @@ -3764,7 +3768,7 @@ static int virtnet_set_ringparam(struct net_device *dev, vi->intr_coal_rx.max_usecs, vi->intr_coal_rx.max_packets); mutex_unlock(&vi->rq[i].dim_lock); - if (err) + if (err && err != -EOPNOTSUPP) return err; } }