DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] common/cnxk: send link event to VF
@ 2021-07-30 16:08 Harman Kalra
  2021-07-30 16:08 ` [dpdk-dev] [PATCH 2/2] net/cnxk: callback for getting link status Harman Kalra
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Harman Kalra @ 2021-07-30 16:08 UTC (permalink / raw)
  To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
	Ray Kinsella
  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/cnxk/roc_dev.c      | 33 ++++++++++++++++++++++++++++++
 drivers/common/cnxk/roc_dev_priv.h |  5 +++++
 drivers/common/cnxk/roc_nix.h      |  7 +++++++
 drivers/common/cnxk/roc_nix_mac.c  | 23 +++++++++++++++++++++
 drivers/common/cnxk/version.map    |  2 ++
 5 files changed, 70 insertions(+)

diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c
index c14f189f9b..4e204373dc 100644
--- a/drivers/common/cnxk/roc_dev.c
+++ b/drivers/common/cnxk/roc_dev.c
@@ -163,6 +163,39 @@ af_pf_wait_msg(struct 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;
+			size_t sz;
+
+			/* Get the link status */
+			memset(&linfo, 0, sizeof(struct cgx_link_user_info));
+			if (dev->ops && dev->ops->link_status_get)
+				dev->ops->link_status_get(dev->roc_nix, &linfo);
+
+			sz = PLT_ALIGN(mbox_id2size(MBOX_MSG_CGX_LINK_EVENT),
+				       MBOX_MSG_ALIGN);
+			/* Prepare the message to be sent */
+			vf_msg = mbox_alloc_msg(&dev->mbox_vfpf_up, vf, sz);
+			if (vf_msg) {
+				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 */
+				mbox_msg_send(&dev->mbox_vfpf_up, vf);
+			}
+		}
+
 		offset = mbox->rx_start + msg->next_msgoff;
 	}
 	plt_spinlock_unlock(&mdev->mbox_lock);
diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h
index 9488db3c41..302dc0feb0 100644
--- a/drivers/common/cnxk/roc_dev_priv.h
+++ b/drivers/common/cnxk/roc_dev_priv.h
@@ -30,9 +30,14 @@ typedef void (*link_info_t)(void *roc_nix,
 /* PTP info callback */
 typedef int (*ptp_info_t)(void *roc_nix, bool enable);
 
+/* Link status get callback */
+typedef void (*link_status_get_t)(void *roc_nix,
+				  struct cgx_link_user_info *link);
+
 struct dev_ops {
 	link_info_t link_status_update;
 	ptp_info_t ptp_info_update;
+	link_status_get_t link_status_get;
 };
 
 #define dev_is_vf(dev) ((dev)->hwcap & DEV_HWCAP_F_VF)
diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h
index bb69027956..d7ab3c674e 100644
--- a/drivers/common/cnxk/roc_nix.h
+++ b/drivers/common/cnxk/roc_nix.h
@@ -243,6 +243,10 @@ typedef void (*link_status_t)(struct roc_nix *roc_nix,
 /* PTP info update callback */
 typedef int (*ptp_info_update_t)(struct roc_nix *roc_nix, bool enable);
 
+/* Link status get callback */
+typedef void (*link_info_get_t)(struct roc_nix *roc_nix,
+				struct roc_nix_link_info *link);
+
 struct roc_nix {
 	/* Input parameters */
 	struct plt_pci_device *pci_dev;
@@ -487,6 +491,9 @@ int __roc_api roc_nix_mac_max_rx_len_set(struct roc_nix *roc_nix,
 int __roc_api roc_nix_mac_link_cb_register(struct roc_nix *roc_nix,
 					   link_status_t link_update);
 void __roc_api roc_nix_mac_link_cb_unregister(struct roc_nix *roc_nix);
+int __roc_api roc_nix_mac_link_info_get_cb_register(
+	struct roc_nix *roc_nix, link_info_get_t link_info_get);
+void __roc_api roc_nix_mac_link_info_get_cb_unregister(struct roc_nix *roc_nix);
 
 /* Ops */
 int __roc_api roc_nix_switch_hdr_set(struct roc_nix *roc_nix,
diff --git a/drivers/common/cnxk/roc_nix_mac.c b/drivers/common/cnxk/roc_nix_mac.c
index 682d5a7295..36259941c9 100644
--- a/drivers/common/cnxk/roc_nix_mac.c
+++ b/drivers/common/cnxk/roc_nix_mac.c
@@ -296,3 +296,26 @@ roc_nix_mac_link_cb_unregister(struct roc_nix *roc_nix)
 
 	dev->ops->link_status_update = NULL;
 }
+
+int
+roc_nix_mac_link_info_get_cb_register(struct roc_nix *roc_nix,
+				      link_info_get_t link_info_get)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct dev *dev = &nix->dev;
+
+	if (link_info_get == NULL)
+		return NIX_ERR_PARAM;
+
+	dev->ops->link_status_get = (link_info_t)link_info_get;
+	return 0;
+}
+
+void
+roc_nix_mac_link_info_get_cb_unregister(struct roc_nix *roc_nix)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct dev *dev = &nix->dev;
+
+	dev->ops->link_status_get = NULL;
+}
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index e3af48c02e..4cc2c9652c 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -105,6 +105,8 @@ INTERNAL {
 	roc_nix_mac_addr_set;
 	roc_nix_mac_link_cb_register;
 	roc_nix_mac_link_cb_unregister;
+	roc_nix_mac_link_info_get_cb_register;
+	roc_nix_mac_link_info_get_cb_unregister;
 	roc_nix_mac_link_event_start_stop;
 	roc_nix_mac_link_info_get;
 	roc_nix_mac_link_info_set;
-- 
2.18.0


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

* [dpdk-dev] [PATCH 2/2] net/cnxk: callback for getting link status
  2021-07-30 16:08 [dpdk-dev] [PATCH 1/2] common/cnxk: send link event to VF Harman Kalra
@ 2021-07-30 16:08 ` Harman Kalra
  2021-09-07  2:59   ` Jerin Jacob
  2021-09-15  8:32   ` Nithin Kumar Dabilpuram
  2021-09-16 14:31 ` [dpdk-dev] [PATCH 1/2] common/cnxk: send link event to VF Jerin Jacob
  2021-09-27 13:06 ` Kinsella, Ray
  2 siblings, 2 replies; 6+ messages in thread
From: Harman Kalra @ 2021-07-30 16:08 UTC (permalink / raw)
  To: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao
  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/cnxk/cnxk_ethdev.c |  9 +++++++++
 drivers/net/cnxk/cnxk_ethdev.h |  2 ++
 drivers/net/cnxk/cnxk_link.c   | 23 +++++++++++++++++++++++
 3 files changed, 34 insertions(+)

diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
index 0e3652ed51..7152dcd002 100644
--- a/drivers/net/cnxk/cnxk_ethdev.c
+++ b/drivers/net/cnxk/cnxk_ethdev.c
@@ -1314,6 +1314,10 @@ cnxk_eth_dev_init(struct rte_eth_dev *eth_dev)
 	/* Register up msg callbacks */
 	roc_nix_mac_link_cb_register(nix, cnxk_eth_dev_link_status_cb);
 
+	/* Register up msg callbacks */
+	roc_nix_mac_link_info_get_cb_register(nix,
+					      cnxk_eth_dev_link_status_get_cb);
+
 	dev->eth_dev = eth_dev;
 	dev->configured = 0;
 	dev->ptype_disable = 0;
@@ -1415,6 +1419,11 @@ cnxk_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool reset)
 	/* Disable link status events */
 	roc_nix_mac_link_event_start_stop(nix, false);
 
+	/* Unregister the link update op, this is required to stop VFs from
+	 * receiving link status updates on exit path.
+	 */
+	roc_nix_mac_link_cb_unregister(nix);
+
 	/* Free up SQs */
 	for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
 		dev_ops->tx_queue_release(eth_dev->data->tx_queues[i]);
diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h
index 4eead03905..4caf26303f 100644
--- a/drivers/net/cnxk/cnxk_ethdev.h
+++ b/drivers/net/cnxk/cnxk_ethdev.h
@@ -349,6 +349,8 @@ int cnxk_nix_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
 void cnxk_nix_toggle_flag_link_cfg(struct cnxk_eth_dev *dev, bool set);
 void cnxk_eth_dev_link_status_cb(struct roc_nix *nix,
 				 struct roc_nix_link_info *link);
+void cnxk_eth_dev_link_status_get_cb(struct roc_nix *nix,
+				     struct roc_nix_link_info *link);
 int cnxk_nix_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete);
 int cnxk_nix_queue_stats_mapping(struct rte_eth_dev *dev, uint16_t queue_id,
 				 uint8_t stat_idx, uint8_t is_rx);
diff --git a/drivers/net/cnxk/cnxk_link.c b/drivers/net/cnxk/cnxk_link.c
index 3fdbdba495..6a70801675 100644
--- a/drivers/net/cnxk/cnxk_link.c
+++ b/drivers/net/cnxk/cnxk_link.c
@@ -45,6 +45,29 @@ nix_link_status_print(struct rte_eth_dev *eth_dev, struct rte_eth_link *link)
 		plt_info("Port %d: Link Down", (int)(eth_dev->data->port_id));
 }
 
+void
+cnxk_eth_dev_link_status_get_cb(struct roc_nix *nix,
+				struct roc_nix_link_info *link)
+{
+	struct cnxk_eth_dev *dev = (struct cnxk_eth_dev *)nix;
+	struct rte_eth_link eth_link;
+	struct rte_eth_dev *eth_dev;
+
+	if (!link || !nix)
+		return;
+
+	eth_dev = dev->eth_dev;
+	if (!eth_dev)
+		return;
+
+	rte_eth_linkstatus_get(eth_dev, &eth_link);
+
+	link->status = eth_link.link_status;
+	link->speed = eth_link.link_speed;
+	link->autoneg = eth_link.link_autoneg;
+	link->full_duplex = eth_link.link_duplex;
+}
+
 void
 cnxk_eth_dev_link_status_cb(struct roc_nix *nix, struct roc_nix_link_info *link)
 {
-- 
2.18.0


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

* Re: [dpdk-dev] [PATCH 2/2] net/cnxk: callback for getting link status
  2021-07-30 16:08 ` [dpdk-dev] [PATCH 2/2] net/cnxk: callback for getting link status Harman Kalra
@ 2021-09-07  2:59   ` Jerin Jacob
  2021-09-15  8:32   ` Nithin Kumar Dabilpuram
  1 sibling, 0 replies; 6+ messages in thread
From: Jerin Jacob @ 2021-09-07  2:59 UTC (permalink / raw)
  To: Harman Kalra, Ferruh Yigit
  Cc: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao, dpdk-dev

On Fri, Jul 30, 2021 at 9:38 PM 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 applied to dpdk-next-net-mrvl/for-next-net. Thanks.


> ---
>  drivers/net/cnxk/cnxk_ethdev.c |  9 +++++++++
>  drivers/net/cnxk/cnxk_ethdev.h |  2 ++
>  drivers/net/cnxk/cnxk_link.c   | 23 +++++++++++++++++++++++
>  3 files changed, 34 insertions(+)
>
> diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
> index 0e3652ed51..7152dcd002 100644
> --- a/drivers/net/cnxk/cnxk_ethdev.c
> +++ b/drivers/net/cnxk/cnxk_ethdev.c
> @@ -1314,6 +1314,10 @@ cnxk_eth_dev_init(struct rte_eth_dev *eth_dev)
>         /* Register up msg callbacks */
>         roc_nix_mac_link_cb_register(nix, cnxk_eth_dev_link_status_cb);
>
> +       /* Register up msg callbacks */
> +       roc_nix_mac_link_info_get_cb_register(nix,
> +                                             cnxk_eth_dev_link_status_get_cb);
> +
>         dev->eth_dev = eth_dev;
>         dev->configured = 0;
>         dev->ptype_disable = 0;
> @@ -1415,6 +1419,11 @@ cnxk_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool reset)
>         /* Disable link status events */
>         roc_nix_mac_link_event_start_stop(nix, false);
>
> +       /* Unregister the link update op, this is required to stop VFs from
> +        * receiving link status updates on exit path.
> +        */
> +       roc_nix_mac_link_cb_unregister(nix);
> +
>         /* Free up SQs */
>         for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
>                 dev_ops->tx_queue_release(eth_dev->data->tx_queues[i]);
> diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h
> index 4eead03905..4caf26303f 100644
> --- a/drivers/net/cnxk/cnxk_ethdev.h
> +++ b/drivers/net/cnxk/cnxk_ethdev.h
> @@ -349,6 +349,8 @@ int cnxk_nix_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
>  void cnxk_nix_toggle_flag_link_cfg(struct cnxk_eth_dev *dev, bool set);
>  void cnxk_eth_dev_link_status_cb(struct roc_nix *nix,
>                                  struct roc_nix_link_info *link);
> +void cnxk_eth_dev_link_status_get_cb(struct roc_nix *nix,
> +                                    struct roc_nix_link_info *link);
>  int cnxk_nix_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete);
>  int cnxk_nix_queue_stats_mapping(struct rte_eth_dev *dev, uint16_t queue_id,
>                                  uint8_t stat_idx, uint8_t is_rx);
> diff --git a/drivers/net/cnxk/cnxk_link.c b/drivers/net/cnxk/cnxk_link.c
> index 3fdbdba495..6a70801675 100644
> --- a/drivers/net/cnxk/cnxk_link.c
> +++ b/drivers/net/cnxk/cnxk_link.c
> @@ -45,6 +45,29 @@ nix_link_status_print(struct rte_eth_dev *eth_dev, struct rte_eth_link *link)
>                 plt_info("Port %d: Link Down", (int)(eth_dev->data->port_id));
>  }
>
> +void
> +cnxk_eth_dev_link_status_get_cb(struct roc_nix *nix,
> +                               struct roc_nix_link_info *link)
> +{
> +       struct cnxk_eth_dev *dev = (struct cnxk_eth_dev *)nix;
> +       struct rte_eth_link eth_link;
> +       struct rte_eth_dev *eth_dev;
> +
> +       if (!link || !nix)
> +               return;
> +
> +       eth_dev = dev->eth_dev;
> +       if (!eth_dev)
> +               return;
> +
> +       rte_eth_linkstatus_get(eth_dev, &eth_link);
> +
> +       link->status = eth_link.link_status;
> +       link->speed = eth_link.link_speed;
> +       link->autoneg = eth_link.link_autoneg;
> +       link->full_duplex = eth_link.link_duplex;
> +}
> +
>  void
>  cnxk_eth_dev_link_status_cb(struct roc_nix *nix, struct roc_nix_link_info *link)
>  {
> --
> 2.18.0
>

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

* Re: [dpdk-dev] [PATCH 2/2] net/cnxk: callback for getting link status
  2021-07-30 16:08 ` [dpdk-dev] [PATCH 2/2] net/cnxk: callback for getting link status Harman Kalra
  2021-09-07  2:59   ` Jerin Jacob
@ 2021-09-15  8:32   ` Nithin Kumar Dabilpuram
  1 sibling, 0 replies; 6+ messages in thread
From: Nithin Kumar Dabilpuram @ 2021-09-15  8:32 UTC (permalink / raw)
  To: Harman Kalra, Kiran Kumar K, Sunil Kumar Kori, Satha Rao
  Cc: dev, Ferruh Yigit, jerinj, ndabilpuram


Acked-by: Nithin Dabilpuram <ndabilpuram@marvell.com>

On 7/30/21 9:38 PM, Harman Kalra 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>
> ---
>   drivers/net/cnxk/cnxk_ethdev.c |  9 +++++++++
>   drivers/net/cnxk/cnxk_ethdev.h |  2 ++
>   drivers/net/cnxk/cnxk_link.c   | 23 +++++++++++++++++++++++
>   3 files changed, 34 insertions(+)
> 
> diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
> index 0e3652ed51..7152dcd002 100644
> --- a/drivers/net/cnxk/cnxk_ethdev.c
> +++ b/drivers/net/cnxk/cnxk_ethdev.c
> @@ -1314,6 +1314,10 @@ cnxk_eth_dev_init(struct rte_eth_dev *eth_dev)
>   	/* Register up msg callbacks */
>   	roc_nix_mac_link_cb_register(nix, cnxk_eth_dev_link_status_cb);
>   
> +	/* Register up msg callbacks */
> +	roc_nix_mac_link_info_get_cb_register(nix,
> +					      cnxk_eth_dev_link_status_get_cb);
> +
>   	dev->eth_dev = eth_dev;
>   	dev->configured = 0;
>   	dev->ptype_disable = 0;
> @@ -1415,6 +1419,11 @@ cnxk_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool reset)
>   	/* Disable link status events */
>   	roc_nix_mac_link_event_start_stop(nix, false);
>   
> +	/* Unregister the link update op, this is required to stop VFs from
> +	 * receiving link status updates on exit path.
> +	 */
> +	roc_nix_mac_link_cb_unregister(nix);
> +
>   	/* Free up SQs */
>   	for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
>   		dev_ops->tx_queue_release(eth_dev->data->tx_queues[i]);
> diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h
> index 4eead03905..4caf26303f 100644
> --- a/drivers/net/cnxk/cnxk_ethdev.h
> +++ b/drivers/net/cnxk/cnxk_ethdev.h
> @@ -349,6 +349,8 @@ int cnxk_nix_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
>   void cnxk_nix_toggle_flag_link_cfg(struct cnxk_eth_dev *dev, bool set);
>   void cnxk_eth_dev_link_status_cb(struct roc_nix *nix,
>   				 struct roc_nix_link_info *link);
> +void cnxk_eth_dev_link_status_get_cb(struct roc_nix *nix,
> +				     struct roc_nix_link_info *link);
>   int cnxk_nix_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete);
>   int cnxk_nix_queue_stats_mapping(struct rte_eth_dev *dev, uint16_t queue_id,
>   				 uint8_t stat_idx, uint8_t is_rx);
> diff --git a/drivers/net/cnxk/cnxk_link.c b/drivers/net/cnxk/cnxk_link.c
> index 3fdbdba495..6a70801675 100644
> --- a/drivers/net/cnxk/cnxk_link.c
> +++ b/drivers/net/cnxk/cnxk_link.c
> @@ -45,6 +45,29 @@ nix_link_status_print(struct rte_eth_dev *eth_dev, struct rte_eth_link *link)
>   		plt_info("Port %d: Link Down", (int)(eth_dev->data->port_id));
>   }
>   
> +void
> +cnxk_eth_dev_link_status_get_cb(struct roc_nix *nix,
> +				struct roc_nix_link_info *link)
> +{
> +	struct cnxk_eth_dev *dev = (struct cnxk_eth_dev *)nix;
> +	struct rte_eth_link eth_link;
> +	struct rte_eth_dev *eth_dev;
> +
> +	if (!link || !nix)
> +		return;
> +
> +	eth_dev = dev->eth_dev;
> +	if (!eth_dev)
> +		return;
> +
> +	rte_eth_linkstatus_get(eth_dev, &eth_link);
> +
> +	link->status = eth_link.link_status;
> +	link->speed = eth_link.link_speed;
> +	link->autoneg = eth_link.link_autoneg;
> +	link->full_duplex = eth_link.link_duplex;
> +}
> +
>   void
>   cnxk_eth_dev_link_status_cb(struct roc_nix *nix, struct roc_nix_link_info *link)
>   {
> 

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

* Re: [dpdk-dev] [PATCH 1/2] common/cnxk: send link event to VF
  2021-07-30 16:08 [dpdk-dev] [PATCH 1/2] common/cnxk: send link event to VF Harman Kalra
  2021-07-30 16:08 ` [dpdk-dev] [PATCH 2/2] net/cnxk: callback for getting link status Harman Kalra
@ 2021-09-16 14:31 ` Jerin Jacob
  2021-09-27 13:06 ` Kinsella, Ray
  2 siblings, 0 replies; 6+ messages in thread
From: Jerin Jacob @ 2021-09-16 14:31 UTC (permalink / raw)
  To: Harman Kalra
  Cc: Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao,
	Ray Kinsella, dpdk-dev

On Fri, Jul 30, 2021 at 9:38 PM Harman Kalra <hkalra@marvell.com> wrote:
>
> 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>


Series Acked-by: Jerin Jacob <jerinj@marvell.com>


> ---
>  drivers/common/cnxk/roc_dev.c      | 33 ++++++++++++++++++++++++++++++
>  drivers/common/cnxk/roc_dev_priv.h |  5 +++++
>  drivers/common/cnxk/roc_nix.h      |  7 +++++++
>  drivers/common/cnxk/roc_nix_mac.c  | 23 +++++++++++++++++++++
>  drivers/common/cnxk/version.map    |  2 ++
>  5 files changed, 70 insertions(+)
>
> diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c
> index c14f189f9b..4e204373dc 100644
> --- a/drivers/common/cnxk/roc_dev.c
> +++ b/drivers/common/cnxk/roc_dev.c
> @@ -163,6 +163,39 @@ af_pf_wait_msg(struct 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;
> +                       size_t sz;
> +
> +                       /* Get the link status */
> +                       memset(&linfo, 0, sizeof(struct cgx_link_user_info));
> +                       if (dev->ops && dev->ops->link_status_get)
> +                               dev->ops->link_status_get(dev->roc_nix, &linfo);
> +
> +                       sz = PLT_ALIGN(mbox_id2size(MBOX_MSG_CGX_LINK_EVENT),
> +                                      MBOX_MSG_ALIGN);
> +                       /* Prepare the message to be sent */
> +                       vf_msg = mbox_alloc_msg(&dev->mbox_vfpf_up, vf, sz);
> +                       if (vf_msg) {
> +                               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 */
> +                               mbox_msg_send(&dev->mbox_vfpf_up, vf);
> +                       }
> +               }
> +
>                 offset = mbox->rx_start + msg->next_msgoff;
>         }
>         plt_spinlock_unlock(&mdev->mbox_lock);
> diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h
> index 9488db3c41..302dc0feb0 100644
> --- a/drivers/common/cnxk/roc_dev_priv.h
> +++ b/drivers/common/cnxk/roc_dev_priv.h
> @@ -30,9 +30,14 @@ typedef void (*link_info_t)(void *roc_nix,
>  /* PTP info callback */
>  typedef int (*ptp_info_t)(void *roc_nix, bool enable);
>
> +/* Link status get callback */
> +typedef void (*link_status_get_t)(void *roc_nix,
> +                                 struct cgx_link_user_info *link);
> +
>  struct dev_ops {
>         link_info_t link_status_update;
>         ptp_info_t ptp_info_update;
> +       link_status_get_t link_status_get;
>  };
>
>  #define dev_is_vf(dev) ((dev)->hwcap & DEV_HWCAP_F_VF)
> diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h
> index bb69027956..d7ab3c674e 100644
> --- a/drivers/common/cnxk/roc_nix.h
> +++ b/drivers/common/cnxk/roc_nix.h
> @@ -243,6 +243,10 @@ typedef void (*link_status_t)(struct roc_nix *roc_nix,
>  /* PTP info update callback */
>  typedef int (*ptp_info_update_t)(struct roc_nix *roc_nix, bool enable);
>
> +/* Link status get callback */
> +typedef void (*link_info_get_t)(struct roc_nix *roc_nix,
> +                               struct roc_nix_link_info *link);
> +
>  struct roc_nix {
>         /* Input parameters */
>         struct plt_pci_device *pci_dev;
> @@ -487,6 +491,9 @@ int __roc_api roc_nix_mac_max_rx_len_set(struct roc_nix *roc_nix,
>  int __roc_api roc_nix_mac_link_cb_register(struct roc_nix *roc_nix,
>                                            link_status_t link_update);
>  void __roc_api roc_nix_mac_link_cb_unregister(struct roc_nix *roc_nix);
> +int __roc_api roc_nix_mac_link_info_get_cb_register(
> +       struct roc_nix *roc_nix, link_info_get_t link_info_get);
> +void __roc_api roc_nix_mac_link_info_get_cb_unregister(struct roc_nix *roc_nix);
>
>  /* Ops */
>  int __roc_api roc_nix_switch_hdr_set(struct roc_nix *roc_nix,
> diff --git a/drivers/common/cnxk/roc_nix_mac.c b/drivers/common/cnxk/roc_nix_mac.c
> index 682d5a7295..36259941c9 100644
> --- a/drivers/common/cnxk/roc_nix_mac.c
> +++ b/drivers/common/cnxk/roc_nix_mac.c
> @@ -296,3 +296,26 @@ roc_nix_mac_link_cb_unregister(struct roc_nix *roc_nix)
>
>         dev->ops->link_status_update = NULL;
>  }
> +
> +int
> +roc_nix_mac_link_info_get_cb_register(struct roc_nix *roc_nix,
> +                                     link_info_get_t link_info_get)
> +{
> +       struct nix *nix = roc_nix_to_nix_priv(roc_nix);
> +       struct dev *dev = &nix->dev;
> +
> +       if (link_info_get == NULL)
> +               return NIX_ERR_PARAM;
> +
> +       dev->ops->link_status_get = (link_info_t)link_info_get;
> +       return 0;
> +}
> +
> +void
> +roc_nix_mac_link_info_get_cb_unregister(struct roc_nix *roc_nix)
> +{
> +       struct nix *nix = roc_nix_to_nix_priv(roc_nix);
> +       struct dev *dev = &nix->dev;
> +
> +       dev->ops->link_status_get = NULL;
> +}
> diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
> index e3af48c02e..4cc2c9652c 100644
> --- a/drivers/common/cnxk/version.map
> +++ b/drivers/common/cnxk/version.map
> @@ -105,6 +105,8 @@ INTERNAL {
>         roc_nix_mac_addr_set;
>         roc_nix_mac_link_cb_register;
>         roc_nix_mac_link_cb_unregister;
> +       roc_nix_mac_link_info_get_cb_register;
> +       roc_nix_mac_link_info_get_cb_unregister;
>         roc_nix_mac_link_event_start_stop;
>         roc_nix_mac_link_info_get;
>         roc_nix_mac_link_info_set;
> --
> 2.18.0
>

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

* Re: [dpdk-dev] [PATCH 1/2] common/cnxk: send link event to VF
  2021-07-30 16:08 [dpdk-dev] [PATCH 1/2] common/cnxk: send link event to VF Harman Kalra
  2021-07-30 16:08 ` [dpdk-dev] [PATCH 2/2] net/cnxk: callback for getting link status Harman Kalra
  2021-09-16 14:31 ` [dpdk-dev] [PATCH 1/2] common/cnxk: send link event to VF Jerin Jacob
@ 2021-09-27 13:06 ` Kinsella, Ray
  2 siblings, 0 replies; 6+ messages in thread
From: Kinsella, Ray @ 2021-09-27 13:06 UTC (permalink / raw)
  To: Harman Kalra, Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori,
	Satha Rao
  Cc: dev



On 30/07/2021 17:08, Harman Kalra wrote:
> 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/cnxk/roc_dev.c      | 33 ++++++++++++++++++++++++++++++
>  drivers/common/cnxk/roc_dev_priv.h |  5 +++++
>  drivers/common/cnxk/roc_nix.h      |  7 +++++++
>  drivers/common/cnxk/roc_nix_mac.c  | 23 +++++++++++++++++++++
>  drivers/common/cnxk/version.map    |  2 ++
>  5 files changed, 70 insertions(+)
> 
Acked-by: Ray Kinsella <mdr@ashroe.eu>

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

end of thread, other threads:[~2021-09-27 13:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-30 16:08 [dpdk-dev] [PATCH 1/2] common/cnxk: send link event to VF Harman Kalra
2021-07-30 16:08 ` [dpdk-dev] [PATCH 2/2] net/cnxk: callback for getting link status Harman Kalra
2021-09-07  2:59   ` Jerin Jacob
2021-09-15  8:32   ` Nithin Kumar Dabilpuram
2021-09-16 14:31 ` [dpdk-dev] [PATCH 1/2] common/cnxk: send link event to VF Jerin Jacob
2021-09-27 13:06 ` Kinsella, Ray

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).