diff mbox series

[2/2] net/cnxk: callback for getting link status

Message ID 20210730160829.13597-2-hkalra@marvell.com (mailing list archive)
State Accepted
Delegated to: Jerin Jacob
Headers show
Series [1/2] common/cnxk: send link event to VF | expand

Checks

Context Check Description
ci/iol-abi-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot success github build: passed
ci/checkpatch success coding style OK

Commit Message

Harman Kalra July 30, 2021, 4:08 p.m. UTC
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(+)

Comments

Jerin Jacob Sept. 7, 2021, 2:59 a.m. UTC | #1
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
>
Nithin Kumar Dabilpuram Sept. 15, 2021, 8:32 a.m. UTC | #2
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)
>   {
>
diff mbox series

Patch

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