2 * Copyright (C) 2013-2015 Chelsio Communications. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * The full GNU General Public License is included in this distribution in
14 * the file called "COPYING".
18 #include <linux/firmware.h>
19 #include <linux/mdio.h>
25 #define EEPROM_MAGIC 0x38E2F10C
27 static u32 get_msglevel(struct net_device *dev)
29 return netdev2adap(dev)->msg_enable;
32 static void set_msglevel(struct net_device *dev, u32 val)
34 netdev2adap(dev)->msg_enable = val;
37 static const char stats_strings[][ETH_GSTRING_LEN] = {
50 "TxFrames1024To1518 ",
82 "RxFrames1024To1518 ",
95 "RxBG0FramesDropped ",
96 "RxBG1FramesDropped ",
97 "RxBG2FramesDropped ",
98 "RxBG3FramesDropped ",
115 static int get_sset_count(struct net_device *dev, int sset)
119 return ARRAY_SIZE(stats_strings);
125 static int get_regs_len(struct net_device *dev)
127 struct adapter *adap = netdev2adap(dev);
129 return t4_get_regs_len(adap);
132 static int get_eeprom_len(struct net_device *dev)
137 static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
139 struct adapter *adapter = netdev2adap(dev);
142 strlcpy(info->driver, cxgb4_driver_name, sizeof(info->driver));
143 strlcpy(info->version, cxgb4_driver_version,
144 sizeof(info->version));
145 strlcpy(info->bus_info, pci_name(adapter->pdev),
146 sizeof(info->bus_info));
148 if (adapter->params.fw_vers)
149 snprintf(info->fw_version, sizeof(info->fw_version),
150 "%u.%u.%u.%u, TP %u.%u.%u.%u",
151 FW_HDR_FW_VER_MAJOR_G(adapter->params.fw_vers),
152 FW_HDR_FW_VER_MINOR_G(adapter->params.fw_vers),
153 FW_HDR_FW_VER_MICRO_G(adapter->params.fw_vers),
154 FW_HDR_FW_VER_BUILD_G(adapter->params.fw_vers),
155 FW_HDR_FW_VER_MAJOR_G(adapter->params.tp_vers),
156 FW_HDR_FW_VER_MINOR_G(adapter->params.tp_vers),
157 FW_HDR_FW_VER_MICRO_G(adapter->params.tp_vers),
158 FW_HDR_FW_VER_BUILD_G(adapter->params.tp_vers));
160 if (!t4_get_exprom_version(adapter, &exprom_vers))
161 snprintf(info->erom_version, sizeof(info->erom_version),
163 FW_HDR_FW_VER_MAJOR_G(exprom_vers),
164 FW_HDR_FW_VER_MINOR_G(exprom_vers),
165 FW_HDR_FW_VER_MICRO_G(exprom_vers),
166 FW_HDR_FW_VER_BUILD_G(exprom_vers));
169 static void get_strings(struct net_device *dev, u32 stringset, u8 *data)
171 if (stringset == ETH_SS_STATS)
172 memcpy(data, stats_strings, sizeof(stats_strings));
175 /* port stats maintained per queue of the port. They should be in the same
176 * order as in stats_strings above.
178 struct queue_port_stats {
188 static void collect_sge_port_stats(const struct adapter *adap,
189 const struct port_info *p,
190 struct queue_port_stats *s)
193 const struct sge_eth_txq *tx = &adap->sge.ethtxq[p->first_qset];
194 const struct sge_eth_rxq *rx = &adap->sge.ethrxq[p->first_qset];
196 memset(s, 0, sizeof(*s));
197 for (i = 0; i < p->nqsets; i++, rx++, tx++) {
199 s->tx_csum += tx->tx_cso;
200 s->rx_csum += rx->stats.rx_cso;
201 s->vlan_ex += rx->stats.vlan_ex;
202 s->vlan_ins += tx->vlan_ins;
203 s->gro_pkts += rx->stats.lro_pkts;
204 s->gro_merged += rx->stats.lro_merged;
208 static void get_stats(struct net_device *dev, struct ethtool_stats *stats,
211 struct port_info *pi = netdev_priv(dev);
212 struct adapter *adapter = pi->adapter;
215 t4_get_port_stats(adapter, pi->tx_chan, (struct port_stats *)data);
217 data += sizeof(struct port_stats) / sizeof(u64);
218 collect_sge_port_stats(adapter, pi, (struct queue_port_stats *)data);
219 data += sizeof(struct queue_port_stats) / sizeof(u64);
220 if (!is_t4(adapter->params.chip)) {
221 t4_write_reg(adapter, SGE_STAT_CFG_A, STATSOURCE_T5_V(7));
222 val1 = t4_read_reg(adapter, SGE_STAT_TOTAL_A);
223 val2 = t4_read_reg(adapter, SGE_STAT_MATCH_A);
229 memset(data, 0, 2 * sizeof(u64));
234 static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
237 struct adapter *adap = netdev2adap(dev);
240 buf_size = t4_get_regs_len(adap);
241 regs->version = mk_adap_vers(adap);
242 t4_get_regs(adap, buf, buf_size);
245 static int restart_autoneg(struct net_device *dev)
247 struct port_info *p = netdev_priv(dev);
249 if (!netif_running(dev))
251 if (p->link_cfg.autoneg != AUTONEG_ENABLE)
253 t4_restart_aneg(p->adapter, p->adapter->pf, p->tx_chan);
257 static int identify_port(struct net_device *dev,
258 enum ethtool_phys_id_state state)
261 struct adapter *adap = netdev2adap(dev);
263 if (state == ETHTOOL_ID_ACTIVE)
265 else if (state == ETHTOOL_ID_INACTIVE)
270 return t4_identify_port(adap, adap->pf, netdev2pinfo(dev)->viid, val);
273 static unsigned int from_fw_linkcaps(enum fw_port_type type, unsigned int caps)
277 if (type == FW_PORT_TYPE_BT_SGMII || type == FW_PORT_TYPE_BT_XFI ||
278 type == FW_PORT_TYPE_BT_XAUI) {
280 if (caps & FW_PORT_CAP_SPEED_100M)
281 v |= SUPPORTED_100baseT_Full;
282 if (caps & FW_PORT_CAP_SPEED_1G)
283 v |= SUPPORTED_1000baseT_Full;
284 if (caps & FW_PORT_CAP_SPEED_10G)
285 v |= SUPPORTED_10000baseT_Full;
286 } else if (type == FW_PORT_TYPE_KX4 || type == FW_PORT_TYPE_KX) {
287 v |= SUPPORTED_Backplane;
288 if (caps & FW_PORT_CAP_SPEED_1G)
289 v |= SUPPORTED_1000baseKX_Full;
290 if (caps & FW_PORT_CAP_SPEED_10G)
291 v |= SUPPORTED_10000baseKX4_Full;
292 } else if (type == FW_PORT_TYPE_KR) {
293 v |= SUPPORTED_Backplane | SUPPORTED_10000baseKR_Full;
294 } else if (type == FW_PORT_TYPE_BP_AP) {
295 v |= SUPPORTED_Backplane | SUPPORTED_10000baseR_FEC |
296 SUPPORTED_10000baseKR_Full | SUPPORTED_1000baseKX_Full;
297 } else if (type == FW_PORT_TYPE_BP4_AP) {
298 v |= SUPPORTED_Backplane | SUPPORTED_10000baseR_FEC |
299 SUPPORTED_10000baseKR_Full | SUPPORTED_1000baseKX_Full |
300 SUPPORTED_10000baseKX4_Full;
301 } else if (type == FW_PORT_TYPE_FIBER_XFI ||
302 type == FW_PORT_TYPE_FIBER_XAUI ||
303 type == FW_PORT_TYPE_SFP ||
304 type == FW_PORT_TYPE_QSFP_10G ||
305 type == FW_PORT_TYPE_QSA) {
306 v |= SUPPORTED_FIBRE;
307 if (caps & FW_PORT_CAP_SPEED_1G)
308 v |= SUPPORTED_1000baseT_Full;
309 if (caps & FW_PORT_CAP_SPEED_10G)
310 v |= SUPPORTED_10000baseT_Full;
311 } else if (type == FW_PORT_TYPE_BP40_BA ||
312 type == FW_PORT_TYPE_QSFP) {
313 v |= SUPPORTED_40000baseSR4_Full;
314 v |= SUPPORTED_FIBRE;
317 if (caps & FW_PORT_CAP_ANEG)
318 v |= SUPPORTED_Autoneg;
322 static unsigned int to_fw_linkcaps(unsigned int caps)
326 if (caps & ADVERTISED_100baseT_Full)
327 v |= FW_PORT_CAP_SPEED_100M;
328 if (caps & ADVERTISED_1000baseT_Full)
329 v |= FW_PORT_CAP_SPEED_1G;
330 if (caps & ADVERTISED_10000baseT_Full)
331 v |= FW_PORT_CAP_SPEED_10G;
332 if (caps & ADVERTISED_40000baseSR4_Full)
333 v |= FW_PORT_CAP_SPEED_40G;
337 static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
339 const struct port_info *p = netdev_priv(dev);
341 if (p->port_type == FW_PORT_TYPE_BT_SGMII ||
342 p->port_type == FW_PORT_TYPE_BT_XFI ||
343 p->port_type == FW_PORT_TYPE_BT_XAUI) {
345 } else if (p->port_type == FW_PORT_TYPE_FIBER_XFI ||
346 p->port_type == FW_PORT_TYPE_FIBER_XAUI) {
347 cmd->port = PORT_FIBRE;
348 } else if (p->port_type == FW_PORT_TYPE_SFP ||
349 p->port_type == FW_PORT_TYPE_QSFP_10G ||
350 p->port_type == FW_PORT_TYPE_QSA ||
351 p->port_type == FW_PORT_TYPE_QSFP) {
352 if (p->mod_type == FW_PORT_MOD_TYPE_LR ||
353 p->mod_type == FW_PORT_MOD_TYPE_SR ||
354 p->mod_type == FW_PORT_MOD_TYPE_ER ||
355 p->mod_type == FW_PORT_MOD_TYPE_LRM)
356 cmd->port = PORT_FIBRE;
357 else if (p->mod_type == FW_PORT_MOD_TYPE_TWINAX_PASSIVE ||
358 p->mod_type == FW_PORT_MOD_TYPE_TWINAX_ACTIVE)
361 cmd->port = PORT_OTHER;
363 cmd->port = PORT_OTHER;
366 if (p->mdio_addr >= 0) {
367 cmd->phy_address = p->mdio_addr;
368 cmd->transceiver = XCVR_EXTERNAL;
369 cmd->mdio_support = p->port_type == FW_PORT_TYPE_BT_SGMII ?
370 MDIO_SUPPORTS_C22 : MDIO_SUPPORTS_C45;
372 cmd->phy_address = 0; /* not really, but no better option */
373 cmd->transceiver = XCVR_INTERNAL;
374 cmd->mdio_support = 0;
377 cmd->supported = from_fw_linkcaps(p->port_type, p->link_cfg.supported);
378 cmd->advertising = from_fw_linkcaps(p->port_type,
379 p->link_cfg.advertising);
380 ethtool_cmd_speed_set(cmd,
381 netif_carrier_ok(dev) ? p->link_cfg.speed : 0);
382 cmd->duplex = DUPLEX_FULL;
383 cmd->autoneg = p->link_cfg.autoneg;
389 static unsigned int speed_to_caps(int speed)
392 return FW_PORT_CAP_SPEED_100M;
394 return FW_PORT_CAP_SPEED_1G;
396 return FW_PORT_CAP_SPEED_10G;
398 return FW_PORT_CAP_SPEED_40G;
402 static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
405 struct port_info *p = netdev_priv(dev);
406 struct link_config *lc = &p->link_cfg;
407 u32 speed = ethtool_cmd_speed(cmd);
409 if (cmd->duplex != DUPLEX_FULL) /* only full-duplex supported */
412 if (!(lc->supported & FW_PORT_CAP_ANEG)) {
413 /* PHY offers a single speed. See if that's what's
416 if (cmd->autoneg == AUTONEG_DISABLE &&
417 (lc->supported & speed_to_caps(speed)))
422 if (cmd->autoneg == AUTONEG_DISABLE) {
423 cap = speed_to_caps(speed);
425 if (!(lc->supported & cap) ||
430 lc->requested_speed = cap;
433 cap = to_fw_linkcaps(cmd->advertising);
434 if (!(lc->supported & cap))
436 lc->requested_speed = 0;
437 lc->advertising = cap | FW_PORT_CAP_ANEG;
439 lc->autoneg = cmd->autoneg;
441 if (netif_running(dev))
442 return t4_link_start(p->adapter, p->adapter->pf, p->tx_chan,
447 static void get_pauseparam(struct net_device *dev,
448 struct ethtool_pauseparam *epause)
450 struct port_info *p = netdev_priv(dev);
452 epause->autoneg = (p->link_cfg.requested_fc & PAUSE_AUTONEG) != 0;
453 epause->rx_pause = (p->link_cfg.fc & PAUSE_RX) != 0;
454 epause->tx_pause = (p->link_cfg.fc & PAUSE_TX) != 0;
457 static int set_pauseparam(struct net_device *dev,
458 struct ethtool_pauseparam *epause)
460 struct port_info *p = netdev_priv(dev);
461 struct link_config *lc = &p->link_cfg;
463 if (epause->autoneg == AUTONEG_DISABLE)
464 lc->requested_fc = 0;
465 else if (lc->supported & FW_PORT_CAP_ANEG)
466 lc->requested_fc = PAUSE_AUTONEG;
470 if (epause->rx_pause)
471 lc->requested_fc |= PAUSE_RX;
472 if (epause->tx_pause)
473 lc->requested_fc |= PAUSE_TX;
474 if (netif_running(dev))
475 return t4_link_start(p->adapter, p->adapter->pf, p->tx_chan,
480 static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e)
482 const struct port_info *pi = netdev_priv(dev);
483 const struct sge *s = &pi->adapter->sge;
485 e->rx_max_pending = MAX_RX_BUFFERS;
486 e->rx_mini_max_pending = MAX_RSPQ_ENTRIES;
487 e->rx_jumbo_max_pending = 0;
488 e->tx_max_pending = MAX_TXQ_ENTRIES;
490 e->rx_pending = s->ethrxq[pi->first_qset].fl.size - 8;
491 e->rx_mini_pending = s->ethrxq[pi->first_qset].rspq.size;
492 e->rx_jumbo_pending = 0;
493 e->tx_pending = s->ethtxq[pi->first_qset].q.size;
496 static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e)
499 const struct port_info *pi = netdev_priv(dev);
500 struct adapter *adapter = pi->adapter;
501 struct sge *s = &adapter->sge;
503 if (e->rx_pending > MAX_RX_BUFFERS || e->rx_jumbo_pending ||
504 e->tx_pending > MAX_TXQ_ENTRIES ||
505 e->rx_mini_pending > MAX_RSPQ_ENTRIES ||
506 e->rx_mini_pending < MIN_RSPQ_ENTRIES ||
507 e->rx_pending < MIN_FL_ENTRIES || e->tx_pending < MIN_TXQ_ENTRIES)
510 if (adapter->flags & FULL_INIT_DONE)
513 for (i = 0; i < pi->nqsets; ++i) {
514 s->ethtxq[pi->first_qset + i].q.size = e->tx_pending;
515 s->ethrxq[pi->first_qset + i].fl.size = e->rx_pending + 8;
516 s->ethrxq[pi->first_qset + i].rspq.size = e->rx_mini_pending;
522 * set_rx_intr_params - set a net devices's RX interrupt holdoff paramete!
523 * @dev: the network device
524 * @us: the hold-off time in us, or 0 to disable timer
525 * @cnt: the hold-off packet count, or 0 to disable counter
527 * Set the RX interrupt hold-off parameters for a network device.
529 static int set_rx_intr_params(struct net_device *dev,
530 unsigned int us, unsigned int cnt)
533 struct port_info *pi = netdev_priv(dev);
534 struct adapter *adap = pi->adapter;
535 struct sge_eth_rxq *q = &adap->sge.ethrxq[pi->first_qset];
537 for (i = 0; i < pi->nqsets; i++, q++) {
538 err = cxgb4_set_rspq_intr_params(&q->rspq, us, cnt);
545 static int set_adaptive_rx_setting(struct net_device *dev, int adaptive_rx)
548 struct port_info *pi = netdev_priv(dev);
549 struct adapter *adap = pi->adapter;
550 struct sge_eth_rxq *q = &adap->sge.ethrxq[pi->first_qset];
552 for (i = 0; i < pi->nqsets; i++, q++)
553 q->rspq.adaptive_rx = adaptive_rx;
558 static int get_adaptive_rx_setting(struct net_device *dev)
560 struct port_info *pi = netdev_priv(dev);
561 struct adapter *adap = pi->adapter;
562 struct sge_eth_rxq *q = &adap->sge.ethrxq[pi->first_qset];
564 return q->rspq.adaptive_rx;
567 static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
569 set_adaptive_rx_setting(dev, c->use_adaptive_rx_coalesce);
570 return set_rx_intr_params(dev, c->rx_coalesce_usecs,
571 c->rx_max_coalesced_frames);
574 static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
576 const struct port_info *pi = netdev_priv(dev);
577 const struct adapter *adap = pi->adapter;
578 const struct sge_rspq *rq = &adap->sge.ethrxq[pi->first_qset].rspq;
580 c->rx_coalesce_usecs = qtimer_val(adap, rq);
581 c->rx_max_coalesced_frames = (rq->intr_params & QINTR_CNT_EN_F) ?
582 adap->sge.counter_val[rq->pktcnt_idx] : 0;
583 c->use_adaptive_rx_coalesce = get_adaptive_rx_setting(dev);
588 * eeprom_ptov - translate a physical EEPROM address to virtual
589 * @phys_addr: the physical EEPROM address
590 * @fn: the PCI function number
591 * @sz: size of function-specific area
593 * Translate a physical EEPROM address to virtual. The first 1K is
594 * accessed through virtual addresses starting at 31K, the rest is
595 * accessed through virtual addresses starting at 0.
597 * The mapping is as follows:
598 * [0..1K) -> [31K..32K)
599 * [1K..1K+A) -> [31K-A..31K)
600 * [1K+A..ES) -> [0..ES-A-1K)
602 * where A = @fn * @sz, and ES = EEPROM size.
604 static int eeprom_ptov(unsigned int phys_addr, unsigned int fn, unsigned int sz)
607 if (phys_addr < 1024)
608 return phys_addr + (31 << 10);
609 if (phys_addr < 1024 + fn)
610 return 31744 - fn + phys_addr - 1024;
611 if (phys_addr < EEPROMSIZE)
612 return phys_addr - 1024 - fn;
616 /* The next two routines implement eeprom read/write from physical addresses.
618 static int eeprom_rd_phys(struct adapter *adap, unsigned int phys_addr, u32 *v)
620 int vaddr = eeprom_ptov(phys_addr, adap->pf, EEPROMPFSIZE);
623 vaddr = pci_read_vpd(adap->pdev, vaddr, sizeof(u32), v);
624 return vaddr < 0 ? vaddr : 0;
627 static int eeprom_wr_phys(struct adapter *adap, unsigned int phys_addr, u32 v)
629 int vaddr = eeprom_ptov(phys_addr, adap->pf, EEPROMPFSIZE);
632 vaddr = pci_write_vpd(adap->pdev, vaddr, sizeof(u32), &v);
633 return vaddr < 0 ? vaddr : 0;
636 #define EEPROM_MAGIC 0x38E2F10C
638 static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e,
642 struct adapter *adapter = netdev2adap(dev);
643 u8 *buf = kmalloc(EEPROMSIZE, GFP_KERNEL);
648 e->magic = EEPROM_MAGIC;
649 for (i = e->offset & ~3; !err && i < e->offset + e->len; i += 4)
650 err = eeprom_rd_phys(adapter, i, (u32 *)&buf[i]);
653 memcpy(data, buf + e->offset, e->len);
658 static int set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
663 u32 aligned_offset, aligned_len, *p;
664 struct adapter *adapter = netdev2adap(dev);
666 if (eeprom->magic != EEPROM_MAGIC)
669 aligned_offset = eeprom->offset & ~3;
670 aligned_len = (eeprom->len + (eeprom->offset & 3) + 3) & ~3;
672 if (adapter->pf > 0) {
673 u32 start = 1024 + adapter->pf * EEPROMPFSIZE;
675 if (aligned_offset < start ||
676 aligned_offset + aligned_len > start + EEPROMPFSIZE)
680 if (aligned_offset != eeprom->offset || aligned_len != eeprom->len) {
681 /* RMW possibly needed for first or last words.
683 buf = kmalloc(aligned_len, GFP_KERNEL);
686 err = eeprom_rd_phys(adapter, aligned_offset, (u32 *)buf);
687 if (!err && aligned_len > 4)
688 err = eeprom_rd_phys(adapter,
689 aligned_offset + aligned_len - 4,
690 (u32 *)&buf[aligned_len - 4]);
693 memcpy(buf + (eeprom->offset & 3), data, eeprom->len);
698 err = t4_seeprom_wp(adapter, false);
702 for (p = (u32 *)buf; !err && aligned_len; aligned_len -= 4, p++) {
703 err = eeprom_wr_phys(adapter, aligned_offset, *p);
708 err = t4_seeprom_wp(adapter, true);
715 static int set_flash(struct net_device *netdev, struct ethtool_flash *ef)
718 const struct firmware *fw;
719 struct adapter *adap = netdev2adap(netdev);
720 unsigned int mbox = PCIE_FW_MASTER_M + 1;
722 ef->data[sizeof(ef->data) - 1] = '\0';
723 ret = request_firmware(&fw, ef->data, adap->pdev_dev);
727 /* If the adapter has been fully initialized then we'll go ahead and
728 * try to get the firmware's cooperation in upgrading to the new
729 * firmware image otherwise we'll try to do the entire job from the
730 * host ... and we always "force" the operation in this path.
732 if (adap->flags & FULL_INIT_DONE)
735 ret = t4_fw_upgrade(adap, mbox, fw->data, fw->size, 1);
736 release_firmware(fw);
738 dev_info(adap->pdev_dev,
739 "loaded firmware %s, reload cxgb4 driver\n", ef->data);
743 #define WOL_SUPPORTED (WAKE_BCAST | WAKE_MAGIC)
744 #define BCAST_CRC 0xa0ccc1a6
746 static void get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
748 wol->supported = WAKE_BCAST | WAKE_MAGIC;
749 wol->wolopts = netdev2adap(dev)->wol;
750 memset(&wol->sopass, 0, sizeof(wol->sopass));
753 static int set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
756 struct port_info *pi = netdev_priv(dev);
758 if (wol->wolopts & ~WOL_SUPPORTED)
760 t4_wol_magic_enable(pi->adapter, pi->tx_chan,
761 (wol->wolopts & WAKE_MAGIC) ? dev->dev_addr : NULL);
762 if (wol->wolopts & WAKE_BCAST) {
763 err = t4_wol_pat_enable(pi->adapter, pi->tx_chan, 0xfe, ~0ULL,
766 err = t4_wol_pat_enable(pi->adapter, pi->tx_chan, 1,
767 ~6ULL, ~0ULL, BCAST_CRC, true);
769 t4_wol_pat_enable(pi->adapter, pi->tx_chan, 0, 0, 0, 0, false);
774 static u32 get_rss_table_size(struct net_device *dev)
776 const struct port_info *pi = netdev_priv(dev);
781 static int get_rss_table(struct net_device *dev, u32 *p, u8 *key, u8 *hfunc)
783 const struct port_info *pi = netdev_priv(dev);
784 unsigned int n = pi->rss_size;
787 *hfunc = ETH_RSS_HASH_TOP;
795 static int set_rss_table(struct net_device *dev, const u32 *p, const u8 *key,
799 struct port_info *pi = netdev_priv(dev);
801 /* We require at least one supported parameter to be changed and no
802 * change in any of the unsupported parameters
805 (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP))
810 for (i = 0; i < pi->rss_size; i++)
812 if (pi->adapter->flags & FULL_INIT_DONE)
813 return cxgb4_write_rss(pi, pi->rss);
817 static int get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
820 const struct port_info *pi = netdev_priv(dev);
823 case ETHTOOL_GRXFH: {
824 unsigned int v = pi->rss_mode;
827 switch (info->flow_type) {
829 if (v & FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN_F)
830 info->data = RXH_IP_SRC | RXH_IP_DST |
831 RXH_L4_B_0_1 | RXH_L4_B_2_3;
832 else if (v & FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN_F)
833 info->data = RXH_IP_SRC | RXH_IP_DST;
836 if ((v & FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN_F) &&
837 (v & FW_RSS_VI_CONFIG_CMD_UDPEN_F))
838 info->data = RXH_IP_SRC | RXH_IP_DST |
839 RXH_L4_B_0_1 | RXH_L4_B_2_3;
840 else if (v & FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN_F)
841 info->data = RXH_IP_SRC | RXH_IP_DST;
846 if (v & FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN_F)
847 info->data = RXH_IP_SRC | RXH_IP_DST;
850 if (v & FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN_F)
851 info->data = RXH_IP_SRC | RXH_IP_DST |
852 RXH_L4_B_0_1 | RXH_L4_B_2_3;
853 else if (v & FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN_F)
854 info->data = RXH_IP_SRC | RXH_IP_DST;
857 if ((v & FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN_F) &&
858 (v & FW_RSS_VI_CONFIG_CMD_UDPEN_F))
859 info->data = RXH_IP_SRC | RXH_IP_DST |
860 RXH_L4_B_0_1 | RXH_L4_B_2_3;
861 else if (v & FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN_F)
862 info->data = RXH_IP_SRC | RXH_IP_DST;
867 if (v & FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN_F)
868 info->data = RXH_IP_SRC | RXH_IP_DST;
873 case ETHTOOL_GRXRINGS:
874 info->data = pi->nqsets;
880 static const struct ethtool_ops cxgb_ethtool_ops = {
881 .get_settings = get_settings,
882 .set_settings = set_settings,
883 .get_drvinfo = get_drvinfo,
884 .get_msglevel = get_msglevel,
885 .set_msglevel = set_msglevel,
886 .get_ringparam = get_sge_param,
887 .set_ringparam = set_sge_param,
888 .get_coalesce = get_coalesce,
889 .set_coalesce = set_coalesce,
890 .get_eeprom_len = get_eeprom_len,
891 .get_eeprom = get_eeprom,
892 .set_eeprom = set_eeprom,
893 .get_pauseparam = get_pauseparam,
894 .set_pauseparam = set_pauseparam,
895 .get_link = ethtool_op_get_link,
896 .get_strings = get_strings,
897 .set_phys_id = identify_port,
898 .nway_reset = restart_autoneg,
899 .get_sset_count = get_sset_count,
900 .get_ethtool_stats = get_stats,
901 .get_regs_len = get_regs_len,
902 .get_regs = get_regs,
905 .get_rxnfc = get_rxnfc,
906 .get_rxfh_indir_size = get_rss_table_size,
907 .get_rxfh = get_rss_table,
908 .set_rxfh = set_rss_table,
909 .flash_device = set_flash,
912 void cxgb4_set_ethtool_ops(struct net_device *netdev)
914 netdev->ethtool_ops = &cxgb_ethtool_ops;