diff options
author | Martin Habets <mhabets@solarflare.com> | 2018-01-25 12:25:15 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-01-25 16:05:14 -0500 |
commit | 23418dc131464ffe29c9ac2d71cf95bf2883fc4f (patch) | |
tree | 00d9a768627f0960913a007e371fb840b1345862 | |
parent | 9c3afb33ae587723d2acda044a352670ec8d5b82 (diff) |
sfc: use main datapath for HW timestamps if available
We can now transmit SKBs in 2 ways:
1. Via the MC (for the 7XXX series and earlier), using
efx_ptp_xmit_skb_mc().
2. Via the TX queues on the dedicated PTP channel (8XXX series and later),
using efx_ptp_xmit_skb_queue().
The PTP worker thread uses the method set up at probe time. It never
checked the return code from the old efx_ptp_xmit_skb(), so it now
returns void.
We increment the TX dropped counter of the device if the transmit fails.
As a result of the probe per channel the remove gets called multiple times.
Clean up efx->ptp_data properly to avoid the 2nd call blowing up.
Signed-off-by: Martin Habets <mhabets@solarflare.com>
Signed-off-by: Edward Cree <ecree@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/sfc/ef10.c | 9 | ||||
-rw-r--r-- | drivers/net/ethernet/sfc/ptp.c | 48 |
2 files changed, 42 insertions, 15 deletions
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c index 774e9cd14302..6deef607a914 100644 --- a/drivers/net/ethernet/sfc/ef10.c +++ b/drivers/net/ethernet/sfc/ef10.c | |||
@@ -760,14 +760,7 @@ static int efx_ef10_probe(struct efx_nic *efx) | |||
760 | if (rc && rc != -EPERM) | 760 | if (rc && rc != -EPERM) |
761 | goto fail5; | 761 | goto fail5; |
762 | 762 | ||
763 | rc = efx_ptp_probe(efx, NULL); | 763 | efx_ptp_defer_probe_with_channel(efx); |
764 | /* Failure to probe PTP is not fatal. | ||
765 | * In the case of EPERM, efx_ptp_probe will print its own message (in | ||
766 | * efx_ptp_get_attributes()), so we don't need to. | ||
767 | */ | ||
768 | if (rc && rc != -EPERM) | ||
769 | netif_warn(efx, drv, efx->net_dev, | ||
770 | "Failed to probe PTP, rc=%d\n", rc); | ||
771 | 764 | ||
772 | #ifdef CONFIG_SFC_SRIOV | 765 | #ifdef CONFIG_SFC_SRIOV |
773 | if ((efx->pci_dev->physfn) && (!efx->pci_dev->is_physfn)) { | 766 | if ((efx->pci_dev->physfn) && (!efx->pci_dev->is_physfn)) { |
diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c index 096b2f7a4835..7f877312c646 100644 --- a/drivers/net/ethernet/sfc/ptp.c +++ b/drivers/net/ethernet/sfc/ptp.c | |||
@@ -218,8 +218,8 @@ struct efx_ptp_timeset { | |||
218 | * @channel: The PTP channel (Siena only) | 218 | * @channel: The PTP channel (Siena only) |
219 | * @rx_ts_inline: Flag for whether RX timestamps are inline (else they are | 219 | * @rx_ts_inline: Flag for whether RX timestamps are inline (else they are |
220 | * separate events) | 220 | * separate events) |
221 | * @rxq: Receive queue (awaiting timestamps) | 221 | * @rxq: Receive SKB queue (awaiting timestamps) |
222 | * @txq: Transmit queue | 222 | * @txq: Transmit SKB queue |
223 | * @evt_list: List of MC receive events awaiting packets | 223 | * @evt_list: List of MC receive events awaiting packets |
224 | * @evt_free_list: List of free events | 224 | * @evt_free_list: List of free events |
225 | * @evt_lock: Lock for manipulating evt_list and evt_free_list | 225 | * @evt_lock: Lock for manipulating evt_list and evt_free_list |
@@ -264,6 +264,7 @@ struct efx_ptp_timeset { | |||
264 | * @oversize_sync_windows: Number of corrected sync windows that are too large | 264 | * @oversize_sync_windows: Number of corrected sync windows that are too large |
265 | * @rx_no_timestamp: Number of packets received without a timestamp. | 265 | * @rx_no_timestamp: Number of packets received without a timestamp. |
266 | * @timeset: Last set of synchronisation statistics. | 266 | * @timeset: Last set of synchronisation statistics. |
267 | * @xmit_skb: Transmit SKB function. | ||
267 | */ | 268 | */ |
268 | struct efx_ptp_data { | 269 | struct efx_ptp_data { |
269 | struct efx_nic *efx; | 270 | struct efx_nic *efx; |
@@ -319,6 +320,7 @@ struct efx_ptp_data { | |||
319 | unsigned int rx_no_timestamp; | 320 | unsigned int rx_no_timestamp; |
320 | struct efx_ptp_timeset | 321 | struct efx_ptp_timeset |
321 | timeset[MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_MAXNUM]; | 322 | timeset[MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_MAXNUM]; |
323 | void (*xmit_skb)(struct efx_nic *efx, struct sk_buff *skb); | ||
322 | }; | 324 | }; |
323 | 325 | ||
324 | static int efx_phc_adjfreq(struct ptp_clock_info *ptp, s32 delta); | 326 | static int efx_phc_adjfreq(struct ptp_clock_info *ptp, s32 delta); |
@@ -894,8 +896,24 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings) | |||
894 | return rc; | 896 | return rc; |
895 | } | 897 | } |
896 | 898 | ||
899 | /* Transmit a PTP packet via the dedicated hardware timestamped queue. */ | ||
900 | static void efx_ptp_xmit_skb_queue(struct efx_nic *efx, struct sk_buff *skb) | ||
901 | { | ||
902 | struct efx_ptp_data *ptp_data = efx->ptp_data; | ||
903 | struct efx_tx_queue *tx_queue; | ||
904 | u8 type = skb->ip_summed == CHECKSUM_PARTIAL ? EFX_TXQ_TYPE_OFFLOAD : 0; | ||
905 | |||
906 | tx_queue = &ptp_data->channel->tx_queue[type]; | ||
907 | if (tx_queue && tx_queue->timestamping) { | ||
908 | efx_enqueue_skb(tx_queue, skb); | ||
909 | } else { | ||
910 | WARN_ONCE(1, "PTP channel has no timestamped tx queue\n"); | ||
911 | dev_kfree_skb_any(skb); | ||
912 | } | ||
913 | } | ||
914 | |||
897 | /* Transmit a PTP packet, via the MCDI interface, to the wire. */ | 915 | /* Transmit a PTP packet, via the MCDI interface, to the wire. */ |
898 | static int efx_ptp_xmit_skb(struct efx_nic *efx, struct sk_buff *skb) | 916 | static void efx_ptp_xmit_skb_mc(struct efx_nic *efx, struct sk_buff *skb) |
899 | { | 917 | { |
900 | struct efx_ptp_data *ptp_data = efx->ptp_data; | 918 | struct efx_ptp_data *ptp_data = efx->ptp_data; |
901 | struct skb_shared_hwtstamps timestamps; | 919 | struct skb_shared_hwtstamps timestamps; |
@@ -938,9 +956,9 @@ static int efx_ptp_xmit_skb(struct efx_nic *efx, struct sk_buff *skb) | |||
938 | rc = 0; | 956 | rc = 0; |
939 | 957 | ||
940 | fail: | 958 | fail: |
941 | dev_kfree_skb(skb); | 959 | dev_kfree_skb_any(skb); |
942 | 960 | ||
943 | return rc; | 961 | return; |
944 | } | 962 | } |
945 | 963 | ||
946 | static void efx_ptp_drop_time_expired_events(struct efx_nic *efx) | 964 | static void efx_ptp_drop_time_expired_events(struct efx_nic *efx) |
@@ -1210,7 +1228,7 @@ static void efx_ptp_worker(struct work_struct *work) | |||
1210 | efx_ptp_process_events(efx, &tempq); | 1228 | efx_ptp_process_events(efx, &tempq); |
1211 | 1229 | ||
1212 | while ((skb = skb_dequeue(&ptp_data->txq))) | 1230 | while ((skb = skb_dequeue(&ptp_data->txq))) |
1213 | efx_ptp_xmit_skb(efx, skb); | 1231 | ptp_data->xmit_skb(efx, skb); |
1214 | 1232 | ||
1215 | while ((skb = __skb_dequeue(&tempq))) | 1233 | while ((skb = __skb_dequeue(&tempq))) |
1216 | efx_ptp_process_rx(efx, skb); | 1234 | efx_ptp_process_rx(efx, skb); |
@@ -1260,6 +1278,11 @@ int efx_ptp_probe(struct efx_nic *efx, struct efx_channel *channel) | |||
1260 | goto fail2; | 1278 | goto fail2; |
1261 | } | 1279 | } |
1262 | 1280 | ||
1281 | if (efx_ptp_use_mac_tx_timestamps(efx)) | ||
1282 | ptp->xmit_skb = efx_ptp_xmit_skb_queue; | ||
1283 | else | ||
1284 | ptp->xmit_skb = efx_ptp_xmit_skb_mc; | ||
1285 | |||
1263 | INIT_WORK(&ptp->work, efx_ptp_worker); | 1286 | INIT_WORK(&ptp->work, efx_ptp_worker); |
1264 | ptp->config.flags = 0; | 1287 | ptp->config.flags = 0; |
1265 | ptp->config.tx_type = HWTSTAMP_TX_OFF; | 1288 | ptp->config.tx_type = HWTSTAMP_TX_OFF; |
@@ -1324,11 +1347,21 @@ fail1: | |||
1324 | static int efx_ptp_probe_channel(struct efx_channel *channel) | 1347 | static int efx_ptp_probe_channel(struct efx_channel *channel) |
1325 | { | 1348 | { |
1326 | struct efx_nic *efx = channel->efx; | 1349 | struct efx_nic *efx = channel->efx; |
1350 | int rc; | ||
1327 | 1351 | ||
1328 | channel->irq_moderation_us = 0; | 1352 | channel->irq_moderation_us = 0; |
1329 | channel->rx_queue.core_index = 0; | 1353 | channel->rx_queue.core_index = 0; |
1330 | 1354 | ||
1331 | return efx_ptp_probe(efx, channel); | 1355 | rc = efx_ptp_probe(efx, channel); |
1356 | /* Failure to probe PTP is not fatal; this channel will just not be | ||
1357 | * used for anything. | ||
1358 | * In the case of EPERM, efx_ptp_probe will print its own message (in | ||
1359 | * efx_ptp_get_attributes()), so we don't need to. | ||
1360 | */ | ||
1361 | if (rc && rc != -EPERM) | ||
1362 | netif_warn(efx, drv, efx->net_dev, | ||
1363 | "Failed to probe PTP, rc=%d\n", rc); | ||
1364 | return 0; | ||
1332 | } | 1365 | } |
1333 | 1366 | ||
1334 | void efx_ptp_remove(struct efx_nic *efx) | 1367 | void efx_ptp_remove(struct efx_nic *efx) |
@@ -1353,6 +1386,7 @@ void efx_ptp_remove(struct efx_nic *efx) | |||
1353 | 1386 | ||
1354 | efx_nic_free_buffer(efx, &efx->ptp_data->start); | 1387 | efx_nic_free_buffer(efx, &efx->ptp_data->start); |
1355 | kfree(efx->ptp_data); | 1388 | kfree(efx->ptp_data); |
1389 | efx->ptp_data = NULL; | ||
1356 | } | 1390 | } |
1357 | 1391 | ||
1358 | static void efx_ptp_remove_channel(struct efx_channel *channel) | 1392 | static void efx_ptp_remove_channel(struct efx_channel *channel) |