Setting up a callback which gets invoked every time a representee
comes up or goes down. Later this callback gets handled by network
conterpart.

Signed-off-by: Harman Kalra <hka...@marvell.com>
---
 drivers/common/cnxk/roc_dev.c      | 24 ++++++++++++++++++++++++
 drivers/common/cnxk/roc_dev_priv.h |  3 +++
 drivers/common/cnxk/roc_eswitch.c  | 23 +++++++++++++++++++++++
 drivers/common/cnxk/roc_eswitch.h  |  6 ++++++
 drivers/common/cnxk/roc_mbox.c     |  2 ++
 drivers/common/cnxk/roc_mbox.h     | 10 +++++++++-
 drivers/common/cnxk/version.map    |  2 ++
 7 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c
index e7e89bf3d6..b12732de34 100644
--- a/drivers/common/cnxk/roc_dev.c
+++ b/drivers/common/cnxk/roc_dev.c
@@ -538,6 +538,29 @@ pf_vf_mbox_send_up_msg(struct dev *dev, void *rec_msg)
        }
 }
 
+static int
+mbox_up_handler_esw_repte_notify(struct dev *dev, struct esw_repte_req *req, 
struct msg_rsp *rsp)
+{
+       int rc = 0;
+
+       plt_base_dbg("pf:%d/vf:%d msg id 0x%x (%s) from: pf:%d/vf:%d", 
dev_get_pf(dev->pf_func),
+                    dev_get_vf(dev->pf_func), req->hdr.id, 
mbox_id2name(req->hdr.id),
+                    dev_get_pf(req->hdr.pcifunc), 
dev_get_vf(req->hdr.pcifunc));
+
+       plt_base_dbg("repte pcifunc %x, enable %d", req->repte_pcifunc, 
req->enable);
+
+       if (dev->ops && dev->ops->repte_notify) {
+               rc = dev->ops->repte_notify(dev->roc_nix, req->repte_pcifunc,
+                                           req->enable);
+               if (rc < 0)
+                       plt_err("Failed to sent new representee %x notification 
to %s",
+                               req->repte_pcifunc, (req->enable == true) ? 
"enable" : "disable");
+       }
+
+       rsp->hdr.rc = rc;
+       return rc;
+}
+
 static int
 mbox_up_handler_mcs_intr_notify(struct dev *dev, struct mcs_intr_info *info, 
struct msg_rsp *rsp)
 {
@@ -712,6 +735,7 @@ mbox_process_msgs_up(struct dev *dev, struct mbox_msghdr 
*req)
        }
                MBOX_UP_CGX_MESSAGES
                MBOX_UP_MCS_MESSAGES
+               MBOX_UP_ESW_MESSAGES
 #undef M
        }
 
diff --git a/drivers/common/cnxk/roc_dev_priv.h 
b/drivers/common/cnxk/roc_dev_priv.h
index 5b2c5096f8..dd694b8572 100644
--- a/drivers/common/cnxk/roc_dev_priv.h
+++ b/drivers/common/cnxk/roc_dev_priv.h
@@ -36,12 +36,15 @@ typedef void (*q_err_cb_t)(void *roc_nix, void *data);
 /* Link status get callback */
 typedef void (*link_status_get_t)(void *roc_nix,
                                  struct cgx_link_user_info *link);
+/* Representee notification callback */
+typedef int (*repte_notify_t)(void *roc_nix, uint16_t pf_func, bool enable);
 
 struct dev_ops {
        link_info_t link_status_update;
        ptp_info_t ptp_info_update;
        link_status_get_t link_status_get;
        q_err_cb_t q_err_cb;
+       repte_notify_t repte_notify;
 };
 
 #define dev_is_vf(dev) ((dev)->hwcap & DEV_HWCAP_F_VF)
diff --git a/drivers/common/cnxk/roc_eswitch.c 
b/drivers/common/cnxk/roc_eswitch.c
index 7f2a8e6c06..31bdba3985 100644
--- a/drivers/common/cnxk/roc_eswitch.c
+++ b/drivers/common/cnxk/roc_eswitch.c
@@ -298,3 +298,26 @@ roc_eswitch_nix_vlan_tpid_set(struct roc_nix *roc_nix, 
uint32_t type, uint16_t t
 
        return rc;
 }
+
+int
+roc_eswitch_nix_process_repte_notify_cb_register(struct roc_nix *roc_nix,
+                                                process_repte_notify_t 
proc_repte_nt)
+{
+       struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+       struct dev *dev = &nix->dev;
+
+       if (proc_repte_nt == NULL)
+               return NIX_ERR_PARAM;
+
+       dev->ops->repte_notify = (repte_notify_t)proc_repte_nt;
+       return 0;
+}
+
+void
+roc_eswitch_nix_process_repte_notify_cb_unregister(struct roc_nix *roc_nix)
+{
+       struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+       struct dev *dev = &nix->dev;
+
+       dev->ops->repte_notify = NULL;
+}
diff --git a/drivers/common/cnxk/roc_eswitch.h 
b/drivers/common/cnxk/roc_eswitch.h
index 0dd23ff76a..8837e19b22 100644
--- a/drivers/common/cnxk/roc_eswitch.h
+++ b/drivers/common/cnxk/roc_eswitch.h
@@ -8,6 +8,9 @@
 #define ROC_ESWITCH_VLAN_TPID 0x8100
 #define ROC_ESWITCH_LBK_CHAN  63
 
+/* Process representee notification callback */
+typedef int (*process_repte_notify_t)(void *roc_nix, uint16_t pf_func, bool 
enable);
+
 /* NPC */
 int __roc_api roc_eswitch_npc_mcam_rx_rule(struct roc_npc *roc_npc, struct 
roc_npc_flow *flow,
                                           uint16_t pcifunc, uint16_t vlan_tci,
@@ -22,4 +25,7 @@ int __roc_api roc_eswitch_npc_rss_action_configure(struct 
roc_npc *roc_npc,
 /* NIX */
 int __roc_api roc_eswitch_nix_vlan_tpid_set(struct roc_nix *nix, uint32_t 
type, uint16_t tpid,
                                            bool is_vf);
+int __roc_api roc_eswitch_nix_process_repte_notify_cb_register(struct roc_nix 
*roc_nix,
+                                                   process_repte_notify_t 
proc_repte_nt);
+void __roc_api roc_eswitch_nix_process_repte_notify_cb_unregister(struct 
roc_nix *roc_nix);
 #endif /* __ROC_ESWITCH_H__ */
diff --git a/drivers/common/cnxk/roc_mbox.c b/drivers/common/cnxk/roc_mbox.c
index 7b734fcd24..cb486b2505 100644
--- a/drivers/common/cnxk/roc_mbox.c
+++ b/drivers/common/cnxk/roc_mbox.c
@@ -499,6 +499,7 @@ mbox_id2name(uint16_t id)
                return #_name;
                MBOX_MESSAGES
                MBOX_UP_CGX_MESSAGES
+               MBOX_UP_ESW_MESSAGES
 #undef M
        }
 }
@@ -514,6 +515,7 @@ mbox_id2size(uint16_t id)
                return sizeof(struct _req_type);
                MBOX_MESSAGES
                MBOX_UP_CGX_MESSAGES
+               MBOX_UP_ESW_MESSAGES
 #undef M
        }
 }
diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h
index 4c846f0757..2bedf1fb81 100644
--- a/drivers/common/cnxk/roc_mbox.h
+++ b/drivers/common/cnxk/roc_mbox.h
@@ -355,9 +355,11 @@ struct mbox_msghdr {
 
 #define MBOX_UP_MCS_MESSAGES M(MCS_INTR_NOTIFY, 0xE00, mcs_intr_notify, 
mcs_intr_info, msg_rsp)
 
+#define MBOX_UP_ESW_MESSAGES M(ESW_REPTE_NOTIFY, 0xF00, esw_repte_notify, 
esw_repte_req, msg_rsp)
+
 enum {
 #define M(_name, _id, _1, _2, _3) MBOX_MSG_##_name = _id,
-       MBOX_MESSAGES MBOX_UP_CGX_MESSAGES MBOX_UP_MCS_MESSAGES
+       MBOX_MESSAGES MBOX_UP_CGX_MESSAGES MBOX_UP_MCS_MESSAGES 
MBOX_UP_ESW_MESSAGES
 #undef M
 };
 
@@ -2778,4 +2780,10 @@ struct nix_spi_to_sa_delete_req {
        uint16_t __io hash_index;
        uint8_t __io way;
 };
+
+struct esw_repte_req {
+       struct mbox_msghdr hdr;
+       uint16_t __io repte_pcifunc;
+       bool __io enable;
+};
 #endif /* __ROC_MBOX_H__ */
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 78c421677d..e170a6a63a 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -91,6 +91,8 @@ INTERNAL {
        roc_dpi_disable;
        roc_dpi_enable;
        roc_error_msg_get;
+       roc_eswitch_nix_process_repte_notify_cb_register;
+       roc_eswitch_nix_process_repte_notify_cb_unregister;
        roc_eswitch_nix_vlan_tpid_set;
        roc_eswitch_npc_mcam_delete_rule;
        roc_eswitch_npc_mcam_rx_rule;
-- 
2.18.0

Reply via email to