From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1665EA053A; Wed, 5 Aug 2020 16:06:38 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 002AC2C28; Wed, 5 Aug 2020 16:06:37 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by dpdk.org (Postfix) with ESMTP id 900532BB5 for ; Wed, 5 Aug 2020 16:06:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596636396; 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=/twIthQgDPBC9cm6jBpjzKfhGxA61ll5TKrqMiHCCfs=; b=SjqpWYfcbf5Z1gUrRbRdh/fYaCBqSwXI65U7LSUd8eegcmd/ZgErWx+lPwZVlEsYw8qrFp dw03eXNJrvh7ALogAq5I9ffks/mnZ+Fb5uIx5g8JU9cDNi9WBZPVZBum8WUYmDNEVuAdzX wySrlhOyjZRkvHnZfE67xO/aXVMaBGo= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-405-i66mN_tsO56JV6_gXJZI8Q-1; Wed, 05 Aug 2020 10:06:34 -0400 X-MC-Unique: i66mN_tsO56JV6_gXJZI8Q-1 Received: by mail-wr1-f72.google.com with SMTP id 89so13616938wrr.15 for ; Wed, 05 Aug 2020 07:06:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=/twIthQgDPBC9cm6jBpjzKfhGxA61ll5TKrqMiHCCfs=; b=qbWv9BpJdWsQ5iEsb/fyWt1YLZ/W4iu7ELKVduoTdxiIfYz4D7iFKvRaDfS37XX+Uo blh2Yw9BVsHbj33LGiXjnxPKqsjsAYc4Crd9s9KxmuQ0JXcUWbIZroTZXrvJoarxIFgq ltVHW0CwLgEf+K4SP9NO+UnqNsy44ykqj7wtgq+fxEZAl1q94LQsXz30bAkWIqFAQ5SL wQsal6gSmorlT1cgb+RdgtQujDxJIoAHERZlc9MTgiBzBPNdQB6OGZYkdvhURtdJ663T hJLStULN4mJHeESZSjwh4K3drks70FenNpjptIu4ERuf37SRFLOmG+ikdgO4HE5E4ufN L3GQ== X-Gm-Message-State: AOAM53143RwZS2u9GAV+QVSxO4QwM505C7jDav8UU71Us/84EiAym9Ns nZeulNG3QASWYDFggTi8TLHoZVYJ5iT/57OC9gaMh/dgV8oSpQoHTSsd7638j6NkkRjqQ1RxKF7 jk3M= X-Received: by 2002:a1c:6408:: with SMTP id y8mr3386519wmb.52.1596636392923; Wed, 05 Aug 2020 07:06:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5Orsnry2jm5Rg54mrkRSMZHWRxprHuTe3A9VXGKy+oQCFYg7cgCbTBWxB6t0xVI6TJVA/ow== X-Received: by 2002:a1c:6408:: with SMTP id y8mr3386498wmb.52.1596636392675; Wed, 05 Aug 2020 07:06:32 -0700 (PDT) Received: from amorenoz.users.ipa.redhat.com ([94.73.63.18]) by smtp.gmail.com with ESMTPSA id l11sm2813600wme.11.2020.08.05.07.06.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Aug 2020 07:06:32 -0700 (PDT) To: "Xia, Chenbo" , "dev@dpdk.org" Cc: "Wang, Zhihong" , "maxime.coquelin@redhat.com" References: <20200804072431.86441-1-amorenoz@redhat.com> <20200804072431.86441-4-amorenoz@redhat.com> From: Adrian Moreno Autocrypt: addr=amoren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+jKSR8F355z0sfW7CIMDC4ZWrPsskjEy1YN/U10 r6tRRH1kNyrCSbTG0d9MtcQO58h7DLXuzUhErB+BtG52A04t5cweIJTJC+koV5XPeilzlHnm RFoj0ncruGa9Odns21BNt3cy9wLfK+aUnWuAB1uc6bJGQPiAwjkilz7g7MBRUuIQ2Zt7HGLc SwARAQABiQE8BBgBCAAmFiEEogUDgihhmbOPHy26d5C5fbYeFsUFAl1syNUCGwwFCQHhM4AA CgkQd5C5fbYeFsUlSwf8CH+u/IXaE7WeWxwFkMaORfW8cM4q0xrL3M6yRGuQNW+kMjnrvK9U J9G+L1/5uTRbDQ/4LdoKqize8LjehA+iF6ba4t9Npikh8fLKWgaJfQ/hPhH4C3O5gWPOLTW6 ylGxiuER4CdFwQIoAMMslhFA7G+teeOKBq36E+1+zrybI6Xy1UBSlpDK9j4CtTnMQejjuSQb Qhle+l8VroaUHq869wjAhRHHhqmtJKggI+OvzgQpDIwfHIDypb1BuKydi2W6cVYEALUYyCLS dTBDhzj8zR5tPCsga8J7+TclQzkWOiI2C6ZtiWrMsL/Uym3uXk5nsoc7lSj7yLd/MrBRhYfP JQ== Message-ID: Date: Wed, 5 Aug 2020 16:06:31 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=amorenoz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v2 3/4] net/virtio: add GET_STATUS support to virtio-user X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 8/5/20 12:55 PM, Xia, Chenbo wrote: > Hi Adrian, > >> -----Original Message----- >> From: Adrian Moreno >> Sent: Tuesday, August 4, 2020 3:25 PM >> To: dev@dpdk.org >> Cc: Wang, Zhihong ; Xia, Chenbo >> ; maxime.coquelin@redhat.com; Adrian Moreno >> >> Subject: [PATCH v2 3/4] net/virtio: add GET_STATUS support to virtio-user >> >> This patch adds support for VHOST_USER_GET_STATUS request. >> >> Only vhost-user backed is supported for now >> >> Signed-off-by: Adrian Moreno >> --- >> drivers/net/virtio/virtio_user/vhost_user.c | 2 + >> .../net/virtio/virtio_user/virtio_user_dev.c | 42 +++++++++++++++++++ >> .../net/virtio/virtio_user/virtio_user_dev.h | 1 + >> drivers/net/virtio/virtio_user_ethdev.c | 2 + >> 4 files changed, 47 insertions(+) >> >> diff --git a/drivers/net/virtio/virtio_user/vhost_user.c >> b/drivers/net/virtio/virtio_user/vhost_user.c >> index 337e51199..12b6c7dbc 100644 >> --- a/drivers/net/virtio/virtio_user/vhost_user.c >> +++ b/drivers/net/virtio/virtio_user/vhost_user.c >> @@ -279,6 +279,7 @@ vhost_user_sock(struct virtio_user_dev *dev, >> switch (req) { >> case VHOST_USER_GET_FEATURES: >> case VHOST_USER_GET_PROTOCOL_FEATURES: >> + case VHOST_USER_GET_STATUS: >> need_reply = 1; >> break; >> >> @@ -373,6 +374,7 @@ vhost_user_sock(struct virtio_user_dev *dev, >> >> switch (req) { >> case VHOST_USER_GET_FEATURES: >> + case VHOST_USER_GET_STATUS: >> case VHOST_USER_GET_PROTOCOL_FEATURES: >> if (msg.size != sizeof(m.payload.u64)) { >> PMD_DRV_LOG(ERR, "Received bad msg size"); >> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c >> b/drivers/net/virtio/virtio_user/virtio_user_dev.c >> index 670fc9d40..a5b2d7057 100644 >> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c >> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c >> @@ -807,3 +807,45 @@ virtio_user_send_status_update(struct virtio_user_dev >> *dev, uint8_t status) >> >> return 0; >> } >> + >> +int >> +virtio_user_update_status(struct virtio_user_dev *dev) >> +{ >> + uint64_t ret; >> + int err; >> + >> + /* Vhost-user only for now */ >> + if (!is_vhost_user_by_type(dev->path)) >> + return 0; >> + >> + if (!(dev->protocol_features & (1UL << >> VHOST_USER_PROTOCOL_F_STATUS))) >> + return 0; >> + >> + err = dev->ops->send_request(dev, VHOST_USER_GET_STATUS, &ret); >> + if (err) { >> + PMD_INIT_LOG(ERR, "VHOST_USER_GET_STATUS failed (%d): %s", err, >> + strerror(errno)); >> + return -1; >> + } >> + if (ret > UINT8_MAX) { >> + PMD_INIT_LOG(ERR, "Invalid VHOST_USER_GET_STATUS response 0x%" >> PRIx64 "\n", ret); >> + return -1; >> + } >> + >> + dev->status = ret; >> + PMD_INIT_LOG(DEBUG, "Updated Device Status(0x%08x):\n" >> + "\t-ACKNOWLEDGE: %u\n" >> + "\t-DRIVER: %u\n" >> + "\t-DRIVER_OK: %u\n" >> + "\t-FEATURES_OK: %u\n" >> + "\t-DEVICE_NEED_RESET: %u\n" >> + "\t-FAILED: %u\n", >> + dev->status, >> + !!(dev->status & VIRTIO_CONFIG_STATUS_ACK), >> + !!(dev->status & VIRTIO_CONFIG_STATUS_DRIVER), >> + !!(dev->status & VIRTIO_CONFIG_STATUS_DRIVER_OK), >> + !!(dev->status & VIRTIO_CONFIG_STATUS_FEATURES_OK), >> + !!(dev->status & VIRTIO_CONFIG_STATUS_DEV_NEED_RESET), >> + !!(dev->status & VIRTIO_CONFIG_STATUS_FAILED)); >> + return 0; >> +} > > Should we also add RESET in this log? I just did a simple test and it shows > status could be updated to 0x00. > Yep. I'll add it. Thanks > Thanks! > Chenbo > >> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h >> b/drivers/net/virtio/virtio_user/virtio_user_dev.h >> index 835ab64ae..9377d5ba6 100644 >> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h >> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h >> @@ -73,4 +73,5 @@ void virtio_user_handle_cq_packed(struct virtio_user_dev >> *dev, >> uint16_t queue_idx); >> uint8_t virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t >> q_pairs); >> int virtio_user_send_status_update(struct virtio_user_dev *dev, uint8_t >> status); >> +int virtio_user_update_status(struct virtio_user_dev *dev); >> #endif >> diff --git a/drivers/net/virtio/virtio_user_ethdev.c >> b/drivers/net/virtio/virtio_user_ethdev.c >> index 785882e06..87f6cb695 100644 >> --- a/drivers/net/virtio/virtio_user_ethdev.c >> +++ b/drivers/net/virtio/virtio_user_ethdev.c >> @@ -280,6 +280,8 @@ virtio_user_get_status(struct virtio_hw *hw) >> { >> struct virtio_user_dev *dev = virtio_user_get_dev(hw); >> >> + virtio_user_update_status(dev); >> + >> return dev->status; >> } >> >> -- >> 2.26.2 > -- Adrián Moreno