Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE446C433EF for ; Tue, 8 Feb 2022 02:58:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230340AbiBHC64 (ORCPT ); Mon, 7 Feb 2022 21:58:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238882AbiBHC64 (ORCPT ); Mon, 7 Feb 2022 21:58:56 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 693A7C061A73 for ; Mon, 7 Feb 2022 18:58:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644289134; 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; bh=1iPL/OY2vKtxnnn4ofse5g3sqVcV7OwRhLLviSAEN2s=; b=fMhzR+yVHt4gd4D1q0IWiMTBk13qtyNdcjiiJQw+YlvHc4o6P1dH+drKz146yFEKCmwhu6 8Z0sIdTJkG70x3TqEf7cJFyLHxxDrhDIPDluOADKbM6ayRYfXS/IPihd2yPzv/T7MoT5NT 5KeCSRAJzq0jeKc2l3OvKJJQpUqxfP8= Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-182-ZFyIQKtvNeCGYsFZ-tvflg-1; Mon, 07 Feb 2022 21:58:53 -0500 X-MC-Unique: ZFyIQKtvNeCGYsFZ-tvflg-1 Received: by mail-pf1-f199.google.com with SMTP id z20-20020aa791d4000000b004bd024eaf19so8606221pfa.16 for ; Mon, 07 Feb 2022 18:58:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=1iPL/OY2vKtxnnn4ofse5g3sqVcV7OwRhLLviSAEN2s=; b=B7a6z+tdJLVqK8dKImfnPuSiPJuJRLEy2CkLcreXdmSJzcFnKuWfEIpU6cBwzsOTol B7uqr0msOCrSuxuSeAljVMWqUNsSBHKa2qEkx2vZD1b2ca6jUufBoMU9eGzv0B9dTxDa 1tvq6fGPY8Zocsarm9qMoAdhbMLIO7zh10QxDnbUerNa/TSi9xX4r8YPVFnPwdF2n+nZ RqK2svWDukLt3yrm07aICL7Af8757JynFEFNgN9kKdXcVbRj1DaW/LFzVirgQUmEUd0P 6fjo+CUp0NzcM0f+vpnwTCginzJKU/N8mD1TrDouodD/HexoFuDZy/xc7Nwwq4twUpD6 dUXw== X-Gm-Message-State: AOAM532w5ZnFGmVtLqC0oo1ZeUpA/kLvn2IPdbUQQku47Vthf+j3qtEL 4Kbn2ozUTDiFso5NqB8ptq98rGsvi63qo5GUb2Z5DK8IYm8G/+ChQeHVbVIS3GwSs/Kpf7R2dVx kzJEQPT5woCmD X-Received: by 2002:a17:902:b583:: with SMTP id a3mr2677353pls.77.1644289131929; Mon, 07 Feb 2022 18:58:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDaqEp6ylw0Kb/+6cBe2Mf1Qn8HvvlERmvET9tFW4bEroVdMmJC/V5b59ayI5l0Rjw7B7isA== X-Received: by 2002:a17:902:b583:: with SMTP id a3mr2677336pls.77.1644289131628; Mon, 07 Feb 2022 18:58:51 -0800 (PST) Received: from [10.72.13.233] ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id r12sm9576072pgn.6.2022.02.07.18.58.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Feb 2022 18:58:51 -0800 (PST) Message-ID: Date: Tue, 8 Feb 2022 10:58:45 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH v3 03/17] virtio: queue_reset: struct virtio_config_ops add callbacks for queue_reset Content-Language: en-US To: Xuan Zhuo Cc: "Michael S. Tsirkin" , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , bpf@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org References: <1644218386.0457659-1-xuanzhuo@linux.alibaba.com> From: Jason Wang In-Reply-To: <1644218386.0457659-1-xuanzhuo@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org 在 2022/2/7 下午3:19, Xuan Zhuo 写道: > On Mon, 7 Feb 2022 14:45:02 +0800, Jason Wang wrote: >> 在 2022/1/26 下午3:35, Xuan Zhuo 写道: >>> Performing reset on a queue is divided into two steps: >>> >>> 1. reset_vq: reset one vq >>> 2. enable_reset_vq: re-enable the reset queue >>> >>> In the first step, these tasks will be completed: >>> 1. notify the hardware queue to reset >>> 2. recycle the buffer from vq >>> 3. release the ring of the vq >>> >>> The second step is similar to find vqs, >> >> Not sure, since find_vqs will usually try to allocate interrupts. >> >> > Yes. > > >>> passing parameters callback and >>> name, etc. Based on the original vq, the ring is re-allocated and >>> configured to the backend. >> >> I wonder whether we really have such requirement. >> >> For example, do we really have a use case that may change: >> >> vq callback, ctx, ring_num or even re-create the virtqueue? > 1. virtqueue is not recreated > 2. ring_num can be used to modify ring num by ethtool -G It looks to me we don't support this right now. > > There is really no scene to modify vq callback, ctx, name. > > Do you mean we still use the old one instead of adding these parameters? Yes, I think for driver we need to implement the function that is needed for the first user (e.g AF_XDP). If there's no use case, we can leave those extension for the future. Thanks > > Thanks. > >> Thanks >> >> >>> So add two callbacks reset_vq, enable_reset_vq to struct >>> virtio_config_ops. >>> >>> Add a structure for passing parameters. This will facilitate subsequent >>> expansion of the parameters of enable reset vq. >>> There is currently only one default extended parameter ring_num. >>> >>> Signed-off-by: Xuan Zhuo >>> --- >>> include/linux/virtio_config.h | 43 ++++++++++++++++++++++++++++++++++- >>> 1 file changed, 42 insertions(+), 1 deletion(-) >>> >>> diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h >>> index 4d107ad31149..51dd8461d1b6 100644 >>> --- a/include/linux/virtio_config.h >>> +++ b/include/linux/virtio_config.h >>> @@ -16,6 +16,44 @@ struct virtio_shm_region { >>> u64 len; >>> }; >>> >>> +typedef void vq_callback_t(struct virtqueue *); >>> + >>> +/* virtio_reset_vq: specify parameters for queue_reset >>> + * >>> + * vdev: the device >>> + * queue_index: the queue index >>> + * >>> + * free_unused_cb: callback to free unused bufs >>> + * data: used by free_unused_cb >>> + * >>> + * callback: callback for the virtqueue, NULL for vq that do not need a >>> + * callback >>> + * name: virtqueue names (mainly for debugging), NULL for vq unused by >>> + * driver >>> + * ctx: ctx >>> + * >>> + * ring_num: specify ring num for the vq to be re-enabled. 0 means use the >>> + * default value. MUST be a power of 2. >>> + */ >>> +struct virtio_reset_vq; >>> +typedef void vq_reset_callback_t(struct virtio_reset_vq *param, void *buf); >>> +struct virtio_reset_vq { >>> + struct virtio_device *vdev; >>> + u16 queue_index; >>> + >>> + /* reset vq param */ >>> + vq_reset_callback_t *free_unused_cb; >>> + void *data; >>> + >>> + /* enable reset vq param */ >>> + vq_callback_t *callback; >>> + const char *name; >>> + const bool *ctx; >>> + >>> + /* ext enable reset vq param */ >>> + u16 ring_num; >>> +}; >>> + >>> /** >>> * virtio_config_ops - operations for configuring a virtio device >>> * Note: Do not assume that a transport implements all of the operations >>> @@ -74,8 +112,9 @@ struct virtio_shm_region { >>> * @set_vq_affinity: set the affinity for a virtqueue (optional). >>> * @get_vq_affinity: get the affinity for a virtqueue (optional). >>> * @get_shm_region: get a shared memory region based on the index. >>> + * @reset_vq: reset a queue individually >>> + * @enable_reset_vq: enable a reset queue >>> */ >>> -typedef void vq_callback_t(struct virtqueue *); >>> struct virtio_config_ops { >>> void (*enable_cbs)(struct virtio_device *vdev); >>> void (*get)(struct virtio_device *vdev, unsigned offset, >>> @@ -100,6 +139,8 @@ struct virtio_config_ops { >>> int index); >>> bool (*get_shm_region)(struct virtio_device *vdev, >>> struct virtio_shm_region *region, u8 id); >>> + int (*reset_vq)(struct virtio_reset_vq *param); >>> + struct virtqueue *(*enable_reset_vq)(struct virtio_reset_vq *param); >>> }; >>> >>> /* If driver didn't advertise the feature, it will never appear. */