DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] raw/cnxk_bphy: extend link state capabilities
@ 2024-01-16 13:01 Tomasz Duszynski
  2024-01-22 13:28 ` Jerin Jacob
  0 siblings, 1 reply; 2+ messages in thread
From: Tomasz Duszynski @ 2024-01-16 13:01 UTC (permalink / raw)
  To: dev; +Cc: jerinj, Tomasz Duszynski

Recent version of firmware extended capabilities of setting link state
by adding two extra parameters i.e. timeout and flag disabling auto
enable of rx/tx during linkup.

This change adds supports for both.

Signed-off-by: Tomasz Duszynski <tduszynski@marvell.com>
---
 drivers/common/cnxk/roc_bphy_cgx.c         | 11 ++++++++---
 drivers/common/cnxk/roc_bphy_cgx.h         |  8 +++++++-
 drivers/common/cnxk/roc_bphy_cgx_priv.h    |  4 ++++
 drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c      |  7 +++++--
 drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c |  9 +++++++--
 drivers/raw/cnxk_bphy/rte_pmd_bphy.h       | 14 ++++++++------
 6 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/drivers/common/cnxk/roc_bphy_cgx.c b/drivers/common/cnxk/roc_bphy_cgx.c
index e966494e21..4f43605e10 100644
--- a/drivers/common/cnxk/roc_bphy_cgx.c
+++ b/drivers/common/cnxk/roc_bphy_cgx.c
@@ -311,7 +311,7 @@ roc_bphy_cgx_stop_rxtx(struct roc_bphy_cgx *roc_cgx, unsigned int lmac)

 int
 roc_bphy_cgx_set_link_state(struct roc_bphy_cgx *roc_cgx, unsigned int lmac,
-			    bool state)
+			    struct roc_bphy_cgx_link_state *state)
 {
 	uint64_t scr1, scr0;

@@ -321,8 +321,13 @@ roc_bphy_cgx_set_link_state(struct roc_bphy_cgx *roc_cgx, unsigned int lmac,
 	if (!roc_bphy_cgx_lmac_exists(roc_cgx, lmac))
 		return -ENODEV;

-	scr1 = state ? FIELD_PREP(SCR1_ETH_CMD_ID, ETH_CMD_LINK_BRING_UP) :
-		       FIELD_PREP(SCR1_ETH_CMD_ID, ETH_CMD_LINK_BRING_DOWN);
+	if (!state)
+		return -EINVAL;
+
+	scr1 = (state->state ? FIELD_PREP(SCR1_ETH_CMD_ID, ETH_CMD_LINK_BRING_UP) :
+			       FIELD_PREP(SCR1_ETH_CMD_ID, ETH_CMD_LINK_BRING_DOWN)) |
+	       FIELD_PREP(SCR1_CGX_LINK_BRINGUP_ARGS_TIMEOUT, state->timeout) |
+	       FIELD_PREP(SCR1_CGX_LINK_BRINGUP_ARGS_RX_TX_DIS, state->rx_tx_dis);

 	return roc_bphy_cgx_intf_req(roc_cgx, lmac, scr1, &scr0);
 }
diff --git a/drivers/common/cnxk/roc_bphy_cgx.h b/drivers/common/cnxk/roc_bphy_cgx.h
index 2b9a23f5b1..18bf3185bb 100644
--- a/drivers/common/cnxk/roc_bphy_cgx.h
+++ b/drivers/common/cnxk/roc_bphy_cgx.h
@@ -144,6 +144,12 @@ struct roc_bphy_cgx_cpri_mode_misc {
 	int flags;
 };

+struct roc_bphy_cgx_link_state {
+	bool state;
+	int timeout;
+	bool rx_tx_dis;
+};
+
 __roc_api int roc_bphy_cgx_dev_init(struct roc_bphy_cgx *roc_cgx);
 __roc_api int roc_bphy_cgx_dev_fini(struct roc_bphy_cgx *roc_cgx);

@@ -152,7 +158,7 @@ __roc_api int roc_bphy_cgx_start_rxtx(struct roc_bphy_cgx *roc_cgx,
 __roc_api int roc_bphy_cgx_stop_rxtx(struct roc_bphy_cgx *roc_cgx,
 				     unsigned int lmac);
 __roc_api int roc_bphy_cgx_set_link_state(struct roc_bphy_cgx *roc_cgx,
-					  unsigned int lmac, bool state);
+					  unsigned int lmac, struct roc_bphy_cgx_link_state *state);
 __roc_api int roc_bphy_cgx_get_linkinfo(struct roc_bphy_cgx *roc_cgx,
 					unsigned int lmac,
 					struct roc_bphy_cgx_link_info *info);
diff --git a/drivers/common/cnxk/roc_bphy_cgx_priv.h b/drivers/common/cnxk/roc_bphy_cgx_priv.h
index 78fa1eaa6b..bbcf622156 100644
--- a/drivers/common/cnxk/roc_bphy_cgx_priv.h
+++ b/drivers/common/cnxk/roc_bphy_cgx_priv.h
@@ -102,6 +102,10 @@ enum eth_cmd_own {
 #define SCR1_CPRI_MODE_MISC_ARGS_LANE_IDX  GENMASK_ULL(15, 12)
 #define SCR1_CPRI_MODE_MISC_ARGS_FLAGS     GENMASK_ULL(17, 16)

+/* struct cgx_link_bringup_args */
+#define SCR1_CGX_LINK_BRINGUP_ARGS_TIMEOUT   GENMASK_ULL(21, 8)
+#define SCR1_CGX_LINK_BRINGUP_ARGS_RX_TX_DIS BIT_ULL(22)
+
 #define SCR1_OWN_STATUS GENMASK_ULL(1, 0)

 #endif /* _ROC_BPHY_CGX_PRIV_H_ */
diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
index 9eb0da9ed4..e30e76b1c0 100644
--- a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
+++ b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx.c
@@ -67,6 +67,7 @@ cnxk_bphy_cgx_process_buf(struct cnxk_bphy_cgx *cgx, unsigned int queue,
 	struct roc_bphy_cgx_cpri_mode_change rcpri_mode;
 	struct roc_bphy_cgx_cpri_mode_misc rmode_misc;
 	struct roc_bphy_cgx_cpri_mode_tx_ctrl rtx_ctrl;
+	struct roc_bphy_cgx_link_state rlink_state;
 	struct roc_bphy_cgx_link_info rlink_info;
 	struct roc_bphy_cgx_link_mode rlink_mode;
 	enum roc_bphy_cgx_eth_link_fec *fec;
@@ -135,8 +136,10 @@ cnxk_bphy_cgx_process_buf(struct cnxk_bphy_cgx *cgx, unsigned int queue,
 		break;
 	case CNXK_BPHY_CGX_MSG_TYPE_SET_LINK_STATE:
 		link_state = msg->data;
-		ret = roc_bphy_cgx_set_link_state(cgx->rcgx, lmac,
-						  link_state->state);
+		rlink_state.state = link_state->state;
+		rlink_state.timeout = link_state->timeout;
+		rlink_state.rx_tx_dis = link_state->rx_tx_dis;
+		ret = roc_bphy_cgx_set_link_state(cgx->rcgx, lmac, &rlink_state);
 		break;
 	case CNXK_BPHY_CGX_MSG_TYPE_START_RXTX:
 		ret = roc_bphy_cgx_start_rxtx(cgx->rcgx, lmac);
diff --git a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c
index 5d2a53be31..58a29f183f 100644
--- a/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c
+++ b/drivers/raw/cnxk_bphy/cnxk_bphy_cgx_test.c
@@ -36,6 +36,7 @@ cnxk_bphy_cgx_link_cond(uint16_t dev_id, unsigned int queue, int cond)
 int
 cnxk_bphy_cgx_dev_selftest(uint16_t dev_id)
 {
+	struct cnxk_bphy_cgx_msg_set_link_state link_state = { };
 	unsigned int queues, i;
 	int ret;

@@ -75,7 +76,8 @@ cnxk_bphy_cgx_dev_selftest(uint16_t dev_id)
 			break;
 		}

-		ret = rte_pmd_bphy_cgx_set_link_state(dev_id, i, false);
+		link_state.state = false;
+		ret = rte_pmd_bphy_cgx_set_link_state(dev_id, i, &link_state);
 		if (ret) {
 			BPHY_CGX_LOG(ERR, "Failed to set link down");
 			break;
@@ -85,7 +87,10 @@ cnxk_bphy_cgx_dev_selftest(uint16_t dev_id)
 		if (ret != 0)
 			BPHY_CGX_LOG(ERR, "Timed out waiting for a link down");

-		ret = rte_pmd_bphy_cgx_set_link_state(dev_id, i, true);
+		link_state.state = true;
+		link_state.timeout = 1500;
+		link_state.rx_tx_dis = true;
+		ret = rte_pmd_bphy_cgx_set_link_state(dev_id, i, &link_state);
 		if (ret) {
 			BPHY_CGX_LOG(ERR, "Failed to set link up");
 			break;
diff --git a/drivers/raw/cnxk_bphy/rte_pmd_bphy.h b/drivers/raw/cnxk_bphy/rte_pmd_bphy.h
index ebb85bd869..1a50bdbcc7 100644
--- a/drivers/raw/cnxk_bphy/rte_pmd_bphy.h
+++ b/drivers/raw/cnxk_bphy/rte_pmd_bphy.h
@@ -231,6 +231,10 @@ struct cnxk_bphy_cgx_msg_link_info {
 struct cnxk_bphy_cgx_msg_set_link_state {
 	/** Defines link state result */
 	bool state; /* up or down */
+	/** Timeout in ms */
+	int timeout;
+	/** Set if Rx/Tx should not be enabled during link up config */
+	bool rx_tx_dis;
 };

 struct cnxk_bphy_cgx_msg_cpri_mode_change {
@@ -676,21 +680,19 @@ rte_pmd_bphy_cgx_set_link_mode(uint16_t dev_id, uint16_t lmac,
  *   The identifier of the device
  * @param lmac
  *   LMAC number for operation
- * @param up
+ * @param state
  *   Link state to set
  *
  * @return
  *   Returns 0 on success, negative error code otherwise
  */
 static __rte_always_inline int
-rte_pmd_bphy_cgx_set_link_state(uint16_t dev_id, uint16_t lmac, bool up)
+rte_pmd_bphy_cgx_set_link_state(uint16_t dev_id, uint16_t lmac,
+				struct cnxk_bphy_cgx_msg_set_link_state *state)
 {
-	struct cnxk_bphy_cgx_msg_set_link_state state = {
-		.state = up,
-	};
 	struct cnxk_bphy_cgx_msg msg = {
 		.type = CNXK_BPHY_CGX_MSG_TYPE_SET_LINK_STATE,
-		.data = &state,
+		.data = state,
 	};

 	return __rte_pmd_bphy_enq_deq(dev_id, lmac, &msg, NULL, 0);
--
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] raw/cnxk_bphy: extend link state capabilities
  2024-01-16 13:01 [PATCH] raw/cnxk_bphy: extend link state capabilities Tomasz Duszynski
@ 2024-01-22 13:28 ` Jerin Jacob
  0 siblings, 0 replies; 2+ messages in thread
From: Jerin Jacob @ 2024-01-22 13:28 UTC (permalink / raw)
  To: Tomasz Duszynski; +Cc: dev, jerinj

On Tue, Jan 16, 2024 at 8:59 PM Tomasz Duszynski <tduszynski@marvell.com> wrote:
>
> Recent version of firmware extended capabilities of setting link state
> by adding two extra parameters i.e. timeout and flag disabling auto
> enable of rx/tx during linkup.
>
> This change adds supports for both.
>
> Signed-off-by: Tomasz Duszynski <tduszynski@marvell.com>

Updated the git commit as follows and applied to
dpdk-next-net-mrvl/for-main. Thanks

    raw/cnxk_bphy: extend link state capabilities

    Update the driver to leverage the firmware capabilities of setting
    link state by adding two extra parameters i.e. timeout and flag
    disabling auto enable of rx/tx during linkup.

    Signed-off-by: Tomasz Duszynski <tduszynski@marvell.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-22 13:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 13:01 [PATCH] raw/cnxk_bphy: extend link state capabilities Tomasz Duszynski
2024-01-22 13:28 ` Jerin Jacob

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).