Lines Matching +full:port +full:- +full:config
1 // SPDX-License-Identifier: (GPL-2.0 OR MIT)
8 * Authors: Kamil Alkhouri <kamil.alkhouri@hs-offenburg.de>
18 int hellcreek_get_ts_info(struct dsa_switch *ds, int port, in hellcreek_get_ts_info() argument
21 struct hellcreek *hellcreek = ds->priv; in hellcreek_get_ts_info()
23 info->phc_index = hellcreek->ptp_clock ? in hellcreek_get_ts_info()
24 ptp_clock_index(hellcreek->ptp_clock) : -1; in hellcreek_get_ts_info()
25 info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | in hellcreek_get_ts_info()
30 info->tx_types = BIT(HWTSTAMP_TX_ON); in hellcreek_get_ts_info()
33 info->rx_filters = BIT(HWTSTAMP_FILTER_PTP_V2_EVENT); in hellcreek_get_ts_info()
42 static int hellcreek_set_hwtstamp_config(struct hellcreek *hellcreek, int port, in hellcreek_set_hwtstamp_config() argument
43 struct hwtstamp_config *config) in hellcreek_set_hwtstamp_config() argument
46 &hellcreek->ports[port].port_hwtstamp; in hellcreek_set_hwtstamp_config()
51 * enabled when this config function ends successfully in hellcreek_set_hwtstamp_config()
53 clear_bit_unlock(HELLCREEK_HWTSTAMP_ENABLED, &ps->state); in hellcreek_set_hwtstamp_config()
55 switch (config->tx_type) { in hellcreek_set_hwtstamp_config()
62 config->tx_type = HWTSTAMP_TX_ON; in hellcreek_set_hwtstamp_config()
66 return -ERANGE; in hellcreek_set_hwtstamp_config()
69 switch (config->rx_filter) { in hellcreek_set_hwtstamp_config()
72 config->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; in hellcreek_set_hwtstamp_config()
84 config->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; in hellcreek_set_hwtstamp_config()
90 config->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; in hellcreek_set_hwtstamp_config()
94 return -ERANGE; in hellcreek_set_hwtstamp_config()
98 return -ERANGE; in hellcreek_set_hwtstamp_config()
101 return -ERANGE; in hellcreek_set_hwtstamp_config()
103 /* If this point is reached, then the requested hwtstamp config is in hellcreek_set_hwtstamp_config()
107 set_bit(HELLCREEK_HWTSTAMP_ENABLED, &ps->state); in hellcreek_set_hwtstamp_config()
112 int hellcreek_port_hwtstamp_set(struct dsa_switch *ds, int port, in hellcreek_port_hwtstamp_set() argument
115 struct hellcreek *hellcreek = ds->priv; in hellcreek_port_hwtstamp_set()
117 struct hwtstamp_config config; in hellcreek_port_hwtstamp_set() local
120 ps = &hellcreek->ports[port].port_hwtstamp; in hellcreek_port_hwtstamp_set()
122 if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) in hellcreek_port_hwtstamp_set()
123 return -EFAULT; in hellcreek_port_hwtstamp_set()
125 err = hellcreek_set_hwtstamp_config(hellcreek, port, &config); in hellcreek_port_hwtstamp_set()
130 memcpy(&ps->tstamp_config, &config, sizeof(config)); in hellcreek_port_hwtstamp_set()
132 return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? in hellcreek_port_hwtstamp_set()
133 -EFAULT : 0; in hellcreek_port_hwtstamp_set()
136 int hellcreek_port_hwtstamp_get(struct dsa_switch *ds, int port, in hellcreek_port_hwtstamp_get() argument
139 struct hellcreek *hellcreek = ds->priv; in hellcreek_port_hwtstamp_get()
141 struct hwtstamp_config *config; in hellcreek_port_hwtstamp_get() local
143 ps = &hellcreek->ports[port].port_hwtstamp; in hellcreek_port_hwtstamp_get()
144 config = &ps->tstamp_config; in hellcreek_port_hwtstamp_get()
146 return copy_to_user(ifr->ifr_data, config, sizeof(*config)) ? in hellcreek_port_hwtstamp_get()
147 -EFAULT : 0; in hellcreek_port_hwtstamp_get()
154 int port, struct sk_buff *skb, in hellcreek_should_tstamp() argument
158 &hellcreek->ports[port].port_hwtstamp; in hellcreek_should_tstamp()
165 if (!test_bit(HELLCREEK_HWTSTAMP_ENABLED, &ps->state)) in hellcreek_should_tstamp()
173 return be32_to_cpu(hdr->reserved2); in hellcreek_get_reserved_field()
178 hdr->reserved2 = 0; in hellcreek_clear_reserved_field()
189 dev_err(hellcreek->dev, in hellcreek_ptp_hwtstamp_available()
214 struct hellcreek_port_hwtstamp *ps, int port) in hellcreek_txtstamp_work() argument
222 if (!ps->tx_skb) in hellcreek_txtstamp_work()
225 switch (port) { in hellcreek_txtstamp_work()
235 dev_err(hellcreek->dev, "Wrong port for timestamping!\n"); in hellcreek_txtstamp_work()
246 if (time_is_before_jiffies(ps->tx_tstamp_start + in hellcreek_txtstamp_work()
248 dev_err(hellcreek->dev, in hellcreek_txtstamp_work()
259 mutex_lock(&hellcreek->ptp_lock); in hellcreek_txtstamp_work()
262 mutex_unlock(&hellcreek->ptp_lock); in hellcreek_txtstamp_work()
270 tmp_skb = ps->tx_skb; in hellcreek_txtstamp_work()
271 ps->tx_skb = NULL; in hellcreek_txtstamp_work()
275 * ps->tx_skb "flag" beforehand in hellcreek_txtstamp_work()
277 clear_bit_unlock(HELLCREEK_HWTSTAMP_TX_IN_PROGRESS, &ps->state); in hellcreek_txtstamp_work()
285 dev_kfree_skb_any(ps->tx_skb); in hellcreek_txtstamp_work()
286 ps->tx_skb = NULL; in hellcreek_txtstamp_work()
287 clear_bit_unlock(HELLCREEK_HWTSTAMP_TX_IN_PROGRESS, &ps->state); in hellcreek_txtstamp_work()
295 int port) in hellcreek_get_rxts() argument
303 spin_lock_irqsave(&rxq->lock, flags); in hellcreek_get_rxts()
305 spin_unlock_irqrestore(&rxq->lock, flags); in hellcreek_get_rxts()
319 mutex_lock(&hellcreek->ptp_lock); in hellcreek_get_rxts()
321 mutex_unlock(&hellcreek->ptp_lock); in hellcreek_get_rxts()
326 shwt->hwtstamp = ns_to_ktime(ns); in hellcreek_get_rxts()
333 int port) in hellcreek_rxtstamp_work() argument
337 skb = skb_dequeue(&ps->rx_queue); in hellcreek_rxtstamp_work()
339 hellcreek_get_rxts(hellcreek, ps, skb, &ps->rx_queue, port); in hellcreek_rxtstamp_work()
345 struct dsa_switch *ds = hellcreek->ds; in hellcreek_hwtstamp_work()
348 for (i = 0; i < ds->num_ports; i++) { in hellcreek_hwtstamp_work()
354 ps = &hellcreek->ports[i].port_hwtstamp; in hellcreek_hwtstamp_work()
356 if (test_bit(HELLCREEK_HWTSTAMP_TX_IN_PROGRESS, &ps->state)) in hellcreek_hwtstamp_work()
362 return restart ? 1 : -1; in hellcreek_hwtstamp_work()
365 void hellcreek_port_txtstamp(struct dsa_switch *ds, int port, in hellcreek_port_txtstamp() argument
368 struct hellcreek *hellcreek = ds->priv; in hellcreek_port_txtstamp()
374 ps = &hellcreek->ports[port].port_hwtstamp; in hellcreek_port_txtstamp()
384 hdr = hellcreek_should_tstamp(hellcreek, port, skb, type); in hellcreek_port_txtstamp()
393 &ps->state)) { in hellcreek_port_txtstamp()
398 ps->tx_skb = clone; in hellcreek_port_txtstamp()
400 /* store the number of ticks occurred since system start-up till this in hellcreek_port_txtstamp()
403 ps->tx_tstamp_start = jiffies; in hellcreek_port_txtstamp()
405 ptp_schedule_worker(hellcreek->ptp_clock, 0); in hellcreek_port_txtstamp()
408 bool hellcreek_port_rxtstamp(struct dsa_switch *ds, int port, in hellcreek_port_rxtstamp() argument
411 struct hellcreek *hellcreek = ds->priv; in hellcreek_port_rxtstamp()
415 ps = &hellcreek->ports[port].port_hwtstamp; in hellcreek_port_rxtstamp()
420 if (ps->tstamp_config.rx_filter != HWTSTAMP_FILTER_PTP_V2_EVENT) in hellcreek_port_rxtstamp()
427 hdr = hellcreek_should_tstamp(hellcreek, port, skb, type); in hellcreek_port_rxtstamp()
433 skb_queue_tail(&ps->rx_queue, skb); in hellcreek_port_rxtstamp()
435 ptp_schedule_worker(hellcreek->ptp_clock, 0); in hellcreek_port_rxtstamp()
440 static void hellcreek_hwtstamp_port_setup(struct hellcreek *hellcreek, int port) in hellcreek_hwtstamp_port_setup() argument
443 &hellcreek->ports[port].port_hwtstamp; in hellcreek_hwtstamp_port_setup()
445 skb_queue_head_init(&ps->rx_queue); in hellcreek_hwtstamp_port_setup()
450 struct dsa_switch *ds = hellcreek->ds; in hellcreek_hwtstamp_setup()
454 for (i = 0; i < ds->num_ports; ++i) { in hellcreek_hwtstamp_setup()