From patchwork Mon Feb 3 12:48:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13957395 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9C0B2080C8 for ; Mon, 3 Feb 2025 12:48:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738586930; cv=none; b=talYbWAsqbpmzHoNGuWIvKfDmedr2y825CrtAVmjXkN1CIwFYhzhaRTtAw8u0aDsO6Eqpr+bQY1SMncdOFgnEl3ewmvMgwBINppzRpSB1Jn1RVpP8tD3hqEsVlgRcF7uHwUax41EPo9Gm5eA9IJv/Rjry6cv53Udcgnu78m3QwE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738586930; c=relaxed/simple; bh=6m+etHzS50IQZaeVn+Tmw2katLiNzpjz3NmuvDMCnR0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZITXjmzxf1Fkqr6QwktCR4ujZSyMzwg3MALECDHnnBXq9gL2qg3KNACaehyxEahVuyKgdweokF1/QZEdPS3klN1uo++dUFctA77YGVmbeEQIfuo5LWY3GjkND6PlOZv8MIw3yOLpMbGZKlQBhE7uDqQzHMaJzLSOdWoOebm1VAg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XQsYOfDh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XQsYOfDh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D0D1C4CED2; Mon, 3 Feb 2025 12:48:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738586930; bh=6m+etHzS50IQZaeVn+Tmw2katLiNzpjz3NmuvDMCnR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XQsYOfDh5/I75sKivlGe4nJQkA1+0hwxGZ3bqdaAKg3kPle8MIjI1sF19aoE4mLS4 /9z/g4k7bnbWW9fq2muIm9oXQdfBssBngREr3iUbwOXJBKIkEWdCYBkQhmQ5yLUtvw Jmn0utKerJSBjL1IjYsZenRwlB2QnZb+Nqlo0LTfMM4HfL8ugvx3Q+kHKVsvDQ0x23 pwV/6aI7D4FBSxXvQA6gAf6LO686mH1kl56Cis11j2yJe8nC7FEtytDadsCaHmuwMe SIMEUM0JP9QUjsccOk+eab6wor9HyL6syFHEX065DAntoeZgGAE3aJSntj9Hw9gb0d 1rX0dFuMbZckQ== From: Leon Romanovsky To: Jason Gunthorpe Cc: Maher Sanalla , linux-rdma@vger.kernel.org Subject: [PATCH rdma-next v1 1/3] IB/cache: Add log messages for IB device state changes Date: Mon, 3 Feb 2025 14:48:04 +0200 Message-ID: <2d26ccbd669bad99089fa2aebb5cba4014fc4999.1738586601.git.leon@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Maher Sanalla Enhance visibility into IB device state transitions by adding log messages to the kernel log (dmesg). Whenever an IB device changes state, a relevant print will be printed, such as: "mlx5_core 0000:08:00.0 mlx5_0: Port: 1 Link DOWN" "mlx5_core 0000:08:00.0 rdmap8s0f0: Port: 2 Link ACTIVE" Signed-off-by: Maher Sanalla Signed-off-by: Leon Romanovsky --- drivers/infiniband/core/cache.c | 6 ++++++ include/rdma/ib_verbs.h | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index f8413f8a9f26..9979a351577f 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c @@ -1501,6 +1501,12 @@ ib_cache_update(struct ib_device *device, u32 port, bool update_gids, device->port_data[port].cache.pkey = pkey_cache; } device->port_data[port].cache.lmc = tprops->lmc; + + if (device->port_data[port].cache.port_state != IB_PORT_NOP && + device->port_data[port].cache.port_state != tprops->state) + ibdev_info(device, "Port: %d Link %s\n", port, + ib_port_state_to_str(tprops->state)); + device->port_data[port].cache.port_state = tprops->state; device->port_data[port].cache.subnet_prefix = tprops->subnet_prefix; diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 0ad104dae253..b59bf30de430 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -519,6 +519,23 @@ enum ib_port_state { IB_PORT_ACTIVE_DEFER = 5 }; +static inline const char *__attribute_const__ +ib_port_state_to_str(enum ib_port_state state) +{ + const char * const states[] = { + [IB_PORT_NOP] = "NOP", + [IB_PORT_DOWN] = "DOWN", + [IB_PORT_INIT] = "INIT", + [IB_PORT_ARMED] = "ARMED", + [IB_PORT_ACTIVE] = "ACTIVE", + [IB_PORT_ACTIVE_DEFER] = "ACTIVE_DEFER", + }; + + if (state < ARRAY_SIZE(states)) + return states[state]; + return "UNKNOWN"; +} + enum ib_port_phys_state { IB_PORT_PHYS_STATE_SLEEP = 1, IB_PORT_PHYS_STATE_POLLING = 2, From patchwork Mon Feb 3 12:48:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13957393 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62D95207DED for ; Mon, 3 Feb 2025 12:48:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738586925; cv=none; b=QTAf2pUuZgf24ltaQocA4Fw2pBkeLd8h80iGnYcRGuvn8zWK58Sc50A8dUeNzoJvu4f+WyXvqU1fS2F8C6yxNl0vu63BICgv5G6V7cyqgGvJ8xmyCGfp8hEaWtZexcXc/Z8KDDjygXwZDaeoXGG3Kiv0PJpY3SXQ/j+Sv68BEBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738586925; c=relaxed/simple; bh=I/6kTPuGF9r80a0srh6VE4oZIujlyJ5NQyUrGsQKM7I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rmk8Y7tE3VayvvOGRjpvWrQ3kJ8jF1hgT1HA0qKl+F4oDAd9SZFCzXiICMkl8gzleYNC5SEAJacP4jrqQjhnmgIv5Qdi7pNIfnhv3wsiy0FtGShA4nqHDZ0PAxI34wb9QeP1dqUn4veDxIdq82uX/EYgH6vsiduSWNxn6ccpKRQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C0t+tC2+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="C0t+tC2+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 337DFC4CED2; Mon, 3 Feb 2025 12:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738586922; bh=I/6kTPuGF9r80a0srh6VE4oZIujlyJ5NQyUrGsQKM7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C0t+tC2+Qxx7/9U7i+avc8LuyvdLwLzRhqN6yWu8EtsErOimwDygJSWGy4YwV8pai NA4S73j/vTE8PoAZEj5SG+KjbOn6Lb6NGL7XHpFs7oAsuqZyXIF7GynfVg+I/SIWt/ LooezlltqJKbGxscNKKanTlMfOv0nsqEn2FOU8XIdvjeTcauYFb3bW74q3+QtmFzqN DIm0JRpnGC+J27lZRttizxMgUbaR3Wpln9jGne5BjWTpxiBfLV0WzaGYwcRhlAq0rF kkGgURgzE1CGanFbITQhpcMAMu3fELhsD8ya5dqhQeR4gBipq8agrqvXggoXNOSshf i8bPWdvlWfm9w== From: Leon Romanovsky To: Jason Gunthorpe Cc: Maher Sanalla , linux-rdma@vger.kernel.org Subject: [PATCH rdma-next v1 2/3] RDMA/core: Use ib_port_state_to_str() for IB state sysfs Date: Mon, 3 Feb 2025 14:48:05 +0200 Message-ID: <06affabbbf144f990e64b447918af39483c78c3e.1738586601.git.leon@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Maher Sanalla Refactor the IB state sysfs implementation to replace the local array used for converting IB state to string with the ib_port_state_to_str() function. Signed-off-by: Maher Sanalla Signed-off-by: Leon Romanovsky --- drivers/infiniband/core/sysfs.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 9f97bef02149..7491328ca5e6 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -216,24 +216,12 @@ static ssize_t state_show(struct ib_device *ibdev, u32 port_num, struct ib_port_attr attr; ssize_t ret; - static const char *state_name[] = { - [IB_PORT_NOP] = "NOP", - [IB_PORT_DOWN] = "DOWN", - [IB_PORT_INIT] = "INIT", - [IB_PORT_ARMED] = "ARMED", - [IB_PORT_ACTIVE] = "ACTIVE", - [IB_PORT_ACTIVE_DEFER] = "ACTIVE_DEFER" - }; - ret = ib_query_port(ibdev, port_num, &attr); if (ret) return ret; return sysfs_emit(buf, "%d: %s\n", attr.state, - attr.state >= 0 && - attr.state < ARRAY_SIZE(state_name) ? - state_name[attr.state] : - "UNKNOWN"); + ib_port_state_to_str(attr.state)); } static ssize_t lid_show(struct ib_device *ibdev, u32 port_num, From patchwork Mon Feb 3 12:48:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13957394 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0376207E00 for ; Mon, 3 Feb 2025 12:48:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738586927; cv=none; b=XEiz7YKmupLx/+lfKMLCNBMrovugyGSkI608wzpy1KvkRyNQ+7K81BbxBJnuuf24gCbZbUnKz1ssvcuqPbH2SN22AAYgWaUX2p9H/AQOHLNYPc31J2ATD4DDRDNBX9Oflz7LDCxxEYAMl67O6ZvuHlA3lKLA7H9zI2/YUYpxM3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738586927; c=relaxed/simple; bh=dmp/OICvyzWbjsx8YA85YoXBDTLLpHmffMp0AD3Hxz8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dw8iYaqhD3Q1T01U+TXHaYX7arZnd14wkWjufOLRgl0TYCCukn4jAkFFv+txiq1rKaCxxi27smd2Ohmx5fug24BofdoRmUIl0hNuY1Mgs6CARBQkoV4vTqLWrnpiy0KUCqKxA/6cU0LvEtj4IYju1UL0DlBy49iON2a32urM4G8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=COUy2V3z; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="COUy2V3z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5BB5C4CEE4; Mon, 3 Feb 2025 12:48:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738586926; bh=dmp/OICvyzWbjsx8YA85YoXBDTLLpHmffMp0AD3Hxz8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=COUy2V3z6dm4ScxiFFfn0MyhZ0oX/jMXPL7wyA090mHaSBa1DhIrAr6ixqLViOY+x iECsgjvHbEIVYDrWam1pvaEjwKp5diP+LBE5rO6eUHzz30c4rV1+FdQZ5EvbSRIYst cSSF9TZYoPxT4MphGVDPVnNlwgTtL4uP1edgI5hPvX2HRB/lA14A2yBljFrWj69TPG bH0hLufXgWThNLLRRJZg8nfQydSNKIe6eom3JDTkMI94GxyvZzzTRsOe7BMSoRQYbe rj0Sz9KpYNsDjWjMURJea2LGsvy52fR8In8WDwUWsmm8zMeEcOLEVyB3x2RIl+N1nl W0wNOGjeTAlug== From: Leon Romanovsky To: Jason Gunthorpe Cc: Maher Sanalla , Dennis Dalessandro , linux-rdma@vger.kernel.org Subject: [PATCH rdma-next v1 3/3] IB/hfi1: Remove state transition log message and opa_lstate_name() Date: Mon, 3 Feb 2025 14:48:06 +0200 Message-ID: <64e48bef00630e33f4b8c830cb7d9a69aedc34dc.1738586601.git.leon@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Maher Sanalla Remove the state transition log message from the hfi1 driver, as the IB core now logs the same information when handling a cache update event. While at it, replace the hfi1-specific opa_lstate_name() function with the ib_verbs equivalent function, ib_port_state_to_str(), for converting IB port state to a string. Signed-off-by: Maher Sanalla Signed-off-by: Leon Romanovsky --- drivers/infiniband/hw/hfi1/chip.c | 18 ------------------ drivers/infiniband/hw/hfi1/chip.h | 1 - drivers/infiniband/hw/hfi1/driver.c | 2 +- drivers/infiniband/hw/hfi1/mad.c | 4 ++-- 4 files changed, 3 insertions(+), 22 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c index a442eca498b8..368b6be3226f 100644 --- a/drivers/infiniband/hw/hfi1/chip.c +++ b/drivers/infiniband/hw/hfi1/chip.c @@ -12882,22 +12882,6 @@ u32 chip_to_opa_pstate(struct hfi1_devdata *dd, u32 chip_pstate) } } -/* return the OPA port logical state name */ -const char *opa_lstate_name(u32 lstate) -{ - static const char * const port_logical_names[] = { - "PORT_NOP", - "PORT_DOWN", - "PORT_INIT", - "PORT_ARMED", - "PORT_ACTIVE", - "PORT_ACTIVE_DEFER", - }; - if (lstate < ARRAY_SIZE(port_logical_names)) - return port_logical_names[lstate]; - return "unknown"; -} - /* return the OPA port physical state name */ const char *opa_pstate_name(u32 pstate) { @@ -12956,8 +12940,6 @@ static void update_statusp(struct hfi1_pportdata *ppd, u32 state) break; } } - dd_dev_info(ppd->dd, "logical state changed to %s (0x%x)\n", - opa_lstate_name(state), state); } /** diff --git a/drivers/infiniband/hw/hfi1/chip.h b/drivers/infiniband/hw/hfi1/chip.h index 8841db16bde7..6992f6d40255 100644 --- a/drivers/infiniband/hw/hfi1/chip.h +++ b/drivers/infiniband/hw/hfi1/chip.h @@ -771,7 +771,6 @@ int is_bx(struct hfi1_devdata *dd); bool is_urg_masked(struct hfi1_ctxtdata *rcd); u32 read_physical_state(struct hfi1_devdata *dd); u32 chip_to_opa_pstate(struct hfi1_devdata *dd, u32 chip_pstate); -const char *opa_lstate_name(u32 lstate); const char *opa_pstate_name(u32 pstate); u32 driver_pstate(struct hfi1_pportdata *ppd); u32 driver_lstate(struct hfi1_pportdata *ppd); diff --git a/drivers/infiniband/hw/hfi1/driver.c b/drivers/infiniband/hw/hfi1/driver.c index 37a6794885d3..50826e7cdb7e 100644 --- a/drivers/infiniband/hw/hfi1/driver.c +++ b/drivers/infiniband/hw/hfi1/driver.c @@ -968,7 +968,7 @@ static bool __set_armed_to_active(struct hfi1_packet *packet) if (hwstate != IB_PORT_ACTIVE) { dd_dev_info(packet->rcd->dd, "Unexpected link state %s\n", - opa_lstate_name(hwstate)); + ib_port_state_to_str(hwstate)); return false; } diff --git a/drivers/infiniband/hw/hfi1/mad.c b/drivers/infiniband/hw/hfi1/mad.c index a9883295f4af..b39f63ce6dfc 100644 --- a/drivers/infiniband/hw/hfi1/mad.c +++ b/drivers/infiniband/hw/hfi1/mad.c @@ -1160,8 +1160,8 @@ static int port_states_transition_allowed(struct hfi1_pportdata *ppd, if (ret == HFI_TRANSITION_DISALLOWED || ret == HFI_TRANSITION_UNDEFINED) { pr_warn("invalid logical state transition %s -> %s\n", - opa_lstate_name(logical_old), - opa_lstate_name(logical_new)); + ib_port_state_to_str(logical_old), + ib_port_state_to_str(logical_new)); return ret; }