bnx2x: Enable PTP only on the PF that initializes the port
authorSudarsana Reddy Kalluru <sudarsana.kalluru@cavium.com>
Wed, 12 Dec 2018 16:57:02 +0000 (08:57 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 13 Dec 2018 00:25:14 +0000 (16:25 -0800)
There will be only one PHC clock per port. PTP should be enabled only on
one PF per port. The change enables PTP functionality on the PF that
initializes the port. The change is useful in multi-function modes e.g.,
NPAR where a port can have more than one PF.

Signed-off-by: Sudarsana Reddy Kalluru <Sudarsana.Kalluru@cavium.com>
Signed-off-by: Ariel Elior <ariel.elior@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c

index 0de487a..7ea9066 100644 (file)
@@ -2520,6 +2520,7 @@ void bnx2x_update_mfw_dump(struct bnx2x *bp);
 void bnx2x_init_ptp(struct bnx2x *bp);
 int bnx2x_configure_ptp_filters(struct bnx2x *bp);
 void bnx2x_set_rx_ts(struct bnx2x *bp, struct sk_buff *skb);
+void bnx2x_register_phc(struct bnx2x *bp);
 
 #define BNX2X_MAX_PHC_DRIFT 31000000
 #define BNX2X_PTP_TX_TIMEOUT
index 686899d..ecb1bd7 100644 (file)
@@ -2842,6 +2842,7 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
        bnx2x_set_rx_mode_inner(bp);
 
        if (bp->flags & PTP_SUPPORTED) {
+               bnx2x_register_phc(bp);
                bnx2x_init_ptp(bp);
                bnx2x_configure_ptp_filters(bp);
        }
index 01a973e..6b54eb1 100644 (file)
@@ -7723,6 +7723,9 @@ static int bnx2x_init_hw_port(struct bnx2x *bp)
                REG_WR(bp, reg_addr, val);
        }
 
+       if (CHIP_IS_E3B0(bp))
+               bp->flags |= PTP_SUPPORTED;
+
        return 0;
 }
 
@@ -9444,8 +9447,13 @@ unload_error:
         * function stop ramrod is sent, since as part of this ramrod FW access
         * PTP registers.
         */
-       if (bp->flags & PTP_SUPPORTED)
+       if (bp->flags & PTP_SUPPORTED) {
                bnx2x_stop_ptp(bp);
+               if (bp->ptp_clock) {
+                       ptp_clock_unregister(bp->ptp_clock);
+                       bp->ptp_clock = NULL;
+               }
+       }
 
        /* Disable HW interrupts, NAPI */
        bnx2x_netif_stop(bp, 1);
@@ -12523,9 +12531,6 @@ static int bnx2x_init_bp(struct bnx2x *bp)
 
        bp->dump_preset_idx = 1;
 
-       if (CHIP_IS_E3B0(bp))
-               bp->flags |= PTP_SUPPORTED;
-
        return rc;
 }
 
@@ -13917,7 +13922,7 @@ static int bnx2x_ptp_enable(struct ptp_clock_info *ptp,
        return -ENOTSUPP;
 }
 
-static void bnx2x_register_phc(struct bnx2x *bp)
+void bnx2x_register_phc(struct bnx2x *bp)
 {
        /* Fill the ptp_clock_info struct and register PTP clock*/
        bp->ptp_clock_info.owner = THIS_MODULE;
@@ -14119,8 +14124,6 @@ static int bnx2x_init_one(struct pci_dev *pdev,
               dev->base_addr, bp->pdev->irq, dev->dev_addr);
        pcie_print_link_status(bp->pdev);
 
-       bnx2x_register_phc(bp);
-
        if (!IS_MF_SD_STORAGE_PERSONALITY_ONLY(bp))
                bnx2x_set_os_driver_state(bp, OS_DRIVER_STATE_DISABLED);
 
@@ -14153,11 +14156,6 @@ static void __bnx2x_remove(struct pci_dev *pdev,
                           struct bnx2x *bp,
                           bool remove_netdev)
 {
-       if (bp->ptp_clock) {
-               ptp_clock_unregister(bp->ptp_clock);
-               bp->ptp_clock = NULL;
-       }
-
        /* Delete storage MAC address */
        if (!NO_FCOE(bp)) {
                rtnl_lock();