hwtstamp.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. /*
  2. * Marvell 88E6xxx Switch hardware timestamping support
  3. *
  4. * Copyright (c) 2008 Marvell Semiconductor
  5. *
  6. * Copyright (c) 2017 National Instruments
  7. * Erik Hons <erik.hons@ni.com>
  8. * Brandon Streiff <brandon.streiff@ni.com>
  9. * Dane Wagner <dane.wagner@ni.com>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. */
  16. #include "chip.h"
  17. #include "global2.h"
  18. #include "hwtstamp.h"
  19. #include "ptp.h"
  20. #include <linux/ptp_classify.h>
  21. #define SKB_PTP_TYPE(__skb) (*(unsigned int *)((__skb)->cb))
  22. static int mv88e6xxx_port_ptp_read(struct mv88e6xxx_chip *chip, int port,
  23. int addr, u16 *data, int len)
  24. {
  25. if (!chip->info->ops->avb_ops->port_ptp_read)
  26. return -EOPNOTSUPP;
  27. return chip->info->ops->avb_ops->port_ptp_read(chip, port, addr,
  28. data, len);
  29. }
  30. static int mv88e6xxx_port_ptp_write(struct mv88e6xxx_chip *chip, int port,
  31. int addr, u16 data)
  32. {
  33. if (!chip->info->ops->avb_ops->port_ptp_write)
  34. return -EOPNOTSUPP;
  35. return chip->info->ops->avb_ops->port_ptp_write(chip, port, addr,
  36. data);
  37. }
  38. static int mv88e6xxx_ptp_write(struct mv88e6xxx_chip *chip, int addr,
  39. u16 data)
  40. {
  41. if (!chip->info->ops->avb_ops->ptp_write)
  42. return -EOPNOTSUPP;
  43. return chip->info->ops->avb_ops->ptp_write(chip, addr, data);
  44. }
  45. /* TX_TSTAMP_TIMEOUT: This limits the time spent polling for a TX
  46. * timestamp. When working properly, hardware will produce a timestamp
  47. * within 1ms. Software may enounter delays due to MDIO contention, so
  48. * the timeout is set accordingly.
  49. */
  50. #define TX_TSTAMP_TIMEOUT msecs_to_jiffies(20)
  51. int mv88e6xxx_get_ts_info(struct dsa_switch *ds, int port,
  52. struct ethtool_ts_info *info)
  53. {
  54. struct mv88e6xxx_chip *chip = ds->priv;
  55. if (!chip->info->ptp_support)
  56. return -EOPNOTSUPP;
  57. info->so_timestamping =
  58. SOF_TIMESTAMPING_TX_HARDWARE |
  59. SOF_TIMESTAMPING_RX_HARDWARE |
  60. SOF_TIMESTAMPING_RAW_HARDWARE;
  61. info->phc_index = ptp_clock_index(chip->ptp_clock);
  62. info->tx_types =
  63. (1 << HWTSTAMP_TX_OFF) |
  64. (1 << HWTSTAMP_TX_ON);
  65. info->rx_filters =
  66. (1 << HWTSTAMP_FILTER_NONE) |
  67. (1 << HWTSTAMP_FILTER_PTP_V2_L4_EVENT) |
  68. (1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC) |
  69. (1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) |
  70. (1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
  71. (1 << HWTSTAMP_FILTER_PTP_V2_L2_SYNC) |
  72. (1 << HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) |
  73. (1 << HWTSTAMP_FILTER_PTP_V2_EVENT) |
  74. (1 << HWTSTAMP_FILTER_PTP_V2_SYNC) |
  75. (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ);
  76. return 0;
  77. }
  78. static int mv88e6xxx_set_hwtstamp_config(struct mv88e6xxx_chip *chip, int port,
  79. struct hwtstamp_config *config)
  80. {
  81. struct mv88e6xxx_port_hwtstamp *ps = &chip->port_hwtstamp[port];
  82. bool tstamp_enable = false;
  83. u16 port_config0;
  84. int err;
  85. /* Prevent the TX/RX paths from trying to interact with the
  86. * timestamp hardware while we reconfigure it.
  87. */
  88. clear_bit_unlock(MV88E6XXX_HWTSTAMP_ENABLED, &ps->state);
  89. /* reserved for future extensions */
  90. if (config->flags)
  91. return -EINVAL;
  92. switch (config->tx_type) {
  93. case HWTSTAMP_TX_OFF:
  94. tstamp_enable = false;
  95. break;
  96. case HWTSTAMP_TX_ON:
  97. tstamp_enable = true;
  98. break;
  99. default:
  100. return -ERANGE;
  101. }
  102. /* The switch supports timestamping both L2 and L4; one cannot be
  103. * disabled independently of the other.
  104. */
  105. switch (config->rx_filter) {
  106. case HWTSTAMP_FILTER_NONE:
  107. tstamp_enable = false;
  108. break;
  109. case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
  110. case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
  111. case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
  112. case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
  113. case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
  114. case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
  115. case HWTSTAMP_FILTER_PTP_V2_EVENT:
  116. case HWTSTAMP_FILTER_PTP_V2_SYNC:
  117. case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
  118. config->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
  119. break;
  120. case HWTSTAMP_FILTER_ALL:
  121. default:
  122. config->rx_filter = HWTSTAMP_FILTER_NONE;
  123. return -ERANGE;
  124. }
  125. if (tstamp_enable) {
  126. /* Disable transportSpecific value matching, so that packets
  127. * with either 1588 (0) and 802.1AS (1) will be timestamped.
  128. */
  129. port_config0 = MV88E6XXX_PORT_PTP_CFG0_DISABLE_TSPEC_MATCH;
  130. } else {
  131. /* Disable PTP. This disables both RX and TX timestamping. */
  132. port_config0 = MV88E6XXX_PORT_PTP_CFG0_DISABLE_PTP;
  133. }
  134. mutex_lock(&chip->reg_lock);
  135. err = mv88e6xxx_port_ptp_write(chip, port, MV88E6XXX_PORT_PTP_CFG0,
  136. port_config0);
  137. mutex_unlock(&chip->reg_lock);
  138. if (err < 0)
  139. return err;
  140. /* Once hardware has been configured, enable timestamp checks
  141. * in the RX/TX paths.
  142. */
  143. if (tstamp_enable)
  144. set_bit(MV88E6XXX_HWTSTAMP_ENABLED, &ps->state);
  145. return 0;
  146. }
  147. int mv88e6xxx_port_hwtstamp_set(struct dsa_switch *ds, int port,
  148. struct ifreq *ifr)
  149. {
  150. struct mv88e6xxx_chip *chip = ds->priv;
  151. struct mv88e6xxx_port_hwtstamp *ps = &chip->port_hwtstamp[port];
  152. struct hwtstamp_config config;
  153. int err;
  154. if (!chip->info->ptp_support)
  155. return -EOPNOTSUPP;
  156. if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
  157. return -EFAULT;
  158. err = mv88e6xxx_set_hwtstamp_config(chip, port, &config);
  159. if (err)
  160. return err;
  161. /* Save the chosen configuration to be returned later. */
  162. memcpy(&ps->tstamp_config, &config, sizeof(config));
  163. return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
  164. -EFAULT : 0;
  165. }
  166. int mv88e6xxx_port_hwtstamp_get(struct dsa_switch *ds, int port,
  167. struct ifreq *ifr)
  168. {
  169. struct mv88e6xxx_chip *chip = ds->priv;
  170. struct mv88e6xxx_port_hwtstamp *ps = &chip->port_hwtstamp[port];
  171. struct hwtstamp_config *config = &ps->tstamp_config;
  172. if (!chip->info->ptp_support)
  173. return -EOPNOTSUPP;
  174. return copy_to_user(ifr->ifr_data, config, sizeof(*config)) ?
  175. -EFAULT : 0;
  176. }
  177. /* Get the start of the PTP header in this skb */
  178. static u8 *parse_ptp_header(struct sk_buff *skb, unsigned int type)
  179. {
  180. u8 *data = skb_mac_header(skb);
  181. unsigned int offset = 0;
  182. if (type & PTP_CLASS_VLAN)
  183. offset += VLAN_HLEN;
  184. switch (type & PTP_CLASS_PMASK) {
  185. case PTP_CLASS_IPV4:
  186. offset += ETH_HLEN + IPV4_HLEN(data + offset) + UDP_HLEN;
  187. break;
  188. case PTP_CLASS_IPV6:
  189. offset += ETH_HLEN + IP6_HLEN + UDP_HLEN;
  190. break;
  191. case PTP_CLASS_L2:
  192. offset += ETH_HLEN;
  193. break;
  194. default:
  195. return NULL;
  196. }
  197. /* Ensure that the entire header is present in this packet. */
  198. if (skb->len + ETH_HLEN < offset + 34)
  199. return NULL;
  200. return data + offset;
  201. }
  202. /* Returns a pointer to the PTP header if the caller should time stamp,
  203. * or NULL if the caller should not.
  204. */
  205. static u8 *mv88e6xxx_should_tstamp(struct mv88e6xxx_chip *chip, int port,
  206. struct sk_buff *skb, unsigned int type)
  207. {
  208. struct mv88e6xxx_port_hwtstamp *ps = &chip->port_hwtstamp[port];
  209. u8 *hdr;
  210. if (!chip->info->ptp_support)
  211. return NULL;
  212. hdr = parse_ptp_header(skb, type);
  213. if (!hdr)
  214. return NULL;
  215. if (!test_bit(MV88E6XXX_HWTSTAMP_ENABLED, &ps->state))
  216. return NULL;
  217. return hdr;
  218. }
  219. static int mv88e6xxx_ts_valid(u16 status)
  220. {
  221. if (!(status & MV88E6XXX_PTP_TS_VALID))
  222. return 0;
  223. if (status & MV88E6XXX_PTP_TS_STATUS_MASK)
  224. return 0;
  225. return 1;
  226. }
  227. static int seq_match(struct sk_buff *skb, u16 ts_seqid)
  228. {
  229. unsigned int type = SKB_PTP_TYPE(skb);
  230. u8 *hdr = parse_ptp_header(skb, type);
  231. __be16 *seqid;
  232. seqid = (__be16 *)(hdr + OFF_PTP_SEQUENCE_ID);
  233. return ts_seqid == ntohs(*seqid);
  234. }
  235. static void mv88e6xxx_get_rxts(struct mv88e6xxx_chip *chip,
  236. struct mv88e6xxx_port_hwtstamp *ps,
  237. struct sk_buff *skb, u16 reg,
  238. struct sk_buff_head *rxq)
  239. {
  240. u16 buf[4] = { 0 }, status, seq_id;
  241. struct skb_shared_hwtstamps *shwt;
  242. struct sk_buff_head received;
  243. u64 ns, timelo, timehi;
  244. unsigned long flags;
  245. int err;
  246. /* The latched timestamp belongs to one of the received frames. */
  247. __skb_queue_head_init(&received);
  248. spin_lock_irqsave(&rxq->lock, flags);
  249. skb_queue_splice_tail_init(rxq, &received);
  250. spin_unlock_irqrestore(&rxq->lock, flags);
  251. mutex_lock(&chip->reg_lock);
  252. err = mv88e6xxx_port_ptp_read(chip, ps->port_id,
  253. reg, buf, ARRAY_SIZE(buf));
  254. mutex_unlock(&chip->reg_lock);
  255. if (err)
  256. pr_err("failed to get the receive time stamp\n");
  257. status = buf[0];
  258. timelo = buf[1];
  259. timehi = buf[2];
  260. seq_id = buf[3];
  261. if (status & MV88E6XXX_PTP_TS_VALID) {
  262. mutex_lock(&chip->reg_lock);
  263. err = mv88e6xxx_port_ptp_write(chip, ps->port_id, reg, 0);
  264. mutex_unlock(&chip->reg_lock);
  265. if (err)
  266. pr_err("failed to clear the receive status\n");
  267. }
  268. /* Since the device can only handle one time stamp at a time,
  269. * we purge any extra frames from the queue.
  270. */
  271. for ( ; skb; skb = __skb_dequeue(&received)) {
  272. if (mv88e6xxx_ts_valid(status) && seq_match(skb, seq_id)) {
  273. ns = timehi << 16 | timelo;
  274. mutex_lock(&chip->reg_lock);
  275. ns = timecounter_cyc2time(&chip->tstamp_tc, ns);
  276. mutex_unlock(&chip->reg_lock);
  277. shwt = skb_hwtstamps(skb);
  278. memset(shwt, 0, sizeof(*shwt));
  279. shwt->hwtstamp = ns_to_ktime(ns);
  280. status &= ~MV88E6XXX_PTP_TS_VALID;
  281. }
  282. netif_rx_ni(skb);
  283. }
  284. }
  285. static void mv88e6xxx_rxtstamp_work(struct mv88e6xxx_chip *chip,
  286. struct mv88e6xxx_port_hwtstamp *ps)
  287. {
  288. struct sk_buff *skb;
  289. skb = skb_dequeue(&ps->rx_queue);
  290. if (skb)
  291. mv88e6xxx_get_rxts(chip, ps, skb, MV88E6XXX_PORT_PTP_ARR0_STS,
  292. &ps->rx_queue);
  293. skb = skb_dequeue(&ps->rx_queue2);
  294. if (skb)
  295. mv88e6xxx_get_rxts(chip, ps, skb, MV88E6XXX_PORT_PTP_ARR1_STS,
  296. &ps->rx_queue2);
  297. }
  298. static int is_pdelay_resp(u8 *msgtype)
  299. {
  300. return (*msgtype & 0xf) == 3;
  301. }
  302. bool mv88e6xxx_port_rxtstamp(struct dsa_switch *ds, int port,
  303. struct sk_buff *skb, unsigned int type)
  304. {
  305. struct mv88e6xxx_port_hwtstamp *ps;
  306. struct mv88e6xxx_chip *chip;
  307. u8 *hdr;
  308. chip = ds->priv;
  309. ps = &chip->port_hwtstamp[port];
  310. if (ps->tstamp_config.rx_filter != HWTSTAMP_FILTER_PTP_V2_EVENT)
  311. return false;
  312. hdr = mv88e6xxx_should_tstamp(chip, port, skb, type);
  313. if (!hdr)
  314. return false;
  315. SKB_PTP_TYPE(skb) = type;
  316. if (is_pdelay_resp(hdr))
  317. skb_queue_tail(&ps->rx_queue2, skb);
  318. else
  319. skb_queue_tail(&ps->rx_queue, skb);
  320. ptp_schedule_worker(chip->ptp_clock, 0);
  321. return true;
  322. }
  323. static int mv88e6xxx_txtstamp_work(struct mv88e6xxx_chip *chip,
  324. struct mv88e6xxx_port_hwtstamp *ps)
  325. {
  326. struct skb_shared_hwtstamps shhwtstamps;
  327. u16 departure_block[4], status;
  328. struct sk_buff *tmp_skb;
  329. u32 time_raw;
  330. int err;
  331. u64 ns;
  332. if (!ps->tx_skb)
  333. return 0;
  334. mutex_lock(&chip->reg_lock);
  335. err = mv88e6xxx_port_ptp_read(chip, ps->port_id,
  336. MV88E6XXX_PORT_PTP_DEP_STS,
  337. departure_block,
  338. ARRAY_SIZE(departure_block));
  339. mutex_unlock(&chip->reg_lock);
  340. if (err)
  341. goto free_and_clear_skb;
  342. if (!(departure_block[0] & MV88E6XXX_PTP_TS_VALID)) {
  343. if (time_is_before_jiffies(ps->tx_tstamp_start +
  344. TX_TSTAMP_TIMEOUT)) {
  345. dev_warn(chip->dev, "p%d: clearing tx timestamp hang\n",
  346. ps->port_id);
  347. goto free_and_clear_skb;
  348. }
  349. /* The timestamp should be available quickly, while getting it
  350. * is high priority and time bounded to only 10ms. A poll is
  351. * warranted so restart the work.
  352. */
  353. return 1;
  354. }
  355. /* We have the timestamp; go ahead and clear valid now */
  356. mutex_lock(&chip->reg_lock);
  357. mv88e6xxx_port_ptp_write(chip, ps->port_id,
  358. MV88E6XXX_PORT_PTP_DEP_STS, 0);
  359. mutex_unlock(&chip->reg_lock);
  360. status = departure_block[0] & MV88E6XXX_PTP_TS_STATUS_MASK;
  361. if (status != MV88E6XXX_PTP_TS_STATUS_NORMAL) {
  362. dev_warn(chip->dev, "p%d: tx timestamp overrun\n", ps->port_id);
  363. goto free_and_clear_skb;
  364. }
  365. if (departure_block[3] != ps->tx_seq_id) {
  366. dev_warn(chip->dev, "p%d: unexpected seq. id\n", ps->port_id);
  367. goto free_and_clear_skb;
  368. }
  369. memset(&shhwtstamps, 0, sizeof(shhwtstamps));
  370. time_raw = ((u32)departure_block[2] << 16) | departure_block[1];
  371. mutex_lock(&chip->reg_lock);
  372. ns = timecounter_cyc2time(&chip->tstamp_tc, time_raw);
  373. mutex_unlock(&chip->reg_lock);
  374. shhwtstamps.hwtstamp = ns_to_ktime(ns);
  375. dev_dbg(chip->dev,
  376. "p%d: txtstamp %llx status 0x%04x skb ID 0x%04x hw ID 0x%04x\n",
  377. ps->port_id, ktime_to_ns(shhwtstamps.hwtstamp),
  378. departure_block[0], ps->tx_seq_id, departure_block[3]);
  379. /* skb_complete_tx_timestamp() will free up the client to make
  380. * another timestamp-able transmit. We have to be ready for it
  381. * -- by clearing the ps->tx_skb "flag" -- beforehand.
  382. */
  383. tmp_skb = ps->tx_skb;
  384. ps->tx_skb = NULL;
  385. clear_bit_unlock(MV88E6XXX_HWTSTAMP_TX_IN_PROGRESS, &ps->state);
  386. skb_complete_tx_timestamp(tmp_skb, &shhwtstamps);
  387. return 0;
  388. free_and_clear_skb:
  389. dev_kfree_skb_any(ps->tx_skb);
  390. ps->tx_skb = NULL;
  391. clear_bit_unlock(MV88E6XXX_HWTSTAMP_TX_IN_PROGRESS, &ps->state);
  392. return 0;
  393. }
  394. long mv88e6xxx_hwtstamp_work(struct ptp_clock_info *ptp)
  395. {
  396. struct mv88e6xxx_chip *chip = ptp_to_chip(ptp);
  397. struct dsa_switch *ds = chip->ds;
  398. struct mv88e6xxx_port_hwtstamp *ps;
  399. int i, restart = 0;
  400. for (i = 0; i < ds->num_ports; i++) {
  401. if (!dsa_is_user_port(ds, i))
  402. continue;
  403. ps = &chip->port_hwtstamp[i];
  404. if (test_bit(MV88E6XXX_HWTSTAMP_TX_IN_PROGRESS, &ps->state))
  405. restart |= mv88e6xxx_txtstamp_work(chip, ps);
  406. mv88e6xxx_rxtstamp_work(chip, ps);
  407. }
  408. return restart ? 1 : -1;
  409. }
  410. bool mv88e6xxx_port_txtstamp(struct dsa_switch *ds, int port,
  411. struct sk_buff *clone, unsigned int type)
  412. {
  413. struct mv88e6xxx_chip *chip = ds->priv;
  414. struct mv88e6xxx_port_hwtstamp *ps = &chip->port_hwtstamp[port];
  415. __be16 *seq_ptr;
  416. u8 *hdr;
  417. if (!(skb_shinfo(clone)->tx_flags & SKBTX_HW_TSTAMP))
  418. return false;
  419. hdr = mv88e6xxx_should_tstamp(chip, port, clone, type);
  420. if (!hdr)
  421. return false;
  422. seq_ptr = (__be16 *)(hdr + OFF_PTP_SEQUENCE_ID);
  423. if (test_and_set_bit_lock(MV88E6XXX_HWTSTAMP_TX_IN_PROGRESS,
  424. &ps->state))
  425. return false;
  426. ps->tx_skb = clone;
  427. ps->tx_tstamp_start = jiffies;
  428. ps->tx_seq_id = be16_to_cpup(seq_ptr);
  429. ptp_schedule_worker(chip->ptp_clock, 0);
  430. return true;
  431. }
  432. static int mv88e6xxx_hwtstamp_port_setup(struct mv88e6xxx_chip *chip, int port)
  433. {
  434. struct mv88e6xxx_port_hwtstamp *ps = &chip->port_hwtstamp[port];
  435. ps->port_id = port;
  436. skb_queue_head_init(&ps->rx_queue);
  437. skb_queue_head_init(&ps->rx_queue2);
  438. return mv88e6xxx_port_ptp_write(chip, port, MV88E6XXX_PORT_PTP_CFG0,
  439. MV88E6XXX_PORT_PTP_CFG0_DISABLE_PTP);
  440. }
  441. int mv88e6xxx_hwtstamp_setup(struct mv88e6xxx_chip *chip)
  442. {
  443. int err;
  444. int i;
  445. /* Disable timestamping on all ports. */
  446. for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
  447. err = mv88e6xxx_hwtstamp_port_setup(chip, i);
  448. if (err)
  449. return err;
  450. }
  451. /* MV88E6XXX_PTP_MSG_TYPE is a mask of PTP message types to
  452. * timestamp. This affects all ports that have timestamping enabled,
  453. * but the timestamp config is per-port; thus we configure all events
  454. * here and only support the HWTSTAMP_FILTER_*_EVENT filter types.
  455. */
  456. err = mv88e6xxx_ptp_write(chip, MV88E6XXX_PTP_MSGTYPE,
  457. MV88E6XXX_PTP_MSGTYPE_ALL_EVENT);
  458. if (err)
  459. return err;
  460. /* Use ARRIVAL1 for peer delay response messages. */
  461. err = mv88e6xxx_ptp_write(chip, MV88E6XXX_PTP_TS_ARRIVAL_PTR,
  462. MV88E6XXX_PTP_MSGTYPE_PDLAY_RES);
  463. if (err)
  464. return err;
  465. /* 88E6341 devices default to timestamping at the PHY, but this has
  466. * a hardware issue that results in unreliable timestamps. Force
  467. * these devices to timestamp at the MAC.
  468. */
  469. if (chip->info->family == MV88E6XXX_FAMILY_6341) {
  470. u16 val = MV88E6341_PTP_CFG_UPDATE |
  471. MV88E6341_PTP_CFG_MODE_IDX |
  472. MV88E6341_PTP_CFG_MODE_TS_AT_MAC;
  473. err = mv88e6xxx_ptp_write(chip, MV88E6341_PTP_CFG, val);
  474. if (err)
  475. return err;
  476. }
  477. return 0;
  478. }
  479. void mv88e6xxx_hwtstamp_free(struct mv88e6xxx_chip *chip)
  480. {
  481. }