Thread (20 messages) 20 messages, 2 authors, 2026-03-13

Re: [PATCH v7 net-next 06/11] net/nebula-matrix: add common resource implementation

From: Paolo Abeni <pabeni@redhat.com>
Date: 2026-03-12 11:59:59
Also in: linux-doc, lkml

On 3/10/26 1:09 PM, illusion.wang wrote:
+int nbl_res_vsi_id_to_pf_id(struct nbl_resource_mgt *res_mgt, u16 vsi_id)
+{
+	struct nbl_vsi_info *vsi_info = res_mgt->resource_info->vsi_info;
+	struct nbl_common_info *common = res_mgt->common;
+	bool vsi_find = false;
+	u32 pf_id = U32_MAX;
+	int i, j;
+
+	for (i = 0; i < vsi_info->num; i++) {
+		for (j = 0; j < NBL_VSI_SERV_MAX_TYPE; j++)
+			if (vsi_id >= vsi_info->serv_info[i][j].base_id &&
+			    (vsi_id < vsi_info->serv_info[i][j].base_id +
+					      vsi_info->serv_info[i][j].num)) {
+				vsi_find = true;
+				break;
+			}
+
+		if (vsi_find)
+			break;
+	}
+
+	if (vsi_find) {
+		if (j >= NBL_VSI_SERV_PF_DATA_TYPE &&
+		    j <= NBL_VSI_SERV_PF_DATA_TYPE)
+			pf_id = i + common->mgt_pf;
AI review says:

This isn't a bug, but the condition checks if j is >=
NBL_VSI_SERV_PF_DATA_TYPE && j <= NBL_VSI_SERV_PF_DATA_TYPE, which is
unnecessarily complex. This is equivalent to checking if j ==
NBL_VSI_SERV_PF_DATA_TYPE.

The confusing comment was removed in v5, but the redundant comparison
logic remains. Could this be simplified to:

    if (j == NBL_VSI_SERV_PF_DATA_TYPE)

This was previously noted by Jakub Kicinski in v4 review.

Reference:
https://lore.kernel.org/netdev/20260207022455.4017894-1-kuba@kernel.org/ (local)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help