From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796303813; b=Dt8G+/CFtfWysT0keAZah1oobdIPljkLLOkqlGdh/3vP9h/5sN3ab2fkTYHn12avcGse bxw4iOBM9spmbFMsjOzBCAH7B29zSdSCTIyGDtmlhgbb7vGzUcQC0p9YMlgKjA7TFX+E3 vCCq0tWfgtCLJSAniOQQSshC4ZC5PPen2IbGlP64OaEJil2HuPBmU7GiZfH7YzA3ZAdwU cuJrKEpKSFO70D9NK8PK1sargF3mdHZQFmuQxplh/KwYMfxPH07TRflZK7ANm4R7v6AeX lBfg9lKpe3Ojnz8vcpT6mEvOjnc6jMWuKgwgb8r4WfJv9i4iLLiPmd1+Q8dDzKsLfqg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796303813; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:Date:From: To:Cc:Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=pAZQ4nlhthAi+YYRZglKPBVDHDISlaNUPk1FTorztTU=; b=gWO6j8dU7d4gTYZSJ4GriYYbq7Nh0PNCpRQl/cX6vPU1yu4nqO0D7XjvsgMmLiJxuaWw XoJAZzzE73s/FIAtlixbftf/0UWZqvGgle+W7rMGiI1N3zYUbWf3T5LH5zWZa1cfgJGc2 PtrIAaepIqvMVnXrztj/MTk/3g5XfU4BDIzp9c+z4m6liC97ly6/LmpS74YXNOnJXAran uhlOMzdF/AwofV0X2iKG2PMJ9hptOw9x3IfUhJZ/aPCFMeUBTYz5TTcp1D1LsdsLoZy46 NrT9NCj6r0S0MJ8rsbLQPNuu5ikwIhtL1gnnZODyrIar26arxQILiKoUbVF/X1T2Fzg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=V3IO3p73; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b="PeLSJu/c"; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77BC8606A322 for ; Thu, 3 Dec 2026 13:16:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 77BC8606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=V3IO3p73; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=PeLSJu/c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796303811; 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: in-reply-to:in-reply-to:references:references; bh=pAZQ4nlhthAi+YYRZglKPBVDHDISlaNUPk1FTorztTU=; b=V3IO3p73T+gUl+aEEXjPLBufRuqJb/8aiZM2MoWgFJjGbwRP7NZktzhHB/7XoD2QymiK6b 1UVdc8QXbmVzYUgQGwZ70jjNCj88u3D8cWis0GNwtjKyOP9V4sBQMS75fFWzC0sbgc1tEc hAFvqMfVDOUY9mSGsjr6Ibk7yP02ZIU= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-453-6DoST_6GOEq7HbT7BmEMdw-1; Thu, 3 Dec 2026 13:16:49 +0000 X-MC-Unique: 6DoST_6GOEq7HbT7BmEMdw-1 X-Mimecast-MFC-AGG-ID: 6DoST_6GOEq7HbT7BmEMdw_1796303808 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4bb6bbc025aso110991575e9.3 for ; Thu, 03 Dec 2026 05:16:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1796303808; x=1796908608; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=pAZQ4nlhthAi+YYRZglKPBVDHDISlaNUPk1FTorztTU=; b=PeLSJu/cOvPQfN5zhh3RfITpx1fqfAffx471uOv5du30aC/A/Cz3fVX3mwFGpRR9Lj GrlEtZj7myAZS9gCdKFBIz/UI6oAC4+dSgP/2jI6oG9wkPm4R6wcskXIcDVE/0h/s0Vp imr9IjKTvGoLNaRwAZ43U//0IuzBgPUK2eDHIGvCRE4BubgipEClAB0QH7/aKAqeZlny 4mEdO0LG2NbnL24qMuwrF8KLphQ452d6x/tlLwG0F6PSdAYyD4ZgPUm/6DUKhiXrzcES CTHvYK6m7PPwqTlT4GlGw4xjD1YH7PzjphIesvj8afZV/6f7xZT4bb34s/kGG64P8iMf 0AEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796303808; x=1796908608; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=pAZQ4nlhthAi+YYRZglKPBVDHDISlaNUPk1FTorztTU=; b=RNtoyjMMYAMuBHkxVhZucgiEMgeCCTcpWX2BV6WzeEFQ4OI/S86ZAcQOegBx3GbUt/ 4edf5p6caa0Ti5h26d0kiNF9c23VqmkC4u0cM6Ipv7QkMmgstOGE2lCUbg51qXoDB4MK 73uFRG9bh+SieV5hDNAjDtNc75BKzcev2VJosIhf+7KHRJozTnCK6KOYXRYzNpabHeIb dNrq1MQFdEpTRM2FyuLG3DqO86dlMmw7Y/Jy1uI4AYJVlbAfTt2ZESch0NAzF0YbmpUG PHTSXEZmyytgSwEFkvHITK7HZldu77ubRPnVdhCUXj5X6waHXQcDRHr/k7HFyc1jllrp FNZw== X-Gm-Message-State: APuU4Z+jPyVtZEkOUP3PLuRi0Z9+zJSACYaldcfwV0nSN7JFEZFj+6/h r7S6yDHH1kQVnt75TnkwLzP49CRH9nhvZ3s4sw5IsMNyFWdkC3Zu7tBlX/lWhVtZyxkTedVsyS6 PIlEZtqyq4EFnPjVROTQSPoo8LCu++kJA/B7qCXTCx3Uco3/E9fqyaaYH5x9S7o2EgA== X-Gm-Gg: AZFdTZetbTCf2HYWqruwpVO7GcVjTyq+eN/JSCq8hAiaCbnzOog9RVl8EUYuye8QKVs oOB0t4lYXg28LZUDfjAdZatp6gVGTnPB8/wgTT5F9bawfchtP+gMjMRsIrhrS6h13HAA9zcnOvS 5wqsBly4wH1nPtDKsxLBp7a+zQZI6EzwOoCEMv7rcPqGsN22/iyoXoY4asxyLwyMTWd0auj+odi ULSzAN9vax+kgUNajXbkHuxL8DqsOPR0/3nkq8xl2KHv+sN6CObBcDMhq6XujQw/fRwtekMkhgT Djqwh2SIl7cuSc33oODjvdspJG5XstLMslurSLW5zvz8Vg9U3zrZQ2KAJZERVkMii94olptF3TR CmgPno1VjeoJmVssFdLGMTpJJxHSX7TpoaWXNWZffsQ== X-Received: by 2002:a05:600d:1c:b0:4bb:9dbd:feb7 with SMTP id 5b1f17b1804b1-4bb9dbdff35mr554621365e9.9.1796303808090; Thu, 03 Dec 2026 05:16:48 -0800 (PST) X-Received: by 2002:a05:600d:1c:b0:4bb:9dbd:feb7 with SMTP id 5b1f17b1804b1-4bb9dbdff35mr554620645e9.9.1796303807381; Thu, 03 Dec 2026 05:16:47 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:153a:4c00:6468:7acf:febf:a046]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe0055483sm79150225e9.6.2026.12.03.05.16.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 05:16:46 -0800 (PST) Date: Thu, 3 Dec 2026 08:16:43 -0500 From: "Michael S. Tsirkin" To: Shahar Shitrit Cc: netdev@vger.kernel.org, jasowang@redhat.com, pabeni@redhat.com, virtualization@lists.linux.dev, parav@nvidia.com, yohadt@nvidia.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, jgg@ziepe.ca, kevin.tian@intel.com, kuba@kernel.org, andrew+netdev@lunn.ch, edumazet@google.com, danielj@nvidia.com Subject: Re: [PATCH net-next v24 06/14] virtio_net: Query and set flow filter caps Message-ID: <20261203081523-mutt-send-email-mst@kernel.org> References: <20261202150502.3350030-1-shshitrit@nvidia.com> <20261202150502.3350030-7-shshitrit@nvidia.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261202150502.3350030-7-shshitrit@nvidia.com> On Wed, Dec 02, 2026 at 05:04:54PM +0200, Shahar Shitrit wrote: > When probing a virtnet device, attempt to read the flow filter > capabilities. In order to use the feature the caps must also > be set. For now setting what was read is sufficient. > > This patch adds uapi definitions virtio_net flow filters define in > version 1.4 of the VirtIO spec. > > Signed-off-by: Shahar Shitrit > Signed-off-by: Daniel Jurgens > Reviewed-by: Parav Pandit > --- > drivers/net/virtio_net.c | 237 +++++++++++++++++++++++++++++ > include/uapi/linux/virtio_net_ff.h | 91 +++++++++++ > 2 files changed, 328 insertions(+) > create mode 100644 include/uapi/linux/virtio_net_ff.h > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 5eef2c3159638..03aea14da492e 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -27,6 +27,10 @@ > #include > #include > #include > +#include > +#include > +#include > +#include > > static int napi_weight = NAPI_POLL_WEIGHT; > module_param(napi_weight, int, 0444); > @@ -284,6 +288,14 @@ static const struct virtnet_stat_desc virtnet_stats_tx_speed_desc_qstat[] = { > VIRTNET_STATS_DESC_TX_QSTAT(speed, ratelimit_packets, hw_drop_ratelimits), > }; > > +struct virtnet_ff { > + struct virtio_device *vdev; > + bool ff_supported; > + struct virtio_net_ff_cap_data *ff_caps; > + struct virtio_net_ff_cap_mask_data *ff_mask; > + struct virtio_net_ff_actions *ff_actions; > +}; > + > #define VIRTNET_Q_TYPE_RX 0 > #define VIRTNET_Q_TYPE_TX 1 > #define VIRTNET_Q_TYPE_CQ 2 > @@ -475,6 +487,8 @@ struct virtnet_info { > > struct virtio_net_rss_config_hdr *rss_hdr; > > + struct virtnet_ff ff; > + > /* Must be last as it ends in a flexible-array member. */ > TRAILING_OVERLAP(struct virtio_net_rss_config_trailer, rss_trailer, hash_key_data, > u8 rss_hash_key_data[NETDEV_RSS_KEY_LEN]; > @@ -518,6 +532,7 @@ static struct sk_buff *virtnet_skb_append_frag(struct receive_queue *rq, > static void virtnet_xsk_completed(struct send_queue *sq, int num); > static void free_unused_bufs(struct virtnet_info *vi); > static void virtnet_del_vqs(struct virtnet_info *vi); > +static void remove_vq_common(struct virtnet_info *vi); > > enum virtnet_xmit_type { > VIRTNET_XMIT_TYPE_SKB, > @@ -5794,6 +5809,199 @@ static const struct netdev_stat_ops virtnet_stat_ops = { > .get_base_stats = virtnet_get_base_stats, > }; > > +static size_t get_mask_size(u16 type) > +{ > + switch (type) { > + case VIRTIO_NET_FF_MASK_TYPE_ETH: > + return sizeof(struct ethhdr); > + case VIRTIO_NET_FF_MASK_TYPE_IPV4: > + return sizeof(struct iphdr); > + case VIRTIO_NET_FF_MASK_TYPE_IPV6: > + return sizeof(struct ipv6hdr); > + case VIRTIO_NET_FF_MASK_TYPE_TCP: > + return sizeof(struct tcphdr); > + case VIRTIO_NET_FF_MASK_TYPE_UDP: > + return sizeof(struct udphdr); > + } > + > + return 0; > +} > + > +static int virtnet_ff_init(struct virtnet_ff *ff, struct virtio_device *vdev) > +{ > + size_t ff_mask_size = sizeof(struct virtio_net_ff_cap_mask_data) + > + sizeof(struct virtio_net_ff_selector) * > + VIRTIO_NET_FF_MASK_TYPE_MAX; > + struct virtio_admin_cmd_query_cap_id_result *cap_id_list; > + struct virtio_net_ff_selector *sel; > + unsigned long sel_types = 0; > + size_t real_ff_mask_size; > + int err; > + int i; > + > + if (!vdev->config->admin_cmd_exec) > + return -EOPNOTSUPP; > + > + cap_id_list = kzalloc(sizeof(*cap_id_list), GFP_KERNEL); > + if (!cap_id_list) > + return -ENOMEM; > + > + err = virtio_admin_cap_id_list_query(vdev, cap_id_list); > + if (err) > + goto err_cap_list; > + > + if (!(virtio_cap_in_list(cap_id_list, VIRTIO_NET_FF_RESOURCE_CAP) && > + virtio_cap_in_list(cap_id_list, VIRTIO_NET_FF_SELECTOR_CAP) && > + virtio_cap_in_list(cap_id_list, VIRTIO_NET_FF_ACTION_CAP))) { > + err = -EOPNOTSUPP; > + goto err_cap_list; > + } > + > + ff->ff_caps = kzalloc(sizeof(*ff->ff_caps), GFP_KERNEL); > + if (!ff->ff_caps) { > + err = -ENOMEM; > + goto err_cap_list; > + } > + > + err = virtio_admin_cap_get(vdev, > + VIRTIO_NET_FF_RESOURCE_CAP, > + ff->ff_caps, > + sizeof(*ff->ff_caps)); > + > + if (err) > + goto err_ff; > + > + if (!le32_to_cpu(ff->ff_caps->groups_limit) || > + !le32_to_cpu(ff->ff_caps->classifiers_limit) || > + !le32_to_cpu(ff->ff_caps->rules_limit) || > + !le32_to_cpu(ff->ff_caps->rules_per_group_limit) || > + !ff->ff_caps->selectors_per_classifier_limit) { > + err = -EINVAL; > + goto err_ff; > + } > + > + /* VIRTIO_NET_FF_MASK_TYPE start at 1 */ > + for (i = 1; i <= VIRTIO_NET_FF_MASK_TYPE_MAX; i++) > + ff_mask_size += get_mask_size(i); > + > + ff->ff_mask = kzalloc(ff_mask_size, GFP_KERNEL); > + if (!ff->ff_mask) { > + err = -ENOMEM; > + goto err_ff; > + } > + > + err = virtio_admin_cap_get(vdev, > + VIRTIO_NET_FF_SELECTOR_CAP, > + ff->ff_mask, > + ff_mask_size); > + > + if (err) > + goto err_ff_mask; > + > + ff->ff_mask->count = min_t(u8, ff->ff_mask->count, > + VIRTIO_NET_FF_MASK_TYPE_MAX); > + > + ff->ff_actions = kzalloc(sizeof(*ff->ff_actions) + > + VIRTIO_NET_FF_ACTION_MAX, > + GFP_KERNEL); > + if (!ff->ff_actions) { > + err = -ENOMEM; > + goto err_ff_mask; > + } > + > + err = virtio_admin_cap_get(vdev, > + VIRTIO_NET_FF_ACTION_CAP, > + ff->ff_actions, > + sizeof(*ff->ff_actions) + VIRTIO_NET_FF_ACTION_MAX); > + > + if (err) > + goto err_ff_action; > + > + ff->ff_actions->count = min_t(u8, ff->ff_actions->count, > + VIRTIO_NET_FF_ACTION_MAX); > + if (!ff->ff_actions->count) { > + err = -EINVAL; > + goto err_ff_action; > + } > + > + err = virtio_admin_cap_set(vdev, > + VIRTIO_NET_FF_RESOURCE_CAP, > + ff->ff_caps, > + sizeof(*ff->ff_caps)); > + if (err) > + goto err_ff_action; > + > + real_ff_mask_size = sizeof(struct virtio_net_ff_cap_mask_data); > + sel = (void *)&ff->ff_mask->selectors; > + > + for (i = 0; i < ff->ff_mask->count; i++) { > + /* If the selector type is unknown it may indicate the spec > + * has been revised to include new types of selectors > + */ > + if (!sel->type || sel->type > VIRTIO_NET_FF_MASK_TYPE_MAX) > + break; > + > + if (sel->length != get_mask_size(sel->type) || > + test_and_set_bit(sel->type, &sel_types)) { > + err = -EPROTO; > + goto err_ff_action; > + } > + real_ff_mask_size += sizeof(*sel) + sel->length; > + if (real_ff_mask_size > ff_mask_size) { > + err = -EPROTO; > + goto err_ff_action; > + } > + sel = (void *)sel + sizeof(*sel) + sel->length; > + } > + ff->ff_mask->count = i; > + > + err = virtio_admin_cap_set(vdev, > + VIRTIO_NET_FF_SELECTOR_CAP, > + ff->ff_mask, > + real_ff_mask_size); > + if (err) > + goto err_ff_action; > + > + err = virtio_admin_cap_set(vdev, > + VIRTIO_NET_FF_ACTION_CAP, > + ff->ff_actions, > + sizeof(*ff->ff_actions) + ff->ff_actions->count); > + if (err) > + goto err_ff_action; > + > + ff->vdev = vdev; > + ff->ff_supported = true; > + > + kfree(cap_id_list); > + > + return 0; > + > +err_ff_action: > + kfree(ff->ff_actions); > + ff->ff_actions = NULL; > +err_ff_mask: > + kfree(ff->ff_mask); > + ff->ff_mask = NULL; > +err_ff: > + kfree(ff->ff_caps); > + ff->ff_caps = NULL; > +err_cap_list: > + kfree(cap_id_list); > + > + return err; > +} > + > +static void virtnet_ff_cleanup(struct virtnet_ff *ff) > +{ > + if (!ff->ff_supported) > + return; > + > + kfree(ff->ff_actions); > + kfree(ff->ff_mask); > + kfree(ff->ff_caps); > + ff->ff_supported = false; > +} > + > static void virtnet_freeze_down(struct virtio_device *vdev) > { > struct virtnet_info *vi = vdev->priv; > @@ -5811,6 +6019,10 @@ static void virtnet_freeze_down(struct virtio_device *vdev) > netif_tx_lock_bh(vi->dev); > netif_device_detach(vi->dev); > netif_tx_unlock_bh(vi->dev); > + > + rtnl_lock(); > + virtnet_ff_cleanup(&vi->ff); > + rtnl_unlock(); > } So do we need rtnl_lock around virtnet_ff_cleanup? Because below it is called without rtnl_lock. > > static int init_vqs(struct virtnet_info *vi); > @@ -5838,6 +6050,20 @@ static int virtnet_restore_up(struct virtio_device *vdev) > goto err_destroy_pools; > } > > + /* > + * Initialize flow filters. Not supported is an acceptable and common > + * return code > + */ > + rtnl_lock(); > + err = virtnet_ff_init(&vi->ff, vi->vdev); > + if (err && err != -EOPNOTSUPP) { > + rtnl_unlock(); > + virtnet_freeze_down(vi->vdev); > + remove_vq_common(vi); > + return err; > + } > + rtnl_unlock(); > + > netif_tx_lock_bh(vi->dev); > netif_device_attach(vi->dev); > netif_tx_unlock_bh(vi->dev); > @@ -7142,6 +7368,15 @@ static int virtnet_probe(struct virtio_device *vdev) > > virtio_device_ready(vdev); > > + /* Initialize flow filters. Not supported is an acceptable and common > + * return code > + */ > + err = virtnet_ff_init(&vi->ff, vi->vdev); > + if (err && err != -EOPNOTSUPP) { > + rtnl_unlock(); > + goto free_unregister_netdev; > + } > + > if (vi->has_rss || vi->has_rss_hash_report) { > if (!virtnet_commit_rss_command(vi)) { > dev_warn(&vdev->dev, "RSS disabled because committing failed.\n"); > @@ -7226,6 +7461,7 @@ static int virtnet_probe(struct virtio_device *vdev) > > free_unregister_netdev: > unregister_netdev(dev); > + virtnet_ff_cleanup(&vi->ff); > free_failover: > net_failover_destroy(vi->failover); > free_page_pools: > @@ -7275,6 +7511,7 @@ static void virtnet_remove(struct virtio_device *vdev) > virtnet_free_irq_moder(vi); > > unregister_netdev(vi->dev); > + virtnet_ff_cleanup(&vi->ff); > > net_failover_destroy(vi->failover); > > diff --git a/include/uapi/linux/virtio_net_ff.h b/include/uapi/linux/virtio_net_ff.h > new file mode 100644 > index 0000000000000..f9e771a0baff1 > --- /dev/null > +++ b/include/uapi/linux/virtio_net_ff.h > @@ -0,0 +1,91 @@ > +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note > + * > + * Header file for virtio_net flow filters > + */ > +#ifndef _LINUX_VIRTIO_NET_FF_H > +#define _LINUX_VIRTIO_NET_FF_H > + > +#include > +#include > + > +#define VIRTIO_NET_FF_RESOURCE_CAP 0x800 > +#define VIRTIO_NET_FF_SELECTOR_CAP 0x801 > +#define VIRTIO_NET_FF_ACTION_CAP 0x802 > + > +/** > + * struct virtio_net_ff_cap_data - Flow filter resource capability limits > + * @groups_limit: maximum number of flow filter groups supported by the device > + * @classifiers_limit: maximum number of classifiers supported by the device > + * @rules_limit: maximum number of rules supported device-wide across all groups > + * @rules_per_group_limit: maximum number of rules allowed in a single group > + * @last_rule_priority: priority value associated with the lowest-priority rule > + * @selectors_per_classifier_limit: maximum selectors allowed in one classifier > + */ > +struct virtio_net_ff_cap_data { > + __le32 groups_limit; > + __le32 classifiers_limit; > + __le32 rules_limit; > + __le32 rules_per_group_limit; > + __u8 last_rule_priority; > + __u8 selectors_per_classifier_limit; > + /* private: */ > + __u8 reserved[2]; > +}; > + > +/** > + * struct virtio_net_ff_selector - Selector mask descriptor > + * @type: selector type, one of VIRTIO_NET_FF_MASK_TYPE_* constants > + * @flags: selector flags, see VIRTIO_NET_FF_MASK_F_* constants > + * @reserved: must be set to 0 by the driver and ignored by the device > + * @length: size in bytes of @mask > + * @reserved1: must be set to 0 by the driver and ignored by the device > + * @mask: variable-length mask payload for @type, length given by @length > + * > + * A selector describes a header mask that a classifier can apply. The format > + * of @mask depends on @type. > + */ > +struct virtio_net_ff_selector { > + __u8 type; > + __u8 flags; > + __u8 reserved[2]; > + __u8 length; > + __u8 reserved1[3]; > + __u8 mask[] __counted_by(length); > +}; > + > +#define VIRTIO_NET_FF_MASK_TYPE_ETH 1 > +#define VIRTIO_NET_FF_MASK_TYPE_IPV4 2 > +#define VIRTIO_NET_FF_MASK_TYPE_IPV6 3 > +#define VIRTIO_NET_FF_MASK_TYPE_TCP 4 > +#define VIRTIO_NET_FF_MASK_TYPE_UDP 5 > +#define VIRTIO_NET_FF_MASK_TYPE_MAX VIRTIO_NET_FF_MASK_TYPE_UDP > + > +/** > + * struct virtio_net_ff_cap_mask_data - Supported selector mask formats > + * @count: number of entries in @selectors > + * @reserved: must be set to 0 by the driver and ignored by the device > + * @selectors: packed array of struct virtio_net_ff_selector. > + */ > +struct virtio_net_ff_cap_mask_data { > + __u8 count; > + __u8 reserved[7]; > + __u8 selectors[]; > +}; > + > +#define VIRTIO_NET_FF_MASK_F_PARTIAL_MASK (1 << 0) > + > +#define VIRTIO_NET_FF_ACTION_DROP 1 > +#define VIRTIO_NET_FF_ACTION_RX_VQ 2 > +#define VIRTIO_NET_FF_ACTION_MAX VIRTIO_NET_FF_ACTION_RX_VQ > +/** > + * struct virtio_net_ff_actions - Supported flow actions > + * @count: number of supported actions in @actions > + * @reserved: must be set to 0 by the driver and ignored by the device > + * @actions: array of action identifiers (VIRTIO_NET_FF_ACTION_*) > + */ > +struct virtio_net_ff_actions { > + __u8 count; > + __u8 reserved[7]; > + __u8 actions[] __counted_by(count); > +}; > +#endif > -- > 2.49.0 >