net/netvsc: fix seg fault during transmit

Message ID 20200729135844.16689-1-3chas3@gmail.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/netvsc: fix seg fault during transmit |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Chas Williams July 29, 2020, 1:58 p.m. UTC
  Commit cc0251813277 ("net/netvsc: split send buffers from Tx
descriptors") changed the way that transmit descriptors are
allocated. They come from a single pool instead of being
individually attached to each mbuf. To find the IOVA, you need
to calculate the offset from the base of the pool.

Fixes: cc0251813277 ("net/netvsc: split send buffers from Tx descriptors")
Cc: stable@dpdk.org

Signed-off-by: Chas Williams <3chas3@gmail.com>
---
 drivers/net/netvsc/hn_rxtx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Stephen Hemminger July 30, 2020, 3:13 p.m. UTC | #1
On Wed, 29 Jul 2020 09:58:44 -0400
Chas Williams <3chas3@gmail.com> wrote:

> Commit cc0251813277 ("net/netvsc: split send buffers from Tx
> descriptors") changed the way that transmit descriptors are
> allocated. They come from a single pool instead of being
> individually attached to each mbuf. To find the IOVA, you need
> to calculate the offset from the base of the pool.
> 
> Fixes: cc0251813277 ("net/netvsc: split send buffers from Tx descriptors")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Chas Williams <3chas3@gmail.com>

Acked-by: Stephen Hemminger <stephen@networkplumber.org>
  
Ferruh Yigit July 30, 2020, 5:31 p.m. UTC | #2
On 7/30/2020 4:13 PM, Stephen Hemminger wrote:
> On Wed, 29 Jul 2020 09:58:44 -0400
> Chas Williams <3chas3@gmail.com> wrote:
> 
>> Commit cc0251813277 ("net/netvsc: split send buffers from Tx
>> descriptors") changed the way that transmit descriptors are
>> allocated. They come from a single pool instead of being
>> individually attached to each mbuf. To find the IOVA, you need
>> to calculate the offset from the base of the pool.
>>
>> Fixes: cc0251813277 ("net/netvsc: split send buffers from Tx descriptors")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Chas Williams <3chas3@gmail.com>
> 
> Acked-by: Stephen Hemminger <stephen@networkplumber.org>
> 

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
index 86a4c0d74..0428c586a 100644
--- a/drivers/net/netvsc/hn_rxtx.c
+++ b/drivers/net/netvsc/hn_rxtx.c
@@ -1421,11 +1421,12 @@  static int hn_xmit_sg(struct hn_tx_queue *txq,
 	hn_rndis_dump(txd->rndis_pkt);
 
 	/* pass IOVA of rndis header in first segment */
-	addr = rte_malloc_virt2iova(txd->rndis_pkt);
+	addr = rte_malloc_virt2iova(txq->tx_rndis);
 	if (unlikely(addr == RTE_BAD_IOVA)) {
 		PMD_DRV_LOG(ERR, "RNDIS transmit can not get iova");
 		return -EINVAL;
 	}
+	addr = addr + ((char *)txd->rndis_pkt - (char *)txq->tx_rndis);
 
 	sg[0].page = addr / PAGE_SIZE;
 	sg[0].ofs = addr & PAGE_MASK;