From: Jie Liu <[email protected]>

When the PF link state changes in switchdev mode, refresh the link
status of every VF representor and trigger the RTE_ETH_EVENT_INTR_LSC
callback on each, so applications receive link events on representor
ports. Also log OICR in hexadecimal for better readability.

Cc: [email protected]
Signed-off-by: Jie Liu <[email protected]>
---
 drivers/net/sxe2/sxe2_irq.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sxe2/sxe2_irq.c b/drivers/net/sxe2/sxe2_irq.c
index 3306504761..53d49a4246 100644
--- a/drivers/net/sxe2/sxe2_irq.c
+++ b/drivers/net/sxe2/sxe2_irq.c
@@ -77,14 +77,32 @@ static int32_t sxe2_fc_state_callback(struct rte_eth_dev 
*dev)
 static void sxe2_event_irq_common_handler(struct sxe2_adapter *adapter, 
uint64_t oicr)
 {
        struct rte_eth_dev *dev = 
&rte_eth_devices[adapter->dev_info.dev_data->port_id];
+       struct rte_eth_dev *repr_eth_dev;
+       struct sxe2_adapter *repr_adapter;
+       uint8_t vf_id;
 
        if (oicr & RTE_BIT32(SXE2_COM_EC_LINK_CHG)) {
-               PMD_DEV_LOG_INFO(adapter, DRV, "OICR=%" PRIu64, oicr);
+               PMD_DEV_LOG_INFO(adapter, DRV, "OICR=0x%" PRIx64, oicr);
                (void)sxe2_drv_mac_link_status_get(adapter);
-               if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+               if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
                        rte_eth_dev_callback_process(dev,
                                                     RTE_ETH_EVENT_INTR_LSC,
                                                     NULL);
+               }
+               if (adapter->switchdev_info.is_switchdev) {
+                       for (vf_id = 0; vf_id < adapter->repr_ctxt.nb_repr_vf; 
vf_id++) {
+                               repr_eth_dev = 
adapter->repr_ctxt.vf_rep_eth_dev[vf_id];
+                               if (!repr_eth_dev)
+                                       continue;
+                               repr_adapter = 
SXE2_DEV_PRIVATE_TO_ADAPTER(repr_eth_dev);
+                               
(void)sxe2_drv_mac_link_status_get(repr_adapter);
+                               if (rte_eal_process_type() == RTE_PROC_PRIMARY) 
{
+                                       
rte_eth_dev_callback_process(repr_eth_dev,
+                                                                    
RTE_ETH_EVENT_INTR_LSC,
+                                                                    NULL);
+                               }
+                       }
+               }
        }
        if (oicr & RTE_BIT32(SXE2_COM_SW_MODE_SWITCHDEV)) {
                PMD_DEV_LOG_INFO(adapter, DRV, "event notify switchdev");
-- 
2.52.0

Reply via email to