Lines Matching +full:cpsw +full:- +full:switch

1 // SPDX-License-Identifier: GPL-2.0
3 * Texas Instruments Ethernet Switch Driver ethtool intf
18 #include "cpsw.h"
111 { "Rx + Tx 65-127 Octet Frames", CPSW_STAT(octetframes65t127) },
112 { "Rx + Tx 128-255 Octet Frames", CPSW_STAT(octetframes128t255) },
113 { "Rx + Tx 256-511 Octet Frames", CPSW_STAT(octetframes256t511) },
114 { "Rx + Tx 512-1023 Octet Frames", CPSW_STAT(octetframes512t1023) },
115 { "Rx + Tx 1024-Up Octet Frames", CPSW_STAT(octetframes1024tup) },
145 return priv->msg_enable; in cpsw_get_msglevel()
152 priv->msg_enable = value; in cpsw_set_msglevel()
157 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_get_coalesce() local
159 coal->rx_coalesce_usecs = cpsw->coal_intvl; in cpsw_get_coalesce()
171 struct cpsw_common *cpsw = priv->cpsw; in cpsw_set_coalesce() local
173 coal_intvl = coal->rx_coalesce_usecs; in cpsw_set_coalesce()
175 int_ctrl = readl(&cpsw->wr_regs->int_control); in cpsw_set_coalesce()
176 prescale = cpsw->bus_freq_mhz * 4; in cpsw_set_coalesce()
178 if (!coal->rx_coalesce_usecs) { in cpsw_set_coalesce()
204 writel(num_interrupts, &cpsw->wr_regs->rx_imax); in cpsw_set_coalesce()
205 writel(num_interrupts, &cpsw->wr_regs->tx_imax); in cpsw_set_coalesce()
212 writel(int_ctrl, &cpsw->wr_regs->int_control); in cpsw_set_coalesce()
215 cpsw->coal_intvl = coal_intvl; in cpsw_set_coalesce()
222 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_get_sset_count() local
224 switch (sset) { in cpsw_get_sset_count()
227 (cpsw->rx_ch_num + cpsw->tx_ch_num) * in cpsw_get_sset_count()
230 return -EOPNOTSUPP; in cpsw_get_sset_count()
253 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_get_strings() local
257 switch (stringset) { in cpsw_get_strings()
265 cpsw_add_ch_strings(&p, cpsw->rx_ch_num, 1); in cpsw_get_strings()
266 cpsw_add_ch_strings(&p, cpsw->tx_ch_num, 0); in cpsw_get_strings()
275 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_get_ethtool_stats() local
281 data[l] = readl(cpsw->hw_stats + in cpsw_get_ethtool_stats()
284 for (ch = 0; ch < cpsw->rx_ch_num; ch++) { in cpsw_get_ethtool_stats()
285 cpdma_chan_get_stats(cpsw->rxv[ch].ch, &ch_stats); in cpsw_get_ethtool_stats()
293 for (ch = 0; ch < cpsw->tx_ch_num; ch++) { in cpsw_get_ethtool_stats()
294 cpdma_chan_get_stats(cpsw->txv[ch].ch, &ch_stats); in cpsw_get_ethtool_stats()
308 pause->autoneg = AUTONEG_DISABLE; in cpsw_get_pauseparam()
309 pause->rx_pause = priv->rx_pause ? true : false; in cpsw_get_pauseparam()
310 pause->tx_pause = priv->tx_pause ? true : false; in cpsw_get_pauseparam()
316 struct cpsw_common *cpsw = priv->cpsw; in cpsw_get_wol() local
317 int slave_no = cpsw_slave_index(cpsw, priv); in cpsw_get_wol()
319 wol->supported = 0; in cpsw_get_wol()
320 wol->wolopts = 0; in cpsw_get_wol()
322 if (cpsw->slaves[slave_no].phy) in cpsw_get_wol()
323 phy_ethtool_get_wol(cpsw->slaves[slave_no].phy, wol); in cpsw_get_wol()
329 struct cpsw_common *cpsw = priv->cpsw; in cpsw_set_wol() local
330 int slave_no = cpsw_slave_index(cpsw, priv); in cpsw_set_wol()
332 if (cpsw->slaves[slave_no].phy) in cpsw_set_wol()
333 return phy_ethtool_set_wol(cpsw->slaves[slave_no].phy, wol); in cpsw_set_wol()
335 return -EOPNOTSUPP; in cpsw_set_wol()
340 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_get_regs_len() local
342 return cpsw_ale_get_num_entries(cpsw->ale) * in cpsw_get_regs_len()
349 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_get_regs() local
351 /* update CPSW IP version */ in cpsw_get_regs()
352 regs->version = cpsw->version; in cpsw_get_regs()
354 cpsw_ale_dump(cpsw->ale, reg); in cpsw_get_regs()
360 struct cpsw_common *cpsw = priv->cpsw; in cpsw_ethtool_op_begin() local
363 ret = pm_runtime_get_sync(cpsw->dev); in cpsw_ethtool_op_begin()
366 pm_runtime_put_noidle(cpsw->dev); in cpsw_ethtool_op_begin()
377 ret = pm_runtime_put(priv->cpsw->dev); in cpsw_ethtool_op_complete()
384 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_get_channels() local
386 ch->max_rx = cpsw->quirk_irq ? 1 : CPSW_MAX_QUEUES; in cpsw_get_channels()
387 ch->max_tx = cpsw->quirk_irq ? 1 : CPSW_MAX_QUEUES; in cpsw_get_channels()
388 ch->max_combined = 0; in cpsw_get_channels()
389 ch->max_other = 0; in cpsw_get_channels()
390 ch->other_count = 0; in cpsw_get_channels()
391 ch->rx_count = cpsw->rx_ch_num; in cpsw_get_channels()
392 ch->tx_count = cpsw->tx_ch_num; in cpsw_get_channels()
393 ch->combined_count = 0; in cpsw_get_channels()
400 struct cpsw_common *cpsw = priv->cpsw; in cpsw_get_link_ksettings() local
401 int slave_no = cpsw_slave_index(cpsw, priv); in cpsw_get_link_ksettings()
403 if (!cpsw->slaves[slave_no].phy) in cpsw_get_link_ksettings()
404 return -EOPNOTSUPP; in cpsw_get_link_ksettings()
406 phy_ethtool_ksettings_get(cpsw->slaves[slave_no].phy, ecmd); in cpsw_get_link_ksettings()
414 struct cpsw_common *cpsw = priv->cpsw; in cpsw_set_link_ksettings() local
415 int slave_no = cpsw_slave_index(cpsw, priv); in cpsw_set_link_ksettings()
417 if (!cpsw->slaves[slave_no].phy) in cpsw_set_link_ksettings()
418 return -EOPNOTSUPP; in cpsw_set_link_ksettings()
420 return phy_ethtool_ksettings_set(cpsw->slaves[slave_no].phy, ecmd); in cpsw_set_link_ksettings()
426 struct cpsw_common *cpsw = priv->cpsw; in cpsw_get_eee() local
427 int slave_no = cpsw_slave_index(cpsw, priv); in cpsw_get_eee()
429 if (cpsw->slaves[slave_no].phy) in cpsw_get_eee()
430 return phy_ethtool_get_eee(cpsw->slaves[slave_no].phy, edata); in cpsw_get_eee()
432 return -EOPNOTSUPP; in cpsw_get_eee()
438 struct cpsw_common *cpsw = priv->cpsw; in cpsw_set_eee() local
439 int slave_no = cpsw_slave_index(cpsw, priv); in cpsw_set_eee()
441 if (cpsw->slaves[slave_no].phy) in cpsw_set_eee()
442 return phy_ethtool_set_eee(cpsw->slaves[slave_no].phy, edata); in cpsw_set_eee()
444 return -EOPNOTSUPP; in cpsw_set_eee()
450 struct cpsw_common *cpsw = priv->cpsw; in cpsw_nway_reset() local
451 int slave_no = cpsw_slave_index(cpsw, priv); in cpsw_nway_reset()
453 if (cpsw->slaves[slave_no].phy) in cpsw_nway_reset()
454 return genphy_restart_aneg(cpsw->slaves[slave_no].phy); in cpsw_nway_reset()
456 return -EOPNOTSUPP; in cpsw_nway_reset()
461 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_suspend_data_pass() local
465 cpsw_intr_disable(cpsw); in cpsw_suspend_data_pass()
469 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_suspend_data_pass()
470 ndev = cpsw->slaves[i].ndev; in cpsw_suspend_data_pass()
481 cpdma_ctlr_stop(cpsw->dma); in cpsw_suspend_data_pass()
487 struct cpsw_common *cpsw = priv->cpsw; in cpsw_resume_data_pass() local
491 if (cpsw->usage_count) { in cpsw_resume_data_pass()
496 cpdma_ctlr_start(cpsw->dma); in cpsw_resume_data_pass()
497 cpsw_intr_enable(cpsw); in cpsw_resume_data_pass()
501 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_resume_data_pass()
502 ndev = cpsw->slaves[i].ndev; in cpsw_resume_data_pass()
510 static int cpsw_check_ch_settings(struct cpsw_common *cpsw, in cpsw_check_ch_settings() argument
513 if (cpsw->quirk_irq) { in cpsw_check_ch_settings()
514 dev_err(cpsw->dev, "Maximum one tx/rx queue is allowed"); in cpsw_check_ch_settings()
515 return -EOPNOTSUPP; in cpsw_check_ch_settings()
518 if (ch->combined_count) in cpsw_check_ch_settings()
519 return -EINVAL; in cpsw_check_ch_settings()
522 if (!ch->rx_count || !ch->tx_count) in cpsw_check_ch_settings()
523 return -EINVAL; in cpsw_check_ch_settings()
525 if (ch->rx_count > cpsw->data.channels || in cpsw_check_ch_settings()
526 ch->tx_count > cpsw->data.channels) in cpsw_check_ch_settings()
527 return -EINVAL; in cpsw_check_ch_settings()
535 struct cpsw_common *cpsw = priv->cpsw; in cpsw_update_channels_res() local
542 ch = &cpsw->rx_ch_num; in cpsw_update_channels_res()
543 vec = cpsw->rxv; in cpsw_update_channels_res()
546 ch = &cpsw->tx_ch_num; in cpsw_update_channels_res()
547 vec = cpsw->txv; in cpsw_update_channels_res()
552 vch = rx ? *ch : 7 - *ch; in cpsw_update_channels_res()
553 vec[*ch].ch = cpdma_chan_create(cpsw->dma, vch, handler, rx); in cpsw_update_channels_res()
554 queue = netdev_get_tx_queue(priv->ndev, *ch); in cpsw_update_channels_res()
555 queue->tx_maxrate = 0; in cpsw_update_channels_res()
561 return -EINVAL; in cpsw_update_channels_res()
569 (*ch)--; in cpsw_update_channels_res()
582 static void cpsw_fail(struct cpsw_common *cpsw) in cpsw_fail() argument
587 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_fail()
588 ndev = cpsw->slaves[i].ndev; in cpsw_fail()
599 struct cpsw_common *cpsw = priv->cpsw; in cpsw_set_channels_common() local
603 ret = cpsw_check_ch_settings(cpsw, chs); in cpsw_set_channels_common()
609 new_pools = (chs->rx_count != cpsw->rx_ch_num) && cpsw->usage_count; in cpsw_set_channels_common()
611 ret = cpsw_update_channels_res(priv, chs->rx_count, 1, rx_handler); in cpsw_set_channels_common()
615 ret = cpsw_update_channels_res(priv, chs->tx_count, 0, rx_handler); in cpsw_set_channels_common()
619 for (i = 0; i < cpsw->data.slaves; i++) { in cpsw_set_channels_common()
620 sl_ndev = cpsw->slaves[i].ndev; in cpsw_set_channels_common()
625 ret = netif_set_real_num_tx_queues(sl_ndev, cpsw->tx_ch_num); in cpsw_set_channels_common()
627 dev_err(priv->dev, "cannot set real number of tx queues\n"); in cpsw_set_channels_common()
631 ret = netif_set_real_num_rx_queues(sl_ndev, cpsw->rx_ch_num); in cpsw_set_channels_common()
633 dev_err(priv->dev, "cannot set real number of rx queues\n"); in cpsw_set_channels_common()
638 cpsw_split_res(cpsw); in cpsw_set_channels_common()
641 cpsw_destroy_xdp_rxqs(cpsw); in cpsw_set_channels_common()
642 ret = cpsw_create_xdp_rxqs(cpsw); in cpsw_set_channels_common()
651 dev_err(priv->dev, "cannot update channels number, closing device\n"); in cpsw_set_channels_common()
652 cpsw_fail(cpsw); in cpsw_set_channels_common()
660 struct cpsw_common *cpsw = priv->cpsw; in cpsw_get_ringparam() local
663 ering->tx_max_pending = cpsw->descs_pool_size - CPSW_MAX_QUEUES; in cpsw_get_ringparam()
664 ering->tx_pending = cpdma_get_num_tx_descs(cpsw->dma); in cpsw_get_ringparam()
665 ering->rx_max_pending = cpsw->descs_pool_size - CPSW_MAX_QUEUES; in cpsw_get_ringparam()
666 ering->rx_pending = cpdma_get_num_rx_descs(cpsw->dma); in cpsw_get_ringparam()
672 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_set_ringparam() local
675 /* ignore ering->tx_pending - only rx_pending adjustment is supported */ in cpsw_set_ringparam()
677 if (ering->rx_mini_pending || ering->rx_jumbo_pending || in cpsw_set_ringparam()
678 ering->rx_pending < CPSW_MAX_QUEUES || in cpsw_set_ringparam()
679 ering->rx_pending > (cpsw->descs_pool_size - CPSW_MAX_QUEUES)) in cpsw_set_ringparam()
680 return -EINVAL; in cpsw_set_ringparam()
682 descs_num = cpdma_get_num_rx_descs(cpsw->dma); in cpsw_set_ringparam()
683 if (ering->rx_pending == descs_num) in cpsw_set_ringparam()
688 ret = cpdma_set_num_rx_descs(cpsw->dma, ering->rx_pending); in cpsw_set_ringparam()
696 if (cpsw->usage_count) { in cpsw_set_ringparam()
697 cpsw_destroy_xdp_rxqs(cpsw); in cpsw_set_ringparam()
698 ret = cpsw_create_xdp_rxqs(cpsw); in cpsw_set_ringparam()
707 cpdma_set_num_rx_descs(cpsw->dma, descs_num); in cpsw_set_ringparam()
708 dev_err(cpsw->dev, "cannot set ring params, closing device\n"); in cpsw_set_ringparam()
709 cpsw_fail(cpsw); in cpsw_set_ringparam()
716 struct cpsw_common *cpsw = ndev_to_cpsw(ndev); in cpsw_get_ts_info() local
718 info->so_timestamping = in cpsw_get_ts_info()
725 info->phc_index = cpsw->cpts->phc_index; in cpsw_get_ts_info()
726 info->tx_types = in cpsw_get_ts_info()
729 info->rx_filters = in cpsw_get_ts_info()
737 info->so_timestamping = in cpsw_get_ts_info()
741 info->phc_index = -1; in cpsw_get_ts_info()
742 info->tx_types = 0; in cpsw_get_ts_info()
743 info->rx_filters = 0; in cpsw_get_ts_info()