aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/chelsio
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2007-12-09 23:41:22 -0500
committerPaul Mackerras <paulus@samba.org>2007-12-09 23:41:22 -0500
commitb242a60206881559bb3102110048762422e6b74e (patch)
tree86459efa47b9c3f69d865b4495beede9c4184003 /drivers/net/chelsio
parente1fd18656c2963e383d67b7006c0e06c9c1d9c79 (diff)
parent94545baded0bfbabdc30a3a4cb48b3db479dd6ef (diff)
Merge branch 'linux-2.6'
Diffstat (limited to 'drivers/net/chelsio')
-rw-r--r--drivers/net/chelsio/cxgb2.c70
-rw-r--r--drivers/net/chelsio/pm3393.c112
-rw-r--r--drivers/net/chelsio/sge.c44
-rw-r--r--drivers/net/chelsio/sge.h3
4 files changed, 116 insertions, 113 deletions
diff --git a/drivers/net/chelsio/cxgb2.c b/drivers/net/chelsio/cxgb2.c
index 2dbf8dc116c6..c5975047c89b 100644
--- a/drivers/net/chelsio/cxgb2.c
+++ b/drivers/net/chelsio/cxgb2.c
@@ -374,7 +374,9 @@ static char stats_strings[][ETH_GSTRING_LEN] = {
374 "TxInternalMACXmitError", 374 "TxInternalMACXmitError",
375 "TxFramesWithExcessiveDeferral", 375 "TxFramesWithExcessiveDeferral",
376 "TxFCSErrors", 376 "TxFCSErrors",
377 377 "TxJumboFramesOk",
378 "TxJumboOctetsOk",
379
378 "RxOctetsOK", 380 "RxOctetsOK",
379 "RxOctetsBad", 381 "RxOctetsBad",
380 "RxUnicastFramesOK", 382 "RxUnicastFramesOK",
@@ -392,16 +394,17 @@ static char stats_strings[][ETH_GSTRING_LEN] = {
392 "RxInRangeLengthErrors", 394 "RxInRangeLengthErrors",
393 "RxOutOfRangeLengthField", 395 "RxOutOfRangeLengthField",
394 "RxFrameTooLongErrors", 396 "RxFrameTooLongErrors",
397 "RxJumboFramesOk",
398 "RxJumboOctetsOk",
395 399
396 /* Port stats */ 400 /* Port stats */
397 "RxPackets",
398 "RxCsumGood", 401 "RxCsumGood",
399 "TxPackets",
400 "TxCsumOffload", 402 "TxCsumOffload",
401 "TxTso", 403 "TxTso",
402 "RxVlan", 404 "RxVlan",
403 "TxVlan", 405 "TxVlan",
404 406 "TxNeedHeadroom",
407
405 /* Interrupt stats */ 408 /* Interrupt stats */
406 "rx drops", 409 "rx drops",
407 "pure_rsps", 410 "pure_rsps",
@@ -463,23 +466,56 @@ static void get_stats(struct net_device *dev, struct ethtool_stats *stats,
463 const struct cmac_statistics *s; 466 const struct cmac_statistics *s;
464 const struct sge_intr_counts *t; 467 const struct sge_intr_counts *t;
465 struct sge_port_stats ss; 468 struct sge_port_stats ss;
466 unsigned int len;
467 469
468 s = mac->ops->statistics_update(mac, MAC_STATS_UPDATE_FULL); 470 s = mac->ops->statistics_update(mac, MAC_STATS_UPDATE_FULL);
469 471 t = t1_sge_get_intr_counts(adapter->sge);
470 len = sizeof(u64)*(&s->TxFCSErrors + 1 - &s->TxOctetsOK);
471 memcpy(data, &s->TxOctetsOK, len);
472 data += len;
473
474 len = sizeof(u64)*(&s->RxFrameTooLongErrors + 1 - &s->RxOctetsOK);
475 memcpy(data, &s->RxOctetsOK, len);
476 data += len;
477
478 t1_sge_get_port_stats(adapter->sge, dev->if_port, &ss); 472 t1_sge_get_port_stats(adapter->sge, dev->if_port, &ss);
479 memcpy(data, &ss, sizeof(ss));
480 data += sizeof(ss);
481 473
482 t = t1_sge_get_intr_counts(adapter->sge); 474 *data++ = s->TxOctetsOK;
475 *data++ = s->TxOctetsBad;
476 *data++ = s->TxUnicastFramesOK;
477 *data++ = s->TxMulticastFramesOK;
478 *data++ = s->TxBroadcastFramesOK;
479 *data++ = s->TxPauseFrames;
480 *data++ = s->TxFramesWithDeferredXmissions;
481 *data++ = s->TxLateCollisions;
482 *data++ = s->TxTotalCollisions;
483 *data++ = s->TxFramesAbortedDueToXSCollisions;
484 *data++ = s->TxUnderrun;
485 *data++ = s->TxLengthErrors;
486 *data++ = s->TxInternalMACXmitError;
487 *data++ = s->TxFramesWithExcessiveDeferral;
488 *data++ = s->TxFCSErrors;
489 *data++ = s->TxJumboFramesOK;
490 *data++ = s->TxJumboOctetsOK;
491
492 *data++ = s->RxOctetsOK;
493 *data++ = s->RxOctetsBad;
494 *data++ = s->RxUnicastFramesOK;
495 *data++ = s->RxMulticastFramesOK;
496 *data++ = s->RxBroadcastFramesOK;
497 *data++ = s->RxPauseFrames;
498 *data++ = s->RxFCSErrors;
499 *data++ = s->RxAlignErrors;
500 *data++ = s->RxSymbolErrors;
501 *data++ = s->RxDataErrors;
502 *data++ = s->RxSequenceErrors;
503 *data++ = s->RxRuntErrors;
504 *data++ = s->RxJabberErrors;
505 *data++ = s->RxInternalMACRcvError;
506 *data++ = s->RxInRangeLengthErrors;
507 *data++ = s->RxOutOfRangeLengthField;
508 *data++ = s->RxFrameTooLongErrors;
509 *data++ = s->RxJumboFramesOK;
510 *data++ = s->RxJumboOctetsOK;
511
512 *data++ = ss.rx_cso_good;
513 *data++ = ss.tx_cso;
514 *data++ = ss.tx_tso;
515 *data++ = ss.vlan_xtract;
516 *data++ = ss.vlan_insert;
517 *data++ = ss.tx_need_hdrroom;
518
483 *data++ = t->rx_drops; 519 *data++ = t->rx_drops;
484 *data++ = t->pure_rsps; 520 *data++ = t->pure_rsps;
485 *data++ = t->unhandled_irqs; 521 *data++ = t->unhandled_irqs;
diff --git a/drivers/net/chelsio/pm3393.c b/drivers/net/chelsio/pm3393.c
index 678778a8d133..2117c4fbb107 100644
--- a/drivers/net/chelsio/pm3393.c
+++ b/drivers/net/chelsio/pm3393.c
@@ -45,7 +45,7 @@
45 45
46#include <linux/crc32.h> 46#include <linux/crc32.h>
47 47
48#define OFFSET(REG_ADDR) (REG_ADDR << 2) 48#define OFFSET(REG_ADDR) ((REG_ADDR) << 2)
49 49
50/* Max frame size PM3393 can handle. Includes Ethernet header and CRC. */ 50/* Max frame size PM3393 can handle. Includes Ethernet header and CRC. */
51#define MAX_FRAME_SIZE 9600 51#define MAX_FRAME_SIZE 9600
@@ -428,69 +428,26 @@ static int pm3393_set_speed_duplex_fc(struct cmac *cmac, int speed, int duplex,
428 return 0; 428 return 0;
429} 429}
430 430
431static void pm3393_rmon_update(struct adapter *adapter, u32 offs, u64 *val, 431#define RMON_UPDATE(mac, name, stat_name) \
432 int over) 432{ \
433{ 433 t1_tpi_read((mac)->adapter, OFFSET(name), &val0); \
434 u32 val0, val1, val2; 434 t1_tpi_read((mac)->adapter, OFFSET((name)+1), &val1); \
435 435 t1_tpi_read((mac)->adapter, OFFSET((name)+2), &val2); \
436 t1_tpi_read(adapter, offs, &val0); 436 (mac)->stats.stat_name = (u64)(val0 & 0xffff) | \
437 t1_tpi_read(adapter, offs + 4, &val1); 437 ((u64)(val1 & 0xffff) << 16) | \
438 t1_tpi_read(adapter, offs + 8, &val2); 438 ((u64)(val2 & 0xff) << 32) | \
439 439 ((mac)->stats.stat_name & \
440 *val &= ~0ull << 40; 440 0xffffff0000000000ULL); \
441 *val |= val0 & 0xffff; 441 if (ro & \
442 *val |= (val1 & 0xffff) << 16; 442 (1ULL << ((name - SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW) >> 2))) \
443 *val |= (u64)(val2 & 0xff) << 32; 443 (mac)->stats.stat_name += 1ULL << 40; \
444
445 if (over)
446 *val += 1ull << 40;
447} 444}
448 445
449static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac, 446static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac,
450 int flag) 447 int flag)
451{ 448{
452 static struct { 449 u64 ro;
453 unsigned int reg; 450 u32 val0, val1, val2, val3;
454 unsigned int offset;
455 } hw_stats [] = {
456
457#define HW_STAT(name, stat_name) \
458 { name, (&((struct cmac_statistics *)NULL)->stat_name) - (u64 *)NULL }
459
460 /* Rx stats */
461 HW_STAT(RxOctetsReceivedOK, RxOctetsOK),
462 HW_STAT(RxUnicastFramesReceivedOK, RxUnicastFramesOK),
463 HW_STAT(RxMulticastFramesReceivedOK, RxMulticastFramesOK),
464 HW_STAT(RxBroadcastFramesReceivedOK, RxBroadcastFramesOK),
465 HW_STAT(RxPAUSEMACCtrlFramesReceived, RxPauseFrames),
466 HW_STAT(RxFrameCheckSequenceErrors, RxFCSErrors),
467 HW_STAT(RxFramesLostDueToInternalMACErrors,
468 RxInternalMACRcvError),
469 HW_STAT(RxSymbolErrors, RxSymbolErrors),
470 HW_STAT(RxInRangeLengthErrors, RxInRangeLengthErrors),
471 HW_STAT(RxFramesTooLongErrors , RxFrameTooLongErrors),
472 HW_STAT(RxJabbers, RxJabberErrors),
473 HW_STAT(RxFragments, RxRuntErrors),
474 HW_STAT(RxUndersizedFrames, RxRuntErrors),
475 HW_STAT(RxJumboFramesReceivedOK, RxJumboFramesOK),
476 HW_STAT(RxJumboOctetsReceivedOK, RxJumboOctetsOK),
477
478 /* Tx stats */
479 HW_STAT(TxOctetsTransmittedOK, TxOctetsOK),
480 HW_STAT(TxFramesLostDueToInternalMACTransmissionError,
481 TxInternalMACXmitError),
482 HW_STAT(TxTransmitSystemError, TxFCSErrors),
483 HW_STAT(TxUnicastFramesTransmittedOK, TxUnicastFramesOK),
484 HW_STAT(TxMulticastFramesTransmittedOK, TxMulticastFramesOK),
485 HW_STAT(TxBroadcastFramesTransmittedOK, TxBroadcastFramesOK),
486 HW_STAT(TxPAUSEMACCtrlFramesTransmitted, TxPauseFrames),
487 HW_STAT(TxJumboFramesReceivedOK, TxJumboFramesOK),
488 HW_STAT(TxJumboOctetsReceivedOK, TxJumboOctetsOK)
489 }, *p = hw_stats;
490 u64 ro;
491 u32 val0, val1, val2, val3;
492 u64 *stats = (u64 *) &mac->stats;
493 unsigned int i;
494 451
495 /* Snap the counters */ 452 /* Snap the counters */
496 pmwrite(mac, SUNI1x10GEXP_REG_MSTAT_CONTROL, 453 pmwrite(mac, SUNI1x10GEXP_REG_MSTAT_CONTROL,
@@ -504,14 +461,35 @@ static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac,
504 ro = ((u64)val0 & 0xffff) | (((u64)val1 & 0xffff) << 16) | 461 ro = ((u64)val0 & 0xffff) | (((u64)val1 & 0xffff) << 16) |
505 (((u64)val2 & 0xffff) << 32) | (((u64)val3 & 0xffff) << 48); 462 (((u64)val2 & 0xffff) << 32) | (((u64)val3 & 0xffff) << 48);
506 463
507 for (i = 0; i < ARRAY_SIZE(hw_stats); i++) { 464 /* Rx stats */
508 unsigned reg = p->reg - SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW; 465 RMON_UPDATE(mac, RxOctetsReceivedOK, RxOctetsOK);
509 466 RMON_UPDATE(mac, RxUnicastFramesReceivedOK, RxUnicastFramesOK);
510 pm3393_rmon_update((mac)->adapter, OFFSET(p->reg), 467 RMON_UPDATE(mac, RxMulticastFramesReceivedOK, RxMulticastFramesOK);
511 stats + p->offset, ro & (reg >> 2)); 468 RMON_UPDATE(mac, RxBroadcastFramesReceivedOK, RxBroadcastFramesOK);
512 } 469 RMON_UPDATE(mac, RxPAUSEMACCtrlFramesReceived, RxPauseFrames);
513 470 RMON_UPDATE(mac, RxFrameCheckSequenceErrors, RxFCSErrors);
514 471 RMON_UPDATE(mac, RxFramesLostDueToInternalMACErrors,
472 RxInternalMACRcvError);
473 RMON_UPDATE(mac, RxSymbolErrors, RxSymbolErrors);
474 RMON_UPDATE(mac, RxInRangeLengthErrors, RxInRangeLengthErrors);
475 RMON_UPDATE(mac, RxFramesTooLongErrors , RxFrameTooLongErrors);
476 RMON_UPDATE(mac, RxJabbers, RxJabberErrors);
477 RMON_UPDATE(mac, RxFragments, RxRuntErrors);
478 RMON_UPDATE(mac, RxUndersizedFrames, RxRuntErrors);
479 RMON_UPDATE(mac, RxJumboFramesReceivedOK, RxJumboFramesOK);
480 RMON_UPDATE(mac, RxJumboOctetsReceivedOK, RxJumboOctetsOK);
481
482 /* Tx stats */
483 RMON_UPDATE(mac, TxOctetsTransmittedOK, TxOctetsOK);
484 RMON_UPDATE(mac, TxFramesLostDueToInternalMACTransmissionError,
485 TxInternalMACXmitError);
486 RMON_UPDATE(mac, TxTransmitSystemError, TxFCSErrors);
487 RMON_UPDATE(mac, TxUnicastFramesTransmittedOK, TxUnicastFramesOK);
488 RMON_UPDATE(mac, TxMulticastFramesTransmittedOK, TxMulticastFramesOK);
489 RMON_UPDATE(mac, TxBroadcastFramesTransmittedOK, TxBroadcastFramesOK);
490 RMON_UPDATE(mac, TxPAUSEMACCtrlFramesTransmitted, TxPauseFrames);
491 RMON_UPDATE(mac, TxJumboFramesReceivedOK, TxJumboFramesOK);
492 RMON_UPDATE(mac, TxJumboOctetsReceivedOK, TxJumboOctetsOK);
515 493
516 return &mac->stats; 494 return &mac->stats;
517} 495}
diff --git a/drivers/net/chelsio/sge.c b/drivers/net/chelsio/sge.c
index 443666292a5c..b301c0428ae0 100644
--- a/drivers/net/chelsio/sge.c
+++ b/drivers/net/chelsio/sge.c
@@ -986,11 +986,10 @@ void t1_sge_get_port_stats(const struct sge *sge, int port,
986 for_each_possible_cpu(cpu) { 986 for_each_possible_cpu(cpu) {
987 struct sge_port_stats *st = per_cpu_ptr(sge->port_stats[port], cpu); 987 struct sge_port_stats *st = per_cpu_ptr(sge->port_stats[port], cpu);
988 988
989 ss->rx_packets += st->rx_packets;
990 ss->rx_cso_good += st->rx_cso_good; 989 ss->rx_cso_good += st->rx_cso_good;
991 ss->tx_packets += st->tx_packets;
992 ss->tx_cso += st->tx_cso; 990 ss->tx_cso += st->tx_cso;
993 ss->tx_tso += st->tx_tso; 991 ss->tx_tso += st->tx_tso;
992 ss->tx_need_hdrroom += st->tx_need_hdrroom;
994 ss->vlan_xtract += st->vlan_xtract; 993 ss->vlan_xtract += st->vlan_xtract;
995 ss->vlan_insert += st->vlan_insert; 994 ss->vlan_insert += st->vlan_insert;
996 } 995 }
@@ -1380,7 +1379,6 @@ static void sge_rx(struct sge *sge, struct freelQ *fl, unsigned int len)
1380 __skb_pull(skb, sizeof(*p)); 1379 __skb_pull(skb, sizeof(*p));
1381 1380
1382 st = per_cpu_ptr(sge->port_stats[p->iff], smp_processor_id()); 1381 st = per_cpu_ptr(sge->port_stats[p->iff], smp_processor_id());
1383 st->rx_packets++;
1384 1382
1385 skb->protocol = eth_type_trans(skb, adapter->port[p->iff].dev); 1383 skb->protocol = eth_type_trans(skb, adapter->port[p->iff].dev);
1386 skb->dev->last_rx = jiffies; 1384 skb->dev->last_rx = jiffies;
@@ -1624,11 +1622,9 @@ int t1_poll(struct napi_struct *napi, int budget)
1624{ 1622{
1625 struct adapter *adapter = container_of(napi, struct adapter, napi); 1623 struct adapter *adapter = container_of(napi, struct adapter, napi);
1626 struct net_device *dev = adapter->port[0].dev; 1624 struct net_device *dev = adapter->port[0].dev;
1627 int work_done; 1625 int work_done = process_responses(adapter, budget);
1628
1629 work_done = process_responses(adapter, budget);
1630 1626
1631 if (likely(!responses_pending(adapter))) { 1627 if (likely(work_done < budget)) {
1632 netif_rx_complete(dev, napi); 1628 netif_rx_complete(dev, napi);
1633 writel(adapter->sge->respQ.cidx, 1629 writel(adapter->sge->respQ.cidx,
1634 adapter->regs + A_SG_SLEEPING); 1630 adapter->regs + A_SG_SLEEPING);
@@ -1848,7 +1844,8 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1848{ 1844{
1849 struct adapter *adapter = dev->priv; 1845 struct adapter *adapter = dev->priv;
1850 struct sge *sge = adapter->sge; 1846 struct sge *sge = adapter->sge;
1851 struct sge_port_stats *st = per_cpu_ptr(sge->port_stats[dev->if_port], smp_processor_id()); 1847 struct sge_port_stats *st = per_cpu_ptr(sge->port_stats[dev->if_port],
1848 smp_processor_id());
1852 struct cpl_tx_pkt *cpl; 1849 struct cpl_tx_pkt *cpl;
1853 struct sk_buff *orig_skb = skb; 1850 struct sk_buff *orig_skb = skb;
1854 int ret; 1851 int ret;
@@ -1856,6 +1853,18 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1856 if (skb->protocol == htons(ETH_P_CPL5)) 1853 if (skb->protocol == htons(ETH_P_CPL5))
1857 goto send; 1854 goto send;
1858 1855
1856 /*
1857 * We are using a non-standard hard_header_len.
1858 * Allocate more header room in the rare cases it is not big enough.
1859 */
1860 if (unlikely(skb_headroom(skb) < dev->hard_header_len - ETH_HLEN)) {
1861 skb = skb_realloc_headroom(skb, sizeof(struct cpl_tx_pkt_lso));
1862 ++st->tx_need_hdrroom;
1863 dev_kfree_skb_any(orig_skb);
1864 if (!skb)
1865 return NETDEV_TX_OK;
1866 }
1867
1859 if (skb_shinfo(skb)->gso_size) { 1868 if (skb_shinfo(skb)->gso_size) {
1860 int eth_type; 1869 int eth_type;
1861 struct cpl_tx_pkt_lso *hdr; 1870 struct cpl_tx_pkt_lso *hdr;
@@ -1889,24 +1898,6 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1889 return NETDEV_TX_OK; 1898 return NETDEV_TX_OK;
1890 } 1899 }
1891 1900
1892 /*
1893 * We are using a non-standard hard_header_len and some kernel
1894 * components, such as pktgen, do not handle it right.
1895 * Complain when this happens but try to fix things up.
1896 */
1897 if (unlikely(skb_headroom(skb) < dev->hard_header_len - ETH_HLEN)) {
1898 pr_debug("%s: headroom %d header_len %d\n", dev->name,
1899 skb_headroom(skb), dev->hard_header_len);
1900
1901 if (net_ratelimit())
1902 printk(KERN_ERR "%s: inadequate headroom in "
1903 "Tx packet\n", dev->name);
1904 skb = skb_realloc_headroom(skb, sizeof(*cpl));
1905 dev_kfree_skb_any(orig_skb);
1906 if (!skb)
1907 return NETDEV_TX_OK;
1908 }
1909
1910 if (!(adapter->flags & UDP_CSUM_CAPABLE) && 1901 if (!(adapter->flags & UDP_CSUM_CAPABLE) &&
1911 skb->ip_summed == CHECKSUM_PARTIAL && 1902 skb->ip_summed == CHECKSUM_PARTIAL &&
1912 ip_hdr(skb)->protocol == IPPROTO_UDP) { 1903 ip_hdr(skb)->protocol == IPPROTO_UDP) {
@@ -1952,7 +1943,6 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1952 cpl->vlan_valid = 0; 1943 cpl->vlan_valid = 0;
1953 1944
1954send: 1945send:
1955 st->tx_packets++;
1956 dev->trans_start = jiffies; 1946 dev->trans_start = jiffies;
1957 ret = t1_sge_tx(skb, adapter, 0, dev); 1947 ret = t1_sge_tx(skb, adapter, 0, dev);
1958 1948
diff --git a/drivers/net/chelsio/sge.h b/drivers/net/chelsio/sge.h
index 713d9c55f24d..cced9dff91c5 100644
--- a/drivers/net/chelsio/sge.h
+++ b/drivers/net/chelsio/sge.h
@@ -57,13 +57,12 @@ struct sge_intr_counts {
57}; 57};
58 58
59struct sge_port_stats { 59struct sge_port_stats {
60 u64 rx_packets; /* # of Ethernet packets received */
61 u64 rx_cso_good; /* # of successful RX csum offloads */ 60 u64 rx_cso_good; /* # of successful RX csum offloads */
62 u64 tx_packets; /* # of TX packets */
63 u64 tx_cso; /* # of TX checksum offloads */ 61 u64 tx_cso; /* # of TX checksum offloads */
64 u64 tx_tso; /* # of TSO requests */ 62 u64 tx_tso; /* # of TSO requests */
65 u64 vlan_xtract; /* # of VLAN tag extractions */ 63 u64 vlan_xtract; /* # of VLAN tag extractions */
66 u64 vlan_insert; /* # of VLAN tag insertions */ 64 u64 vlan_insert; /* # of VLAN tag insertions */
65 u64 tx_need_hdrroom; /* # of TX skbs in need of more header room */
67}; 66};
68 67
69struct sk_buff; 68struct sk_buff;