Add support for starting or stopping specific lmac. Start enables rx/tx
traffic while stop does the opposite.

Signed-off-by: Tomasz Duszynski <tduszyn...@marvell.com>
Signed-off-by: Jakub Palider <jpali...@marvell.com>
---
 drivers/common/cnxk/roc_bphy_cgx.c | 42 ++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_bphy_cgx.h |  4 +++
 drivers/common/cnxk/version.map    |  2 ++
 3 files changed, 48 insertions(+)

diff --git a/drivers/common/cnxk/roc_bphy_cgx.c 
b/drivers/common/cnxk/roc_bphy_cgx.c
index d1701eaa7..886f8d65d 100644
--- a/drivers/common/cnxk/roc_bphy_cgx.c
+++ b/drivers/common/cnxk/roc_bphy_cgx.c
@@ -7,6 +7,9 @@
 #include "roc_api.h"
 #include "roc_priv.h"
 
+#define CGX_CMRX_CONFIG                       0x00
+#define CGX_CMRX_CONFIG_DATA_PKT_RX_EN BIT_ULL(54)
+#define CGX_CMRX_CONFIG_DATA_PKT_TX_EN BIT_ULL(53)
 #define CGX_CMRX_INT                  0x40
 #define CGX_CMRX_INT_OVERFLW          BIT_ULL(1)
 /*
@@ -213,6 +216,33 @@ roc_bphy_cgx_lmac_exists(struct roc_bphy_cgx *roc_cgx, 
unsigned int lmac)
               (roc_cgx->lmac_bmap & BIT_ULL(lmac));
 }
 
+static int
+roc_bphy_cgx_start_stop_rxtx(struct roc_bphy_cgx *roc_cgx, unsigned int lmac,
+                            bool start)
+{
+       uint64_t val;
+
+       if (!roc_cgx)
+               return -EINVAL;
+
+       if (!roc_bphy_cgx_lmac_exists(roc_cgx, lmac))
+               return -EINVAL;
+
+       pthread_mutex_lock(&roc_cgx->lock);
+       val = roc_bphy_cgx_read(roc_cgx, lmac, CGX_CMRX_CONFIG);
+       val &= ~(CGX_CMRX_CONFIG_DATA_PKT_RX_EN |
+                CGX_CMRX_CONFIG_DATA_PKT_TX_EN);
+
+       if (start)
+               val |= FIELD_PREP(CGX_CMRX_CONFIG_DATA_PKT_RX_EN, 1) |
+                      FIELD_PREP(CGX_CMRX_CONFIG_DATA_PKT_TX_EN, 1);
+
+       roc_bphy_cgx_write(roc_cgx, lmac, CGX_CMRX_CONFIG, val);
+       pthread_mutex_unlock(&roc_cgx->lock);
+
+       return 0;
+}
+
 static int
 roc_bphy_cgx_intlbk_ena_dis(struct roc_bphy_cgx *roc_cgx, unsigned int lmac,
                            bool enable)
@@ -252,6 +282,18 @@ 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_start_rxtx(struct roc_bphy_cgx *roc_cgx, unsigned int lmac)
+{
+       return roc_bphy_cgx_start_stop_rxtx(roc_cgx, lmac, true);
+}
+
+int
+roc_bphy_cgx_stop_rxtx(struct roc_bphy_cgx *roc_cgx, unsigned int lmac)
+{
+       return roc_bphy_cgx_start_stop_rxtx(roc_cgx, lmac, false);
+}
+
 int
 roc_bphy_cgx_set_link_state(struct roc_bphy_cgx *roc_cgx, unsigned int lmac,
                            bool state)
diff --git a/drivers/common/cnxk/roc_bphy_cgx.h 
b/drivers/common/cnxk/roc_bphy_cgx.h
index 74f7465e7..1f49de8fd 100644
--- a/drivers/common/cnxk/roc_bphy_cgx.h
+++ b/drivers/common/cnxk/roc_bphy_cgx.h
@@ -95,6 +95,10 @@ 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_start_rxtx(struct roc_bphy_cgx *roc_cgx,
+                                     unsigned int lmac);
+__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);
 __roc_api int roc_bphy_cgx_get_linkinfo(struct roc_bphy_cgx *roc_cgx,
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 7766f52e0..0ad805dba 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -18,6 +18,8 @@ INTERNAL {
        roc_bphy_cgx_ptp_rx_enable;
        roc_bphy_cgx_set_link_mode;
        roc_bphy_cgx_set_link_state;
+       roc_bphy_cgx_start_rxtx;
+       roc_bphy_cgx_stop_rxtx;
        roc_clk_freq_get;
        roc_error_msg_get;
        roc_idev_lmt_base_addr_get;
-- 
2.25.1

Reply via email to