chelsio: 10G driver
Subsystems (2)
cover chelsio: 10G driver
These patches are against netdev-2.6#upstream version of driver.
PATCH 1/10 chelsio: whitespace fixes
Fix indentation and blank/tab issues.
--- drivers/net/chelsio/cxgb2.c | 2 +- drivers/net/chelsio/espi.c | 2 +- drivers/net/chelsio/pm3393.c | 16 ++++++++-------- drivers/net/chelsio/subr.c | 12 ++++++------ 4 files changed, 16 insertions(+), 16 deletions(-)
drivers/net/chelsio/cxgb2.c +1 -1
@@ -729,7 +729,7 @@ static int get_coalesce(struct net_devicstatic int get_eeprom_len (struct net_device *dev) { -return EEPROM_SIZE ; +return EEPROM_SIZE ; }#define EEPROM_MAGIC (ap) \
drivers/net/chelsio/espi.c +1 -1
@@ -192,7 +192,7 @@ int t1_espi_intr_handler(struct peespi *const struct espi_intr_counts *t1_espi_get_intr_counts (struct peespi *espi) { -return &espi->intr_cnt; +return &espi->intr_cnt; }static void espi_setup_for_pm3393 (adapter_t *adapter)
drivers/net/chelsio/pm3393.c +8 -8
@@ -46,17 +46,17 @@/* 802.3ae 10Gb/s MDIO Manageable Device(MMD) */ enum { -MMD_RESERVED , -MMD_PMAPMD , -MMD_WIS , -MMD_PCS , -MMD_PHY_XGXS ,/* XGMII Extender Sublayer */ -MMD_DTE_XGXS , +MMD_RESERVED , +MMD_PMAPMD , +MMD_WIS , +MMD_PCS , +MMD_PHY_XGXS ,/* XGMII Extender Sublayer */ +MMD_DTE_XGXS , };enum { -PHY_XGXS_CTRL_1 , -PHY_XGXS_STATUS_1 +PHY_XGXS_CTRL_1 , +PHY_XGXS_STATUS_1 };#define OFFSET (REG_ADDR ) (REG_ADDR << 2)
drivers/net/chelsio/subr.c +6 -6
@@ -166,11 +166,11 @@ static int t1_pci_intr_handler(adapter_t {u32 pcix_cause; -pci_read_config_dword (adapter->pdev,A_PCICFG_INTR_CAUSE , &pcix_cause); +pci_read_config_dword (adapter->pdev,A_PCICFG_INTR_CAUSE , &pcix_cause);if (pcix_cause) {pci_write_config_dword (adapter->pdev,A_PCICFG_INTR_CAUSE , - pcix_cause); + pcix_cause);t1_fatal_err (adapter);/* PCI errors are fatal */ }return 0 ;
@@ -420,9 +420,9 @@ int t1_link_start(struct cphy *phy, stru*/ int elmer0_ext_intr_handler (adapter_t *adapter) { -struct cphy *phy; +struct cphy *phy;int phy_cause; -u32 cause; +u32 cause;t1_tpi_read (adapter,A_ELMER0_INT_CAUSE , &cause);
@@ -515,7 +515,7 @@ void t1_interrupts_clear(adapter_t* adap }/* Enable interrupts for external devices. */ - pl_intr =readl (adapter->regs +A_PL_CAUSE ); + pl_intr =readl (adapter->regs +A_PL_CAUSE );writel (pl_intr |F_PL_INTR_EXT |F_PL_INTR_PCIX , adapter->regs +A_PL_CAUSE );
@@ -643,7 +643,7 @@ static int board_init(adapter_t *adaptercase CHBT_BOARD_N110 :case CHBT_BOARD_N210 :writel (V_TPIPAR (0xf ), adapter->regs +A_TPI_PAR ); -t1_tpi_write (adapter,A_ELMER0_GPO ,0x800 ); +t1_tpi_write (adapter,A_ELMER0_GPO ,0x800 );break ; }return 0 ;
PATCH 2/10 chelsio: use kzalloc
In reply to Stephen HemmingerUse kzalloc in several places.
--- drivers/net/chelsio/mv88x201x.c | 4 ++-- drivers/net/chelsio/pm3393.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/chelsio/mv88x201x.c +2 -2
@@ -205,11 +205,11 @@ static struct cphy *mv88x201x_phy_create struct mdio_ops *mdio_ops) {u32 val; -struct cphy *cphy =kmalloc (sizeof (*cphy),GFP_KERNEL ); +struct cphy *cphy =kzalloc (sizeof (*cphy),GFP_KERNEL );if (!cphy)return NULL ; -memset (cphy,0 ,sizeof (*cphy)); +cphy_init (cphy, adapter, phy_addr, &mv88x201x_ops, mdio_ops);/* Commands the PHY to enable XFP's clock. */
drivers/net/chelsio/pm3393.c +1 -2
@@ -631,10 +631,9 @@ static struct cmac *pm3393_mac_create(ad {struct cmac *cmac; - cmac =kmalloc (sizeof (*cmac) +sizeof (cmac_instance),GFP_KERNEL ); + cmac =kzalloc (sizeof (*cmac) +sizeof (cmac_instance),GFP_KERNEL );if (!cmac)return NULL ; -memset (cmac,0 ,sizeof (*cmac)); cmac->ops = &pm3393_ops; cmac->instance = (cmac_instance *) (cmac +1 );
PATCH 3/10 chelsio: remove unused mutex
In reply to Stephen HemmingerThis mutex is unused in current (non TOE) code.
--- drivers/net/chelsio/common.h | 1 - drivers/net/chelsio/cxgb2.c | 1 - 2 files changed, 2 deletions(-)
drivers/net/chelsio/common.h +0 -1
@@ -212,7 +212,6 @@ struct adapter {struct work_struct stats_update_task;struct timer_list stats_update_timer; -struct semaphore mib_mutex;spinlock_t tpi_lock;spinlock_t work_lock;/* guards async operations */
drivers/net/chelsio/cxgb2.c +0 -1
@@ -1040,7 +1040,6 @@ static int __devinit init_one(struct pci adapter->msg_enable = dflt_msg_enable; adapter->mmio_len = mmio_len; -init_MUTEX (&adapter->mib_mutex);spin_lock_init (&adapter->tpi_lock);spin_lock_init (&adapter->work_lock);spin_lock_init (&adapter->async_lock);
PATCH 5/10 chelsio: add 1G swcixw aupport
In reply to Stephen HemmingerAdd support for 1G versions of Chelsio devices.
--- drivers/net/Kconfig | 7 drivers/net/chelsio/Makefile | 1 drivers/net/chelsio/common.h | 2 drivers/net/chelsio/cxgb2.c | 1 drivers/net/chelsio/ixf1010.c | 485 +++++++++++++++++++++++++ drivers/net/chelsio/mac.c | 368 +++++++++++++++++++ drivers/net/chelsio/mv88e1xxx.c | 397 ++++++++++++++++++++ drivers/net/chelsio/subr.c | 221 +++++++++++ drivers/net/chelsio/tp.c | 33 + drivers/net/chelsio/vsc7326.c | 725 ++++++++++++++++++++++++++++++++++++++ drivers/net/chelsio/vsc8244.c | 368 +++++++++++++++++++ drivers/net/chelsio/vsc8244_reg.h | 172 +++++++++ 12 files changed, 2780 insertions(+)
drivers/net/chelsio/Makefile +1 -0
@@ -4,6 +4,7 @@ obj-$(CONFIG_CHELSIO_T1) += cxgb.o +cxgb-$(CONFIG_CHELSIO_T1_1G) += ixf1010.o mac.o mv88e1xxx.o vsc7326.o vsc8244.o cxgb-objs := cxgb2.o espi.o tp.o pm3393.o sge.o subr.o \ mv88x201x.o my3126.o $(cxgb-y)
drivers/net/chelsio/ixf1010.c new file +485 -0
485 lines not on this page · raw message
drivers/net/chelsio/mac.c new file +368 -0
368 lines not on this page · raw message
drivers/net/chelsio/mv88e1xxx.c new file +397 -0
397 lines not on this page · raw message
drivers/net/chelsio/subr.c +221 -0
281 lines not on this page · raw message
drivers/net/chelsio/tp.c +33 -0
@@ -2,6 +2,9 @@#include "common.h" #include "regs.h" #include "tp.h" +#ifdef CONFIG_CHELSIO_T1_1G +#include "fpga_defs.h" +#endif struct petp {adapter_t *adapter;
@@ -70,6 +73,15 @@ void t1_tp_intr_enable(struct petp *tp) {u32 tp_intr =readl (tp->adapter->regs +A_PL_ENABLE ); +#ifdef CONFIG_CHELSIO_T1_1G +if (!t1_is_asic (tp->adapter)) { +/* FPGA */ +writel (0xffffffff , + tp->adapter->regs +FPGA_TP_ADDR_INTERRUPT_ENABLE ); +writel (tp_intr |FPGA_PCIX_INTERRUPT_TP , + tp->adapter->regs +A_PL_ENABLE ); + } else +#endif {/* We don't use any TP interrupts */ writel (0 , tp->adapter->regs +A_TP_INT_ENABLE );
@@ -82,6 +94,14 @@ void t1_tp_intr_disable(struct petp *tp) {u32 tp_intr =readl (tp->adapter->regs +A_PL_ENABLE ); +#ifdef CONFIG_CHELSIO_T1_1G +if (!t1_is_asic (tp->adapter)) { +/* FPGA */ +writel (0 , tp->adapter->regs +FPGA_TP_ADDR_INTERRUPT_ENABLE ); +writel (tp_intr & ~FPGA_PCIX_INTERRUPT_TP , + tp->adapter->regs +A_PL_ENABLE ); + } else +#endif {writel (0 , tp->adapter->regs +A_TP_INT_ENABLE ); writel(tp_intr & ~F_PL_INTR_TP,
@@ -91,6 +111,14 @@ void t1_tp_intr_disable(struct petp *tp)void t1_tp_intr_clear (struct petp *tp) { +#ifdef CONFIG_CHELSIO_T1_1G +if (!t1_is_asic (tp->adapter)) { +writel (0xffffffff , + tp->adapter->regs +FPGA_TP_ADDR_INTERRUPT_CAUSE ); +writel (FPGA_PCIX_INTERRUPT_TP , tp->adapter->regs +A_PL_CAUSE ); +return ; + } +#endif writel (0xffffffff , tp->adapter->regs +A_TP_INT_CAUSE );writel (F_PL_INTR_TP , tp->adapter->regs +A_PL_CAUSE ); }
@@ -99,6 +127,11 @@ int t1_tp_intr_handler(struct petp *tp) {u32 cause; +#ifdef CONFIG_CHELSIO_T1_1G +/* FPGA doesn't support TP interrupts. */ +if (!t1_is_asic (tp->adapter)) +return 1 ; +#endif cause =readl (tp->adapter->regs +A_TP_INT_CAUSE );writel (cause, tp->adapter->regs +A_TP_INT_CAUSE );
drivers/net/chelsio/vsc7326.c new file +725 -0
725 lines not on this page · raw message
drivers/net/chelsio/vsc8244.c new file +368 -0
368 lines not on this page · raw message
drivers/net/chelsio/vsc8244_reg.h new file +172 -0
172 lines not on this page · raw message
drivers/net/chelsio/common.h +2 -0
@@ -283,6 +283,8 @@ struct adapter {spinlock_t tpi_lock;spinlock_t work_lock; +spinlock_t mac_lock; +/* guards async operations */ spinlock_t async_lock____cacheline_aligned ;u32 slow_intr_mask;
drivers/net/chelsio/cxgb2.c +1 -0
@@ -1094,6 +1094,7 @@ static int __devinit init_one(struct pcispin_lock_init (&adapter->tpi_lock);spin_lock_init (&adapter->work_lock);spin_lock_init (&adapter->async_lock); +spin_lock_init (&adapter->mac_lock);INIT_WORK (&adapter->ext_intr_handler_task, ext_intr_task, adapter);
drivers/net/Kconfig +7 -0
@@ -2376,6 +2376,13 @@ config CHELSIO_T1 To compile this driver as a module, choose M here: the module will be called cxgb. +config CHELSIO_T1_1G + bool "Chelsio gigabit Ethernet support" + depends on CHELSIO_T1 + help + Enables support for Chelsio's gigabit Ethernet PCI cards. If you + are using only 10G cards say 'N' here. + config EHEA tristate "eHEA Ethernet support" depends on IBMEBUS
PATCH 6/10 chelsio: cleanup pm3393 code
In reply to Stephen HemmingerReplace macro with function for updating RMON values
Cleanups:
* remove unused enum's
* Fix comment format
--- drivers/net/chelsio/pm3393.c | 69 ++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 40 deletions(-)
drivers/net/chelsio/pm3393.c +29 -40
@@ -43,22 +43,6 @@#include "elmer0.h" #include "suni1x10gexp_regs.h" -/* 802.3ae 10Gb/s MDIO Manageable Device(MMD) -*/ -enum { -MMD_RESERVED , -MMD_PMAPMD , -MMD_WIS , -MMD_PCS , -MMD_PHY_XGXS ,/* XGMII Extender Sublayer */ -MMD_DTE_XGXS , -}; - -enum { -PHY_XGXS_CTRL_1 , -PHY_XGXS_STATUS_1 -}; -#define OFFSET (REG_ADDR ) (REG_ADDR << 2)/* Max frame size PM3393 can handle. Includes Ethernet header and CRC. */
@@ -128,12 +112,12 @@ static int pm3393_reset(struct cmac *cma/* * Enable interrupts for the PM3393 - -1. Enable PM3393 BLOCK interrupts. -2. Enable PM3393 Master Interrupt bit(INTE) -3. Enable ELMER's PM3393 bit. -4. Enable Terminator external interrupt. -*/ +* +* 1. Enable PM3393 BLOCK interrupts. +* 2. Enable PM3393 Master Interrupt bit(INTE) +* 3. Enable ELMER's PM3393 bit. +* 4. Enable Terminator external interrupt. +*/ static int pm3393_interrupt_enable (struct cmac *cmac) {u32 pl_intr;
@@ -261,11 +245,7 @@ static int pm3393_interrupt_clear(structstatic int pm3393_interrupt_handler (struct cmac *cmac) {u32 master_intr_status; -/* -1. Read master interrupt register. -2. Read BLOCK's interrupt status registers. -3. Handle BLOCK interrupts. -*/ +/* Read the master interrupt status register. */ pmread (cmac, SUNI1x10GEXP_REG_MASTER_INTERRUPT_STATUS, &master_intr_status);
@@ -473,20 +453,29 @@ static int pm3393_set_speed_duplex_fc(streturn 0 ; } +static void pm3393_rmon_update (struct adapter *adapter,u32 offs,u64 *val, +int over) +{ +u32 val0, val1, val2; + +t1_tpi_read (adapter, offs, &val0); +t1_tpi_read (adapter, offs +4 , &val1); +t1_tpi_read (adapter, offs +8 , &val2); + + *val &= ~0ull <<40 ; + *val |= val0 &0xffff ; + *val |= (val1 &0xffff ) <<16 ; + *val |= (u64)(val2 &0xff ) <<32 ; + +if (over) + *val +=1ull <<40 ; +} +#define RMON_UPDATE (mac, name, stat_name) \ - { \ - t1_tpi_read((mac)->adapter, OFFSET(name), &val0); \ - t1_tpi_read((mac)->adapter, OFFSET(((name)+1)), &val1); \ - t1_tpi_read((mac)->adapter, OFFSET(((name)+2)), &val2); \ - (mac)->stats.stat_name = ((u64)val0 & 0xffff) | \ - (((u64)val1 & 0xffff) << 16) | \ - (((u64)val2 & 0xff) << 32) | \ - ((mac)->stats.stat_name & \ - (~(u64)0 << 40)); \ - if (ro & \ - ((name - SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW) >> 2)) \ - (mac)->stats.stat_name += ((u64)1 << 40); \ - } + pm3393_rmon_update((mac)->adapter, OFFSET(name), \ + &(mac)->stats.stat_name, \ + (ro &((name - SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW) >> 2))) +static const struct cmac_statistics *pm3393_update_statistics (struct cmac *mac,int flag)
PATCH 7/10 chelsio: use standard CRC routines
In reply to Stephen HemmingerReplace driver crc calculation with existing library.
--- drivers/net/Kconfig | 1 + drivers/net/chelsio/pm3393.c | 31 +++---------------------------- 2 files changed, 4 insertions(+), 28 deletions(-)
drivers/net/Kconfig +1 -0
@@ -2360,6 +2360,7 @@ menu "Ethernet (10000 Mbit)" config CHELSIO_T1 tristate "Chelsio 10Gb Ethernet support" depends on PCI + select CRC32 help This driver supports Chelsio gigabit and 10-gigabit Ethernet cards. More information about adapter features and
drivers/net/chelsio/pm3393.c +3 -28
@@ -43,6 +43,8 @@#include "elmer0.h" #include "suni1x10gexp_regs.h" +#include <linux/crc32.h> +#define OFFSET (REG_ADDR ) (REG_ADDR << 2)/* Max frame size PM3393 can handle. Includes Ethernet header and CRC. */
@@ -345,33 +347,6 @@ static int pm3393_set_mtu(struct cmac *creturn 0 ; } -static u32 calc_crc (u8 *b,int len) -{ -int i; -u32 crc = (u32 )~0 ; - -/* calculate crc one bit at a time */ -while (len--) { - crc ^= *b++; -for (i =0 ; i <8 ; i++) { -if (crc &0x1 ) - crc = (crc >>1 ) ^0xedb88320 ; -else - crc = (crc >>1 ); - } - } - -/* reverse bits */ - crc = ((crc >>4 ) &0x0f0f0f0f ) | ((crc <<4 ) &0xf0f0f0f0 ); - crc = ((crc >>2 ) &0x33333333 ) | ((crc <<2 ) &0xcccccccc ); - crc = ((crc >>1 ) &0x55555555 ) | ((crc <<1 ) &0xaaaaaaaa ); -/* swap bytes */ - crc = (crc >>16 ) | (crc <<16 ); - crc = (crc >>8 &0x00ff00ff ) | (crc <<8 &0xff00ff00 ); - -return crc; -} -static int pm3393_set_rx_mode (struct cmac *cmac,struct t1_rx_mode *rm) {int enabled = cmac->instance->enabled &MAC_DIRECTION_RX ;
@@ -405,7 +380,7 @@ static int pm3393_set_rx_mode(struct cmau16 mc_filter[4 ] = {0 , };while ((addr =t1_get_next_mcaddr (rm))) { - bit = (calc_crc (addr,ETH_ALEN ) >>23 ) &0x3f ;/* bit[23:28] */ + bit = (ether_crc (ETH_ALEN , addr) >>23 ) &0x3f ;/* bit[23:28] */ mc_filter[bit >>4 ] |=1 << (bit &0xf ); }pmwrite (cmac, SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_LOW, mc_filter[0 ]);
PATCH 8/10 chelsio: add MSI support
In reply to Stephen HemmingerUsing MSI can avoid sharing IRQ and associated overhead. Tested on PCI-X.
--- drivers/net/chelsio/common.h | 1 + drivers/net/chelsio/cxgb2.c | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-)
drivers/net/chelsio/common.h +1 -0
@@ -228,6 +228,7 @@ struct adapter_params {unsigned short chip_revision;unsigned char chip_version;unsigned char is_asic; +unsigned char has_msi; };struct link_config {
drivers/net/chelsio/cxgb2.c +17 -3
@@ -107,6 +107,10 @@ static int t1powersave = 1; /* HW defaulmodule_param (t1powersave, int,0 );MODULE_PARM_DESC (t1powersave,"Enable/Disable T1 powersaving mode" ); +static int disable_msi =0 ; +module_param (disable_msi, int,0 ); +MODULE_PARM_DESC (disable_msi,"Disable Message Signaled Interrupt (MSI)" ); +static const char pci_speed[][4 ] = {"33" ,"66" ,"100" ,"133" };
@@ -215,11 +219,19 @@ static int cxgb_up(struct adapter *adapt }t1_interrupts_clear (adapter); -if ((err =request_irq (adapter->pdev->irq, -t1_select_intr_handler (adapter),IRQF_SHARED , - adapter->name, adapter))) { + + adapter->params.has_msi = !disable_msi &&pci_enable_msi (adapter->pdev) ==0 ; + err =request_irq (adapter->pdev->irq, +t1_select_intr_handler (adapter), + adapter->params.has_msi ?0 :IRQF_SHARED , + adapter->name, adapter); +if (err) { +if (adapter->params.has_msi) +pci_disable_msi (adapter->pdev); + goto out_err; } +t1_sge_start (adapter->sge);t1_interrupts_enable (adapter); out_err:
@@ -234,6 +246,8 @@ static void cxgb_down(struct adapter *adt1_sge_stop (adapter->sge);t1_interrupts_disable (adapter);free_irq (adapter->pdev->irq, adapter); +if (adapter->params.has_msi) +pci_disable_msi (adapter->pdev); }static int cxgb_open (struct net_device *dev)
PATCH 9/10 chelsio: statistics improvement
In reply to Stephen HemmingerCleanup statistics management:
* Get rid of duplicate or unused statistics
* Convert high volume stats to per-cpu and 64 bit
--- drivers/net/chelsio/cxgb2.c | 74 ++++++++++++++++++++++---------------------- drivers/net/chelsio/sge.c | 65 +++++++++++++++++++++++++++++--------- drivers/net/chelsio/sge.h | 29 +++++++---------- 3 files changed, 100 insertions(+), 68 deletions(-)
drivers/net/chelsio/cxgb2.c +38 -36
@@ -390,13 +390,19 @@ static char stats_strings[][ETH_GSTRING_"RxOutOfRangeLengthField" ,"RxFrameTooLongErrors" , -"TSO" , -"VLANextractions" , -"VLANinsertions" , +/* Port stats */ +"RxPackets" ,"RxCsumGood" , +"TxPackets" ,"TxCsumOffload" , -"RxDrops" - +"TxTso" , +"RxVlan" , +"TxVlan" , + +/* Interrupt stats */ +"rx drops" , +"pure_rsps" , +"unhandled irqs" ,"respQ_empty" ,"respQ_overflow" , "freelistQ_empty",
@@ -404,10 +410,6 @@ static char stats_strings[][ETH_GSTRING_"pkt_mismatch" ,"cmdQ_full0" ,"cmdQ_full1" , -"tx_ipfrags" , -"tx_reg_pkts" , -"tx_lso_pkts" , -"tx_do_cksum" ,"espi_DIP2ParityErr" , "espi_DIP4Err",
@@ -451,12 +453,10 @@ static void get_stats(struct net_devicestruct adapter *adapter = dev->priv;struct cmac *mac = adapter->port[dev->if_port].mac;const struct cmac_statistics *s; -const struct sge_port_stats *ss;const struct sge_intr_counts *t; +struct sge_port_stats ss; s = mac->ops->statistics_update (mac,MAC_STATS_UPDATE_FULL ); - ss =t1_sge_get_port_stats (adapter->sge, dev->if_port); - t =t1_sge_get_intr_counts (adapter->sge); *data++ = s->TxOctetsOK; *data++ = s->TxOctetsBad;
@@ -492,35 +492,37 @@ static void get_stats(struct net_device *data++ = s->RxOutOfRangeLengthField; *data++ = s->RxFrameTooLongErrors; - *data++ = ss->tso; - *data++ = ss->vlan_xtract; - *data++ = ss->vlan_insert; - *data++ = ss->rx_cso_good; - *data++ = ss->tx_cso; - *data++ = ss->rx_drops; - - *data++ = (u64 )t->respQ_empty; - *data++ = (u64 )t->respQ_overflow; - *data++ = (u64 )t->freelistQ_empty; - *data++ = (u64 )t->pkt_too_big; - *data++ = (u64 )t->pkt_mismatch; - *data++ = (u64 )t->cmdQ_full[0 ]; - *data++ = (u64 )t->cmdQ_full[1 ]; - *data++ = (u64 )t->tx_ipfrags; - *data++ = (u64 )t->tx_reg_pkts; - *data++ = (u64 )t->tx_lso_pkts; - *data++ = (u64 )t->tx_do_cksum; +t1_sge_get_port_stats (adapter->sge, dev->if_port, &ss); + *data++ = ss.rx_packets; + *data++ = ss.rx_cso_good; + *data++ = ss.tx_packets; + *data++ = ss.tx_cso; + *data++ = ss.tx_tso; + *data++ = ss.vlan_xtract; + *data++ = ss.vlan_insert; + + t =t1_sge_get_intr_counts (adapter->sge); + *data++ = t->rx_drops; + *data++ = t->pure_rsps; + *data++ = t->unhandled_irqs; + *data++ = t->respQ_empty; + *data++ = t->respQ_overflow; + *data++ = t->freelistQ_empty; + *data++ = t->pkt_too_big; + *data++ = t->pkt_mismatch; + *data++ = t->cmdQ_full[0 ]; + *data++ = t->cmdQ_full[1 ];if (adapter->espi) {const struct espi_intr_counts *e; e =t1_espi_get_intr_counts (adapter->espi); - *data++ = (u64 ) e->DIP2_parity_err; - *data++ = (u64 ) e->DIP4_err; - *data++ = (u64 ) e->rx_drops; - *data++ = (u64 ) e->tx_drops; - *data++ = (u64 ) e->rx_ovflw; - *data++ = (u64 ) e->parity_err; + *data++ = e->DIP2_parity_err; + *data++ = e->DIP4_err; + *data++ = e->rx_drops; + *data++ = e->tx_drops; + *data++ = e->rx_ovflw; + *data++ = e->parity_err; } }
drivers/net/chelsio/sge.c +50 -15
165 lines not on this page · raw message
drivers/net/chelsio/sge.h +12 -17
@@ -44,6 +44,9 @@#include <asm/byteorder.h> struct sge_intr_counts { +unsigned int rx_drops;/* # of packets dropped due to no mem */ +unsigned int pure_rsps;/* # of non-payload responses */ +unsigned int unhandled_irqs;/* # of unhandled interrupts */ unsigned int respQ_empty;/* # times respQ empty */ unsigned int respQ_overflow;/* # respQ overflow (fatal) */ unsigned int freelistQ_empty;/* # times freelist empty */
@@ -51,24 +54,16 @@ struct sge_intr_counts {unsigned int pkt_mismatch;unsigned int cmdQ_full[3 ];/* not HW IRQ, host cmdQ[] full */ unsigned int cmdQ_restarted[3 ];/* # of times cmdQ X was restarted */ -unsigned int ethernet_pkts;/* # of Ethernet packets received */ -unsigned int offload_pkts;/* # of offload packets received */ -unsigned int offload_bundles;/* # of offload pkt bundles delivered */ -unsigned int pure_rsps;/* # of non-payload responses */ -unsigned int unhandled_irqs;/* # of unhandled interrupts */ -unsigned int tx_ipfrags; -unsigned int tx_reg_pkts; -unsigned int tx_lso_pkts; -unsigned int tx_do_cksum; };struct sge_port_stats { -unsigned long rx_cso_good;/* # of successful RX csum offloads */ -unsigned long tx_cso;/* # of TX checksum offloads */ -unsigned long vlan_xtract;/* # of VLAN tag extractions */ -unsigned long vlan_insert;/* # of VLAN tag extractions */ -unsigned long tso;/* # of TSO requests */ -unsigned long rx_drops;/* # of packets dropped due to no mem */ +u64 rx_packets;/* # of Ethernet packets received */ +u64 rx_cso_good;/* # of successful RX csum offloads */ +u64 tx_packets;/* # of TX packets */ +u64 tx_cso;/* # of TX checksum offloads */ +u64 tx_tso;/* # of TSO requests */ +u64 vlan_xtract;/* # of VLAN tag extractions */ +u64 vlan_insert;/* # of VLAN tag insertions */ };struct sk_buff ;
@@ -90,8 +85,8 @@ int t1_sge_intr_error_handler(struct sgevoid t1_sge_intr_enable (struct sge *);void t1_sge_intr_disable (struct sge *);void t1_sge_intr_clear (struct sge *); -const struct sge_intr_counts *t1_sge_get_intr_counts (struct sge *sge); -const struct sge_port_stats *t1_sge_get_port_stats (struct sge *sge,int port); +const struct sge_intr_counts *t1_sge_get_intr_counts (const struct sge *sge); +void t1_sge_get_port_stats (const struct sge *sge,int port,struct sge_port_stats *);void t1_sched_set_max_avail_bytes (struct sge *,unsigned int );void t1_sched_set_drain_bits_per_us (struct sge *,unsigned int ,unsigned int ); unsigned int t1_sched_update_parms(struct sge *, unsigned int, unsigned int,
PATCH 10/10 chelesio: transmit locking (plus bug fix).
In reply to Stephen HemmingerIf transmit lock is contended on, then push return code back and retry at higher level.
Bugfix: If buffer is reallocated because of lack of headroom and the send is blocked, then drop packet. This is necessary because caller would end up requeuing a freed skb.
--- drivers/net/chelsio/sge.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
drivers/net/chelsio/sge.c +15 -4
@@ -1778,7 +1778,9 @@ static int t1_sge_tx(struct sk_buff *skbstruct cmdQ *q = &sge->cmdQ[qid];unsigned int credits, pidx, genbit, count, use_sched_skb =0 ; -spin_lock (&q->lock); +if (!spin_trylock (&q->lock)) +return NETDEV_TX_LOCKED ; +reclaim_completed_tx (sge, q); pidx = q->pidx;
@@ -1887,6 +1889,8 @@ int t1_start_xmit(struct sk_buff *skb, sstruct sge *sge = adapter->sge;struct sge_port_stats *st =per_cpu_ptr (sge->port_stats[dev->if_port],smp_processor_id ());struct cpl_tx_pkt *cpl; +struct sk_buff *orig_skb = skb; +int ret;if (skb->protocol ==htons (ETH_P_CPL5 )) goto send;
@@ -1930,8 +1934,6 @@ int t1_start_xmit(struct sk_buff *skb, s* Complain when this happens but try to fix things up. */ if (unlikely (skb_headroom (skb) < dev->hard_header_len -ETH_HLEN )) { -struct sk_buff *orig_skb = skb; -pr_debug ("%s: headroom %d header_len %d\n" , dev->name,skb_headroom (skb), dev->hard_header_len);
@@ -1991,7 +1993,16 @@ int t1_start_xmit(struct sk_buff *skb, s send: st->tx_packets++; dev->trans_start = jiffies; -return t1_sge_tx (skb, adapter,0 , dev); + ret =t1_sge_tx (skb, adapter,0 , dev); + +/* If transmit busy, and we reallocated skb's due to headroom limit, +* then silently discard to avoid leak. +*/ +if (unlikely (ret !=NETDEV_TX_OK && skb != orig_skb)) { +dev_kfree_skb_any (skb); + ret =NETDEV_TX_OK ; + } +return ret; }/*
Re: [PATCH 10/10] chelesio: transmit locking (plus bug fix).
Stephen,
Quoted 2 lines · Stephen Hemminger
If transmit lock is contended on, then push return code back and retry at higher level.
Looking at qdisc_restart, it seems to me that the NETDEV_TX_LOCKED return code must only be used if the device features LLTX. With your patch, if q->lock is already grabbed, qdisc_restart is going to requeue skb without going through the collision section of qdisc_restart.
Quoted 68 lines
Bugfix: If buffer is reallocated because of lack of headroom and the send is blocked, then drop packet. This is necessary because caller would end up requeuing a freed skb.
Signed-off-by Stephen Hemminger <[email protected]>--- drivers/net/chelsio/sge.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)drivers/net/chelsio/sge.c +15
-6@@ -1778,7 +1778,9 @@ static int t1_sge_tx(struct sk_buff *skbstruct cmdQ *q = &sge->cmdQ[qid];unsigned int credits, pidx, genbit, count, use_sched_skb =0 ; -spin_lock (&q->lock); +if (!spin_trylock (&q->lock)) +return NETDEV_TX_LOCKED ; +reclaim_completed_tx (sge, q); pidx = q->pidx;@@ -1887,6 +1889,8 @@ int t1_start_xmit(struct sk_buff *skb, sstruct sge *sge = adapter->sge;struct sge_port_stats *st =per_cpu_ptr (sge->port_stats[dev->if_port],smp_processor_id ());struct cpl_tx_pkt *cpl; +struct sk_buff *orig_skb = skb; +int ret;if (skb->protocol ==htons (ETH_P_CPL5 )) goto send;@@ -1930,8 +1934,6 @@ int t1_start_xmit(struct sk_buff *skb, s* Complain when this happens but try to fix things up. */ if (unlikely (skb_headroom (skb) < dev->hard_header_len -ETH_HLEN )) { -struct sk_buff *orig_skb = skb; -pr_debug ("%s: headroom %d header_len %d\n" , dev->name,skb_headroom (skb), dev->hard_header_len);@@ -1991,7 +1993,16 @@ int t1_start_xmit(struct sk_buff *skb, s send: st->tx_packets++; dev->trans_start = jiffies; -return t1_sge_tx (skb, adapter,0 , dev); + ret =t1_sge_tx (skb, adapter,0 , dev); + +/* If transmit busy, and we reallocated skb's due to headroom limit, +* then silently discard to avoid leak. +*/ +if (unlikely (ret !=NETDEV_TX_OK && skb != orig_skb)) { +dev_kfree_skb_any (skb); + ret =NETDEV_TX_OK ; + } +return ret; }/* -- -To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Eric
Re: [PATCH 10/10] chelesio: transmit locking (plus bug fix).
Quoted 12 lines · On Sun, 3 Dec 2006 11:45:09 +0100 "Eric Lemoine" <[email protected]> wrote:
Stephen,
Quoted 2 lines · Stephen Hemminger
If transmit lock is contended on, then push return code back and retry at higher level.
Looking at
qdisc_restart, it seems to me that theNETDEV_TX_LOCKEDreturn code must only be used if the device features LLTX. With your patch, ifq->lockis already grabbed,qdisc_restartis going to requeue skb without going through the collision section ofqdisc_restart.
The Chelsio driver already sets LLTX (see drivers/net/chelsio/cxgb2.c)