Lines Matching +full:micro +full:- +full:frames
9 * Copyright (c) 2014-2016 Advanced Micro Devices, Inc.
59 * Copyright (c) 2014-2016 Advanced Micro Devices, Inc.
69 * * Neither the name of Advanced Micro Devices, Inc. nor the
122 #include "xgbe-common.h"
201 for (i = 0; i < pdata->tx_ring_count; i++) { in xgbe_get_strings()
206 for (i = 0; i < pdata->rx_ring_count; i++) { in xgbe_get_strings()
222 pdata->hw_if.read_mmc_stats(pdata); in xgbe_get_ethtool_stats()
227 for (i = 0; i < pdata->tx_ring_count; i++) { in xgbe_get_ethtool_stats()
228 *data++ = pdata->ext_stats.txq_packets[i]; in xgbe_get_ethtool_stats()
229 *data++ = pdata->ext_stats.txq_bytes[i]; in xgbe_get_ethtool_stats()
231 for (i = 0; i < pdata->rx_ring_count; i++) { in xgbe_get_ethtool_stats()
232 *data++ = pdata->ext_stats.rxq_packets[i]; in xgbe_get_ethtool_stats()
233 *data++ = pdata->ext_stats.rxq_bytes[i]; in xgbe_get_ethtool_stats()
245 (pdata->tx_ring_count * 2) + in xgbe_get_sset_count()
246 (pdata->rx_ring_count * 2); in xgbe_get_sset_count()
250 ret = -EOPNOTSUPP; in xgbe_get_sset_count()
261 pause->autoneg = pdata->phy.pause_autoneg; in xgbe_get_pauseparam()
262 pause->tx_pause = pdata->phy.tx_pause; in xgbe_get_pauseparam()
263 pause->rx_pause = pdata->phy.rx_pause; in xgbe_get_pauseparam()
270 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_set_pauseparam()
273 if (pause->autoneg && (pdata->phy.autoneg != AUTONEG_ENABLE)) { in xgbe_set_pauseparam()
276 return -EINVAL; in xgbe_set_pauseparam()
279 pdata->phy.pause_autoneg = pause->autoneg; in xgbe_set_pauseparam()
280 pdata->phy.tx_pause = pause->tx_pause; in xgbe_set_pauseparam()
281 pdata->phy.rx_pause = pause->rx_pause; in xgbe_set_pauseparam()
286 if (pause->rx_pause) { in xgbe_set_pauseparam()
291 if (pause->tx_pause) { in xgbe_set_pauseparam()
300 ret = pdata->phy_if.phy_config_aneg(pdata); in xgbe_set_pauseparam()
309 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_get_link_ksettings()
311 cmd->base.phy_address = pdata->phy.address; in xgbe_get_link_ksettings()
314 cmd->base.speed = pdata->phy.speed; in xgbe_get_link_ksettings()
315 cmd->base.duplex = pdata->phy.duplex; in xgbe_get_link_ksettings()
317 cmd->base.speed = SPEED_UNKNOWN; in xgbe_get_link_ksettings()
318 cmd->base.duplex = DUPLEX_UNKNOWN; in xgbe_get_link_ksettings()
321 cmd->base.autoneg = pdata->phy.autoneg; in xgbe_get_link_ksettings()
322 cmd->base.port = PORT_NONE; in xgbe_get_link_ksettings()
335 struct ethtool_link_ksettings *lks = &pdata->phy.lks; in xgbe_set_link_ksettings()
340 speed = cmd->base.speed; in xgbe_set_link_ksettings()
342 if (cmd->base.phy_address != pdata->phy.address) { in xgbe_set_link_ksettings()
344 cmd->base.phy_address); in xgbe_set_link_ksettings()
345 return -EINVAL; in xgbe_set_link_ksettings()
348 if ((cmd->base.autoneg != AUTONEG_ENABLE) && in xgbe_set_link_ksettings()
349 (cmd->base.autoneg != AUTONEG_DISABLE)) { in xgbe_set_link_ksettings()
351 cmd->base.autoneg); in xgbe_set_link_ksettings()
352 return -EINVAL; in xgbe_set_link_ksettings()
355 if (cmd->base.autoneg == AUTONEG_DISABLE) { in xgbe_set_link_ksettings()
356 if (!pdata->phy_if.phy_valid_speed(pdata, speed)) { in xgbe_set_link_ksettings()
358 return -EINVAL; in xgbe_set_link_ksettings()
361 if (cmd->base.duplex != DUPLEX_FULL) { in xgbe_set_link_ksettings()
363 cmd->base.duplex); in xgbe_set_link_ksettings()
364 return -EINVAL; in xgbe_set_link_ksettings()
370 __ETHTOOL_LINK_MODE_MASK_NBITS, cmd->link_modes.advertising, in xgbe_set_link_ksettings()
371 __ETHTOOL_LINK_MODE_MASK_NBITS, lks->link_modes.supported); in xgbe_set_link_ksettings()
373 linkmode_and(advertising, cmd->link_modes.advertising, in xgbe_set_link_ksettings()
374 lks->link_modes.supported); in xgbe_set_link_ksettings()
376 if ((cmd->base.autoneg == AUTONEG_ENABLE) && in xgbe_set_link_ksettings()
380 return -EINVAL; in xgbe_set_link_ksettings()
384 pdata->phy.autoneg = cmd->base.autoneg; in xgbe_set_link_ksettings()
385 pdata->phy.speed = speed; in xgbe_set_link_ksettings()
386 pdata->phy.duplex = cmd->base.duplex; in xgbe_set_link_ksettings()
387 linkmode_copy(lks->link_modes.advertising, advertising); in xgbe_set_link_ksettings()
389 if (cmd->base.autoneg == AUTONEG_ENABLE) in xgbe_set_link_ksettings()
395 ret = pdata->phy_if.phy_config_aneg(pdata); in xgbe_set_link_ksettings()
404 struct xgbe_hw_features *hw_feat = &pdata->hw_feat; in xgbe_get_drvinfo()
406 strscpy(drvinfo->driver, XGBE_DRV_NAME, sizeof(drvinfo->driver)); in xgbe_get_drvinfo()
407 strscpy(drvinfo->bus_info, dev_name(pdata->dev), in xgbe_get_drvinfo()
408 sizeof(drvinfo->bus_info)); in xgbe_get_drvinfo()
409 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "%d.%d.%d", in xgbe_get_drvinfo()
410 XGMAC_GET_BITS(hw_feat->version, MAC_VR, USERVER), in xgbe_get_drvinfo()
411 XGMAC_GET_BITS(hw_feat->version, MAC_VR, DEVID), in xgbe_get_drvinfo()
412 XGMAC_GET_BITS(hw_feat->version, MAC_VR, SNPSVER)); in xgbe_get_drvinfo()
419 return pdata->msg_enable; in xgbe_get_msglevel()
426 pdata->msg_enable = msglevel; in xgbe_set_msglevel()
438 ec->rx_coalesce_usecs = pdata->rx_usecs; in xgbe_get_coalesce()
439 ec->rx_max_coalesced_frames = pdata->rx_frames; in xgbe_get_coalesce()
441 ec->tx_max_coalesced_frames = pdata->tx_frames; in xgbe_get_coalesce()
452 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_set_coalesce()
456 rx_riwt = hw_if->usec_to_riwt(pdata, ec->rx_coalesce_usecs); in xgbe_set_coalesce()
457 rx_usecs = ec->rx_coalesce_usecs; in xgbe_set_coalesce()
458 rx_frames = ec->rx_max_coalesced_frames; in xgbe_set_coalesce()
466 netdev_err(netdev, "rx-usec is limited to %d usecs\n", in xgbe_set_coalesce()
467 hw_if->riwt_to_usec(pdata, XGMAC_MAX_DMA_RIWT)); in xgbe_set_coalesce()
468 return -EINVAL; in xgbe_set_coalesce()
470 if (rx_frames > pdata->rx_desc_count) { in xgbe_set_coalesce()
471 netdev_err(netdev, "rx-frames is limited to %d frames\n", in xgbe_set_coalesce()
472 pdata->rx_desc_count); in xgbe_set_coalesce()
473 return -EINVAL; in xgbe_set_coalesce()
476 tx_frames = ec->tx_max_coalesced_frames; in xgbe_set_coalesce()
479 if (tx_frames > pdata->tx_desc_count) { in xgbe_set_coalesce()
480 netdev_err(netdev, "tx-frames is limited to %d frames\n", in xgbe_set_coalesce()
481 pdata->tx_desc_count); in xgbe_set_coalesce()
482 return -EINVAL; in xgbe_set_coalesce()
485 pdata->rx_riwt = rx_riwt; in xgbe_set_coalesce()
486 pdata->rx_usecs = rx_usecs; in xgbe_set_coalesce()
487 pdata->rx_frames = rx_frames; in xgbe_set_coalesce()
488 hw_if->config_rx_coalesce(pdata); in xgbe_set_coalesce()
490 pdata->tx_frames = tx_frames; in xgbe_set_coalesce()
491 hw_if->config_tx_coalesce(pdata); in xgbe_set_coalesce()
501 switch (rxnfc->cmd) { in xgbe_get_rxnfc()
503 rxnfc->data = pdata->rx_ring_count; in xgbe_get_rxnfc()
506 return -EOPNOTSUPP; in xgbe_get_rxnfc()
516 return sizeof(pdata->rss_key); in xgbe_get_rxfh_key_size()
523 return ARRAY_SIZE(pdata->rss_table); in xgbe_get_rxfh_indir_size()
532 if (rxfh->indir) { in xgbe_get_rxfh()
533 for (i = 0; i < ARRAY_SIZE(pdata->rss_table); i++) in xgbe_get_rxfh()
534 rxfh->indir[i] = XGMAC_GET_BITS(pdata->rss_table[i], in xgbe_get_rxfh()
538 if (rxfh->key) in xgbe_get_rxfh()
539 memcpy(rxfh->key, pdata->rss_key, sizeof(pdata->rss_key)); in xgbe_get_rxfh()
541 rxfh->hfunc = ETH_RSS_HASH_TOP; in xgbe_get_rxfh()
551 struct xgbe_hw_if *hw_if = &pdata->hw_if; in xgbe_set_rxfh()
554 if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE && in xgbe_set_rxfh()
555 rxfh->hfunc != ETH_RSS_HASH_TOP) { in xgbe_set_rxfh()
557 return -EOPNOTSUPP; in xgbe_set_rxfh()
560 if (rxfh->indir) { in xgbe_set_rxfh()
561 ret = hw_if->set_rss_lookup_table(pdata, rxfh->indir); in xgbe_set_rxfh()
566 if (rxfh->key) { in xgbe_set_rxfh()
567 ret = hw_if->set_rss_hash_key(pdata, rxfh->key); in xgbe_set_rxfh()
580 ts_info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE | in xgbe_get_ts_info()
585 if (pdata->ptp_clock) in xgbe_get_ts_info()
586 ts_info->phc_index = ptp_clock_index(pdata->ptp_clock); in xgbe_get_ts_info()
588 ts_info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON); in xgbe_get_ts_info()
589 ts_info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) | in xgbe_get_ts_info()
609 return pdata->phy_if.module_info(pdata, modinfo); in xgbe_get_module_info()
617 return pdata->phy_if.module_eeprom(pdata, eeprom, data); in xgbe_get_module_eeprom()
628 ringparam->rx_max_pending = XGBE_RX_DESC_CNT_MAX; in xgbe_get_ringparam()
629 ringparam->tx_max_pending = XGBE_TX_DESC_CNT_MAX; in xgbe_get_ringparam()
630 ringparam->rx_pending = pdata->rx_desc_count; in xgbe_get_ringparam()
631 ringparam->tx_pending = pdata->tx_desc_count; in xgbe_get_ringparam()
642 if (ringparam->rx_mini_pending || ringparam->rx_jumbo_pending) { in xgbe_set_ringparam()
644 return -EINVAL; in xgbe_set_ringparam()
647 if ((ringparam->rx_pending < XGBE_RX_DESC_CNT_MIN) || in xgbe_set_ringparam()
648 (ringparam->rx_pending > XGBE_RX_DESC_CNT_MAX)) { in xgbe_set_ringparam()
652 return -EINVAL; in xgbe_set_ringparam()
655 if ((ringparam->tx_pending < XGBE_TX_DESC_CNT_MIN) || in xgbe_set_ringparam()
656 (ringparam->tx_pending > XGBE_TX_DESC_CNT_MAX)) { in xgbe_set_ringparam()
660 return -EINVAL; in xgbe_set_ringparam()
663 rx = __rounddown_pow_of_two(ringparam->rx_pending); in xgbe_set_ringparam()
664 if (rx != ringparam->rx_pending) in xgbe_set_ringparam()
669 tx = __rounddown_pow_of_two(ringparam->tx_pending); in xgbe_set_ringparam()
670 if (tx != ringparam->tx_pending) in xgbe_set_ringparam()
675 if ((rx == pdata->rx_desc_count) && in xgbe_set_ringparam()
676 (tx == pdata->tx_desc_count)) in xgbe_set_ringparam()
679 pdata->rx_desc_count = rx; in xgbe_set_ringparam()
680 pdata->tx_desc_count = tx; in xgbe_set_ringparam()
695 * - Take into account the number of available IRQs in xgbe_get_channels()
696 * - Do not take into account the number of online CPUs so that in xgbe_get_channels()
697 * the user can over-subscribe if desired in xgbe_get_channels()
698 * - Tx is additionally limited by the number of hardware queues in xgbe_get_channels()
700 rx = min(pdata->hw_feat.rx_ch_cnt, pdata->rx_max_channel_count); in xgbe_get_channels()
701 rx = min(rx, pdata->channel_irq_count); in xgbe_get_channels()
702 tx = min(pdata->hw_feat.tx_ch_cnt, pdata->tx_max_channel_count); in xgbe_get_channels()
703 tx = min(tx, pdata->channel_irq_count); in xgbe_get_channels()
704 tx = min(tx, pdata->tx_max_q_count); in xgbe_get_channels()
708 channels->max_combined = combined; in xgbe_get_channels()
709 channels->max_rx = rx ? rx - 1 : 0; in xgbe_get_channels()
710 channels->max_tx = tx ? tx - 1 : 0; in xgbe_get_channels()
713 rx = pdata->new_rx_ring_count ? : pdata->rx_ring_count; in xgbe_get_channels()
714 tx = pdata->new_tx_ring_count ? : pdata->tx_ring_count; in xgbe_get_channels()
717 rx -= combined; in xgbe_get_channels()
718 tx -= combined; in xgbe_get_channels()
720 channels->combined_count = combined; in xgbe_get_channels()
721 channels->rx_count = rx; in xgbe_get_channels()
722 channels->tx_count = tx; in xgbe_get_channels()
728 netdev_err(netdev, "channel inputs: combined=%u, rx-only=%u, tx-only=%u\n", in xgbe_print_set_channels_input()
729 channels->combined_count, channels->rx_count, in xgbe_print_set_channels_input()
730 channels->tx_count); in xgbe_print_set_channels_input()
740 * - Take into account the number of available IRQs in xgbe_set_channels()
741 * - Do not take into account the number of online CPUs so that in xgbe_set_channels()
742 * the user can over-subscribe if desired in xgbe_set_channels()
743 * - Tx is additionally limited by the number of hardware queues in xgbe_set_channels()
745 rx = min(pdata->hw_feat.rx_ch_cnt, pdata->rx_max_channel_count); in xgbe_set_channels()
746 rx = min(rx, pdata->channel_irq_count); in xgbe_set_channels()
747 tx = min(pdata->hw_feat.tx_ch_cnt, pdata->tx_max_channel_count); in xgbe_set_channels()
748 tx = min(tx, pdata->tx_max_q_count); in xgbe_set_channels()
749 tx = min(tx, pdata->channel_irq_count); in xgbe_set_channels()
754 if (channels->other_count) { in xgbe_set_channels()
757 return -EINVAL; in xgbe_set_channels()
761 if (!channels->combined_count) { in xgbe_set_channels()
765 return -EINVAL; in xgbe_set_channels()
769 if (channels->combined_count > combined) { in xgbe_set_channels()
774 return -EINVAL; in xgbe_set_channels()
777 /* Can have some Rx-only or Tx-only channels, but not both */ in xgbe_set_channels()
778 if (channels->rx_count && channels->tx_count) { in xgbe_set_channels()
780 "cannot specify both Rx-only and Tx-only channels\n"); in xgbe_set_channels()
782 return -EINVAL; in xgbe_set_channels()
786 if ((channels->combined_count + channels->rx_count) > rx) { in xgbe_set_channels()
789 channels->combined_count + channels->rx_count, rx); in xgbe_set_channels()
791 return -EINVAL; in xgbe_set_channels()
794 if ((channels->combined_count + channels->tx_count) > tx) { in xgbe_set_channels()
797 channels->combined_count + channels->tx_count, tx); in xgbe_set_channels()
799 return -EINVAL; in xgbe_set_channels()
802 rx = channels->combined_count + channels->rx_count; in xgbe_set_channels()
803 tx = channels->combined_count + channels->tx_count; in xgbe_set_channels()
805 rx_curr = pdata->new_rx_ring_count ? : pdata->rx_ring_count; in xgbe_set_channels()
806 tx_curr = pdata->new_tx_ring_count ? : pdata->tx_ring_count; in xgbe_set_channels()
811 pdata->new_rx_ring_count = rx; in xgbe_set_channels()
812 pdata->new_tx_ring_count = tx; in xgbe_set_channels()