All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: "illusion.wang" <illusion.wang@nebula-matrix.com>
Cc: dimon.zhao@nebula-matrix.com, alvin.wang@nebula-matrix.com,
	sam.chen@nebula-matrix.com, netdev@vger.kernel.org,
	andrew+netdev@lunn.ch, corbet@lwn.net, horms@kernel.org,
	linux-doc@vger.kernel.org, pabeni@redhat.com,
	vadim.fedorenko@linux.dev, lukas.bulwahn@redhat.com,
	edumazet@google.com, enelsonmoore@gmail.com,
	skhan@linuxfoundation.org, hkallweit1@gmail.com,
	linux-kernel@vger.kernel.org (open list)
Subject: Re: [PATCH v22 net-next 04/12] net/nebula-matrix: add channel layer
Date: Thu, 30 Jul 2026 18:27:18 -0700	[thread overview]
Message-ID: <20260730182718.7b85ca1f@kernel.org> (raw)
In-Reply-To: <20260723040110.91410-5-illusion.wang@nebula-matrix.com>

On Thu, 23 Jul 2026 12:00:56 +0800 illusion.wang wrote:
> +#define FNV_PRIME_32 0x01000193
> +#define FNV_OFFSET_32 0x811C9DC5
> +static u32 nbl_common_calc_hash_key(void *key, u32 key_size, u32 bucket_size)
> +{
> +	u32 hash = FNV_OFFSET_32;
> +	u8 *p = (u8 *)key;
> +	u32 i;
> +
> +	if (bucket_size == 0 || bucket_size == NBL_HASH_TBL_LIST_BUCKET_SIZE)
> +		return 0;
> +
> +	for (i = 0; i < key_size; i++) {
> +		hash ^= p[i];
> +		hash *= FNV_PRIME_32;
> +	}
> +	/* Use bitmask if bucket_size is a power of 2 */
> +	if ((bucket_size & (bucket_size - 1)) == 0)
> +		return hash & (bucket_size - 1);
> +	else
> +		return hash % bucket_size;
> +}

Why are you implementing your own hashing function and your own hash
table? Can't one of existing implementations in the kernel be used?

> +int nbl_common_alloc_hash_node(struct nbl_hash_tbl_mgt *tbl_mgt, void *key,
> +			       void *data, void **out_data)
> +{
> +	struct nbl_hash_entry_node *hash_node;
> +	u16 data_size;
> +	u32 hash_val;
> +	u16 key_size;
> +
> +	hash_node = devm_kzalloc(tbl_mgt->tbl_key.dev, sizeof(*hash_node),
> +				 GFP_KERNEL);

Don't use devm_ for inherently dynamically allocated memory...

> +static void nbl_common_detach_hash_node(struct nbl_hash_tbl_mgt *tbl_mgt,
> +					struct nbl_hash_entry_node *hash_node)
> +{
> +	hlist_del(&hash_node->node);
> +	devm_kfree(tbl_mgt->tbl_key.dev, hash_node->key);
> +	devm_kfree(tbl_mgt->tbl_key.dev, hash_node->data);
> +	devm_kfree(tbl_mgt->tbl_key.dev, hash_node);

... if you ever have to explicitly free something, chances are you
shouldn't be using devm_ in the first place.

> index 7ae331959ca1..d6b7bfff3cc6 100644
> --- a/drivers/net/ethernet/nebula-matrix/nbl/nbl_core.h
> +++ b/drivers/net/ethernet/nebula-matrix/nbl/nbl_core.h
> @@ -11,23 +11,34 @@
>  #include "nbl_include/nbl_def_common.h"
>  
>  struct nbl_hw_mgt;
> +struct nbl_hw_ops_tbl;
> +struct nbl_channel_ops_tbl;
> +struct nbl_channel_mgt;
>  

Lots of unnecessary forward declarations.
Using type as a member implicitly forward declares.

>  struct nbl_adapter *nbl_core_init(struct pci_dev *pdev,
>  				  struct nbl_init_param *param);
>  void nbl_core_remove(struct nbl_adapter *adapter);
> +
>  #endif

This chunk should be squashed into an earlier patch

> +#define NBL_CHAN_SEND(chan_send, dst_id, mesg_type, argument, arg_length,\
> +		      response, resp_length, need_ack)			\
> +do {									\
> +	typeof(chan_send)	*__chan_send = &(chan_send);		\
> +	__chan_send->dstid	= (dst_id);				\
> +	__chan_send->msg_type	= (mesg_type);				\
> +	__chan_send->arg	= (argument);				\
> +	__chan_send->arg_len	= (arg_length);				\
> +	__chan_send->resp	= (response);				\
> +	__chan_send->resp_len	= (resp_length);			\
> +	__chan_send->ack	= (need_ack);				\
> +} while (0)
> +
> +#define NBL_CHAN_ACK(chan_ack, dst_id, mesg_type, msg_id, err_code, ack_data, \
> +		     data_length)					\
> +do {									\
> +	typeof(chan_ack)	*__chan_ack = &(chan_ack);		\
> +	__chan_ack->dstid	= (dst_id);				\
> +	__chan_ack->msg_type	= (mesg_type);				\
> +	__chan_ack->msgid	= (msg_id);				\
> +	__chan_ack->err		= (err_code);				\
> +	__chan_ack->data	= (ack_data);				\
> +	__chan_ack->data_len	= (data_length);			\
> +} while (0)
> +

Why are these macros and not C code?
You only seem to pass struct nbl_chan_ack_info into NBL_CHAN_ACK()

> +struct nbl_hash_tbl_mgt;

This forward declaration here makes no sense.
Please look at your patches before you post them.

>  struct nbl_common_info {
>  	struct pci_dev *pdev;
>  	struct device *dev;
> @@ -29,4 +31,19 @@ struct nbl_common_info {
>  	u8 has_net;
>  };
>  
> +struct nbl_hash_tbl_key {


  reply	other threads:[~2026-07-31  1:27 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23  4:00 [PATCH v22 net-next 00/12] nbl driver for Nebulamatrix NICs illusion.wang
2026-07-23  4:00 ` [PATCH v22 net-next 01/12] net/nebula-matrix: add minimum nbl build framework illusion.wang
2026-07-31  1:10   ` Jakub Kicinski
2026-07-23  4:00 ` [PATCH v22 net-next 02/12] net/nebula-matrix: add core driver architecture and HW layer initialization illusion.wang
2026-07-30  9:18   ` 回复:[PATCH " Illusion Wang
2026-07-31  1:13   ` [PATCH " Jakub Kicinski
2026-07-31  1:30   ` Jakub Kicinski
2026-07-23  4:00 ` [PATCH v22 net-next 03/12] net/nebula-matrix: add channel wire opcode enum definitions illusion.wang
2026-07-23  4:00 ` [PATCH v22 net-next 04/12] net/nebula-matrix: add channel layer illusion.wang
2026-07-31  1:27   ` Jakub Kicinski [this message]
2026-07-31  1:30   ` Jakub Kicinski
2026-07-23  4:00 ` [PATCH v22 net-next 05/12] net/nebula-matrix: add common resource implementation illusion.wang
2026-07-31  1:30   ` Jakub Kicinski
2026-07-23  4:00 ` [PATCH v22 net-next 06/12] net/nebula-matrix: add intr " illusion.wang
2026-07-31  1:30   ` Jakub Kicinski
2026-07-23  4:00 ` [PATCH v22 net-next 07/12] net/nebula-matrix: add chip-wide hardware init/deinit implementation illusion.wang
2026-07-31  1:30   ` Jakub Kicinski
2026-07-23  4:01 ` [PATCH v22 net-next 08/12] net/nebula-matrix: dispatch: add control-level routing core infrastructure illusion.wang
2026-07-23  4:01 ` [PATCH v22 net-next 09/12] net/nebula-matrix: dispatch: add cross-version channel message framework illusion.wang
2026-07-31  1:30   ` Jakub Kicinski
2026-07-23  4:01 ` [PATCH v22 net-next 10/12] net/nebula-matrix: dispatch: add mutual exclusion lock for shared hardware resource ops illusion.wang
2026-07-31  1:30   ` Jakub Kicinski
2026-07-23  4:01 ` [PATCH v22 net-next 11/12] net/nebula-matrix: add common/ctrl dev init/remove operation illusion.wang
2026-07-31  1:30   ` Jakub Kicinski
2026-07-23  4:01 ` [PATCH v22 net-next 12/12] net/nebula-matrix: add common dev start/stop operation illusion.wang
2026-07-31  1:30   ` Jakub Kicinski
2026-07-31  1:29 ` [PATCH v22 net-next 00/12] nbl driver for Nebulamatrix NICs Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260730182718.7b85ca1f@kernel.org \
    --to=kuba@kernel.org \
    --cc=alvin.wang@nebula-matrix.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=corbet@lwn.net \
    --cc=dimon.zhao@nebula-matrix.com \
    --cc=edumazet@google.com \
    --cc=enelsonmoore@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=illusion.wang@nebula-matrix.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas.bulwahn@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sam.chen@nebula-matrix.com \
    --cc=skhan@linuxfoundation.org \
    --cc=vadim.fedorenko@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.