> -----Original Message-----
> From: Xing, Beilei <beilei.x...@intel.com>
> Sent: Friday, September 8, 2023 7:17 PM
> To: Wu, Jingjing <jingjing...@intel.com>
> Cc: dev@dpdk.org; Liu, Mingxia <mingxia....@intel.com>; Xing, Beilei
> <beilei.x...@intel.com>
> Subject: [PATCH v4 10/10] net/cpfl: support link update for representor
> 
> From: Beilei Xing <beilei.x...@intel.com>
> 
> Add link update ops for representor.
> 
> Signed-off-by: Jingjing Wu <jingjing...@intel.com>
> Signed-off-by: Beilei Xing <beilei.x...@intel.com>
> ---
>  drivers/net/cpfl/cpfl_ethdev.h      |  1 +
>  drivers/net/cpfl/cpfl_representor.c | 21 +++++++++++++++++++++
>  2 files changed, 22 insertions(+)
> 
> diff --git a/drivers/net/cpfl/cpfl_ethdev.h b/drivers/net/cpfl/cpfl_ethdev.h
> index 4937d2c6e3..0dd9d4e7f9 100644
> --- a/drivers/net/cpfl/cpfl_ethdev.h
> +++ b/drivers/net/cpfl/cpfl_ethdev.h
> @@ -162,6 +162,7 @@ struct cpfl_repr {
>       struct cpfl_repr_id repr_id;
>       struct rte_ether_addr mac_addr;
>       struct cpfl_vport_info *vport_info;
> +     bool func_up; /* If the represented function is up */
>  };
> 
>  struct cpfl_adapter_ext {
> diff --git a/drivers/net/cpfl/cpfl_representor.c
> b/drivers/net/cpfl/cpfl_representor.c
> index 0cd92b1351..3c0fa957de 100644
> --- a/drivers/net/cpfl/cpfl_representor.c
> +++ b/drivers/net/cpfl/cpfl_representor.c
> @@ -308,6 +308,23 @@ cpfl_repr_tx_queue_setup(__rte_unused struct
> rte_eth_dev *dev,
>       return 0;
>  }
> 
> +static int
> +cpfl_repr_link_update(struct rte_eth_dev *ethdev,
> +                   __rte_unused int wait_to_complete)
> +{
> +     struct cpfl_repr *repr = CPFL_DEV_TO_REPR(ethdev);
> +     struct rte_eth_link *dev_link = &ethdev->data->dev_link;
> +
> +     if (!(ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)) {
> +             PMD_INIT_LOG(ERR, "This ethdev is not representor.");
> +             return -EINVAL;
> +     }
> +     dev_link->link_status = repr->func_up ?
> +             RTE_ETH_LINK_UP : RTE_ETH_LINK_DOWN;
> +
> +     return 0;
> +}
> +
>  static const struct eth_dev_ops cpfl_repr_dev_ops = {
>       .dev_start              = cpfl_repr_dev_start,
>       .dev_stop               = cpfl_repr_dev_stop,
> @@ -317,6 +334,8 @@ static const struct eth_dev_ops cpfl_repr_dev_ops = {
> 
>       .rx_queue_setup         = cpfl_repr_rx_queue_setup,
>       .tx_queue_setup         = cpfl_repr_tx_queue_setup,
> +
> +     .link_update            = cpfl_repr_link_update,
>  };
> 
>  static int
> @@ -331,6 +350,8 @@ cpfl_repr_init(struct rte_eth_dev *eth_dev, void
> *init_param)
>       repr->itf.type = CPFL_ITF_TYPE_REPRESENTOR;
>       repr->itf.adapter = adapter;
>       repr->itf.data = eth_dev->data;
> +     if (repr->vport_info->vport_info.vport_status ==
> CPCHNL2_VPORT_STATUS_ENABLED)
> +             repr->func_up = true;
> 
Now event process? Think about the vsi status changes?

>       eth_dev->dev_ops = &cpfl_repr_dev_ops;
> 
> --
> 2.34.1

Reply via email to