BNX2X: manually removes the PTP code
authorBarret Rhoden <brho@cs.berkeley.edu>
Tue, 10 Feb 2015 23:01:34 +0000 (18:01 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 2 Mar 2015 16:59:09 +0000 (11:59 -0500)
Peer Time Protocol.  Not particularly interested in supporting it right
now, and there's no kernel support.

kern/drivers/net/bnx2x/bnx2x.h
kern/drivers/net/bnx2x/bnx2x_cmn.c
kern/drivers/net/bnx2x/bnx2x_ethtool.c
kern/drivers/net/bnx2x/bnx2x_main.c

index 32f5424..8d20272 100644 (file)
@@ -1932,19 +1932,6 @@ struct bnx2x {
 
        uint8_t                                 phys_port_id[Eaddrlen];
 
-       /* PTP related context */
-       struct ptp_clock *ptp_clock;
-       struct ptp_clock_info ptp_clock_info;
-       struct work_struct ptp_task;
-       struct cyclecounter cyclecounter;
-       struct timecounter timecounter;
-       bool timecounter_init_done;
-       struct sk_buff *ptp_tx_skb;
-       unsigned long ptp_tx_start;
-       bool hwtstamp_ioctl_called;
-       uint16_t tx_type;
-       uint16_t rx_filter;
-
        struct bnx2x_link_report_data           vf_link_vars;
 };
 
@@ -2608,10 +2595,6 @@ void bnx2x_update_mng_version(struct bnx2x *bp);
 
 #define E1H_MAX_MF_SB_COUNT (HC_SB_MAX_SB_E1X/(E1HVN_MAX * PORT_MAX))
 
-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);
-
 #define BNX2X_MAX_PHC_DRIFT 31000000
 #define BNX2X_PTP_TX_TIMEOUT
 
index b8eb28f..5f8c2e2 100644 (file)
@@ -1058,11 +1058,6 @@ reuse_rx:
 
                skb_record_rx_queue(skb, fp->rx_queue);
 
-               /* Check if this packet was timestamped */
-               if (unlikely(cqe->fast_path_cqe.type_error_flags &
-                            (1 << ETH_FAST_PATH_RX_CQE_PTP_PKT_SHIFT)))
-                       bnx2x_set_rx_ts(bp, skb);
-
                if (le16_to_cpu(cqe_fp->pars_flags.flags) &
                    PARSING_FLAGS_VLAN)
                        __vlan_hwaccel_put_tag(skb, cpu_to_be16(ETH_P_8021Q),
@@ -2806,10 +2801,6 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
        /* Initialize Rx filter. */
        bnx2x_set_rx_mode_inner(bp);
 
-       if (bp->flags & PTP_SUPPORTED) {
-               bnx2x_init_ptp(bp);
-               bnx2x_configure_ptp_filters(bp);
-       }
        /* Start Tx */
        switch (load_mode) {
        case LOAD_NORMAL:
@@ -3837,20 +3828,6 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct ether *dev)
 
        tx_start_bd->bd_flags.as_bitfield = ETH_TX_BD_FLAGS_START_BD;
 
-       if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) {
-               if (!(bp->flags & TX_TIMESTAMPING_EN)) {
-                       BNX2X_ERR("Tx timestamping was not enabled, this packet will not be timestamped\n");
-               } else if (bp->ptp_tx_skb) {
-                       BNX2X_ERR("The device supports only a single outstanding packet to timestamp, this packet will not be timestamped\n");
-               } else {
-                       skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
-                       /* schedule check for Tx timestamp */
-                       bp->ptp_tx_skb = skb_get(skb);
-                       bp->ptp_tx_start = jiffies;
-                       schedule_work(&bp->ptp_task);
-               }
-       }
-
        /* header nbd: indirectly zero other flags! */
        tx_start_bd->general_data = 1 << ETH_TX_START_BD_HDR_NBDS_SHIFT;
 
index 062025c..0b4934e 100644 (file)
@@ -3511,38 +3511,6 @@ static int bnx2x_get_ts_info(struct ether *dev,
 {
        struct bnx2x *bp = netdev_priv(dev);
 
-       if (bp->flags & PTP_SUPPORTED) {
-               info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
-                                       SOF_TIMESTAMPING_RX_SOFTWARE |
-                                       SOF_TIMESTAMPING_SOFTWARE |
-                                       SOF_TIMESTAMPING_TX_HARDWARE |
-                                       SOF_TIMESTAMPING_RX_HARDWARE |
-                                       SOF_TIMESTAMPING_RAW_HARDWARE;
-
-               if (bp->ptp_clock)
-                       info->phc_index = ptp_clock_index(bp->ptp_clock);
-               else
-                       info->phc_index = -1;
-
-               info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
-                                  (1 << HWTSTAMP_FILTER_PTP_V1_L4_EVENT) |
-                                  (1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) |
-                                  (1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) |
-                                  (1 << HWTSTAMP_FILTER_PTP_V2_L4_EVENT) |
-                                  (1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC) |
-                                  (1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) |
-                                  (1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
-                                  (1 << HWTSTAMP_FILTER_PTP_V2_L2_SYNC) |
-                                  (1 << HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) |
-                                  (1 << HWTSTAMP_FILTER_PTP_V2_EVENT) |
-                                  (1 << HWTSTAMP_FILTER_PTP_V2_SYNC) |
-                                  (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ);
-
-               info->tx_types = (1 << HWTSTAMP_TX_OFF)|(1 << HWTSTAMP_TX_ON);
-
-               return 0;
-       }
-
        return ethtool_op_get_ts_info(dev, info);
 }
 
index 5e872d4..0af3fd8 100644 (file)
@@ -9115,48 +9115,6 @@ static int bnx2x_func_wait_started(struct bnx2x *bp)
        return 0;
 }
 
-static void bnx2x_disable_ptp(struct bnx2x *bp)
-{
-       int port = BP_PORT(bp);
-
-       /* Disable sending PTP packets to host */
-       REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_TO_HOST :
-              NIG_REG_P0_LLH_PTP_TO_HOST, 0x0);
-
-       /* Reset PTP event detection rules */
-       REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_PARAM_MASK :
-              NIG_REG_P0_LLH_PTP_PARAM_MASK, 0x7FF);
-       REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_RULE_MASK :
-              NIG_REG_P0_LLH_PTP_RULE_MASK, 0x3FFF);
-       REG_WR(bp, port ? NIG_REG_P1_TLLH_PTP_PARAM_MASK :
-              NIG_REG_P0_TLLH_PTP_PARAM_MASK, 0x7FF);
-       REG_WR(bp, port ? NIG_REG_P1_TLLH_PTP_RULE_MASK :
-              NIG_REG_P0_TLLH_PTP_RULE_MASK, 0x3FFF);
-
-       /* Disable the PTP feature */
-       REG_WR(bp, port ? NIG_REG_P1_PTP_EN :
-              NIG_REG_P0_PTP_EN, 0x0);
-}
-
-/* Called during unload, to stop PTP-related stuff */
-void bnx2x_stop_ptp(struct bnx2x *bp)
-{
-       /* Cancel PTP work queue. Should be done after the Tx queues are
-        * drained to prevent additional scheduling.
-        */
-       cancel_work_sync(&bp->ptp_task);
-
-       if (bp->ptp_tx_skb) {
-               dev_kfree_skb_any(bp->ptp_tx_skb);
-               bp->ptp_tx_skb = NULL;
-       }
-
-       /* Disable PTP in HW */
-       bnx2x_disable_ptp(bp);
-
-       DP(BNX2X_MSG_PTP, "PTP stop ended successfully\n");
-}
-
 void bnx2x_chip_cleanup(struct bnx2x *bp, int unload_mode, bool keep_link)
 {
        int port = BP_PORT(bp);
@@ -9275,13 +9233,6 @@ unload_error:
 #endif
        }
 
-       /* stop_ptp should be after the Tx queues are drained to prevent
-        * scheduling to the cancelled PTP work queue. It should also be after
-        * function stop ramrod is sent, since as part of this ramrod FW access
-        * PTP registers.
-        */
-       bnx2x_stop_ptp(bp);
-
        /* Disable HW interrupts, NAPI */
        bnx2x_netif_stop(bp, 1);
        /* Delete all NAPI objects */
@@ -13164,155 +13115,6 @@ static int bnx2x_send_update_drift_ramrod(struct bnx2x *bp, int drift_dir,
        return bnx2x_func_state_change(bp, &func_params);
 }
 
-static int bnx2x_ptp_adjfreq(struct ptp_clock_info *ptp, int32_t ppb)
-{
-       struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);
-       int rc;
-       int drift_dir = 1;
-       int val, period, period1, period2, dif, dif1, dif2;
-       int best_dif = BNX2X_MAX_PHC_DRIFT, best_period = 0, best_val = 0;
-
-       DP(BNX2X_MSG_PTP, "PTP adjfreq called, ppb = %d\n", ppb);
-
-       if (!netif_running(bp->dev)) {
-               DP(BNX2X_MSG_PTP,
-                  "PTP adjfreq called while the interface is down\n");
-               return -EFAULT;
-       }
-
-       if (ppb < 0) {
-               ppb = -ppb;
-               drift_dir = 0;
-       }
-
-       if (ppb == 0) {
-               best_val = 1;
-               best_period = 0x1FFFFFF;
-       } else if (ppb >= BNX2X_MAX_PHC_DRIFT) {
-               best_val = 31;
-               best_period = 1;
-       } else {
-               /* Changed not to allow val = 8, 16, 24 as these values
-                * are not supported in workaround.
-                */
-               for (val = 0; val <= 31; val++) {
-                       if ((val & 0x7) == 0)
-                               continue;
-                       period1 = val * 1000000 / ppb;
-                       period2 = period1 + 1;
-                       if (period1 != 0)
-                               dif1 = ppb - (val * 1000000 / period1);
-                       else
-                               dif1 = BNX2X_MAX_PHC_DRIFT;
-                       if (dif1 < 0)
-                               dif1 = -dif1;
-                       dif2 = ppb - (val * 1000000 / period2);
-                       if (dif2 < 0)
-                               dif2 = -dif2;
-                       dif = (dif1 < dif2) ? dif1 : dif2;
-                       period = (dif1 < dif2) ? period1 : period2;
-                       if (dif < best_dif) {
-                               best_dif = dif;
-                               best_val = val;
-                               best_period = period;
-                       }
-               }
-       }
-
-       rc = bnx2x_send_update_drift_ramrod(bp, drift_dir, best_val,
-                                           best_period);
-       if (rc) {
-               BNX2X_ERR("Failed to set drift\n");
-               return -EFAULT;
-       }
-
-       DP(BNX2X_MSG_PTP, "Configured val = %d, period = %d\n", best_val,
-          best_period);
-
-       return 0;
-}
-
-static int bnx2x_ptp_adjtime(struct ptp_clock_info *ptp, int64_t delta)
-{
-       struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);
-       uint64_t now;
-
-       DP(BNX2X_MSG_PTP, "PTP adjtime called, delta = %llx\n", delta);
-
-       now = timecounter_read(&bp->timecounter);
-       now += delta;
-       /* Re-init the timecounter */
-       timecounter_init(&bp->timecounter, &bp->cyclecounter, now);
-
-       return 0;
-}
-
-static int bnx2x_ptp_gettime(struct ptp_clock_info *ptp, struct timespec *ts)
-{
-       struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);
-       uint64_t ns;
-       uint32_t remainder;
-
-       ns = timecounter_read(&bp->timecounter);
-
-       DP(BNX2X_MSG_PTP, "PTP gettime called, ns = %llu\n", ns);
-
-       ts->tv_sec = div_u64_rem(ns, 1000000000ULL, &remainder);
-       ts->tv_nsec = remainder;
-
-       return 0;
-}
-
-static int bnx2x_ptp_settime(struct ptp_clock_info *ptp,
-                            const struct timespec *ts)
-{
-       struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);
-       uint64_t ns;
-
-       ns = ts->tv_sec * 1000000000ULL;
-       ns += ts->tv_nsec;
-
-       DP(BNX2X_MSG_PTP, "PTP settime called, ns = %llu\n", ns);
-
-       /* Re-init the timecounter */
-       timecounter_init(&bp->timecounter, &bp->cyclecounter, ns);
-
-       return 0;
-}
-
-/* Enable (or disable) ancillary features of the phc subsystem */
-static int bnx2x_ptp_enable(struct ptp_clock_info *ptp,
-                           struct ptp_clock_request *rq, int on)
-{
-       struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);
-
-       BNX2X_ERR("PHC ancillary features are not supported\n");
-       return -ENOTSUPP;
-}
-
-void bnx2x_register_phc(struct bnx2x *bp)
-{
-       /* Fill the ptp_clock_info struct and register PTP clock*/
-       bp->ptp_clock_info.owner = THIS_MODULE;
-       snprintf(bp->ptp_clock_info.name, 16, "%s", bp->dev->name);
-       bp->ptp_clock_info.max_adj = BNX2X_MAX_PHC_DRIFT; /* In PPB */
-       bp->ptp_clock_info.n_alarm = 0;
-       bp->ptp_clock_info.n_ext_ts = 0;
-       bp->ptp_clock_info.n_per_out = 0;
-       bp->ptp_clock_info.pps = 0;
-       bp->ptp_clock_info.adjfreq = bnx2x_ptp_adjfreq;
-       bp->ptp_clock_info.adjtime = bnx2x_ptp_adjtime;
-       bp->ptp_clock_info.gettime = bnx2x_ptp_gettime;
-       bp->ptp_clock_info.settime = bnx2x_ptp_settime;
-       bp->ptp_clock_info.enable = bnx2x_ptp_enable;
-
-       bp->ptp_clock = ptp_clock_register(&bp->ptp_clock_info, &bp->pdev->dev);
-       if (IS_ERR(bp->ptp_clock)) {
-               bp->ptp_clock = NULL;
-               BNX2X_ERR("PTP clock registeration failed\n");
-       }
-}
-
 static int bnx2x_init_one(struct pci_device *pdev,
                                    const struct pci_device_id *ent)
 {
@@ -13512,11 +13314,6 @@ static void __bnx2x_remove(struct pci_device *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();
@@ -14500,332 +14297,3 @@ int bnx2x_pretend_func(struct bnx2x *bp, uint16_t pretend_func_val)
        REG_RD(bp, pretend_reg);
        return 0;
 }
-
-static void bnx2x_ptp_task(struct work_struct *work)
-{
-       struct bnx2x *bp = container_of(work, struct bnx2x, ptp_task);
-       int port = BP_PORT(bp);
-       uint32_t val_seq;
-       uint64_t timestamp, ns;
-       struct skb_shared_hwtstamps shhwtstamps;
-
-       /* Read Tx timestamp registers */
-       val_seq = REG_RD(bp, port ? NIG_REG_P1_TLLH_PTP_BUF_SEQID :
-                        NIG_REG_P0_TLLH_PTP_BUF_SEQID);
-       if (val_seq & 0x10000) {
-               /* There is a valid timestamp value */
-               timestamp = REG_RD(bp, port ? NIG_REG_P1_TLLH_PTP_BUF_TS_MSB :
-                                  NIG_REG_P0_TLLH_PTP_BUF_TS_MSB);
-               timestamp <<= 32;
-               timestamp |= REG_RD(bp, port ? NIG_REG_P1_TLLH_PTP_BUF_TS_LSB :
-                                   NIG_REG_P0_TLLH_PTP_BUF_TS_LSB);
-               /* Reset timestamp register to allow new timestamp */
-               REG_WR(bp, port ? NIG_REG_P1_TLLH_PTP_BUF_SEQID :
-                      NIG_REG_P0_TLLH_PTP_BUF_SEQID, 0x10000);
-               ns = timecounter_cyc2time(&bp->timecounter, timestamp);
-
-               memset(&shhwtstamps, 0, sizeof(shhwtstamps));
-               shhwtstamps.hwtstamp = ns_to_ktime(ns);
-               skb_tstamp_tx(bp->ptp_tx_skb, &shhwtstamps);
-               dev_kfree_skb_any(bp->ptp_tx_skb);
-               bp->ptp_tx_skb = NULL;
-
-               DP(BNX2X_MSG_PTP, "Tx timestamp, timestamp cycles = %llu, ns = %llu\n",
-                  timestamp, ns);
-       } else {
-               DP(BNX2X_MSG_PTP, "There is no valid Tx timestamp yet\n");
-               /* Reschedule to keep checking for a valid timestamp value */
-               schedule_work(&bp->ptp_task);
-       }
-}
-
-void bnx2x_set_rx_ts(struct bnx2x *bp, struct sk_buff *skb)
-{
-       int port = BP_PORT(bp);
-       uint64_t timestamp, ns;
-
-       timestamp = REG_RD(bp, port ? NIG_REG_P1_LLH_PTP_HOST_BUF_TS_MSB :
-                           NIG_REG_P0_LLH_PTP_HOST_BUF_TS_MSB);
-       timestamp <<= 32;
-       timestamp |= REG_RD(bp, port ? NIG_REG_P1_LLH_PTP_HOST_BUF_TS_LSB :
-                           NIG_REG_P0_LLH_PTP_HOST_BUF_TS_LSB);
-
-       /* Reset timestamp register to allow new timestamp */
-       REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_HOST_BUF_SEQID :
-              NIG_REG_P0_LLH_PTP_HOST_BUF_SEQID, 0x10000);
-
-       ns = timecounter_cyc2time(&bp->timecounter, timestamp);
-
-       skb_hwtstamps(skb)->hwtstamp = ns_to_ktime(ns);
-
-       DP(BNX2X_MSG_PTP, "Rx timestamp, timestamp cycles = %llu, ns = %llu\n",
-          timestamp, ns);
-}
-
-/* Read the PHC */
-static cycle_t bnx2x_cyclecounter_read(const struct cyclecounter *cc)
-{
-       struct bnx2x *bp = container_of(cc, struct bnx2x, cyclecounter);
-       int port = BP_PORT(bp);
-       uint32_t wb_data[2];
-       uint64_t phc_cycles;
-
-       REG_RD_DMAE(bp, port ? NIG_REG_TIMESYNC_GEN_REG + tsgen_synctime_t1 :
-                   NIG_REG_TIMESYNC_GEN_REG + tsgen_synctime_t0, wb_data, 2);
-       phc_cycles = wb_data[1];
-       phc_cycles = (phc_cycles << 32) + wb_data[0];
-
-       DP(BNX2X_MSG_PTP, "PHC read cycles = %llu\n", phc_cycles);
-
-       return phc_cycles;
-}
-
-static void bnx2x_init_cyclecounter(struct bnx2x *bp)
-{
-       memset(&bp->cyclecounter, 0, sizeof(bp->cyclecounter));
-       bp->cyclecounter.read = bnx2x_cyclecounter_read;
-       bp->cyclecounter.mask = CLOCKSOURCE_MASK(64);
-       bp->cyclecounter.shift = 1;
-       bp->cyclecounter.mult = 1;
-}
-
-static int bnx2x_send_reset_timesync_ramrod(struct bnx2x *bp)
-{
-       struct bnx2x_func_state_params func_params = {NULL};
-       struct bnx2x_func_set_timesync_params *set_timesync_params =
-               &func_params.params.set_timesync;
-
-       /* Prepare parameters for function state transitions */
-       __set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
-       __set_bit(RAMROD_RETRY, &func_params.ramrod_flags);
-
-       func_params.f_obj = &bp->func_obj;
-       func_params.cmd = BNX2X_F_CMD_SET_TIMESYNC;
-
-       /* Function parameters */
-       set_timesync_params->drift_adjust_cmd = TS_DRIFT_ADJUST_RESET;
-       set_timesync_params->offset_cmd = TS_OFFSET_KEEP;
-
-       return bnx2x_func_state_change(bp, &func_params);
-}
-
-int bnx2x_enable_ptp_packets(struct bnx2x *bp)
-{
-       struct bnx2x_queue_state_params q_params;
-       int rc, i;
-
-       /* send queue update ramrod to enable PTP packets */
-       memset(&q_params, 0, sizeof(q_params));
-       __set_bit(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
-       q_params.cmd = BNX2X_Q_CMD_UPDATE;
-       __set_bit(BNX2X_Q_UPDATE_PTP_PKTS_CHNG,
-                 &q_params.params.update.update_flags);
-       __set_bit(BNX2X_Q_UPDATE_PTP_PKTS,
-                 &q_params.params.update.update_flags);
-
-       /* send the ramrod on all the queues of the PF */
-       for_each_eth_queue(bp, i) {
-               struct bnx2x_fastpath *fp = &bp->fp[i];
-
-               /* Set the appropriate Queue object */
-               q_params.q_obj = &bnx2x_sp_obj(bp, fp).q_obj;
-
-               /* Update the Queue state */
-               rc = bnx2x_queue_state_change(bp, &q_params);
-               if (rc) {
-                       BNX2X_ERR("Failed to enable PTP packets\n");
-                       return rc;
-               }
-       }
-
-       return 0;
-}
-
-int bnx2x_configure_ptp_filters(struct bnx2x *bp)
-{
-       int port = BP_PORT(bp);
-       int rc;
-
-       if (!bp->hwtstamp_ioctl_called)
-               return 0;
-
-       switch (bp->tx_type) {
-       case HWTSTAMP_TX_ON:
-               bp->flags |= TX_TIMESTAMPING_EN;
-               REG_WR(bp, port ? NIG_REG_P1_TLLH_PTP_PARAM_MASK :
-                      NIG_REG_P0_TLLH_PTP_PARAM_MASK, 0x6AA);
-               REG_WR(bp, port ? NIG_REG_P1_TLLH_PTP_RULE_MASK :
-                      NIG_REG_P0_TLLH_PTP_RULE_MASK, 0x3EEE);
-               break;
-       case HWTSTAMP_TX_ONESTEP_SYNC:
-               BNX2X_ERR("One-step timestamping is not supported\n");
-               return -ERANGE;
-       }
-
-       switch (bp->rx_filter) {
-       case HWTSTAMP_FILTER_NONE:
-               break;
-       case HWTSTAMP_FILTER_ALL:
-       case HWTSTAMP_FILTER_SOME:
-               bp->rx_filter = HWTSTAMP_FILTER_NONE;
-               break;
-       case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
-       case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
-       case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
-               bp->rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
-               /* Initialize PTP detection for UDP/IPv4 events */
-               REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_PARAM_MASK :
-                      NIG_REG_P0_LLH_PTP_PARAM_MASK, 0x7EE);
-               REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_RULE_MASK :
-                      NIG_REG_P0_LLH_PTP_RULE_MASK, 0x3FFE);
-               break;
-       case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
-       case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
-       case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
-               bp->rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT;
-               /* Initialize PTP detection for UDP/IPv4 or UDP/IPv6 events */
-               REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_PARAM_MASK :
-                      NIG_REG_P0_LLH_PTP_PARAM_MASK, 0x7EA);
-               REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_RULE_MASK :
-                      NIG_REG_P0_LLH_PTP_RULE_MASK, 0x3FEE);
-               break;
-       case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
-       case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
-       case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
-               bp->rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
-               /* Initialize PTP detection L2 events */
-               REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_PARAM_MASK :
-                      NIG_REG_P0_LLH_PTP_PARAM_MASK, 0x6BF);
-               REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_RULE_MASK :
-                      NIG_REG_P0_LLH_PTP_RULE_MASK, 0x3EFF);
-
-               break;
-       case HWTSTAMP_FILTER_PTP_V2_EVENT:
-       case HWTSTAMP_FILTER_PTP_V2_SYNC:
-       case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
-               bp->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
-               /* Initialize PTP detection L2, UDP/IPv4 or UDP/IPv6 events */
-               REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_PARAM_MASK :
-                      NIG_REG_P0_LLH_PTP_PARAM_MASK, 0x6AA);
-               REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_RULE_MASK :
-                      NIG_REG_P0_LLH_PTP_RULE_MASK, 0x3EEE);
-               break;
-       }
-
-       /* Indicate to FW that this PF expects recorded PTP packets */
-       rc = bnx2x_enable_ptp_packets(bp);
-       if (rc)
-               return rc;
-
-       /* Enable sending PTP packets to host */
-       REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_TO_HOST :
-              NIG_REG_P0_LLH_PTP_TO_HOST, 0x1);
-
-       return 0;
-}
-
-static int bnx2x_hwtstamp_ioctl(struct bnx2x *bp, struct ifreq *ifr)
-{
-       struct hwtstamp_config config;
-       int rc;
-
-       DP(BNX2X_MSG_PTP, "HWTSTAMP IOCTL called\n");
-
-       if (memcpy_from_user(current, &config, ifr->ifr_data, sizeof(config)))
-               return -EFAULT;
-
-       DP(BNX2X_MSG_PTP, "Requested tx_type: %d, requested rx_filters = %d\n",
-          config.tx_type, config.rx_filter);
-
-       if (config.flags) {
-               BNX2X_ERR("config.flags is reserved for future use\n");
-               return -EINVAL;
-       }
-
-       bp->hwtstamp_ioctl_called = 1;
-       bp->tx_type = config.tx_type;
-       bp->rx_filter = config.rx_filter;
-
-       rc = bnx2x_configure_ptp_filters(bp);
-       if (rc)
-               return rc;
-
-       config.rx_filter = bp->rx_filter;
-
-       return memcpy_to_user(current, ifr->ifr_data, &config, sizeof(config)) ?
-               -EFAULT : 0;
-}
-
-/* Configures HW for PTP */
-static int bnx2x_configure_ptp(struct bnx2x *bp)
-{
-       int rc, port = BP_PORT(bp);
-       uint32_t wb_data[2];
-
-       /* Reset PTP event detection rules - will be configured in the IOCTL */
-       REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_PARAM_MASK :
-              NIG_REG_P0_LLH_PTP_PARAM_MASK, 0x7FF);
-       REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_RULE_MASK :
-              NIG_REG_P0_LLH_PTP_RULE_MASK, 0x3FFF);
-       REG_WR(bp, port ? NIG_REG_P1_TLLH_PTP_PARAM_MASK :
-              NIG_REG_P0_TLLH_PTP_PARAM_MASK, 0x7FF);
-       REG_WR(bp, port ? NIG_REG_P1_TLLH_PTP_RULE_MASK :
-              NIG_REG_P0_TLLH_PTP_RULE_MASK, 0x3FFF);
-
-       /* Disable PTP packets to host - will be configured in the IOCTL*/
-       REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_TO_HOST :
-              NIG_REG_P0_LLH_PTP_TO_HOST, 0x0);
-
-       /* Enable the PTP feature */
-       REG_WR(bp, port ? NIG_REG_P1_PTP_EN :
-              NIG_REG_P0_PTP_EN, 0x3F);
-
-       /* Enable the free-running counter */
-       wb_data[0] = 0;
-       wb_data[1] = 0;
-       REG_WR_DMAE(bp, NIG_REG_TIMESYNC_GEN_REG + tsgen_ctrl, wb_data, 2);
-
-       /* Reset drift register (offset register is not reset) */
-       rc = bnx2x_send_reset_timesync_ramrod(bp);
-       if (rc) {
-               BNX2X_ERR("Failed to reset PHC drift register\n");
-               return -EFAULT;
-       }
-
-       /* Reset possibly old timestamps */
-       REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_HOST_BUF_SEQID :
-              NIG_REG_P0_LLH_PTP_HOST_BUF_SEQID, 0x10000);
-       REG_WR(bp, port ? NIG_REG_P1_TLLH_PTP_BUF_SEQID :
-              NIG_REG_P0_TLLH_PTP_BUF_SEQID, 0x10000);
-
-       return 0;
-}
-
-/* Called during load, to initialize PTP-related stuff */
-void bnx2x_init_ptp(struct bnx2x *bp)
-{
-       int rc;
-
-       /* Configure PTP in HW */
-       rc = bnx2x_configure_ptp(bp);
-       if (rc) {
-               BNX2X_ERR("Stopping PTP initialization\n");
-               return;
-       }
-
-       /* Init work queue for Tx timestamping */
-       INIT_WORK(&bp->ptp_task, bnx2x_ptp_task);
-
-       /* Init cyclecounter and timecounter. This is done only in the first
-        * load. If done in every load, PTP application will fail when doing
-        * unload / load (e.g. MTU change) while it is running.
-        */
-       if (!bp->timecounter_init_done) {
-               bnx2x_init_cyclecounter(bp);
-               timecounter_init(&bp->timecounter, &bp->cyclecounter,
-                                epoch_nsec());
-               bp->timecounter_init_done = 1;
-       }
-
-       DP(BNX2X_MSG_PTP, "PTP initialization ended successfully\n");
-}