From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=G2Df/GIO; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 80FF15A061D for ; Thu, 14 Nov 2024 11:23:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731579796; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=/11xgPv1tGsQUFnxHvlTbZZfibcB7JrBhC+nbG1uet8=; b=G2Df/GIOrzMFbLtJJm3CUrNAoYlvnZ2Dq7DlXXDnt69xtxQj3P4TLd4mYEaQwPaqQc9XQf +hOBmi2ccHxgDfVXBfDoF84ugXqVRrt6mtPD0IyORarRfVJL5ycX3diKHW1W5x25B677qS Bo2EugEnTqhoYBK4BmpUegP1rFY7ImQ= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-616-xJfhqtW8OF6p7tMPWXwB-A-1; Thu, 14 Nov 2024 05:23:14 -0500 X-MC-Unique: xJfhqtW8OF6p7tMPWXwB-A-1 X-Mimecast-MFC-AGG-ID: xJfhqtW8OF6p7tMPWXwB-A Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-381e8cf69a6so414018f8f.1 for ; Thu, 14 Nov 2024 02:23:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731579793; x=1732184593; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/11xgPv1tGsQUFnxHvlTbZZfibcB7JrBhC+nbG1uet8=; b=EuD7T2pi9XFAZInJh2BoUooV8zzi6R2wZlPk9buA19UBUXJ6BumXtIE7qUXqQmjZqx 25fvwuhclfk1Mppku4s4WKwhOO1cOczx6HWTc8mgsS6u/OsHXKy4YuVjKrhWUJ2CIvsw qFCTjXobCwMNmxjyc4SLTXQZU2ew3rk83pAXmPy2MtHxkV8V+z9nPYnQCwjHDa0mL6e7 5UbtJnmfcOi/O3WkfzqesZDiW62L9iuCBr/Ob5H+9nVEPt50CkVZaOIDFDfUJmkRGMm2 Vz73VnT64YLBloBFgB/uUoio6Et/8vrDGyz+ZE5VHF5stPQtbI7AY7BVe/L8yLIczsws fTWA== X-Gm-Message-State: AOJu0YyDjl1Hb1rLxZbsBKDYGqi9xfYH8W13is0AA5D5artNaGuOQKdv Vi6kqp2UJuB12hKRdnsmPtnt+WzEJ6yzZTv5LG0l2uUkWoSuxOBotxojH5TEA+58Ir6fad8QPl1 jyhGUulZ4wKtuv7GwKjH7y3DNvSTVpocATiVKIQWqwn312ZkgTyzDfToiSw== X-Received: by 2002:a05:6000:18af:b0:37d:3985:8871 with SMTP id ffacd0b85a97d-382185392fbmr1265229f8f.39.1731579793285; Thu, 14 Nov 2024 02:23:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEKKQzDFytW4+FHcin+yPxSL77Qdj7vWsStPI1m2LO6fQaYiJqHijfOz7ODx79nAwAoGWgQcA== X-Received: by 2002:a05:6000:18af:b0:37d:3985:8871 with SMTP id ffacd0b85a97d-382185392fbmr1265215f8f.39.1731579792907; Thu, 14 Nov 2024 02:23:12 -0800 (PST) Received: from ?IPV6:2a01:e0a:e10:ef90:343a:68f:2e91:95c? ([2a01:e0a:e10:ef90:343a:68f:2e91:95c]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3821ae32211sm1041476f8f.107.2024.11.14.02.23.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Nov 2024 02:23:12 -0800 (PST) Message-ID: <81955149-fc8f-47ef-b6fb-ce284e8e8b1b@redhat.com> Date: Thu, 14 Nov 2024 11:23:11 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v8 7/8] vhost-user: add vhost-user To: Stefano Brivio References: <20241010122903.1188992-1-lvivier@redhat.com> <20241010122903.1188992-8-lvivier@redhat.com> <20241017021034.437f3757@elisabeth> From: Laurent Vivier Autocrypt: addr=lvivier@redhat.com; keydata= xsFNBFYFJhkBEAC2me7w2+RizYOKZM+vZCx69GTewOwqzHrrHSG07MUAxJ6AY29/+HYf6EY2 WoeuLWDmXE7A3oJoIsRecD6BXHTb0OYS20lS608anr3B0xn5g0BX7es9Mw+hV/pL+63EOCVm SUVTEQwbGQN62guOKnJJJfphbbv82glIC/Ei4Ky8BwZkUuXd7d5NFJKC9/GDrbWdj75cDNQx UZ9XXbXEKY9MHX83Uy7JFoiFDMOVHn55HnncflUncO0zDzY7CxFeQFwYRbsCXOUL9yBtqLer Ky8/yjBskIlNrp0uQSt9LMoMsdSjYLYhvk1StsNPg74+s4u0Q6z45+l8RAsgLw5OLtTa+ePM JyS7OIGNYxAX6eZk1+91a6tnqfyPcMbduxyBaYXn94HUG162BeuyBkbNoIDkB7pCByed1A7q q9/FbuTDwgVGVLYthYSfTtN0Y60OgNkWCMtFwKxRaXt1WFA5ceqinN/XkgA+vf2Ch72zBkJL RBIhfOPFv5f2Hkkj0MvsUXpOWaOjatiu0fpPo6Hw14UEpywke1zN4NKubApQOlNKZZC4hu6/ 8pv2t4HRi7s0K88jQYBRPObjrN5+owtI51xMaYzvPitHQ2053LmgsOdN9EKOqZeHAYG2SmRW LOxYWKX14YkZI5j/TXfKlTpwSMvXho+efN4kgFvFmP6WT+tPnwARAQABz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DVvX5yicNqYJPKh5MFXN1bvsB kmYiStMRbrD0HoY1kx5/VozBtc70OU0EB8Wrv9hZD+Ofp0T3KOr1RUHvCZoLURfFhSQ= In-Reply-To: <20241017021034.437f3757@elisabeth> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: EQRH6H-oYV46NsQZObhYBfeMVDYdp0mR3pCYTO2a8f0_1731579793 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: EILVGWO6UNGGM2DEFUFNDH6AZJ7WUSBQ X-Message-ID-Hash: EILVGWO6UNGGM2DEFUFNDH6AZJ7WUSBQ X-MailFrom: lvivier@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 17/10/2024 02:10, Stefano Brivio wrote: >> +/** >> + * tcp_vu_data_from_sock() - Handle new data from socket, queue to vhost-user, >> + * in window >> + * @c: Execution context >> + * @conn: Connection pointer >> + * >> + * Return: Negative on connection reset, 0 otherwise >> + */ >> +int tcp_vu_data_from_sock(const struct ctx *c, struct tcp_tap_conn *conn) >> +{ >> + uint32_t wnd_scaled = conn->wnd_from_tap << conn->ws_from_tap; >> + struct vu_dev *vdev = c->vdev; >> + struct vu_virtq *vq = &vdev->vq[VHOST_USER_RX_QUEUE]; >> + const struct flowside *tapside = TAPFLOW(conn); >> + uint16_t mss = MSS_GET(conn); >> + size_t l2_hdrlen, fillsize; >> + int i, iov_cnt, iov_used; >> + int v4 = CONN_V4(conn); >> + uint32_t already_sent = 0; >> + const uint16_t *check; >> + struct iovec *first; >> + int frame_size; >> + int num_buffers; >> + ssize_t len; >> + >> + if (!vu_queue_enabled(vq) || !vu_queue_started(vq)) { >> + flow_err(conn, >> + "Got packet, but RX virtqueue not usable yet"); >> + return 0; >> + } >> + >> + already_sent = conn->seq_to_tap - conn->seq_ack_from_tap; >> + >> + if (SEQ_LT(already_sent, 0)) { >> + /* RFC 761, section 2.1. */ >> + flow_trace(conn, "ACK sequence gap: ACK for %u, sent: %u", >> + conn->seq_ack_from_tap, conn->seq_to_tap); >> + conn->seq_to_tap = conn->seq_ack_from_tap; >> + already_sent = 0; >> + } >> + >> + if (!wnd_scaled || already_sent >= wnd_scaled) { >> + conn_flag(c, conn, STALLED); >> + conn_flag(c, conn, ACK_FROM_TAP_DUE); >> + return 0; >> + } >> + >> + /* Set up buffer descriptors we'll fill completely and partially. */ >> + >> + fillsize = wnd_scaled; >> + >> + if (peek_offset_cap) >> + already_sent = 0; >> + >> + iov_vu[0].iov_base = tcp_buf_discard; >> + iov_vu[0].iov_len = already_sent; >> + fillsize -= already_sent; >> + >> + /* collect the buffers from vhost-user and fill them with the >> + * data from the socket >> + */ >> + iov_cnt = tcp_vu_sock_recv(c, conn, v4, fillsize, &len); >> + if (iov_cnt <= 0) >> + return iov_cnt; >> + >> + len -= already_sent; >> + if (len <= 0) { >> + conn_flag(c, conn, STALLED); >> + vu_queue_rewind(vq, iov_cnt); >> + return 0; >> + } >> + >> + conn_flag(c, conn, ~STALLED); >> + >> + /* Likely, some new data was acked too. */ >> + tcp_update_seqack_wnd(c, conn, 0, NULL); >> + >> + /* initialize headers */ >> + l2_hdrlen = tcp_vu_l2_hdrlen(!v4); >> + iov_used = 0; >> + num_buffers = 0; >> + check = NULL; >> + frame_size = 0; >> + >> + /* iov_vu is an array of buffers and the buffer size can be >> + * smaller than the frame size we want to use but with >> + * num_buffer we can merge several virtio iov buffers in one packet >> + * we need only to set the packet headers in the first iov and >> + * num_buffer to the number of iov entries > ...this part is clear to me, what I don't understand is if we still > have a way to guarantee that the sum of several buffers is big enough > to fit frame_size bytes. We don't have this garantee. But I think it's the same for the socket version? Thanks, Laurent