Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'support-for-hwtstamp_get-in-phy-part-2'

Vadim Fedorenko says:

====================
support for hwtstamp_get in phy - part 2

There are 2 drivers which had some inconsistency in HW timestamping
configuration logic. Improve both of them and add hwtstamp_get()
callback.
====================

Link: https://patch.msgid.link/20260106160723.3925872-1-vadim.fedorenko@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+67 -11
+38 -6
drivers/net/phy/micrel.c
··· 3147 3147 lanphy_read_page_reg(phydev, LAN8814_PAGE_PORT_REGS, PTP_TSU_INT_STS); 3148 3148 } 3149 3149 3150 + static int lan8814_hwtstamp_get(struct mii_timestamper *mii_ts, 3151 + struct kernel_hwtstamp_config *config) 3152 + { 3153 + struct kszphy_ptp_priv *ptp_priv = 3154 + container_of(mii_ts, struct kszphy_ptp_priv, mii_ts); 3155 + 3156 + config->tx_type = ptp_priv->hwts_tx_type; 3157 + config->rx_filter = ptp_priv->rx_filter; 3158 + 3159 + return 0; 3160 + } 3161 + 3150 3162 static int lan8814_hwtstamp_set(struct mii_timestamper *mii_ts, 3151 3163 struct kernel_hwtstamp_config *config, 3152 3164 struct netlink_ext_ack *extack) ··· 3168 3156 struct lan8814_ptp_rx_ts *rx_ts, *tmp; 3169 3157 int txcfg = 0, rxcfg = 0; 3170 3158 int pkt_ts_enable; 3171 - 3172 - ptp_priv->hwts_tx_type = config->tx_type; 3173 - ptp_priv->rx_filter = config->rx_filter; 3174 3159 3175 3160 switch (config->rx_filter) { 3176 3161 case HWTSTAMP_FILTER_NONE: ··· 3195 3186 default: 3196 3187 return -ERANGE; 3197 3188 } 3189 + 3190 + switch (config->tx_type) { 3191 + case HWTSTAMP_TX_OFF: 3192 + case HWTSTAMP_TX_ON: 3193 + case HWTSTAMP_TX_ONESTEP_SYNC: 3194 + break; 3195 + default: 3196 + return -ERANGE; 3197 + } 3198 + 3199 + ptp_priv->hwts_tx_type = config->tx_type; 3200 + ptp_priv->rx_filter = config->rx_filter; 3198 3201 3199 3202 if (ptp_priv->layer & PTP_CLASS_L2) { 3200 3203 rxcfg = PTP_RX_PARSE_CONFIG_LAYER2_EN_; ··· 4411 4390 ptp_priv->mii_ts.rxtstamp = lan8814_rxtstamp; 4412 4391 ptp_priv->mii_ts.txtstamp = lan8814_txtstamp; 4413 4392 ptp_priv->mii_ts.hwtstamp_set = lan8814_hwtstamp_set; 4393 + ptp_priv->mii_ts.hwtstamp_get = lan8814_hwtstamp_get; 4414 4394 ptp_priv->mii_ts.ts_info = lan8814_ts_info; 4415 4395 4416 4396 phydev->mii_ts = &ptp_priv->mii_ts; ··· 5073 5051 int txcfg = 0, rxcfg = 0; 5074 5052 int pkt_ts_enable; 5075 5053 5076 - ptp_priv->hwts_tx_type = config->tx_type; 5077 - ptp_priv->rx_filter = config->rx_filter; 5078 - 5079 5054 switch (config->rx_filter) { 5080 5055 case HWTSTAMP_FILTER_NONE: 5081 5056 ptp_priv->layer = 0; ··· 5099 5080 default: 5100 5081 return -ERANGE; 5101 5082 } 5083 + 5084 + switch (config->tx_type) { 5085 + case HWTSTAMP_TX_OFF: 5086 + case HWTSTAMP_TX_ON: 5087 + case HWTSTAMP_TX_ONESTEP_SYNC: 5088 + break; 5089 + default: 5090 + return -ERANGE; 5091 + } 5092 + 5093 + ptp_priv->hwts_tx_type = config->tx_type; 5094 + ptp_priv->rx_filter = config->rx_filter; 5102 5095 5103 5096 /* Setup parsing of the frames and enable the timestamping for ptp 5104 5097 * frames ··· 5956 5925 ptp_priv->mii_ts.rxtstamp = lan8841_rxtstamp; 5957 5926 ptp_priv->mii_ts.txtstamp = lan8814_txtstamp; 5958 5927 ptp_priv->mii_ts.hwtstamp_set = lan8841_hwtstamp_set; 5928 + ptp_priv->mii_ts.hwtstamp_get = lan8814_hwtstamp_get; 5959 5929 ptp_priv->mii_ts.ts_info = lan8841_ts_info; 5960 5930 5961 5931 phydev->mii_ts = &ptp_priv->mii_ts;
+29 -5
drivers/net/phy/microchip_rds_ptp.c
··· 476 476 return true; 477 477 } 478 478 479 + static int mchp_rds_ptp_hwtstamp_get(struct mii_timestamper *mii_ts, 480 + struct kernel_hwtstamp_config *config) 481 + { 482 + struct mchp_rds_ptp_clock *clock = 483 + container_of(mii_ts, struct mchp_rds_ptp_clock, 484 + mii_ts); 485 + config->tx_type = clock->hwts_tx_type; 486 + config->rx_filter = clock->rx_filter; 487 + 488 + return 0; 489 + } 490 + 479 491 static int mchp_rds_ptp_hwtstamp_set(struct mii_timestamper *mii_ts, 480 492 struct kernel_hwtstamp_config *config, 481 493 struct netlink_ext_ack *extack) ··· 499 487 int txcfg = 0, rxcfg = 0; 500 488 unsigned long flags; 501 489 int rc; 502 - 503 - clock->hwts_tx_type = config->tx_type; 504 - clock->rx_filter = config->rx_filter; 505 490 506 491 switch (config->rx_filter) { 507 492 case HWTSTAMP_FILTER_NONE: ··· 522 513 case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: 523 514 clock->layer = PTP_CLASS_L4 | PTP_CLASS_L2; 524 515 clock->version = PTP_CLASS_V2; 516 + break; 517 + default: 518 + return -ERANGE; 519 + } 520 + 521 + switch (config->tx_type) { 522 + case HWTSTAMP_TX_ONESTEP_SYNC: 523 + case HWTSTAMP_TX_ON: 524 + case HWTSTAMP_TX_OFF: 525 525 break; 526 526 default: 527 527 return -ERANGE; ··· 571 553 if (rc < 0) 572 554 return rc; 573 555 574 - if (clock->hwts_tx_type == HWTSTAMP_TX_ONESTEP_SYNC) 556 + if (config->tx_type == HWTSTAMP_TX_ONESTEP_SYNC) 575 557 /* Enable / disable of the TX timestamp in the SYNC frames */ 576 558 rc = mchp_rds_phy_modify_mmd(clock, MCHP_RDS_PTP_TX_MOD, 577 559 MCHP_RDS_PTP_PORT, ··· 605 587 /* Now enable the timestamping interrupts */ 606 588 rc = mchp_rds_ptp_config_intr(clock, 607 589 config->rx_filter != HWTSTAMP_FILTER_NONE); 590 + if (rc < 0) 591 + return rc; 608 592 609 - return rc < 0 ? rc : 0; 593 + clock->hwts_tx_type = config->tx_type; 594 + clock->rx_filter = config->rx_filter; 595 + 596 + return 0; 610 597 } 611 598 612 599 static int mchp_rds_ptp_ts_info(struct mii_timestamper *mii_ts, ··· 1305 1282 clock->mii_ts.rxtstamp = mchp_rds_ptp_rxtstamp; 1306 1283 clock->mii_ts.txtstamp = mchp_rds_ptp_txtstamp; 1307 1284 clock->mii_ts.hwtstamp_set = mchp_rds_ptp_hwtstamp_set; 1285 + clock->mii_ts.hwtstamp_get = mchp_rds_ptp_hwtstamp_get; 1308 1286 clock->mii_ts.ts_info = mchp_rds_ptp_ts_info; 1309 1287 1310 1288 phydev->mii_ts = &clock->mii_ts;