net/sfc: implement port representor link update
authorIgor Romanov <igor.romanov@oktetlabs.ru>
Mon, 11 Oct 2021 14:48:39 +0000 (17:48 +0300)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 12 Oct 2021 16:44:11 +0000 (18:44 +0200)
Implement the callback by reporting link down if the representor
is not started, otherwise report link up with undefined link speed.

Link speed is undefined since representors can pass traffic to each
other even if the PF link is down.

Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
Reviewed-by: Ivan Malov <ivan.malov@oktetlabs.ru>
drivers/net/sfc/sfc_repr.c

index 2961892..83ac733 100644 (file)
@@ -463,6 +463,24 @@ sfc_repr_dev_infos_get(struct rte_eth_dev *dev,
        return 0;
 }
 
+static int
+sfc_repr_dev_link_update(struct rte_eth_dev *dev,
+                        __rte_unused int wait_to_complete)
+{
+       struct sfc_repr *sr = sfc_repr_by_eth_dev(dev);
+       struct rte_eth_link link;
+
+       if (sr->state != SFC_ETHDEV_STARTED) {
+               sfc_port_link_mode_to_info(EFX_LINK_UNKNOWN, &link);
+       } else {
+               memset(&link, 0, sizeof(link));
+               link.link_status = ETH_LINK_UP;
+               link.link_speed = ETH_SPEED_NUM_UNKNOWN;
+       }
+
+       return rte_eth_linkstatus_set(dev, &link);
+}
+
 static int
 sfc_repr_ring_create(uint16_t pf_port_id, uint16_t repr_id,
                     const char *type_name, uint16_t qid, uint16_t nb_desc,
@@ -760,6 +778,7 @@ static const struct eth_dev_ops sfc_repr_dev_ops = {
        .dev_stop                       = sfc_repr_dev_stop,
        .dev_close                      = sfc_repr_dev_close,
        .dev_infos_get                  = sfc_repr_dev_infos_get,
+       .link_update                    = sfc_repr_dev_link_update,
        .rx_queue_setup                 = sfc_repr_rx_queue_setup,
        .rx_queue_release               = sfc_repr_rx_queue_release,
        .tx_queue_setup                 = sfc_repr_tx_queue_setup,