^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright IBM Corp. 2018
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #define KMSG_COMPONENT "qeth"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/ethtool.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "qeth_core.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #define QETH_TXQ_STAT(_name, _stat) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) .name = _name, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) .offset = offsetof(struct qeth_out_q_stats, _stat) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define QETH_CARD_STAT(_name, _stat) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) .name = _name, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) .offset = offsetof(struct qeth_card_stats, _stat) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct qeth_stats {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) char name[ETH_GSTRING_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) unsigned int offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) static const struct qeth_stats txq_stats[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) QETH_TXQ_STAT("IO buffers", bufs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) QETH_TXQ_STAT("IO buffer elements", buf_elements),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) QETH_TXQ_STAT("packed IO buffers", bufs_pack),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) QETH_TXQ_STAT("skbs", tx_packets),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) QETH_TXQ_STAT("packed skbs", skbs_pack),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) QETH_TXQ_STAT("SG skbs", skbs_sg),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) QETH_TXQ_STAT("HW csum skbs", skbs_csum),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) QETH_TXQ_STAT("TSO skbs", skbs_tso),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) QETH_TXQ_STAT("linearized skbs", skbs_linearized),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) QETH_TXQ_STAT("linearized+error skbs", skbs_linearized_fail),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) QETH_TXQ_STAT("TSO bytes", tso_bytes),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) QETH_TXQ_STAT("Packing mode switches", packing_mode_switch),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) QETH_TXQ_STAT("Queue stopped", stopped),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) QETH_TXQ_STAT("Doorbell", doorbell),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) QETH_TXQ_STAT("IRQ for frames", coal_frames),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) QETH_TXQ_STAT("Completion yield", completion_yield),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) QETH_TXQ_STAT("Completion timer", completion_timer),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static const struct qeth_stats card_stats[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) QETH_CARD_STAT("rx0 IO buffers", rx_bufs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) QETH_CARD_STAT("rx0 HW csum skbs", rx_skb_csum),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) QETH_CARD_STAT("rx0 SG skbs", rx_sg_skbs),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) QETH_CARD_STAT("rx0 SG page frags", rx_sg_frags),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) QETH_CARD_STAT("rx0 SG page allocs", rx_sg_alloc_page),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) QETH_CARD_STAT("rx0 dropped, no memory", rx_dropped_nomem),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) QETH_CARD_STAT("rx0 dropped, bad format", rx_dropped_notsupp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) QETH_CARD_STAT("rx0 dropped, runt", rx_dropped_runt),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define TXQ_STATS_LEN ARRAY_SIZE(txq_stats)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define CARD_STATS_LEN ARRAY_SIZE(card_stats)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static void qeth_add_stat_data(u64 **dst, void *src,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) const struct qeth_stats stats[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) unsigned int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) char *stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) for (i = 0; i < size; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) stat = (char *)src + stats[i].offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) **dst = *(u64 *)stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) (*dst)++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) static void qeth_add_stat_strings(u8 **data, const char *prefix,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) const struct qeth_stats stats[],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) unsigned int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) for (i = 0; i < size; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) snprintf(*data, ETH_GSTRING_LEN, "%s%s", prefix, stats[i].name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) *data += ETH_GSTRING_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) static int qeth_get_sset_count(struct net_device *dev, int stringset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) struct qeth_card *card = dev->ml_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) switch (stringset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) case ETH_SS_STATS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) return CARD_STATS_LEN +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) card->qdio.no_out_queues * TXQ_STATS_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static void qeth_get_ethtool_stats(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct ethtool_stats *stats, u64 *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) struct qeth_card *card = dev->ml_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) qeth_add_stat_data(&data, &card->stats, card_stats, CARD_STATS_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) for (i = 0; i < card->qdio.no_out_queues; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) qeth_add_stat_data(&data, &card->qdio.out_qs[i]->stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) txq_stats, TXQ_STATS_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) static void __qeth_set_coalesce(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct qeth_qdio_out_q *queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) struct ethtool_coalesce *coal)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) WRITE_ONCE(queue->coalesce_usecs, coal->tx_coalesce_usecs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) WRITE_ONCE(queue->max_coalesced_frames, coal->tx_max_coalesced_frames);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) if (coal->tx_coalesce_usecs &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) netif_running(dev) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) !qeth_out_queue_is_empty(queue))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) qeth_tx_arm_timer(queue, coal->tx_coalesce_usecs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static int qeth_set_coalesce(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) struct ethtool_coalesce *coal)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) struct qeth_card *card = dev->ml_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) struct qeth_qdio_out_q *queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) if (!IS_IQD(card))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) if (!coal->tx_coalesce_usecs && !coal->tx_max_coalesced_frames)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) qeth_for_each_output_queue(card, queue, i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) __qeth_set_coalesce(dev, queue, coal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static void qeth_get_ringparam(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) struct ethtool_ringparam *param)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) struct qeth_card *card = dev->ml_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) param->rx_max_pending = QDIO_MAX_BUFFERS_PER_Q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) param->rx_mini_max_pending = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) param->rx_jumbo_max_pending = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) param->tx_max_pending = QDIO_MAX_BUFFERS_PER_Q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) param->rx_pending = card->qdio.in_buf_pool.buf_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) param->rx_mini_pending = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) param->rx_jumbo_pending = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) param->tx_pending = QDIO_MAX_BUFFERS_PER_Q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) static void qeth_get_strings(struct net_device *dev, u32 stringset, u8 *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) struct qeth_card *card = dev->ml_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) char prefix[ETH_GSTRING_LEN] = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) switch (stringset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) case ETH_SS_STATS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) qeth_add_stat_strings(&data, prefix, card_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) CARD_STATS_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) for (i = 0; i < card->qdio.no_out_queues; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) snprintf(prefix, ETH_GSTRING_LEN, "tx%u ", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) qeth_add_stat_strings(&data, prefix, txq_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) TXQ_STATS_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) static void qeth_get_drvinfo(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) struct ethtool_drvinfo *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) struct qeth_card *card = dev->ml_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) strlcpy(info->driver, IS_LAYER2(card) ? "qeth_l2" : "qeth_l3",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) sizeof(info->driver));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) strlcpy(info->fw_version, card->info.mcl_level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) sizeof(info->fw_version));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) snprintf(info->bus_info, sizeof(info->bus_info), "%s/%s/%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) CARD_RDEV_ID(card), CARD_WDEV_ID(card), CARD_DDEV_ID(card));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) static void qeth_get_channels(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) struct ethtool_channels *channels)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) struct qeth_card *card = dev->ml_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) channels->max_rx = dev->num_rx_queues;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) channels->max_tx = card->qdio.no_out_queues;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) channels->max_other = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) channels->max_combined = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) channels->rx_count = dev->real_num_rx_queues;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) channels->tx_count = dev->real_num_tx_queues;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) channels->other_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) channels->combined_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) static int qeth_set_channels(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) struct ethtool_channels *channels)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) struct qeth_priv *priv = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) struct qeth_card *card = dev->ml_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) if (channels->rx_count == 0 || channels->tx_count == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) if (channels->tx_count > card->qdio.no_out_queues)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) /* Prio-queueing needs all TX queues: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) if (qeth_uses_tx_prio_queueing(card))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) if (IS_IQD(card)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) if (channels->tx_count < QETH_IQD_MIN_TXQ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) /* Reject downgrade while running. It could push displaced
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * ucast flows onto txq0, which is reserved for mcast.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) if (netif_running(dev) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) channels->tx_count < dev->real_num_tx_queues)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) rc = qeth_set_real_num_tx_queues(card, channels->tx_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) priv->tx_wanted_queues = channels->tx_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) static int qeth_get_ts_info(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) struct ethtool_ts_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) struct qeth_card *card = dev->ml_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) if (!IS_IQD(card))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) return ethtool_op_get_ts_info(dev, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) static int qeth_get_tunable(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) const struct ethtool_tunable *tuna, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) struct qeth_priv *priv = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) switch (tuna->id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) case ETHTOOL_RX_COPYBREAK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) *(u32 *)data = priv->rx_copybreak;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) static int qeth_set_tunable(struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) const struct ethtool_tunable *tuna,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) struct qeth_priv *priv = netdev_priv(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) switch (tuna->id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) case ETHTOOL_RX_COPYBREAK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) WRITE_ONCE(priv->rx_copybreak, *(u32 *)data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) static int qeth_get_per_queue_coalesce(struct net_device *dev, u32 __queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) struct ethtool_coalesce *coal)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) struct qeth_card *card = dev->ml_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) struct qeth_qdio_out_q *queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) if (!IS_IQD(card))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) if (__queue >= card->qdio.no_out_queues)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) queue = card->qdio.out_qs[__queue];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) coal->tx_coalesce_usecs = queue->coalesce_usecs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) coal->tx_max_coalesced_frames = queue->max_coalesced_frames;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) static int qeth_set_per_queue_coalesce(struct net_device *dev, u32 queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) struct ethtool_coalesce *coal)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) struct qeth_card *card = dev->ml_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) if (!IS_IQD(card))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) return -EOPNOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) if (queue >= card->qdio.no_out_queues)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) if (!coal->tx_coalesce_usecs && !coal->tx_max_coalesced_frames)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) __qeth_set_coalesce(dev, card->qdio.out_qs[queue], coal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) /* Helper function to fill 'advertising' and 'supported' which are the same. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) /* Autoneg and full-duplex are supported and advertised unconditionally. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) /* Always advertise and support all speeds up to specified, and only one */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) /* specified port type. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) static void qeth_set_cmd_adv_sup(struct ethtool_link_ksettings *cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) int maxspeed, int porttype)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) ethtool_link_ksettings_zero_link_mode(cmd, supported);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) ethtool_link_ksettings_zero_link_mode(cmd, advertising);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) ethtool_link_ksettings_zero_link_mode(cmd, lp_advertising);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) ethtool_link_ksettings_add_link_mode(cmd, supported, Autoneg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) ethtool_link_ksettings_add_link_mode(cmd, advertising, Autoneg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) switch (porttype) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) case PORT_TP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) ethtool_link_ksettings_add_link_mode(cmd, supported, TP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) ethtool_link_ksettings_add_link_mode(cmd, advertising, TP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) case PORT_FIBRE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) ethtool_link_ksettings_add_link_mode(cmd, supported, FIBRE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) ethtool_link_ksettings_add_link_mode(cmd, advertising, FIBRE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) ethtool_link_ksettings_add_link_mode(cmd, supported, TP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) ethtool_link_ksettings_add_link_mode(cmd, advertising, TP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) WARN_ON_ONCE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) /* partially does fall through, to also select lower speeds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) switch (maxspeed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) case SPEED_25000:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) ethtool_link_ksettings_add_link_mode(cmd, supported,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 25000baseSR_Full);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) ethtool_link_ksettings_add_link_mode(cmd, advertising,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 25000baseSR_Full);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) case SPEED_10000:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) ethtool_link_ksettings_add_link_mode(cmd, supported,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 10000baseT_Full);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) ethtool_link_ksettings_add_link_mode(cmd, advertising,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 10000baseT_Full);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) case SPEED_1000:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) ethtool_link_ksettings_add_link_mode(cmd, supported,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 1000baseT_Full);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) ethtool_link_ksettings_add_link_mode(cmd, advertising,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 1000baseT_Full);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) ethtool_link_ksettings_add_link_mode(cmd, supported,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 1000baseT_Half);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) ethtool_link_ksettings_add_link_mode(cmd, advertising,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 1000baseT_Half);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) case SPEED_100:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) ethtool_link_ksettings_add_link_mode(cmd, supported,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 100baseT_Full);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) ethtool_link_ksettings_add_link_mode(cmd, advertising,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 100baseT_Full);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) ethtool_link_ksettings_add_link_mode(cmd, supported,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 100baseT_Half);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) ethtool_link_ksettings_add_link_mode(cmd, advertising,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 100baseT_Half);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) case SPEED_10:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) ethtool_link_ksettings_add_link_mode(cmd, supported,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 10baseT_Full);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) ethtool_link_ksettings_add_link_mode(cmd, advertising,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 10baseT_Full);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) ethtool_link_ksettings_add_link_mode(cmd, supported,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 10baseT_Half);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) ethtool_link_ksettings_add_link_mode(cmd, advertising,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 10baseT_Half);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) ethtool_link_ksettings_add_link_mode(cmd, supported,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 10baseT_Full);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) ethtool_link_ksettings_add_link_mode(cmd, advertising,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 10baseT_Full);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) ethtool_link_ksettings_add_link_mode(cmd, supported,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 10baseT_Half);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) ethtool_link_ksettings_add_link_mode(cmd, advertising,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 10baseT_Half);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) WARN_ON_ONCE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) static int qeth_get_link_ksettings(struct net_device *netdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) struct ethtool_link_ksettings *cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) struct qeth_card *card = netdev->ml_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) enum qeth_link_types link_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) struct carrier_info carrier_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) if (IS_IQD(card) || IS_VM_NIC(card))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) link_type = QETH_LINK_TYPE_10GBIT_ETH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) link_type = card->info.link_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) cmd->base.duplex = DUPLEX_FULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) cmd->base.autoneg = AUTONEG_ENABLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) cmd->base.phy_address = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) cmd->base.mdio_support = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) cmd->base.eth_tp_mdix = ETH_TP_MDI_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) cmd->base.eth_tp_mdix_ctrl = ETH_TP_MDI_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) switch (link_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) case QETH_LINK_TYPE_FAST_ETH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) case QETH_LINK_TYPE_LANE_ETH100:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) cmd->base.speed = SPEED_100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) cmd->base.port = PORT_TP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) case QETH_LINK_TYPE_GBIT_ETH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) case QETH_LINK_TYPE_LANE_ETH1000:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) cmd->base.speed = SPEED_1000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) cmd->base.port = PORT_FIBRE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) case QETH_LINK_TYPE_10GBIT_ETH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) cmd->base.speed = SPEED_10000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) cmd->base.port = PORT_FIBRE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) case QETH_LINK_TYPE_25GBIT_ETH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) cmd->base.speed = SPEED_25000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) cmd->base.port = PORT_FIBRE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) cmd->base.speed = SPEED_10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) cmd->base.port = PORT_TP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) qeth_set_cmd_adv_sup(cmd, cmd->base.speed, cmd->base.port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) /* Check if we can obtain more accurate information. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) /* If QUERY_CARD_INFO command is not supported or fails, */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) /* just return the heuristics that was filled above. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) rc = qeth_query_card_info(card, &carrier_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) if (rc == -EOPNOTSUPP) /* for old hardware, return heuristic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) if (rc) /* report error from the hardware operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) /* on success, fill in the information got from the hardware */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) netdev_dbg(netdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) "card info: card_type=0x%02x, port_mode=0x%04x, port_speed=0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) carrier_info.card_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) carrier_info.port_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) carrier_info.port_speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) /* Update attributes for which we've obtained more authoritative */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) /* information, leave the rest the way they where filled above. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) switch (carrier_info.card_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) case CARD_INFO_TYPE_1G_COPPER_A:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) case CARD_INFO_TYPE_1G_COPPER_B:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) cmd->base.port = PORT_TP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) qeth_set_cmd_adv_sup(cmd, SPEED_1000, cmd->base.port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) case CARD_INFO_TYPE_1G_FIBRE_A:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) case CARD_INFO_TYPE_1G_FIBRE_B:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) cmd->base.port = PORT_FIBRE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) qeth_set_cmd_adv_sup(cmd, SPEED_1000, cmd->base.port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) case CARD_INFO_TYPE_10G_FIBRE_A:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) case CARD_INFO_TYPE_10G_FIBRE_B:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) cmd->base.port = PORT_FIBRE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) qeth_set_cmd_adv_sup(cmd, SPEED_10000, cmd->base.port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) switch (carrier_info.port_mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) case CARD_INFO_PORTM_FULLDUPLEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) cmd->base.duplex = DUPLEX_FULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) case CARD_INFO_PORTM_HALFDUPLEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) cmd->base.duplex = DUPLEX_HALF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) switch (carrier_info.port_speed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) case CARD_INFO_PORTS_10M:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) cmd->base.speed = SPEED_10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) case CARD_INFO_PORTS_100M:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) cmd->base.speed = SPEED_100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) case CARD_INFO_PORTS_1G:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) cmd->base.speed = SPEED_1000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) case CARD_INFO_PORTS_10G:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) cmd->base.speed = SPEED_10000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) case CARD_INFO_PORTS_25G:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) cmd->base.speed = SPEED_25000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) const struct ethtool_ops qeth_ethtool_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) .supported_coalesce_params = ETHTOOL_COALESCE_TX_USECS |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) ETHTOOL_COALESCE_TX_MAX_FRAMES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) .get_link = ethtool_op_get_link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) .set_coalesce = qeth_set_coalesce,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) .get_ringparam = qeth_get_ringparam,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) .get_strings = qeth_get_strings,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) .get_ethtool_stats = qeth_get_ethtool_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) .get_sset_count = qeth_get_sset_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) .get_drvinfo = qeth_get_drvinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) .get_channels = qeth_get_channels,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) .set_channels = qeth_set_channels,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) .get_ts_info = qeth_get_ts_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) .get_tunable = qeth_get_tunable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) .set_tunable = qeth_set_tunable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) .get_per_queue_coalesce = qeth_get_per_queue_coalesce,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) .set_per_queue_coalesce = qeth_set_per_queue_coalesce,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) .get_link_ksettings = qeth_get_link_ksettings,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) const struct ethtool_ops qeth_osn_ethtool_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) .get_strings = qeth_get_strings,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) .get_ethtool_stats = qeth_get_ethtool_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) .get_sset_count = qeth_get_sset_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) .get_drvinfo = qeth_get_drvinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) };