[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240916084619.581-1-gur.stavi@huawei.com>
Date: Mon, 16 Sep 2024 11:46:18 +0300
From: <gur.stavi@...wei.com>
To: <akihiko.odaki@...nix.com>
CC: <andrew@...nix.com>, <corbet@....net>, <davem@...emloft.net>,
<edumazet@...gle.com>, <jasowang@...hat.com>, <kuba@...nel.org>,
<kvm@...r.kernel.org>, <linux-doc@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-kselftest@...r.kernel.org>,
<mst@...hat.com>, <netdev@...r.kernel.org>, <pabeni@...hat.com>,
<shuah@...nel.org>, <virtualization@...ts.linux-foundation.org>,
<willemdebruijn.kernel@...il.com>, <xuanzhuo@...ux.alibaba.com>,
<yuri.benditovich@...nix.com>
Subject: [PATCH RFC v3 2/9] virtio_net: Add functions for hashing
> +
> +static inline bool virtio_net_hash_rss(const struct sk_buff *skb,
> + u32 types, const __be32 *key,
> + struct virtio_net_hash *hash)
Based on the guidelines, this function seems imperative rather than
predicate and should return an error-code integer.
https://www.kernel.org/doc/html/latest/process/coding-style.html#function-return-values-and-names
> +{
> + u16 report;
> + struct virtio_net_toeplitz_state toeplitz_state = {
> + .key_buffer = be32_to_cpu(*key),
> + .key = key
> + };
> + struct flow_keys flow;
> +
> + if (!skb_flow_dissect_flow_keys(skb, &flow, 0))
> + return false;
> +
> + report = virtio_net_hash_report(types, flow.basic);
> +
> + switch (report) {
> + case VIRTIO_NET_HASH_REPORT_IPv4:
> + virtio_net_toeplitz(&toeplitz_state,
> + (__be32 *)&flow.addrs.v4addrs,
> + sizeof(flow.addrs.v4addrs) / 4);
> + break;
> +
> + case VIRTIO_NET_HASH_REPORT_TCPv4:
> + virtio_net_toeplitz(&toeplitz_state,
> + (__be32 *)&flow.addrs.v4addrs,
> + sizeof(flow.addrs.v4addrs) / 4);
> + virtio_net_toeplitz(&toeplitz_state, &flow.ports.ports,
> + 1);
> + break;
> +
> + case VIRTIO_NET_HASH_REPORT_UDPv4:
> + virtio_net_toeplitz(&toeplitz_state,
> + (__be32 *)&flow.addrs.v4addrs,
> + sizeof(flow.addrs.v4addrs) / 4);
> + virtio_net_toeplitz(&toeplitz_state, &flow.ports.ports,
> + 1);
> + break;
> +
> + case VIRTIO_NET_HASH_REPORT_IPv6:
> + virtio_net_toeplitz(&toeplitz_state,
> + (__be32 *)&flow.addrs.v6addrs,
> + sizeof(flow.addrs.v6addrs) / 4);
> + break;
> +
> + case VIRTIO_NET_HASH_REPORT_TCPv6:
> + virtio_net_toeplitz(&toeplitz_state,
> + (__be32 *)&flow.addrs.v6addrs,
> + sizeof(flow.addrs.v6addrs) / 4);
> + virtio_net_toeplitz(&toeplitz_state, &flow.ports.ports,
> + 1);
> + break;
> +
> + case VIRTIO_NET_HASH_REPORT_UDPv6:
> + virtio_net_toeplitz(&toeplitz_state,
> + (__be32 *)&flow.addrs.v6addrs,
> + sizeof(flow.addrs.v6addrs) / 4);
> + virtio_net_toeplitz(&toeplitz_state, &flow.ports.ports,
> + 1);
> + break;
> +
> + default:
> + return false;
> + }
> +
> + hash->value = toeplitz_state.hash;
> + hash->report = report;
> +
> + return true;
> +}
> +
Powered by blists - more mailing lists