Commit f3211600 authored by Laurence Evans's avatar Laurence Evans Committed by Ben Hutchings

sfc: PTP: Moderate log message on event queue overflow

Limit syslog flood if a PTP packet storm occurs.

Fixes: 7c236c43 ('sfc: Add support for IEEE-1588 PTP')
Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
parent e5a498e9
...@@ -220,6 +220,7 @@ struct efx_ptp_timeset { ...@@ -220,6 +220,7 @@ struct efx_ptp_timeset {
* @evt_list: List of MC receive events awaiting packets * @evt_list: List of MC receive events awaiting packets
* @evt_free_list: List of free events * @evt_free_list: List of free events
* @evt_lock: Lock for manipulating evt_list and evt_free_list * @evt_lock: Lock for manipulating evt_list and evt_free_list
* @evt_overflow: Boolean indicating that event list has overflowed
* @rx_evts: Instantiated events (on evt_list and evt_free_list) * @rx_evts: Instantiated events (on evt_list and evt_free_list)
* @workwq: Work queue for processing pending PTP operations * @workwq: Work queue for processing pending PTP operations
* @work: Work task * @work: Work task
...@@ -270,6 +271,7 @@ struct efx_ptp_data { ...@@ -270,6 +271,7 @@ struct efx_ptp_data {
struct list_head evt_list; struct list_head evt_list;
struct list_head evt_free_list; struct list_head evt_free_list;
spinlock_t evt_lock; spinlock_t evt_lock;
bool evt_overflow;
struct efx_ptp_event_rx rx_evts[MAX_RECEIVE_EVENTS]; struct efx_ptp_event_rx rx_evts[MAX_RECEIVE_EVENTS];
struct workqueue_struct *workwq; struct workqueue_struct *workwq;
struct work_struct work; struct work_struct work;
...@@ -635,6 +637,11 @@ static void efx_ptp_drop_time_expired_events(struct efx_nic *efx) ...@@ -635,6 +637,11 @@ static void efx_ptp_drop_time_expired_events(struct efx_nic *efx)
} }
} }
} }
/* If the event overflow flag is set and the event list is now empty
* clear the flag to re-enable the overflow warning message.
*/
if (ptp->evt_overflow && list_empty(&ptp->evt_list))
ptp->evt_overflow = false;
spin_unlock_bh(&ptp->evt_lock); spin_unlock_bh(&ptp->evt_lock);
} }
...@@ -676,6 +683,11 @@ static enum ptp_packet_state efx_ptp_match_rx(struct efx_nic *efx, ...@@ -676,6 +683,11 @@ static enum ptp_packet_state efx_ptp_match_rx(struct efx_nic *efx,
break; break;
} }
} }
/* If the event overflow flag is set and the event list is now empty
* clear the flag to re-enable the overflow warning message.
*/
if (ptp->evt_overflow && list_empty(&ptp->evt_list))
ptp->evt_overflow = false;
spin_unlock_bh(&ptp->evt_lock); spin_unlock_bh(&ptp->evt_lock);
return rc; return rc;
...@@ -809,6 +821,7 @@ static int efx_ptp_stop(struct efx_nic *efx) ...@@ -809,6 +821,7 @@ static int efx_ptp_stop(struct efx_nic *efx)
list_for_each_safe(cursor, next, &efx->ptp_data->evt_list) { list_for_each_safe(cursor, next, &efx->ptp_data->evt_list) {
list_move(cursor, &efx->ptp_data->evt_free_list); list_move(cursor, &efx->ptp_data->evt_free_list);
} }
ptp->evt_overflow = false;
spin_unlock_bh(&efx->ptp_data->evt_lock); spin_unlock_bh(&efx->ptp_data->evt_lock);
return rc; return rc;
...@@ -901,6 +914,7 @@ static int efx_ptp_probe_channel(struct efx_channel *channel) ...@@ -901,6 +914,7 @@ static int efx_ptp_probe_channel(struct efx_channel *channel)
spin_lock_init(&ptp->evt_lock); spin_lock_init(&ptp->evt_lock);
for (pos = 0; pos < MAX_RECEIVE_EVENTS; pos++) for (pos = 0; pos < MAX_RECEIVE_EVENTS; pos++)
list_add(&ptp->rx_evts[pos].link, &ptp->evt_free_list); list_add(&ptp->rx_evts[pos].link, &ptp->evt_free_list);
ptp->evt_overflow = false;
ptp->phc_clock_info.owner = THIS_MODULE; ptp->phc_clock_info.owner = THIS_MODULE;
snprintf(ptp->phc_clock_info.name, snprintf(ptp->phc_clock_info.name,
...@@ -1299,8 +1313,13 @@ static void ptp_event_rx(struct efx_nic *efx, struct efx_ptp_data *ptp) ...@@ -1299,8 +1313,13 @@ static void ptp_event_rx(struct efx_nic *efx, struct efx_ptp_data *ptp)
list_add_tail(&evt->link, &ptp->evt_list); list_add_tail(&evt->link, &ptp->evt_list);
queue_work(ptp->workwq, &ptp->work); queue_work(ptp->workwq, &ptp->work);
} else { } else if (!ptp->evt_overflow) {
netif_err(efx, rx_err, efx->net_dev, "No free PTP event"); /* Log a warning message and set the event overflow flag.
* The message won't be logged again until the event queue
* becomes empty.
*/
netif_err(efx, rx_err, efx->net_dev, "PTP event queue overflow\n");
ptp->evt_overflow = true;
} }
spin_unlock_bh(&ptp->evt_lock); spin_unlock_bh(&ptp->evt_lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment