diff --git a/drivers/common/cnxk/roc_bphy_cgx.c b/drivers/common/cnxk/roc_bphy_cgx.c index e966494e217..4f43605e103 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 2b9a23f5b1a..18bf3185bb7 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 78fa1eaa6be..bbcf6221563 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 9eb0da9ed45..e30e76b1c02 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 5d2a53be31f..58a29f183fc 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 ebb85bd8690..1a50bdbcc7f 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);