Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH net-next-2.6 v2] can: Topcliff: PCH_CAN driver: Fix build warnings
From: Wolfgang Grandegger @ 2010-10-29 19:32 UTC (permalink / raw)
  To: Tomoya
  Cc: andrew.chih.howe.khor-ral2JQCrhuEAvxtiuMwx3w, Masayuki Ohtake,
	Samuel Ortiz, margie.foster-ral2JQCrhuEAvxtiuMwx3w,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
	yong.y.wang-ral2JQCrhuEAvxtiuMwx3w, Marc Kleine-Budde,
	joel.clark-ral2JQCrhuEAvxtiuMwx3w,
	kok.howg.ewe-ral2JQCrhuEAvxtiuMwx3w, David S. Miller,
	Christian Pellegrin, qi.wang-ral2JQCrhuEAvxtiuMwx3w
In-Reply-To: <4CCAF517.2000409-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

Hello,

some more comments from my side.

On 10/29/2010 06:23 PM, Marc Kleine-Budde wrote:
> Hello,
> 
> On 10/29/2010 02:57 PM, Marc Kleine-Budde wrote:
>> The driver has already been merged. Please send incremental patches
>> against david's net-2.6 branch.
> 
> Here a review, find comments inline. Lets talk about my remarks, please
> answer inline and don't delete the code.
> 
> Can you please explain me your locking sheme? If I understand the
> documenation correctly the two message interfaces can be used mutual.
> And you use one for rx the other one for tx.
> 
> Please use netdev_<level> instead of dev_<level> for debug.
> 
>> --- /dev/null
>> +++ b/drivers/net/can/pch_can.c
>> @@ -0,0 +1,1436 @@
>> +/*
>> + * Copyright (C) 1999 - 2010 Intel Corporation.
>> + * Copyright (C) 2010 OKI SEMICONDUCTOR CO., LTD.
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; version 2 of the License.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * along with this program; if not, write to the Free Software
>> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
>> + */
>> +
>> +#include <linux/interrupt.h>
>> +#include <linux/delay.h>
>> +#include <linux/io.h>
>> +#include <linux/module.h>
>> +#include <linux/sched.h>
>> +#include <linux/pci.h>
>> +#include <linux/init.h>
>> +#include <linux/kernel.h>
>> +#include <linux/types.h>
>> +#include <linux/errno.h>
>> +#include <linux/netdevice.h>
>> +#include <linux/skbuff.h>
>> +#include <linux/can.h>
>> +#include <linux/can/dev.h>
>> +#include <linux/can/error.h>
>> +
>> +#define MAX_MSG_OBJ		32
>> +#define MSG_OBJ_RX		0 /* The receive message object flag. */
>> +#define MSG_OBJ_TX		1 /* The transmit message object flag. */
>> +
>> +#define CAN_CTRL_INIT		0x0001 /* The INIT bit of CANCONT register. */
>> +#define CAN_CTRL_IE		0x0002 /* The IE bit of CAN control register */
>> +#define CAN_CTRL_IE_SIE_EIE	0x000e
>> +#define CAN_CTRL_CCE		0x0040
>> +#define CAN_CTRL_OPT		0x0080 /* The OPT bit of CANCONT register. */
>> +#define CAN_OPT_SILENT		0x0008 /* The Silent bit of CANOPT reg. */
>> +#define CAN_OPT_LBACK		0x0010 /* The LoopBack bit of CANOPT reg. */
>> +#define CAN_CMASK_RX_TX_SET	0x00f3
>> +#define CAN_CMASK_RX_TX_GET	0x0073
>> +#define CAN_CMASK_ALL		0xff
>> +#define CAN_CMASK_RDWR		0x80
>> +#define CAN_CMASK_ARB		0x20
>> +#define CAN_CMASK_CTRL		0x10
>> +#define CAN_CMASK_MASK		0x40
>> +#define CAN_CMASK_NEWDAT	0x04
>> +#define CAN_CMASK_CLRINTPND	0x08
>> +
>> +#define CAN_IF_MCONT_NEWDAT	0x8000
>> +#define CAN_IF_MCONT_INTPND	0x2000
>> +#define CAN_IF_MCONT_UMASK	0x1000
>> +#define CAN_IF_MCONT_TXIE	0x0800
>> +#define CAN_IF_MCONT_RXIE	0x0400
>> +#define CAN_IF_MCONT_RMTEN	0x0200
>> +#define CAN_IF_MCONT_TXRQXT	0x0100
>> +#define CAN_IF_MCONT_EOB	0x0080
>> +#define CAN_IF_MCONT_DLC	0x000f
>> +#define CAN_IF_MCONT_MSGLOST	0x4000
>> +#define CAN_MASK2_MDIR_MXTD	0xc000
>> +#define CAN_ID2_DIR		0x2000
>> +#define CAN_ID_MSGVAL		0x8000
>> +
>> +#define CAN_STATUS_INT		0x8000
>> +#define CAN_IF_CREQ_BUSY	0x8000
>> +#define CAN_ID2_XTD		0x4000
>> +
>> +#define CAN_REC			0x00007f00
>> +#define CAN_TEC			0x000000ff
> 
> A prefix for like PCH_ instead of CAN_ for all those define above would
> be fine to avoid namespace clashes and/or confusion with the defines from the socketcan framework.
> 
>> +
>> +#define PCH_RX_OK		0x00000010
>> +#define PCH_TX_OK		0x00000008
>> +#define PCH_BUS_OFF		0x00000080
>> +#define PCH_EWARN		0x00000040
>> +#define PCH_EPASSIV		0x00000020
>> +#define PCH_LEC0		0x00000001
>> +#define PCH_LEC1		0x00000002
>> +#define PCH_LEC2		0x00000004
> 
> These are just single set bit, please use BIT()
> Consider adding the name of the corresponding register to the define's
> name.
> 
>> +#define PCH_LEC_ALL		(PCH_LEC0 | PCH_LEC1 | PCH_LEC2)
>> +#define PCH_STUF_ERR		PCH_LEC0
>> +#define PCH_FORM_ERR		PCH_LEC1
>> +#define PCH_ACK_ERR		(PCH_LEC0 | PCH_LEC1)
>> +#define PCH_BIT1_ERR		PCH_LEC2
>> +#define PCH_BIT0_ERR		(PCH_LEC0 | PCH_LEC2)
>> +#define PCH_CRC_ERR		(PCH_LEC1 | PCH_LEC2)

This is an enumeration:

enum {
	PCH_STUF_ERR = 1,
	PCH_FORM_ERR,
	PCH_ACK_ERR,
	PCH_BIT1_ERR;
	PCH_BIT0_ERR,
	PCH_CRC_ERR,
	PCH_LEC_ALL;
}

Also, s/PCH_/PCH_LEC_/ would be nice.

>> +/* bit position of certain controller bits. */
>> +#define BIT_BITT_BRP		0
>> +#define BIT_BITT_SJW		6
>> +#define BIT_BITT_TSEG1		8
>> +#define BIT_BITT_TSEG2		12
>> +#define BIT_IF1_MCONT_RXIE	10
>> +#define BIT_IF2_MCONT_TXIE	11
>> +#define BIT_BRPE_BRPE		6
>> +#define BIT_ES_TXERRCNT		0
>> +#define BIT_ES_RXERRCNT		8
> 
> these are usually called SHIFT
> 
>> +#define MSK_BITT_BRP		0x3f
>> +#define MSK_BITT_SJW		0xc0
>> +#define MSK_BITT_TSEG1		0xf00
>> +#define MSK_BITT_TSEG2		0x7000
>> +#define MSK_BRPE_BRPE		0x3c0
>> +#define MSK_BRPE_GET		0x0f
>> +#define MSK_CTRL_IE_SIE_EIE	0x07
>> +#define MSK_MCONT_TXIE		0x08
>> +#define MSK_MCONT_RXIE		0x10
> 
> MSK or MASK is okay, however the last two are just single bits.
> 
> Please add a PCH_ prefix here, too.
> 
>> +#define PCH_CAN_NO_TX_BUFF	1
>> +#define COUNTER_LIMIT		10
> 
> dito
> 
>> +
>> +#define PCH_CAN_CLK		50000000	/* 50MHz */
>> +
>> +/*
>> + * Define the number of message object.
>> + * PCH CAN communications are done via Message RAM.
>> + * The Message RAM consists of 32 message objects.
>> + */
>> +#define PCH_RX_OBJ_NUM		26  /* 1~ PCH_RX_OBJ_NUM is Rx*/
>> +#define PCH_TX_OBJ_NUM		6  /* PCH_RX_OBJ_NUM is RX ~ Tx*/
>> +#define PCH_OBJ_NUM		(PCH_TX_OBJ_NUM + PCH_RX_OBJ_NUM)
> 
> You define MAX_MSG_OBJ earlier, seems like two names for the same value.
> 
>> +
>> +#define PCH_FIFO_THRESH		16
>> +
>> +enum pch_can_mode {
>> +	PCH_CAN_ENABLE,
>> +	PCH_CAN_DISABLE,
>> +	PCH_CAN_ALL,
>> +	PCH_CAN_NONE,
>> +	PCH_CAN_STOP,
>> +	PCH_CAN_RUN,
>> +};
>> +
>> +struct pch_can_regs {
>> +	u32 cont;
>> +	u32 stat;
>> +	u32 errc;
>> +	u32 bitt;
>> +	u32 intr;
>> +	u32 opt;
>> +	u32 brpe;
>> +	u32 reserve1;
> 
> VVVV
>> +	u32 if1_creq;
>> +	u32 if1_cmask;
>> +	u32 if1_mask1;
>> +	u32 if1_mask2;
>> +	u32 if1_id1;
>> +	u32 if1_id2;
>> +	u32 if1_mcont;
>> +	u32 if1_dataa1;
>> +	u32 if1_dataa2;
>> +	u32 if1_datab1;
>> +	u32 if1_datab2;
> ^^^^
> 
> these registers and....
> 
>> +	u32 reserve2;
>> +	u32 reserve3[12];
> 
> ...and these
> 
> VVVV
>> +	u32 if2_creq;
>> +	u32 if2_cmask;
>> +	u32 if2_mask1;
>> +	u32 if2_mask2;
>> +	u32 if2_id1;
>> +	u32 if2_id2;
>> +	u32 if2_mcont;
>> +	u32 if2_dataa1;
>> +	u32 if2_dataa2;
>> +	u32 if2_datab1;
>> +	u32 if2_datab2;
> 
> ^^^^
> 
> ...are identical. I suggest to make a struct defining a complete
> "Message Interface Register Set". If you include the correct number of
> reserved bytes in the struct, you can have an array of two of these
> structs in the struct pch_can_regs.

Yep, that would be nice. Using it consequently would also allow to
remove duplicated code efficiently. I will name it "struct pch_can_if"
for latter references.

> 
>> +	u32 reserve4;
>> +	u32 reserve5[20];
>> +	u32 treq1;
>> +	u32 treq2;
>> +	u32 reserve6[2];
>> +	u32 reserve7[56];
>> +	u32 reserve8[3];

Why not just one reserveX ?

>> +	u32 srst;
>> +};
>> +
>> +struct pch_can_priv {
>> +	struct can_priv can;
>> +	struct pci_dev *dev;
>> +	unsigned int tx_enable[MAX_MSG_OBJ];
>> +	unsigned int rx_enable[MAX_MSG_OBJ];
>> +	unsigned int rx_link[MAX_MSG_OBJ];
>> +	unsigned int int_enables;
>> +	unsigned int int_stat;
>> +	struct net_device *ndev;
>> +	spinlock_t msgif_reg_lock; /* Message Interface Registers Access Lock*/
>                                                                             ^^^
> please add a whitespace
> 
>> +	unsigned int msg_obj[MAX_MSG_OBJ];
>> +	struct pch_can_regs __iomem *regs;
>> +	struct napi_struct napi;
>> +	unsigned int tx_obj;	/* Point next Tx Obj index */
>> +	unsigned int use_msi;
>> +};
>> +
>> +static struct can_bittiming_const pch_can_bittiming_const = {
>> +	.name = "pch_can",
>> +	.tseg1_min = 1,
>> +	.tseg1_max = 16,
>> +	.tseg2_min = 1,
>> +	.tseg2_max = 8,
>> +	.sjw_max = 4,
>> +	.brp_min = 1,
>> +	.brp_max = 1024, /* 6bit + extended 4bit */
>> +	.brp_inc = 1,
>> +};
>> +
>> +static DEFINE_PCI_DEVICE_TABLE(pch_pci_tbl) = {
>> +	{PCI_VENDOR_ID_INTEL, 0x8818, PCI_ANY_ID, PCI_ANY_ID,},
>> +	{0,}
>> +};
>> +MODULE_DEVICE_TABLE(pci, pch_pci_tbl);
>> +
>> +static inline void pch_can_bit_set(u32 *addr, u32 mask)
>                                       ^^^^^
> 
> that should be an void __iomem *, see mail I've send the other day.
> Please use sparse to check for this kinds of errors.
> (Compile the driver with C=2, i.e.: make drivers/net/can/pch_can.ko C=2)
> 
>> +{
>> +	iowrite32(ioread32(addr) | mask, addr);
>> +}
>> +
>> +static inline void pch_can_bit_clear(u32 *addr, u32 mask)
>                                         ^^^^^
> 
> dito
> 
>> +{
>> +	iowrite32(ioread32(addr) & ~mask, addr);
>> +}
>> +
>> +static void pch_can_set_run_mode(struct pch_can_priv *priv,
>> +				 enum pch_can_mode mode)
>> +{
>> +	switch (mode) {
>> +	case PCH_CAN_RUN:
>> +		pch_can_bit_clear(&priv->regs->cont, CAN_CTRL_INIT);
>> +		break;
>> +
>> +	case PCH_CAN_STOP:
>> +		pch_can_bit_set(&priv->regs->cont, CAN_CTRL_INIT);
>> +		break;
>> +
>> +	default:
>> +		dev_err(&priv->ndev->dev, "%s -> Invalid Mode.\n", __func__);
>> +		break;
>> +	}
>> +}
>> +
>> +static void pch_can_set_optmode(struct pch_can_priv *priv)
>> +{
>> +	u32 reg_val = ioread32(&priv->regs->opt);
>> +
>> +	if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)
>> +		reg_val |= CAN_OPT_SILENT;
>> +
>> +	if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK)
>> +		reg_val |= CAN_OPT_LBACK;
>> +
>> +	pch_can_bit_set(&priv->regs->cont, CAN_CTRL_OPT);
>> +	iowrite32(reg_val, &priv->regs->opt);
>> +}
>> +
> 
> IMHO the function name is missleading, if I understand the code
> correctly, this functions triggers the transmission of the message.
> After this it checks for busy, but 
> 
>> +static void pch_can_check_if_busy(u32 __iomem *creq_addr, u32 num)
>                                      ^^^^
> 
> that should probaby be a void

With separate structs for if1 and i2, a pointer to the relevant "struct
pch_can_if" could be passed instead.

>> +{
>> +	u32 counter = COUNTER_LIMIT;
>> +	u32 ifx_creq;
>> +
>> +	iowrite32(num, creq_addr);
>> +	while (counter) {
>> +		ifx_creq = ioread32(creq_addr) & CAN_IF_CREQ_BUSY;
>> +		if (!ifx_creq)
>> +			break;
>> +		counter--;
>> +		udelay(1);
>> +	}
>> +	if (!counter)
>> +		pr_err("%s:IF1 BUSY Flag is set forever.\n", __func__);
>> +}
>> +
>> +static void pch_can_set_int_enables(struct pch_can_priv *priv,
>> +				    enum pch_can_mode interrupt_no)
>> +{
>> +	switch (interrupt_no) {
>> +	case PCH_CAN_ENABLE:
>> +		pch_can_bit_set(&priv->regs->cont, CAN_CTRL_IE);
> 
> noone uses this case.
> 
>> +		break;
>> +
>> +	case PCH_CAN_DISABLE:
>> +		pch_can_bit_clear(&priv->regs->cont, CAN_CTRL_IE);
>> +		break;
>> +
>> +	case PCH_CAN_ALL:
>> +		pch_can_bit_set(&priv->regs->cont, CAN_CTRL_IE_SIE_EIE);
>> +		break;
>> +
>> +	case PCH_CAN_NONE:
>> +		pch_can_bit_clear(&priv->regs->cont, CAN_CTRL_IE_SIE_EIE);
>> +		break;
>> +
>> +	default:
>> +		dev_err(&priv->ndev->dev, "Invalid interrupt number.\n");
>> +		break;
>> +	}
>> +}
>> +
>> +static void pch_can_set_rx_enable(struct pch_can_priv *priv, u32 buff_num,
>> +				  int set)
>> +{
>> +	unsigned long flags;
>> +
>> +	spin_lock_irqsave(&priv->msgif_reg_lock, flags);
>> +	/* Reading the receive buffer data from RAM to Interface1 registers */
>> +	iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
>> +	pch_can_check_if_busy(&priv->regs->if1_creq, buff_num);
>> +
>> +	/* Setting the IF1MASK1 register to access MsgVal and RxIE bits */
>> +	iowrite32(CAN_CMASK_RDWR | CAN_CMASK_ARB | CAN_CMASK_CTRL,
>> +		  &priv->regs->if1_cmask);
>> +
>> +	if (set == 1) {
>> +		/* Setting the MsgVal and RxIE bits */
>> +		pch_can_bit_set(&priv->regs->if1_mcont, CAN_IF_MCONT_RXIE);
>> +		pch_can_bit_set(&priv->regs->if1_id2, CAN_ID_MSGVAL);
>> +
>> +	} else if (set == 0) {
>> +		/* Resetting the MsgVal and RxIE bits */
>> +		pch_can_bit_clear(&priv->regs->if1_mcont, CAN_IF_MCONT_RXIE);
>> +		pch_can_bit_clear(&priv->regs->if1_id2, CAN_ID_MSGVAL);
>> +	}

Why not just?

	if (set)
	else


>> +	pch_can_check_if_busy(&priv->regs->if1_creq, buff_num);
>> +	spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
>> +}
>> +
>> +static void pch_can_rx_enable_all(struct pch_can_priv *priv)
>> +{
>> +	int i;
>> +
>> +	/* Traversing to obtain the object configured as receivers. */
>> +	for (i = 1; i <= PCH_RX_OBJ_NUM; i++)
>> +		pch_can_set_rx_enable(priv, i, 1);
>> +}
>> +
>> +static void pch_can_rx_disable_all(struct pch_can_priv *priv)
>> +{
>> +	int i;
>> +
>> +	/* Traversing to obtain the object configured as receivers. */
>> +	for (i = 1; i <= PCH_RX_OBJ_NUM; i++)
>> +		pch_can_set_rx_enable(priv, i, 0);
>> +}
>> +
>> +static void pch_can_set_tx_enable(struct pch_can_priv *priv, u32 buff_num,
>> +				 u32 set)
>> +{
>> +	unsigned long flags;
>> +
>> +	spin_lock_irqsave(&priv->msgif_reg_lock, flags);
>> +	/* Reading the Msg buffer from Message RAM to Interface2 registers. */
>> +	iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if2_cmask);
>> +	pch_can_check_if_busy(&priv->regs->if2_creq, buff_num);
>> +
>> +	/* Setting the IF2CMASK register for accessing the
>> +		MsgVal and TxIE bits */
>> +	iowrite32(CAN_CMASK_RDWR | CAN_CMASK_ARB | CAN_CMASK_CTRL,
>> +		 &priv->regs->if2_cmask);
>> +
>> +	if (set == 1) {
>> +		/* Setting the MsgVal and TxIE bits */
>> +		pch_can_bit_set(&priv->regs->if2_mcont, CAN_IF_MCONT_TXIE);
>> +		pch_can_bit_set(&priv->regs->if2_id2, CAN_ID_MSGVAL);
>> +	} else if (set == 0) {
>> +		/* Resetting the MsgVal and TxIE bits. */
>> +		pch_can_bit_clear(&priv->regs->if2_mcont, CAN_IF_MCONT_TXIE);
>> +		pch_can_bit_clear(&priv->regs->if2_id2, CAN_ID_MSGVAL);
>> +	}
>> +
>> +	pch_can_check_if_busy(&priv->regs->if2_creq, buff_num);
>> +	spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
>> +}

That function is almost identical to pch_can_set_rx_enable. Just if2 is
used instead of if1 and CAN_IF_MCONT_TXIE instead of CAN_IF_MCONT_RXIE.
With separate "struct  pch_can_if" for if1 and if2, it could be handled
by a common function.

>> +static void pch_can_tx_enable_all(struct pch_can_priv *priv)
>> +{
>> +	int i;
>> +
>> +	/* Traversing to obtain the object configured as transmit object. */
>> +	for (i = PCH_RX_OBJ_NUM + 1; i <= PCH_OBJ_NUM; i++)
>> +		pch_can_set_tx_enable(priv, i, 1);
>> +}
>> +
>> +static void pch_can_tx_disable_all(struct pch_can_priv *priv)
>> +{
>> +	int i;
>> +
>> +	/* Traversing to obtain the object configured as transmit object. */
>> +	for (i = PCH_RX_OBJ_NUM + 1; i <= PCH_OBJ_NUM; i++)
>> +		pch_can_set_tx_enable(priv, i, 0);
>> +}

I think there is no need for separate functions for enable and disable.
Just pass "enable" 0 or 1 like you do with "set" above.

>> +static int pch_can_int_pending(struct pch_can_priv *priv)
>           ^^^
> 
> make it u32 as it returns a register value, or a u16 as you only use
> the 16 lower bits.
> 
>> +{
>> +	return ioread32(&priv->regs->intr) & 0xffff;
>> +}
>> +
>> +static void pch_can_clear_buffers(struct pch_can_priv *priv)
>> +{
>> +	int i; /* Msg Obj ID (1~32) */
>> +
>> +	for (i = 1; i <= PCH_RX_OBJ_NUM; i++) {
> 
> IMHO the readability would be improved if you define something like
> PCH_RX_OBJ_START and PCH_RX_OBJ_END.
> 
>> +		iowrite32(CAN_CMASK_RX_TX_SET, &priv->regs->if1_cmask);
>> +		iowrite32(0xffff, &priv->regs->if1_mask1);
>> +		iowrite32(0xffff, &priv->regs->if1_mask2);
>> +		iowrite32(0x0, &priv->regs->if1_id1);
>> +		iowrite32(0x0, &priv->regs->if1_id2);
>> +		iowrite32(0x0, &priv->regs->if1_mcont);
>> +		iowrite32(0x0, &priv->regs->if1_dataa1);
>> +		iowrite32(0x0, &priv->regs->if1_dataa2);
>> +		iowrite32(0x0, &priv->regs->if1_datab1);
>> +		iowrite32(0x0, &priv->regs->if1_datab2);
>> +		iowrite32(CAN_CMASK_RDWR | CAN_CMASK_MASK |
>> +			  CAN_CMASK_ARB | CAN_CMASK_CTRL,
>> +			  &priv->regs->if1_cmask);
>> +		pch_can_check_if_busy(&priv->regs->if1_creq, i);
>> +	}
>> +
>> +	for (i = PCH_RX_OBJ_NUM + 1; i <= PCH_OBJ_NUM; i++) {
>                  ^^^^^^^^^^^^^^^^^^
> dito for TX objects
> 
>> +		iowrite32(CAN_CMASK_RX_TX_SET, &priv->regs->if2_cmask);
>> +		iowrite32(0xffff, &priv->regs->if2_mask1);
>> +		iowrite32(0xffff, &priv->regs->if2_mask2);
>> +		iowrite32(0x0, &priv->regs->if2_id1);
>> +		iowrite32(0x0, &priv->regs->if2_id2);
>> +		iowrite32(0x0, &priv->regs->if2_mcont);
>> +		iowrite32(0x0, &priv->regs->if2_dataa1);
>> +		iowrite32(0x0, &priv->regs->if2_dataa2);
>> +		iowrite32(0x0, &priv->regs->if2_datab1);
>> +		iowrite32(0x0, &priv->regs->if2_datab2);
>> +		iowrite32(CAN_CMASK_RDWR | CAN_CMASK_MASK | CAN_CMASK_ARB |
>> +			  CAN_CMASK_CTRL, &priv->regs->if2_cmask);
>> +		pch_can_check_if_busy(&priv->regs->if2_creq, i);

This is almost the same code as above, just if2 instead of if1. With
separate "struct  pch_can_if" for if1 and i2, it could be handled by a
common function.

>> +	}
>> +}
>> +
>> +static void pch_can_config_rx_tx_buffers(struct pch_can_priv *priv)
>> +{
>> +	int i;
>> +	unsigned long flags;
>> +
>> +	spin_lock_irqsave(&priv->msgif_reg_lock, flags);
>> +
>> +	for (i = 1; i <= PCH_RX_OBJ_NUM; i++) {
>> +		iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
>> +		pch_can_check_if_busy(&priv->regs->if1_creq, i);
> 
> If I understand the code correctly, the about function triggers a
> transfer. Why do you first trigger a transfer, then set the message contents....
>> +
>> +		iowrite32(0x0, &priv->regs->if1_id1);
>> +		iowrite32(0x0, &priv->regs->if1_id2);
>> +
>> +		pch_can_bit_set(&priv->regs->if1_mcont, CAN_IF_MCONT_UMASK);
> 
>     Why do you set the "Use acceptance mask" bit? We want to receive
>     all can messages.
> 
>> +
>> +		/* Set FIFO mode set to 0 except last Rx Obj*/
>> +		pch_can_bit_clear(&priv->regs->if1_mcont, CAN_IF_MCONT_EOB);
>> +		/* In case FIFO mode, Last EoB of Rx Obj must be 1 */
>> +		if (i == (PCH_RX_OBJ_NUM - 1))
>> +			pch_can_bit_set(&priv->regs->if1_mcont,
>> +					CAN_IF_MCONT_EOB);
> 
>     Make it if () { } else { }, please.
> 
>> +
>> +		iowrite32(0, &priv->regs->if1_mask1);
>> +		pch_can_bit_clear(&priv->regs->if1_mask2,
>> +				  0x1fff | CAN_MASK2_MDIR_MXTD);
>> +
>> +		/* Setting CMASK for writing */
>> +		iowrite32(CAN_CMASK_RDWR | CAN_CMASK_MASK | CAN_CMASK_ARB |
>> +			  CAN_CMASK_CTRL, &priv->regs->if1_cmask);
>> +
>> +		pch_can_check_if_busy(&priv->regs->if1_creq, i);
> 
> ...and then trigger the transfer again?
> 
>> +	}
>> +
>> +	for (i = PCH_RX_OBJ_NUM + 1; i <= PCH_OBJ_NUM; i++) {
>> +		iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if2_cmask);
>> +		pch_can_check_if_busy(&priv->regs->if2_creq, i);
> 
> same question about triggering the transfer 2 times applied here, too
>> +
>> +		/* Resetting DIR bit for reception */
>> +		iowrite32(0x0, &priv->regs->if2_id1);
>> +		iowrite32(0x0, &priv->regs->if2_id2);
>> +		pch_can_bit_set(&priv->regs->if2_id2, CAN_ID2_DIR);
> 
> Can you combine the two accesses to >if2_id2 into one?
> 
>> +
>> +		/* Setting EOB bit for transmitter */
>> +		iowrite32(CAN_IF_MCONT_EOB, &priv->regs->if2_mcont);
>> +
>> +		pch_can_bit_set(&priv->regs->if2_mcont,
>> +				CAN_IF_MCONT_UMASK);
> 
> dito for if2_mcont
> 
>> +
>> +		iowrite32(0, &priv->regs->if2_mask1);
>> +		pch_can_bit_clear(&priv->regs->if2_mask2, 0x1fff);
>> +
>> +		/* Setting CMASK for writing */
>> +		iowrite32(CAN_CMASK_RDWR | CAN_CMASK_MASK | CAN_CMASK_ARB |
>> +			  CAN_CMASK_CTRL, &priv->regs->if2_cmask);
>> +
>> +		pch_can_check_if_busy(&priv->regs->if2_creq, i);
>> +	}
>> +
>> +	spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
>> +}
>> +
>> +static void pch_can_init(struct pch_can_priv *priv)
>> +{
>> +	/* Stopping the Can device. */
>> +	pch_can_set_run_mode(priv, PCH_CAN_STOP);
>> +
>> +	/* Clearing all the message object buffers. */
>> +	pch_can_clear_buffers(priv);
>> +
>> +	/* Configuring the respective message object as either rx/tx object. */
>> +	pch_can_config_rx_tx_buffers(priv);
>> +
>> +	/* Enabling the interrupts. */
>> +	pch_can_set_int_enables(priv, PCH_CAN_ALL);
>> +}
>> +
>> +static void pch_can_release(struct pch_can_priv *priv)
>> +{
>> +	/* Stooping the CAN device. */
>> +	pch_can_set_run_mode(priv, PCH_CAN_STOP);
>> +
>> +	/* Disabling the interrupts. */
>> +	pch_can_set_int_enables(priv, PCH_CAN_NONE);
>> +
>> +	/* Disabling all the receive object. */
>> +	pch_can_rx_disable_all(priv);
>> +
>> +	/* Disabling all the transmit object. */
>> +	pch_can_tx_disable_all(priv);
>> +}
>> +
>> +/* This function clears interrupt(s) from the CAN device. */
>> +static void pch_can_int_clr(struct pch_can_priv *priv, u32 mask)
>> +{
>> +	if (mask == CAN_STATUS_INT) {
> 
> is this a valid case?
> 
>> +		ioread32(&priv->regs->stat);
>> +		return;
>> +	}
>> +
>> +	/* Clear interrupt for transmit object */
>> +	if ((mask >= 1) && (mask <= PCH_RX_OBJ_NUM)) {
>> +		/* Setting CMASK for clearing the reception interrupts. */
>> +		iowrite32(CAN_CMASK_RDWR | CAN_CMASK_CTRL | CAN_CMASK_ARB,
>> +			  &priv->regs->if1_cmask);
>> +
>> +		/* Clearing the Dir bit. */
>> +		pch_can_bit_clear(&priv->regs->if1_id2, CAN_ID2_DIR);
>> +
>> +		/* Clearing NewDat & IntPnd */
>> +		pch_can_bit_clear(&priv->regs->if1_mcont,
>> +				  CAN_IF_MCONT_NEWDAT | CAN_IF_MCONT_INTPND);
>> +
>> +		pch_can_check_if_busy(&priv->regs->if1_creq, mask);
>> +	} else if ((mask > PCH_RX_OBJ_NUM) && (mask <= PCH_OBJ_NUM)) {
>> +		/* Setting CMASK for clearing interrupts for
>> +		   frame transmission. */
> 
> /*
>  * this is the prefered style of multi line comments,
>  * please adjust you comments
>  */
> 
>> +		iowrite32(CAN_CMASK_RDWR | CAN_CMASK_CTRL | CAN_CMASK_ARB,
>> +			  &priv->regs->if2_cmask);
>> +
>> +		/* Resetting the ID registers. */
>> +		pch_can_bit_set(&priv->regs->if2_id2,
>> +			       CAN_ID2_DIR | (0x7ff << 2));
>> +		iowrite32(0x0, &priv->regs->if2_id1);
>> +
>> +		/* Claring NewDat, TxRqst & IntPnd */
>> +		pch_can_bit_clear(&priv->regs->if2_mcont,
>> +				  CAN_IF_MCONT_NEWDAT | CAN_IF_MCONT_INTPND |
>> +				  CAN_IF_MCONT_TXRQXT);
>> +		pch_can_check_if_busy(&priv->regs->if2_creq, mask);
>> +	}
>> +}
>> +
>> +static u32 pch_can_get_buffer_status(struct pch_can_priv *priv)
>> +{
>> +	return (ioread32(&priv->regs->treq1) & 0xffff) |
>> +	       ((ioread32(&priv->regs->treq2) & 0xffff) << 16);
> 
> the second 0xffff is not needed, as the return value is u32 and you shift by 16.
> 
>> +}
>> +
>> +static void pch_can_reset(struct pch_can_priv *priv)
>> +{
>> +	/* write to sw reset register */
>> +	iowrite32(1, &priv->regs->srst);
>> +	iowrite32(0, &priv->regs->srst);
>> +}
>> +
>> +static void pch_can_error(struct net_device *ndev, u32 status)
>> +{
>> +	struct sk_buff *skb;
>> +	struct pch_can_priv *priv = netdev_priv(ndev);
>> +	struct can_frame *cf;
>> +	u32 errc;
>> +	struct net_device_stats *stats = &(priv->ndev->stats);
>> +	enum can_state state = priv->can.state;
>> +
>> +	skb = alloc_can_err_skb(ndev, &cf);
>> +	if (!skb)
>> +		return;
>> +
>> +	if (status & PCH_BUS_OFF) {
>> +		pch_can_tx_disable_all(priv);
>> +		pch_can_rx_disable_all(priv);
>> +		state = CAN_STATE_BUS_OFF;
>> +		cf->can_id |= CAN_ERR_BUSOFF;
>> +		can_bus_off(ndev);
>> +	}
>> +
>> +	/* Warning interrupt. */
>> +	if (status & PCH_EWARN) {
>> +		state = CAN_STATE_ERROR_WARNING;
>> +		priv->can.can_stats.error_warning++;
>> +		cf->can_id |= CAN_ERR_CRTL;
>> +		errc = ioread32(&priv->regs->errc);
>> +		if (((errc & CAN_REC) >> 8) > 96)
>> +			cf->data[1] |= CAN_ERR_CRTL_RX_WARNING;
>> +		if ((errc & CAN_TEC) > 96)
>> +			cf->data[1] |= CAN_ERR_CRTL_TX_WARNING;
>> +		dev_warn(&ndev->dev,
>> +			"%s -> Error Counter is more than 96.\n", __func__);
> 
> Please use just "debug" level not warning here. Consider to use
> netdev_dbg() instead. IMHO the __func__ can be dropped and the
> "official" name for the error is "Error Warning".
> 
>> +	}
>> +	/* Error passive interrupt. */
>> +	if (status & PCH_EPASSIV) {
>> +		priv->can.can_stats.error_passive++;
>> +		state = CAN_STATE_ERROR_PASSIVE;
>> +		cf->can_id |= CAN_ERR_CRTL;
>> +		errc = ioread32(&priv->regs->errc);
>> +		if (((errc & CAN_REC) >> 8) > 127)
>> +			cf->data[1] |= CAN_ERR_CRTL_RX_PASSIVE;
>> +		if ((errc & CAN_TEC) > 127)
>> +			cf->data[1] |= CAN_ERR_CRTL_TX_PASSIVE;
>> +		dev_err(&ndev->dev,
>> +			"%s -> CAN controller is ERROR PASSIVE .\n", __func__);
> 
> dito
> 
>> +	}
>> +
>> +	if (status & PCH_LEC_ALL) {
>> +		priv->can.can_stats.bus_error++;
>> +		stats->rx_errors++;
>> +		switch (status & PCH_LEC_ALL) {
> 
> I suggest to convert to a if-bit-set because there might be more than
> one bit set.

Marc, what do you mean here. It's an enumeraton. Maybe the following
code is more clear:

	lec = status & PCH_LEC_ALL;
	if (lec > 0) {
		switch (lec) {

>> +		case PCH_STUF_ERR:
>> +			cf->data[2] |= CAN_ERR_PROT_STUFF;
>> +			break;
>> +		case PCH_FORM_ERR:
>> +			cf->data[2] |= CAN_ERR_PROT_FORM;
>> +			break;
>> +		case PCH_ACK_ERR:
>> +			cf->data[2] |= CAN_ERR_PROT_LOC_ACK |
>> +				       CAN_ERR_PROT_LOC_ACK_DEL;

Could you check what that type of bus error that is? Usually it's a ack
lost error.

>> +			break;
>> +		case PCH_BIT1_ERR:
>> +		case PCH_BIT0_ERR:
>> +			cf->data[2] |= CAN_ERR_PROT_BIT;
>> +			break;
>> +		case PCH_CRC_ERR:
>> +			cf->data[2] |= CAN_ERR_PROT_LOC_CRC_SEQ |
>> +				       CAN_ERR_PROT_LOC_CRC_DEL;
>> +			break;
>> +		default:
>> +			iowrite32(status | PCH_LEC_ALL, &priv->regs->stat);
>> +			break;
>> +		}
>> +
>> +	}

Also, could you please add the TEC and REC:

	cf->data[6] = ioread32(&priv->regs->errc) & CAN_TEC;
	cf->data[7] = (ioread32(&priv->regs->errc) & CAN_REC) >> 8;

>> +	priv->can.state = state;
>> +	netif_receive_skb(skb);
>> +
>> +	stats->rx_packets++;
>> +	stats->rx_bytes += cf->can_dlc;
>> +}
>> +
>> +static irqreturn_t pch_can_interrupt(int irq, void *dev_id)
>> +{
>> +	struct net_device *ndev = (struct net_device *)dev_id;
>> +	struct pch_can_priv *priv = netdev_priv(ndev);
>> +
>> +	pch_can_set_int_enables(priv, PCH_CAN_NONE);
>> +	napi_schedule(&priv->napi);
>> +
>> +	return IRQ_HANDLED;
>> +}
>> +
>> +static void pch_fifo_thresh(struct pch_can_priv *priv, int obj_id)
>> +{
>> +	if (obj_id < PCH_FIFO_THRESH) {
>> +		iowrite32(CAN_CMASK_RDWR | CAN_CMASK_CTRL |
>> +			  CAN_CMASK_ARB, &priv->regs->if1_cmask);
>> +
>> +		/* Clearing the Dir bit. */
>> +		pch_can_bit_clear(&priv->regs->if1_id2, CAN_ID2_DIR);
>> +
>> +		/* Clearing NewDat & IntPnd */
>> +		pch_can_bit_clear(&priv->regs->if1_mcont,
>> +				  CAN_IF_MCONT_INTPND);
>> +		pch_can_check_if_busy(&priv->regs->if1_creq, obj_id);
>> +	} else if (obj_id > PCH_FIFO_THRESH) {
>> +		pch_can_int_clr(priv, obj_id);
>> +	} else if (obj_id == PCH_FIFO_THRESH) {
>> +		int cnt;
>> +		for (cnt = 0; cnt < PCH_FIFO_THRESH; cnt++)
>> +			pch_can_int_clr(priv, cnt+1);
>> +	}
>> +}
>> +
>> +static int pch_can_rx_msg_lost(struct net_device *ndev, int obj_id)
>> +{
>> +	struct pch_can_priv *priv = netdev_priv(ndev);
>> +	struct net_device_stats *stats = &(priv->ndev->stats);
>> +	struct sk_buff *skb;
>> +	struct can_frame *cf;
>> +
>> +	dev_err(&priv->ndev->dev, "Msg Obj is overwritten.\n");

Please use dev_dbg or even remove the line above.

>> +	pch_can_bit_clear(&priv->regs->if1_mcont,
>> +			  CAN_IF_MCONT_MSGLOST);
>> +	iowrite32(CAN_CMASK_RDWR | CAN_CMASK_CTRL,
>> +		  &priv->regs->if1_cmask);
>> +	pch_can_check_if_busy(&priv->regs->if1_creq, obj_id);

I think the if busy checks could be improved. Why do you need to wait here?

>> +
>> +	skb = alloc_can_err_skb(ndev, &cf);
>> +	if (!skb)
>> +		return -ENOMEM;
>> +
>> +	priv->can.can_stats.error_passive++;
>> +	priv->can.state = CAN_STATE_ERROR_PASSIVE;

Please remove the above two bogus lines.

>> +	cf->can_id |= CAN_ERR_CRTL;
>> +	cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW;
>> +	stats->rx_over_errors++;
>> +	stats->rx_errors++;
>> +
>> +	netif_receive_skb(skb);
>> +
>> +	return 0;
>> +}
>> +
>> +static int pch_can_rx_normal(struct net_device *ndev, u32 obj_num, int quota)
>> +{
>> +	u32 reg;
>> +	canid_t id;
>> +	u32 ide;
>> +	u32 rtr;
>> +	int rcv_pkts = 0;
>> +	int rtn;
>> +	int next_flag = 0;
>> +	struct sk_buff *skb;
>> +	struct can_frame *cf;
>> +	struct pch_can_priv *priv = netdev_priv(ndev);
>> +	struct net_device_stats *stats = &(priv->ndev->stats);
>> +
>> +	/* Reading the messsage object from the Message RAM */
>> +	iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
>> +	pch_can_check_if_busy(&priv->regs->if1_creq, obj_num);
>> +
>> +	/* Reading the MCONT register. */
>> +	reg = ioread32(&priv->regs->if1_mcont);
>> +	reg &= 0xffff;
>> +
>> +	for (; (!(reg & CAN_IF_MCONT_EOB)) && (quota > 0);
>> +						obj_num++, next_flag = 0) {
>> +		/* If MsgLost bit set. */
>> +		if (reg & CAN_IF_MCONT_MSGLOST) {
>> +			rtn = pch_can_rx_msg_lost(ndev, obj_num);
>> +			if (!rtn)
>> +				return rtn;
>> +			rcv_pkts++;
>> +			quota--;
>> +			next_flag = 1;
>> +		} else if (!(reg & CAN_IF_MCONT_NEWDAT))
>> +			next_flag = 1;
>> +
> 
> after rearanging the code (see below..) you should be able to use a continue here.
> 
>> +		if (!next_flag) {
>> +			skb = alloc_can_skb(priv->ndev, &cf);
>> +			if (!skb)
>> +				return -ENOMEM;
>> +
>> +			/* Get Received data */
>> +			ide = ((ioread32(&priv->regs->if1_id2)) & CAN_ID2_XTD);
>> +			if (ide) {
>> +				id = (ioread32(&priv->regs->if1_id1) & 0xffff);
>> +				id |= (((ioread32(&priv->regs->if1_id2)) &
>> +						    0x1fff) << 16);
>> +				cf->can_id = (id & CAN_EFF_MASK) | CAN_EFF_FLAG;
>                                               ^^^^^^^^^^^^^^^^^
> 
> is the mask needed, you mask the if1_id{1,2} already
> 
>> +			} else {
>> +				id = (((ioread32(&priv->regs->if1_id2)) &
>> +						  (CAN_SFF_MASK << 2)) >> 2);
>> +				cf->can_id = (id & CAN_SFF_MASK);
> 
> one mask can go away
> 
>> +			}
>> +
>> +			rtr = ioread32(&priv->regs->if1_id2) &  CAN_ID2_DIR;
>                                                               ^^
> 
> remove one space
> 
>> +
>> +			if (rtr)
>> +				cf->can_id |= CAN_RTR_FLAG;
>> +
>> +			cf->can_dlc = get_can_dlc((ioread32(&priv->regs->
>> +						   if1_mcont)) & 0xF);
>> +			*(u16 *)(cf->data + 0) = ioread16(&priv->regs->
>> +							  if1_dataa1);
>> +			*(u16 *)(cf->data + 2) = ioread16(&priv->regs->
>> +							  if1_dataa2);
>> +			*(u16 *)(cf->data + 4) = ioread16(&priv->regs->
>> +							  if1_datab1);
>> +			*(u16 *)(cf->data + 6) = ioread16(&priv->regs->
>> +							  if1_datab2);
> 
> are you sure, the bytes in the can package a in the correct order.
> Please test your pch_can against a non pch_can system.
> 
>> +
>> +			netif_receive_skb(skb);
>> +			rcv_pkts++;
>> +			stats->rx_packets++;
>> +			quota--;
>> +			stats->rx_bytes += cf->can_dlc;
>> +
>> +			pch_fifo_thresh(priv, obj_num);
>> +		}
>> +
>> +		/* Reading the messsage object from the Message RAM */
>> +		iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
>> +		pch_can_check_if_busy(&priv->regs->if1_creq, obj_num + 1);
>> +		reg = ioread32(&priv->regs->if1_mcont);
> 
> this is almost the same code as before the the loop, can you rearange
> the code to avoid duplication?
>  
>> +	}
>> +
>> +	return rcv_pkts;
>> +}
>> +
>> +static void pch_can_tx_complete(struct net_device *ndev, u32 int_stat)
>> +{
>> +	struct pch_can_priv *priv = netdev_priv(ndev);
>> +	struct net_device_stats *stats = &(priv->ndev->stats);
>> +	unsigned long flags;
>> +	u32 dlc;
>> +
>> +	can_get_echo_skb(ndev, int_stat - PCH_RX_OBJ_NUM - 1);
>> +	spin_lock_irqsave(&priv->msgif_reg_lock, flags);
>> +	iowrite32(CAN_CMASK_RX_TX_GET | CAN_CMASK_CLRINTPND,
>> +		  &priv->regs->if2_cmask);
>> +	dlc = ioread32(&priv->regs->if2_mcont) & CAN_IF_MCONT_DLC;
>> +	pch_can_check_if_busy(&priv->regs->if2_creq, int_stat);
>> +	spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
>> +	if (dlc > 8)
>> +		dlc = 8;
> 
> use get_can_dlc
> 
>> +	stats->tx_bytes += dlc;
>> +	stats->tx_packets++;
>> +}
>> +
>> +static int pch_can_rx_poll(struct napi_struct *napi, int quota)
>> +{
>> +	struct net_device *ndev = napi->dev;
>> +	struct pch_can_priv *priv = netdev_priv(ndev);
>> +	u32 int_stat;
>> +	int rcv_pkts = 0;
>> +	u32 reg_stat;
>> +	unsigned long flags;
>> +
>> +	int_stat = pch_can_int_pending(priv);
>> +	if (!int_stat)
>> +		goto END;

Labels should be lowercase as well.

>> +
>> +	if ((int_stat == CAN_STATUS_INT) && (quota > 0)) {
>> +		reg_stat = ioread32(&priv->regs->stat);
>> +		if (reg_stat & (PCH_BUS_OFF | PCH_LEC_ALL)) {
>> +			if ((reg_stat & PCH_LEC_ALL) != PCH_LEC_ALL) {
>> +				pch_can_error(ndev, reg_stat);
>> +				quota--;
>> +			}
>> +		}
>> +
>> +		if (reg_stat & PCH_TX_OK) {
>> +			spin_lock_irqsave(&priv->msgif_reg_lock, flags);
>> +			iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if2_cmask);
>> +			pch_can_check_if_busy(&priv->regs->if2_creq,
>> +					       ioread32(&priv->regs->intr));
>                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> Isn't this "int_stat". Might it be possilbe that regs->intr changes
> between the pch_can_int_pending and here?
> 
> What should this transfer do?
> 
>> +			spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
>> +			pch_can_bit_clear(&priv->regs->stat, PCH_TX_OK);
>> +		}
>> +
>> +		if (reg_stat & PCH_RX_OK)
>> +			pch_can_bit_clear(&priv->regs->stat, PCH_RX_OK);
>> +
>> +		int_stat = pch_can_int_pending(priv);
>> +	}
>> +
>> +	if (quota == 0)
>> +		goto END;
>> +
>> +	if ((int_stat >= 1) && (int_stat <= PCH_RX_OBJ_NUM)) {
>> +		spin_lock_irqsave(&priv->msgif_reg_lock, flags);
>> +		rcv_pkts += pch_can_rx_normal(ndev, int_stat, quota);
>> +		spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
>> +		quota -= rcv_pkts;
>> +		if (rcv_pkts < 0)
> 
> how can this happen?
> 
>> +			goto END;
>> +	} else if ((int_stat > PCH_RX_OBJ_NUM) && (int_stat <= PCH_OBJ_NUM)) {
>> +		/* Handle transmission interrupt */
>> +		pch_can_tx_complete(ndev, int_stat);
>> +	}
>> +
>> +END:
>> +	napi_complete(napi);
>> +	pch_can_set_int_enables(priv, PCH_CAN_ALL);
>> +
>> +	return rcv_pkts;
>> +}
>> +
>> +static int pch_set_bittiming(struct net_device *ndev)
>> +{
>> +	struct pch_can_priv *priv = netdev_priv(ndev);
>> +	const struct can_bittiming *bt = &priv->can.bittiming;
>> +	u32 canbit;
>> +	u32 bepe;
>> +
>> +	/* Setting the CCE bit for accessing the Can Timing register. */
>> +	pch_can_bit_set(&priv->regs->cont, CAN_CTRL_CCE);
>> +
>> +	canbit = (bt->brp - 1) & MSK_BITT_BRP;
>> +	canbit |= (bt->sjw - 1) << BIT_BITT_SJW;
>> +	canbit |= (bt->phase_seg1 + bt->prop_seg - 1) << BIT_BITT_TSEG1;
>> +	canbit |= (bt->phase_seg2 - 1) << BIT_BITT_TSEG2;
>> +	bepe = ((bt->brp - 1) & MSK_BRPE_BRPE) >> BIT_BRPE_BRPE;
>> +	iowrite32(canbit, &priv->regs->bitt);
>> +	iowrite32(bepe, &priv->regs->brpe);
>> +	pch_can_bit_clear(&priv->regs->cont, CAN_CTRL_CCE);
>> +
>> +	return 0;
>> +}
>> +
>> +static void pch_can_start(struct net_device *ndev)
>> +{
>> +	struct pch_can_priv *priv = netdev_priv(ndev);
>> +
>> +	if (priv->can.state != CAN_STATE_STOPPED)
>> +		pch_can_reset(priv);
>> +
>> +	pch_set_bittiming(ndev);
>> +	pch_can_set_optmode(priv);
>> +
>> +	pch_can_tx_enable_all(priv);
>> +	pch_can_rx_enable_all(priv);
>> +
>> +	/* Setting the CAN to run mode. */
>> +	pch_can_set_run_mode(priv, PCH_CAN_RUN);
>> +
>> +	priv->can.state = CAN_STATE_ERROR_ACTIVE;
>> +
>> +	return;
>> +}
>> +
>> +static int pch_can_do_set_mode(struct net_device *ndev, enum can_mode mode)
>> +{
>> +	int ret = 0;
>> +
>> +	switch (mode) {
>> +	case CAN_MODE_START:
>> +		pch_can_start(ndev);
>> +		netif_wake_queue(ndev);
>> +		break;
>> +	default:
>> +		ret = -EOPNOTSUPP;
>> +		break;
>> +	}
>> +
>> +	return ret;
>> +}
>> +
>> +static int pch_can_open(struct net_device *ndev)
>> +{
>> +	struct pch_can_priv *priv = netdev_priv(ndev);
>> +	int retval;
>> +
>> +	/* Regsitering the interrupt. */

Typo!

>> +	retval = request_irq(priv->dev->irq, pch_can_interrupt, IRQF_SHARED,
>> +			     ndev->name, ndev);
>> +	if (retval) {
>> +		dev_err(&ndev->dev, "request_irq failed.\n");
>> +		goto req_irq_err;
>> +	}
>> +
>> +	/* Open common can device */
>> +	retval = open_candev(ndev);
>> +	if (retval) {
>> +		dev_err(ndev->dev.parent, "open_candev() failed %d\n", retval);
>> +		goto err_open_candev;
>> +	}
>> +
>> +	pch_can_init(priv);
>> +	pch_can_start(ndev);
>> +	napi_enable(&priv->napi);
>> +	netif_start_queue(ndev);
>> +
>> +	return 0;
>> +
>> +err_open_candev:
>> +	free_irq(priv->dev->irq, ndev);
>> +req_irq_err:
>> +	pch_can_release(priv);
>> +
>> +	return retval;
>> +}
>> +
>> +static int pch_close(struct net_device *ndev)
>> +{
>> +	struct pch_can_priv *priv = netdev_priv(ndev);
>> +
>> +	netif_stop_queue(ndev);
>> +	napi_disable(&priv->napi);
>> +	pch_can_release(priv);
>> +	free_irq(priv->dev->irq, ndev);
>> +	close_candev(ndev);
>> +	priv->can.state = CAN_STATE_STOPPED;
>> +	return 0;
>> +}
>> +
>> +static netdev_tx_t pch_xmit(struct sk_buff *skb, struct net_device *ndev)
>> +{
>> +	unsigned long flags;
>> +	struct pch_can_priv *priv = netdev_priv(ndev);
>> +	struct can_frame *cf = (struct can_frame *)skb->data;
>> +	int tx_buffer_avail = 0;
> 
> What I'm totally missing is the TX flow controll. Your driver has to
> ensure that the package leave the controller in the order that come
> into the xmit function. Further you have to stop your xmit queue if
> you're out of tx objects and reenable if you have a object free.
> 
> Use netif_stop_queue() and netif_wake_queue() for this.
> 
>> +
>> +	if (can_dropped_invalid_skb(ndev, skb))
>> +		return NETDEV_TX_OK;
>> +
>> +	if (priv->tx_obj == (PCH_OBJ_NUM + 1)) { /* Point tail Obj + 1 */
>> +		while (ioread32(&priv->regs->treq2) & 0xfc00)
>> +			udelay(1);
> 
> please no (possible) infinite delays!
> 
>> +		priv->tx_obj = PCH_RX_OBJ_NUM + 1; /* Point head of Tx Obj ID */
>> +	}
> 
>> +
>> +	tx_buffer_avail = priv->tx_obj;
> 
> why has the "object" become a "buffer" now? :)
> 
>> +	priv->tx_obj++;
>> +
>> +	/* Attaining the lock. */
>> +	spin_lock_irqsave(&priv->msgif_reg_lock, flags);
>> +
>> +	/* Setting the CMASK register to set value*/
>                                                  ^^^
> 
> pleas add a whitespace
> 
>> +	iowrite32(CAN_CMASK_RX_TX_SET, &priv->regs->if2_cmask);
>> +
>> +	/* If ID extended is set. */
>> +	if (cf->can_id & CAN_EFF_FLAG) {
>> +		iowrite32(cf->can_id & 0xffff, &priv->regs->if2_id1);
>> +		iowrite32(((cf->can_id >> 16) & 0x1fff) | CAN_ID2_XTD,
>> +			    &priv->regs->if2_id2);
>> +	} else {
>> +		iowrite32(0, &priv->regs->if2_id1);
>> +		iowrite32((cf->can_id & CAN_SFF_MASK) << 2,
>> +			   &priv->regs->if2_id2);
>> +	}
>> +
>> +	pch_can_bit_set(&priv->regs->if2_id2, CAN_ID_MSGVAL);
> 
> Do you need to do a read-modify-write of the hardware register? Please
> prepare the values you want to write to hardware, then do it.
> 
>> +
>> +	/* If remote frame has to be transmitted.. */
>> +	if (!(cf->can_id & CAN_RTR_FLAG))
>> +		pch_can_bit_set(&priv->regs->if2_id2, CAN_ID2_DIR);
> dito
>> +	/* If remote frame has to be transmitted.. */
>> +	if (cf->can_id & CAN_RTR_FLAG)
>> +		pch_can_bit_clear(&priv->regs->if2_id2, CAN_ID2_DIR);
> dito
>> +
>> +	/* Copy data to register */
>> +	if (cf->can_dlc > 0) {
>> +		u32 data1 = *((u16 *)&cf->data[0]);
>> +		iowrite32(data1, &priv->regs->if2_dataa1);
> 
> do you think you send the bytes in correct order?
> 
>> +	}
>> +	if (cf->can_dlc > 2) {
>> +		u32 data1 = *((u16 *)&cf->data[2]);
>> +		iowrite32(data1, &priv->regs->if2_dataa2);
>> +	}
>> +	if (cf->can_dlc > 4) {
>> +		u32 data1 = *((u16 *)&cf->data[4]);
>> +		iowrite32(data1, &priv->regs->if2_datab1);
>> +	}
>> +	if (cf->can_dlc > 6) {
>> +		u32 data1 = *((u16 *)&cf->data[6]);
>> +		iowrite32(data1, &priv->regs->if2_datab2);
>> +	}

Could be handled by a loop.

>> +	can_put_echo_skb(skb, ndev, tx_buffer_avail - PCH_RX_OBJ_NUM - 1);
>> +
>> +	/* Set the size of the data. */
>> +	iowrite32(cf->can_dlc, &priv->regs->if2_mcont);
>> +
>> +	/* Update if2_mcont */
>> +	pch_can_bit_set(&priv->regs->if2_mcont,
>> +			CAN_IF_MCONT_NEWDAT | CAN_IF_MCONT_TXRQXT |
>> +			CAN_IF_MCONT_TXIE);
> 
> pleae first perpare your value, then write to hardware.
> 
>> +
>> +	if (tx_buffer_avail == PCH_RX_OBJ_NUM) /* If points tail of FIFO  */
>> +		pch_can_bit_set(&priv->regs->if2_mcont, CAN_IF_MCONT_EOB);
> 
> dito
> 
> Is EOB relevant for TX objects?
> 
>> +	pch_can_check_if_busy(&priv->regs->if2_creq, tx_buffer_avail);
>> +	spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
>> +
>> +	return NETDEV_TX_OK;
>> +}
>> +
>> +static const struct net_device_ops pch_can_netdev_ops = {
>> +	.ndo_open		= pch_can_open,
>> +	.ndo_stop		= pch_close,
>> +	.ndo_start_xmit		= pch_xmit,
>> +};
>> +
>> +static void __devexit pch_can_remove(struct pci_dev *pdev)
>> +{
>> +	struct net_device *ndev = pci_get_drvdata(pdev);
>> +	struct pch_can_priv *priv = netdev_priv(ndev);
>> +
>> +	unregister_candev(priv->ndev);
>> +	pci_iounmap(pdev, priv->regs);
>> +	if (priv->use_msi)
>> +		pci_disable_msi(priv->dev);
>> +	pci_release_regions(pdev);
>> +	pci_disable_device(pdev);
>> +	pci_set_drvdata(pdev, NULL);
>> +	free_candev(priv->ndev);
>> +}
>> +
>> +#ifdef CONFIG_PM
>> +static void pch_can_set_int_custom(struct pch_can_priv *priv)
>> +{
>> +	/* Clearing the IE, SIE and EIE bits of Can control register. */
>> +	pch_can_bit_clear(&priv->regs->cont, CAN_CTRL_IE_SIE_EIE);
>> +
>> +	/* Appropriately setting them. */
>> +	pch_can_bit_set(&priv->regs->cont,
>> +			((priv->int_enables & MSK_CTRL_IE_SIE_EIE) << 1));
>> +}
>> +
>> +/* This function retrieves interrupt enabled for the CAN device. */
>> +static u32 pch_can_get_int_enables(struct pch_can_priv *priv)
>> +{
>> +	/* Obtaining the status of IE, SIE and EIE interrupt bits. */
>> +	return (ioread32(&priv->regs->cont) & CAN_CTRL_IE_SIE_EIE) >> 1;
>> +}
>> +
>> +static u32 pch_can_get_rx_enable(struct pch_can_priv *priv, u32 buff_num)
>> +{
>> +	unsigned long flags;
>> +	u32 enable;
>> +
>> +	spin_lock_irqsave(&priv->msgif_reg_lock, flags);
>> +	iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
>> +	pch_can_check_if_busy(&priv->regs->if1_creq, buff_num);
>> +
>> +	if (((ioread32(&priv->regs->if1_id2)) & CAN_ID_MSGVAL) &&
>> +			((ioread32(&priv->regs->if1_mcont)) &
>> +			CAN_IF_MCONT_RXIE))
>> +		enable = 1;
>> +	else
>> +		enable = 0;
>> +	spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
>> +	return enable;
>> +}
>> +
>> +static u32 pch_can_get_tx_enable(struct pch_can_priv *priv, u32 buff_num)
>> +{
>> +	unsigned long flags;
>> +	u32 enable;
>> +
>> +	spin_lock_irqsave(&priv->msgif_reg_lock, flags);
>> +
>> +	iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if2_cmask);
>> +	pch_can_check_if_busy(&priv->regs->if2_creq, buff_num);
>> +	if (((ioread32(&priv->regs->if2_id2)) & CAN_ID_MSGVAL) &&
>> +			((ioread32(&priv->regs->if2_mcont)) &
>> +			CAN_IF_MCONT_TXIE)) {
>> +		enable = 1;
>> +	} else {
>> +		enable = 0;
>> +	}
>> +	spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
>> +
>> +	return enable;
>> +}

The above two functions could be handled by a common one passing "struct
pch_can_if". See similar comments above.

>> +static void pch_can_set_rx_buffer_link(struct pch_can_priv *priv,
>> +				       u32 buffer_num, u32 set)
>> +{
>> +	unsigned long flags;
>> +
>> +	spin_lock_irqsave(&priv->msgif_reg_lock, flags);
>> +	iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
>> +	pch_can_check_if_busy(&priv->regs->if1_creq, buffer_num);
>> +	iowrite32(CAN_CMASK_RDWR | CAN_CMASK_CTRL, &priv->regs->if1_cmask);
>> +	if (set == 1)
>> +		pch_can_bit_clear(&priv->regs->if1_mcont, CAN_IF_MCONT_EOB);
>> +	else
>> +		pch_can_bit_set(&priv->regs->if1_mcont, CAN_IF_MCONT_EOB);
>> +
>> +	pch_can_check_if_busy(&priv->regs->if1_creq, buffer_num);
>> +	spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
>> +}
>> +
>> +static u32 pch_can_get_rx_buffer_link(struct pch_can_priv *priv, u32 buffer_num)
>> +{
>> +	unsigned long flags;
>> +	u32 link;
>> +
>> +	spin_lock_irqsave(&priv->msgif_reg_lock, flags);
>> +	iowrite32(CAN_CMASK_RX_TX_GET, &priv->regs->if1_cmask);
>> +	pch_can_check_if_busy(&priv->regs->if1_creq, buffer_num);
>> +
>> +	if (ioread32(&priv->regs->if1_mcont) & CAN_IF_MCONT_EOB)
>> +		link = 0;
>> +	else
>> +		link = 1;
>> +	spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
>> +	return link;
>> +}
>> +
>> +static int pch_can_suspend(struct pci_dev *pdev, pm_message_t state)
>> +{
>> +	int i;
>> +	int retval;
>> +	u32 buf_stat;	/* Variable for reading the transmit buffer status. */
>> +	u32 counter = COUNTER_LIMIT;
>> +
>> +	struct net_device *dev = pci_get_drvdata(pdev);
>> +	struct pch_can_priv *priv = netdev_priv(dev);
>> +
>> +	/* Stop the CAN controller */
>> +	pch_can_set_run_mode(priv, PCH_CAN_STOP);
>> +
>> +	/* Indicate that we are aboutto/in suspend */
>> +	priv->can.state = CAN_STATE_STOPPED;
>> +
>> +	/* Waiting for all transmission to complete. */
>> +	while (counter) {
>> +		buf_stat = pch_can_get_buffer_status(priv);
>> +		if (!buf_stat)
>> +			break;
>> +		counter--;
>> +		udelay(1);
>> +	}
>> +	if (!counter)
>> +		dev_err(&pdev->dev, "%s -> Transmission time out.\n", __func__);
>> +
>> +	/* Save interrupt configuration and then disable them */
>> +	priv->int_enables = pch_can_get_int_enables(priv);
>> +	pch_can_set_int_enables(priv, PCH_CAN_DISABLE);
>> +
>> +	/* Save Tx buffer enable state */
>> +	for (i = PCH_RX_OBJ_NUM + 1; i <= PCH_OBJ_NUM; i++)
>> +		priv->tx_enable[i] = pch_can_get_tx_enable(priv, i);
>> +
>> +	/* Disable all Transmit buffers */
>> +	pch_can_tx_disable_all(priv);
>> +
>> +	/* Save Rx buffer enable state */
>> +	for (i = 1; i <= PCH_RX_OBJ_NUM; i++) {
>> +		priv->rx_enable[i] = pch_can_get_rx_enable(priv, i);
>> +		priv->rx_link[i] = pch_can_get_rx_buffer_link(priv, i);
>> +	}
>> +
>> +	/* Disable all Receive buffers */
>> +	pch_can_rx_disable_all(priv);
>> +	retval = pci_save_state(pdev);
>> +	if (retval) {
>> +		dev_err(&pdev->dev, "pci_save_state failed.\n");
>> +	} else {
>> +		pci_enable_wake(pdev, PCI_D3hot, 0);
>> +		pci_disable_device(pdev);
>> +		pci_set_power_state(pdev, pci_choose_state(pdev, state));
>> +	}
>> +
>> +	return retval;
>> +}
>> +
>> +static int pch_can_resume(struct pci_dev *pdev)
>> +{
>> +	int i;
>> +	int retval;
>> +	struct net_device *dev = pci_get_drvdata(pdev);
>> +	struct pch_can_priv *priv = netdev_priv(dev);
>> +
>> +	pci_set_power_state(pdev, PCI_D0);
>> +	pci_restore_state(pdev);
>> +	retval = pci_enable_device(pdev);
>> +	if (retval) {
>> +		dev_err(&pdev->dev, "pci_enable_device failed.\n");
>> +		return retval;
>> +	}
>> +
>> +	pci_enable_wake(pdev, PCI_D3hot, 0);
>> +
>> +	priv->can.state = CAN_STATE_ERROR_ACTIVE;
>> +
>> +	/* Disabling all interrupts. */
>> +	pch_can_set_int_enables(priv, PCH_CAN_DISABLE);
>> +
>> +	/* Setting the CAN device in Stop Mode. */
>> +	pch_can_set_run_mode(priv, PCH_CAN_STOP);
>> +
>> +	/* Configuring the transmit and receive buffers. */
>> +	pch_can_config_rx_tx_buffers(priv);
>> +
>> +	/* Restore the CAN state */
>> +	pch_set_bittiming(dev);
>> +
>> +	/* Listen/Active */
>> +	pch_can_set_optmode(priv);
>> +
>> +	/* Enabling the transmit buffer. */
>> +	for (i = 1; i <= PCH_RX_OBJ_NUM; i++)
>> +		pch_can_set_tx_enable(priv, i, priv->tx_enable[i]);
>> +
>> +	/* Configuring the receive buffer and enabling them. */
>> +	for (i = PCH_RX_OBJ_NUM + 1; i <= PCH_OBJ_NUM; i++) {
>> +		/* Restore buffer link */
>> +		pch_can_set_rx_buffer_link(priv, i, priv->rx_link[i]);
>> +
>> +		/* Restore buffer enables */
>> +		pch_can_set_rx_enable(priv, i, priv->rx_enable[i]);
>> +	}
>> +
>> +	/* Enable CAN Interrupts */
>> +	pch_can_set_int_custom(priv);
>> +
>> +	/* Restore Run Mode */
>> +	pch_can_set_run_mode(priv, PCH_CAN_RUN);
>> +
>> +	return retval;
>> +}
>> +#else
>> +#define pch_can_suspend NULL
>> +#define pch_can_resume NULL
>> +#endif
>> +
>> +static int pch_can_get_berr_counter(const struct net_device *dev,
>> +				    struct can_berr_counter *bec)
>> +{
>> +	struct pch_can_priv *priv = netdev_priv(dev);
>> +
>> +	bec->txerr = ioread32(&priv->regs->errc) & CAN_TEC;
>> +	bec->rxerr = (ioread32(&priv->regs->errc) & CAN_REC) >> 8;
>> +
>> +	return 0;
>> +}
>> +
>> +static int __devinit pch_can_probe(struct pci_dev *pdev,
>> +				   const struct pci_device_id *id)
>> +{
>> +	struct net_device *ndev;
>> +	struct pch_can_priv *priv;
>> +	int rc;
>> +	void __iomem *addr;
>> +
>> +	rc = pci_enable_device(pdev);
>> +	if (rc) {
>> +		dev_err(&pdev->dev, "Failed pci_enable_device %d\n", rc);
>> +		goto probe_exit_endev;
>> +	}
>> +
>> +	rc = pci_request_regions(pdev, KBUILD_MODNAME);
>> +	if (rc) {
>> +		dev_err(&pdev->dev, "Failed pci_request_regions %d\n", rc);
>> +		goto probe_exit_pcireq;
>> +	}
>> +
>> +	addr = pci_iomap(pdev, 1, 0);
>> +	if (!addr) {
>> +		rc = -EIO;
>> +		dev_err(&pdev->dev, "Failed pci_iomap\n");
>> +		goto probe_exit_ipmap;
>> +	}
>> +
>> +	ndev = alloc_candev(sizeof(struct pch_can_priv), PCH_TX_OBJ_NUM);
>> +	if (!ndev) {
>> +		rc = -ENOMEM;
>> +		dev_err(&pdev->dev, "Failed alloc_candev\n");
>> +		goto probe_exit_alloc_candev;
>> +	}
>> +
>> +	priv = netdev_priv(ndev);
>> +	priv->ndev = ndev;
>> +	priv->regs = addr;
>> +	priv->dev = pdev;
>> +	priv->can.bittiming_const = &pch_can_bittiming_const;
>> +	priv->can.do_set_mode = pch_can_do_set_mode;
>> +	priv->can.do_get_berr_counter = pch_can_get_berr_counter;
>> +	priv->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY |
>> +				       CAN_CTRLMODE_LOOPBACK;

I'm missing CAN_CTRLMODE_3_SAMPLES here?

>> +	priv->tx_obj = PCH_RX_OBJ_NUM + 1; /* Point head of Tx Obj */
>> +
>> +	ndev->irq = pdev->irq;
>> +	ndev->flags |= IFF_ECHO;
>> +
>> +	pci_set_drvdata(pdev, ndev);
>> +	SET_NETDEV_DEV(ndev, &pdev->dev);
>> +	ndev->netdev_ops = &pch_can_netdev_ops;
>> +	priv->can.clock.freq = PCH_CAN_CLK; /* Hz */
>> +
>> +	netif_napi_add(ndev, &priv->napi, pch_can_rx_poll, PCH_RX_OBJ_NUM);
>> +
>> +	rc = pci_enable_msi(priv->dev);
>> +	if (rc) {
>> +		dev_info(&ndev->dev, "PCH CAN opened without MSI\n");
>> +		priv->use_msi = 0;
>> +	} else {
>> +		dev_info(&ndev->dev, "PCH CAN opened with MSI\n");
>> +		priv->use_msi = 1;
>> +	}
>> +
>> +	rc = register_candev(ndev);
>> +	if (rc) {
>> +		dev_err(&pdev->dev, "Failed register_candev %d\n", rc);
>> +		goto probe_exit_reg_candev;
>> +	}
>> +
>> +	return 0;
>> +
>> +probe_exit_reg_candev:
>> +	free_candev(ndev);
>> +probe_exit_alloc_candev:
>> +	pci_iounmap(pdev, addr);
>> +probe_exit_ipmap:
>> +	pci_release_regions(pdev);
>> +probe_exit_pcireq:
>> +	pci_disable_device(pdev);
>> +probe_exit_endev:
>> +	return rc;
>> +}
>> +
>> +static struct pci_driver pch_can_pcidev = {
>> +	.name = "pch_can",
>> +	.id_table = pch_pci_tbl,
>> +	.probe = pch_can_probe,
>> +	.remove = __devexit_p(pch_can_remove),
>> +	.suspend = pch_can_suspend,
>> +	.resume = pch_can_resume,
>> +};
>> +
>> +static int __init pch_can_pci_init(void)
>> +{
>> +	return pci_register_driver(&pch_can_pcidev);
>> +}
>> +module_init(pch_can_pci_init);
>> +
>> +static void __exit pch_can_pci_exit(void)
>> +{
>> +	pci_unregister_driver(&pch_can_pcidev);
>> +}
>> +module_exit(pch_can_pci_exit);
>> +
>> +MODULE_DESCRIPTION("Intel EG20T PCH CAN(Controller Area Network) Driver");
>> +MODULE_LICENSE("GPL v2");
>> +MODULE_VERSION("0.94");

As the driver has already been merged. Please provide incremental
patches against the net-2.6 branch. Also, it would be nice if you could
check in-order transmission and reception, e.g., with the can-utils
program canfdtest:

http://svn.berlios.de/wsvn/socketcan/trunk/can-utils/canfdtest.c

Thanks,

Wolfgang.

^ permalink raw reply

* Re: [PATCH] net: Limit socket I/O iovec total length to INT_MAX.
From: Linus Torvalds @ 2010-10-29 19:37 UTC (permalink / raw)
  To: David Miller; +Cc: viro, netdev, jon.maloy, allan.stephens, drosenberg
In-Reply-To: <20101029.123230.226768623.davem@davemloft.net>

On Fri, Oct 29, 2010 at 12:32 PM, David Miller <davem@davemloft.net> wrote:
>
> I just got out of a long dentist appointment, will look at this right
> now, thanks!

I booted with it and committed it as "obvious". Let's see if there is
any fallout. I doubt it, but I also doubt we'll find any until we have
lots of testers, unless I made some subtly totally buggy change that
just didn't happen to show up during a normal boot.

                      Linus

^ permalink raw reply

* Re: Fwd: NULL pointer dereference at netxen_nic_probe+0x813/0x9a0
From: Denis Kirjanov @ 2010-10-29 19:47 UTC (permalink / raw)
  To: bjorn.helgaas; +Cc: amit.salecha, netdev, linux-kernel
In-Reply-To: <AANLkTim8coGDmxxCnhzXXLEswf1OYptswbA59BYcbp-N@mail.gmail.com>

> This is on current Linus upstream as of this morning (8128057)
> on an HP DL785:
> 
> QLogic/NetXen Network Driver v4.0.74
> netxen_nic 0000:07:00.0: PCI INT A -> GSI 30 (level, low) -> IRQ 30
> netxen_nic 0000:07:00.0: setting latency timer to 64
> netxen_nic 0000:07:00.0: 2MB memory map
> netxen_nic 0000:07:00.0: loading firmware from flash
> netxen_nic 0000:07:00.0: using 64-bit dma mask
> kernel: Quad Gig LP Board S/N TI9ABK0266  Chip rev 0x42
> netxen_nic 0000:07:00.0: firmware v4.0.520 [legacy]
> netxen_nic 0000:07:00.0: irq 72 for MSI/MSI-X
> netxen_nic 0000:07:00.0: irq 73 for MSI/MSI-X
> netxen_nic 0000:07:00.0: irq 74 for MSI/MSI-X
> netxen_nic 0000:07:00.0: irq 75 for MSI/MSI-X
> netxen_nic 0000:07:00.0: using msi-x interrupts
> BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
> IP: [<ffffffff8160afda>] netxen_nic_probe+0x813/0x9a0
> PGD 0
> Oops: 0002 [#1] SMP
> last sysfs file:
> CPU 0
> Modules linked in:
> 
> Pid: 1650, comm: work_for_cpu Not tainted 2.6.36-07338-g8128057 #269
> /ProLiant DL785 G5
> RIP: 0010:[<ffffffff8160afda>]  [<ffffffff8160afda>]
> netxen_nic_probe+0x813/0x9a0
> RSP: 0018:ffff8806138abe30  EFLAGS: 00010246
> RAX: 0000000000000010 RBX: ffff8806139126c0 RCX: 0000000000000000
> RDX: 0000000000000000 RSI: ffff880613895616 RDI: ffff880613912000
> RBP: ffff8806138abe90 R08: 0000000000000000 R09: ffff8806138abb80
> R10: 0000000000000000 R11: 0000000000000000 R12: ffff880613912000
> R13: ffff8812174f7000 R14: ffff880613912000 R15: ffff8812174f7000
> FS:  0000000000000000(0000) GS:ffff8800cfa00000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
> CR2: 0000000000000010 CR3: 0000000001c07000 CR4: 00000000000006f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
> Process work_for_cpu (pid: 1650, threadinfo ffff8806138aa000, task
> ffff880616f12be0)
> Stack:
>  ffff8812174f7090 0000000000000246 ffff8806138abe90 ffff8812174f7000
>  00008806138abfd8 0000000000000282 68cd0025b30068cc ffff880c17439d30
>  ffff8812174f7090 ffff8812174f7000 ffff8812174f7208 0000000000000000
> Call Trace:
>  [<ffffffff81203696>] local_pci_probe+0x48/0x91
>  [<ffffffff81052bae>] ? do_work_for_cpu+0x0/0x26
>  [<ffffffff81052bc1>] do_work_for_cpu+0x13/0x26
>  [<ffffffff81052bae>] ? do_work_for_cpu+0x0/0x26
>  [<ffffffff81057a7b>] kthread+0x81/0x89
>  [<ffffffff81003854>] kernel_thread_helper+0x4/0x10
>  [<ffffffff810579fa>] ? kthread+0x0/0x89
>  [<ffffffff81003850>] ? kernel_thread_helper+0x0/0x10
> Code: 00 eb 15 49 8d bf 90 00 00 00 48 c7 c6 1b 2e aa 81 31 c0 e8 c0
> 4e cd ff 4c 89 f7 e8 d6 bb ee ff 49 8b 96 00 03 00 00 48 8d 42 10 <f0>
> 80 4a 10 01 4c 89 f7 e8 a3 7e ed ff 85 c0 41 89 c4 74 2a 49
> RIP  [<ffffffff8160afda>] netxen_nic_probe+0x813/0x9a0
>  RSP <ffff8806138abe30>
> CR2: 0000000000000010
> ---[ end trace 059c7071bbf8de1f ]---
Could you please try the following patch.  

diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 50820be..5766475 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -1239,15 +1239,15 @@ netxen_setup_netdev(struct netxen_adapter *adapter,
 	if (netxen_read_mac_addr(adapter))
 		dev_warn(&pdev->dev, "failed to read mac addr\n");
 
-	netif_carrier_off(netdev);
-	netif_stop_queue(netdev);
-
 	err = register_netdev(netdev);
 	if (err) {
 		dev_err(&pdev->dev, "failed to register net device\n");
 		return err;
 	}
 
+	netif_carrier_off(netdev);
+	netif_stop_queue(netdev);
+
 	return 0;
 }


^ permalink raw reply related

* Re: NULL pointer dereference at netxen_nic_probe+0x813/0x9a0
From: David Miller @ 2010-10-29 19:54 UTC (permalink / raw)
  To: dkirjanov; +Cc: bjorn.helgaas, amit.salecha, netdev, linux-kernel
In-Reply-To: <4CCB24CA.3050106@kernel.org>

From: Denis Kirjanov <dkirjanov@kernel.org>
Date: Fri, 29 Oct 2010 23:47:22 +0400

>> This is on current Linus upstream as of this morning (8128057)
>> on an HP DL785:
>> 
>> QLogic/NetXen Network Driver v4.0.74
>> netxen_nic 0000:07:00.0: PCI INT A -> GSI 30 (level, low) -> IRQ 30
>> netxen_nic 0000:07:00.0: setting latency timer to 64
>> netxen_nic 0000:07:00.0: 2MB memory map
>> netxen_nic 0000:07:00.0: loading firmware from flash
>> netxen_nic 0000:07:00.0: using 64-bit dma mask
>> kernel: Quad Gig LP Board S/N TI9ABK0266  Chip rev 0x42
>> netxen_nic 0000:07:00.0: firmware v4.0.520 [legacy]
>> netxen_nic 0000:07:00.0: irq 72 for MSI/MSI-X
>> netxen_nic 0000:07:00.0: irq 73 for MSI/MSI-X
>> netxen_nic 0000:07:00.0: irq 74 for MSI/MSI-X
>> netxen_nic 0000:07:00.0: irq 75 for MSI/MSI-X
>> netxen_nic 0000:07:00.0: using msi-x interrupts
>> BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
>> IP: [<ffffffff8160afda>] netxen_nic_probe+0x813/0x9a0
>> PGD 0
>> Oops: 0002 [#1] SMP
>> last sysfs file:
>> CPU 0
>> Modules linked in:
>> 
>> Pid: 1650, comm: work_for_cpu Not tainted 2.6.36-07338-g8128057 #269
>> /ProLiant DL785 G5
>> RIP: 0010:[<ffffffff8160afda>]  [<ffffffff8160afda>]
>> netxen_nic_probe+0x813/0x9a0
>> RSP: 0018:ffff8806138abe30  EFLAGS: 00010246
>> RAX: 0000000000000010 RBX: ffff8806139126c0 RCX: 0000000000000000
>> RDX: 0000000000000000 RSI: ffff880613895616 RDI: ffff880613912000
>> RBP: ffff8806138abe90 R08: 0000000000000000 R09: ffff8806138abb80
>> R10: 0000000000000000 R11: 0000000000000000 R12: ffff880613912000
>> R13: ffff8812174f7000 R14: ffff880613912000 R15: ffff8812174f7000
>> FS:  0000000000000000(0000) GS:ffff8800cfa00000(0000) knlGS:0000000000000000
>> CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
>> CR2: 0000000000000010 CR3: 0000000001c07000 CR4: 00000000000006f0
>> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
>> DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
>> Process work_for_cpu (pid: 1650, threadinfo ffff8806138aa000, task
>> ffff880616f12be0)
>> Stack:
>>  ffff8812174f7090 0000000000000246 ffff8806138abe90 ffff8812174f7000
>>  00008806138abfd8 0000000000000282 68cd0025b30068cc ffff880c17439d30
>>  ffff8812174f7090 ffff8812174f7000 ffff8812174f7208 0000000000000000
>> Call Trace:
>>  [<ffffffff81203696>] local_pci_probe+0x48/0x91
>>  [<ffffffff81052bae>] ? do_work_for_cpu+0x0/0x26
>>  [<ffffffff81052bc1>] do_work_for_cpu+0x13/0x26
>>  [<ffffffff81052bae>] ? do_work_for_cpu+0x0/0x26
>>  [<ffffffff81057a7b>] kthread+0x81/0x89
>>  [<ffffffff81003854>] kernel_thread_helper+0x4/0x10
>>  [<ffffffff810579fa>] ? kthread+0x0/0x89
>>  [<ffffffff81003850>] ? kernel_thread_helper+0x0/0x10
>> Code: 00 eb 15 49 8d bf 90 00 00 00 48 c7 c6 1b 2e aa 81 31 c0 e8 c0
>> 4e cd ff 4c 89 f7 e8 d6 bb ee ff 49 8b 96 00 03 00 00 48 8d 42 10 <f0>
>> 80 4a 10 01 4c 89 f7 e8 a3 7e ed ff 85 c0 41 89 c4 74 2a 49
>> RIP  [<ffffffff8160afda>] netxen_nic_probe+0x813/0x9a0
>>  RSP <ffff8806138abe30>
>> CR2: 0000000000000010
>> ---[ end trace 059c7071bbf8de1f ]---
> Could you please try the following patch.  

Why do you need to touch the queue state at all in the probing code?

Until the first ->open() occurs, the queue state is "don't care."

The netif_carrier_off() call is fine.

^ permalink raw reply

* Re: [PATCH] net: Limit socket I/O iovec total length to INT_MAX.
From: David Miller @ 2010-10-29 19:55 UTC (permalink / raw)
  To: torvalds; +Cc: viro, netdev, jon.maloy, allan.stephens, drosenberg
In-Reply-To: <AANLkTikGkfcHdemZwURrYLPBC1QQnbQP_g-7YadzeE-D@mail.gmail.com>

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Fri, 29 Oct 2010 12:37:29 -0700

> On Fri, Oct 29, 2010 at 12:32 PM, David Miller <davem@davemloft.net> wrote:
>>
>> I just got out of a long dentist appointment, will look at this right
>> now, thanks!
> 
> I booted with it and committed it as "obvious". Let's see if there is
> any fallout. I doubt it, but I also doubt we'll find any until we have
> lots of testers, unless I made some subtly totally buggy change that
> just didn't happen to show up during a normal boot.

It ought to be ok.

Let me send you a pull request so you can get the verify_iovec() change.

^ permalink raw reply

* [GIT] Networking
From: David Miller @ 2010-10-29 19:59 UTC (permalink / raw)
  To: torvalds; +Cc: akpm, netdev, linux-kernel


This has the verify_iovec() INT_MAX limiter change as well as:

1) kdump fix in netxen from Rajesh Borundia

2) 8390 oops in probe regression fix from Pavel Emelyanov

3) ipv4 routing table memory leak on namespace stop, also from Pavel
   Emelyanov.

4) cxgb3 probe OOPS fix from Nishanth Aravamudan

5) Limit kernel stack usage of root in pktgen, from Nelson Elhage,
   although this needs a few more tweaks I think.

6) Fix panic in cxgb3 tx desc freeing, from Krishna Kumar.

7) DCCP updates from Gerrit Renker

8) pch_gbe build fix, due to missing dependency

9) Signedness fix in netfilte xt_socket code.

10) Atheros driver fixes from Felix Fietkau, Jones Desougi, Luis
    R. Rodriguez, Mohammed Shafi Shajakhan, and Rajkumar Manoharan

Please pull, thanks a lot!

The following changes since commit 1e431a9d6478940c0b5fcfa1c17a336fc0683409:

  Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb (2010-10-29 11:49:38 -0700)

are available in the git repository at:

  master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6.git master

Carolyn Wyborny (2):
      e1000e: reset PHY after errors detected
      e1000e: Add check for reset flags before displaying reset message

David S. Miller (4):
      pch_gbe: Select MII.
      net: Limit socket I/O iovec total length to INT_MAX.
      netfilter: xt_socket: Make tproto signed in socket_mt6_v1().
      Merge branch 'master' of git://git.kernel.org/.../linville/wireless-2.6

Dmitry Artamonow (1):
      USB: gadget: fix ethernet gadget crash in gether_setup

Emil Tantilov (2):
      ixgb: call pci_disable_device in ixgb_remove
      igbvf: fix panic on load

Felix Fietkau (1):
      ath9k: fix tx aggregation flush on AR9003

Geert Uytterhoeven (1):
      net: atarilance - flags should be unsigned long

Gerrit Renker (4):
      dccp: Return-value convention of hc_tx_send_packet()
      dccp: Extend CCID packet dequeueing interface
      dccp: Refine the wait-for-ccid mechanism
      dccp ccid-2: Stop polling

Jesper Juhl (1):
      mac80211: fix failure to check kmalloc return value in key_key_read

Jesse Gross (1):
      igb: Fix unused variable warning.

John Fastabend (1):
      ixgbe: DCB, fix TX hang occurring in stress condition with PFC

Jones Desougi (1):
      ath5k: Fix double free on hw attach error path

Jouni Malinen (1):
      mac80211: Fix scan_ies_len to include DS Params

Krishna Kumar (1):
      cxgb3: Fix panic in free_tx_desc()

Larry Finger (1):
      b43: Fix warning at drivers/mmc/core/core.c:237 in mmc_wait_for_cmd

Luis R. Rodriguez (4):
      ath9k: add locking for stopping RX
      ath9k: add locking for starting the PCU on RX
      ath9k: rename rxflushlock to pcu_lock
      ath9k: lock reset and PCU start/stopping

Mohammed Shafi Shajakhan (1):
      ath9k: Fix incorrect access of rate flags in RC

Nelson Elhage (1):
      pktgen: Limit how much data we copy onto the stack.

Nishanth Aravamudan (1):
      cxgb3: fix crash due to manipulating queues before registration

Paul Fox (1):
      libertas: Fix sd8686 firmware reload

Pavel Emelyanov (2):
      8390: Don't oops on starting dev queue
      fib: Fix fib zone and its hash leak on namespace stop

Rajesh Borundia (1):
      netxen: fix kdump

Rajkumar Manoharan (1):
      ath9k_htc: Set proper firmware offset for Netgear WNDA3200

avisconti (1):
      stmmac: enable/disable rx/tx in the core with a single write.

 drivers/net/Kconfig                      |    1 +
 drivers/net/atarilance.c                 |    2 +-
 drivers/net/cxgb3/cxgb3_main.c           |    2 +-
 drivers/net/cxgb3/sge.c                  |    4 +-
 drivers/net/e1000e/82571.c               |   38 ++++++
 drivers/net/e1000e/e1000.h               |    3 +
 drivers/net/e1000e/netdev.c              |   29 ++++-
 drivers/net/igb/igb_main.c               |    1 -
 drivers/net/igbvf/netdev.c               |    8 +-
 drivers/net/ixgb/ixgb_main.c             |    1 +
 drivers/net/ixgbe/ixgbe_dcb.c            |   39 +++++-
 drivers/net/ixgbe/ixgbe_dcb.h            |    5 +-
 drivers/net/ixgbe/ixgbe_dcb_82599.c      |    5 +
 drivers/net/ixgbe/ixgbe_dcb_82599.h      |    3 +
 drivers/net/ixgbe/ixgbe_main.c           |   12 ++-
 drivers/net/lib8390.c                    |    1 -
 drivers/net/netxen/netxen_nic_ctx.c      |   15 --
 drivers/net/netxen/netxen_nic_main.c     |    7 +
 drivers/net/stmmac/stmmac_main.c         |   40 ++-----
 drivers/net/wireless/ath/ath5k/attach.c  |   17 +--
 drivers/net/wireless/ath/ath9k/ath9k.h   |    2 +-
 drivers/net/wireless/ath/ath9k/hif_usb.c |   10 +-
 drivers/net/wireless/ath/ath9k/main.c    |   31 ++++-
 drivers/net/wireless/ath/ath9k/rc.c      |    2 +-
 drivers/net/wireless/ath/ath9k/recv.c    |   15 +-
 drivers/net/wireless/ath/ath9k/xmit.c    |   18 ++--
 drivers/net/wireless/b43/sdio.c          |    2 +
 drivers/net/wireless/libertas/if_sdio.c  |   32 ++++-
 drivers/usb/gadget/u_ether.c             |    2 +-
 include/linux/dccp.h                     |    4 +-
 include/linux/socket.h                   |    2 +-
 include/net/ip_fib.h                     |    2 +
 net/compat.c                             |   10 +-
 net/core/iovec.c                         |   20 ++--
 net/core/pktgen.c                        |    7 +-
 net/dccp/ccid.h                          |   34 +++++-
 net/dccp/ccids/ccid2.c                   |   23 ++-
 net/dccp/ccids/ccid2.h                   |    5 +
 net/dccp/ccids/ccid3.c                   |   12 +-
 net/dccp/dccp.h                          |    5 +-
 net/dccp/output.c                        |  209 ++++++++++++++++++------------
 net/dccp/proto.c                         |   21 +++-
 net/dccp/timer.c                         |   27 ++--
 net/ipv4/fib_frontend.c                  |    2 +-
 net/ipv4/fib_hash.c                      |   18 +++
 net/ipv4/fib_trie.c                      |    5 +
 net/mac80211/debugfs_key.c               |    6 +-
 net/mac80211/main.c                      |    5 +-
 net/netfilter/xt_socket.c                |    7 +-
 49 files changed, 525 insertions(+), 246 deletions(-)

^ permalink raw reply

* Re: [PATCH] cxgb4vf: fix crash due to manipulating queues before registration
From: David Miller @ 2010-10-29 20:05 UTC (permalink / raw)
  To: dm; +Cc: leedom, netdev
In-Reply-To: <8A71B368A89016469F72CD08050AD334088DA49E@maui.asicdesigners.com>

From: "Dimitrios Michailidis" <dm@chelsio.com>
Date: Fri, 29 Oct 2010 00:36:22 -0700

> Further, I believe moving the call after register_netdev is buggy as
> open can be called after registration and it can clash with the
> queue stopping.  It seems then that these netif_tx_stop_all_queues
> calls have to go now.

This is a good explanation of why no driver should be touching the
queue state before the first ->open() call.

^ permalink raw reply

* Re: [PATCH 0/1] RFC: poll/select performance on datagram sockets
From: Davide Libenzi @ 2010-10-29 20:08 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Alban Crequy, David S. Miller, Stephen Hemminger, Cyrill Gorcunov,
	Alexey Dobriyan, netdev, Linux Kernel Mailing List,
	Pauli Nieminen, Rainer Weikusat
In-Reply-To: <1288380431.2680.3.camel@edumazet-laptop>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1857 bytes --]

On Fri, 29 Oct 2010, Eric Dumazet wrote:

> Le vendredi 29 octobre 2010 à 19:18 +0100, Alban Crequy a écrit :
> > Hi,
> > 
> > When a process calls the poll or select, the kernel calls (struct
> > file_operations)->poll on every file descriptor and returns a mask of
> > events which are ready. If the process is only interested by POLLIN
> > events, the mask is still computed for POLLOUT and it can be expensive.
> > For example, on Unix datagram sockets, a process running poll() with
> > POLLIN will wakes-up when the remote end call read(). This is a
> > performance regression introduced when fixing another bug by
> > 3c73419c09a5ef73d56472dbfdade9e311496e9b and
> > ec0d215f9420564fc8286dcf93d2d068bb53a07e.
> > 
> > The attached program illustrates the problem. It compares the
> > performance of sending/receiving data on an Unix datagram socket and
> > select(). When the datagram sockets are not connected, the performance
> > problem is not triggered, but when they are connected it becomes a lot
> > slower. On my computer, I have the following time:
> > 
> > Connected datagram sockets: >4 seconds
> > Non-connected datagram sockets: <1 second
> > 
> > The patch attached in the next email fixes the performance problem: it
> > becomes <1 second for both cases. I am not suggesting the patch for
> > inclusion; I would like to change the prototype of (struct
> > file_operations)->poll instead of adding ->poll2. But there is a lot of
> > poll functions to change (grep tells me 337 functions).
> > 
> > Any opinions?
> 
> My opinion would be to use epoll() for this kind of workload.

Yeah, epoll does check for event hints coming with the callback wakeup, 
and avoid waking up epoll_wait() waiters, for non matching events.
Most of the devices we care about, have been modified to report the event 
mask with the wakeup call.


- Davide


^ permalink raw reply

* Re: "src" attribute ignored for IPv6 (preferred source address selection)
From: David Miller @ 2010-10-29 20:11 UTC (permalink / raw)
  To: dr; +Cc: netdev
In-Reply-To: <20101017011205.GA10610@srv03.cluenet.de>

From: Daniel Roesen <dr@cluenet.de>
Date: Sun, 17 Oct 2010 03:12:08 +0200

> http://lkml.indiana.edu/hypermail/linux/kernel/0409.0/1768.html
> 
> Unfortunately I don't have the time (and most probably not the necessary
> kernel knowhow) to hack this up myself, but I'm still interested. :-)

The routing table in ipv6 can very much handle routing by source
address now, if the ip commands mention do not work it's some
bug in the tool or the routing table rule adding code in the
kernel.

It's not a fundamental limitation any more.

^ permalink raw reply

* Re: [PATCH 0/1] RFC: poll/select performance on datagram sockets
From: Jesper Juhl @ 2010-10-29 20:20 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Alban Crequy, David S. Miller, Stephen Hemminger, Cyrill Gorcunov,
	Alexey Dobriyan, netdev, linux-kernel, Pauli Nieminen,
	Rainer Weikusat
In-Reply-To: <1288380431.2680.3.camel@edumazet-laptop>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2140 bytes --]

On Fri, 29 Oct 2010, Eric Dumazet wrote:

> Le vendredi 29 octobre 2010 à 19:18 +0100, Alban Crequy a écrit :
> > Hi,
> > 
> > When a process calls the poll or select, the kernel calls (struct
> > file_operations)->poll on every file descriptor and returns a mask of
> > events which are ready. If the process is only interested by POLLIN
> > events, the mask is still computed for POLLOUT and it can be expensive.
> > For example, on Unix datagram sockets, a process running poll() with
> > POLLIN will wakes-up when the remote end call read(). This is a
> > performance regression introduced when fixing another bug by
> > 3c73419c09a5ef73d56472dbfdade9e311496e9b and
> > ec0d215f9420564fc8286dcf93d2d068bb53a07e.
> > 
> > The attached program illustrates the problem. It compares the
> > performance of sending/receiving data on an Unix datagram socket and
> > select(). When the datagram sockets are not connected, the performance
> > problem is not triggered, but when they are connected it becomes a lot
> > slower. On my computer, I have the following time:
> > 
> > Connected datagram sockets: >4 seconds
> > Non-connected datagram sockets: <1 second
> > 
> > The patch attached in the next email fixes the performance problem: it
> > becomes <1 second for both cases. I am not suggesting the patch for
> > inclusion; I would like to change the prototype of (struct
> > file_operations)->poll instead of adding ->poll2. But there is a lot of
> > poll functions to change (grep tells me 337 functions).
> > 
> > Any opinions?
> 
> My opinion would be to use epoll() for this kind of workload.
> 
Sorry to intrude out of the blue without really understanding the kernel 
side of most of the code in question, but if there's a performance 
regression for applications using poll() shouldn't we address that so we 
get back to the prior performance level rather than requireing all 
userspace apps to switch to epoll() ??

-- 
Jesper Juhl <jj@chaosbits.net>             http://www.chaosbits.net/
Plain text mails only, please      http://www.expita.com/nomime.html
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html

^ permalink raw reply

* Re: [PATCH 0/1] RFC: poll/select performance on datagram sockets
From: Eric Dumazet @ 2010-10-29 20:20 UTC (permalink / raw)
  To: Davide Libenzi
  Cc: Alban Crequy, David S. Miller, Stephen Hemminger, Cyrill Gorcunov,
	Alexey Dobriyan, netdev, Linux Kernel Mailing List,
	Pauli Nieminen, Rainer Weikusat
In-Reply-To: <alpine.DEB.2.00.1010291306390.8517@davide-lnx1>

Le vendredi 29 octobre 2010 à 13:08 -0700, Davide Libenzi a écrit :

> Yeah, epoll does check for event hints coming with the callback wakeup, 
> and avoid waking up epoll_wait() waiters, for non matching events.
> Most of the devices we care about, have been modified to report the event 
> mask with the wakeup call.

Alban test program is _very_ pathological :

All the time is consumed in do_select() because of false sharing between
two tasks.

We can probably rearrange variables in do_select() to make this false
sharing less problematic. I am taking a look at this.

Events: 3K cycles
+     26.14%  uclient  [kernel.kallsyms]  [k] do_raw_spin_lock              
+     21.11%  uclient  [kernel.kallsyms]  [k] do_select                     
+     13.38%  uclient  [kernel.kallsyms]  [k] pollwake                      
+      9.22%  uclient  [kernel.kallsyms]  [k] unix_dgram_poll               
+      5.24%  uclient  [kernel.kallsyms]  [k] unix_peer_get                 
+      3.04%  uclient  [kernel.kallsyms]  [k] _raw_spin_unlock_irqrestore   
+      3.03%  uclient  [kernel.kallsyms]  [k] task_rq_lock                  
+      2.85%  uclient  [kernel.kallsyms]  [k] do_raw_spin_unlock            
+      1.84%  uclient  [kernel.kallsyms]  [k] try_to_wake_up                
+      1.55%  uclient  [kernel.kallsyms]  [k] fget_light                    
+      1.34%  uclient  [kernel.kallsyms]  [k] core_kernel_text              


annotate :

   5.66 :        410fb342:       85 ff                   test   %edi,%edi                  
    0.00 :        410fb344:       74 1f                   je     410fb365 <do_select+0x3d5> 
    0.13 :        410fb346:       85 b5 6c fd ff ff       test   %esi,-0x294(%ebp)          
    0.00 :        410fb34c:       74 17                   je     410fb365 <do_select+0x3d5> 
         :                                                        res_out |= bit;           
    0.00 :        410fb34e:       09 b5 5c fd ff ff       or     %esi,-0x2a4(%ebp)          
         :                                                        retval++;                 
    0.00 :        410fb354:       83 85 64 fd ff ff 01    addl   $0x1,-0x29c(%ebp)          
         :                                                        wait = NULL;              
    0.00 :        410fb35b:       c7 85 7c fd ff ff 00    movl   $0x0,-0x284(%ebp)          
    0.00 :        410fb362:       00 00 00                                                  
         :                                               }            
         :                                                if ((mask & POLLEX_SET) && (ex & bit)) {
   43.27 :        410fb365:       85 d2                   test   %edx,%edx                 
    0.00 :        410fb367:       0f 84 f3 fe ff ff       je     410fb260 <do_select+0x2d0>
    0.00 :        410fb36d:       85 b5 74 fd ff ff       test   %esi,-0x28c(%ebp)         
    0.00 :        410fb373:       0f 84 e7 fe ff ff       je     410fb260 <do_select+0x2d0>
         :                                                        res_ex |= bit;           
    0.00 :        410fb379:       09 b5 58 fd ff ff       or     %esi,-0x2a8(%ebp)         
         :                                if (all_bits == 0) {   
         :                                        i += __NFDBITS;
         :                                        continue;
         :                                }

^ permalink raw reply

* Re: [PATCH] net: Limit socket I/O iovec total length to INT_MAX.
From: Dan Rosenberg @ 2010-10-29 20:22 UTC (permalink / raw)
  To: David Miller; +Cc: torvalds, viro, netdev, jon.maloy, allan.stephens
In-Reply-To: <20101029.125509.104071725.davem@davemloft.net>

Thanks for your work on this.  Just a friendly reminder not to forget
the compat code.  :)

-Dan

On Fri, 2010-10-29 at 12:55 -0700, David Miller wrote:
> From: Linus Torvalds <torvalds@linux-foundation.org>
> Date: Fri, 29 Oct 2010 12:37:29 -0700
> 
> > On Fri, Oct 29, 2010 at 12:32 PM, David Miller <davem@davemloft.net> wrote:
> >>
> >> I just got out of a long dentist appointment, will look at this right
> >> now, thanks!
> > 
> > I booted with it and committed it as "obvious". Let's see if there is
> > any fallout. I doubt it, but I also doubt we'll find any until we have
> > lots of testers, unless I made some subtly totally buggy change that
> > just didn't happen to show up during a normal boot.
> 
> It ought to be ok.
> 
> Let me send you a pull request so you can get the verify_iovec() change.



^ permalink raw reply

* Re: [PATCH v13 10/16] Add a hook to intercept external buffers from NIC driver.
From: David Miller @ 2010-10-29 20:28 UTC (permalink / raw)
  To: xiaohui.xin; +Cc: netdev, kvm, linux-kernel, mst, mingo, herbert, jdike
In-Reply-To: <F2E9EB7348B8264F86B6AB8151CE2D7931E3CB834A@shsmsx502.ccr.corp.intel.com>

From: "Xin, Xiaohui" <xiaohui.xin@intel.com>
Date: Wed, 27 Oct 2010 09:33:12 +0800

> Somehow, it seems not a trivial work to support it now. Can we support it
> later and as a todo with our current work?

I would prefer the feature work properly, rather than only in specific
cases, before being integated.

^ permalink raw reply

* Re: [PATCH 0/1] RFC: poll/select performance on datagram sockets
From: David Miller @ 2010-10-29 20:40 UTC (permalink / raw)
  To: jj
  Cc: eric.dumazet, alban.crequy, shemminger, gorcunov, adobriyan,
	netdev, linux-kernel, pauli.nieminen, rweikusat
In-Reply-To: <alpine.LNX.2.00.1010292217390.24561@swampdragon.chaosbits.net>

From: Jesper Juhl <jj@chaosbits.net>
Date: Fri, 29 Oct 2010 22:20:12 +0200 (CEST)

> Sorry to intrude out of the blue without really understanding the kernel 
> side of most of the code in question, but if there's a performance 
> regression for applications using poll() shouldn't we address that so we 
> get back to the prior performance level rather than requireing all 
> userspace apps to switch to epoll() ??

For such a pathological program like Alban's test case, I say
absolutely not.

^ permalink raw reply

* Re: [PATCH 0/1] RFC: poll/select performance on datagram sockets
From: Eric Dumazet @ 2010-10-29 20:45 UTC (permalink / raw)
  To: David Miller
  Cc: jj, alban.crequy, shemminger, gorcunov, adobriyan, netdev,
	linux-kernel, pauli.nieminen, rweikusat
In-Reply-To: <20101029.134058.246543591.davem@davemloft.net>

Le vendredi 29 octobre 2010 à 13:40 -0700, David Miller a écrit :
> From: Jesper Juhl <jj@chaosbits.net>
> Date: Fri, 29 Oct 2010 22:20:12 +0200 (CEST)
> 
> > Sorry to intrude out of the blue without really understanding the kernel 
> > side of most of the code in question, but if there's a performance 
> > regression for applications using poll() shouldn't we address that so we 
> > get back to the prior performance level rather than requireing all 
> > userspace apps to switch to epoll() ??
> 
> For such a pathological program like Alban's test case, I say
> absolutely not.

Yes, and with some perf tool help, we probably can find out how to
speedup the thing again, with no API change.

^ permalink raw reply

* Re: [PATCH 0/1] RFC: poll/select performance on datagram sockets
From: Davide Libenzi @ 2010-10-29 20:46 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Alban Crequy, David S. Miller, Stephen Hemminger, Cyrill Gorcunov,
	Alexey Dobriyan, netdev, Linux Kernel Mailing List,
	Pauli Nieminen, Rainer Weikusat
In-Reply-To: <alpine.DEB.2.00.1010291306390.8517@davide-lnx1>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1941 bytes --]

On Fri, 29 Oct 2010, Davide Libenzi wrote:

> On Fri, 29 Oct 2010, Eric Dumazet wrote:
> 
> > Le vendredi 29 octobre 2010 à 19:18 +0100, Alban Crequy a écrit :
> > > Hi,
> > > 
> > > When a process calls the poll or select, the kernel calls (struct
> > > file_operations)->poll on every file descriptor and returns a mask of
> > > events which are ready. If the process is only interested by POLLIN
> > > events, the mask is still computed for POLLOUT and it can be expensive.
> > > For example, on Unix datagram sockets, a process running poll() with
> > > POLLIN will wakes-up when the remote end call read(). This is a
> > > performance regression introduced when fixing another bug by
> > > 3c73419c09a5ef73d56472dbfdade9e311496e9b and
> > > ec0d215f9420564fc8286dcf93d2d068bb53a07e.
> > > 
> > > The attached program illustrates the problem. It compares the
> > > performance of sending/receiving data on an Unix datagram socket and
> > > select(). When the datagram sockets are not connected, the performance
> > > problem is not triggered, but when they are connected it becomes a lot
> > > slower. On my computer, I have the following time:
> > > 
> > > Connected datagram sockets: >4 seconds
> > > Non-connected datagram sockets: <1 second
> > > 
> > > The patch attached in the next email fixes the performance problem: it
> > > becomes <1 second for both cases. I am not suggesting the patch for
> > > inclusion; I would like to change the prototype of (struct
> > > file_operations)->poll instead of adding ->poll2. But there is a lot of
> > > poll functions to change (grep tells me 337 functions).
> > > 
> > > Any opinions?
> > 
> > My opinion would be to use epoll() for this kind of workload.
> 
> Yeah, epoll does check for event hints coming with the callback wakeup, 
> and avoid waking up epoll_wait() waiters, for non matching events.

Also, why not using the existing wait->key instead of adding a poll2()?


- Davide

^ permalink raw reply

* Re: [PATCH] phy/marvell: rename 88ec048 to 88e1318s and fix mscr1 addr
From: David Miller @ 2010-10-29 20:50 UTC (permalink / raw)
  To: cyril; +Cc: netdev
In-Reply-To: <1288280112-622-1-git-send-email-cyril@ti.com>

From: Cyril Chemparathy <cyril@ti.com>
Date: Thu, 28 Oct 2010 11:35:12 -0400

> The marvell 88ec048's official part number is 88e1318s.  This patch renames
> definitions in the driver to reflect this.
> 
> In addition, a minor bug fix has been added to write back the MSCR1 register
> value properly.
> 
> Signed-off-by: Cyril Chemparathy <cyril@ti.com>

Applied, thank you.

^ permalink raw reply

* Re: [PATCH 0/1] RFC: poll/select performance on datagram sockets
From: Eric Dumazet @ 2010-10-29 21:05 UTC (permalink / raw)
  To: Davide Libenzi
  Cc: Alban Crequy, David S. Miller, Stephen Hemminger, Cyrill Gorcunov,
	Alexey Dobriyan, netdev, Linux Kernel Mailing List,
	Pauli Nieminen, Rainer Weikusat
In-Reply-To: <alpine.DEB.2.00.1010291339180.8517@davide-lnx1>

Following patch solves the problem for me, and its only a start, I am
pretty sure we can optimize more than that.

What I did is to move "struct poll_wqueues table;" out of do_select()
in its caller. This structure is highly modified by an other cpu in
Alban workload, and this slow down do_select() because many accesses to
some of its local variables (normally, private ones !) hit a false
sharing.

Before :

# time /root/uclient connected
The performance problem will be triggered
select: begin
select: end: 3 seconds

real	0m3.101s
user	0m0.000s
sys	0m6.104s

After :

# time /root/uclient connected
The performance problem will be triggered
select: begin
select: end: 1 seconds

real	0m1.041s
user	0m0.004s
sys	0m2.040s


Impressive no ?

Reported-by: Alban Crequy <alban.crequy@collabora.co.uk>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
 fs/compat.c          |    3 ++-
 fs/select.c          |   19 ++++++++++---------
 include/linux/poll.h |    3 ++-
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/fs/compat.c b/fs/compat.c
index ff66c0d..3c3c3d3 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1704,6 +1704,7 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp,
 	int size, max_fds, ret = -EINVAL;
 	struct fdtable *fdt;
 	long stack_fds[SELECT_STACK_ALLOC/sizeof(long)];
+	struct poll_wqueues table;
 
 	if (n < 0)
 		goto out_nofds;
@@ -1744,7 +1745,7 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp,
 	zero_fd_set(n, fds.res_out);
 	zero_fd_set(n, fds.res_ex);
 
-	ret = do_select(n, &fds, end_time);
+	ret = do_select(n, &fds, end_time, &table);
 
 	if (ret < 0)
 		goto out;
diff --git a/fs/select.c b/fs/select.c
index b7b10aa..ed054f5 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -393,10 +393,10 @@ static inline void wait_key_set(poll_table *wait, unsigned long in,
 	}
 }
 
-int do_select(int n, fd_set_bits *fds, struct timespec *end_time)
+int do_select(int n, fd_set_bits *fds, struct timespec *end_time,
+	      struct poll_wqueues *table)
 {
 	ktime_t expire, *to = NULL;
-	struct poll_wqueues table;
 	poll_table *wait;
 	int retval, i, timed_out = 0;
 	unsigned long slack = 0;
@@ -409,8 +409,8 @@ int do_select(int n, fd_set_bits *fds, struct timespec *end_time)
 		return retval;
 	n = retval;
 
-	poll_initwait(&table);
-	wait = &table.pt;
+	poll_initwait(table);
+	wait = &table->pt;
 	if (end_time && !end_time->tv_sec && !end_time->tv_nsec) {
 		wait = NULL;
 		timed_out = 1;
@@ -482,8 +482,8 @@ int do_select(int n, fd_set_bits *fds, struct timespec *end_time)
 		wait = NULL;
 		if (retval || timed_out || signal_pending(current))
 			break;
-		if (table.error) {
-			retval = table.error;
+		if (table->error) {
+			retval = table->error;
 			break;
 		}
 
@@ -497,12 +497,12 @@ int do_select(int n, fd_set_bits *fds, struct timespec *end_time)
 			to = &expire;
 		}
 
-		if (!poll_schedule_timeout(&table, TASK_INTERRUPTIBLE,
+		if (!poll_schedule_timeout(table, TASK_INTERRUPTIBLE,
 					   to, slack))
 			timed_out = 1;
 	}
 
-	poll_freewait(&table);
+	poll_freewait(table);
 
 	return retval;
 }
@@ -528,6 +528,7 @@ int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp,
 	struct fdtable *fdt;
 	/* Allocate small arguments on the stack to save memory and be faster */
 	long stack_fds[SELECT_STACK_ALLOC/sizeof(long)];
+	struct poll_wqueues table;
 
 	ret = -EINVAL;
 	if (n < 0)
@@ -570,7 +571,7 @@ int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp,
 	zero_fd_set(n, fds.res_out);
 	zero_fd_set(n, fds.res_ex);
 
-	ret = do_select(n, &fds, end_time);
+	ret = do_select(n, &fds, end_time, &table);
 
 	if (ret < 0)
 		goto out;
diff --git a/include/linux/poll.h b/include/linux/poll.h
index 56e76af..54ba625 100644
--- a/include/linux/poll.h
+++ b/include/linux/poll.h
@@ -130,7 +130,8 @@ void zero_fd_set(unsigned long nr, unsigned long *fdset)
 
 #define MAX_INT64_SECONDS (((s64)(~((u64)0)>>1)/HZ)-1)
 
-extern int do_select(int n, fd_set_bits *fds, struct timespec *end_time);
+extern int do_select(int n, fd_set_bits *fds, struct timespec *end_time,
+		     struct poll_wqueues *table);
 extern int do_sys_poll(struct pollfd __user * ufds, unsigned int nfds,
 		       struct timespec *end_time);
 extern int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp,

^ permalink raw reply related

* Re: [PATCH 0/15] RFC: create drivers/net/legacy for ISA, EISA, MCA drivers
From: Paul Gortmaker @ 2010-10-29 21:26 UTC (permalink / raw)
  To: Joe Perches; +Cc: davem, netdev, Jeff Kirsher
In-Reply-To: <1288316896.1836.41.camel@Joe-Laptop>

On 10-10-28 09:48 PM, Joe Perches wrote:
> On Thu, 2010-10-28 at 21:19 -0400, Paul Gortmaker wrote:
>> The drivers/net dir has a lot of files - originally there were
>> no subdirs, but at least now subdirs are being used effectively.
>> But the original drivers from 10+ years ago are still right
>> there at the top.  This series creates a drivers/net/legacy dir.
> 
> Hi Paul.
> 
> I like this idea.
> 
> I suggest a bit of a further grouping by using a
> drivers/net/ethernet directory and putting those
> legacy drivers in a new subdirectory
> drivers/net/ethernet/legacy.

That is a substantially larger change, since you'd now be
relocating nearly every remaining driver, i.e. all the
relatively modern 100M and GigE drivers.  Plus what do you
do with the sb1000 - create drivers/cablemodem/legacy
just for one file?  Or the ethernet drivers already in
existing subdirs, like arm and pcmcia -- do we move those?

With this, I tried to aim for a significant gain (close to 1/3
less files) within what I felt was a reasonable sized change
set that had a chance of getting an overall OK from folks.
Giant "flag-day" type mammoth changesets are a PITA for all.

> 
>> The initial target is things like ISA/EISA/MCA drivers, and with
>> that alone, we can get close to 90 files out of drivers/net.
>> Plus, by having a semi-defined description for legacy as being
>> "drivers more than 10 years old" we'll always have a destination
>> for drivers as they fall out of maintainership and use.
> 
> I think legacy is "old and not sold or used much anymore".

I tried to stick to having both, ie. old + not used much,
in what I chose for my initial group.   Where "old" is
meant to apply to the hardware, and not to the driver. 

> 
> I believe you're not moving 3c59x as that's relatively
> still popular even though it's nearly 15 years old.
> 
> Or maybe that was just an oversight...

I didn't want to include any drivers in the initial group
that I thought might sidetrack the issue by being contentious
(clearly I was off by one) -- the point being, that once the
base infrastructure and initial group of (almost) universally
agreed upon ones is in, more can be discussed and added later,
as appropriate.

Paul.

> 
> 
> 


^ permalink raw reply

* Re: [GIT] Networking
From: Linus Torvalds @ 2010-10-29 21:41 UTC (permalink / raw)
  To: David Miller; +Cc: akpm, netdev, linux-kernel
In-Reply-To: <20101029.125920.189692530.davem@davemloft.net>

[-- Attachment #1: Type: text/plain, Size: 1435 bytes --]

On Fri, Oct 29, 2010 at 12:59 PM, David Miller <davem@davemloft.net> wrote:
>
> This has the verify_iovec() INT_MAX limiter change as well as:

I think you'd want this as well, to make sure that sendto/recvfrom
don't generate invalid iovecs.

Feel free to add my sign-off (or just commit it as yourself) after
giving it some testing.

NOTE! On thing that struck me is that the VFS layer does the
"access_ok()" on the pre-truncated size and pointer pair, and I think
that is the correct thing to do. However, the socket layer (and this
patch) just truncates the size, so even if the copy is then done
correctly with the proper user access checking, it will not check that
the whole original buffer was valid - only that the buffer it fills in
is valid.

Now, this is not a security issue (since we're just not checking stuff
that isn't getting filled in), but I think it's a QoI issue - it
allows users to successfully pass in bogus buffers with huge sizes,
and then if the thing only reads a few bytes it will all be ok.

That's not a new thing: the old code may not have truncated the sizes,
but if you pass in a 2GB buffer size, 99.999% of all socket read calls
obviously won't ever fill that 2GB, but will happily return with
whatever is there in the socket now (especially with nonblocking IO
etc). But I do wonder if we shouldn't do the access_ok() on the whole
buffer, as a way to keep user code honest.

                  Linus

[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 686 bytes --]

 net/socket.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/net/socket.c b/net/socket.c
index 5247ae1..3ca2fd9 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1652,6 +1652,8 @@ SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
 	struct iovec iov;
 	int fput_needed;
 
+	if (len > INT_MAX)
+		len = INT_MAX;
 	sock = sockfd_lookup_light(fd, &err, &fput_needed);
 	if (!sock)
 		goto out;
@@ -1709,6 +1711,8 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
 	int err, err2;
 	int fput_needed;
 
+	if (size > INT_MAX)
+		size = INT_MAX;
 	sock = sockfd_lookup_light(fd, &err, &fput_needed);
 	if (!sock)
 		goto out;

^ permalink raw reply related

* Re: [PATCH] ipv4: Flush per-ns routing cache more sanely.
From: Daniel Lezcano @ 2010-10-29 21:41 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David Miller, ebiederm, netdev
In-Reply-To: <1288121422.2652.14.camel@edumazet-laptop>

On 10/26/2010 09:30 PM, Eric Dumazet wrote:
> Le mardi 26 octobre 2010 à 12:20 -0700, David Miller a écrit :
>    
>> From: ebiederm@xmission.com (Eric W. Biederman)
>> Date: Tue, 26 Oct 2010 12:05:39 -0700
>>
>>      
>>>> @@ -999,7 +999,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
>>>>   		rt_cache_flush(dev_net(dev), 0);
>>>>   		break;
>>>>   	case NETDEV_UNREGISTER_BATCH:
>>>> -		rt_cache_flush_batch();
>>>> +		rt_cache_flush_batch(dev_net(dev));
>>>>          
>>> It still has this incorrect conversion in it.
>>>        
>> Sorry I missed that, what's the exact problem with it?
>>      
> Because the way _BATCH operation is performed, we call it once...
>
> rollback_registered_many() calls it for the first dev queued in the
> list.
>
> So it should be net independant.
>    

Dave,

do you plan to send another version of this patch ? Or can I test it as 
it is ?
Without removing a network device, I can check the routine, no ?

Thanks
   -- Daniel

^ permalink raw reply

* Re: [PATCH net-next] vxge: make functions local and remove dead code
From: Jon Mason @ 2010-10-29 21:44 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: David Miller, netdev@vger.kernel.org, Ramkrishna Vepa,
	Sivakumar Subramani, Sreenivasa Honnur
In-Reply-To: <20101018202822.GC13623@exar.com>

The original patch did not apply after the patch-set I sent out
yesterday, so I've reworked it based on the output of namespace.
Below is the patch which handles all of the issues.  I've done a quick
sniff test, and it seems to be happy.  I'll add it to our internal
patch queue, and push it out once testing has been completed.

Thanks,
Jon

commit 9d78e68196097b5ed4e9fbd16d9e936b498f075f
Author: Jon Mason <jon.mason@exar.com>
Date:   Fri Oct 29 13:59:53 2010 -0500

    vxge: make functions local and remove dead code

    Use results of make namespacecheck to make functions local and
    remove code that is not used.

    Also rename initialize_ethtool_ops to vxge_initialize_ethtool_ops.

    Based on original patch by Stephen Hemminger

    Signed-off-by: Jon Mason <jon.mason@exar.com>

diff --git a/drivers/net/vxge/vxge-config.c b/drivers/net/vxge/vxge-config.c
index 312c4c1..6a2ed90 100644
--- a/drivers/net/vxge/vxge-config.c
+++ b/drivers/net/vxge/vxge-config.c
@@ -21,6 +21,15 @@
 #include "vxge-config.h"
 #include "vxge-main.h"

+#define VXGE_HW_VPATH_STATS_PIO_READ(offset) {                         \
+       status = __vxge_hw_vpath_stats_access(vpath,                    \
+                       VXGE_HW_STATS_OP_READ,                          \
+                       offset,                                         \
+                       &val64);                                        \
+       if (status != VXGE_HW_OK)                                       \
+               return status;                                          \
+}
+
 static void
 vxge_hw_vpath_set_zero_rx_frm_len(struct vxge_hw_vpath_reg __iomem *vp_reg)
 {
@@ -103,6 +112,53 @@ void vxge_hw_device_wait_receive_idle(struct __vxge_hw_device *hldev)
        }
 }

+/*
+ * __vxge_hw_device_register_poll
+ * Will poll certain register for specified amount of time.
+ * Will poll until masked bit is not cleared.
+ */
+static enum vxge_hw_status
+__vxge_hw_device_register_poll(void __iomem *reg, u64 mask, u32 max_millis)
+{
+       u64 val64;
+       u32 i = 0;
+       enum vxge_hw_status ret = VXGE_HW_FAIL;
+
+       udelay(10);
+
+       do {
+               val64 = readq(reg);
+               if (!(val64 & mask))
+                       return VXGE_HW_OK;
+               udelay(100);
+       } while (++i <= 9);
+
+       i = 0;
+       do {
+               val64 = readq(reg);
+               if (!(val64 & mask))
+                       return VXGE_HW_OK;
+               mdelay(1);
+       } while (++i <= max_millis);
+
+       return ret;
+}
+
+static inline enum vxge_hw_status
+__vxge_hw_pio_mem_write64(u64 val64, void __iomem *addr,
+                         u64 mask, u32 max_millis)
+{
+       enum vxge_hw_status status = VXGE_HW_OK;
+
+       __vxge_hw_pio_mem_write32_lower((u32)vxge_bVALn(val64, 32, 32), addr);
+       wmb();
+       __vxge_hw_pio_mem_write32_upper((u32)vxge_bVALn(val64, 0, 32), addr);
+       wmb();
+
+       status = __vxge_hw_device_register_poll(addr, mask, max_millis);
+       return status;
+}
+
 static enum vxge_hw_status
 vxge_hw_vpath_fw_api(struct __vxge_hw_virtualpath *vpath, u32 action,
                     u32 fw_memo, u32 offset, u64 *data0, u64 *data1,
@@ -355,82 +411,11 @@ vxge_hw_vpath_eprom_img_ver_get(struct __vxge_hw_device *hldev,
 }

 /*
- * __vxge_hw_channel_allocate - Allocate memory for channel
- * This function allocates required memory for the channel and various arrays
- * in the channel
- */
-struct __vxge_hw_channel*
-__vxge_hw_channel_allocate(struct __vxge_hw_vpath_handle *vph,
-                          enum __vxge_hw_channel_type type,
-       u32 length, u32 per_dtr_space, void *userdata)
-{
-       struct __vxge_hw_channel *channel;
-       struct __vxge_hw_device *hldev;
-       int size = 0;
-       u32 vp_id;
-
-       hldev = vph->vpath->hldev;
-       vp_id = vph->vpath->vp_id;
-
-       switch (type) {
-       case VXGE_HW_CHANNEL_TYPE_FIFO:
-               size = sizeof(struct __vxge_hw_fifo);
-               break;
-       case VXGE_HW_CHANNEL_TYPE_RING:
-               size = sizeof(struct __vxge_hw_ring);
-               break;
-       default:
-               break;
-       }
-
-       channel = kzalloc(size, GFP_KERNEL);
-       if (channel == NULL)
-               goto exit0;
-       INIT_LIST_HEAD(&channel->item);
-
-       channel->common_reg = hldev->common_reg;
-       channel->first_vp_id = hldev->first_vp_id;
-       channel->type = type;
-       channel->devh = hldev;
-       channel->vph = vph;
-       channel->userdata = userdata;
-       channel->per_dtr_space = per_dtr_space;
-       channel->length = length;
-       channel->vp_id = vp_id;
-
-       channel->work_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL);
-       if (channel->work_arr == NULL)
-               goto exit1;
-
-       channel->free_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL);
-       if (channel->free_arr == NULL)
-               goto exit1;
-       channel->free_ptr = length;
-
-       channel->reserve_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL);
-       if (channel->reserve_arr == NULL)
-               goto exit1;
-       channel->reserve_ptr = length;
-       channel->reserve_top = 0;
-
-       channel->orig_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL);
-       if (channel->orig_arr == NULL)
-               goto exit1;
-
-       return channel;
-exit1:
-       __vxge_hw_channel_free(channel);
-
-exit0:
-       return NULL;
-}
-
-/*
  * __vxge_hw_channel_free - Free memory allocated for channel
  * This function deallocates memory from the channel and various arrays
  * in the channel
  */
-void __vxge_hw_channel_free(struct __vxge_hw_channel *channel)
+static void __vxge_hw_channel_free(struct __vxge_hw_channel *channel)
 {
        kfree(channel->work_arr);
        kfree(channel->free_arr);
@@ -444,7 +429,7 @@ void __vxge_hw_channel_free(struct __vxge_hw_channel *channel)
  * This function initializes a channel by properly setting the
  * various references
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_channel_initialize(struct __vxge_hw_channel *channel)
 {
        u32 i;
@@ -479,7 +464,7 @@ __vxge_hw_channel_initialize(struct __vxge_hw_channel *channel)
  * __vxge_hw_channel_reset - Resets a channel
  * This function resets a channel by properly setting the various references
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_channel_reset(struct __vxge_hw_channel *channel)
 {
        u32 i;
@@ -506,8 +491,7 @@ __vxge_hw_channel_reset(struct __vxge_hw_channel *channel)
  * Initialize certain PCI/PCI-X configuration registers
  * with recommended values. Save config space for future hw resets.
  */
-void
-__vxge_hw_device_pci_e_init(struct __vxge_hw_device *hldev)
+static void __vxge_hw_device_pci_e_init(struct __vxge_hw_device *hldev)
 {
        u16 cmd = 0;

@@ -519,43 +503,11 @@ __vxge_hw_device_pci_e_init(struct __vxge_hw_device *hldev)
        pci_save_state(hldev->pdev);
 }

-/*
- * __vxge_hw_device_register_poll
- * Will poll certain register for specified amount of time.
- * Will poll until masked bit is not cleared.
- */
-enum vxge_hw_status
-__vxge_hw_device_register_poll(void __iomem *reg, u64 mask, u32 max_millis)
-{
-       u64 val64;
-       u32 i = 0;
-       enum vxge_hw_status ret = VXGE_HW_FAIL;
-
-       udelay(10);
-
-       do {
-               val64 = readq(reg);
-               if (!(val64 & mask))
-                       return VXGE_HW_OK;
-               udelay(100);
-       } while (++i <= 9);
-
-       i = 0;
-       do {
-               val64 = readq(reg);
-               if (!(val64 & mask))
-                       return VXGE_HW_OK;
-               mdelay(1);
-       } while (++i <= max_millis);
-
-       return ret;
-}
-
 /* __vxge_hw_device_vpath_reset_in_prog_check - Check if vpath reset
  * in progress
  * This routine checks the vpath reset in progress register is turned zero
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_device_vpath_reset_in_prog_check(u64 __iomem *vpath_rst_in_prog)
 {
        enum vxge_hw_status status;
@@ -566,11 +518,66 @@ __vxge_hw_device_vpath_reset_in_prog_check(u64 __iomem *vpath_rst_in_prog)
 }

 /*
+ * _hw_legacy_swapper_set - Set the swapper bits for the legacy secion.
+ * Set the swapper bits appropriately for the lagacy section.
+ */
+static enum vxge_hw_status
+__vxge_hw_legacy_swapper_set(struct vxge_hw_legacy_reg __iomem *legacy_reg)
+{
+       u64 val64;
+       enum vxge_hw_status status = VXGE_HW_OK;
+
+       val64 = readq(&legacy_reg->toc_swapper_fb);
+
+       wmb();
+
+       switch (val64) {
+
+       case VXGE_HW_SWAPPER_INITIAL_VALUE:
+               return status;
+
+       case VXGE_HW_SWAPPER_BYTE_SWAPPED_BIT_FLIPPED:
+               writeq(VXGE_HW_SWAPPER_READ_BYTE_SWAP_ENABLE,
+                       &legacy_reg->pifm_rd_swap_en);
+               writeq(VXGE_HW_SWAPPER_READ_BIT_FLAP_ENABLE,
+                       &legacy_reg->pifm_rd_flip_en);
+               writeq(VXGE_HW_SWAPPER_WRITE_BYTE_SWAP_ENABLE,
+                       &legacy_reg->pifm_wr_swap_en);
+               writeq(VXGE_HW_SWAPPER_WRITE_BIT_FLAP_ENABLE,
+                       &legacy_reg->pifm_wr_flip_en);
+               break;
+
+       case VXGE_HW_SWAPPER_BYTE_SWAPPED:
+               writeq(VXGE_HW_SWAPPER_READ_BYTE_SWAP_ENABLE,
+                       &legacy_reg->pifm_rd_swap_en);
+               writeq(VXGE_HW_SWAPPER_WRITE_BYTE_SWAP_ENABLE,
+                       &legacy_reg->pifm_wr_swap_en);
+               break;
+
+       case VXGE_HW_SWAPPER_BIT_FLIPPED:
+               writeq(VXGE_HW_SWAPPER_READ_BIT_FLAP_ENABLE,
+                       &legacy_reg->pifm_rd_flip_en);
+               writeq(VXGE_HW_SWAPPER_WRITE_BIT_FLAP_ENABLE,
+                       &legacy_reg->pifm_wr_flip_en);
+               break;
+       }
+
+       wmb();
+
+       val64 = readq(&legacy_reg->toc_swapper_fb);
+
+       if (val64 != VXGE_HW_SWAPPER_INITIAL_VALUE)
+               status = VXGE_HW_ERR_SWAPPER_CTRL;
+
+       return status;
+}
+
+/*
  * __vxge_hw_device_toc_get
  * This routine sets the swapper and reads the toc pointer and returns the
  * memory mapped address of the toc
  */
-struct vxge_hw_toc_reg __iomem *
+static struct vxge_hw_toc_reg __iomem *
 __vxge_hw_device_toc_get(void __iomem *bar0)
 {
        u64 val64;
@@ -596,7 +603,7 @@ exit:
  * register location pointers in the device object. It waits until the ric is
  * completed initializing registers.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_device_reg_addr_get(struct __vxge_hw_device *hldev)
 {
        u64 val64;
@@ -792,7 +799,8 @@ __vxge_hw_verify_pci_e_info(struct __vxge_hw_device *hldev)
  * __vxge_hw_device_initialize
  * Initialize Titan-V hardware.
  */
-enum vxge_hw_status __vxge_hw_device_initialize(struct __vxge_hw_device *hldev)
+static enum vxge_hw_status
+__vxge_hw_device_initialize(struct __vxge_hw_device *hldev)
 {
        enum vxge_hw_status status = VXGE_HW_OK;

@@ -1105,6 +1113,227 @@ exit:
 }

 /*
+ * __vxge_hw_blockpool_destroy - Deallocates the block pool
+ */
+static void __vxge_hw_blockpool_destroy(struct __vxge_hw_blockpool *blockpool)
+{
+
+       struct __vxge_hw_device *hldev;
+       struct list_head *p, *n;
+       u16 ret;
+
+       if (blockpool == NULL) {
+               ret = 1;
+               goto exit;
+       }
+
+       hldev = blockpool->hldev;
+
+       list_for_each_safe(p, n, &blockpool->free_block_list) {
+
+               pci_unmap_single(hldev->pdev,
+                       ((struct __vxge_hw_blockpool_entry *)p)->dma_addr,
+                       ((struct __vxge_hw_blockpool_entry *)p)->length,
+                       PCI_DMA_BIDIRECTIONAL);
+
+               vxge_os_dma_free(hldev->pdev,
+                       ((struct __vxge_hw_blockpool_entry *)p)->memblock,
+                       &((struct __vxge_hw_blockpool_entry *) p)->acc_handle);
+
+               list_del(
+                       &((struct __vxge_hw_blockpool_entry *)p)->item);
+               kfree(p);
+               blockpool->pool_size--;
+       }
+
+       list_for_each_safe(p, n, &blockpool->free_entry_list) {
+               list_del(
+                       &((struct __vxge_hw_blockpool_entry *)p)->item);
+               kfree((void *)p);
+       }
+       ret = 0;
+exit:
+       return;
+}
+
+/*
+ * __vxge_hw_blockpool_create - Create block pool
+ */
+static enum vxge_hw_status
+__vxge_hw_blockpool_create(struct __vxge_hw_device *hldev,
+                          struct __vxge_hw_blockpool *blockpool,
+                          u32 pool_size,
+                          u32 pool_max)
+{
+       u32 i;
+       struct __vxge_hw_blockpool_entry *entry = NULL;
+       void *memblock;
+       dma_addr_t dma_addr;
+       struct pci_dev *dma_handle;
+       struct pci_dev *acc_handle;
+       enum vxge_hw_status status = VXGE_HW_OK;
+
+       if (blockpool == NULL) {
+               status = VXGE_HW_FAIL;
+               goto blockpool_create_exit;
+       }
+
+       blockpool->hldev = hldev;
+       blockpool->block_size = VXGE_HW_BLOCK_SIZE;
+       blockpool->pool_size = 0;
+       blockpool->pool_max = pool_max;
+       blockpool->req_out = 0;
+
+       INIT_LIST_HEAD(&blockpool->free_block_list);
+       INIT_LIST_HEAD(&blockpool->free_entry_list);
+
+       for (i = 0; i < pool_size + pool_max; i++) {
+               entry = kzalloc(sizeof(struct __vxge_hw_blockpool_entry),
+                               GFP_KERNEL);
+               if (entry == NULL) {
+                       __vxge_hw_blockpool_destroy(blockpool);
+                       status = VXGE_HW_ERR_OUT_OF_MEMORY;
+                       goto blockpool_create_exit;
+               }
+               list_add(&entry->item, &blockpool->free_entry_list);
+       }
+
+       for (i = 0; i < pool_size; i++) {
+
+               memblock = vxge_os_dma_malloc(
+                               hldev->pdev,
+                               VXGE_HW_BLOCK_SIZE,
+                               &dma_handle,
+                               &acc_handle);
+
+               if (memblock == NULL) {
+                       __vxge_hw_blockpool_destroy(blockpool);
+                       status = VXGE_HW_ERR_OUT_OF_MEMORY;
+                       goto blockpool_create_exit;
+               }
+
+               dma_addr = pci_map_single(hldev->pdev, memblock,
+                               VXGE_HW_BLOCK_SIZE, PCI_DMA_BIDIRECTIONAL);
+
+               if (unlikely(pci_dma_mapping_error(hldev->pdev,
+                               dma_addr))) {
+
+                       vxge_os_dma_free(hldev->pdev, memblock, &acc_handle);
+                       __vxge_hw_blockpool_destroy(blockpool);
+                       status = VXGE_HW_ERR_OUT_OF_MEMORY;
+                       goto blockpool_create_exit;
+               }
+
+               if (!list_empty(&blockpool->free_entry_list))
+                       entry = (struct __vxge_hw_blockpool_entry *)
+                               list_first_entry(&blockpool->free_entry_list,
+                                       struct __vxge_hw_blockpool_entry,
+                                       item);
+
+               if (entry == NULL)
+                       entry =
+                           kzalloc(sizeof(struct __vxge_hw_blockpool_entry),
+                                       GFP_KERNEL);
+               if (entry != NULL) {
+                       list_del(&entry->item);
+                       entry->length = VXGE_HW_BLOCK_SIZE;
+                       entry->memblock = memblock;
+                       entry->dma_addr = dma_addr;
+                       entry->acc_handle = acc_handle;
+                       entry->dma_handle = dma_handle;
+                       list_add(&entry->item,
+                                         &blockpool->free_block_list);
+                       blockpool->pool_size++;
+               } else {
+                       __vxge_hw_blockpool_destroy(blockpool);
+                       status = VXGE_HW_ERR_OUT_OF_MEMORY;
+                       goto blockpool_create_exit;
+               }
+       }
+
+blockpool_create_exit:
+       return status;
+}
+
+/*
+ * __vxge_hw_device_fifo_config_check - Check fifo configuration.
+ * Check the fifo configuration
+ */
+static enum vxge_hw_status
+__vxge_hw_device_fifo_config_check(struct vxge_hw_fifo_config *fifo_config)
+{
+       if ((fifo_config->fifo_blocks < VXGE_HW_MIN_FIFO_BLOCKS) ||
+            (fifo_config->fifo_blocks > VXGE_HW_MAX_FIFO_BLOCKS))
+               return VXGE_HW_BADCFG_FIFO_BLOCKS;
+
+       return VXGE_HW_OK;
+}
+
+/*
+ * __vxge_hw_device_vpath_config_check - Check vpath configuration.
+ * Check the vpath configuration
+ */
+static enum vxge_hw_status
+__vxge_hw_device_vpath_config_check(struct vxge_hw_vp_config *vp_config)
+{
+       enum vxge_hw_status status;
+
+       if ((vp_config->min_bandwidth < VXGE_HW_VPATH_BANDWIDTH_MIN) ||
+               (vp_config->min_bandwidth >
+                                       VXGE_HW_VPATH_BANDWIDTH_MAX))
+               return VXGE_HW_BADCFG_VPATH_MIN_BANDWIDTH;
+
+       status = __vxge_hw_device_fifo_config_check(&vp_config->fifo);
+       if (status != VXGE_HW_OK)
+               return status;
+
+       if ((vp_config->mtu != VXGE_HW_VPATH_USE_FLASH_DEFAULT_INITIAL_MTU) &&
+               ((vp_config->mtu < VXGE_HW_VPATH_MIN_INITIAL_MTU) ||
+               (vp_config->mtu > VXGE_HW_VPATH_MAX_INITIAL_MTU)))
+               return VXGE_HW_BADCFG_VPATH_MTU;
+
+       if ((vp_config->rpa_strip_vlan_tag !=
+               VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_USE_FLASH_DEFAULT) &&
+               (vp_config->rpa_strip_vlan_tag !=
+               VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_ENABLE) &&
+               (vp_config->rpa_strip_vlan_tag !=
+               VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_DISABLE))
+               return VXGE_HW_BADCFG_VPATH_RPA_STRIP_VLAN_TAG;
+
+       return VXGE_HW_OK;
+}
+
+/*
+ * __vxge_hw_device_config_check - Check device configuration.
+ * Check the device configuration
+ */
+static enum vxge_hw_status
+__vxge_hw_device_config_check(struct vxge_hw_device_config *new_config)
+{
+       u32 i;
+       enum vxge_hw_status status;
+
+       if ((new_config->intr_mode != VXGE_HW_INTR_MODE_IRQLINE) &&
+          (new_config->intr_mode != VXGE_HW_INTR_MODE_MSIX) &&
+          (new_config->intr_mode != VXGE_HW_INTR_MODE_MSIX_ONE_SHOT) &&
+          (new_config->intr_mode != VXGE_HW_INTR_MODE_DEF))
+               return VXGE_HW_BADCFG_INTR_MODE;
+
+       if ((new_config->rts_mac_en != VXGE_HW_RTS_MAC_DISABLE) &&
+          (new_config->rts_mac_en != VXGE_HW_RTS_MAC_ENABLE))
+               return VXGE_HW_BADCFG_RTS_MAC_EN;
+
+       for (i = 0; i < VXGE_HW_MAX_VIRTUAL_PATHS; i++) {
+               status = __vxge_hw_device_vpath_config_check(
+                               &new_config->vp_config[i]);
+               if (status != VXGE_HW_OK)
+                       return status;
+       }
+
+       return VXGE_HW_OK;
+}
+
+/*
  * vxge_hw_device_initialize - Initialize Titan device.
  * Initialize Titan device. Note that all the arguments of this public API
  * are 'IN', including @hldev. Driver cooperates with
@@ -1214,6 +1443,243 @@ vxge_hw_device_terminate(struct __vxge_hw_device *hldev)
 }

 /*
+ * __vxge_hw_vpath_stats_access - Get the statistics from the given location
+ *                           and offset and perform an operation
+ */
+static enum vxge_hw_status
+__vxge_hw_vpath_stats_access(struct __vxge_hw_virtualpath *vpath,
+                            u32 operation, u32 offset, u64 *stat)
+{
+       u64 val64;
+       enum vxge_hw_status status = VXGE_HW_OK;
+       struct vxge_hw_vpath_reg __iomem *vp_reg;
+
+       if (vpath->vp_open == VXGE_HW_VP_NOT_OPEN) {
+               status = VXGE_HW_ERR_VPATH_NOT_OPEN;
+               goto vpath_stats_access_exit;
+       }
+
+       vp_reg = vpath->vp_reg;
+
+       val64 =  VXGE_HW_XMAC_STATS_ACCESS_CMD_OP(operation) |
+                VXGE_HW_XMAC_STATS_ACCESS_CMD_STROBE |
+                VXGE_HW_XMAC_STATS_ACCESS_CMD_OFFSET_SEL(offset);
+
+       status = __vxge_hw_pio_mem_write64(val64,
+                               &vp_reg->xmac_stats_access_cmd,
+                               VXGE_HW_XMAC_STATS_ACCESS_CMD_STROBE,
+                               vpath->hldev->config.device_poll_millis);
+
+       if ((status == VXGE_HW_OK) && (operation == VXGE_HW_STATS_OP_READ))
+               *stat = readq(&vp_reg->xmac_stats_access_data);
+       else
+               *stat = 0;
+
+vpath_stats_access_exit:
+       return status;
+}
+
+/*
+ * __vxge_hw_vpath_xmac_tx_stats_get - Get the TX Statistics of a vpath
+ */
+static enum vxge_hw_status
+__vxge_hw_vpath_xmac_tx_stats_get(struct __vxge_hw_virtualpath *vpath,
+                       struct vxge_hw_xmac_vpath_tx_stats *vpath_tx_stats)
+{
+       u64 *val64;
+       int i;
+       u32 offset = VXGE_HW_STATS_VPATH_TX_OFFSET;
+       enum vxge_hw_status status = VXGE_HW_OK;
+
+       val64 = (u64 *) vpath_tx_stats;
+
+       if (vpath->vp_open == VXGE_HW_VP_NOT_OPEN) {
+               status = VXGE_HW_ERR_VPATH_NOT_OPEN;
+               goto exit;
+       }
+
+       for (i = 0; i < sizeof(struct vxge_hw_xmac_vpath_tx_stats) / 8; i++) {
+               status = __vxge_hw_vpath_stats_access(vpath,
+                                       VXGE_HW_STATS_OP_READ,
+                                       offset, val64);
+               if (status != VXGE_HW_OK)
+                       goto exit;
+               offset++;
+               val64++;
+       }
+exit:
+       return status;
+}
+
+/*
+ * __vxge_hw_vpath_xmac_rx_stats_get - Get the RX Statistics of a vpath
+ */
+static enum vxge_hw_status
+__vxge_hw_vpath_xmac_rx_stats_get(struct __vxge_hw_virtualpath *vpath,
+                       struct vxge_hw_xmac_vpath_rx_stats *vpath_rx_stats)
+{
+       u64 *val64;
+       enum vxge_hw_status status = VXGE_HW_OK;
+       int i;
+       u32 offset = VXGE_HW_STATS_VPATH_RX_OFFSET;
+       val64 = (u64 *) vpath_rx_stats;
+
+       if (vpath->vp_open == VXGE_HW_VP_NOT_OPEN) {
+               status = VXGE_HW_ERR_VPATH_NOT_OPEN;
+               goto exit;
+       }
+       for (i = 0; i < sizeof(struct vxge_hw_xmac_vpath_rx_stats) / 8; i++) {
+               status = __vxge_hw_vpath_stats_access(vpath,
+                                       VXGE_HW_STATS_OP_READ,
+                                       offset >> 3, val64);
+               if (status != VXGE_HW_OK)
+                       goto exit;
+
+               offset += 8;
+               val64++;
+       }
+exit:
+       return status;
+}
+
+/*
+ * __vxge_hw_vpath_stats_get - Get the vpath hw statistics.
+ */
+static enum vxge_hw_status
+__vxge_hw_vpath_stats_get(struct __vxge_hw_virtualpath *vpath,
+                         struct vxge_hw_vpath_stats_hw_info *hw_stats)
+{
+       u64 val64;
+       enum vxge_hw_status status = VXGE_HW_OK;
+       struct vxge_hw_vpath_reg __iomem *vp_reg;
+
+       if (vpath->vp_open == VXGE_HW_VP_NOT_OPEN) {
+               status = VXGE_HW_ERR_VPATH_NOT_OPEN;
+               goto exit;
+       }
+       vp_reg = vpath->vp_reg;
+
+       val64 = readq(&vp_reg->vpath_debug_stats0);
+       hw_stats->ini_num_mwr_sent =
+               (u32)VXGE_HW_VPATH_DEBUG_STATS0_GET_INI_NUM_MWR_SENT(val64);
+
+       val64 = readq(&vp_reg->vpath_debug_stats1);
+       hw_stats->ini_num_mrd_sent =
+               (u32)VXGE_HW_VPATH_DEBUG_STATS1_GET_INI_NUM_MRD_SENT(val64);
+
+       val64 = readq(&vp_reg->vpath_debug_stats2);
+       hw_stats->ini_num_cpl_rcvd =
+               (u32)VXGE_HW_VPATH_DEBUG_STATS2_GET_INI_NUM_CPL_RCVD(val64);
+
+       val64 = readq(&vp_reg->vpath_debug_stats3);
+       hw_stats->ini_num_mwr_byte_sent =
+               VXGE_HW_VPATH_DEBUG_STATS3_GET_INI_NUM_MWR_BYTE_SENT(val64);
+
+       val64 = readq(&vp_reg->vpath_debug_stats4);
+       hw_stats->ini_num_cpl_byte_rcvd =
+               VXGE_HW_VPATH_DEBUG_STATS4_GET_INI_NUM_CPL_BYTE_RCVD(val64);
+
+       val64 = readq(&vp_reg->vpath_debug_stats5);
+       hw_stats->wrcrdtarb_xoff =
+               (u32)VXGE_HW_VPATH_DEBUG_STATS5_GET_WRCRDTARB_XOFF(val64);
+
+       val64 = readq(&vp_reg->vpath_debug_stats6);
+       hw_stats->rdcrdtarb_xoff =
+               (u32)VXGE_HW_VPATH_DEBUG_STATS6_GET_RDCRDTARB_XOFF(val64);
+
+       val64 = readq(&vp_reg->vpath_genstats_count01);
+       hw_stats->vpath_genstats_count0 =
+       (u32)VXGE_HW_VPATH_GENSTATS_COUNT01_GET_PPIF_VPATH_GENSTATS_COUNT0(
+               val64);
+
+       val64 = readq(&vp_reg->vpath_genstats_count01);
+       hw_stats->vpath_genstats_count1 =
+       (u32)VXGE_HW_VPATH_GENSTATS_COUNT01_GET_PPIF_VPATH_GENSTATS_COUNT1(
+               val64);
+
+       val64 = readq(&vp_reg->vpath_genstats_count23);
+       hw_stats->vpath_genstats_count2 =
+       (u32)VXGE_HW_VPATH_GENSTATS_COUNT23_GET_PPIF_VPATH_GENSTATS_COUNT2(
+               val64);
+
+       val64 = readq(&vp_reg->vpath_genstats_count01);
+       hw_stats->vpath_genstats_count3 =
+       (u32)VXGE_HW_VPATH_GENSTATS_COUNT23_GET_PPIF_VPATH_GENSTATS_COUNT3(
+               val64);
+
+       val64 = readq(&vp_reg->vpath_genstats_count4);
+       hw_stats->vpath_genstats_count4 =
+       (u32)VXGE_HW_VPATH_GENSTATS_COUNT4_GET_PPIF_VPATH_GENSTATS_COUNT4(
+               val64);
+
+       val64 = readq(&vp_reg->vpath_genstats_count5);
+       hw_stats->vpath_genstats_count5 =
+       (u32)VXGE_HW_VPATH_GENSTATS_COUNT5_GET_PPIF_VPATH_GENSTATS_COUNT5(
+               val64);
+
+       status = __vxge_hw_vpath_xmac_tx_stats_get(vpath, &hw_stats->tx_stats);
+       if (status != VXGE_HW_OK)
+               goto exit;
+
+       status = __vxge_hw_vpath_xmac_rx_stats_get(vpath, &hw_stats->rx_stats);
+       if (status != VXGE_HW_OK)
+               goto exit;
+
+       VXGE_HW_VPATH_STATS_PIO_READ(
+               VXGE_HW_STATS_VPATH_PROG_EVENT_VNUM0_OFFSET);
+
+       hw_stats->prog_event_vnum0 =
+                       (u32)VXGE_HW_STATS_GET_VPATH_PROG_EVENT_VNUM0(val64);
+
+       hw_stats->prog_event_vnum1 =
+                       (u32)VXGE_HW_STATS_GET_VPATH_PROG_EVENT_VNUM1(val64);
+
+       VXGE_HW_VPATH_STATS_PIO_READ(
+               VXGE_HW_STATS_VPATH_PROG_EVENT_VNUM2_OFFSET);
+
+       hw_stats->prog_event_vnum2 =
+                       (u32)VXGE_HW_STATS_GET_VPATH_PROG_EVENT_VNUM2(val64);
+
+       hw_stats->prog_event_vnum3 =
+                       (u32)VXGE_HW_STATS_GET_VPATH_PROG_EVENT_VNUM3(val64);
+
+       val64 = readq(&vp_reg->rx_multi_cast_stats);
+       hw_stats->rx_multi_cast_frame_discard =
+               (u16)VXGE_HW_RX_MULTI_CAST_STATS_GET_FRAME_DISCARD(val64);
+
+       val64 = readq(&vp_reg->rx_frm_transferred);
+       hw_stats->rx_frm_transferred =
+               (u32)VXGE_HW_RX_FRM_TRANSFERRED_GET_RX_FRM_TRANSFERRED(val64);
+
+       val64 = readq(&vp_reg->rxd_returned);
+       hw_stats->rxd_returned =
+               (u16)VXGE_HW_RXD_RETURNED_GET_RXD_RETURNED(val64);
+
+       val64 = readq(&vp_reg->dbg_stats_rx_mpa);
+       hw_stats->rx_mpa_len_fail_frms =
+               (u16)VXGE_HW_DBG_STATS_GET_RX_MPA_LEN_FAIL_FRMS(val64);
+       hw_stats->rx_mpa_mrk_fail_frms =
+               (u16)VXGE_HW_DBG_STATS_GET_RX_MPA_MRK_FAIL_FRMS(val64);
+       hw_stats->rx_mpa_crc_fail_frms =
+               (u16)VXGE_HW_DBG_STATS_GET_RX_MPA_CRC_FAIL_FRMS(val64);
+
+       val64 = readq(&vp_reg->dbg_stats_rx_fau);
+       hw_stats->rx_permitted_frms =
+               (u16)VXGE_HW_DBG_STATS_GET_RX_FAU_RX_PERMITTED_FRMS(val64);
+       hw_stats->rx_vp_reset_discarded_frms =
+       (u16)VXGE_HW_DBG_STATS_GET_RX_FAU_RX_VP_RESET_DISCARDED_FRMS(val64);
+       hw_stats->rx_wol_frms =
+               (u16)VXGE_HW_DBG_STATS_GET_RX_FAU_RX_WOL_FRMS(val64);
+
+       val64 = readq(&vp_reg->tx_vp_reset_discarded_frms);
+       hw_stats->tx_vp_reset_discarded_frms =
+       (u16)VXGE_HW_TX_VP_RESET_DISCARDED_FRMS_GET_TX_VP_RESET_DISCARDED_FRMS(
+               val64);
+exit:
+       return status;
+}
+
+/*
  * vxge_hw_device_stats_get - Get the device hw statistics.
  * Returns the vpath h/w stats for the device.
  */
@@ -1300,7 +1766,7 @@ exit:
  * vxge_hw_device_xmac_aggr_stats_get - Get the Statistics on aggregate port
  * Get the Statistics on aggregate port
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 vxge_hw_device_xmac_aggr_stats_get(struct __vxge_hw_device *hldev, u32 port,
                                   struct vxge_hw_xmac_aggr_stats *aggr_stats)
 {
@@ -1335,7 +1801,7 @@ exit:
  * vxge_hw_device_xmac_port_stats_get - Get the Statistics on a port
  * Get the Statistics on port
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 vxge_hw_device_xmac_port_stats_get(struct __vxge_hw_device *hldev, u32 port,
                                   struct vxge_hw_xmac_port_stats *port_stats)
 {
@@ -1473,20 +1939,7 @@ u32 vxge_hw_device_trace_level_get(struct __vxge_hw_device *hldev)
        return 0;
 #endif
 }
-/*
- * vxge_hw_device_debug_mask_get - Get the debug mask
- * This routine returns the current debug mask set
- */
-u32 vxge_hw_device_debug_mask_get(struct __vxge_hw_device *hldev)
-{
-#if defined(VXGE_DEBUG_TRACE_MASK) || defined(VXGE_DEBUG_ERR_MASK)
-       if (hldev == NULL)
-               return 0;
-       return hldev->debug_module_mask;
-#else
-       return 0;
-#endif
-}
+

 /*
  * vxge_hw_getpause_data -Pause frame frame generation and reception.
@@ -1610,7 +2063,7 @@ __vxge_hw_ring_block_next_pointer_set(u8 *block, dma_addr_t dma_next)
  *             first block
  * Returns the dma address of the first RxD block
  */
-u64 __vxge_hw_ring_first_block_address_get(struct __vxge_hw_ring *ring)
+static u64 __vxge_hw_ring_first_block_address_get(struct __vxge_hw_ring *ring)
 {
        struct vxge_hw_mempool_dma *dma_object;

@@ -1768,196 +2221,368 @@ exit:
 }

 /*
- * __vxge_hw_ring_create - Create a Ring
- * This function creates Ring and initializes it.
+ * __vxge_hw_channel_allocate - Allocate memory for channel
+ * This function allocates required memory for the channel and various arrays
+ * in the channel
  */
-enum vxge_hw_status
-__vxge_hw_ring_create(struct __vxge_hw_vpath_handle *vp,
-                     struct vxge_hw_ring_attr *attr)
+static struct __vxge_hw_channel *
+__vxge_hw_channel_allocate(struct __vxge_hw_vpath_handle *vph,
+                          enum __vxge_hw_channel_type type,
+                          u32 length, u32 per_dtr_space,
+                          void *userdata)
 {
-       enum vxge_hw_status status = VXGE_HW_OK;
-       struct __vxge_hw_ring *ring;
-       u32 ring_length;
-       struct vxge_hw_ring_config *config;
+       struct __vxge_hw_channel *channel;
        struct __vxge_hw_device *hldev;
+       int size = 0;
        u32 vp_id;
-       struct vxge_hw_mempool_cbs ring_mp_callback;

-       if ((vp == NULL) || (attr == NULL)) {
+       hldev = vph->vpath->hldev;
+       vp_id = vph->vpath->vp_id;
+
+       switch (type) {
+       case VXGE_HW_CHANNEL_TYPE_FIFO:
+               size = sizeof(struct __vxge_hw_fifo);
+               break;
+       case VXGE_HW_CHANNEL_TYPE_RING:
+               size = sizeof(struct __vxge_hw_ring);
+               break;
+       default:
+               break;
+       }
+
+       channel = kzalloc(size, GFP_KERNEL);
+       if (channel == NULL)
+               goto exit0;
+       INIT_LIST_HEAD(&channel->item);
+
+       channel->common_reg = hldev->common_reg;
+       channel->first_vp_id = hldev->first_vp_id;
+       channel->type = type;
+       channel->devh = hldev;
+       channel->vph = vph;
+       channel->userdata = userdata;
+       channel->per_dtr_space = per_dtr_space;
+       channel->length = length;
+       channel->vp_id = vp_id;
+
+       channel->work_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL);
+       if (channel->work_arr == NULL)
+               goto exit1;
+
+       channel->free_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL);
+       if (channel->free_arr == NULL)
+               goto exit1;
+       channel->free_ptr = length;
+
+       channel->reserve_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL);
+       if (channel->reserve_arr == NULL)
+               goto exit1;
+       channel->reserve_ptr = length;
+       channel->reserve_top = 0;
+
+       channel->orig_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL);
+       if (channel->orig_arr == NULL)
+               goto exit1;
+
+       return channel;
+exit1:
+       __vxge_hw_channel_free(channel);
+
+exit0:
+       return NULL;
+}
+
+/*
+ * vxge_hw_blockpool_block_add - callback for vxge_os_dma_malloc_async
+ * Adds a block to block pool
+ */
+static void vxge_hw_blockpool_block_add(struct __vxge_hw_device *devh,
+                                       void *block_addr,
+                                       u32 length,
+                                       struct pci_dev *dma_h,
+                                       struct pci_dev *acc_handle)
+{
+       struct __vxge_hw_blockpool *blockpool;
+       struct __vxge_hw_blockpool_entry *entry = NULL;
+       dma_addr_t dma_addr;
+       enum vxge_hw_status status = VXGE_HW_OK;
+       u32 req_out;
+
+       blockpool = &devh->block_pool;
+
+       if (block_addr == NULL) {
+               blockpool->req_out--;
                status = VXGE_HW_FAIL;
                goto exit;
        }

-       hldev = vp->vpath->hldev;
-       vp_id = vp->vpath->vp_id;
+       dma_addr = pci_map_single(devh->pdev, block_addr, length,
+                               PCI_DMA_BIDIRECTIONAL);

-       config = &hldev->config.vp_config[vp_id].ring;
+       if (unlikely(pci_dma_mapping_error(devh->pdev, dma_addr))) {
+               vxge_os_dma_free(devh->pdev, block_addr, &acc_handle);
+               blockpool->req_out--;
+               status = VXGE_HW_FAIL;
+               goto exit;
+       }

-       ring_length = config->ring_blocks *
-                       vxge_hw_ring_rxds_per_block_get(config->buffer_mode);
+       if (!list_empty(&blockpool->free_entry_list))
+               entry = (struct __vxge_hw_blockpool_entry *)
+                       list_first_entry(&blockpool->free_entry_list,
+                               struct __vxge_hw_blockpool_entry,
+                               item);

-       ring = (struct __vxge_hw_ring *)__vxge_hw_channel_allocate(vp,
-                                               VXGE_HW_CHANNEL_TYPE_RING,
-                                               ring_length,
-                                               attr->per_rxd_space,
-                                               attr->userdata);
+       if (entry == NULL)
+               entry = (struct __vxge_hw_blockpool_entry *)
+                       vmalloc(sizeof(struct __vxge_hw_blockpool_entry));
+       else
+               list_del(&entry->item);

-       if (ring == NULL) {
+       if (entry != NULL) {
+               entry->length = length;
+               entry->memblock = block_addr;
+               entry->dma_addr = dma_addr;
+               entry->acc_handle = acc_handle;
+               entry->dma_handle = dma_h;
+               list_add(&entry->item, &blockpool->free_block_list);
+               blockpool->pool_size++;
+               status = VXGE_HW_OK;
+       } else
                status = VXGE_HW_ERR_OUT_OF_MEMORY;
-               goto exit;
-       }

-       vp->vpath->ringh = ring;
-       ring->vp_id = vp_id;
-       ring->vp_reg = vp->vpath->vp_reg;
-       ring->common_reg = hldev->common_reg;
-       ring->stats = &vp->vpath->sw_stats->ring_stats;
-       ring->config = config;
-       ring->callback = attr->callback;
-       ring->rxd_init = attr->rxd_init;
-       ring->rxd_term = attr->rxd_term;
-       ring->buffer_mode = config->buffer_mode;
-       ring->rxds_limit = config->rxds_limit;
+       blockpool->req_out--;

-       ring->rxd_size = vxge_hw_ring_rxd_size_get(config->buffer_mode);
-       ring->rxd_priv_size =
-               sizeof(struct __vxge_hw_ring_rxd_priv) + attr->per_rxd_space;
-       ring->per_rxd_space = attr->per_rxd_space;
+       req_out = blockpool->req_out;
+exit:
+       return;
+}

-       ring->rxd_priv_size =
-               ((ring->rxd_priv_size + VXGE_CACHE_LINE_SIZE - 1) /
-               VXGE_CACHE_LINE_SIZE) * VXGE_CACHE_LINE_SIZE;
+static inline void
+vxge_os_dma_malloc_async(struct pci_dev *pdev, void *devh, unsigned long size)
+{
+       gfp_t flags;
+       void *vaddr;

-       /* how many RxDs can fit into one block. Depends on configured
-        * buffer_mode. */
-       ring->rxds_per_block =
-               vxge_hw_ring_rxds_per_block_get(config->buffer_mode);
+       if (in_interrupt())
+               flags = GFP_ATOMIC | GFP_DMA;
+       else
+               flags = GFP_KERNEL | GFP_DMA;

-       /* calculate actual RxD block private size */
-       ring->rxdblock_priv_size = ring->rxd_priv_size * ring->rxds_per_block;
-       ring_mp_callback.item_func_alloc = __vxge_hw_ring_mempool_item_alloc;
-       ring->mempool = __vxge_hw_mempool_create(hldev,
-                               VXGE_HW_BLOCK_SIZE,
-                               VXGE_HW_BLOCK_SIZE,
-                               ring->rxdblock_priv_size,
-                               ring->config->ring_blocks,
-                               ring->config->ring_blocks,
-                               &ring_mp_callback,
-                               ring);
+       vaddr = kmalloc((size), flags);

-       if (ring->mempool == NULL) {
-               __vxge_hw_ring_delete(vp);
-               return VXGE_HW_ERR_OUT_OF_MEMORY;
-       }
+       vxge_hw_blockpool_block_add(devh, vaddr, size, pdev, pdev);
+}

-       status = __vxge_hw_channel_initialize(&ring->channel);
-       if (status != VXGE_HW_OK) {
-               __vxge_hw_ring_delete(vp);
-               goto exit;
+/*
+ * __vxge_hw_blockpool_blocks_add - Request additional blocks
+ */
+static
+void __vxge_hw_blockpool_blocks_add(struct __vxge_hw_blockpool *blockpool)
+{
+       u32 nreq = 0, i;
+
+       if ((blockpool->pool_size  +  blockpool->req_out) <
+               VXGE_HW_MIN_DMA_BLOCK_POOL_SIZE) {
+               nreq = VXGE_HW_INCR_DMA_BLOCK_POOL_SIZE;
+               blockpool->req_out += nreq;
        }

-       /* Note:
-        * Specifying rxd_init callback means two things:
-        * 1) rxds need to be initialized by driver at channel-open time;
-        * 2) rxds need to be posted at channel-open time
-        *    (that's what the initial_replenish() below does)
-        * Currently we don't have a case when the 1) is done without the 2).
-        */
-       if (ring->rxd_init) {
-               status = vxge_hw_ring_replenish(ring);
-               if (status != VXGE_HW_OK) {
-                       __vxge_hw_ring_delete(vp);
+       for (i = 0; i < nreq; i++)
+               vxge_os_dma_malloc_async(
+                       ((struct __vxge_hw_device *)blockpool->hldev)->pdev,
+                       blockpool->hldev, VXGE_HW_BLOCK_SIZE);
+}
+
+/*
+ * __vxge_hw_blockpool_malloc - Allocate a memory block from pool
+ * Allocates a block of memory of given size, either from block pool
+ * or by calling vxge_os_dma_malloc()
+ */
+static void *__vxge_hw_blockpool_malloc(struct __vxge_hw_device *devh, u32 size,
+                                       struct vxge_hw_mempool_dma *dma_object)
+{
+       struct __vxge_hw_blockpool_entry *entry = NULL;
+       struct __vxge_hw_blockpool  *blockpool;
+       void *memblock = NULL;
+       enum vxge_hw_status status = VXGE_HW_OK;
+
+       blockpool = &devh->block_pool;
+
+       if (size != blockpool->block_size) {
+
+               memblock = vxge_os_dma_malloc(devh->pdev, size,
+                                               &dma_object->handle,
+                                               &dma_object->acc_handle);
+
+               if (memblock == NULL) {
+                       status = VXGE_HW_ERR_OUT_OF_MEMORY;
                        goto exit;
                }
-       }

-       /* initial replenish will increment the counter in its post() routine,
-        * we have to reset it */
-       ring->stats->common_stats.usage_cnt = 0;
+               dma_object->addr = pci_map_single(devh->pdev, memblock, size,
+                                       PCI_DMA_BIDIRECTIONAL);
+
+               if (unlikely(pci_dma_mapping_error(devh->pdev,
+                               dma_object->addr))) {
+                       vxge_os_dma_free(devh->pdev, memblock,
+                               &dma_object->acc_handle);
+                       status = VXGE_HW_ERR_OUT_OF_MEMORY;
+                       goto exit;
+               }
+
+       } else {
+
+               if (!list_empty(&blockpool->free_block_list))
+                       entry = (struct __vxge_hw_blockpool_entry *)
+                               list_first_entry(&blockpool->free_block_list,
+                                       struct __vxge_hw_blockpool_entry,
+                                       item);
+
+               if (entry != NULL) {
+                       list_del(&entry->item);
+                       dma_object->addr = entry->dma_addr;
+                       dma_object->handle = entry->dma_handle;
+                       dma_object->acc_handle = entry->acc_handle;
+                       memblock = entry->memblock;
+
+                       list_add(&entry->item,
+                               &blockpool->free_entry_list);
+                       blockpool->pool_size--;
+               }
+
+               if (memblock != NULL)
+                       __vxge_hw_blockpool_blocks_add(blockpool);
+       }
 exit:
-       return status;
+       return memblock;
 }

 /*
- * __vxge_hw_ring_abort - Returns the RxD
- * This function terminates the RxDs of ring
+ * __vxge_hw_blockpool_blocks_remove - Free additional blocks
  */
-enum vxge_hw_status __vxge_hw_ring_abort(struct __vxge_hw_ring *ring)
+static void
+__vxge_hw_blockpool_blocks_remove(struct __vxge_hw_blockpool *blockpool)
 {
-       void *rxdh;
-       struct __vxge_hw_channel *channel;
-
-       channel = &ring->channel;
+       struct list_head *p, *n;

-       for (;;) {
-               vxge_hw_channel_dtr_try_complete(channel, &rxdh);
+       list_for_each_safe(p, n, &blockpool->free_block_list) {

-               if (rxdh == NULL)
+               if (blockpool->pool_size < blockpool->pool_max)
                        break;

-               vxge_hw_channel_dtr_complete(channel);
+               pci_unmap_single(
+                       ((struct __vxge_hw_device *)blockpool->hldev)->pdev,
+                       ((struct __vxge_hw_blockpool_entry *)p)->dma_addr,
+                       ((struct __vxge_hw_blockpool_entry *)p)->length,
+                       PCI_DMA_BIDIRECTIONAL);

-               if (ring->rxd_term)
-                       ring->rxd_term(rxdh, VXGE_HW_RXD_STATE_POSTED,
-                               channel->userdata);
+               vxge_os_dma_free(
+                       ((struct __vxge_hw_device *)blockpool->hldev)->pdev,
+                       ((struct __vxge_hw_blockpool_entry *)p)->memblock,
+                       &((struct __vxge_hw_blockpool_entry *)p)->acc_handle);

-               vxge_hw_channel_dtr_free(channel, rxdh);
-       }
+               list_del(&((struct __vxge_hw_blockpool_entry *)p)->item);

-       return VXGE_HW_OK;
+               list_add(p, &blockpool->free_entry_list);
+
+               blockpool->pool_size--;
+
+       }
 }

 /*
- * __vxge_hw_ring_reset - Resets the ring
- * This function resets the ring during vpath reset operation
+ * __vxge_hw_blockpool_free - Frees the memory allcoated with
+ *                             __vxge_hw_blockpool_malloc
  */
-enum vxge_hw_status __vxge_hw_ring_reset(struct __vxge_hw_ring *ring)
+static void __vxge_hw_blockpool_free(struct __vxge_hw_device *devh,
+                                    void *memblock, u32 size,
+                                    struct vxge_hw_mempool_dma *dma_object)
 {
+       struct __vxge_hw_blockpool_entry *entry = NULL;
+       struct __vxge_hw_blockpool  *blockpool;
        enum vxge_hw_status status = VXGE_HW_OK;
-       struct __vxge_hw_channel *channel;

-       channel = &ring->channel;
+       blockpool = &devh->block_pool;

-       __vxge_hw_ring_abort(ring);
+       if (size != blockpool->block_size) {
+               pci_unmap_single(devh->pdev, dma_object->addr, size,
+                       PCI_DMA_BIDIRECTIONAL);
+               vxge_os_dma_free(devh->pdev, memblock, &dma_object->acc_handle);
+       } else {

-       status = __vxge_hw_channel_reset(channel);
+               if (!list_empty(&blockpool->free_entry_list))
+                       entry = (struct __vxge_hw_blockpool_entry *)
+                               list_first_entry(&blockpool->free_entry_list,
+                                       struct __vxge_hw_blockpool_entry,
+                                       item);

-       if (status != VXGE_HW_OK)
-               goto exit;
+               if (entry == NULL)
+                       entry = (struct __vxge_hw_blockpool_entry *)
+                               vmalloc(sizeof(
+                                       struct __vxge_hw_blockpool_entry));
+               else
+                       list_del(&entry->item);

-       if (ring->rxd_init) {
-               status = vxge_hw_ring_replenish(ring);
-               if (status != VXGE_HW_OK)
-                       goto exit;
+               if (entry != NULL) {
+                       entry->length = size;
+                       entry->memblock = memblock;
+                       entry->dma_addr = dma_object->addr;
+                       entry->acc_handle = dma_object->acc_handle;
+                       entry->dma_handle = dma_object->handle;
+                       list_add(&entry->item,
+                                       &blockpool->free_block_list);
+                       blockpool->pool_size++;
+                       status = VXGE_HW_OK;
+               } else
+                       status = VXGE_HW_ERR_OUT_OF_MEMORY;
+
+               if (status == VXGE_HW_OK)
+                       __vxge_hw_blockpool_blocks_remove(blockpool);
        }
-exit:
-       return status;
 }

 /*
- * __vxge_hw_ring_delete - Removes the ring
- * This function freeup the memory pool and removes the ring
+ * vxge_hw_mempool_destroy
  */
-enum vxge_hw_status __vxge_hw_ring_delete(struct __vxge_hw_vpath_handle *vp)
+static void __vxge_hw_mempool_destroy(struct vxge_hw_mempool *mempool)
 {
-       struct __vxge_hw_ring *ring = vp->vpath->ringh;
+       u32 i, j;
+       struct __vxge_hw_device *devh = mempool->devh;

-       __vxge_hw_ring_abort(ring);
+       for (i = 0; i < mempool->memblocks_allocated; i++) {
+               struct vxge_hw_mempool_dma *dma_object;

-       if (ring->mempool)
-               __vxge_hw_mempool_destroy(ring->mempool);
+               vxge_assert(mempool->memblocks_arr[i]);
+               vxge_assert(mempool->memblocks_dma_arr + i);

-       vp->vpath->ringh = NULL;
-       __vxge_hw_channel_free(&ring->channel);
+               dma_object = mempool->memblocks_dma_arr + i;

-       return VXGE_HW_OK;
+               for (j = 0; j < mempool->items_per_memblock; j++) {
+                       u32 index = i * mempool->items_per_memblock + j;
+
+                       /* to skip last partially filled(if any) memblock */
+                       if (index >= mempool->items_current)
+                               break;
+               }
+
+               vfree(mempool->memblocks_priv_arr[i]);
+
+               __vxge_hw_blockpool_free(devh, mempool->memblocks_arr[i],
+                               mempool->memblock_size, dma_object);
+       }
+
+       vfree(mempool->items_arr);
+       vfree(mempool->memblocks_dma_arr);
+       vfree(mempool->memblocks_priv_arr);
+       vfree(mempool->memblocks_arr);
+       vfree(mempool);
 }

 /*
  * __vxge_hw_mempool_grow
  * Will resize mempool up to %num_allocate value.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_mempool_grow(struct vxge_hw_mempool *mempool, u32 num_allocate,
                       u32 *num_allocated)
 {
@@ -2046,16 +2671,15 @@ exit:
  * with size enough to hold %items_initial number of items. Memory is
  * DMA-able but client must map/unmap before interoperating with the device.
  */
-struct vxge_hw_mempool*
-__vxge_hw_mempool_create(
-       struct __vxge_hw_device *devh,
-       u32 memblock_size,
-       u32 item_size,
-       u32 items_priv_size,
-       u32 items_initial,
-       u32 items_max,
-       struct vxge_hw_mempool_cbs *mp_callback,
-       void *userdata)
+static struct vxge_hw_mempool *
+__vxge_hw_mempool_create(struct __vxge_hw_device *devh,
+                        u32 memblock_size,
+                        u32 item_size,
+                        u32 items_priv_size,
+                        u32 items_initial,
+                        u32 items_max,
+                        struct vxge_hw_mempool_cbs *mp_callback,
+                        void *userdata)
 {
        enum vxge_hw_status status = VXGE_HW_OK;
        u32 memblocks_to_allocate;
@@ -2161,122 +2785,189 @@ exit:
 }

 /*
- * vxge_hw_mempool_destroy
+ * __vxge_hw_ring_abort - Returns the RxD
+ * This function terminates the RxDs of ring
  */
-void __vxge_hw_mempool_destroy(struct vxge_hw_mempool *mempool)
+static enum vxge_hw_status __vxge_hw_ring_abort(struct __vxge_hw_ring *ring)
 {
-       u32 i, j;
-       struct __vxge_hw_device *devh = mempool->devh;
-
-       for (i = 0; i < mempool->memblocks_allocated; i++) {
-               struct vxge_hw_mempool_dma *dma_object;
+       void *rxdh;
+       struct __vxge_hw_channel *channel;

-               vxge_assert(mempool->memblocks_arr[i]);
-               vxge_assert(mempool->memblocks_dma_arr + i);
+       channel = &ring->channel;

-               dma_object = mempool->memblocks_dma_arr + i;
+       for (;;) {
+               vxge_hw_channel_dtr_try_complete(channel, &rxdh);

-               for (j = 0; j < mempool->items_per_memblock; j++) {
-                       u32 index = i * mempool->items_per_memblock + j;
+               if (rxdh == NULL)
+                       break;

-                       /* to skip last partially filled(if any) memblock */
-                       if (index >= mempool->items_current)
-                               break;
-               }
+               vxge_hw_channel_dtr_complete(channel);

-               vfree(mempool->memblocks_priv_arr[i]);
+               if (ring->rxd_term)
+                       ring->rxd_term(rxdh, VXGE_HW_RXD_STATE_POSTED,
+                               channel->userdata);

-               __vxge_hw_blockpool_free(devh, mempool->memblocks_arr[i],
-                               mempool->memblock_size, dma_object);
+               vxge_hw_channel_dtr_free(channel, rxdh);
        }

-       vfree(mempool->items_arr);
+       return VXGE_HW_OK;
+}

-       vfree(mempool->memblocks_dma_arr);
+/*
+ * __vxge_hw_ring_reset - Resets the ring
+ * This function resets the ring during vpath reset operation
+ */
+static enum vxge_hw_status __vxge_hw_ring_reset(struct __vxge_hw_ring *ring)
+{
+       enum vxge_hw_status status = VXGE_HW_OK;
+       struct __vxge_hw_channel *channel;

-       vfree(mempool->memblocks_priv_arr);
+       channel = &ring->channel;

-       vfree(mempool->memblocks_arr);
+       __vxge_hw_ring_abort(ring);

-       vfree(mempool);
+       status = __vxge_hw_channel_reset(channel);
+
+       if (status != VXGE_HW_OK)
+               goto exit;
+
+       if (ring->rxd_init) {
+               status = vxge_hw_ring_replenish(ring);
+               if (status != VXGE_HW_OK)
+                       goto exit;
+       }
+exit:
+       return status;
 }

 /*
- * __vxge_hw_device_fifo_config_check - Check fifo configuration.
- * Check the fifo configuration
+ * __vxge_hw_ring_delete - Removes the ring
+ * This function freeup the memory pool and removes the ring
  */
-enum vxge_hw_status
-__vxge_hw_device_fifo_config_check(struct vxge_hw_fifo_config *fifo_config)
+static enum vxge_hw_status __vxge_hw_ring_delete(struct __vxge_hw_vpath_handle *vp)
 {
-       if ((fifo_config->fifo_blocks < VXGE_HW_MIN_FIFO_BLOCKS) ||
-            (fifo_config->fifo_blocks > VXGE_HW_MAX_FIFO_BLOCKS))
-               return VXGE_HW_BADCFG_FIFO_BLOCKS;
+       struct __vxge_hw_ring *ring = vp->vpath->ringh;
+
+       __vxge_hw_ring_abort(ring);
+
+       if (ring->mempool)
+               __vxge_hw_mempool_destroy(ring->mempool);
+
+       vp->vpath->ringh = NULL;
+       __vxge_hw_channel_free(&ring->channel);

        return VXGE_HW_OK;
 }

 /*
- * __vxge_hw_device_vpath_config_check - Check vpath configuration.
- * Check the vpath configuration
+ * __vxge_hw_ring_create - Create a Ring
+ * This function creates Ring and initializes it.
  */
-enum vxge_hw_status
-__vxge_hw_device_vpath_config_check(struct vxge_hw_vp_config *vp_config)
+static enum vxge_hw_status
+__vxge_hw_ring_create(struct __vxge_hw_vpath_handle *vp,
+                     struct vxge_hw_ring_attr *attr)
 {
-       enum vxge_hw_status status;
+       enum vxge_hw_status status = VXGE_HW_OK;
+       struct __vxge_hw_ring *ring;
+       u32 ring_length;
+       struct vxge_hw_ring_config *config;
+       struct __vxge_hw_device *hldev;
+       u32 vp_id;
+       struct vxge_hw_mempool_cbs ring_mp_callback;

-       if ((vp_config->min_bandwidth < VXGE_HW_VPATH_BANDWIDTH_MIN) ||
-               (vp_config->min_bandwidth >
-                                       VXGE_HW_VPATH_BANDWIDTH_MAX))
-               return VXGE_HW_BADCFG_VPATH_MIN_BANDWIDTH;
+       if ((vp == NULL) || (attr == NULL)) {
+               status = VXGE_HW_FAIL;
+               goto exit;
+       }

-       status = __vxge_hw_device_fifo_config_check(&vp_config->fifo);
-       if (status != VXGE_HW_OK)
-               return status;
+       hldev = vp->vpath->hldev;
+       vp_id = vp->vpath->vp_id;

-       if ((vp_config->mtu != VXGE_HW_VPATH_USE_FLASH_DEFAULT_INITIAL_MTU) &&
-               ((vp_config->mtu < VXGE_HW_VPATH_MIN_INITIAL_MTU) ||
-               (vp_config->mtu > VXGE_HW_VPATH_MAX_INITIAL_MTU)))
-               return VXGE_HW_BADCFG_VPATH_MTU;
+       config = &hldev->config.vp_config[vp_id].ring;

-       if ((vp_config->rpa_strip_vlan_tag !=
-               VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_USE_FLASH_DEFAULT) &&
-               (vp_config->rpa_strip_vlan_tag !=
-               VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_ENABLE) &&
-               (vp_config->rpa_strip_vlan_tag !=
-               VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_DISABLE))
-               return VXGE_HW_BADCFG_VPATH_RPA_STRIP_VLAN_TAG;
+       ring_length = config->ring_blocks *
+                       vxge_hw_ring_rxds_per_block_get(config->buffer_mode);

-       return VXGE_HW_OK;
-}
+       ring = (struct __vxge_hw_ring *)__vxge_hw_channel_allocate(vp,
+                                               VXGE_HW_CHANNEL_TYPE_RING,
+                                               ring_length,
+                                               attr->per_rxd_space,
+                                               attr->userdata);

-/*
- * __vxge_hw_device_config_check - Check device configuration.
- * Check the device configuration
- */
-enum vxge_hw_status
-__vxge_hw_device_config_check(struct vxge_hw_device_config *new_config)
-{
-       u32 i;
-       enum vxge_hw_status status;
+       if (ring == NULL) {
+               status = VXGE_HW_ERR_OUT_OF_MEMORY;
+               goto exit;
+       }

-       if ((new_config->intr_mode != VXGE_HW_INTR_MODE_IRQLINE) &&
-          (new_config->intr_mode != VXGE_HW_INTR_MODE_MSIX) &&
-          (new_config->intr_mode != VXGE_HW_INTR_MODE_MSIX_ONE_SHOT) &&
-          (new_config->intr_mode != VXGE_HW_INTR_MODE_DEF))
-               return VXGE_HW_BADCFG_INTR_MODE;
+       vp->vpath->ringh = ring;
+       ring->vp_id = vp_id;
+       ring->vp_reg = vp->vpath->vp_reg;
+       ring->common_reg = hldev->common_reg;
+       ring->stats = &vp->vpath->sw_stats->ring_stats;
+       ring->config = config;
+       ring->callback = attr->callback;
+       ring->rxd_init = attr->rxd_init;
+       ring->rxd_term = attr->rxd_term;
+       ring->buffer_mode = config->buffer_mode;
+       ring->rxds_limit = config->rxds_limit;

-       if ((new_config->rts_mac_en != VXGE_HW_RTS_MAC_DISABLE) &&
-          (new_config->rts_mac_en != VXGE_HW_RTS_MAC_ENABLE))
-               return VXGE_HW_BADCFG_RTS_MAC_EN;
+       ring->rxd_size = vxge_hw_ring_rxd_size_get(config->buffer_mode);
+       ring->rxd_priv_size =
+               sizeof(struct __vxge_hw_ring_rxd_priv) + attr->per_rxd_space;
+       ring->per_rxd_space = attr->per_rxd_space;

-       for (i = 0; i < VXGE_HW_MAX_VIRTUAL_PATHS; i++) {
-               status = __vxge_hw_device_vpath_config_check(
-                               &new_config->vp_config[i]);
-               if (status != VXGE_HW_OK)
-                       return status;
+       ring->rxd_priv_size =
+               ((ring->rxd_priv_size + VXGE_CACHE_LINE_SIZE - 1) /
+               VXGE_CACHE_LINE_SIZE) * VXGE_CACHE_LINE_SIZE;
+
+       /* how many RxDs can fit into one block. Depends on configured
+        * buffer_mode. */
+       ring->rxds_per_block =
+               vxge_hw_ring_rxds_per_block_get(config->buffer_mode);
+
+       /* calculate actual RxD block private size */
+       ring->rxdblock_priv_size = ring->rxd_priv_size * ring->rxds_per_block;
+       ring_mp_callback.item_func_alloc = __vxge_hw_ring_mempool_item_alloc;
+       ring->mempool = __vxge_hw_mempool_create(hldev,
+                               VXGE_HW_BLOCK_SIZE,
+                               VXGE_HW_BLOCK_SIZE,
+                               ring->rxdblock_priv_size,
+                               ring->config->ring_blocks,
+                               ring->config->ring_blocks,
+                               &ring_mp_callback,
+                               ring);
+
+       if (ring->mempool == NULL) {
+               __vxge_hw_ring_delete(vp);
+               return VXGE_HW_ERR_OUT_OF_MEMORY;
        }

-       return VXGE_HW_OK;
+       status = __vxge_hw_channel_initialize(&ring->channel);
+       if (status != VXGE_HW_OK) {
+               __vxge_hw_ring_delete(vp);
+               goto exit;
+       }
+
+       /* Note:
+        * Specifying rxd_init callback means two things:
+        * 1) rxds need to be initialized by driver at channel-open time;
+        * 2) rxds need to be posted at channel-open time
+        *    (that's what the initial_replenish() below does)
+        * Currently we don't have a case when the 1) is done without the 2).
+        */
+       if (ring->rxd_init) {
+               status = vxge_hw_ring_replenish(ring);
+               if (status != VXGE_HW_OK) {
+                       __vxge_hw_ring_delete(vp);
+                       goto exit;
+               }
+       }
+
+       /* initial replenish will increment the counter in its post() routine,
+        * we have to reset it */
+       ring->stats->common_stats.usage_cnt = 0;
+exit:
+       return status;
 }

 /*
@@ -2438,65 +3129,10 @@ vxge_hw_device_config_default_get(struct vxge_hw_device_config *device_config)
 }

 /*
- * _hw_legacy_swapper_set - Set the swapper bits for the legacy secion.
- * Set the swapper bits appropriately for the lagacy section.
- */
-enum vxge_hw_status
-__vxge_hw_legacy_swapper_set(struct vxge_hw_legacy_reg __iomem *legacy_reg)
-{
-       u64 val64;
-       enum vxge_hw_status status = VXGE_HW_OK;
-
-       val64 = readq(&legacy_reg->toc_swapper_fb);
-
-       wmb();
-
-       switch (val64) {
-
-       case VXGE_HW_SWAPPER_INITIAL_VALUE:
-               return status;
-
-       case VXGE_HW_SWAPPER_BYTE_SWAPPED_BIT_FLIPPED:
-               writeq(VXGE_HW_SWAPPER_READ_BYTE_SWAP_ENABLE,
-                       &legacy_reg->pifm_rd_swap_en);
-               writeq(VXGE_HW_SWAPPER_READ_BIT_FLAP_ENABLE,
-                       &legacy_reg->pifm_rd_flip_en);
-               writeq(VXGE_HW_SWAPPER_WRITE_BYTE_SWAP_ENABLE,
-                       &legacy_reg->pifm_wr_swap_en);
-               writeq(VXGE_HW_SWAPPER_WRITE_BIT_FLAP_ENABLE,
-                       &legacy_reg->pifm_wr_flip_en);
-               break;
-
-       case VXGE_HW_SWAPPER_BYTE_SWAPPED:
-               writeq(VXGE_HW_SWAPPER_READ_BYTE_SWAP_ENABLE,
-                       &legacy_reg->pifm_rd_swap_en);
-               writeq(VXGE_HW_SWAPPER_WRITE_BYTE_SWAP_ENABLE,
-                       &legacy_reg->pifm_wr_swap_en);
-               break;
-
-       case VXGE_HW_SWAPPER_BIT_FLIPPED:
-               writeq(VXGE_HW_SWAPPER_READ_BIT_FLAP_ENABLE,
-                       &legacy_reg->pifm_rd_flip_en);
-               writeq(VXGE_HW_SWAPPER_WRITE_BIT_FLAP_ENABLE,
-                       &legacy_reg->pifm_wr_flip_en);
-               break;
-       }
-
-       wmb();
-
-       val64 = readq(&legacy_reg->toc_swapper_fb);
-
-       if (val64 != VXGE_HW_SWAPPER_INITIAL_VALUE)
-               status = VXGE_HW_ERR_SWAPPER_CTRL;
-
-       return status;
-}
-
-/*
  * __vxge_hw_vpath_swapper_set - Set the swapper bits for the vpath.
  * Set the swapper bits appropriately for the vpath.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_swapper_set(struct vxge_hw_vpath_reg __iomem *vpath_reg)
 {
 #ifndef __BIG_ENDIAN
@@ -2515,10 +3151,9 @@ __vxge_hw_vpath_swapper_set(struct vxge_hw_vpath_reg __iomem *vpath_reg)
  * __vxge_hw_kdfc_swapper_set - Set the swapper bits for the kdfc.
  * Set the swapper bits appropriately for the vpath.
  */
-enum vxge_hw_status
-__vxge_hw_kdfc_swapper_set(
-       struct vxge_hw_legacy_reg __iomem *legacy_reg,
-       struct vxge_hw_vpath_reg __iomem *vpath_reg)
+static enum vxge_hw_status
+__vxge_hw_kdfc_swapper_set(struct vxge_hw_legacy_reg __iomem *legacy_reg,
+                          struct vxge_hw_vpath_reg __iomem *vpath_reg)
 {
        u64 val64;

@@ -2540,28 +3175,6 @@ __vxge_hw_kdfc_swapper_set(
 }

 /*
- * vxge_hw_mgmt_device_config - Retrieve device configuration.
- * Get device configuration. Permits to retrieve at run-time configuration
- * values that were used to initialize and configure the device.
- */
-enum vxge_hw_status
-vxge_hw_mgmt_device_config(struct __vxge_hw_device *hldev,
-                          struct vxge_hw_device_config *dev_config, int size)
-{
-
-       if ((hldev == NULL) || (hldev->magic != VXGE_HW_DEVICE_MAGIC))
-               return VXGE_HW_ERR_INVALID_DEVICE;
-
-       if (size != sizeof(struct vxge_hw_device_config))
-               return VXGE_HW_ERR_VERSION_CONFLICT;
-
-       memcpy(dev_config, &hldev->config,
-               sizeof(struct vxge_hw_device_config));
-
-       return VXGE_HW_OK;
-}
-
-/*
  * vxge_hw_mgmt_reg_read - Read Titan register.
  */
 enum vxge_hw_status
@@ -2790,6 +3403,69 @@ exit:
 }

 /*
+ * __vxge_hw_fifo_abort - Returns the TxD
+ * This function terminates the TxDs of fifo
+ */
+static enum vxge_hw_status __vxge_hw_fifo_abort(struct __vxge_hw_fifo *fifo)
+{
+       void *txdlh;
+
+       for (;;) {
+               vxge_hw_channel_dtr_try_complete(&fifo->channel, &txdlh);
+
+               if (txdlh == NULL)
+                       break;
+
+               vxge_hw_channel_dtr_complete(&fifo->channel);
+
+               if (fifo->txdl_term) {
+                       fifo->txdl_term(txdlh,
+                       VXGE_HW_TXDL_STATE_POSTED,
+                       fifo->channel.userdata);
+               }
+
+               vxge_hw_channel_dtr_free(&fifo->channel, txdlh);
+       }
+
+       return VXGE_HW_OK;
+}
+
+/*
+ * __vxge_hw_fifo_reset - Resets the fifo
+ * This function resets the fifo during vpath reset operation
+ */
+static enum vxge_hw_status __vxge_hw_fifo_reset(struct __vxge_hw_fifo *fifo)
+{
+       enum vxge_hw_status status = VXGE_HW_OK;
+
+       __vxge_hw_fifo_abort(fifo);
+       status = __vxge_hw_channel_reset(&fifo->channel);
+
+       return status;
+}
+
+/*
+ * __vxge_hw_fifo_delete - Removes the FIFO
+ * This function freeup the memory pool and removes the FIFO
+ */
+static enum vxge_hw_status
+__vxge_hw_fifo_delete(struct __vxge_hw_vpath_handle *vp)
+{
+       struct __vxge_hw_fifo *fifo = vp->vpath->fifoh;
+
+       __vxge_hw_fifo_abort(fifo);
+
+       if (fifo->mempool)
+               __vxge_hw_mempool_destroy(fifo->mempool);
+
+       vp->vpath->fifoh = NULL;
+
+       __vxge_hw_channel_free(&fifo->channel);
+
+       return VXGE_HW_OK;
+}
+
+/*
  * __vxge_hw_fifo_mempool_item_alloc - Allocate List blocks for TxD
  * list callback
  * This function is callback passed to __vxge_hw_mempool_create to create memory
@@ -2835,7 +3511,7 @@ __vxge_hw_fifo_mempool_item_alloc(
  * __vxge_hw_fifo_create - Create a FIFO
  * This function creates FIFO and initializes it.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
                      struct vxge_hw_fifo_attr *attr)
 {
@@ -2954,73 +3630,11 @@ exit:
 }

 /*
- * __vxge_hw_fifo_abort - Returns the TxD
- * This function terminates the TxDs of fifo
- */
-enum vxge_hw_status __vxge_hw_fifo_abort(struct __vxge_hw_fifo *fifo)
-{
-       void *txdlh;
-
-       for (;;) {
-               vxge_hw_channel_dtr_try_complete(&fifo->channel, &txdlh);
-
-               if (txdlh == NULL)
-                       break;
-
-               vxge_hw_channel_dtr_complete(&fifo->channel);
-
-               if (fifo->txdl_term) {
-                       fifo->txdl_term(txdlh,
-                       VXGE_HW_TXDL_STATE_POSTED,
-                       fifo->channel.userdata);
-               }
-
-               vxge_hw_channel_dtr_free(&fifo->channel, txdlh);
-       }
-
-       return VXGE_HW_OK;
-}
-
-/*
- * __vxge_hw_fifo_reset - Resets the fifo
- * This function resets the fifo during vpath reset operation
- */
-enum vxge_hw_status __vxge_hw_fifo_reset(struct __vxge_hw_fifo *fifo)
-{
-       enum vxge_hw_status status = VXGE_HW_OK;
-
-       __vxge_hw_fifo_abort(fifo);
-       status = __vxge_hw_channel_reset(&fifo->channel);
-
-       return status;
-}
-
-/*
- * __vxge_hw_fifo_delete - Removes the FIFO
- * This function freeup the memory pool and removes the FIFO
- */
-enum vxge_hw_status __vxge_hw_fifo_delete(struct __vxge_hw_vpath_handle *vp)
-{
-       struct __vxge_hw_fifo *fifo = vp->vpath->fifoh;
-
-       __vxge_hw_fifo_abort(fifo);
-
-       if (fifo->mempool)
-               __vxge_hw_mempool_destroy(fifo->mempool);
-
-       vp->vpath->fifoh = NULL;
-
-       __vxge_hw_channel_free(&fifo->channel);
-
-       return VXGE_HW_OK;
-}
-
-/*
  * __vxge_hw_vpath_pci_read - Read the content of given address
  *                          in pci config space.
  * Read from the vpath pci config space.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_pci_read(struct __vxge_hw_virtualpath *vpath,
                         u32 phy_func_0, u32 offset, u32 *val)
 {
@@ -3459,7 +4073,7 @@ __vxge_hw_vpath_mgmt_read(
  * This routine checks the vpath_rst_in_prog register to see if
  * adapter completed the reset process for the vpath
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_reset_check(struct __vxge_hw_virtualpath *vpath)
 {
        enum vxge_hw_status status;
@@ -3477,7 +4091,7 @@ __vxge_hw_vpath_reset_check(struct __vxge_hw_virtualpath *vpath)
  * __vxge_hw_vpath_reset
  * This routine resets the vpath on the device
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_reset(struct __vxge_hw_device *hldev, u32 vp_id)
 {
        u64 val64;
@@ -3495,7 +4109,7 @@ __vxge_hw_vpath_reset(struct __vxge_hw_device *hldev, u32 vp_id)
  * __vxge_hw_vpath_sw_reset
  * This routine resets the vpath structures
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_sw_reset(struct __vxge_hw_device *hldev, u32 vp_id)
 {
        enum vxge_hw_status status = VXGE_HW_OK;
@@ -3520,7 +4134,7 @@ exit:
  * This routine configures the prc registers of virtual path using the config
  * passed
  */
-void
+static void
 __vxge_hw_vpath_prc_configure(struct __vxge_hw_device *hldev, u32 vp_id)
 {
        u64 val64;
@@ -3592,7 +4206,7 @@ __vxge_hw_vpath_prc_configure(struct __vxge_hw_device *hldev, u32 vp_id)
  * This routine configures the kdfc registers of virtual path using the
  * config passed
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_kdfc_configure(struct __vxge_hw_device *hldev, u32 vp_id)
 {
        u64 val64;
@@ -3665,7 +4279,7 @@ exit:
  * __vxge_hw_vpath_mac_configure
  * This routine configures the mac of virtual path using the config passed
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_mac_configure(struct __vxge_hw_device *hldev, u32 vp_id)
 {
        u64 val64;
@@ -3733,7 +4347,7 @@ __vxge_hw_vpath_mac_configure(struct __vxge_hw_device *hldev, u32 vp_id)
  * This routine configures the tim registers of virtual path using the config
  * passed
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_tim_configure(struct __vxge_hw_device *hldev, u32 vp_id)
 {
        u64 val64;
@@ -4009,7 +4623,7 @@ vxge_hw_vpath_tti_ci_set(struct __vxge_hw_device *hldev, u32 vp_id)
  * This routine is the final phase of init which initializes the
  * registers of the vpath using the configuration passed.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vpath_initialize(struct __vxge_hw_device *hldev, u32 vp_id)
 {
        u64 val64;
@@ -4074,11 +4688,33 @@ exit:
 }

 /*
+ * __vxge_hw_vp_terminate - Terminate Virtual Path structure
+ * This routine closes all channels it opened and freeup memory
+ */
+static void __vxge_hw_vp_terminate(struct __vxge_hw_device *hldev, u32 vp_id)
+{
+       struct __vxge_hw_virtualpath *vpath;
+
+       vpath = &hldev->virtual_paths[vp_id];
+
+       if (vpath->vp_open == VXGE_HW_VP_NOT_OPEN)
+               goto exit;
+
+       VXGE_HW_DEVICE_TIM_INT_MASK_RESET(vpath->hldev->tim_int_mask0,
+               vpath->hldev->tim_int_mask1, vpath->vp_id);
+       hldev->stats.hw_dev_info_stats.vpath_info[vpath->vp_id] = NULL;
+
+       memset(vpath, 0, sizeof(struct __vxge_hw_virtualpath));
+exit:
+       return;
+}
+
+/*
  * __vxge_hw_vp_initialize - Initialize Virtual Path structure
  * This routine is the initial phase of init which resets the vpath and
  * initializes the software support structures.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 __vxge_hw_vp_initialize(struct __vxge_hw_device *hldev, u32 vp_id,
                        struct vxge_hw_vp_config *config)
 {
@@ -4129,29 +4765,6 @@ exit:
 }

 /*
- * __vxge_hw_vp_terminate - Terminate Virtual Path structure
- * This routine closes all channels it opened and freeup memory
- */
-void
-__vxge_hw_vp_terminate(struct __vxge_hw_device *hldev, u32 vp_id)
-{
-       struct __vxge_hw_virtualpath *vpath;
-
-       vpath = &hldev->virtual_paths[vp_id];
-
-       if (vpath->vp_open == VXGE_HW_VP_NOT_OPEN)
-               goto exit;
-
-       VXGE_HW_DEVICE_TIM_INT_MASK_RESET(vpath->hldev->tim_int_mask0,
-               vpath->hldev->tim_int_mask1, vpath->vp_id);
-       hldev->stats.hw_dev_info_stats.vpath_info[vpath->vp_id] = NULL;
-
-       memset(vpath, 0, sizeof(struct __vxge_hw_virtualpath));
-exit:
-       return;
-}
-
-/*
  * vxge_hw_vpath_mtu_set - Set MTU.
  * Set new MTU value. Example, to use jumbo frames:
  * vxge_hw_vpath_mtu_set(my_device, 9600);
@@ -4188,6 +4801,64 @@ exit:
 }

 /*
+ * vxge_hw_vpath_stats_enable - Enable vpath h/wstatistics.
+ * Enable the DMA vpath statistics. The function is to be called to re-enable
+ * the adapter to update stats into the host memory
+ */
+static enum vxge_hw_status
+vxge_hw_vpath_stats_enable(struct __vxge_hw_vpath_handle *vp)
+{
+       enum vxge_hw_status status = VXGE_HW_OK;
+       struct __vxge_hw_virtualpath *vpath;
+
+       vpath = vp->vpath;
+
+       if (vpath->vp_open == VXGE_HW_VP_NOT_OPEN) {
+               status = VXGE_HW_ERR_VPATH_NOT_OPEN;
+               goto exit;
+       }
+
+       memcpy(vpath->hw_stats_sav, vpath->hw_stats,
+                       sizeof(struct vxge_hw_vpath_stats_hw_info));
+
+       status = __vxge_hw_vpath_stats_get(vpath, vpath->hw_stats);
+exit:
+       return status;
+}
+
+/*
+ * __vxge_hw_blockpool_block_allocate - Allocates a block from block pool
+ * This function allocates a block from block pool or from the system
+ */
+static struct __vxge_hw_blockpool_entry *
+__vxge_hw_blockpool_block_allocate(struct __vxge_hw_device *devh, u32 size)
+{
+       struct __vxge_hw_blockpool_entry *entry = NULL;
+       struct __vxge_hw_blockpool  *blockpool;
+
+       blockpool = &devh->block_pool;
+
+       if (size == blockpool->block_size) {
+
+               if (!list_empty(&blockpool->free_block_list))
+                       entry = (struct __vxge_hw_blockpool_entry *)
+                               list_first_entry(&blockpool->free_block_list,
+                                       struct __vxge_hw_blockpool_entry,
+                                       item);
+
+               if (entry != NULL) {
+                       list_del(&entry->item);
+                       blockpool->pool_size--;
+               }
+       }
+
+       if (entry != NULL)
+               __vxge_hw_blockpool_blocks_add(blockpool);
+
+       return entry;
+}
+
+/*
  * vxge_hw_vpath_open - Open a virtual path on a given adapter
  * This function is used to open access to virtual path of an
  * adapter for offload, GRO operations. This function returns
@@ -4342,6 +5013,29 @@ vxge_hw_vpath_rx_doorbell_init(struct __vxge_hw_vpath_handle *vp)
 }

 /*
+ * __vxge_hw_blockpool_block_free - Frees a block from block pool
+ * @devh: Hal device
+ * @entry: Entry of block to be freed
+ *
+ * This function frees a block from block pool
+ */
+static void
+__vxge_hw_blockpool_block_free(struct __vxge_hw_device *devh,
+                              struct __vxge_hw_blockpool_entry *entry)
+{
+       struct __vxge_hw_blockpool  *blockpool;
+
+       blockpool = &devh->block_pool;
+
+       if (entry->length == blockpool->block_size) {
+               list_add(&entry->item, &blockpool->free_block_list);
+               blockpool->pool_size++;
+       }
+
+       __vxge_hw_blockpool_blocks_remove(blockpool);
+}
+
+/*
  * vxge_hw_vpath_close - Close the handle got from previous vpath (vpath) open
  * This function is used to close access to virtual path opened
  * earlier.
@@ -4492,705 +5186,3 @@ vxge_hw_vpath_enable(struct __vxge_hw_vpath_handle *vp)
        __vxge_hw_pio_mem_write32_upper((u32)vxge_bVALn(val64, 0, 32),
                &hldev->common_reg->cmn_rsthdlr_cfg1);
 }
-
-/*
- * vxge_hw_vpath_stats_enable - Enable vpath h/wstatistics.
- * Enable the DMA vpath statistics. The function is to be called to re-enable
- * the adapter to update stats into the host memory
- */
-enum vxge_hw_status
-vxge_hw_vpath_stats_enable(struct __vxge_hw_vpath_handle *vp)
-{
-       enum vxge_hw_status status = VXGE_HW_OK;
-       struct __vxge_hw_virtualpath *vpath;
-
-       vpath = vp->vpath;
-
-       if (vpath->vp_open == VXGE_HW_VP_NOT_OPEN) {
-               status = VXGE_HW_ERR_VPATH_NOT_OPEN;
-               goto exit;
-       }
-
-       memcpy(vpath->hw_stats_sav, vpath->hw_stats,
-                       sizeof(struct vxge_hw_vpath_stats_hw_info));
-
-       status = __vxge_hw_vpath_stats_get(vpath, vpath->hw_stats);
-exit:
-       return status;
-}
-
-/*
- * __vxge_hw_vpath_stats_access - Get the statistics from the given location
- *                           and offset and perform an operation
- */
-enum vxge_hw_status
-__vxge_hw_vpath_stats_access(struct __vxge_hw_virtualpath *vpath,
-                            u32 operation, u32 offset, u64 *stat)
-{
-       u64 val64;
-       enum vxge_hw_status status = VXGE_HW_OK;
-       struct vxge_hw_vpath_reg __iomem *vp_reg;
-
-       if (vpath->vp_open == VXGE_HW_VP_NOT_OPEN) {
-               status = VXGE_HW_ERR_VPATH_NOT_OPEN;
-               goto vpath_stats_access_exit;
-       }
-
-       vp_reg = vpath->vp_reg;
-
-       val64 =  VXGE_HW_XMAC_STATS_ACCESS_CMD_OP(operation) |
-                VXGE_HW_XMAC_STATS_ACCESS_CMD_STROBE |
-                VXGE_HW_XMAC_STATS_ACCESS_CMD_OFFSET_SEL(offset);
-
-       status = __vxge_hw_pio_mem_write64(val64,
-                               &vp_reg->xmac_stats_access_cmd,
-                               VXGE_HW_XMAC_STATS_ACCESS_CMD_STROBE,
-                               vpath->hldev->config.device_poll_millis);
-
-       if ((status == VXGE_HW_OK) && (operation == VXGE_HW_STATS_OP_READ))
-               *stat = readq(&vp_reg->xmac_stats_access_data);
-       else
-               *stat = 0;
-
-vpath_stats_access_exit:
-       return status;
-}
-
-/*
- * __vxge_hw_vpath_xmac_tx_stats_get - Get the TX Statistics of a vpath
- */
-enum vxge_hw_status
-__vxge_hw_vpath_xmac_tx_stats_get(
-       struct __vxge_hw_virtualpath *vpath,
-       struct vxge_hw_xmac_vpath_tx_stats *vpath_tx_stats)
-{
-       u64 *val64;
-       int i;
-       u32 offset = VXGE_HW_STATS_VPATH_TX_OFFSET;
-       enum vxge_hw_status status = VXGE_HW_OK;
-
-       val64 = (u64 *) vpath_tx_stats;
-
-       if (vpath->vp_open == VXGE_HW_VP_NOT_OPEN) {
-               status = VXGE_HW_ERR_VPATH_NOT_OPEN;
-               goto exit;
-       }
-
-       for (i = 0; i < sizeof(struct vxge_hw_xmac_vpath_tx_stats) / 8; i++) {
-               status = __vxge_hw_vpath_stats_access(vpath,
-                                       VXGE_HW_STATS_OP_READ,
-                                       offset, val64);
-               if (status != VXGE_HW_OK)
-                       goto exit;
-               offset++;
-               val64++;
-       }
-exit:
-       return status;
-}
-
-/*
- * __vxge_hw_vpath_xmac_rx_stats_get - Get the RX Statistics of a vpath
- */
-enum vxge_hw_status
-__vxge_hw_vpath_xmac_rx_stats_get(struct __vxge_hw_virtualpath *vpath,
-                       struct vxge_hw_xmac_vpath_rx_stats *vpath_rx_stats)
-{
-       u64 *val64;
-       enum vxge_hw_status status = VXGE_HW_OK;
-       int i;
-       u32 offset = VXGE_HW_STATS_VPATH_RX_OFFSET;
-       val64 = (u64 *) vpath_rx_stats;
-
-       if (vpath->vp_open == VXGE_HW_VP_NOT_OPEN) {
-               status = VXGE_HW_ERR_VPATH_NOT_OPEN;
-               goto exit;
-       }
-       for (i = 0; i < sizeof(struct vxge_hw_xmac_vpath_rx_stats) / 8; i++) {
-               status = __vxge_hw_vpath_stats_access(vpath,
-                                       VXGE_HW_STATS_OP_READ,
-                                       offset >> 3, val64);
-               if (status != VXGE_HW_OK)
-                       goto exit;
-
-               offset += 8;
-               val64++;
-       }
-exit:
-       return status;
-}
-
-/*
- * __vxge_hw_vpath_stats_get - Get the vpath hw statistics.
- */
-enum vxge_hw_status __vxge_hw_vpath_stats_get(
-                       struct __vxge_hw_virtualpath *vpath,
-                       struct vxge_hw_vpath_stats_hw_info *hw_stats)
-{
-       u64 val64;
-       enum vxge_hw_status status = VXGE_HW_OK;
-       struct vxge_hw_vpath_reg __iomem *vp_reg;
-
-       if (vpath->vp_open == VXGE_HW_VP_NOT_OPEN) {
-               status = VXGE_HW_ERR_VPATH_NOT_OPEN;
-               goto exit;
-       }
-       vp_reg = vpath->vp_reg;
-
-       val64 = readq(&vp_reg->vpath_debug_stats0);
-       hw_stats->ini_num_mwr_sent =
-               (u32)VXGE_HW_VPATH_DEBUG_STATS0_GET_INI_NUM_MWR_SENT(val64);
-
-       val64 = readq(&vp_reg->vpath_debug_stats1);
-       hw_stats->ini_num_mrd_sent =
-               (u32)VXGE_HW_VPATH_DEBUG_STATS1_GET_INI_NUM_MRD_SENT(val64);
-
-       val64 = readq(&vp_reg->vpath_debug_stats2);
-       hw_stats->ini_num_cpl_rcvd =
-               (u32)VXGE_HW_VPATH_DEBUG_STATS2_GET_INI_NUM_CPL_RCVD(val64);
-
-       val64 = readq(&vp_reg->vpath_debug_stats3);
-       hw_stats->ini_num_mwr_byte_sent =
-               VXGE_HW_VPATH_DEBUG_STATS3_GET_INI_NUM_MWR_BYTE_SENT(val64);
-
-       val64 = readq(&vp_reg->vpath_debug_stats4);
-       hw_stats->ini_num_cpl_byte_rcvd =
-               VXGE_HW_VPATH_DEBUG_STATS4_GET_INI_NUM_CPL_BYTE_RCVD(val64);
-
-       val64 = readq(&vp_reg->vpath_debug_stats5);
-       hw_stats->wrcrdtarb_xoff =
-               (u32)VXGE_HW_VPATH_DEBUG_STATS5_GET_WRCRDTARB_XOFF(val64);
-
-       val64 = readq(&vp_reg->vpath_debug_stats6);
-       hw_stats->rdcrdtarb_xoff =
-               (u32)VXGE_HW_VPATH_DEBUG_STATS6_GET_RDCRDTARB_XOFF(val64);
-
-       val64 = readq(&vp_reg->vpath_genstats_count01);
-       hw_stats->vpath_genstats_count0 =
-       (u32)VXGE_HW_VPATH_GENSTATS_COUNT01_GET_PPIF_VPATH_GENSTATS_COUNT0(
-               val64);
-
-       val64 = readq(&vp_reg->vpath_genstats_count01);
-       hw_stats->vpath_genstats_count1 =
-       (u32)VXGE_HW_VPATH_GENSTATS_COUNT01_GET_PPIF_VPATH_GENSTATS_COUNT1(
-               val64);
-
-       val64 = readq(&vp_reg->vpath_genstats_count23);
-       hw_stats->vpath_genstats_count2 =
-       (u32)VXGE_HW_VPATH_GENSTATS_COUNT23_GET_PPIF_VPATH_GENSTATS_COUNT2(
-               val64);
-
-       val64 = readq(&vp_reg->vpath_genstats_count01);
-       hw_stats->vpath_genstats_count3 =
-       (u32)VXGE_HW_VPATH_GENSTATS_COUNT23_GET_PPIF_VPATH_GENSTATS_COUNT3(
-               val64);
-
-       val64 = readq(&vp_reg->vpath_genstats_count4);
-       hw_stats->vpath_genstats_count4 =
-       (u32)VXGE_HW_VPATH_GENSTATS_COUNT4_GET_PPIF_VPATH_GENSTATS_COUNT4(
-               val64);
-
-       val64 = readq(&vp_reg->vpath_genstats_count5);
-       hw_stats->vpath_genstats_count5 =
-       (u32)VXGE_HW_VPATH_GENSTATS_COUNT5_GET_PPIF_VPATH_GENSTATS_COUNT5(
-               val64);
-
-       status = __vxge_hw_vpath_xmac_tx_stats_get(vpath, &hw_stats->tx_stats);
-       if (status != VXGE_HW_OK)
-               goto exit;
-
-       status = __vxge_hw_vpath_xmac_rx_stats_get(vpath, &hw_stats->rx_stats);
-       if (status != VXGE_HW_OK)
-               goto exit;
-
-       VXGE_HW_VPATH_STATS_PIO_READ(
-               VXGE_HW_STATS_VPATH_PROG_EVENT_VNUM0_OFFSET);
-
-       hw_stats->prog_event_vnum0 =
-                       (u32)VXGE_HW_STATS_GET_VPATH_PROG_EVENT_VNUM0(val64);
-
-       hw_stats->prog_event_vnum1 =
-                       (u32)VXGE_HW_STATS_GET_VPATH_PROG_EVENT_VNUM1(val64);
-
-       VXGE_HW_VPATH_STATS_PIO_READ(
-               VXGE_HW_STATS_VPATH_PROG_EVENT_VNUM2_OFFSET);
-
-       hw_stats->prog_event_vnum2 =
-                       (u32)VXGE_HW_STATS_GET_VPATH_PROG_EVENT_VNUM2(val64);
-
-       hw_stats->prog_event_vnum3 =
-                       (u32)VXGE_HW_STATS_GET_VPATH_PROG_EVENT_VNUM3(val64);
-
-       val64 = readq(&vp_reg->rx_multi_cast_stats);
-       hw_stats->rx_multi_cast_frame_discard =
-               (u16)VXGE_HW_RX_MULTI_CAST_STATS_GET_FRAME_DISCARD(val64);
-
-       val64 = readq(&vp_reg->rx_frm_transferred);
-       hw_stats->rx_frm_transferred =
-               (u32)VXGE_HW_RX_FRM_TRANSFERRED_GET_RX_FRM_TRANSFERRED(val64);
-
-       val64 = readq(&vp_reg->rxd_returned);
-       hw_stats->rxd_returned =
-               (u16)VXGE_HW_RXD_RETURNED_GET_RXD_RETURNED(val64);
-
-       val64 = readq(&vp_reg->dbg_stats_rx_mpa);
-       hw_stats->rx_mpa_len_fail_frms =
-               (u16)VXGE_HW_DBG_STATS_GET_RX_MPA_LEN_FAIL_FRMS(val64);
-       hw_stats->rx_mpa_mrk_fail_frms =
-               (u16)VXGE_HW_DBG_STATS_GET_RX_MPA_MRK_FAIL_FRMS(val64);
-       hw_stats->rx_mpa_crc_fail_frms =
-               (u16)VXGE_HW_DBG_STATS_GET_RX_MPA_CRC_FAIL_FRMS(val64);
-
-       val64 = readq(&vp_reg->dbg_stats_rx_fau);
-       hw_stats->rx_permitted_frms =
-               (u16)VXGE_HW_DBG_STATS_GET_RX_FAU_RX_PERMITTED_FRMS(val64);
-       hw_stats->rx_vp_reset_discarded_frms =
-       (u16)VXGE_HW_DBG_STATS_GET_RX_FAU_RX_VP_RESET_DISCARDED_FRMS(val64);
-       hw_stats->rx_wol_frms =
-               (u16)VXGE_HW_DBG_STATS_GET_RX_FAU_RX_WOL_FRMS(val64);
-
-       val64 = readq(&vp_reg->tx_vp_reset_discarded_frms);
-       hw_stats->tx_vp_reset_discarded_frms =
-       (u16)VXGE_HW_TX_VP_RESET_DISCARDED_FRMS_GET_TX_VP_RESET_DISCARDED_FRMS(
-               val64);
-exit:
-       return status;
-}
-
-/*
- * __vxge_hw_blockpool_create - Create block pool
- */
-
-enum vxge_hw_status
-__vxge_hw_blockpool_create(struct __vxge_hw_device *hldev,
-                          struct __vxge_hw_blockpool *blockpool,
-                          u32 pool_size,
-                          u32 pool_max)
-{
-       u32 i;
-       struct __vxge_hw_blockpool_entry *entry = NULL;
-       void *memblock;
-       dma_addr_t dma_addr;
-       struct pci_dev *dma_handle;
-       struct pci_dev *acc_handle;
-       enum vxge_hw_status status = VXGE_HW_OK;
-
-       if (blockpool == NULL) {
-               status = VXGE_HW_FAIL;
-               goto blockpool_create_exit;
-       }
-
-       blockpool->hldev = hldev;
-       blockpool->block_size = VXGE_HW_BLOCK_SIZE;
-       blockpool->pool_size = 0;
-       blockpool->pool_max = pool_max;
-       blockpool->req_out = 0;
-
-       INIT_LIST_HEAD(&blockpool->free_block_list);
-       INIT_LIST_HEAD(&blockpool->free_entry_list);
-
-       for (i = 0; i < pool_size + pool_max; i++) {
-               entry = kzalloc(sizeof(struct __vxge_hw_blockpool_entry),
-                               GFP_KERNEL);
-               if (entry == NULL) {
-                       __vxge_hw_blockpool_destroy(blockpool);
-                       status = VXGE_HW_ERR_OUT_OF_MEMORY;
-                       goto blockpool_create_exit;
-               }
-               list_add(&entry->item, &blockpool->free_entry_list);
-       }
-
-       for (i = 0; i < pool_size; i++) {
-
-               memblock = vxge_os_dma_malloc(
-                               hldev->pdev,
-                               VXGE_HW_BLOCK_SIZE,
-                               &dma_handle,
-                               &acc_handle);
-
-               if (memblock == NULL) {
-                       __vxge_hw_blockpool_destroy(blockpool);
-                       status = VXGE_HW_ERR_OUT_OF_MEMORY;
-                       goto blockpool_create_exit;
-               }
-
-               dma_addr = pci_map_single(hldev->pdev, memblock,
-                               VXGE_HW_BLOCK_SIZE, PCI_DMA_BIDIRECTIONAL);
-
-               if (unlikely(pci_dma_mapping_error(hldev->pdev,
-                               dma_addr))) {
-
-                       vxge_os_dma_free(hldev->pdev, memblock, &acc_handle);
-                       __vxge_hw_blockpool_destroy(blockpool);
-                       status = VXGE_HW_ERR_OUT_OF_MEMORY;
-                       goto blockpool_create_exit;
-               }
-
-               if (!list_empty(&blockpool->free_entry_list))
-                       entry = (struct __vxge_hw_blockpool_entry *)
-                               list_first_entry(&blockpool->free_entry_list,
-                                       struct __vxge_hw_blockpool_entry,
-                                       item);
-
-               if (entry == NULL)
-                       entry =
-                           kzalloc(sizeof(struct __vxge_hw_blockpool_entry),
-                                       GFP_KERNEL);
-               if (entry != NULL) {
-                       list_del(&entry->item);
-                       entry->length = VXGE_HW_BLOCK_SIZE;
-                       entry->memblock = memblock;
-                       entry->dma_addr = dma_addr;
-                       entry->acc_handle = acc_handle;
-                       entry->dma_handle = dma_handle;
-                       list_add(&entry->item,
-                                         &blockpool->free_block_list);
-                       blockpool->pool_size++;
-               } else {
-                       __vxge_hw_blockpool_destroy(blockpool);
-                       status = VXGE_HW_ERR_OUT_OF_MEMORY;
-                       goto blockpool_create_exit;
-               }
-       }
-
-blockpool_create_exit:
-       return status;
-}
-
-/*
- * __vxge_hw_blockpool_destroy - Deallocates the block pool
- */
-
-void __vxge_hw_blockpool_destroy(struct __vxge_hw_blockpool *blockpool)
-{
-
-       struct __vxge_hw_device *hldev;
-       struct list_head *p, *n;
-       u16 ret;
-
-       if (blockpool == NULL) {
-               ret = 1;
-               goto exit;
-       }
-
-       hldev = blockpool->hldev;
-
-       list_for_each_safe(p, n, &blockpool->free_block_list) {
-
-               pci_unmap_single(hldev->pdev,
-                       ((struct __vxge_hw_blockpool_entry *)p)->dma_addr,
-                       ((struct __vxge_hw_blockpool_entry *)p)->length,
-                       PCI_DMA_BIDIRECTIONAL);
-
-               vxge_os_dma_free(hldev->pdev,
-                       ((struct __vxge_hw_blockpool_entry *)p)->memblock,
-                       &((struct __vxge_hw_blockpool_entry *) p)->acc_handle);
-
-               list_del(
-                       &((struct __vxge_hw_blockpool_entry *)p)->item);
-               kfree(p);
-               blockpool->pool_size--;
-       }
-
-       list_for_each_safe(p, n, &blockpool->free_entry_list) {
-               list_del(
-                       &((struct __vxge_hw_blockpool_entry *)p)->item);
-               kfree((void *)p);
-       }
-       ret = 0;
-exit:
-       return;
-}
-
-/*
- * __vxge_hw_blockpool_blocks_add - Request additional blocks
- */
-static
-void __vxge_hw_blockpool_blocks_add(struct __vxge_hw_blockpool *blockpool)
-{
-       u32 nreq = 0, i;
-
-       if ((blockpool->pool_size  +  blockpool->req_out) <
-               VXGE_HW_MIN_DMA_BLOCK_POOL_SIZE) {
-               nreq = VXGE_HW_INCR_DMA_BLOCK_POOL_SIZE;
-               blockpool->req_out += nreq;
-       }
-
-       for (i = 0; i < nreq; i++)
-               vxge_os_dma_malloc_async(
-                       ((struct __vxge_hw_device *)blockpool->hldev)->pdev,
-                       blockpool->hldev, VXGE_HW_BLOCK_SIZE);
-}
-
-/*
- * __vxge_hw_blockpool_blocks_remove - Free additional blocks
- */
-static
-void __vxge_hw_blockpool_blocks_remove(struct __vxge_hw_blockpool *blockpool)
-{
-       struct list_head *p, *n;
-
-       list_for_each_safe(p, n, &blockpool->free_block_list) {
-
-               if (blockpool->pool_size < blockpool->pool_max)
-                       break;
-
-               pci_unmap_single(
-                       ((struct __vxge_hw_device *)blockpool->hldev)->pdev,
-                       ((struct __vxge_hw_blockpool_entry *)p)->dma_addr,
-                       ((struct __vxge_hw_blockpool_entry *)p)->length,
-                       PCI_DMA_BIDIRECTIONAL);
-
-               vxge_os_dma_free(
-                       ((struct __vxge_hw_device *)blockpool->hldev)->pdev,
-                       ((struct __vxge_hw_blockpool_entry *)p)->memblock,
-                       &((struct __vxge_hw_blockpool_entry *)p)->acc_handle);
-
-               list_del(&((struct __vxge_hw_blockpool_entry *)p)->item);
-
-               list_add(p, &blockpool->free_entry_list);
-
-               blockpool->pool_size--;
-
-       }
-}
-
-/*
- * vxge_hw_blockpool_block_add - callback for vxge_os_dma_malloc_async
- * Adds a block to block pool
- */
-void vxge_hw_blockpool_block_add(
-                       struct __vxge_hw_device *devh,
-                       void *block_addr,
-                       u32 length,
-                       struct pci_dev *dma_h,
-                       struct pci_dev *acc_handle)
-{
-       struct __vxge_hw_blockpool  *blockpool;
-       struct __vxge_hw_blockpool_entry  *entry = NULL;
-       dma_addr_t dma_addr;
-       enum vxge_hw_status status = VXGE_HW_OK;
-       u32 req_out;
-
-       blockpool = &devh->block_pool;
-
-       if (block_addr == NULL) {
-               blockpool->req_out--;
-               status = VXGE_HW_FAIL;
-               goto exit;
-       }
-
-       dma_addr = pci_map_single(devh->pdev, block_addr, length,
-                               PCI_DMA_BIDIRECTIONAL);
-
-       if (unlikely(pci_dma_mapping_error(devh->pdev, dma_addr))) {
-
-               vxge_os_dma_free(devh->pdev, block_addr, &acc_handle);
-               blockpool->req_out--;
-               status = VXGE_HW_FAIL;
-               goto exit;
-       }
-
-
-       if (!list_empty(&blockpool->free_entry_list))
-               entry = (struct __vxge_hw_blockpool_entry *)
-                       list_first_entry(&blockpool->free_entry_list,
-                               struct __vxge_hw_blockpool_entry,
-                               item);
-
-       if (entry == NULL)
-               entry = (struct __vxge_hw_blockpool_entry *)
-                       vmalloc(sizeof(struct __vxge_hw_blockpool_entry));
-       else
-               list_del(&entry->item);
-
-       if (entry != NULL) {
-               entry->length = length;
-               entry->memblock = block_addr;
-               entry->dma_addr = dma_addr;
-               entry->acc_handle = acc_handle;
-               entry->dma_handle = dma_h;
-               list_add(&entry->item, &blockpool->free_block_list);
-               blockpool->pool_size++;
-               status = VXGE_HW_OK;
-       } else
-               status = VXGE_HW_ERR_OUT_OF_MEMORY;
-
-       blockpool->req_out--;
-
-       req_out = blockpool->req_out;
-exit:
-       return;
-}
-
-/*
- * __vxge_hw_blockpool_malloc - Allocate a memory block from pool
- * Allocates a block of memory of given size, either from block pool
- * or by calling vxge_os_dma_malloc()
- */
-void *
-__vxge_hw_blockpool_malloc(struct __vxge_hw_device *devh, u32 size,
-                               struct vxge_hw_mempool_dma *dma_object)
-{
-       struct __vxge_hw_blockpool_entry *entry = NULL;
-       struct __vxge_hw_blockpool  *blockpool;
-       void *memblock = NULL;
-       enum vxge_hw_status status = VXGE_HW_OK;
-
-       blockpool = &devh->block_pool;
-
-       if (size != blockpool->block_size) {
-
-               memblock = vxge_os_dma_malloc(devh->pdev, size,
-                                               &dma_object->handle,
-                                               &dma_object->acc_handle);
-
-               if (memblock == NULL) {
-                       status = VXGE_HW_ERR_OUT_OF_MEMORY;
-                       goto exit;
-               }
-
-               dma_object->addr = pci_map_single(devh->pdev, memblock, size,
-                                       PCI_DMA_BIDIRECTIONAL);
-
-               if (unlikely(pci_dma_mapping_error(devh->pdev,
-                               dma_object->addr))) {
-                       vxge_os_dma_free(devh->pdev, memblock,
-                               &dma_object->acc_handle);
-                       status = VXGE_HW_ERR_OUT_OF_MEMORY;
-                       goto exit;
-               }
-
-       } else {
-
-               if (!list_empty(&blockpool->free_block_list))
-                       entry = (struct __vxge_hw_blockpool_entry *)
-                               list_first_entry(&blockpool->free_block_list,
-                                       struct __vxge_hw_blockpool_entry,
-                                       item);
-
-               if (entry != NULL) {
-                       list_del(&entry->item);
-                       dma_object->addr = entry->dma_addr;
-                       dma_object->handle = entry->dma_handle;
-                       dma_object->acc_handle = entry->acc_handle;
-                       memblock = entry->memblock;
-
-                       list_add(&entry->item,
-                               &blockpool->free_entry_list);
-                       blockpool->pool_size--;
-               }
-
-               if (memblock != NULL)
-                       __vxge_hw_blockpool_blocks_add(blockpool);
-       }
-exit:
-       return memblock;
-}
-
-/*
- * __vxge_hw_blockpool_free - Frees the memory allcoated with
-                               __vxge_hw_blockpool_malloc
- */
-void
-__vxge_hw_blockpool_free(struct __vxge_hw_device *devh,
-                       void *memblock, u32 size,
-                       struct vxge_hw_mempool_dma *dma_object)
-{
-       struct __vxge_hw_blockpool_entry *entry = NULL;
-       struct __vxge_hw_blockpool  *blockpool;
-       enum vxge_hw_status status = VXGE_HW_OK;
-
-       blockpool = &devh->block_pool;
-
-       if (size != blockpool->block_size) {
-               pci_unmap_single(devh->pdev, dma_object->addr, size,
-                       PCI_DMA_BIDIRECTIONAL);
-               vxge_os_dma_free(devh->pdev, memblock, &dma_object->acc_handle);
-       } else {
-
-               if (!list_empty(&blockpool->free_entry_list))
-                       entry = (struct __vxge_hw_blockpool_entry *)
-                               list_first_entry(&blockpool->free_entry_list,
-                                       struct __vxge_hw_blockpool_entry,
-                                       item);
-
-               if (entry == NULL)
-                       entry = (struct __vxge_hw_blockpool_entry *)
-                               vmalloc(sizeof(
-                                       struct __vxge_hw_blockpool_entry));
-               else
-                       list_del(&entry->item);
-
-               if (entry != NULL) {
-                       entry->length = size;
-                       entry->memblock = memblock;
-                       entry->dma_addr = dma_object->addr;
-                       entry->acc_handle = dma_object->acc_handle;
-                       entry->dma_handle = dma_object->handle;
-                       list_add(&entry->item,
-                                       &blockpool->free_block_list);
-                       blockpool->pool_size++;
-                       status = VXGE_HW_OK;
-               } else
-                       status = VXGE_HW_ERR_OUT_OF_MEMORY;
-
-               if (status == VXGE_HW_OK)
-                       __vxge_hw_blockpool_blocks_remove(blockpool);
-       }
-}
-
-/*
- * __vxge_hw_blockpool_block_allocate - Allocates a block from block pool
- * This function allocates a block from block pool or from the system
- */
-struct __vxge_hw_blockpool_entry *
-__vxge_hw_blockpool_block_allocate(struct __vxge_hw_device *devh, u32 size)
-{
-       struct __vxge_hw_blockpool_entry *entry = NULL;
-       struct __vxge_hw_blockpool  *blockpool;
-
-       blockpool = &devh->block_pool;
-
-       if (size == blockpool->block_size) {
-
-               if (!list_empty(&blockpool->free_block_list))
-                       entry = (struct __vxge_hw_blockpool_entry *)
-                               list_first_entry(&blockpool->free_block_list,
-                                       struct __vxge_hw_blockpool_entry,
-                                       item);
-
-               if (entry != NULL) {
-                       list_del(&entry->item);
-                       blockpool->pool_size--;
-               }
-       }
-
-       if (entry != NULL)
-               __vxge_hw_blockpool_blocks_add(blockpool);
-
-       return entry;
-}
-
-/*
- * __vxge_hw_blockpool_block_free - Frees a block from block pool
- * @devh: Hal device
- * @entry: Entry of block to be freed
- *
- * This function frees a block from block pool
- */
-void
-__vxge_hw_blockpool_block_free(struct __vxge_hw_device *devh,
-                       struct __vxge_hw_blockpool_entry *entry)
-{
-       struct __vxge_hw_blockpool  *blockpool;
-
-       blockpool = &devh->block_pool;
-
-       if (entry->length == blockpool->block_size) {
-               list_add(&entry->item, &blockpool->free_block_list);
-               blockpool->pool_size++;
-       }
-
-       __vxge_hw_blockpool_blocks_remove(blockpool);
-}
diff --git a/drivers/net/vxge/vxge-config.h b/drivers/net/vxge/vxge-config.h
index 252969c..94c809c 100644
--- a/drivers/net/vxge/vxge-config.h
+++ b/drivers/net/vxge/vxge-config.h
@@ -868,15 +868,6 @@ struct vxge_hw_device_attr {
                return status;                                          \
 }

-#define VXGE_HW_VPATH_STATS_PIO_READ(offset) {                         \
-       status = __vxge_hw_vpath_stats_access(vpath, \
-                       VXGE_HW_STATS_OP_READ, \
-                       offset, \
-                       &val64);                                        \
-       if (status != VXGE_HW_OK)                                       \
-               return status;                                          \
-}
-
 /*
  * struct __vxge_hw_ring - Ring channel.
  * @channel: Channel "base" of this ring, the common part of all HW
@@ -1455,9 +1446,6 @@ struct vxge_hw_rth_hash_types {
           hash_type_ipv6ex_en:1;
 };

-u32
-vxge_hw_device_debug_mask_get(struct __vxge_hw_device *devh);
-
 void vxge_hw_device_debug_set(
        struct __vxge_hw_device *devh,
        enum vxge_debug_level level,
@@ -1469,9 +1457,6 @@ vxge_hw_device_error_level_get(struct __vxge_hw_device *devh);
 u32
 vxge_hw_device_trace_level_get(struct __vxge_hw_device *devh);

-u32
-vxge_hw_device_debug_mask_get(struct __vxge_hw_device *devh);
-
 /**
  * vxge_hw_ring_rxd_size_get   - Get the size of ring descriptor.
  * @buf_mode: Buffer mode (1, 3 or 5)
@@ -1846,44 +1831,6 @@ struct vxge_hw_vpath_attr {
        struct vxge_hw_fifo_attr        fifo_attr;
 };

-enum vxge_hw_status
-__vxge_hw_blockpool_create(struct __vxge_hw_device *hldev,
-                       struct __vxge_hw_blockpool  *blockpool,
-                       u32 pool_size,
-                       u32 pool_max);
-
-void
-__vxge_hw_blockpool_destroy(struct __vxge_hw_blockpool  *blockpool);
-
-struct __vxge_hw_blockpool_entry *
-__vxge_hw_blockpool_block_allocate(struct __vxge_hw_device *hldev,
-                       u32 size);
-
-void
-__vxge_hw_blockpool_block_free(struct __vxge_hw_device *hldev,
-                       struct __vxge_hw_blockpool_entry *entry);
-
-void *
-__vxge_hw_blockpool_malloc(struct __vxge_hw_device *hldev,
-                       u32 size,
-                       struct vxge_hw_mempool_dma *dma_object);
-
-void
-__vxge_hw_blockpool_free(struct __vxge_hw_device *hldev,
-                       void *memblock,
-                       u32 size,
-                       struct vxge_hw_mempool_dma *dma_object);
-
-enum vxge_hw_status
-__vxge_hw_device_fifo_config_check(struct vxge_hw_fifo_config *fifo_config);
-
-enum vxge_hw_status
-__vxge_hw_device_config_check(struct vxge_hw_device_config *new_config);
-
-enum vxge_hw_status
-vxge_hw_mgmt_device_config(struct __vxge_hw_device *devh,
-               struct vxge_hw_device_config    *dev_config, int size);
-
 enum vxge_hw_status __devinit vxge_hw_device_hw_info_get(
        void __iomem *bar0,
        struct vxge_hw_device_hw_info *hw_info);
@@ -1971,29 +1918,6 @@ out:
        return vaddr;
 }

-extern void vxge_hw_blockpool_block_add(
-                       struct __vxge_hw_device *devh,
-                       void *block_addr,
-                       u32 length,
-                       struct pci_dev *dma_h,
-                       struct pci_dev *acc_handle);
-
-static inline void vxge_os_dma_malloc_async(struct pci_dev *pdev, void *devh,
-                                       unsigned long size)
-{
-       gfp_t flags;
-       void *vaddr;
-
-       if (in_interrupt())
-               flags = GFP_ATOMIC | GFP_DMA;
-       else
-               flags = GFP_KERNEL | GFP_DMA;
-
-       vaddr = kmalloc((size), flags);
-
-       vxge_hw_blockpool_block_add(devh, vaddr, size, pdev, pdev);
-}
-
 static inline void vxge_os_dma_free(struct pci_dev *pdev, const void *vaddr,
                        struct pci_dev **p_dma_acch)
 {
@@ -2027,40 +1951,6 @@ __vxge_hw_mempool_item_priv(
                            (*memblock_item_idx) * mempool->items_priv_size;
 }

-enum vxge_hw_status
-__vxge_hw_mempool_grow(
-       struct vxge_hw_mempool *mempool,
-       u32 num_allocate,
-       u32 *num_allocated);
-
-struct vxge_hw_mempool*
-__vxge_hw_mempool_create(
-       struct __vxge_hw_device *devh,
-       u32 memblock_size,
-       u32 item_size,
-       u32 private_size,
-       u32 items_initial,
-       u32 items_max,
-       struct vxge_hw_mempool_cbs *mp_callback,
-       void *userdata);
-
-struct __vxge_hw_channel*
-__vxge_hw_channel_allocate(struct __vxge_hw_vpath_handle *vph,
-                       enum __vxge_hw_channel_type type, u32 length,
-                       u32 per_dtr_space, void *userdata);
-
-void
-__vxge_hw_channel_free(
-       struct __vxge_hw_channel *channel);
-
-enum vxge_hw_status
-__vxge_hw_channel_initialize(
-       struct __vxge_hw_channel *channel);
-
-enum vxge_hw_status
-__vxge_hw_channel_reset(
-       struct __vxge_hw_channel *channel);
-
 /*
  * __vxge_hw_fifo_txdl_priv - Return the max fragments allocated
  * for the fifo.
@@ -2082,9 +1972,6 @@ enum vxge_hw_status vxge_hw_vpath_open(
        struct vxge_hw_vpath_attr *attr,
        struct __vxge_hw_vpath_handle **vpath_handle);

-enum vxge_hw_status
-__vxge_hw_device_vpath_reset_in_prog_check(u64 __iomem *vpath_rst_in_prog);
-
 enum vxge_hw_status vxge_hw_vpath_close(
        struct __vxge_hw_vpath_handle *vpath_handle);

@@ -2106,55 +1993,9 @@ enum vxge_hw_status vxge_hw_vpath_mtu_set(
        struct __vxge_hw_vpath_handle *vpath_handle,
        u32 new_mtu);

-enum vxge_hw_status vxge_hw_vpath_stats_enable(
-       struct __vxge_hw_vpath_handle *vpath_handle);
-
-enum vxge_hw_status
-__vxge_hw_vpath_stats_access(
-       struct __vxge_hw_virtualpath    *vpath,
-       u32                     operation,
-       u32                     offset,
-       u64                     *stat);
-
-enum vxge_hw_status
-__vxge_hw_vpath_xmac_tx_stats_get(
-       struct __vxge_hw_virtualpath    *vpath,
-       struct vxge_hw_xmac_vpath_tx_stats *vpath_tx_stats);
-
-enum vxge_hw_status
-__vxge_hw_vpath_xmac_rx_stats_get(
-       struct __vxge_hw_virtualpath    *vpath,
-       struct vxge_hw_xmac_vpath_rx_stats *vpath_rx_stats);
-
-enum vxge_hw_status
-__vxge_hw_vpath_stats_get(
-       struct __vxge_hw_virtualpath *vpath,
-       struct vxge_hw_vpath_stats_hw_info *hw_stats);
-
 void
 vxge_hw_vpath_rx_doorbell_init(struct __vxge_hw_vpath_handle *vp);

-enum vxge_hw_status
-__vxge_hw_device_vpath_config_check(struct vxge_hw_vp_config *vp_config);
-
-void
-__vxge_hw_device_pci_e_init(struct __vxge_hw_device *hldev);
-
-enum vxge_hw_status
-__vxge_hw_legacy_swapper_set(struct vxge_hw_legacy_reg __iomem *legacy_reg);
-
-enum vxge_hw_status
-__vxge_hw_vpath_swapper_set(struct vxge_hw_vpath_reg __iomem *vpath_reg);
-
-enum vxge_hw_status
-__vxge_hw_kdfc_swapper_set(struct vxge_hw_legacy_reg __iomem *legacy_reg,
-       struct vxge_hw_vpath_reg __iomem *vpath_reg);
-
-enum vxge_hw_status
-__vxge_hw_device_register_poll(
-       void __iomem    *reg,
-       u64 mask, u32 max_millis);
-
 #ifndef readq
 static inline u64 readq(void __iomem *addr)
 {
@@ -2185,44 +2026,10 @@ static inline void __vxge_hw_pio_mem_write32_lower(u32 val, void __iomem *addr)
        writel(val, addr);
 }

-static inline enum vxge_hw_status
-__vxge_hw_pio_mem_write64(u64 val64, void __iomem *addr,
-                         u64 mask, u32 max_millis)
-{
-       enum vxge_hw_status status = VXGE_HW_OK;
-
-       __vxge_hw_pio_mem_write32_lower((u32)vxge_bVALn(val64, 32, 32), addr);
-       wmb();
-       __vxge_hw_pio_mem_write32_upper((u32)vxge_bVALn(val64, 0, 32), addr);
-       wmb();
-
-       status = __vxge_hw_device_register_poll(addr, mask, max_millis);
-       return status;
-}
-
-struct vxge_hw_toc_reg __iomem *
-__vxge_hw_device_toc_get(void __iomem *bar0);
-
-enum vxge_hw_status
-__vxge_hw_device_reg_addr_get(struct __vxge_hw_device *hldev);
-
 enum vxge_hw_status
 vxge_hw_device_flick_link_led(struct __vxge_hw_device *devh, u64 on_off);

 enum vxge_hw_status
-__vxge_hw_device_initialize(struct __vxge_hw_device *hldev);
-
-enum vxge_hw_status
-__vxge_hw_vpath_pci_read(
-       struct __vxge_hw_virtualpath    *vpath,
-       u32                     phy_func_0,
-       u32                     offset,
-       u32                     *val);
-
-enum vxge_hw_status
-__vxge_hw_vpath_reset_check(struct __vxge_hw_virtualpath *vpath);
-
-enum vxge_hw_status
 vxge_hw_vpath_strip_fcs_check(struct __vxge_hw_device *hldev, u64 vpath_mask);

 /**
diff --git a/drivers/net/vxge/vxge-ethtool.c b/drivers/net/vxge/vxge-ethtool.c
index c5ab375..7e026e9 100644
--- a/drivers/net/vxge/vxge-ethtool.c
+++ b/drivers/net/vxge/vxge-ethtool.c
@@ -1193,7 +1193,7 @@ static const struct ethtool_ops vxge_ethtool_ops = {
        .flash_device           = vxge_fw_flash,
 };

-void initialize_ethtool_ops(struct net_device *ndev)
+void vxge_initialize_ethtool_ops(struct net_device *ndev)
 {
        SET_ETHTOOL_OPS(ndev, &vxge_ethtool_ops);
 }
diff --git a/drivers/net/vxge/vxge-main.c b/drivers/net/vxge/vxge-main.c
index c014b26..47bb914 100644
--- a/drivers/net/vxge/vxge-main.c
+++ b/drivers/net/vxge/vxge-main.c
@@ -140,8 +140,7 @@ static inline void VXGE_COMPLETE_ALL_RX(struct vxgedev *vdev)
  * This function is called during interrupt context to notify link up state
  * change.
  */
-void
-vxge_callback_link_up(struct __vxge_hw_device *hldev)
+static void vxge_callback_link_up(struct __vxge_hw_device *hldev)
 {
        struct net_device *dev = hldev->ndev;
        struct vxgedev *vdev = (struct vxgedev *)netdev_priv(dev);
@@ -164,8 +163,7 @@ vxge_callback_link_up(struct __vxge_hw_device *hldev)
  * This function is called during interrupt context to notify link down state
  * change.
  */
-void
-vxge_callback_link_down(struct __vxge_hw_device *hldev)
+static void vxge_callback_link_down(struct __vxge_hw_device *hldev)
 {
        struct net_device *dev = hldev->ndev;
        struct vxgedev *vdev = (struct vxgedev *)netdev_priv(dev);
@@ -356,7 +354,7 @@ static inline void vxge_post(int *dtr_cnt, void **first_dtr,
  * If the interrupt is because of a received frame or if the receive ring
  * contains fresh as yet un-processed frames, this function is called.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 vxge_rx_1b_compl(struct __vxge_hw_ring *ringh, void *dtr,
                 u8 t_code, void *userdata)
 {
@@ -550,7 +548,7 @@ vxge_rx_1b_compl(struct __vxge_hw_ring *ringh, void *dtr,
  * freed and frees all skbs whose data have already DMA'ed into the NICs
  * internal memory.
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 vxge_xmit_compl(struct __vxge_hw_fifo *fifo_hw, void *dtr,
                enum vxge_hw_fifo_tcode t_code, void *userdata,
                struct sk_buff ***skb_ptr, int nr_skb, int *more)
@@ -669,6 +667,65 @@ static enum vxge_hw_status vxge_search_mac_addr_in_list(
        return FALSE;
 }

+static int vxge_mac_list_add(struct vxge_vpath *vpath, struct macInfo *mac)
+{
+       struct vxge_mac_addrs *new_mac_entry;
+       u8 *mac_address = NULL;
+
+       if (vpath->mac_addr_cnt >= VXGE_MAX_LEARN_MAC_ADDR_CNT)
+               return TRUE;
+
+       new_mac_entry = kzalloc(sizeof(struct vxge_mac_addrs), GFP_ATOMIC);
+       if (!new_mac_entry) {
+               vxge_debug_mem(VXGE_ERR,
+                       "%s: memory allocation failed",
+                       VXGE_DRIVER_NAME);
+               return FALSE;
+       }
+
+       list_add(&new_mac_entry->item, &vpath->mac_addr_list);
+
+       /* Copy the new mac address to the list */
+       mac_address = (u8 *)&new_mac_entry->macaddr;
+       memcpy(mac_address, mac->macaddr, ETH_ALEN);
+
+       new_mac_entry->state = mac->state;
+       vpath->mac_addr_cnt++;
+
+       /* Is this a multicast address */
+       if (0x01 & mac->macaddr[0])
+               vpath->mcast_addr_cnt++;
+
+       return TRUE;
+}
+
+/* Add a mac address to DA table */
+static enum vxge_hw_status
+vxge_add_mac_addr(struct vxgedev *vdev, struct macInfo *mac)
+{
+       enum vxge_hw_status status = VXGE_HW_OK;
+       struct vxge_vpath *vpath;
+       enum vxge_hw_vpath_mac_addr_add_mode duplicate_mode;
+
+       if (0x01 & mac->macaddr[0]) /* multicast address */
+               duplicate_mode = VXGE_HW_VPATH_MAC_ADDR_ADD_DUPLICATE;
+       else
+               duplicate_mode = VXGE_HW_VPATH_MAC_ADDR_REPLACE_DUPLICATE;
+
+       vpath = &vdev->vpaths[mac->vpath_no];
+       status = vxge_hw_vpath_mac_addr_add(vpath->handle, mac->macaddr,
+                                               mac->macmask, duplicate_mode);
+       if (status != VXGE_HW_OK) {
+               vxge_debug_init(VXGE_ERR,
+                       "DA config add entry failed for vpath:%d",
+                       vpath->device_id);
+       } else
+               if (FALSE == vxge_mac_list_add(vpath, mac))
+                       status = -EPERM;
+
+       return status;
+}
+
 static int vxge_learn_mac(struct vxgedev *vdev, u8 *mac_header)
 {
        struct macInfo mac_info;
@@ -1014,6 +1071,50 @@ vxge_tx_term(void *dtrh, enum vxge_hw_txdl_state state, void *userdata)
                "%s:%d  Exiting...", __func__, __LINE__);
 }

+static int vxge_mac_list_del(struct vxge_vpath *vpath, struct macInfo *mac)
+{
+       struct list_head *entry, *next;
+       u64 del_mac = 0;
+       u8 *mac_address = (u8 *) (&del_mac);
+
+       /* Copy the mac address to delete from the list */
+       memcpy(mac_address, mac->macaddr, ETH_ALEN);
+
+       list_for_each_safe(entry, next, &vpath->mac_addr_list) {
+               if (((struct vxge_mac_addrs *)entry)->macaddr == del_mac) {
+                       list_del(entry);
+                       kfree((struct vxge_mac_addrs *)entry);
+                       vpath->mac_addr_cnt--;
+
+                       /* Is this a multicast address */
+                       if (0x01 & mac->macaddr[0])
+                               vpath->mcast_addr_cnt--;
+                       return TRUE;
+               }
+       }
+
+       return FALSE;
+}
+
+/* delete a mac address from DA table */
+static enum vxge_hw_status
+vxge_del_mac_addr(struct vxgedev *vdev, struct macInfo *mac)
+{
+       enum vxge_hw_status status = VXGE_HW_OK;
+       struct vxge_vpath *vpath;
+
+       vpath = &vdev->vpaths[mac->vpath_no];
+       status = vxge_hw_vpath_mac_addr_delete(vpath->handle, mac->macaddr,
+                                               mac->macmask);
+       if (status != VXGE_HW_OK) {
+               vxge_debug_init(VXGE_ERR,
+                       "DA config delete entry failed for vpath:%d",
+                       vpath->device_id);
+       } else
+               vxge_mac_list_del(vpath, mac);
+       return status;
+}
+
 /**
  * vxge_set_multicast
  * @dev: pointer to the device structure
@@ -1265,7 +1366,7 @@ static int vxge_set_mac_addr(struct net_device *dev, void *p)
  *
  * Enables the interrupts for the vpath
 */
-void vxge_vpath_intr_enable(struct vxgedev *vdev, int vp_id)
+static void vxge_vpath_intr_enable(struct vxgedev *vdev, int vp_id)
 {
        struct vxge_vpath *vpath = &vdev->vpaths[vp_id];
        int msix_id = 0;
@@ -1298,7 +1399,7 @@ void vxge_vpath_intr_enable(struct vxgedev *vdev, int vp_id)
  *
  * Disables the interrupts for the vpath
 */
-void vxge_vpath_intr_disable(struct vxgedev *vdev, int vp_id)
+static void vxge_vpath_intr_disable(struct vxgedev *vdev, int vp_id)
 {
        struct vxge_vpath *vpath = &vdev->vpaths[vp_id];
        struct __vxge_hw_device *hldev;
@@ -1324,6 +1425,97 @@ void vxge_vpath_intr_disable(struct vxgedev *vdev, int vp_id)
        }
 }

+/* list all mac addresses from DA table */
+static enum vxge_hw_status
+vxge_search_mac_addr_in_da_table(struct vxge_vpath *vpath, struct macInfo *mac)
+{
+       enum vxge_hw_status status = VXGE_HW_OK;
+       unsigned char macmask[ETH_ALEN];
+       unsigned char macaddr[ETH_ALEN];
+
+       status = vxge_hw_vpath_mac_addr_get(vpath->handle,
+                               macaddr, macmask);
+       if (status != VXGE_HW_OK) {
+               vxge_debug_init(VXGE_ERR,
+                       "DA config list entry failed for vpath:%d",
+                       vpath->device_id);
+               return status;
+       }
+
+       while (memcmp(mac->macaddr, macaddr, ETH_ALEN)) {
+
+               status = vxge_hw_vpath_mac_addr_get_next(vpath->handle,
+                               macaddr, macmask);
+               if (status != VXGE_HW_OK)
+                       break;
+       }
+
+       return status;
+}
+
+/* Store all mac addresses from the list to the DA table */
+static enum vxge_hw_status vxge_restore_vpath_mac_addr(struct vxge_vpath *vpath)
+{
+       enum vxge_hw_status status = VXGE_HW_OK;
+       struct macInfo mac_info;
+       u8 *mac_address = NULL;
+       struct list_head *entry, *next;
+
+       memset(&mac_info, 0, sizeof(struct macInfo));
+
+       if (vpath->is_open) {
+
+               list_for_each_safe(entry, next, &vpath->mac_addr_list) {
+                       mac_address =
+                               (u8 *)&
+                               ((struct vxge_mac_addrs *)entry)->macaddr;
+                       memcpy(mac_info.macaddr, mac_address, ETH_ALEN);
+                       ((struct vxge_mac_addrs *)entry)->state =
+                               VXGE_LL_MAC_ADDR_IN_DA_TABLE;
+                       /* does this mac address already exist in da table? */
+                       status = vxge_search_mac_addr_in_da_table(vpath,
+                               &mac_info);
+                       if (status != VXGE_HW_OK) {
+                               /* Add this mac address to the DA table */
+                               status = vxge_hw_vpath_mac_addr_add(
+                                       vpath->handle, mac_info.macaddr,
+                                       mac_info.macmask,
+                                   VXGE_HW_VPATH_MAC_ADDR_ADD_DUPLICATE);
+                               if (status != VXGE_HW_OK) {
+                                       vxge_debug_init(VXGE_ERR,
+                                           "DA add entry failed for vpath:%d",
+                                           vpath->device_id);
+                                       ((struct vxge_mac_addrs *)entry)->state
+                                               = VXGE_LL_MAC_ADDR_IN_LIST;
+                               }
+                       }
+               }
+       }
+
+       return status;
+}
+
+/* Store all vlan ids from the list to the vid table */
+static enum vxge_hw_status
+vxge_restore_vpath_vid_table(struct vxge_vpath *vpath)
+{
+       enum vxge_hw_status status = VXGE_HW_OK;
+       struct vxgedev *vdev = vpath->vdev;
+       u16 vid;
+
+       if (vdev->vlgrp && vpath->is_open) {
+
+               for (vid = 0; vid < VLAN_N_VID; vid++) {
+                       if (!vlan_group_get_device(vdev->vlgrp, vid))
+                               continue;
+                       /* Add these vlan to the vid table */
+                       status = vxge_hw_vpath_vid_add(vpath->handle, vid);
+               }
+       }
+
+       return status;
+}
+
 /*
  * vxge_reset_vpath
  * @vdev: pointer to vdev
@@ -1578,7 +1770,7 @@ out:
  *
  * driver may reset the chip on events of serr, eccerr, etc
  */
-int vxge_reset(struct vxgedev *vdev)
+static int vxge_reset(struct vxgedev *vdev)
 {
        return do_vxge_reset(vdev, VXGE_LL_FULL_RESET);
 }
@@ -1749,197 +1941,6 @@ static enum vxge_hw_status vxge_rth_configure(struct vxgedev *vdev)
        return status;
 }

-int vxge_mac_list_add(struct vxge_vpath *vpath, struct macInfo *mac)
-{
-       struct vxge_mac_addrs *new_mac_entry;
-       u8 *mac_address = NULL;
-
-       if (vpath->mac_addr_cnt >= VXGE_MAX_LEARN_MAC_ADDR_CNT)
-               return TRUE;
-
-       new_mac_entry = kzalloc(sizeof(struct vxge_mac_addrs), GFP_ATOMIC);
-       if (!new_mac_entry) {
-               vxge_debug_mem(VXGE_ERR,
-                       "%s: memory allocation failed",
-                       VXGE_DRIVER_NAME);
-               return FALSE;
-       }
-
-       list_add(&new_mac_entry->item, &vpath->mac_addr_list);
-
-       /* Copy the new mac address to the list */
-       mac_address = (u8 *)&new_mac_entry->macaddr;
-       memcpy(mac_address, mac->macaddr, ETH_ALEN);
-
-       new_mac_entry->state = mac->state;
-       vpath->mac_addr_cnt++;
-
-       /* Is this a multicast address */
-       if (0x01 & mac->macaddr[0])
-               vpath->mcast_addr_cnt++;
-
-       return TRUE;
-}
-
-/* Add a mac address to DA table */
-enum vxge_hw_status vxge_add_mac_addr(struct vxgedev *vdev, struct macInfo *mac)
-{
-       enum vxge_hw_status status = VXGE_HW_OK;
-       struct vxge_vpath *vpath;
-       enum vxge_hw_vpath_mac_addr_add_mode duplicate_mode;
-
-       if (0x01 & mac->macaddr[0]) /* multicast address */
-               duplicate_mode = VXGE_HW_VPATH_MAC_ADDR_ADD_DUPLICATE;
-       else
-               duplicate_mode = VXGE_HW_VPATH_MAC_ADDR_REPLACE_DUPLICATE;
-
-       vpath = &vdev->vpaths[mac->vpath_no];
-       status = vxge_hw_vpath_mac_addr_add(vpath->handle, mac->macaddr,
-                                               mac->macmask, duplicate_mode);
-       if (status != VXGE_HW_OK) {
-               vxge_debug_init(VXGE_ERR,
-                       "DA config add entry failed for vpath:%d",
-                       vpath->device_id);
-       } else
-               if (FALSE == vxge_mac_list_add(vpath, mac))
-                       status = -EPERM;
-
-       return status;
-}
-
-int vxge_mac_list_del(struct vxge_vpath *vpath, struct macInfo *mac)
-{
-       struct list_head *entry, *next;
-       u64 del_mac = 0;
-       u8 *mac_address = (u8 *) (&del_mac);
-
-       /* Copy the mac address to delete from the list */
-       memcpy(mac_address, mac->macaddr, ETH_ALEN);
-
-       list_for_each_safe(entry, next, &vpath->mac_addr_list) {
-               if (((struct vxge_mac_addrs *)entry)->macaddr == del_mac) {
-                       list_del(entry);
-                       kfree((struct vxge_mac_addrs *)entry);
-                       vpath->mac_addr_cnt--;
-
-                       /* Is this a multicast address */
-                       if (0x01 & mac->macaddr[0])
-                               vpath->mcast_addr_cnt--;
-                       return TRUE;
-               }
-       }
-
-       return FALSE;
-}
-/* delete a mac address from DA table */
-enum vxge_hw_status vxge_del_mac_addr(struct vxgedev *vdev, struct macInfo *mac)
-{
-       enum vxge_hw_status status = VXGE_HW_OK;
-       struct vxge_vpath *vpath;
-
-       vpath = &vdev->vpaths[mac->vpath_no];
-       status = vxge_hw_vpath_mac_addr_delete(vpath->handle, mac->macaddr,
-                                               mac->macmask);
-       if (status != VXGE_HW_OK) {
-               vxge_debug_init(VXGE_ERR,
-                       "DA config delete entry failed for vpath:%d",
-                       vpath->device_id);
-       } else
-               vxge_mac_list_del(vpath, mac);
-       return status;
-}
-
-/* list all mac addresses from DA table */
-enum vxge_hw_status
-static vxge_search_mac_addr_in_da_table(struct vxge_vpath *vpath,
-                                       struct macInfo *mac)
-{
-       enum vxge_hw_status status = VXGE_HW_OK;
-       unsigned char macmask[ETH_ALEN];
-       unsigned char macaddr[ETH_ALEN];
-
-       status = vxge_hw_vpath_mac_addr_get(vpath->handle,
-                               macaddr, macmask);
-       if (status != VXGE_HW_OK) {
-               vxge_debug_init(VXGE_ERR,
-                       "DA config list entry failed for vpath:%d",
-                       vpath->device_id);
-               return status;
-       }
-
-       while (memcmp(mac->macaddr, macaddr, ETH_ALEN)) {
-
-               status = vxge_hw_vpath_mac_addr_get_next(vpath->handle,
-                               macaddr, macmask);
-               if (status != VXGE_HW_OK)
-                       break;
-       }
-
-       return status;
-}
-
-/* Store all vlan ids from the list to the vid table */
-enum vxge_hw_status vxge_restore_vpath_vid_table(struct vxge_vpath *vpath)
-{
-       enum vxge_hw_status status = VXGE_HW_OK;
-       struct vxgedev *vdev = vpath->vdev;
-       u16 vid;
-
-       if (vdev->vlgrp && vpath->is_open) {
-
-               for (vid = 0; vid < VLAN_N_VID; vid++) {
-                       if (!vlan_group_get_device(vdev->vlgrp, vid))
-                               continue;
-                       /* Add these vlan to the vid table */
-                       status = vxge_hw_vpath_vid_add(vpath->handle, vid);
-               }
-       }
-
-       return status;
-}
-
-/* Store all mac addresses from the list to the DA table */
-enum vxge_hw_status vxge_restore_vpath_mac_addr(struct vxge_vpath *vpath)
-{
-       enum vxge_hw_status status = VXGE_HW_OK;
-       struct macInfo mac_info;
-       u8 *mac_address = NULL;
-       struct list_head *entry, *next;
-
-       memset(&mac_info, 0, sizeof(struct macInfo));
-
-       if (vpath->is_open) {
-
-               list_for_each_safe(entry, next, &vpath->mac_addr_list) {
-                       mac_address =
-                               (u8 *)&
-                               ((struct vxge_mac_addrs *)entry)->macaddr;
-                       memcpy(mac_info.macaddr, mac_address, ETH_ALEN);
-                       ((struct vxge_mac_addrs *)entry)->state =
-                               VXGE_LL_MAC_ADDR_IN_DA_TABLE;
-                       /* does this mac address already exist in da table? */
-                       status = vxge_search_mac_addr_in_da_table(vpath,
-                               &mac_info);
-                       if (status != VXGE_HW_OK) {
-                               /* Add this mac address to the DA table */
-                               status = vxge_hw_vpath_mac_addr_add(
-                                       vpath->handle, mac_info.macaddr,
-                                       mac_info.macmask,
-                                   VXGE_HW_VPATH_MAC_ADDR_ADD_DUPLICATE);
-                               if (status != VXGE_HW_OK) {
-                                       vxge_debug_init(VXGE_ERR,
-                                           "DA add entry failed for vpath:%d",
-                                           vpath->device_id);
-                                       ((struct vxge_mac_addrs *)entry)->state
-                                               = VXGE_LL_MAC_ADDR_IN_LIST;
-                               }
-                       }
-               }
-       }
-
-       return status;
-}
-
 /* reset vpaths */
 enum vxge_hw_status vxge_reset_all_vpaths(struct vxgedev *vdev)
 {
@@ -1973,7 +1974,7 @@ enum vxge_hw_status vxge_reset_all_vpaths(struct vxgedev *vdev)
 }

 /* close vpaths */
-void vxge_close_vpaths(struct vxgedev *vdev, int index)
+static void vxge_close_vpaths(struct vxgedev *vdev, int index)
 {
        struct vxge_vpath *vpath;
        int i;
@@ -1991,7 +1992,7 @@ void vxge_close_vpaths(struct vxgedev *vdev, int index)
 }

 /* open vpaths */
-int vxge_open_vpaths(struct vxgedev *vdev)
+static int vxge_open_vpaths(struct vxgedev *vdev)
 {
        struct vxge_hw_vpath_attr attr;
        enum vxge_hw_status status;
@@ -2558,8 +2559,7 @@ static void vxge_poll_vp_lockup(unsigned long data)
  * Return value: '0' on success and an appropriate (-)ve integer as
  * defined in errno.h file on failure.
  */
-int
-vxge_open(struct net_device *dev)
+static int vxge_open(struct net_device *dev)
 {
        enum vxge_hw_status status;
        struct vxgedev *vdev;
@@ -2765,7 +2765,7 @@ out0:
 }

 /* Loop throught the mac address list and delete all the entries */
-void vxge_free_mac_add_list(struct vxge_vpath *vpath)
+static void vxge_free_mac_add_list(struct vxge_vpath *vpath)
 {

        struct list_head *entry, *next;
@@ -2789,7 +2789,7 @@ static void vxge_napi_del_all(struct vxgedev *vdev)
        }
 }

-int do_vxge_close(struct net_device *dev, int do_io)
+static int do_vxge_close(struct net_device *dev, int do_io)
 {
        enum vxge_hw_status status;
        struct vxgedev *vdev;
@@ -2904,8 +2904,7 @@ int do_vxge_close(struct net_device *dev, int do_io)
  * Return value: '0' on success and an appropriate (-)ve integer as
  * defined in errno.h file on failure.
  */
-int
-vxge_close(struct net_device *dev)
+static int vxge_close(struct net_device *dev)
 {
        do_vxge_close(dev, 1);
        return 0;
@@ -3338,7 +3337,7 @@ static int __devinit vxge_device_register(struct __vxge_hw_device *hldev,

        ndev->watchdog_timeo = VXGE_LL_WATCH_DOG_TIMEOUT;

-       initialize_ethtool_ops(ndev);
+       vxge_initialize_ethtool_ops(ndev);

        if (vdev->config.rth_steering != NO_STEERING) {
                ndev->features |= NETIF_F_RXHASH;
@@ -3429,8 +3428,7 @@ _out0:
  *
  * This function will unregister and free network device
  */
-void
-vxge_device_unregister(struct __vxge_hw_device *hldev)
+static void vxge_device_unregister(struct __vxge_hw_device *hldev)
 {
        struct vxgedev *vdev;
        struct net_device *dev;
diff --git a/drivers/net/vxge/vxge-main.h b/drivers/net/vxge/vxge-main.h
index 151f54b..994d1e0 100644
--- a/drivers/net/vxge/vxge-main.h
+++ b/drivers/net/vxge/vxge-main.h
@@ -420,61 +420,8 @@ struct vxge_tx_priv {
                mod_timer(&timer, (jiffies + exp)); \
        } while (0);

-void vxge_device_unregister(struct __vxge_hw_device *devh);
-
-void vxge_vpath_intr_enable(struct vxgedev *vdev, int vp_id);
-
-void vxge_vpath_intr_disable(struct vxgedev *vdev, int vp_id);
-
-void vxge_callback_link_up(struct __vxge_hw_device *devh);
-
-void vxge_callback_link_down(struct __vxge_hw_device *devh);
-
-enum vxge_hw_status vxge_add_mac_addr(struct vxgedev *vdev,
-       struct macInfo *mac);
-
-int vxge_mac_list_del(struct vxge_vpath *vpath, struct macInfo *mac);
-
-int vxge_reset(struct vxgedev *vdev);
-
-enum vxge_hw_status
-vxge_rx_1b_compl(struct __vxge_hw_ring *ringh, void *dtr,
-       u8 t_code, void *userdata);
-
-enum vxge_hw_status
-vxge_xmit_compl(struct __vxge_hw_fifo *fifo_hw, void *dtr,
-       enum vxge_hw_fifo_tcode t_code, void *userdata,
-       struct sk_buff ***skb_ptr, int nr_skbs, int *more);
-
-int vxge_close(struct net_device *dev);
-
-int vxge_open(struct net_device *dev);
-
-void vxge_close_vpaths(struct vxgedev *vdev, int index);
-
-int vxge_open_vpaths(struct vxgedev *vdev);
-
 enum vxge_hw_status vxge_reset_all_vpaths(struct vxgedev *vdev);
-
-enum vxge_hw_status vxge_add_mac_addr(struct vxgedev *vdev,
-       struct macInfo *mac);
-
-enum vxge_hw_status vxge_del_mac_addr(struct vxgedev *vdev,
-       struct macInfo *mac);
-
-int vxge_mac_list_add(struct vxge_vpath *vpath,
-       struct macInfo *mac);
-
-void vxge_free_mac_add_list(struct vxge_vpath *vpath);
-
-enum vxge_hw_status vxge_restore_vpath_mac_addr(struct vxge_vpath *vpath);
-
-enum vxge_hw_status vxge_restore_vpath_vid_table(struct vxge_vpath *vpath);
-
-int do_vxge_close(struct net_device *dev, int do_io);
-
-extern void initialize_ethtool_ops(struct net_device *ndev);
-
+void vxge_initialize_ethtool_ops(struct net_device *ndev);
 int vxge_fw_upgrade(struct vxgedev *vdev, char *fw_name, int override);

 /**
diff --git a/drivers/net/vxge/vxge-traffic.c b/drivers/net/vxge/vxge-traffic.c
index cedf08f..0fb8505 100644
--- a/drivers/net/vxge/vxge-traffic.c
+++ b/drivers/net/vxge/vxge-traffic.c
@@ -412,6 +412,384 @@ void vxge_hw_device_flush_io(struct __vxge_hw_device *hldev)
 }

 /**
+ * __vxge_hw_device_handle_error - Handle error
+ * @hldev: HW device
+ * @vp_id: Vpath Id
+ * @type: Error type. Please see enum vxge_hw_event{}
+ *
+ * Handle error.
+ */
+static enum vxge_hw_status
+__vxge_hw_device_handle_error(struct __vxge_hw_device *hldev, u32 vp_id,
+                             enum vxge_hw_event type)
+{
+       switch (type) {
+       case VXGE_HW_EVENT_UNKNOWN:
+               break;
+       case VXGE_HW_EVENT_RESET_START:
+       case VXGE_HW_EVENT_RESET_COMPLETE:
+       case VXGE_HW_EVENT_LINK_DOWN:
+       case VXGE_HW_EVENT_LINK_UP:
+               goto out;
+       case VXGE_HW_EVENT_ALARM_CLEARED:
+               goto out;
+       case VXGE_HW_EVENT_ECCERR:
+       case VXGE_HW_EVENT_MRPCIM_ECCERR:
+               goto out;
+       case VXGE_HW_EVENT_FIFO_ERR:
+       case VXGE_HW_EVENT_VPATH_ERR:
+       case VXGE_HW_EVENT_CRITICAL_ERR:
+       case VXGE_HW_EVENT_SERR:
+               break;
+       case VXGE_HW_EVENT_SRPCIM_SERR:
+       case VXGE_HW_EVENT_MRPCIM_SERR:
+               goto out;
+       case VXGE_HW_EVENT_SLOT_FREEZE:
+               break;
+       default:
+               vxge_assert(0);
+               goto out;
+       }
+
+       /* notify driver */
+       if (hldev->uld_callbacks.crit_err)
+               hldev->uld_callbacks.crit_err(
+                       (struct __vxge_hw_device *)hldev,
+                       type, vp_id);
+out:
+
+       return VXGE_HW_OK;
+}
+
+/*
+ * __vxge_hw_device_handle_link_down_ind
+ * @hldev: HW device handle.
+ *
+ * Link down indication handler. The function is invoked by HW when
+ * Titan indicates that the link is down.
+ */
+static enum vxge_hw_status
+__vxge_hw_device_handle_link_down_ind(struct __vxge_hw_device *hldev)
+{
+       /*
+        * If the previous link state is not down, return.
+        */
+       if (hldev->link_state == VXGE_HW_LINK_DOWN)
+               goto exit;
+
+       hldev->link_state = VXGE_HW_LINK_DOWN;
+
+       /* notify driver */
+       if (hldev->uld_callbacks.link_down)
+               hldev->uld_callbacks.link_down(hldev);
+exit:
+       return VXGE_HW_OK;
+}
+
+/*
+ * __vxge_hw_device_handle_link_up_ind
+ * @hldev: HW device handle.
+ *
+ * Link up indication handler. The function is invoked by HW when
+ * Titan indicates that the link is up for programmable amount of time.
+ */
+static enum vxge_hw_status
+__vxge_hw_device_handle_link_up_ind(struct __vxge_hw_device *hldev)
+{
+       /*
+        * If the previous link state is not down, return.
+        */
+       if (hldev->link_state == VXGE_HW_LINK_UP)
+               goto exit;
+
+       hldev->link_state = VXGE_HW_LINK_UP;
+
+       /* notify driver */
+       if (hldev->uld_callbacks.link_up)
+               hldev->uld_callbacks.link_up(hldev);
+exit:
+       return VXGE_HW_OK;
+}
+
+/*
+ * __vxge_hw_vpath_alarm_process - Process Alarms.
+ * @vpath: Virtual Path.
+ * @skip_alarms: Do not clear the alarms
+ *
+ * Process vpath alarms.
+ *
+ */
+static enum vxge_hw_status
+__vxge_hw_vpath_alarm_process(struct __vxge_hw_virtualpath *vpath,
+                             u32 skip_alarms)
+{
+       u64 val64;
+       u64 alarm_status;
+       u64 pic_status;
+       struct __vxge_hw_device *hldev = NULL;
+       enum vxge_hw_event alarm_event = VXGE_HW_EVENT_UNKNOWN;
+       u64 mask64;
+       struct vxge_hw_vpath_stats_sw_info *sw_stats;
+       struct vxge_hw_vpath_reg __iomem *vp_reg;
+
+       if (vpath == NULL) {
+               alarm_event = VXGE_HW_SET_LEVEL(VXGE_HW_EVENT_UNKNOWN,
+                       alarm_event);
+               goto out2;
+       }
+
+       hldev = vpath->hldev;
+       vp_reg = vpath->vp_reg;
+       alarm_status = readq(&vp_reg->vpath_general_int_status);
+
+       if (alarm_status == VXGE_HW_ALL_FOXES) {
+               alarm_event = VXGE_HW_SET_LEVEL(VXGE_HW_EVENT_SLOT_FREEZE,
+                       alarm_event);
+               goto out;
+       }
+
+       sw_stats = vpath->sw_stats;
+
+       if (alarm_status & ~(
+               VXGE_HW_VPATH_GENERAL_INT_STATUS_PIC_INT |
+               VXGE_HW_VPATH_GENERAL_INT_STATUS_PCI_INT |
+               VXGE_HW_VPATH_GENERAL_INT_STATUS_WRDMA_INT |
+               VXGE_HW_VPATH_GENERAL_INT_STATUS_XMAC_INT)) {
+               sw_stats->error_stats.unknown_alarms++;
+
+               alarm_event = VXGE_HW_SET_LEVEL(VXGE_HW_EVENT_UNKNOWN,
+                       alarm_event);
+               goto out;
+       }
+
+       if (alarm_status & VXGE_HW_VPATH_GENERAL_INT_STATUS_XMAC_INT) {
+
+               val64 = readq(&vp_reg->xgmac_vp_int_status);
+
+               if (val64 &
+               VXGE_HW_XGMAC_VP_INT_STATUS_ASIC_NTWK_VP_ERR_ASIC_NTWK_VP_INT) {
+
+                       val64 = readq(&vp_reg->asic_ntwk_vp_err_reg);
+
+                       if (((val64 &
+                             VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT) &&
+                            (!(val64 &
+                               VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK))) ||
+                           ((val64 &
+                             VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT_OCCURR) &&
+                            (!(val64 &
+                               VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK_OCCURR)
+                                    ))) {
+                               sw_stats->error_stats.network_sustained_fault++;
+
+                               writeq(
+                               VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT,
+                                       &vp_reg->asic_ntwk_vp_err_mask);
+
+                               __vxge_hw_device_handle_link_down_ind(hldev);
+                               alarm_event = VXGE_HW_SET_LEVEL(
+                                       VXGE_HW_EVENT_LINK_DOWN, alarm_event);
+                       }
+
+                       if (((val64 &
+                             VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK) &&
+                            (!(val64 &
+                               VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT))) ||
+                           ((val64 &
+                             VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK_OCCURR) &&
+                            (!(val64 &
+                               VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT_OCCURR)
+                                    ))) {
+
+                               sw_stats->error_stats.network_sustained_ok++;
+
+                               writeq(
+                               VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK,
+                                       &vp_reg->asic_ntwk_vp_err_mask);
+
+                               __vxge_hw_device_handle_link_up_ind(hldev);
+                               alarm_event = VXGE_HW_SET_LEVEL(
+                                       VXGE_HW_EVENT_LINK_UP, alarm_event);
+                       }
+
+                       writeq(VXGE_HW_INTR_MASK_ALL,
+                               &vp_reg->asic_ntwk_vp_err_reg);
+
+                       alarm_event = VXGE_HW_SET_LEVEL(
+                               VXGE_HW_EVENT_ALARM_CLEARED, alarm_event);
+
+                       if (skip_alarms)
+                               return VXGE_HW_OK;
+               }
+       }
+
+       if (alarm_status & VXGE_HW_VPATH_GENERAL_INT_STATUS_PIC_INT) {
+
+               pic_status = readq(&vp_reg->vpath_ppif_int_status);
+
+               if (pic_status &
+                   VXGE_HW_VPATH_PPIF_INT_STATUS_GENERAL_ERRORS_GENERAL_INT) {
+
+                       val64 = readq(&vp_reg->general_errors_reg);
+                       mask64 = readq(&vp_reg->general_errors_mask);
+
+                       if ((val64 &
+                               VXGE_HW_GENERAL_ERRORS_REG_INI_SERR_DET) &
+                               ~mask64) {
+                               sw_stats->error_stats.ini_serr_det++;
+
+                               alarm_event = VXGE_HW_SET_LEVEL(
+                                       VXGE_HW_EVENT_SERR, alarm_event);
+                       }
+
+                       if ((val64 &
+                           VXGE_HW_GENERAL_ERRORS_REG_DBLGEN_FIFO0_OVRFLOW) &
+                               ~mask64) {
+                               sw_stats->error_stats.dblgen_fifo0_overflow++;
+
+                               alarm_event = VXGE_HW_SET_LEVEL(
+                                       VXGE_HW_EVENT_FIFO_ERR, alarm_event);
+                       }
+
+                       if ((val64 &
+                           VXGE_HW_GENERAL_ERRORS_REG_STATSB_PIF_CHAIN_ERR) &
+                               ~mask64)
+                               sw_stats->error_stats.statsb_pif_chain_error++;
+
+                       if ((val64 &
+                          VXGE_HW_GENERAL_ERRORS_REG_STATSB_DROP_TIMEOUT_REQ) &
+                               ~mask64)
+                               sw_stats->error_stats.statsb_drop_timeout++;
+
+                       if ((val64 &
+                               VXGE_HW_GENERAL_ERRORS_REG_TGT_ILLEGAL_ACCESS) &
+                               ~mask64)
+                               sw_stats->error_stats.target_illegal_access++;
+
+                       if (!skip_alarms) {
+                               writeq(VXGE_HW_INTR_MASK_ALL,
+                                       &vp_reg->general_errors_reg);
+                               alarm_event = VXGE_HW_SET_LEVEL(
+                                       VXGE_HW_EVENT_ALARM_CLEARED,
+                                       alarm_event);
+                       }
+               }
+
+               if (pic_status &
+                   VXGE_HW_VPATH_PPIF_INT_STATUS_KDFCCTL_ERRORS_KDFCCTL_INT) {
+
+                       val64 = readq(&vp_reg->kdfcctl_errors_reg);
+                       mask64 = readq(&vp_reg->kdfcctl_errors_mask);
+
+                       if ((val64 &
+                           VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO0_OVRWR) &
+                               ~mask64) {
+                               sw_stats->error_stats.kdfcctl_fifo0_overwrite++;
+
+                               alarm_event = VXGE_HW_SET_LEVEL(
+                                       VXGE_HW_EVENT_FIFO_ERR,
+                                       alarm_event);
+                       }
+
+                       if ((val64 &
+                           VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO0_POISON) &
+                               ~mask64) {
+                               sw_stats->error_stats.kdfcctl_fifo0_poison++;
+
+                               alarm_event = VXGE_HW_SET_LEVEL(
+                                       VXGE_HW_EVENT_FIFO_ERR,
+                                       alarm_event);
+                       }
+
+                       if ((val64 &
+                           VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO0_DMA_ERR) &
+                               ~mask64) {
+                               sw_stats->error_stats.kdfcctl_fifo0_dma_error++;
+
+                               alarm_event = VXGE_HW_SET_LEVEL(
+                                       VXGE_HW_EVENT_FIFO_ERR,
+                                       alarm_event);
+                       }
+
+                       if (!skip_alarms) {
+                               writeq(VXGE_HW_INTR_MASK_ALL,
+                                       &vp_reg->kdfcctl_errors_reg);
+                               alarm_event = VXGE_HW_SET_LEVEL(
+                                       VXGE_HW_EVENT_ALARM_CLEARED,
+                                       alarm_event);
+                       }
+               }
+
+       }
+
+       if (alarm_status & VXGE_HW_VPATH_GENERAL_INT_STATUS_WRDMA_INT) {
+
+               val64 = readq(&vp_reg->wrdma_alarm_status);
+
+               if (val64 & VXGE_HW_WRDMA_ALARM_STATUS_PRC_ALARM_PRC_INT) {
+
+                       val64 = readq(&vp_reg->prc_alarm_reg);
+                       mask64 = readq(&vp_reg->prc_alarm_mask);
+
+                       if ((val64 & VXGE_HW_PRC_ALARM_REG_PRC_RING_BUMP)&
+                               ~mask64)
+                               sw_stats->error_stats.prc_ring_bumps++;
+
+                       if ((val64 & VXGE_HW_PRC_ALARM_REG_PRC_RXDCM_SC_ERR) &
+                               ~mask64) {
+                               sw_stats->error_stats.prc_rxdcm_sc_err++;
+
+                               alarm_event = VXGE_HW_SET_LEVEL(
+                                       VXGE_HW_EVENT_VPATH_ERR,
+                                       alarm_event);
+                       }
+
+                       if ((val64 & VXGE_HW_PRC_ALARM_REG_PRC_RXDCM_SC_ABORT)
+                               & ~mask64) {
+                               sw_stats->error_stats.prc_rxdcm_sc_abort++;
+
+                               alarm_event = VXGE_HW_SET_LEVEL(
+                                               VXGE_HW_EVENT_VPATH_ERR,
+                                               alarm_event);
+                       }
+
+                       if ((val64 & VXGE_HW_PRC_ALARM_REG_PRC_QUANTA_SIZE_ERR)
+                                & ~mask64) {
+                               sw_stats->error_stats.prc_quanta_size_err++;
+
+                               alarm_event = VXGE_HW_SET_LEVEL(
+                                       VXGE_HW_EVENT_VPATH_ERR,
+                                       alarm_event);
+                       }
+
+                       if (!skip_alarms) {
+                               writeq(VXGE_HW_INTR_MASK_ALL,
+                                       &vp_reg->prc_alarm_reg);
+                               alarm_event = VXGE_HW_SET_LEVEL(
+                                               VXGE_HW_EVENT_ALARM_CLEARED,
+                                               alarm_event);
+                       }
+               }
+       }
+out:
+       hldev->stats.sw_dev_err_stats.vpath_alarms++;
+out2:
+       if ((alarm_event == VXGE_HW_EVENT_ALARM_CLEARED) ||
+               (alarm_event == VXGE_HW_EVENT_UNKNOWN))
+               return VXGE_HW_OK;
+
+       __vxge_hw_device_handle_error(hldev, vpath->vp_id, alarm_event);
+
+       if (alarm_event == VXGE_HW_EVENT_SERR)
+               return VXGE_HW_ERR_CRITICAL;
+
+       return (alarm_event == VXGE_HW_EVENT_SLOT_FREEZE) ?
+               VXGE_HW_ERR_SLOT_FREEZE :
+               (alarm_event == VXGE_HW_EVENT_FIFO_ERR) ? VXGE_HW_ERR_FIFO :
+               VXGE_HW_ERR_VPATH;
+}
+
+/**
  * vxge_hw_device_begin_irq - Begin IRQ processing.
  * @hldev: HW device handle.
  * @skip_alarms: Do not clear the alarms
@@ -506,108 +884,6 @@ exit:
        return ret;
 }

-/*
- * __vxge_hw_device_handle_link_up_ind
- * @hldev: HW device handle.
- *
- * Link up indication handler. The function is invoked by HW when
- * Titan indicates that the link is up for programmable amount of time.
- */
-enum vxge_hw_status
-__vxge_hw_device_handle_link_up_ind(struct __vxge_hw_device *hldev)
-{
-       /*
-        * If the previous link state is not down, return.
-        */
-       if (hldev->link_state == VXGE_HW_LINK_UP)
-               goto exit;
-
-       hldev->link_state = VXGE_HW_LINK_UP;
-
-       /* notify driver */
-       if (hldev->uld_callbacks.link_up)
-               hldev->uld_callbacks.link_up(hldev);
-exit:
-       return VXGE_HW_OK;
-}
-
-/*
- * __vxge_hw_device_handle_link_down_ind
- * @hldev: HW device handle.
- *
- * Link down indication handler. The function is invoked by HW when
- * Titan indicates that the link is down.
- */
-enum vxge_hw_status
-__vxge_hw_device_handle_link_down_ind(struct __vxge_hw_device *hldev)
-{
-       /*
-        * If the previous link state is not down, return.
-        */
-       if (hldev->link_state == VXGE_HW_LINK_DOWN)
-               goto exit;
-
-       hldev->link_state = VXGE_HW_LINK_DOWN;
-
-       /* notify driver */
-       if (hldev->uld_callbacks.link_down)
-               hldev->uld_callbacks.link_down(hldev);
-exit:
-       return VXGE_HW_OK;
-}
-
-/**
- * __vxge_hw_device_handle_error - Handle error
- * @hldev: HW device
- * @vp_id: Vpath Id
- * @type: Error type. Please see enum vxge_hw_event{}
- *
- * Handle error.
- */
-enum vxge_hw_status
-__vxge_hw_device_handle_error(
-               struct __vxge_hw_device *hldev,
-               u32 vp_id,
-               enum vxge_hw_event type)
-{
-       switch (type) {
-       case VXGE_HW_EVENT_UNKNOWN:
-               break;
-       case VXGE_HW_EVENT_RESET_START:
-       case VXGE_HW_EVENT_RESET_COMPLETE:
-       case VXGE_HW_EVENT_LINK_DOWN:
-       case VXGE_HW_EVENT_LINK_UP:
-               goto out;
-       case VXGE_HW_EVENT_ALARM_CLEARED:
-               goto out;
-       case VXGE_HW_EVENT_ECCERR:
-       case VXGE_HW_EVENT_MRPCIM_ECCERR:
-               goto out;
-       case VXGE_HW_EVENT_FIFO_ERR:
-       case VXGE_HW_EVENT_VPATH_ERR:
-       case VXGE_HW_EVENT_CRITICAL_ERR:
-       case VXGE_HW_EVENT_SERR:
-               break;
-       case VXGE_HW_EVENT_SRPCIM_SERR:
-       case VXGE_HW_EVENT_MRPCIM_SERR:
-               goto out;
-       case VXGE_HW_EVENT_SLOT_FREEZE:
-               break;
-       default:
-               vxge_assert(0);
-               goto out;
-       }
-
-       /* notify driver */
-       if (hldev->uld_callbacks.crit_err)
-               hldev->uld_callbacks.crit_err(
-                       (struct __vxge_hw_device *)hldev,
-                       type, vp_id);
-out:
-
-       return VXGE_HW_OK;
-}
-
 /**
  * vxge_hw_device_clear_tx_rx - Acknowledge (that is, clear) the
  * condition that has caused the Tx and RX interrupt.
@@ -646,7 +922,7 @@ void vxge_hw_device_clear_tx_rx(struct __vxge_hw_device *hldev)
  * it swaps the reserve and free arrays.
  *
  */
-enum vxge_hw_status
+static enum vxge_hw_status
 vxge_hw_channel_dtr_alloc(struct __vxge_hw_channel *channel, void **dtrh)
 {
        void **tmp_arr;
@@ -692,7 +968,8 @@ _alloc_after_swap:
  * Posts a dtr to work array.
  *
  */
-void vxge_hw_channel_dtr_post(struct __vxge_hw_channel *channel, void *dtrh)
+static void
+vxge_hw_channel_dtr_post(struct __vxge_hw_channel *channel, void *dtrh)
 {
        vxge_assert(channel->work_arr[channel->post_index] == NULL);

@@ -1658,37 +1935,6 @@ exit:
 }

 /**
- * vxge_hw_vpath_vid_get_next - Get the next vid entry for this vpath
- *               from vlan id table.
- * @vp: Vpath handle.
- * @vid: Buffer to return vlan id
- *
- * Returns the next vlan id in the list for this vpath.
- * see also: vxge_hw_vpath_vid_get
- *
- */
-enum vxge_hw_status
-vxge_hw_vpath_vid_get_next(struct __vxge_hw_vpath_handle *vp, u64 *vid)
-{
-       u64 data;
-       enum vxge_hw_status status = VXGE_HW_OK;
-
-       if (vp == NULL) {
-               status = VXGE_HW_ERR_INVALID_HANDLE;
-               goto exit;
-       }
-
-       status = __vxge_hw_vpath_rts_table_get(vp,
-                       VXGE_HW_RTS_ACCESS_STEER_CTRL_ACTION_LIST_NEXT_ENTRY,
-                       VXGE_HW_RTS_ACCESS_STEER_CTRL_DATA_STRUCT_SEL_VID,
-                       0, vid, &data);
-
-       *vid = VXGE_HW_RTS_ACCESS_STEER_DATA0_GET_VLAN_ID(*vid);
-exit:
-       return status;
-}
-
-/**
  * vxge_hw_vpath_vid_delete - Delete the vlan id entry for this vpath
  *               to vlan id table.
  * @vp: Vpath handle.
@@ -1891,284 +2137,6 @@ exit:
 }

 /*
- * __vxge_hw_vpath_alarm_process - Process Alarms.
- * @vpath: Virtual Path.
- * @skip_alarms: Do not clear the alarms
- *
- * Process vpath alarms.
- *
- */
-enum vxge_hw_status __vxge_hw_vpath_alarm_process(
-                       struct __vxge_hw_virtualpath *vpath,
-                       u32 skip_alarms)
-{
-       u64 val64;
-       u64 alarm_status;
-       u64 pic_status;
-       struct __vxge_hw_device *hldev = NULL;
-       enum vxge_hw_event alarm_event = VXGE_HW_EVENT_UNKNOWN;
-       u64 mask64;
-       struct vxge_hw_vpath_stats_sw_info *sw_stats;
-       struct vxge_hw_vpath_reg __iomem *vp_reg;
-
-       if (vpath == NULL) {
-               alarm_event = VXGE_HW_SET_LEVEL(VXGE_HW_EVENT_UNKNOWN,
-                       alarm_event);
-               goto out2;
-       }
-
-       hldev = vpath->hldev;
-       vp_reg = vpath->vp_reg;
-       alarm_status = readq(&vp_reg->vpath_general_int_status);
-
-       if (alarm_status == VXGE_HW_ALL_FOXES) {
-               alarm_event = VXGE_HW_SET_LEVEL(VXGE_HW_EVENT_SLOT_FREEZE,
-                       alarm_event);
-               goto out;
-       }
-
-       sw_stats = vpath->sw_stats;
-
-       if (alarm_status & ~(
-               VXGE_HW_VPATH_GENERAL_INT_STATUS_PIC_INT |
-               VXGE_HW_VPATH_GENERAL_INT_STATUS_PCI_INT |
-               VXGE_HW_VPATH_GENERAL_INT_STATUS_WRDMA_INT |
-               VXGE_HW_VPATH_GENERAL_INT_STATUS_XMAC_INT)) {
-               sw_stats->error_stats.unknown_alarms++;
-
-               alarm_event = VXGE_HW_SET_LEVEL(VXGE_HW_EVENT_UNKNOWN,
-                       alarm_event);
-               goto out;
-       }
-
-       if (alarm_status & VXGE_HW_VPATH_GENERAL_INT_STATUS_XMAC_INT) {
-
-               val64 = readq(&vp_reg->xgmac_vp_int_status);
-
-               if (val64 &
-               VXGE_HW_XGMAC_VP_INT_STATUS_ASIC_NTWK_VP_ERR_ASIC_NTWK_VP_INT) {
-
-                       val64 = readq(&vp_reg->asic_ntwk_vp_err_reg);
-
-                       if (((val64 &
-                             VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT) &&
-                            (!(val64 &
-                               VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK))) ||
-                           ((val64 &
-                             VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT_OCCURR) &&
-                            (!(val64 &
-                               VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK_OCCURR)
-                                    ))) {
-                               sw_stats->error_stats.network_sustained_fault++;
-
-                               writeq(
-                               VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT,
-                                       &vp_reg->asic_ntwk_vp_err_mask);
-
-                               __vxge_hw_device_handle_link_down_ind(hldev);
-                               alarm_event = VXGE_HW_SET_LEVEL(
-                                       VXGE_HW_EVENT_LINK_DOWN, alarm_event);
-                       }
-
-                       if (((val64 &
-                             VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK) &&
-                            (!(val64 &
-                               VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT))) ||
-                           ((val64 &
-                             VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK_OCCURR) &&
-                            (!(val64 &
-                               VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_FLT_OCCURR)
-                                    ))) {
-
-                               sw_stats->error_stats.network_sustained_ok++;
-
-                               writeq(
-                               VXGE_HW_ASIC_NW_VP_ERR_REG_XMACJ_STN_OK,
-                                       &vp_reg->asic_ntwk_vp_err_mask);
-
-                               __vxge_hw_device_handle_link_up_ind(hldev);
-                               alarm_event = VXGE_HW_SET_LEVEL(
-                                       VXGE_HW_EVENT_LINK_UP, alarm_event);
-                       }
-
-                       writeq(VXGE_HW_INTR_MASK_ALL,
-                               &vp_reg->asic_ntwk_vp_err_reg);
-
-                       alarm_event = VXGE_HW_SET_LEVEL(
-                               VXGE_HW_EVENT_ALARM_CLEARED, alarm_event);
-
-                       if (skip_alarms)
-                               return VXGE_HW_OK;
-               }
-       }
-
-       if (alarm_status & VXGE_HW_VPATH_GENERAL_INT_STATUS_PIC_INT) {
-
-               pic_status = readq(&vp_reg->vpath_ppif_int_status);
-
-               if (pic_status &
-                   VXGE_HW_VPATH_PPIF_INT_STATUS_GENERAL_ERRORS_GENERAL_INT) {
-
-                       val64 = readq(&vp_reg->general_errors_reg);
-                       mask64 = readq(&vp_reg->general_errors_mask);
-
-                       if ((val64 &
-                               VXGE_HW_GENERAL_ERRORS_REG_INI_SERR_DET) &
-                               ~mask64) {
-                               sw_stats->error_stats.ini_serr_det++;
-
-                               alarm_event = VXGE_HW_SET_LEVEL(
-                                       VXGE_HW_EVENT_SERR, alarm_event);
-                       }
-
-                       if ((val64 &
-                           VXGE_HW_GENERAL_ERRORS_REG_DBLGEN_FIFO0_OVRFLOW) &
-                               ~mask64) {
-                               sw_stats->error_stats.dblgen_fifo0_overflow++;
-
-                               alarm_event = VXGE_HW_SET_LEVEL(
-                                       VXGE_HW_EVENT_FIFO_ERR, alarm_event);
-                       }
-
-                       if ((val64 &
-                           VXGE_HW_GENERAL_ERRORS_REG_STATSB_PIF_CHAIN_ERR) &
-                               ~mask64)
-                               sw_stats->error_stats.statsb_pif_chain_error++;
-
-                       if ((val64 &
-                          VXGE_HW_GENERAL_ERRORS_REG_STATSB_DROP_TIMEOUT_REQ) &
-                               ~mask64)
-                               sw_stats->error_stats.statsb_drop_timeout++;
-
-                       if ((val64 &
-                               VXGE_HW_GENERAL_ERRORS_REG_TGT_ILLEGAL_ACCESS) &
-                               ~mask64)
-                               sw_stats->error_stats.target_illegal_access++;
-
-                       if (!skip_alarms) {
-                               writeq(VXGE_HW_INTR_MASK_ALL,
-                                       &vp_reg->general_errors_reg);
-                               alarm_event = VXGE_HW_SET_LEVEL(
-                                       VXGE_HW_EVENT_ALARM_CLEARED,
-                                       alarm_event);
-                       }
-               }
-
-               if (pic_status &
-                   VXGE_HW_VPATH_PPIF_INT_STATUS_KDFCCTL_ERRORS_KDFCCTL_INT) {
-
-                       val64 = readq(&vp_reg->kdfcctl_errors_reg);
-                       mask64 = readq(&vp_reg->kdfcctl_errors_mask);
-
-                       if ((val64 &
-                           VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO0_OVRWR) &
-                               ~mask64) {
-                               sw_stats->error_stats.kdfcctl_fifo0_overwrite++;
-
-                               alarm_event = VXGE_HW_SET_LEVEL(
-                                       VXGE_HW_EVENT_FIFO_ERR,
-                                       alarm_event);
-                       }
-
-                       if ((val64 &
-                           VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO0_POISON) &
-                               ~mask64) {
-                               sw_stats->error_stats.kdfcctl_fifo0_poison++;
-
-                               alarm_event = VXGE_HW_SET_LEVEL(
-                                       VXGE_HW_EVENT_FIFO_ERR,
-                                       alarm_event);
-                       }
-
-                       if ((val64 &
-                           VXGE_HW_KDFCCTL_ERRORS_REG_KDFCCTL_FIFO0_DMA_ERR) &
-                               ~mask64) {
-                               sw_stats->error_stats.kdfcctl_fifo0_dma_error++;
-
-                               alarm_event = VXGE_HW_SET_LEVEL(
-                                       VXGE_HW_EVENT_FIFO_ERR,
-                                       alarm_event);
-                       }
-
-                       if (!skip_alarms) {
-                               writeq(VXGE_HW_INTR_MASK_ALL,
-                                       &vp_reg->kdfcctl_errors_reg);
-                               alarm_event = VXGE_HW_SET_LEVEL(
-                                       VXGE_HW_EVENT_ALARM_CLEARED,
-                                       alarm_event);
-                       }
-               }
-
-       }
-
-       if (alarm_status & VXGE_HW_VPATH_GENERAL_INT_STATUS_WRDMA_INT) {
-
-               val64 = readq(&vp_reg->wrdma_alarm_status);
-
-               if (val64 & VXGE_HW_WRDMA_ALARM_STATUS_PRC_ALARM_PRC_INT) {
-
-                       val64 = readq(&vp_reg->prc_alarm_reg);
-                       mask64 = readq(&vp_reg->prc_alarm_mask);
-
-                       if ((val64 & VXGE_HW_PRC_ALARM_REG_PRC_RING_BUMP)&
-                               ~mask64)
-                               sw_stats->error_stats.prc_ring_bumps++;
-
-                       if ((val64 & VXGE_HW_PRC_ALARM_REG_PRC_RXDCM_SC_ERR) &
-                               ~mask64) {
-                               sw_stats->error_stats.prc_rxdcm_sc_err++;
-
-                               alarm_event = VXGE_HW_SET_LEVEL(
-                                       VXGE_HW_EVENT_VPATH_ERR,
-                                       alarm_event);
-                       }
-
-                       if ((val64 & VXGE_HW_PRC_ALARM_REG_PRC_RXDCM_SC_ABORT)
-                               & ~mask64) {
-                               sw_stats->error_stats.prc_rxdcm_sc_abort++;
-
-                               alarm_event = VXGE_HW_SET_LEVEL(
-                                               VXGE_HW_EVENT_VPATH_ERR,
-                                               alarm_event);
-                       }
-
-                       if ((val64 & VXGE_HW_PRC_ALARM_REG_PRC_QUANTA_SIZE_ERR)
-                                & ~mask64) {
-                               sw_stats->error_stats.prc_quanta_size_err++;
-
-                               alarm_event = VXGE_HW_SET_LEVEL(
-                                       VXGE_HW_EVENT_VPATH_ERR,
-                                       alarm_event);
-                       }
-
-                       if (!skip_alarms) {
-                               writeq(VXGE_HW_INTR_MASK_ALL,
-                                       &vp_reg->prc_alarm_reg);
-                               alarm_event = VXGE_HW_SET_LEVEL(
-                                               VXGE_HW_EVENT_ALARM_CLEARED,
-                                               alarm_event);
-                       }
-               }
-       }
-out:
-       hldev->stats.sw_dev_err_stats.vpath_alarms++;
-out2:
-       if ((alarm_event == VXGE_HW_EVENT_ALARM_CLEARED) ||
-               (alarm_event == VXGE_HW_EVENT_UNKNOWN))
-               return VXGE_HW_OK;
-
-       __vxge_hw_device_handle_error(hldev, vpath->vp_id, alarm_event);
-
-       if (alarm_event == VXGE_HW_EVENT_SERR)
-               return VXGE_HW_ERR_CRITICAL;
-
-       return (alarm_event == VXGE_HW_EVENT_SLOT_FREEZE) ?
-               VXGE_HW_ERR_SLOT_FREEZE :
-               (alarm_event == VXGE_HW_EVENT_FIFO_ERR) ? VXGE_HW_ERR_FIFO :
-               VXGE_HW_ERR_VPATH;
-}
-
-/*
  * vxge_hw_vpath_alarm_process - Process Alarms.
  * @vpath: Virtual Path.
  * @skip_alarms: Do not clear the alarms
@@ -2265,36 +2233,6 @@ vxge_hw_vpath_msix_mask(struct __vxge_hw_vpath_handle *vp, int msix_id)
 }

 /**
- * vxge_hw_vpath_msix_clear - Clear MSIX Vector.
- * @vp: Virtual Path handle.
- * @msix_id:  MSI ID
- *
- * The function clears the msix interrupt for the given msix_id
- *
- * Returns: 0,
- * Otherwise, VXGE_HW_ERR_WRONG_IRQ if the msix index is out of range
- * status.
- * See also:
- */
-void
-vxge_hw_vpath_msix_clear(struct __vxge_hw_vpath_handle *vp, int msix_id)
-{
-       struct __vxge_hw_device *hldev = vp->vpath->hldev;
-       if (hldev->config.intr_mode ==
-                       VXGE_HW_INTR_MODE_MSIX_ONE_SHOT) {
-               __vxge_hw_pio_mem_write32_upper(
-                       (u32)vxge_bVALn(vxge_mBIT(msix_id >> 2), 0, 32),
-                               &hldev->common_reg->
-                                       clr_msix_one_shot_vec[msix_id%4]);
-       } else {
-               __vxge_hw_pio_mem_write32_upper(
-                       (u32)vxge_bVALn(vxge_mBIT(msix_id >> 2), 0, 32),
-                               &hldev->common_reg->
-                                       clear_msix_mask_vect[msix_id%4]);
-       }
-}
-
-/**
  * vxge_hw_vpath_msix_unmask - Unmask the MSIX Vector.
  * @vp: Virtual Path handle.
  * @msix_id:  MSI ID
@@ -2316,22 +2254,6 @@ vxge_hw_vpath_msix_unmask(struct __vxge_hw_vpath_handle *vp, int msix_id)
 }

 /**
- * vxge_hw_vpath_msix_mask_all - Mask all MSIX vectors for the vpath.
- * @vp: Virtual Path handle.
- *
- * The function masks all msix interrupt for the given vpath
- *
- */
-void
-vxge_hw_vpath_msix_mask_all(struct __vxge_hw_vpath_handle *vp)
-{
-
-       __vxge_hw_pio_mem_write32_upper(
-               (u32)vxge_bVALn(vxge_mBIT(vp->vpath->vp_id), 0, 32),
-               &vp->vpath->hldev->common_reg->set_msix_mask_all_vect);
-}
-
-/**
  * vxge_hw_vpath_inta_mask_tx_rx - Mask Tx and Rx interrupts.
  * @vp: Virtual Path handle.
  *
diff --git a/drivers/net/vxge/vxge-traffic.h b/drivers/net/vxge/vxge-traffic.h
index 20fda17..35f8afc 100644
--- a/drivers/net/vxge/vxge-traffic.h
+++ b/drivers/net/vxge/vxge-traffic.h
@@ -1749,14 +1749,6 @@ vxge_hw_mrpcim_stats_access(
        u64 *stat);

 enum vxge_hw_status
-vxge_hw_device_xmac_aggr_stats_get(struct __vxge_hw_device *devh, u32 port,
-                                  struct vxge_hw_xmac_aggr_stats *aggr_stats);
-
-enum vxge_hw_status
-vxge_hw_device_xmac_port_stats_get(struct __vxge_hw_device *devh, u32 port,
-                                  struct vxge_hw_xmac_port_stats *port_stats);
-
-enum vxge_hw_status
 vxge_hw_device_xmac_stats_get(struct __vxge_hw_device *devh,
                              struct vxge_hw_xmac_stats *xmac_stats);

@@ -2089,49 +2081,6 @@ struct __vxge_hw_ring_rxd_priv {
 #endif
 };

-/* ========================= RING PRIVATE API ============================= */
-u64
-__vxge_hw_ring_first_block_address_get(
-       struct __vxge_hw_ring *ringh);
-
-enum vxge_hw_status
-__vxge_hw_ring_create(
-       struct __vxge_hw_vpath_handle *vpath_handle,
-       struct vxge_hw_ring_attr *attr);
-
-enum vxge_hw_status
-__vxge_hw_ring_abort(
-       struct __vxge_hw_ring *ringh);
-
-enum vxge_hw_status
-__vxge_hw_ring_reset(
-       struct __vxge_hw_ring *ringh);
-
-enum vxge_hw_status
-__vxge_hw_ring_delete(
-       struct __vxge_hw_vpath_handle *vpath_handle);
-
-/* ========================= FIFO PRIVATE API ============================= */
-
-struct vxge_hw_fifo_attr;
-
-enum vxge_hw_status
-__vxge_hw_fifo_create(
-       struct __vxge_hw_vpath_handle *vpath_handle,
-       struct vxge_hw_fifo_attr *attr);
-
-enum vxge_hw_status
-__vxge_hw_fifo_abort(
-       struct __vxge_hw_fifo *fifoh);
-
-enum vxge_hw_status
-__vxge_hw_fifo_reset(
-       struct __vxge_hw_fifo *ringh);
-
-enum vxge_hw_status
-__vxge_hw_fifo_delete(
-       struct __vxge_hw_vpath_handle *vpath_handle);
-
 struct vxge_hw_mempool_cbs {
        void (*item_func_alloc)(
                        struct vxge_hw_mempool *mempoolh,
@@ -2141,10 +2090,6 @@ struct vxge_hw_mempool_cbs {
                        u32                     is_last);
 };

-void
-__vxge_hw_mempool_destroy(
-       struct vxge_hw_mempool *mempool);
-
 #define VXGE_HW_VIRTUAL_PATH_HANDLE(vpath)                             \
                ((struct __vxge_hw_vpath_handle *)(vpath)->vpath_handles.next)

@@ -2167,61 +2112,10 @@ __vxge_hw_vpath_rts_table_set(
        u64                     data2);

 enum vxge_hw_status
-__vxge_hw_vpath_reset(
-       struct __vxge_hw_device *devh,
-       u32                     vp_id);
-
-enum vxge_hw_status
-__vxge_hw_vpath_sw_reset(
-       struct __vxge_hw_device *devh,
-       u32                     vp_id);
-
-enum vxge_hw_status
 __vxge_hw_vpath_enable(
        struct __vxge_hw_device *devh,
        u32                     vp_id);

-void
-__vxge_hw_vpath_prc_configure(
-       struct __vxge_hw_device *devh,
-       u32                     vp_id);
-
-enum vxge_hw_status
-__vxge_hw_vpath_kdfc_configure(
-       struct __vxge_hw_device *devh,
-       u32                     vp_id);
-
-enum vxge_hw_status
-__vxge_hw_vpath_mac_configure(
-       struct __vxge_hw_device *devh,
-       u32                     vp_id);
-
-enum vxge_hw_status
-__vxge_hw_vpath_tim_configure(
-       struct __vxge_hw_device *devh,
-       u32                     vp_id);
-
-enum vxge_hw_status
-__vxge_hw_vpath_initialize(
-       struct __vxge_hw_device *devh,
-       u32                     vp_id);
-
-enum vxge_hw_status
-__vxge_hw_vp_initialize(
-       struct __vxge_hw_device *devh,
-       u32                     vp_id,
-       struct vxge_hw_vp_config        *config);
-
-void
-__vxge_hw_vp_terminate(
-       struct __vxge_hw_device *devh,
-       u32                     vp_id);
-
-enum vxge_hw_status
-__vxge_hw_vpath_alarm_process(
-       struct __vxge_hw_virtualpath    *vpath,
-       u32                     skip_alarms);
-
 void vxge_hw_device_intr_enable(
        struct __vxge_hw_device *devh);

@@ -2293,11 +2187,6 @@ vxge_hw_vpath_vid_get(
        u64                     *vid);

 enum vxge_hw_status
-vxge_hw_vpath_vid_get_next(
-       struct __vxge_hw_vpath_handle *vpath_handle,
-       u64                     *vid);
-
-enum vxge_hw_status
 vxge_hw_vpath_vid_delete(
        struct __vxge_hw_vpath_handle *vpath_handle,
        u64                     vid);
@@ -2359,16 +2248,9 @@ vxge_hw_vpath_msix_mask(struct __vxge_hw_vpath_handle *vpath_handle,
 void vxge_hw_device_flush_io(struct __vxge_hw_device *devh);

 void
-vxge_hw_vpath_msix_clear(struct __vxge_hw_vpath_handle *vpath_handle,
-                        int msix_id);
-
-void
 vxge_hw_vpath_msix_unmask(struct __vxge_hw_vpath_handle *vpath_handle,
                          int msix_id);

-void
-vxge_hw_vpath_msix_mask_all(struct __vxge_hw_vpath_handle *vpath_handle);
-
 enum vxge_hw_status vxge_hw_vpath_intr_enable(
                                struct __vxge_hw_vpath_handle *vpath_handle);

@@ -2387,12 +2269,6 @@ vxge_hw_channel_msix_mask(struct __vxge_hw_channel *channelh, int msix_id);
 void
 vxge_hw_channel_msix_unmask(struct __vxge_hw_channel *channelh, int msix_id);

-enum vxge_hw_status
-vxge_hw_channel_dtr_alloc(struct __vxge_hw_channel *channel, void **dtrh);
-
-void
-vxge_hw_channel_dtr_post(struct __vxge_hw_channel *channel, void *dtrh);
-
 void
 vxge_hw_channel_dtr_try_complete(struct __vxge_hw_channel *channel,
                                 void **dtrh);
@@ -2408,18 +2284,4 @@ vxge_hw_channel_dtr_count(struct __vxge_hw_channel *channel);
 void
 vxge_hw_vpath_tti_ci_set(struct __vxge_hw_device *hldev, u32 vp_id);

-/* ========================== PRIVATE API ================================= */
-
-enum vxge_hw_status
-__vxge_hw_device_handle_link_up_ind(struct __vxge_hw_device *hldev);
-
-enum vxge_hw_status
-__vxge_hw_device_handle_link_down_ind(struct __vxge_hw_device *hldev);
-
-enum vxge_hw_status
-__vxge_hw_device_handle_error(
-               struct __vxge_hw_device *hldev,
-               u32 vp_id,
-               enum vxge_hw_event type);
-
 #endif

The information and any attached documents contained in this message
may be confidential and/or legally privileged.  The message is
intended solely for the addressee(s).  If you are not the intended
recipient, you are hereby notified that any use, dissemination, or
reproduction is strictly prohibited and may be unlawful.  If you are
not the intended recipient, please contact the sender immediately by
return e-mail and destroy all copies of the original message.

^ permalink raw reply related

* Re: [PATCH 0/1] RFC: poll/select performance on datagram sockets
From: Davide Libenzi @ 2010-10-29 21:57 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Alban Crequy, David S. Miller, Stephen Hemminger, Cyrill Gorcunov,
	Alexey Dobriyan, netdev, Linux Kernel Mailing List,
	Pauli Nieminen, Rainer Weikusat
In-Reply-To: <1288386348.2680.25.camel@edumazet-laptop>

On Fri, 29 Oct 2010, Eric Dumazet wrote:

> Following patch solves the problem for me, and its only a start, I am
> pretty sure we can optimize more than that.
> 
> What I did is to move "struct poll_wqueues table;" out of do_select()
> in its caller. This structure is highly modified by an other cpu in
> Alban workload, and this slow down do_select() because many accesses to
> some of its local variables (normally, private ones !) hit a false
> sharing.
> 
> Before :
> 
> # time /root/uclient connected
> The performance problem will be triggered
> select: begin
> select: end: 3 seconds
> 
> real	0m3.101s
> user	0m0.000s
> sys	0m6.104s
> 
> After :
> 
> # time /root/uclient connected
> The performance problem will be triggered
> select: begin
> select: end: 1 seconds
> 
> real	0m1.041s
> user	0m0.004s
> sys	0m2.040s
> 
> 
> Impressive no ?

It is, though I am not sure that shuffling code around to chase false 
sharing on very specific cases, is an approach worth following.
The new position of the table on the stack might share with another hot 
line, under a different load.


- Davide



^ permalink raw reply

* Re: [PATCH 0/1] RFC: poll/select performance on datagram sockets
From: Eric Dumazet @ 2010-10-29 22:08 UTC (permalink / raw)
  To: Davide Libenzi
  Cc: Alban Crequy, David S. Miller, Stephen Hemminger, Cyrill Gorcunov,
	Alexey Dobriyan, netdev, Linux Kernel Mailing List,
	Pauli Nieminen, Rainer Weikusat
In-Reply-To: <alpine.DEB.2.00.1010291451330.8517@davide-lnx1>

Le vendredi 29 octobre 2010 à 14:57 -0700, Davide Libenzi a écrit :

> It is, though I am not sure that shuffling code around to chase false 
> sharing on very specific cases, is an approach worth following.
> The new position of the table on the stack might share with another hot 
> line, under a different load.
> 

Sure. Its only a start as I said. We should identify the shared portion
and make sure it sits in a dedicated cache line.




^ permalink raw reply

* Re: [PATCH 0/15] RFC: create drivers/net/legacy for ISA, EISA, MCA drivers
From: Joe Perches @ 2010-10-29 22:08 UTC (permalink / raw)
  To: Paul Gortmaker; +Cc: davem, netdev, Jeff Kirsher
In-Reply-To: <4CCB3BF1.7070000@windriver.com>

On Fri, 2010-10-29 at 17:26 -0400, Paul Gortmaker wrote:
> On 10-10-28 09:48 PM, Joe Perches wrote:
> > On Thu, 2010-10-28 at 21:19 -0400, Paul Gortmaker wrote:
> >> The drivers/net dir has a lot of files - originally there were
> >> no subdirs, but at least now subdirs are being used effectively.
> >> But the original drivers from 10+ years ago are still right
> >> there at the top.  This series creates a drivers/net/legacy dir.
> > I like this idea.
> > I suggest a bit of a further grouping by using a
> > drivers/net/ethernet directory and putting those
> > legacy drivers in a new subdirectory
> > drivers/net/ethernet/legacy.
> That is a substantially larger change, since you'd now be
> relocating nearly every remaining driver, i.e. all the
> relatively modern 100M and GigE drivers.

Files to not need immediate renames.

Renames could happen when the appropriate maintainer
wants to or gets coerced to conform to some new
file layout standard.

I had submitted a related RFC patch:

https://patchwork.kernel.org/patch/244641/

and then had some off list discussions
with Jeff Kirsher from Intel.

Perhaps Jeff will chime in.

> Plus what do you
> do with the sb1000 - create drivers/cablemodem/legacy
> just for one file?

I never looked at that particular driver before.
Maybe.  I don't have a strong opinion.  Leaving
it where it is might be OK.

> Or the ethernet drivers already in
> existing subdirs, like arm and pcmcia -- do we move those?

Maybe.  If there's no demand, there's no absolute need to
move it at all.  I think a reasonable goal is to have some
sensible and consistent file layout scheme though.

There are arch specific directories under various drivers/...
so I don't see a need to move directories like drivers/net/arm
or drivers/s390.

> With this, I tried to aim for a significant gain (close to 1/3
> less files) within what I felt was a reasonable sized change
> set that had a chance of getting an overall OK from folks.
> Giant "flag-day" type mammoth changesets are a PITA for all.

I believe there's no need for a flag-day.
File renames could happen gradually or not at all.



^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox