DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] common/octeontx2: send link event to VF
@ 2021-06-22 20:05 Harman Kalra
  2021-06-22 20:05 ` [dpdk-dev] [PATCH 2/2] net/octeontx2: callback for getting link status Harman Kalra
  0 siblings, 1 reply; 3+ messages in thread
From: Harman Kalra @ 2021-06-22 20:05 UTC (permalink / raw)
  To: Jerin Jacob, Nithin Dabilpuram; +Cc: dev, Harman Kalra

Currently link event is only sent to the PF by AF as soon as it comes
up, or in case of any physical change in link. PF will broadcast
these link events to all its VFs as soon as it receives it.
But no event is sent when a new VF comes up, hence it will not have
the link status.
Adding support for sending link status to the VF once it comes up
successfully.

Signed-off-by: Harman Kalra <hkalra@marvell.com>
---
 drivers/common/octeontx2/otx2_dev.c | 26 ++++++++++++++++++++++++++
 drivers/common/octeontx2/otx2_dev.h | 10 +++++++---
 2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/drivers/common/octeontx2/otx2_dev.c b/drivers/common/octeontx2/otx2_dev.c
index 6a84df2344..1485e2b357 100644
--- a/drivers/common/octeontx2/otx2_dev.c
+++ b/drivers/common/octeontx2/otx2_dev.c
@@ -163,6 +163,32 @@ af_pf_wait_msg(struct otx2_dev *dev, uint16_t vf, int num_msg)
 		rsp->rc = msg->rc;
 		rsp->pcifunc = msg->pcifunc;
 
+		/* Whenever a PF comes up, AF sends the link status to it but
+		 * when VF comes up no such event is sent to respective VF.
+		 * Using MBOX_MSG_NIX_LF_START_RX response from AF for the
+		 * purpose and send the link status of PF to VF.
+		 */
+		if (msg->id == MBOX_MSG_NIX_LF_START_RX) {
+			/* Send link status to VF */
+			struct cgx_link_user_info linfo;
+			struct mbox_msghdr *vf_msg;
+
+			/* Get the link status */
+			if (dev->ops && dev->ops->link_status_get)
+				dev->ops->link_status_get(dev, &linfo);
+
+			/* Prepare the message to be sent */
+			vf_msg = otx2_mbox_alloc_msg(&dev->mbox_vfpf_up, vf,
+						     size);
+			otx2_mbox_req_init(MBOX_MSG_CGX_LINK_EVENT, vf_msg);
+			memcpy((uint8_t *)vf_msg + sizeof(struct mbox_msghdr),
+			       &linfo, sizeof(struct cgx_link_user_info));
+
+			vf_msg->rc = msg->rc;
+			vf_msg->pcifunc = msg->pcifunc;
+			/* Send to VF */
+			otx2_mbox_msg_send(&dev->mbox_vfpf_up, vf);
+		}
 		offset = mbox->rx_start + msg->next_msgoff;
 	}
 	rte_spinlock_unlock(&mdev->mbox_lock);
diff --git a/drivers/common/octeontx2/otx2_dev.h b/drivers/common/octeontx2/otx2_dev.h
index cd4fe517db..be0faacc6a 100644
--- a/drivers/common/octeontx2/otx2_dev.h
+++ b/drivers/common/octeontx2/otx2_dev.h
@@ -57,15 +57,19 @@
 
 struct otx2_dev;
 
-/* Link status callback */
-typedef void (*otx2_link_status_t)(struct otx2_dev *dev,
+/* Link status update callback */
+typedef void (*otx2_link_status_update_t)(struct otx2_dev *dev,
 				   struct cgx_link_user_info *link);
 /* PTP info callback */
 typedef int (*otx2_ptp_info_t)(struct otx2_dev *dev, bool ptp_en);
+/* Link status get callback */
+typedef void (*otx2_link_status_get_t)(struct otx2_dev *dev,
+				   struct cgx_link_user_info *link);
 
 struct otx2_dev_ops {
-	otx2_link_status_t link_status_update;
+	otx2_link_status_update_t link_status_update;
 	otx2_ptp_info_t ptp_info_update;
+	otx2_link_status_get_t link_status_get;
 };
 
 #define OTX2_DEV					\
-- 
2.18.0


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

* [dpdk-dev] [PATCH 2/2] net/octeontx2: callback for getting link status
  2021-06-22 20:05 [dpdk-dev] [PATCH 1/2] common/octeontx2: send link event to VF Harman Kalra
@ 2021-06-22 20:05 ` Harman Kalra
  2021-06-29 14:12   ` Jerin Jacob
  0 siblings, 1 reply; 3+ messages in thread
From: Harman Kalra @ 2021-06-22 20:05 UTC (permalink / raw)
  To: Jerin Jacob, Nithin Dabilpuram, Kiran Kumar K; +Cc: dev, Harman Kalra

Adding a new callback for reading the link status. PF can read it's
link status and can forward the same to VF once it comes up.

Signed-off-by: Harman Kalra <hkalra@marvell.com>
---
 drivers/net/octeontx2/otx2_ethdev.c |  8 +++++++-
 drivers/net/octeontx2/otx2_ethdev.h |  2 ++
 drivers/net/octeontx2/otx2_link.c   | 23 +++++++++++++++++++++++
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c
index 0834de0cb1..471fa34da1 100644
--- a/drivers/net/octeontx2/otx2_ethdev.c
+++ b/drivers/net/octeontx2/otx2_ethdev.c
@@ -42,7 +42,8 @@ nix_get_tx_offload_capa(struct otx2_eth_dev *dev)
 
 static const struct otx2_dev_ops otx2_dev_ops = {
 	.link_status_update = otx2_eth_dev_link_status_update,
-	.ptp_info_update = otx2_eth_dev_ptp_info_update
+	.ptp_info_update = otx2_eth_dev_ptp_info_update,
+	.link_status_get = otx2_eth_dev_link_status_get
 };
 
 static int
@@ -2625,6 +2626,11 @@ otx2_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool mbox_close)
 
 	nix_cgx_stop_link_event(dev);
 
+	/* Unregister the dev ops, this is required to stop VFs from
+	 * receiving link status updates on exit path.
+	 */
+	dev->ops = NULL;
+
 	/* Free up SQs */
 	for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
 		otx2_nix_tx_queue_release(eth_dev->data->tx_queues[i]);
diff --git a/drivers/net/octeontx2/otx2_ethdev.h b/drivers/net/octeontx2/otx2_ethdev.h
index ac50da7b18..08f9a2a7bc 100644
--- a/drivers/net/octeontx2/otx2_ethdev.h
+++ b/drivers/net/octeontx2/otx2_ethdev.h
@@ -453,6 +453,8 @@ void otx2_nix_toggle_flag_link_cfg(struct otx2_eth_dev *dev, bool set);
 int otx2_nix_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete);
 void otx2_eth_dev_link_status_update(struct otx2_dev *dev,
 				     struct cgx_link_user_info *link);
+void otx2_eth_dev_link_status_get(struct otx2_dev *dev,
+				  struct cgx_link_user_info *link);
 int otx2_nix_dev_set_link_up(struct rte_eth_dev *eth_dev);
 int otx2_nix_dev_set_link_down(struct rte_eth_dev *eth_dev);
 int otx2_apply_link_speed(struct rte_eth_dev *eth_dev);
diff --git a/drivers/net/octeontx2/otx2_link.c b/drivers/net/octeontx2/otx2_link.c
index a79b997376..5378e5c3b9 100644
--- a/drivers/net/octeontx2/otx2_link.c
+++ b/drivers/net/octeontx2/otx2_link.c
@@ -47,6 +47,29 @@ nix_link_status_print(struct rte_eth_dev *eth_dev, struct rte_eth_link *link)
 		otx2_info("Port %d: Link Down", (int)(eth_dev->data->port_id));
 }
 
+void
+otx2_eth_dev_link_status_get(struct otx2_dev *dev,
+			     struct cgx_link_user_info *link)
+{
+	struct otx2_eth_dev *otx2_dev = (struct otx2_eth_dev *)dev;
+	struct rte_eth_link eth_link;
+	struct rte_eth_dev *eth_dev;
+
+	if (!link || !dev)
+		return;
+
+	eth_dev = otx2_dev->eth_dev;
+	if (!eth_dev)
+		return;
+
+	rte_eth_linkstatus_get(eth_dev, &eth_link);
+
+	link->link_up = eth_link.link_status;
+	link->speed = eth_link.link_speed;
+	link->an = eth_link.link_autoneg;
+	link->full_duplex = eth_link.link_duplex;
+}
+
 void
 otx2_eth_dev_link_status_update(struct otx2_dev *dev,
 				struct cgx_link_user_info *link)
-- 
2.18.0


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

* Re: [dpdk-dev] [PATCH 2/2] net/octeontx2: callback for getting link status
  2021-06-22 20:05 ` [dpdk-dev] [PATCH 2/2] net/octeontx2: callback for getting link status Harman Kalra
@ 2021-06-29 14:12   ` Jerin Jacob
  0 siblings, 0 replies; 3+ messages in thread
From: Jerin Jacob @ 2021-06-29 14:12 UTC (permalink / raw)
  To: Harman Kalra; +Cc: Jerin Jacob, Nithin Dabilpuram, Kiran Kumar K, dpdk-dev

On Wed, Jun 23, 2021 at 1:36 AM Harman Kalra <hkalra@marvell.com> wrote:
>
> Adding a new callback for reading the link status. PF can read it's
> link status and can forward the same to VF once it comes up.
>
> Signed-off-by: Harman Kalra <hkalra@marvell.com>


Series Acked-by: Jerin Jacob <jerinj@marvell.com>
Series applied to dpdk-next-net-mrvl/for-dpdk-main. Thanks.

> ---
>  drivers/net/octeontx2/otx2_ethdev.c |  8 +++++++-
>  drivers/net/octeontx2/otx2_ethdev.h |  2 ++
>  drivers/net/octeontx2/otx2_link.c   | 23 +++++++++++++++++++++++
>  3 files changed, 32 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c
> index 0834de0cb1..471fa34da1 100644
> --- a/drivers/net/octeontx2/otx2_ethdev.c
> +++ b/drivers/net/octeontx2/otx2_ethdev.c
> @@ -42,7 +42,8 @@ nix_get_tx_offload_capa(struct otx2_eth_dev *dev)
>
>  static const struct otx2_dev_ops otx2_dev_ops = {
>         .link_status_update = otx2_eth_dev_link_status_update,
> -       .ptp_info_update = otx2_eth_dev_ptp_info_update
> +       .ptp_info_update = otx2_eth_dev_ptp_info_update,
> +       .link_status_get = otx2_eth_dev_link_status_get
>  };
>
>  static int
> @@ -2625,6 +2626,11 @@ otx2_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool mbox_close)
>
>         nix_cgx_stop_link_event(dev);
>
> +       /* Unregister the dev ops, this is required to stop VFs from
> +        * receiving link status updates on exit path.
> +        */
> +       dev->ops = NULL;
> +
>         /* Free up SQs */
>         for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
>                 otx2_nix_tx_queue_release(eth_dev->data->tx_queues[i]);
> diff --git a/drivers/net/octeontx2/otx2_ethdev.h b/drivers/net/octeontx2/otx2_ethdev.h
> index ac50da7b18..08f9a2a7bc 100644
> --- a/drivers/net/octeontx2/otx2_ethdev.h
> +++ b/drivers/net/octeontx2/otx2_ethdev.h
> @@ -453,6 +453,8 @@ void otx2_nix_toggle_flag_link_cfg(struct otx2_eth_dev *dev, bool set);
>  int otx2_nix_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete);
>  void otx2_eth_dev_link_status_update(struct otx2_dev *dev,
>                                      struct cgx_link_user_info *link);
> +void otx2_eth_dev_link_status_get(struct otx2_dev *dev,
> +                                 struct cgx_link_user_info *link);
>  int otx2_nix_dev_set_link_up(struct rte_eth_dev *eth_dev);
>  int otx2_nix_dev_set_link_down(struct rte_eth_dev *eth_dev);
>  int otx2_apply_link_speed(struct rte_eth_dev *eth_dev);
> diff --git a/drivers/net/octeontx2/otx2_link.c b/drivers/net/octeontx2/otx2_link.c
> index a79b997376..5378e5c3b9 100644
> --- a/drivers/net/octeontx2/otx2_link.c
> +++ b/drivers/net/octeontx2/otx2_link.c
> @@ -47,6 +47,29 @@ nix_link_status_print(struct rte_eth_dev *eth_dev, struct rte_eth_link *link)
>                 otx2_info("Port %d: Link Down", (int)(eth_dev->data->port_id));
>  }
>
> +void
> +otx2_eth_dev_link_status_get(struct otx2_dev *dev,
> +                            struct cgx_link_user_info *link)
> +{
> +       struct otx2_eth_dev *otx2_dev = (struct otx2_eth_dev *)dev;
> +       struct rte_eth_link eth_link;
> +       struct rte_eth_dev *eth_dev;
> +
> +       if (!link || !dev)
> +               return;
> +
> +       eth_dev = otx2_dev->eth_dev;
> +       if (!eth_dev)
> +               return;
> +
> +       rte_eth_linkstatus_get(eth_dev, &eth_link);
> +
> +       link->link_up = eth_link.link_status;
> +       link->speed = eth_link.link_speed;
> +       link->an = eth_link.link_autoneg;
> +       link->full_duplex = eth_link.link_duplex;
> +}
> +
>  void
>  otx2_eth_dev_link_status_update(struct otx2_dev *dev,
>                                 struct cgx_link_user_info *link)
> --
> 2.18.0
>

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

end of thread, other threads:[~2021-06-29 14:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-22 20:05 [dpdk-dev] [PATCH 1/2] common/octeontx2: send link event to VF Harman Kalra
2021-06-22 20:05 ` [dpdk-dev] [PATCH 2/2] net/octeontx2: callback for getting link status Harman Kalra
2021-06-29 14:12   ` 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).