common/cnxk: set BPHY link state
authorTomasz Duszynski <tduszynski@marvell.com>
Mon, 21 Jun 2021 15:04:24 +0000 (17:04 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 5 Jul 2021 21:07:01 +0000 (23:07 +0200)
Add support for setting link up or down.

Signed-off-by: Tomasz Duszynski <tduszynski@marvell.com>
Signed-off-by: Jakub Palider <jpalider@marvell.com>
Reviewed-by: Jerin Jacob <jerinj@marvell.com>
drivers/common/cnxk/roc_bphy_cgx.c
drivers/common/cnxk/roc_bphy_cgx.h
drivers/common/cnxk/roc_bphy_cgx_priv.h
drivers/common/cnxk/version.map

index 09d988b..978dbda 100644 (file)
@@ -253,6 +253,24 @@ roc_bphy_cgx_ptp_rx_ena_dis(struct roc_bphy_cgx *roc_cgx, unsigned int lmac,
        return roc_bphy_cgx_intf_req(roc_cgx, lmac, scr1, &scr0);
 }
 
+int
+roc_bphy_cgx_set_link_state(struct roc_bphy_cgx *roc_cgx, unsigned int lmac,
+                           bool state)
+{
+       uint64_t scr1, scr0;
+
+       if (!roc_cgx)
+               return -EINVAL;
+
+       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);
+
+       return roc_bphy_cgx_intf_req(roc_cgx, lmac, scr1, &scr0);
+}
+
 int
 roc_bphy_cgx_get_linkinfo(struct roc_bphy_cgx *roc_cgx, unsigned int lmac,
                          struct roc_bphy_cgx_link_info *info)
index b9a6e0b..ab62392 100644 (file)
@@ -95,6 +95,8 @@ struct roc_bphy_cgx_link_info {
 __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);
 
+__roc_api int roc_bphy_cgx_set_link_state(struct roc_bphy_cgx *roc_cgx,
+                                         unsigned int lmac, bool 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);
index ee75784..71a277f 100644 (file)
@@ -61,6 +61,8 @@ enum eth_mode {
 /* REQUEST ID types. Input to firmware */
 enum eth_cmd_id {
        ETH_CMD_GET_LINK_STS = 4,
+       ETH_CMD_LINK_BRING_UP = 5,
+       ETH_CMD_LINK_BRING_DOWN = 6,
        ETH_CMD_INTERNAL_LBK = 7,
        ETH_CMD_MODE_CHANGE = 11, /* hot plug support */
        ETH_CMD_INTF_SHUTDOWN = 12,
index 15a6d3a..7766f52 100644 (file)
@@ -17,6 +17,7 @@ INTERNAL {
        roc_bphy_cgx_ptp_rx_disable;
        roc_bphy_cgx_ptp_rx_enable;
        roc_bphy_cgx_set_link_mode;
+       roc_bphy_cgx_set_link_state;
        roc_clk_freq_get;
        roc_error_msg_get;
        roc_idev_lmt_base_addr_get;