Re: [PATCH 2.6.18-rc7 3/9] NetXen: hw initilization routines

2006-09-19 Thread Pradeep Dalvi

diff -u linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_init.c 
linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_init.c
--- linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_init.c   2006-09-15 
10:51:59.0 -0700
+++ linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_init.c   2006-09-19 
07:51:20.0 -0700
@@ -208,8 +208,8 @@
ops-handle_phy_intr = netxen_nic_gbe_handle_phy_intr;
ops-macaddr_set = netxen_niu_macaddr_set;
ops-set_mtu = netxen_nic_set_mtu_gb;
-   ops-set_promisc_mode = netxen_niu_set_promiscuous_mode;
-   ops-unset_promisc_mode = netxen_niu_set_promiscuous_mode;
+   ops-set_promisc = netxen_niu_set_promiscuous_mode;
+   ops-unset_promisc = netxen_niu_set_promiscuous_mode;
ops-phy_read = netxen_niu_gbe_phy_read;
ops-phy_write = netxen_niu_gbe_phy_write;
ops-init_port = netxen_niu_gbe_init_port;
@@ -225,8 +225,8 @@
ops-handle_phy_intr = netxen_nic_xgbe_handle_phy_intr;
ops-macaddr_set = netxen_niu_xg_macaddr_set;
ops-set_mtu = netxen_nic_set_mtu_xgb;
-   ops-set_promisc_mode = netxen_niu_xg_set_promiscuous_mode;
-   ops-unset_promisc_mode = netxen_niu_xg_set_promiscuous_mode;
+   ops-set_promisc = netxen_niu_xg_set_promiscuous_mode;
+   ops-unset_promisc = netxen_niu_xg_set_promiscuous_mode;
ops-stop_port = netxen_niu_disable_xg_port;
break;

@@ -535,8 +535,8 @@
struct netxen_recv_context *recv_ctx =
(adapter-recv_ctx[ctx]);
u32 consumer;
-   struct status_desc_t *desc_head;
-   struct status_desc_t *desc; /* used to read status desc 
here */
+   struct status_desc *desc_head;
+   struct status_desc *desc;   /* used to read status desc 
here */

consumer = recv_ctx-status_rx_consumer;
desc_head = recv_ctx-rcv_status_desc_head;
@@ -584,7 +584,7 @@
  */
 void
 netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
-  struct status_desc_t *desc)
+  struct status_desc *desc)
 {
struct netxen_port *port = adapter-port[STATUS_DESC_PORT(desc)];
struct pci_dev *pdev = port-pdev;
@@ -674,8 +674,8 @@
 u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
 {
struct netxen_recv_context *recv_ctx = (adapter-recv_ctx[ctxid]);
-   struct status_desc_t *desc_head = recv_ctx-rcv_status_desc_head;
-   struct status_desc_t *desc; /* used to read status desc here */
+   struct status_desc *desc_head = recv_ctx-rcv_status_desc_head;
+   struct status_desc *desc;   /* used to read status desc here */
u32 consumer = recv_ctx-status_rx_consumer;
int count = 0, ring;

@@ -829,9 +829,9 @@
__FUNCTION__);
 }

-/**
+/*
  * netxen_post_rx_buffers puts buffer in the Phantom memory
- **/
+ */
 void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 
ringid)
 {
struct pci_dev *pdev = adapter-ahw.pdev;
@@ -841,7 +841,7 @@
struct netxen_recv_crb *crbarea = recv_crb_registers[ctx];
struct netxen_rcv_desc_crb *rcv_desc_crb = NULL;
u32 producer;
-   struct rcv_desc_t *pdesc;
+   struct rcv_desc *pdesc;
struct netxen_rx_buffer *buffer;
int count = 0;
int index = 0;

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.18-rc7 2/9] NetXen: Hardware access routines

2006-09-19 Thread Pradeep Dalvi

diff -u linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_hw.c 
linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_hw.c
--- linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_hw.c 2006-09-15 
10:51:59.0 -0700
+++ linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_hw.c 2006-09-19 
07:51:20.0 -0700
@@ -44,7 +44,6 @@
 #define NETXEN_PHANTOM_MEM_BASE(NETXEN_FLASH_BASE)
 #define NETXEN_MAX_MTU 8000
 #define NETXEN_MIN_MTU  64
-#define NETXEN_MTU_MASK0x
 #define NETXEN_ETH_FCS_SIZE 4
 #define NETXEN_ENET_HEADER_SIZE 14
 #define NETXEN_WINDOW_ONE 0x200/* CRB Window: bit 25 of CRB address */
@@ -77,9 +76,9 @@
return 0;
 }

-/**
+/*
  * netxen_nic_set_multi - Multicast
- **/
+ */
 void netxen_nic_set_multi(struct net_device *netdev)
 {
struct netxen_port *port = netdev_priv(netdev);
@@ -89,15 +88,15 @@

mc_ptr = netdev-mc_list;
if (netdev-flags  IFF_PROMISC) {
-   if (adapter-ops-set_promisc_mode)
-   adapter-ops-set_promisc_mode(adapter,
-  port-portnum,
-  
NETXEN_NIU_PROMISCOUS_MODE);
+   if (adapter-ops-set_promisc)
+   adapter-ops-set_promisc(adapter,
+ port-portnum,
+ NETXEN_NIU_PROMISC_MODE);
} else {
-   if (adapter-ops-unset_promisc_mode)
-   adapter-ops-unset_promisc_mode(adapter,
-port-portnum,
-
NETXEN_NIU_NON_PROMISCOUS_MODE);
+   if (adapter-ops-unset_promisc)
+   adapter-ops-unset_promisc(adapter,
+   port-portnum,
+   
NETXEN_NIU_NON_PROMISC_MODE);
}
if (adapter-ahw.board_type == NETXEN_NIC_XGBE) {
netxen_nic_mcr_set_mode_select(netxen_mac_addr_cntl_data, 0x03);
@@ -136,31 +135,21 @@
  * netxen_nic_change_mtu - Change the Maximum Transfer Unit
  * @returns 0 on success, negative on failure
  */
-int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu)
+int netxen_nic_change_mtu(struct net_device *netdev, int mtu)
 {
struct netxen_port *port = netdev_priv(netdev);
-   int max_mtu = new_mtu + NETXEN_ENET_HEADER_SIZE + NETXEN_ETH_FCS_SIZE;
-
-   if (max_mtu  NETXEN_MTU_MASK)
-   return -EINVAL;
-
-   if (max_mtu  NETXEN_MAX_MTU) {
-   printk(KERN_ERR
-  %s: %s MTU  NETXEN_MAX_MTU is not supported\n,
-  netxen_nic_driver_name, netdev-name);
-   return -EINVAL;
-   }
+   struct netxen_adapter *adapter = port-adapter;
+   int eff_mtu = mtu + NETXEN_ENET_HEADER_SIZE + NETXEN_ETH_FCS_SIZE;

-   if (max_mtu  NETXEN_MIN_MTU) {
-   printk(KERN_ERR
-  %s: %s MTU  NETXEN_MIN_MTU is not supported\n,
-  netxen_nic_driver_name, netdev-name);
+   if ((eff_mtu  NETXEN_MAX_MTU) || (eff_mtu  NETXEN_MIN_MTU)) {
+   printk(KERN_ERR %s: %s %d is not supported.\n,
+  netxen_nic_driver_name, netdev-name, mtu);
return -EINVAL;
}

-   if (port-adapter-ops-set_mtu)
-   port-adapter-ops-set_mtu(port, new_mtu);
-   netdev-mtu = new_mtu;
+   if (adapter-ops-set_mtu)
+   adapter-ops-set_mtu(port, mtu);
+   netdev-mtu = mtu;

return 0;
 }
@@ -181,7 +170,7 @@
struct netxen_rcv_desc_crb *rcv_desc_crb = NULL;
struct netxen_recv_context *recv_ctx;
struct netxen_rcv_desc_ctx *rcv_desc;
-   struct cmd_desc_type0_t *pcmd;
+   struct cmd_desc_type0 *pcmd;

DPRINTK(INFO, pci_base: %lx\n, adapter-ahw.pci_base);
DPRINTK(INFO, crb_base: %lx %lx, NETXEN_PCI_CRBSPACE,
@@ -226,7 +215,7 @@
DPRINTK(INFO, Recieve Peg ready too. starting stuff\n);

addr = pci_alloc_consistent(adapter-ahw.pdev,
-   sizeof(struct cmd_desc_type0_t) *
+   sizeof(struct cmd_desc_type0) *
adapter-max_tx_desc_count,
hw-cmd_desc_phys_addr);
if (addr == NULL) {
@@ -236,16 +225,16 @@
}

/* we need to prelink all of the cmd descriptors */
-   pcmd = (struct cmd_desc_type0_t *)addr;
+   pcmd = (struct cmd_desc_type0 *)addr;
for (i = 1; i  adapter-max_tx_desc_count; i++) {
pcmd-netxen_next =
-   (card_cmdring + i * sizeof(struct cmd_desc_type0_t));
+   (card_cmdring + i * sizeof(struct cmd_desc_type0));
pcmd++;
}
/* fill in last 

Re: [PATCH 2.6.18-rc7 1/9] NetXen: Makefile and driver main file

2006-09-19 Thread Pradeep Dalvi

Randy,

Thanks for feedback. We have incorporated all of the suggestions.

--
pradeep

diff -u linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_main.c 
linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_main.c
--- linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_main.c   2006-09-15 
10:51:59.0 -0700
+++ linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_main.c   2006-09-19 
07:51:20.0 -0700
@@ -561,9 +561,9 @@
return 0;
 }

-/**
+/*
  * netxen_nic_close - Disables a network interface entry point
- **/
+ */
 static int netxen_nic_close(struct net_device *netdev)
 {
struct netxen_port *port = netdev_priv(netdev);
@@ -628,7 +628,7 @@

u32 producer = 0;
u32 saved_producer = 0;
-   struct cmd_desc_type0_t *hwdesc;
+   struct cmd_desc_type0 *hwdesc;
int k;
struct netxen_cmd_buffer *pbuf = NULL;
unsigned int tries = 0;
@@ -691,7 +691,7 @@
if (((skb-nh.iph)-ihl * sizeof(u32)) +
((skb-h.th)-doff * sizeof(u32)) +
sizeof(struct ethhdr) 
-   (sizeof(struct cmd_desc_type0_t) - NET_IP_ALIGN)) {
+   (sizeof(struct cmd_desc_type0) - NET_IP_ALIGN)) {
no_of_desc++;
}
}
@@ -733,7 +733,7 @@
producer = local_producer;
saved_producer = producer;
hwdesc = hw-cmd_desc_head[producer];
-   memset(hwdesc, 0, sizeof(struct cmd_desc_type0_t));
+   memset(hwdesc, 0, sizeof(struct cmd_desc_type0));
/* Take skb-data itself */
pbuf = adapter-cmd_buf_arr[producer];
if (skb_shinfo(skb)-gso_size  0) {
@@ -773,7 +773,7 @@
producer = get_next_index(producer,
  adapter-max_tx_desc_count);
hwdesc = hw-cmd_desc_head[producer];
-   memset(hwdesc, 0, sizeof(struct cmd_desc_type0_t));
+   memset(hwdesc, 0, sizeof(struct cmd_desc_type0));
}
frag = skb_shinfo(skb)-frags[i - 1];
len = frag-size;
@@ -819,9 +819,9 @@
if (hw-cmd_desc_head[saved_producer].opcode == TX_TCP_LSO) {
int hdr_len, first_hdr_len, more_hdr;
hdr_len = hw-cmd_desc_head[saved_producer].total_hdr_length;
-   if (hdr_len  (sizeof(struct cmd_desc_type0_t) - NET_IP_ALIGN)) 
{
+   if (hdr_len  (sizeof(struct cmd_desc_type0) - NET_IP_ALIGN)) {
first_hdr_len =
-   sizeof(struct cmd_desc_type0_t) - NET_IP_ALIGN;
+   sizeof(struct cmd_desc_type0) - NET_IP_ALIGN;
more_hdr = 1;
} else {
first_hdr_len = hdr_len;
@@ -964,11 +964,11 @@
return ret;
 }

-/**
+/*
  * netxen_intr - Interrupt Handler
  * @irq: interrupt number
  * data points to adapter stucture (which may be handling more than 1 port
- **/
+ */
 irqreturn_t netxen_intr(int irq, void *data, struct pt_regs * regs)
 {
struct netxen_adapter *adapter;

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.18-rc7 5/9] NetXen: ethtool interface

2006-09-19 Thread Pradeep Dalvi

diff -u linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_ethtool.c 
linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_ethtool.c
--- linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_ethtool.c2006-09-15 
10:51:59.0 -0700
+++ linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_ethtool.c2006-09-19 
07:51:20.0 -0700
@@ -115,7 +115,7 @@
uint32_t fw_minor = 0;
uint32_t fw_build = 0;

-   strncpy(drvinfo-driver, NetXen, 32);
+   strncpy(drvinfo-driver, netxen_nic, 32);
strncpy(drvinfo-version, NETXEN_NIC_LINUX_VERSIONID, 32);
fw_major = readl(NETXEN_CRB_NORMALIZE(adapter,
  NETXEN_FW_VERSION_MAJOR));
@@ -551,7 +551,7 @@
return 0;
}

-   /* netxen_niu_gb_mii_mgmt_indicators_t is read only */
+   /* netxen_niu_gb_mii_mgmt_indicators is read only */
netxen_nic_read_w0(adapter,
   NETXEN_NIU_GB_MII_MGMT_INDICATE(port-
   portnum),
@@ -579,7 +579,7 @@
return 0;
}

-   /* netxen_niu_gb_interface_status_t is read only */
+   /* netxen_niu_gb_interface_status is read only */
netxen_nic_read_w0(adapter,
   NETXEN_NIU_GB_INTERFACE_STATUS(port-
  portnum),

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.18-rc7 4/9] NetXen: intr routines and niu handling

2006-09-19 Thread Pradeep Dalvi

diff -u linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_niu.c 
linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_niu.c
--- linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_niu.c2006-09-15 
10:51:59.0 -0700
+++ linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_niu.c2006-09-19 
07:51:20.0 -0700
@@ -34,7 +34,7 @@
 #include netxen_nic.h
 #include linux/delay.h

-/** 
+/*

  * netxen_niu_gbe_phy_read - read a register from the GbE PHY via
  * mii management interface.
  *
@@ -46,7 +46,7 @@
  * @returns  0 on success
  *  -1 on error
  *
- **/
+ */
 int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy,
long reg, __le32 * readval)
 {
@@ -134,7 +134,7 @@
return result;
 }

-/** 
+/*

  * netxen_niu_gbe_phy_write - write a register to the GbE PHY via
  * mii management interface.
  *
@@ -146,7 +146,7 @@
  * @returns  0 on success
  *  -1 on error
  *
- **/
+ */
 int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter,
 long phy, long reg, __le32 val)
 {
@@ -282,10 +282,10 @@
return result;
 }

-/** 
+/*

  * netxen_niu_gbe_set_mii_mode- Set 10/100 Mbit Mode for GbE MAC
  *
- **/
+ */
 void netxen_niu_gbe_set_mii_mode(struct netxen_adapter *adapter,
 int port, long enable)
 {
@@ -321,9 +321,9 @@
printk(KERN_ERR PFX ERROR clearing PHY interrupts\n);
 }

-/** 
+/*

  * netxen_niu_gbe_set_gmii_mode- Set GbE Mode for GbE MAC
- **/
+ */
 void netxen_niu_gbe_set_gmii_mode(struct netxen_adapter *adapter,
  int port, long enable)
 {
@@ -407,11 +407,11 @@
return result;
 }

-/** 
+/*

  * netxen_niu_gbe_handle_phy_interrupt - Handles GbE PHY interrupts
  * @param enable 0 means don't enable the port
  *   1 means enable (or re-enable) the port
- **/
+ */
 int netxen_niu_gbe_handle_phy_interrupt(struct netxen_adapter *adapter,
int port, long enable)
 {
@@ -500,10 +500,10 @@
return result;
 }

-/**
+/*
  * Return the current station MAC address.
  * Note that the passed-in value must already be in network byte order.
- **/
+ */
 int netxen_niu_macaddr_get(struct netxen_adapter *adapter,
   int phy, netxen_ethernet_macaddr_t * addr)
 {
@@ -530,10 +530,10 @@
return 0;
 }

-/**
+/*
  * Set the station MAC address.
  * Note that the passed-in value must already be in network byte order.
- **/
+ */
 int netxen_niu_macaddr_set(struct netxen_port *port,
   netxen_ethernet_macaddr_t addr)
 {
@@ -680,7 +680,7 @@
if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR,
  reg, 4))
return -EIO;
-   if (mode == NETXEN_NIU_PROMISCOUS_MODE) {
+   if (mode == NETXEN_NIU_PROMISC_MODE) {
switch (port) {
case 0:
netxen_clear_gb_drop_gb0(reg);
@@ -721,10 +721,10 @@
return 0;
 }

-/**
+/*
  * Set the MAC address for an XG port
  * Note that the passed-in value must already be in network byte order.
- **/
+ */
 int netxen_niu_xg_macaddr_set(struct netxen_port *port,
  netxen_ethernet_macaddr_t addr)
 {
@@ -749,10 +749,10 @@
return 0;
 }

-/**
+/*
  * Return the current station MAC address.
  * Note that the passed-in value must already be in network byte order.
- **/
+ */
 int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter, int phy,
  netxen_ethernet_macaddr_t * addr)
 {
@@ -789,7 +789,7 @@

if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_XGE_CONFIG_1, reg, 4))
return -EIO;
-   if (mode == NETXEN_NIU_PROMISCOUS_MODE)
+   if (mode == NETXEN_NIU_PROMISC_MODE)
reg = (reg | 0x2000UL);
else
reg = (reg  ~0x2000UL);

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.18-rc7 6/9] NetXen: Main header file

2006-09-19 Thread Pradeep Dalvi

diff -u linux-2.6.18-rc7/drivers/net/netxen/netxen_nic.h 
linux-2.6.18-rc7/drivers/net/netxen/netxen_nic.h
--- linux-2.6.18-rc7/drivers/net/netxen/netxen_nic.h2006-09-15 
10:51:59.0 -0700
+++ linux-2.6.18-rc7/drivers/net/netxen/netxen_nic.h2006-09-19 
07:51:20.0 -0700
@@ -62,8 +62,6 @@
 #include asm/uaccess.h
 #include asm/pgtable.h

-#include linux/skbuff.h
-
 #include netxen_nic_hw.h

 #define NETXEN_NIC_BUILD_NO 232
@@ -74,9 +72,9 @@
 #define NETXEN_NIC_FW_VERSIONID 2.3.57

 #define RCV_DESC_RINGSIZE  \
-   (sizeof(struct rcv_desc_t) * adapter-max_rx_desc_count)
+   (sizeof(struct rcv_desc) * adapter-max_rx_desc_count)
 #define STATUS_DESC_RINGSIZE   \
-   (sizeof(struct status_desc_t)* adapter-max_rx_desc_count)
+   (sizeof(struct status_desc)* adapter-max_rx_desc_count)
 #define TX_RINGSIZE\
(sizeof(struct netxen_cmd_buffer) * adapter-max_tx_desc_count)
 #define RCV_BUFFSIZE   \
@@ -158,7 +156,7 @@
 #define MAX_RCV_DESC   MAX_RCV_DESCRIPTORS
 #define MAX_RCVSTATUS_DESC MAX_RCV_DESCRIPTORS
 #define NUM_RCV_DESC   (MAX_RCV_DESC + MAX_JUMBO_RCV_DESCRIPTORS)
-#define MAX_EPG_DESCRIPTORSMAX_CMD_DESCRIPTORS * 8
+#define MAX_EPG_DESCRIPTORS(MAX_CMD_DESCRIPTORS * 8)

 #define MIN_TX_COUNT   4096
 #define MIN_RX_COUNT   4096
@@ -174,16 +172,16 @@
 #define get_index_range(index,length,count)\
(((index) + (count))  ((length) - 1))

-/**
+/*
  * Following data structures describe the descriptors that will be used.
  * Added fileds of tcpHdrSize and ipHdrSize, The driver needs to do it only 
when
  * we are doing LSO (above the 1500 size packet) only.
- **/
+ */

-/**
+/*
  * The size of reference handle been changed to 16 bits to pass the MSS fields
  * for the LSO packet
- **/
+ */

 #define FLAGS_CHECKSUM_ENABLED 0x01
 #define FLAGS_LSO_ENABLED  0x02
@@ -205,7 +203,7 @@
 #define CMD_DESC_PORT_WRT(cmd_desc, var)   \
((cmd_desc)-port_ctxid |= ((var)  0x0F))

-struct cmd_desc_type0_t {
+struct cmd_desc_type0 {
u64 netxen_next;/* for fragments handled by Phantom */
union {
struct {
@@ -261,22 +259,22 @@
 } __attribute__ ((aligned(64)));

 /* Note: sizeof(rcv_desc) should always be a mutliple of 2 */
-struct rcv_desc_t {
+struct rcv_desc {
u16 reference_handle;
u16 reserved;
u32 buffer_length;  /* allocated buffer length (usually 2K) */
u64 addr_buffer;
 };

-/* opcode field in status_desc_t */
+/* opcode field in status_desc */
 #define RCV_NIC_PKT(0xA)
 #define STATUS_NIC_PKT ((RCV_NIC_PKT)  12)

-/* for status field in status_desc_t */
+/* for status field in status_desc */
 #define STATUS_NEED_CKSUM  (1)
 #define STATUS_CKSUM_OK(2)

-/* owner bits of status_desc_t */
+/* owner bits of status_desc */
 #define STATUS_OWNER_HOST  (0x1)
 #define STATUS_OWNER_PHANTOM   (0x2)

@@ -293,7 +291,7 @@
 #define STATUS_DESC_OPCODE(status_desc)\
(((status_desc)-port_status_type_op  12)  0x0F)

-struct status_desc_t {
+struct status_desc {
/* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-15 opcode */
u16 port_status_type_op;
u16 total_length;   /* NIC mode */
@@ -625,7 +623,7 @@
struct netxen_board_info boardcfg;
u32 xg_linkup;
/* Address of cmd ring in Phantom */
-   struct cmd_desc_type0_t *cmd_desc_head;
+   struct cmd_desc_type0 *cmd_desc_head;
dma_addr_t cmd_desc_phys_addr;
struct netxen_adapter *adapter;
 };
@@ -657,7 +655,7 @@
u32 rcv_pending;/* Num of bufs posted in phantom */
u32 rcv_free;   /* Num of bufs in free list */
dma_addr_t phys_addr;
-   struct rcv_desc_t *desc_head;   /* address of rx ring in Phantom */
+   struct rcv_desc *desc_head; /* address of rx ring in Phantom */
u32 max_rx_desc_count;
u32 dma_size;
u32 skb_size;
@@ -676,14 +674,13 @@
u32 status_rx_producer;
u32 status_rx_consumer;
dma_addr_t rcv_status_desc_phys_addr;
-   struct status_desc_t *rcv_status_desc_head;
+   struct status_desc *rcv_status_desc_head;
 };

 #define NETXEN_NIC_MSI_ENABLED 0x02

 struct netxen_drvops;

-/* this structure by all ports on the adapter */
 struct netxen_adapter {
struct netxen_hardware_context ahw;
int port_count; /* Number of configured ports  */
@@ -776,10 +773,10 @@
void (*handle_phy_intr) (struct netxen_adapter *);
int (*macaddr_set) (struct netxen_port *, netxen_ethernet_macaddr_t);
int (*set_mtu) (struct netxen_port *, int);
-   int (*set_promisc_mode) (struct netxen_adapter *, int,
-netxen_niu_prom_mode_t);
-   int (*unset_promisc_mode) (struct netxen_adapter *, int,
-  netxen_niu_prom_mode_t);
+   int (*set_promisc) (struct netxen_adapter *, int,
+

Re: [PATCH 2.6.18-rc7 7/9] NetXen: hw access routines header file

2006-09-19 Thread Pradeep Dalvi

diff -u linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_hw.h 
linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_hw.h
--- linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_hw.h 2006-09-15 
10:51:59.0 -0700
+++ linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_hw.h 2006-09-19 
07:51:20.0 -0700
@@ -368,8 +368,8 @@

 /* Promiscous mode options (GbE mode only) */
 typedef enum {
-   NETXEN_NIU_PROMISCOUS_MODE = 0,
-   NETXEN_NIU_NON_PROMISCOUS_MODE
+   NETXEN_NIU_PROMISC_MODE = 0,
+   NETXEN_NIU_NON_PROMISC_MODE
 } netxen_niu_prom_mode_t;

 /*
@@ -415,7 +415,20 @@
 #define netxen_xg_soft_reset(config_word)  \
set_bit(4, (unsigned long*)config_word)

-/* Structure  unm_mac_addr_cntl_t for MAC CONTROL REGISTER */
+/*
+ * MAC Control Register
+ * 
+ * Bit 0-1   : id_pool0

+ * Bit 2 : enable_xtnd0
+ * Bit 4-5   : id_pool1
+ * Bit 6 : enable_xtnd1
+ * Bit 8-9   : id_pool2
+ * Bit 10: enable_xtnd2
+ * Bit 12-13 : id_pool3
+ * Bit 14: enable_xtnd3
+ * Bit 24-25 : mode_select
+ * Bit 28-31 : enable_pool
+ */

 #define netxen_nic_mcr_set_id_pool0(config, val)   \
((config) |= ((val) 0x03))
@@ -436,7 +449,7 @@
 #define netxen_nic_mcr_set_mode_select(config, val)\
((config) |= (((val)  0x03)  24))
 #define netxen_nic_mcr_set_enable_pool(config, val)\
-   ((config) |= (((val)  0x0f)  26))
+   ((config) |= (((val)  0x0f)  28))

 /* Set promiscuous mode for a GbE interface */
 int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter, int port,
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.18-rc7 9/9] NetXen: CRB reg definitions

2006-09-19 Thread Pradeep Dalvi

diff -u linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_phan_reg.h 
linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_phan_reg.h
--- linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_phan_reg.h   2006-09-15 
10:51:59.0 -0700
+++ linux-2.6.18-rc7/drivers/net/netxen/netxen_nic_phan_reg.h   2006-09-19 
07:51:20.0 -0700
@@ -30,26 +30,26 @@
 #ifndef __NIC_PHAN_REG_H_
 #define __NIC_PHAN_REG_H_

-/** 
- * CRB Registers or queue message done only at initialization time

- **/
+/* 
+ * CRB Registers or queue message done only at initialization time.

+ */

-/**
+/*
  * The following 2 are the base adresses for the CRB registers and their
- * offsets will be added to get addresses for the index addresses...
- **/
+ * offsets will be added to get addresses for the index addresses.
+ */
 #define NIC_CRB_BASE_PORT1 NETXEN_CAM_RAM(0x200)
 #define NIC_CRB_BASE_PORT2 NETXEN_CAM_RAM(0x250)

 #define NETXEN_NIC_REG(X)  (NIC_CRB_BASE_PORT1+(X))

-/**
+/*
  * CrbPortPhanCntrHi/Lo is used to pass the address of HostPhantomIndex address
  * which can be read by the Phantom host to get producer/consumer indexes from
  * Phantom/Casper. If it is not HOST_SHARED_MEMORY, then the following
  * registers will be used for the addresses of the ring's shared memory
  * on the Phantom.
- **/
+ */

 #define CRB_PHAN_CNTRL_LO_OFFSET   NETXEN_NIC_REG(0x00)
 #define CRB_PHAN_CNTRL_HI_OFFSET   NETXEN_NIC_REG(0x04)

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.17 0/9] NetXen: 1G/10G Ethernet Driver

2006-09-13 Thread Pradeep Dalvi

Jeff,

Thanks for your comments.  We are incorporating these suggestions and will 
resubmit an updated driver asap.


--
pradeep

On Tue, 12 Sep 2006, Jeff Garzik wrote:


More updates needed:

1) diff against 2.6.18-rcX (currently -rc6)

2) remove ifdefs around NETIF_F_TSO

3) remove ifdefs around CONFIG_PCI_MSI

4) during initial allocation of port struct, the following line is completely 
superfluous:


port-flags = ~NETXEN_NETDEV_STATUS

5) netxen_nic_set_multi() does not have any multi-cast filter update code

6) remove impossible checks such as the following in nic_set_promise_mode:

+   if ((phy  0) || (phy  3))
+   return -1;

7) the following line in nic_set_mtu requires explanation, or fixing:

+   case NETXEN_NIC_XGBE:
+   new_mtu += 100; /* so that MAC accepts frames  MTU */

8) never call udelay() with a number = 1000.  use mdelay()

9) [major] a great many functions simply do

netxen_nic_do_blah()
  case NETXEN_NIC_GBE:
netxen_nic_do_blah_gbe()
break;

  case NETXEN_NIC_XGBE:
netxen_nic_do_blah_xgbe()
break;

This is silly and makes the code needlessly larger and needlessly slower. 
Modularize the driver to avoid all such functions.


10) don't cast iounmap argument to u8*

11) don't case to/from void*, particularly where you accidentally drop the 
__iomem marker:


+   addr = (void *)(adapter-ahw.pci_base + off);

12) make sure the driver passes sparse checks.  Read Documentation/sparse.txt

13) __iomem markers missing in NETXEN_NIC_HW_BLOCK_WRITE_64, 
NETXEN_NIC_HW_BLOCK_READ_64


14) If you need a 'void __iomem *' cast in the following macros, there is a 
type definition bug somewhere:



+#define NETXEN_NIC_LOCKED_READ_REG(X, Y)   \
+   addr = (void __iomem *)(adapter-ahw.pci_base + X); \
+   *(u32 *)Y = readl(addr);
+
+#define NETXEN_NIC_LOCKED_WRITE_REG(X, Y)  \
+   addr = (void __iomem *)(adapter-ahw.pci_base + X); \
+   writel(*(u32 *)Y, addr);
+

15) implement NETXEN_NIC_LOCKED_READ_REG, NETXEN_NIC_LOCKED_WRITE_REG, 
NETXEN_NIC_HW_BLOCK_WRITE_64, NETXEN_NIC_HW_BLOCK_READ_64 as static inline 
functions rather than macros for greater type safety


16) don't invent your own set_bit, clear_bit, etc:  _netxen_crb_set_bit

17) don't needlessly invent new types such as
+typedef __le32 netxen_crbword_t;   /* single word in CRB space */

18) The strings in netxen_nic_gstrings_test[] should be easily 
computer-parseable.  Eliminate parens, spaces


19) eliminate magic numbers (replace with named constants) in, e.g.

+   if ((netxen_rom_fast_read(adapter, 0, n) == 0)  (n  0x8000)) 
{

+   n = ~0x8000;
+   if (n  1024)

20) use the short driver name (commonly DRV_NAME constant in other drivers) 
in ETHTOOL_GDRVINFO:

+   strncpy(drvinfo-driver, NetXen NIC Driver, 32);

21) export the real firmware version in ETHTOOL_GDRVINFO:
+   strncpy(drvinfo-fw_version, NETXEN_NIC_FW_VERSIONID, 32);

22) netxen_nic_set_settings() simply returns success if the NIC is XGBE, 
which is obviously wrong


23) bogus return value -1 in netxen_nic_get_eeprom()

24) -EOPNOTSUPP would seem to be a much better return value for XGBE in 
netxen_nic_set_pauseparam()


25) netxen_nic_change_mtu() should check minimum MTU too

26) long delays should be sleeping, not spinning the CPU and locking out 
other tasks:


+   udelay(1);



I stopped reviewing here.  That should keep you busy...

Jeff






-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.17 0/9] NetXen: 1G/10G Ethernet Driver

2006-09-01 Thread Pradeep Dalvi

Hi,

This entire patch is available at,
http://www.netxen.com/products/downloads/netxen-2.6.17.patch.zip

Thanks,
pradeep

On Thu, 31 Aug 2006, Amit S. Kale wrote:


Hi All,

Thank you Stephen, Don and Wendy.
We have incorporated feedbacks which have received since after last post. 
I'll be resending updated patchset in subsequent emails.


We are working on finding out good way of using tables to manage 
compatibility between firmware version number and driver version number.


Kindly review it and feel free to send feedback.

Thanks,
-Amit

Signed-off-by: Amit S. Kale [EMAIL PROTECTED]

MAINTAINERS  |7
drivers/net/Kconfig  |5
drivers/net/Makefile |1
drivers/net/netxen/Makefile  |   35
drivers/net/netxen/netxen_nic.h  |  901 +
drivers/net/netxen/netxen_nic_ethtool.c  |  696 +++
drivers/net/netxen/netxen_nic_hdr.h  |  611 +
drivers/net/netxen/netxen_nic_hw.c   | 1102 
++

drivers/net/netxen/netxen_nic_hw.h   |  499 +
drivers/net/netxen/netxen_nic_init.c | 1089 
++

drivers/net/netxen/netxen_nic_ioctl.h|   75 ++
drivers/net/netxen/netxen_nic_isr.c  |  301 
drivers/net/netxen/netxen_nic_main.c | 1107 
+++

drivers/net/netxen/netxen_nic_niu.c  |  779 +
drivers/net/netxen/netxen_nic_phan_reg.h |  195 +
15 files changed, 7403 insertions(+)




-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.17 0/9] NetXen: 1G/10G Ethernet Driver

2006-08-22 Thread Pradeep Dalvi

Hi,

This updated patch with name prefix changes is available for download at,
http://www.netxen.com/products/downloads/netxen-2.6.17.patch.zip

Thanks and regards,
pradeep

On Fri, 18 Aug 2006, Amit S. Kale wrote:


Hi,

I'll be sending a NetXen Multi port 1G/10G ethernet driver patch in 
subsequent emails. This set of patches have changes as per the suggestions, 
which we received since last post.


Kindly review it and feel free to send feedback.

Thanks,
-Amit

Signed-off-by: Amit S. Kale [EMAIL PROTECTED]

MAINTAINERS  |7
drivers/net/Kconfig  |5
drivers/net/Makefile |1
drivers/net/netxen/Makefile  |   35
drivers/net/netxen/netxen_nic.h  |  901 +
drivers/net/netxen/netxen_nic_ethtool.c  |  696 +++
drivers/net/netxen/netxen_nic_hdr.h  |  611 +
drivers/net/netxen/netxen_nic_hw.c   | 1097 
++

drivers/net/netxen/netxen_nic_hw.h   |  500 ++
drivers/net/netxen/netxen_nic_init.c | 1090 
++

drivers/net/netxen/netxen_nic_ioctl.h|   75 ++
drivers/net/netxen/netxen_nic_isr.c  |  300 
drivers/net/netxen/netxen_nic_main.c | 1107 
+++

drivers/net/netxen/netxen_nic_niu.c  |  778 +
drivers/net/netxen/netxen_nic_phan_reg.h |  195 +
15 files changed, 7398 insertions(+)




-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.17 2/9] NetXen: Hardware access routines (name prefixed)

2006-08-21 Thread Pradeep Dalvi


diff -u linux-2.6.17/drivers/net/netxen/netxen_nic_hw.c 
linux-2.6.17/drivers/net/netxen/netxen_nic_hw.c
--- linux-2.6.17/drivers/net/netxen/netxen_nic_hw.c 2006-08-17 
07:12:34.0 -0700
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_hw.c 2006-08-21 
02:20:00.0 -0700
@@ -317,9 +317,9 @@
adapter-stats.xmitcsummed++;
 }

-int is_flash_supported(struct netxen_adapter *adapter)
+int netxen_is_flash_supported(struct netxen_adapter *adapter)
 {
-   int locs[] = { 0, 0x4, 0x100, 0x4000, 0x4128 };
+   const int locs[] = { 0, 0x4, 0x100, 0x4000, 0x4128 };
int addr, val01, val02, i, j;

/* if the flash size less than 4Mb, make huge war cry and die */
@@ -364,7 +364,7 @@
return 0;
 }

-int get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[])
+int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[])
 {
u32 *pmac = (u32 *)  mac[0];

@@ -430,7 +430,7 @@
adapter-curr_window = wndw;
 }

-void load_firmware(struct netxen_adapter *adapter)
+void netxen_load_firmware(struct netxen_adapter *adapter)
 {
int i;
long data, size = 0;



On Fri, 18 Aug 2006, Stephen Hemminger wrote:



Way to many DPRINTK()'s


+
+int is_flash_supported(struct netxen_adapter *adapter)


needs to be static or prefixed.


+{
+   int locs[] = { 0, 0x4, 0x100, 0x4000, 0x4128 };


use const


+   int addr, val01, val02, i, j;
+
+   /* if the flash size less than 4Mb, make huge war cry and die */
+   for (j = 1; j  4; j++) {
+   addr = j * 0x10;
+   for (i = 0; i  (sizeof(locs) / sizeof(locs[0])); i++) {
+   if (netxen_rom_fast_read(adapter, locs[i], val01) == 0
+netxen_rom_fast_read(adapter, (addr + locs[i]),
+   val02) == 0) {
+   if (val01 == val02)
+   return -1;
+   } else
+   return -1;
+   }
+   }
+
+   return 0;
+}
+
+static int netxen_get_flash_block(struct netxen_adapter *adapter, int base,
+ int size, u32 * buf)
+{
+   int i, addr;
+   u32 *ptr32;
+
+   addr = base;
+   ptr32 = buf;
+   for (i = 0; i  size / sizeof(u32); i++) {
+   if (netxen_rom_fast_read(adapter, addr, ptr32) == -1)
+   return -1;
+   ptr32++;
+   addr += sizeof(u32);
+   }
+   if ((char *)buf + size  (char *)ptr32) {
+   u32 local;
+
+   if (netxen_rom_fast_read(adapter, addr, local) == -1)
+   return -1;
+   memcpy(ptr32, local, (char *)buf + size - (char *)ptr32);
+   }
+
+   return 0;
+}
+
+int get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[])


static int get_flash_mac_addr()..
+

+void load_firmware(struct netxen_adapter *adapter)


also must be static


+{
+   int i;
+   long data, size = 0;
+   long flashaddr = NETXEN_FLASH_BASE, memaddr = NETXEN_PHANTOM_MEM_BASE;
+   u64 off;
+   ptrdiff_t addr;
+
+   size = (16 * 1024) / 4;
+   writel(1, NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_CAS_RST));
+
+   for (i = 0; i  size; i++) {
+   if (netxen_rom_fast_read(adapter, flashaddr, (int *)data) != 
0) {
+   DPRINTK(ERR,
+   Error in netxen_rom_fast_read(). Will skip
+   loading flash image\n);
+   return;
+   }
+   off = netxen_nic_pci_set_window(adapter-ahw.pci_base, memaddr);
+   addr = (ptrdiff_t) (adapter-ahw.pci_base + off);
+   writel(data, (void __iomem *)addr);
+   flashaddr += 4;
+   memaddr += 4;
+   }
+   udelay(100);
+   /* make sure Casper is powered on */
+   writel(0x3fff,
+  NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_CHIP_CLK_CTRL));
+   writel(0, NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_CAS_RST));
+
+   udelay(1);
+}
+
+int
+netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data,
+  int len)
+{
+   void __iomem * addr;
+
+   if (ADDR_IN_WINDOW1(off)) {
+   addr = NETXEN_CRB_NORMALIZE(adapter, off);
+   } else {/* Window 0 */
+   addr = (void *)(ptrdiff_t) (adapter-ahw.pci_base + off);
+   netxen_nic_pci_change_crbwindow(adapter, 0);
+   }
+
+   DPRINTK(INFO, writing to base %lx offset %llx addr %p
+data %llx len %d\n,
+   adapter-ahw.pci_base, off, addr,
+   *(unsigned long long *)data, len);
+   switch (len) {
+   case 1:
+   writeb(*(u8 *) data, addr);
+   break;
+   case 2:
+   writew(*(u16 *) data, addr);
+

Re: [PATCH 2.6.17 1/9] NetXen: Makefile and driver main file (name prefix change)

2006-08-21 Thread Pradeep Dalvi

diff -u linux-2.6.17/drivers/net/netxen/netxen_nic_main.c 
linux-2.6.17/drivers/net/netxen/netxen_nic_main.c
--- linux-2.6.17/drivers/net/netxen/netxen_nic_main.c   2006-08-17 
07:12:34.0 -0700
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_main.c   2006-08-21 
02:20:00.0 -0700
@@ -211,8 +211,8 @@
adapter-ahw.pci_base = mem_ptr;
spin_lock_init(adapter-tx_lock);
spin_lock_init(adapter-lock);
-
-   initialize_adapter_sw(adapter); /* initialize the buffers in adapter */
+   /* initialize the buffers in adapter */
+   netxen_initialize_adapter_sw(adapter);
/*
 * Set the CRB window to invalid. If any register in window 0 is
 * accessed it should set the window to 0 and then reset it to 1.
@@ -222,7 +222,7 @@
 *  Adapter in our case is quad port so initialize it before
 *  initializing the ports
 */
-   initialize_adapter_hw(adapter); /* initialize the adapter */
+   netxen_initialize_adapter_hw(adapter);  /* initialize the adapter */

init_timer(adapter-watchdog_timer);
adapter-ahw.xg_linkup = 0;
@@ -243,8 +243,8 @@
adapter-flags |= NETXEN_NIC_MSI_ENABLED;
 #endif

-   if (is_flash_supported(adapter) == 0 
-   get_flash_mac_addr(adapter, mac_addr) == 0)
+   if (netxen_is_flash_supported(adapter) == 0 
+   netxen_get_flash_mac_addr(adapter, mac_addr) == 0)
valid_mac = 1;
else
valid_mac = 0;
@@ -345,7 +345,7 @@
writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET));
writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO));

-   phantom_init(adapter);
+   netxen_phantom_init(adapter);
/*
 * delay a while to ensure that the Pegs are up  running.
 * Otherwise, we might see some flaky behaviour.
@@ -423,9 +423,9 @@

netxen_nic_stop_all_ports(adapter);
/* leave the hw in the same state as reboot */
-   pinit_from_rom(adapter, 0);
+   netxen_pinit_from_rom(adapter, 0);
udelay(500);
-   load_firmware(adapter);
+   netxen_load_firmware(adapter);

if ((adapter-flags  NETXEN_NIC_MSI_ENABLED))
netxen_nic_disable_int(adapter);
@@ -486,7 +486,7 @@
int ctx, ring;

if (adapter-is_up != NETXEN_ADAPTER_UP_MAGIC) {
-   err = init_firmware(adapter);
+   err = netxen_init_firmware(adapter);
if (err != 0) {
printk(KERN_ERR Failed to init firmware\n);
return -EIO;

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.17 3/9] NetXen: hw initialization routines (name prefix change)

2006-08-21 Thread Pradeep Dalvi

diff -u linux-2.6.17/drivers/net/netxen/netxen_nic_init.c 
linux-2.6.17/drivers/net/netxen/netxen_nic_init.c
--- linux-2.6.17/drivers/net/netxen/netxen_nic_init.c   2006-08-17 
07:12:34.0 -0700
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_init.c   2006-08-21 
02:20:00.0 -0700
@@ -103,7 +103,7 @@
crb_addr_transform(C2C0);
 }

-int init_firmware(struct netxen_adapter *adapter)
+int netxen_init_firmware(struct netxen_adapter *adapter)
 {
u32 state = 0, loops = 0, err = 0;

@@ -133,7 +133,7 @@
return err;
 }

-void initialize_adapter_sw(struct netxen_adapter *adapter)
+void netxen_initialize_adapter_sw(struct netxen_adapter *adapter)
 {
int ctxid, ring;
u32 i;
@@ -167,7 +167,7 @@
adapter-free_cmd_buf_list, adapter-free_rxbuf);
 }

-void initialize_adapter_hw(struct netxen_adapter *adapter)
+void netxen_initialize_adapter_hw(struct netxen_adapter *adapter)
 {
if (netxen_nic_get_board_info(adapter) != 0)
printk(%s: Error getting board config info.\n,
@@ -218,7 +218,7 @@
 static long rom_max_timeout = 1;
 static long rom_lock_timeout = 100;

-int rom_lock(struct netxen_adapter *adapter)
+static inline int rom_lock(struct netxen_adapter *adapter)
 {
int iter;
u32 done = 0;
@@ -248,7 +248,7 @@
return 0;
 }

-void rom_unlock(struct netxen_adapter *adapter)
+static inline void rom_unlock(struct netxen_adapter *adapter)
 {
u32 val;

@@ -274,7 +274,8 @@
return 0;
 }

-int do_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp)
+static inline int
+do_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp)
 {
netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr);
netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3);
@@ -314,7 +315,7 @@
 #define NETXEN_ROM_ROUNDUP 0x8000ULL
 #define NETXEN_ROM_FOUND_INIT  0x400

-int pinit_from_rom(struct netxen_adapter *adapter, int verbose)
+int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
 {
int addr, val, status;
int n, i;
@@ -457,7 +458,7 @@
return 0;
 }

-void phantom_init(struct netxen_adapter *adapter)
+void netxen_phantom_init(struct netxen_adapter *adapter)
 {
u32 val = 0;
int loops = 0;

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.17 6/9] NetXen: Main header file (Name prefix change)

2006-08-21 Thread Pradeep Dalvi

diff -u linux-2.6.17/drivers/net/netxen/netxen_nic.h 
linux-2.6.17/drivers/net/netxen/netxen_nic.h
--- linux-2.6.17/drivers/net/netxen/netxen_nic.h2006-08-17 
07:12:34.0 -0700
+++ linux-2.6.17/drivers/net/netxen/netxen_nic.h2006-08-21 
02:20:00.0 -0700
@@ -550,8 +550,8 @@
 #define FLASH_SECONDARY_SIZE   (USER_START-SECONDARY_START)
 #define NUM_PRIMARY_SECTORS(0x20)
 #define NUM_CONFIG_SECTORS (1)
-int is_flash_supported(struct netxen_adapter *adapter);
-int get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]);
+int netxen_is_flash_supported(struct netxen_adapter *adapter);
+int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]);

 extern void netxen_change_ringparam(struct netxen_adapter *adapter);
 extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr,
@@ -817,9 +817,9 @@
 unsigned long off, int data);

 /* Functions from netxen_nic_init.c */
-void phantom_init(struct netxen_adapter *adapter);
-void load_firmware(struct netxen_adapter *adapter);
-int pinit_from_rom(struct netxen_adapter *adapter, int verbose);
+void netxen_phantom_init(struct netxen_adapter *adapter);
+void netxen_load_firmware(struct netxen_adapter *adapter);
+int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose);
 int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp);

 /* Functions from netxen_nic_isr.c */
@@ -842,9 +842,9 @@
 int netxen_nic_unset_promisc_mode(struct netxen_port *port);
 void netxen_nic_stop_all_ports(struct netxen_adapter *adapter);
 void netxen_nic_stop_port(struct netxen_port *port);
-void initialize_adapter_sw(struct netxen_adapter *adapter);
-void initialize_adapter_hw(struct netxen_adapter *adapter);
-int init_firmware(struct netxen_adapter *adapter);
+void netxen_initialize_adapter_sw(struct netxen_adapter *adapter);
+void netxen_initialize_adapter_hw(struct netxen_adapter *adapter);
+int netxen_init_firmware(struct netxen_adapter *adapter);
 void netxen_free_hw_resources(struct netxen_adapter *adapter);
 void netxen_tso_check(struct netxen_adapter *adapter,
  struct cmd_desc_type0_t *desc, struct sk_buff *skb);

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2.6.17 1/9] NetXen: Makefile and ethtool interface

2006-07-06 Thread Pradeep Dalvi
Jeff,

Thanks a lot for feedback.

We are working on incorporating the feedback. And we will upload the entire 
single patch soon.

Thanks,
pradeep

On Wednesday 05 July 2006 21:04, Jeff Garzik wrote:
 Linsys Contractor Amit S. Kale wrote:
  +static int
  +netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd
  *ecmd) +{
  +struct netxen_port *port = netdev_priv(dev);
  +struct netxen_adapter *adapter = port-adapter;
  +struct netxen_niu_phy_status status;
  +
  +/* read which mode */
  +if (adapter-ahw.board_type == NETXEN_NIC_GBE) {
  +/* autonegotiation */
  +if (netxen_nic_phy_write(port-adapter, port-portnum,
  + NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
  + (netxen_crbword_t) ecmd-autoneg) != 0)
  +return -EIO;
  +else
  +port-link_autoneg = ecmd-autoneg;
  +
  +if (netxen_nic_phy_read(port-adapter, port-portnum,
  +NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
  +(netxen_crbword_t *)  status) != 0)
  +return -EIO;
  +
  +/* speed */
  +switch (ecmd-speed) {
  +case SPEED_10:
  +status.speed = 0;
  +break;
  +case SPEED_100:
  +status.speed = 1;
  +break;
  +case SPEED_1000:
  +status.speed = 2;
  +break;
  +}
  +/* set duplex mode */
  +if (ecmd-duplex == DUPLEX_HALF)
  +status.duplex = 0;
  +if (ecmd-duplex == DUPLEX_FULL)
  +status.duplex = 1;
  +
  +if (netxen_nic_phy_write(port-adapter, port-portnum,
  + NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
  + *((int *)status)) != 0)
  +return -EIO;
  +else {
  +port-link_speed = ecmd-speed;
  +port-link_duplex = ecmd-duplex;
  +}
  +}
  +if (netif_running(dev)) {
  +dev-stop(dev);
  +dev-open(dev);
  +}
  +return 0;
  +}
  +
 
  +/* Restart Link Process */
  +static int netxen_nic_nway_reset(struct net_device *dev)
  +{
  +if (netif_running(dev)) {
  +dev-stop(dev);/* verify */
  +dev-open(dev);
  +}
  +return 0;
  +}

 Direct calls to dev-stop() and dev-open() are likely buggy, because
 the locking/context differs between the above quoted calls and the calls
 from inside the net stack.

  +struct ethtool_ops netxen_nic_ethtool_ops = {
  +.get_settings = netxen_nic_get_settings,
  +.set_settings = netxen_nic_set_settings,
  +.get_drvinfo = netxen_nic_get_drvinfo,
  +.get_regs_len = netxen_nic_get_regs_len,
  +.get_regs = netxen_nic_get_regs,
  +.get_wol = netxen_nic_get_wol,
  +.nway_reset = netxen_nic_nway_reset,
  +.get_link = netxen_nic_get_link,
  +.get_eeprom_len = netxen_nic_get_eeprom_len,
  +.get_eeprom = netxen_nic_get_eeprom,
  +.get_ringparam = netxen_nic_get_ringparam,
  +.get_pauseparam = netxen_nic_get_pauseparam,
  +.set_pauseparam = netxen_nic_set_pauseparam,
  +.get_tx_csum = ethtool_op_get_tx_csum,
  +.set_tx_csum = ethtool_op_set_tx_csum,
  +.get_sg = ethtool_op_get_sg,
  +.set_sg = ethtool_op_set_sg,
  +#ifdef NETIF_F_TSO
  +.get_tso = ethtool_op_get_tso,
  +.set_tso = ethtool_op_set_tso,
  +#endif

 kill this #ifdef

   Jeff
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9] NetXen 1G/10G ethernet driver patch with corrections

2006-06-08 Thread Pradeep Dalvi
diff -u linux-2.6.16.20/drivers/net/netxen/netxen_nic_ethtool.c
linux-2.6.16.20/drivers/net/netxen/netxen_nic_ethtool.c
--- linux-2.6.16.20/drivers/net/netxen/netxen_nic_ethtool.c 2006-06-06
06:58:11.0 -0700
+++ linux-2.6.16.20/drivers/net/netxen/netxen_nic_ethtool.c 2006-06-08
06:52:09.0 -0700
@@ -240,6 +240,95 @@
return NETXEN_NIC_REGS_LEN;
 }
 
+struct netxen_niu_regs {
+   netxen_crbword_treg[NETXEN_NIC_REGS_COUNT];
+};
+
+static struct netxen_niu_regs niu_registers[] = {
+   {
+/* GB Mode */
+{
+ NETXEN_NIU_GB_SERDES_RESET,
+ NETXEN_NIU_GB0_MII_MODE,
+ NETXEN_NIU_GB1_MII_MODE,
+ NETXEN_NIU_GB2_MII_MODE,
+ NETXEN_NIU_GB3_MII_MODE,
+ NETXEN_NIU_GB0_GMII_MODE,
+ NETXEN_NIU_GB1_GMII_MODE,
+ NETXEN_NIU_GB2_GMII_MODE,
+ NETXEN_NIU_GB3_GMII_MODE,
+ NETXEN_NIU_REMOTE_LOOPBACK,
+ NETXEN_NIU_GB0_HALF_DUPLEX,
+ NETXEN_NIU_GB1_HALF_DUPLEX,
+ NETXEN_NIU_RESET_SYS_FIFOS,
+ NETXEN_NIU_GB_CRC_DROP,
+ NETXEN_NIU_GB_DROP_WRONGADDR,
+ NETXEN_NIU_TEST_MUX_CTL,
+
+ NETXEN_NIU_GB_MAC_CONFIG_0(0),
+ NETXEN_NIU_GB_MAC_CONFIG_1(0),
+ NETXEN_NIU_GB_HALF_DUPLEX_CTRL(0),
+ NETXEN_NIU_GB_MAX_FRAME_SIZE(0),
+ NETXEN_NIU_GB_TEST_REG(0),
+ NETXEN_NIU_GB_MII_MGMT_CONFIG(0),
+ NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
+ NETXEN_NIU_GB_MII_MGMT_ADDR(0),
+ NETXEN_NIU_GB_MII_MGMT_CTRL(0),
+ NETXEN_NIU_GB_MII_MGMT_STATUS(0),
+ NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
+ NETXEN_NIU_GB_INTERFACE_CTRL(0),
+ NETXEN_NIU_GB_INTERFACE_STATUS(0),
+ NETXEN_NIU_GB_STATION_ADDR_0(0),
+ NETXEN_NIU_GB_STATION_ADDR_1(0),
+ -1,
+}
+   },
+   {
+/* XG Mode */
+{
+ NETXEN_NIU_XG_SINGLE_TERM,
+ NETXEN_NIU_XG_DRIVE_HI,
+ NETXEN_NIU_XG_DRIVE_LO,
+ NETXEN_NIU_XG_DTX,
+ NETXEN_NIU_XG_DEQ,
+ NETXEN_NIU_XG_WORD_ALIGN,
+ NETXEN_NIU_XG_RESET,
+ NETXEN_NIU_XG_POWER_DOWN,
+ NETXEN_NIU_XG_RESET_PLL,
+ NETXEN_NIU_XG_SERDES_LOOPBACK,
+ NETXEN_NIU_XG_DO_BYTE_ALIGN,
+ NETXEN_NIU_XG_TX_ENABLE,
+ NETXEN_NIU_XG_RX_ENABLE,
+ NETXEN_NIU_XG_STATUS,
+ NETXEN_NIU_XG_PAUSE_THRESHOLD,
+ NETXEN_NIU_XGE_CONFIG_0,
+ NETXEN_NIU_XGE_CONFIG_1,
+ NETXEN_NIU_XGE_IPG,
+ NETXEN_NIU_XGE_STATION_ADDR_0_HI,
+ NETXEN_NIU_XGE_STATION_ADDR_0_1,
+ NETXEN_NIU_XGE_STATION_ADDR_1_LO,
+ NETXEN_NIU_XGE_STATUS,
+ NETXEN_NIU_XGE_MAX_FRAME_SIZE,
+ NETXEN_NIU_XGE_PAUSE_FRAME_VALUE,
+ NETXEN_NIU_XGE_TX_BYTE_CNT,
+ NETXEN_NIU_XGE_TX_FRAME_CNT,
+ NETXEN_NIU_XGE_RX_BYTE_CNT,
+ NETXEN_NIU_XGE_RX_FRAME_CNT,
+ NETXEN_NIU_XGE_AGGR_ERROR_CNT,
+ NETXEN_NIU_XGE_MULTICAST_FRAME_CNT,
+ NETXEN_NIU_XGE_UNICAST_FRAME_CNT,
+ NETXEN_NIU_XGE_CRC_ERROR_CNT,
+ NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR,
+ NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR,
+ NETXEN_NIU_XGE_LOCAL_ERROR_CNT,
+ NETXEN_NIU_XGE_REMOTE_ERROR_CNT,
+ NETXEN_NIU_XGE_CONTROL_CHAR_CNT,
+ NETXEN_NIU_XGE_PAUSE_FRAME_CNT,
+ -1,
+}
+   }
+};
+
 static void
 netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs,
void *p)
 {
@@ -248,6 +337,7 @@
netxen_crbword_t mode, *regs_buff = p;
unsigned long flags;
void *addr;
+   int i, window;
 
memset(p, 0, NETXEN_NIC_REGS_LEN);
regs-version = (1  24) | (adapter-ahw.revision_id  16) |
@@ -260,176 +350,18 @@
/* Common registers to all the modes */
NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_STRAP_VALUE_SAVE_HIGHER,
   regs_buff[2]);
-   switch (mode) {
-   case 4:{/* XGB Mode */
-   NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XG_SINGLE_TERM,
-  regs_buff[3]);
-   NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XG_DRIVE_HI,
-  regs_buff[4]);
-   NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XG_DRIVE_LO,
-  regs_buff[5]);
-   NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XG_DTX,
-  regs_buff[6]);
-   NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XG_DEQ,
-  regs_buff[7]);
-   NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XG_WORD_ALIGN,
-  regs_buff[8]);
-   NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XG_RESET,
-  regs_buff[9]);
-   

Re: [PATCH 6/9] Resending NetXen 1G/10G NIC driver patch

2006-05-26 Thread Pradeep Dalvi
diff -u linux-2.6.16.18/drivers/net/netxen/netxen_nic_init.c
linux-2.6.16.18/drivers/net/netxen/netxen_nic_init.c
--- linux-2.6.16.18/drivers/net/netxen/netxen_nic_init.c
2006-05-25 02:43:22.0 -0700
+++ linux-2.6.16.18/drivers/net/netxen/netxen_nic_init.c
2006-05-26 04:05:34.0 -0700
@@ -200,8 +200,8 @@
 }

 /*
- * netxen_decode_crb_addr(0 - utility to translate from internal
Phantom
- * CRB address to external PCI CRB address.
+ * netxen_decode_crb_addr(0 - utility to translate from internal
Phantom CRB address
+ * to external PCI CRB address.
  */
 unsigned long netxen_decode_crb_addr(unsigned long addr)
 {
@@ -869,7 +869,6 @@
for (p = 0; p  adapter-ahw.max_ports; p++) {
nport = adapter-port[p];
if (netif_queue_stopped(nport-netdev)
-(nport-state == NETXEN_PORT_UP)
 (nport-flags  NETXEN_NETDEV_STATUS)) {
netif_wake_queue(nport-netdev);
nport-flags = ~NETXEN_NETDEV_STATUS;
@@ -920,7 +919,7 @@
}
count++;/* now there should be no failure */
pdesc = rcv_desc-desc_head[producer];
-   skb_reserve(skb, IP_ALIGNMENT_BYTES);
+   skb_reserve(skb, NET_IP_ALIGN);
/*
 * This will be setup when we receive the
 * buffer after it has been filled

On Thu, 2006-05-25 at 09:47 -0700, Stephen Hemminger wrote:
 Why is this necessary. Additional private API seems like leftover
 debug code.
 
  +int
  +netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data,
  +   struct netxen_port *port)
  +{
  +   struct netxen_nic_ioctl_data data;
  +   struct netxen_nic_ioctl_data *up_data;
  +   int retval = 0;
  +   struct netxen_statistics netxen_stats;
  +
  +   up_data = (void *)u_data;
  +
  +   DPRINTK(INFO, doing ioctl for %p\n, adapter);
  +   if (copy_from_user(data, up_data, sizeof(data))) {
  +   /* evil user tried to crash the kernel */
  +   DPRINTK(ERR, bad copy from userland: %d\n, (int)sizeof(data));
  +   retval = -EFAULT;
  +   goto error_out;
  +   }
  +
  +   /* Shouldn't access beyond legal limits of  char u[64]; member */
  +   if (!data.ptr  (data.size  sizeof(data.u))) {
  +   /* evil user tried to crash the kernel */
  +   DPRINTK(ERR, bad size: %d\n, data.size);
  +   retval = -EFAULT;
  +   goto error_out;
  +   }
  +
  +   switch (data.cmd) {
  +   case netxen_nic_cmd_pci_read:
  +   if ((retval = netxen_nic_hw_read_wx(adapter, data.off,
  +   (data.u), data.size)))
  +   goto error_out;
  +   if (copy_to_user((void *)(up_data-u), (data.u), data.size)) {
  +   DPRINTK(ERR, bad copy to userland: %d\n,
  +   (int)sizeof(data));
  +   retval = -EFAULT;
  +   goto error_out;
  +   }
  +   data.rv = 0;
  +   break;
  +
 
 Can't you access the same registers area with ethtool.
 
 
  +   case netxen_nic_cmd_pci_write:
  +   data.rv = netxen_nic_hw_write_wx(adapter, data.off, (data.u),
  +data.size);
  +   break;
  +
  +   case netxen_nic_cmd_pci_mem_read:
  +   DPRINTK(INFO, doing %s for %p\n,
  +   netxen_nic_cmd_pci_mm_rd, adapter);
  +   netxen_nic_pci_mem_read(adapter, data.off, (data.u),
  +   data.size);
  +   if (copy_to_user((void *)(up_data-u), (data.u), data.size)) {
  +   DPRINTK(ERR, bad copy to userland: %d\n,
  +   (int)sizeof(data));
  +   retval = -EFAULT;
  +   goto error_out;
  +   }
  +   data.rv = 0;
  +   DPRINTK(INFO, read %lx\n, (unsigned long)data.u);
  +   break;
 
 PCI memory is accessible directly through sysfs for diagnostic tools.
 
 
  +   case netxen_nic_cmd_pci_mem_write:
  +   netxen_nic_pci_mem_write(adapter, data.off, (data.u),
  +data.size);
  +   data.rv = 0;/* write always succeeds */
  +   break;
  +
  +   case netxen_nic_cmd_pci_config_read:
  +   switch (data.size) {
  +   case 1:
  +   data.rv = pci_read_config_byte(adapter-ahw.pdev,
  +  data.off,
  +  (char *)(data.u));
  +   break;
  +   case 2:
  +   data.rv = pci_read_config_word(adapter-ahw.pdev,
  +  data.off,
  +  (short *)(data.u));
  +   break;
  +   case 4:
  + 

Re: [PATCH 1/9] Resending NetXen 1G/10G NIC driver patch

2006-05-26 Thread Pradeep Dalvi
Following are the minor changes for [PATCH 1/9] in accordance with the
given suggestions.

Regards,
pradeep

diff -u linux-2.6.16.18/drivers/net/netxen/netxen_nic_ethtool.c
linux-2.6.16.18/drivers/net/netxen/netxen_nic_ethtool.c
--- linux-2.6.16.18/drivers/net/netxen/netxen_nic_ethtool.c
2006-05-25 02:43:22.0 -0700
+++ linux-2.6.16.18/drivers/net/netxen/netxen_nic_ethtool.c
2006-05-26 04:05:34.0 -0700
@@ -145,7 +145,7 @@

ecmd-port = PORT_TP;

-   if (port-state) {
+   if (dev-flags  IFF_UP) {
ecmd-speed = port-link_speed;
ecmd-duplex = port-link_duplex;
} else
@@ -512,16 +512,6 @@
ring-rx_jumbo_pending = 0;
 }

-/*
- * Note: This change will be reflected in all the four ports as there
is
- * only one common adapter.
- */
-static int
-netxen_nic_set_ringparam(struct net_device *dev, struct
ethtool_ringparam *ring)
-{
-   return 0;
-}
-
 static void
 netxen_nic_get_pauseparam(struct net_device *dev,
  struct ethtool_pauseparam *pause)
@@ -781,7 +771,6 @@
.get_eeprom_len = netxen_nic_get_eeprom_len,
.get_eeprom = netxen_nic_get_eeprom,
.get_ringparam = netxen_nic_get_ringparam,
-   .set_ringparam = netxen_nic_set_ringparam,
.get_pauseparam = netxen_nic_get_pauseparam,
.set_pauseparam = netxen_nic_set_pauseparam,
.get_rx_csum = netxen_nic_get_rx_csum,


On Thu, 2006-05-25 at 09:33 -0700, Stephen Hemminger wrote:
 Minor nits.
 
 On Thu, 25 May 2006 03:48:38 -0700 (PDT)
 Linsys Contractor Amit S. Kale [EMAIL PROTECTED] wrote:
 
  +/*
  + * Note: This change will be reflected in all the four ports as there is 
  + * only one common adapter.
  + */
  +static int
  +netxen_nic_set_ringparam(struct net_device *dev, struct ethtool_ringparam 
  *ring)
  +{
  +   return 0;
  +}
 
 Why not just return have no hook if you can't set parameters.  Then the ioctl
 will return not supported -EOPNOTSUPP
 
 
  +static u32 netxen_nic_get_rx_csum(struct net_device *dev)
  +{
  +   return (dev-features  NETIF_F_HW_CSUM);
  +}
 
 
 You got receive and transmit checksum confused.  You need to separate
 checksumming on output (dev-features  NETIF_F_HW_CSUM) versus receive
 checksum (controlled by hardware and usually a flag in private data 
 structure).
 
  +static int netxen_nic_set_rx_csum(struct net_device *dev, u32 data)
  +{
  +   if (data)
  +   dev-features |= NETIF_F_HW_CSUM;
  +   else
  +   dev-features = (~NETIF_F_HW_CSUM);
  +
  +   if (netif_running(dev)) {
  +   dev-stop(dev); /* verify */
  +   dev-open(dev);
 
 What if open fail fails?  Then you have an interesting recovery
 situation.  
  +   }
  +   return 0;
  +}
  
 

-- 
pradeep

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/9] Resending NetXen 1G/10G NIC driver patch

2006-05-26 Thread Pradeep Dalvi
diff -u linux-2.6.16.18/drivers/net/netxen/netxen_nic_hw.c
linux-2.6.16.18/drivers/net/netxen/netxen_nic_hw.c
--- linux-2.6.16.18/drivers/net/netxen/netxen_nic_hw.c  2006-05-25
02:43:22.0 -0700
+++ linux-2.6.16.18/drivers/net/netxen/netxen_nic_hw.c  2006-05-26
04:05:34.0 -0700
@@ -61,7 +61,6 @@

DPRINTK(INFO, valid ether addr\n);
memcpy(netdev-dev_addr, addr-sa_data, netdev-addr_len);
-   memcpy(port-hw.mac_addr, addr-sa_data, netdev-addr_len);

netxen_nic_macaddr_set(port, addr-sa_data);

@@ -102,7 +101,6 @@

netxen_nic_set_mtu(port, new_mtu);
netdev-mtu = new_mtu;
-   port-hw.mtu = new_mtu;

return 0;
 }
@@ -628,8 +626,9 @@
return val;
 }

+/* Change the window to 0, write and change back to window 1. */
 void netxen_nic_write_w0(struct netxen_adapter *adapter, u32 index, u32
value)
-{  /* Change the window to 0, write and
change back to window 1. */
+{
unsigned long flags;
void *addr;

@@ -641,8 +640,9 @@
write_unlock_irqrestore(adapter-adapter_lock, flags);
 }

+/* Change the window to 0, read and change back to window 1. */
 void netxen_nic_read_w0(struct netxen_adapter *adapter, u32 index, u32
* value)
-{  /* Change the window to 0, read and
change back to window 1. */
+{
unsigned long flags;
void *addr;

@@ -1188,7 +1188,6 @@

NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
(netxen_crbword_t *)  status)
== 0) {
if (status.link) {
-   port-state = 1;
switch (status.speed) {
case 0:
port-link_speed = SPEED_10;
@@ -1224,7 +1223,6 @@
goto link_down;
} else {
  link_down:
-   port-state = -1;
port-link_speed = -1;
port-link_duplex = -1;
}

On Thu, 2006-05-25 at 03:53 -0700, Linsys Contractor Amit S. Kale wrote:
 diff -Naru linux-2.6.16.18.orig/drivers/net/netxen/netxen_nic_hw.c 
 linux-2.6.16.18/drivers/net/netxen/netxen_nic_hw.c
 --- linux-2.6.16.18.orig/drivers/net/netxen/netxen_nic_hw.c   1969-12-31 
 16:00:00.0 -0800
 +++ linux-2.6.16.18/drivers/net/netxen/netxen_nic_hw.c2006-05-25 
 02:43:22.0 -0700
 @@ -0,0 +1,1289 @@
 +/*
 + * Copyright (C) 2003 - 2006 NetXen, Inc.
 + * All rights reserved.
 + * 
 + * 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; either version 2
 + * of the License, or (at your option) any later version.
 + *
 + * 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.
 + * 
 + * The full GNU General Public License is included in this distribution
 + * in the file called LICENSE.
 + * 
 + * Contact Information:
 + *[EMAIL PROTECTED]
 + * NetXen,
 + * 3965 Freedom Circle, Fourth floor,
 + * Santa Clara, CA 95054
 + *
 + *
 + * Source file for NIC routines to access the Phantom hardware
 + *
 + */
 +
 +#include linux/delay.h
 +#include linux/netdevice.h
 +#include linux/ethtool.h
 +#include linux/version.h
 +#include netxen_nic.h
 +#include netxen_nic_hw.h
 +#include netxen_nic_phan_reg.h
 +
 +/*  PCI Windowing for DDR regions.  */
 +
 +#define ADDR_IN_RANGE(addr, low, high)   \
 + (((addr) = (high))  ((addr) = (low)))
 +
 +static unsigned long netxen_nic_pci_set_window(unsigned long long pci_base,
 +unsigned long long addr);
 +void netxen_free_hw_resources(struct netxen_adapter *adapter);
 +
 +int netxen_nic_set_mac(struct net_device *netdev, void *p)
 +{
 + struct netxen_port *port = netdev_priv(netdev);
 + struct sockaddr *addr = p;
 +
 + if (netif_running(netdev))
 + return -EBUSY;
 +
 + if (!is_valid_ether_addr(addr-sa_data))
 + return -EADDRNOTAVAIL;
 +
 + DPRINTK(INFO, valid ether addr\n);
 + memcpy(netdev-dev_addr, addr-sa_data, netdev-addr_len);
 + memcpy(port-hw.mac_addr, addr-sa_data, netdev-addr_len);
 +
 + netxen_nic_macaddr_set(port, addr-sa_data);
 +
 + return 0;
 +}
 +
 +/**
 + * netxen_nic_set_multi - Multicast
 + **/
 +void netxen_nic_set_multi(struct net_device *netdev)
 +{
 + struct netxen_port *port = 

Re: [PATCH 2/9] Resending NetXen 1G/10G NIC driver patch

2006-05-26 Thread Pradeep Dalvi
Following are the minor changes for [PATCH 2/9] in accordance with the
given suggestions.

Regards,
pradeep

diff -u linux-2.6.16.18/drivers/net/netxen/netxen_nic.h
linux-2.6.16.18/drivers/net/netxen/netxen_nic.h
--- linux-2.6.16.18/drivers/net/netxen/netxen_nic.h 2006-05-25
02:43:22.0 -0700
+++ linux-2.6.16.18/drivers/net/netxen/netxen_nic.h 2006-05-26
04:05:34.0 -0700
@@ -98,12 +98,11 @@
(void *)(ptrdiff_t)(adapter-ahw.pci_base+ (reg)\
- NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST)

-#define IP_ALIGNMENT_BYTES 2 /* make ip aligned on 16 bytes
addr */
 #define MAX_RX_BUFFER_LENGTH   2000
 #define MAX_RX_JUMBO_BUFFER_LENGTH 9046
-#define RX_DMA_MAP_LEN (MAX_RX_BUFFER_LENGTH -
IP_ALIGNMENT_BYTES)
+#define RX_DMA_MAP_LEN (MAX_RX_BUFFER_LENGTH -
NET_IP_ALIGN)
 #define RX_JUMBO_DMA_MAP_LEN   \
-   (MAX_RX_JUMBO_BUFFER_LENGTH - IP_ALIGNMENT_BYTES)
+   (MAX_RX_JUMBO_BUFFER_LENGTH - NET_IP_ALIGN)

 /* Opcodes to be used with the commands */
 #defineTX_ETHER_PKT 0x01
@@ -608,7 +607,7 @@
struct netxen_board_info boardcfg;
u32 xg_linkup;
struct netxen_adapter *adapter;
-   struct cmd_desc_type0_t *cmd_desc_head; /* Address of cmd ring
in Phantom */
+   struct cmd_desc_type0_t *cmd_desc_head;
u32 cmd_producer;
u32 cmd_consumer;
u32 rcv_flag;
@@ -695,8 +694,6 @@
struct work_struct watchdog_task;
struct work_struct tx_timeout_task[4];
struct timer_list watchdog_timer;
-   struct tasklet_struct tx_tasklet;
-   struct tasklet_struct rx_tasklet;

u32 curr_window;

@@ -742,20 +739,6 @@
struct net_device *netdev;
 };

-struct netxen_port_hw {
-   unsigned char mac_addr[MAX_ADDR_LEN];
-   int mtu;
-   struct pci_dev *pdev;
-   struct netxen_port *port;
-};
-
-/* Following structure is for specific port information*/
-
-#defineNETXEN_PORT_UP  0
-#defineNETXEN_PORT_DOWN1
-#defineNETXEN_PORT_INITIALIAZED2
-#defineNETXEN_PORT_SUSPEND 3
-
 /* Max number of xmit producer threads that can run simultaneously */
 #defineMAX_XMIT_PRODUCERS  16

@@ -785,11 +768,9 @@
 struct netxen_port {
struct netxen_adapter *adapter;

-   struct netxen_port_hw hw;   /* port hardware structure */
u16 portnum;/* GBE port number */
u16 link_speed;
u16 link_duplex;
-   u16 state;  /* state of the port */
u16 link_autoneg;

int flags;


On Thu, 2006-05-25 at 09:42 -0700, Stephen Hemminger wrote:
 On Thu, 25 May 2006 03:51:03 -0700 (PDT)
 Linsys Contractor Amit S. Kale [EMAIL PROTECTED] wrote:
 
  diff -Naru linux-2.6.16.18.orig/drivers/net/netxen/netxen_nic.h 
  linux-2.6.16.18/drivers/net/netxen/netxen_nic.h
  --- linux-2.6.16.18.orig/drivers/net/netxen/netxen_nic.h1969-12-31 
  16:00:00.0 -0800
  +++ linux-2.6.16.18/drivers/net/netxen/netxen_nic.h 2006-05-25 
  02:43:22.0 -0700
  @@ -0,0 +1,950 @@
 
  +#define IP_ALIGNMENT_BYTES 2 /* make ip aligned on 16 bytes addr */
 
 Please use NET_IP_ALIGN, it does the right architecture dependent
 offset.
 
 ...
  +#define NETXEN_PCI_ID(X) { PCI_DEVICE(PCI_VENDOR_ID_NX, (X)) }
 
 Nested macro's on macro's, just use PCI_DEVICE()
 
  +
  +#define PFX netxen: 
  +
  +/* Note: Make sure to not call this before adapter-port is valid */
  +#if !defined(NETXEN_DEBUG)
  +#define DPRINTK(klevel, fmt, args...)  do { \
  +   } while (0)
  +#else
  +#define DPRINTK(klevel, fmt, args...)  do { \
  +   printk(KERN_##klevel PFX %s: %s:  fmt, __FUNCTION__,\
  +   (adapter != NULL  adapter-port != NULL  \
  +   adapter-port[0] != NULL  \
  +   adapter-port[0]-netdev != NULL) ? \
  +   adapter-port[0]-netdev-name : NULL, \
  +   ## args); } while(0)
  +#endif
  +
 
 Ugh. Macro with magic variable.  if you need to keep this, pass adapter.
 
 
  +struct netdev_list {
  +   struct netdev_list *next;
  +   struct net_device *netdev;
  +};
 
 Why not use regular list.h or simple linked list.  Even better
 figure out how to not need need list of devices at all
 
  +struct netxen_port_hw {
  +   unsigned char mac_addr[MAX_ADDR_LEN];
  +   int mtu;
  +   struct pci_dev *pdev;
  +   struct netxen_port *port;
  +};
 
 Isn't mtu redundant with dev-mtu and mac_addr redundant
 with dev-dev_addr
 
 
  +/* Following structure is for specific port information*/
  +
  +#defineNETXEN_PORT_UP  0
  +#defineNETXEN_PORT_DOWN1
  +#defineNETXEN_PORT_INITIALIAZED2
  +#defineNETXEN_PORT_SUSPEND 3
 
 Don't mirror port state with netdevice state because you risk
 getting the two out of sync. Isn't this redundant with
 netif_running()
 
 
 
-- 
pradeep

-
To unsubscribe from this list: 

Re: [PATCH 8/9] Resending NetXen 1G/10G NIC driver patch

2006-05-26 Thread Pradeep Dalvi
diff -u linux-2.6.16.18/drivers/net/netxen/netxen_nic_main.c
linux-2.6.16.18/drivers/net/netxen/netxen_nic_main.c
--- linux-2.6.16.18/drivers/net/netxen/netxen_nic_main.c
2006-05-25 02:43:22.0 -0700
+++ linux-2.6.16.18/drivers/net/netxen/netxen_nic_main.c
2006-05-26 04:05:34.0 -0700
@@ -259,14 +259,12 @@
pci_read_config_byte(pdev, PCI_REVISION_ID, adapter-
ahw.revision_id);
pci_read_config_word(pdev, PCI_COMMAND, adapter-
ahw.pci_cmd_word);

-#if defined(CONFIG_PCI_MSI)
-   adapter-flags |= NETXEN_NIC_MSI_ENABLED;
if (pci_enable_msi(pdev)) {
adapter-flags = ~NETXEN_NIC_MSI_ENABLED;
printk(KERN_WARNING %s: unable to allocate MSI
interrupt
error\n, netxen_nic_driver_name);
-   }
-#endif
+   } else
+   adapter-flags |= NETXEN_NIC_MSI_ENABLED;

if (is_flash_supported(adapter) == 0 
get_flash_mac_addr(adapter, mac_addr) == 0)
@@ -295,7 +293,6 @@
port = netdev_priv(netdev);
port-netdev = netdev;
port-pdev = pdev;
-   port-hw.port = port;
port-adapter = adapter;
port-portnum = i;  /* Gigabit port number starting
from 0-3 */
port-flags = ~NETXEN_NETDEV_STATUS;
@@ -329,27 +326,25 @@
boardno = netxen_nic_get_board_num(adapter);
if (valid_mac) {
unsigned char *p = (unsigned char *)mac_addr
[i];
-   port-hw.mac_addr[0] = *(p + 5);
-   port-hw.mac_addr[1] = *(p + 4);
-   port-hw.mac_addr[2] = *(p + 3);
-   port-hw.mac_addr[3] = *(p + 2);
-   port-hw.mac_addr[4] = *(p + 1);
-   port-hw.mac_addr[5] = *(p + 0);
-
-   if (!is_valid_ether_addr(port-hw.mac_addr)) {
-   printk(KERN_ERR%s: Bad MAC address
-  %02x:%02x:%02x:%02x:%02x:%
02x.\n,
+   netdev-dev_addr[0] = *(p + 5);
+   netdev-dev_addr[1] = *(p + 4);
+   netdev-dev_addr[2] = *(p + 3);
+   netdev-dev_addr[3] = *(p + 2);
+   netdev-dev_addr[4] = *(p + 1);
+   netdev-dev_addr[5] = *(p + 0);
+
+   if (!is_valid_ether_addr(netdev-dev_addr)) {
+   printk(KERN_ERR
+  %s: Bad MAC address %02x:%02x:%
02x:%02x:%02x:%02x.\n,
   netxen_nic_driver_name,
-  port-hw.mac_addr[0],
-  port-hw.mac_addr[1],
-  port-hw.mac_addr[2],
-  port-hw.mac_addr[3],
-  port-hw.mac_addr[4],
-  port-hw.mac_addr[5]);
+  netdev-dev_addr[0],
+  netdev-dev_addr[1],
+  netdev-dev_addr[2],
+  netdev-dev_addr[3],
+  netdev-dev_addr[4],
+  netdev-dev_addr[5]);
} else {
-   memcpy(netdev-dev_addr, port-
hw.mac_addr,
-  netdev-addr_len);
-   netxen_nic_macaddr_set(port, port-
hw.mac_addr);
+   netxen_nic_macaddr_set(port, netdev-
dev_addr);
}
}
INIT_WORK(adapter-tx_timeout_task + i,
@@ -629,14 +624,13 @@

/* Done here again so that even if phantom sw overwrote it,
   we set it */
-   netxen_nic_macaddr_set(port, port-hw.mac_addr);
+   netxen_nic_macaddr_set(port, netdev-dev_addr);
netxen_nic_set_link_parameters(port);

netxen_nic_set_multi(netdev);
if (!adapter-driver_mismatch)
netif_start_queue(netdev);

-   port-state = NETXEN_PORT_UP;
return 0;
 }

@@ -728,7 +722,7 @@
if (((skb-nh.iph)-ihl * sizeof(u32)) +
((skb-h.th)-doff * sizeof(u32)) +
sizeof(struct ethhdr) 
-   (sizeof(struct cmd_desc_type0_t) -
IP_ALIGNMENT_BYTES)) {
+   (sizeof(struct cmd_desc_type0_t) - NET_IP_ALIGN)) {
no_of_desc++;
}
}
@@ -852,10 +846,10 @@
int hdr_len, first_hdr_len, more_hdr;
hdr_len = hw-cmd_desc_head
[saved_producer].total_hdr_length;
if (hdr_len 
-   (sizeof(struct cmd_desc_type0_t) -
IP_ALIGNMENT_BYTES)) {
+   (sizeof(struct cmd_desc_type0_t) - NET_IP_ALIGN)) {
   

Re: [PATCH 9/9] Resending NetXen 1G/10G NIC driver patch

2006-05-26 Thread Pradeep Dalvi
diff -u linux-2.6.16.18/drivers/net/netxen/netxen_nic_niu.c
linux-2.6.16.18/drivers/net/netxen/netxen_nic_niu.c
--- linux-2.6.16.18/drivers/net/netxen/netxen_nic_niu.c 2006-05-25
02:43:22.0 -0700
+++ linux-2.6.16.18/drivers/net/netxen/netxen_nic_niu.c 2006-05-26
04:05:34.0 -0700
@@ -34,22 +34,6 @@
 #include netxen_nic.h
 #include linux/delay.h

-void netxen_delay(int value)
-{
-   unsigned long remainder;
-
-   remainder = value / 5;
-   do {
-   if (remainder  1000) {
-   udelay(1000);
-   remainder -= 1000;
-   } else {
-   udelay(remainder + 1);
-   remainder = 0;
-   }
-   } while (remainder  0);
-}
-
 /**
  * netxen_niu_gbe_phy_read - read a register from the GbE PHY via
  * mii management interface.
@@ -78,7 +62,7 @@
/* MII mgmt all goes through port 0 MAC interface, so it cannot
be in reset */
if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0
(0),
  mac_cfg0, 4))
-   return -1;
+   return -EIO;
if (mac_cfg0.soft_reset) {
struct netxen_niu_gb_mac_config_0_t temp;
*(netxen_crbword_t *)  temp = 0;
@@ -89,7 +73,7 @@
if (netxen_nic_hw_write_wx(adapter,
   NETXEN_NIU_GB_MAC_CONFIG_0
(0),
   temp, 4))
-   return -1;
+   return -EIO;
restore = 1;
}

@@ -99,34 +83,34 @@
mii_cfg.reset = 1;
if (netxen_nic_hw_write_wx(adapter,
NETXEN_NIU_GB_MII_MGMT_CONFIG(0),
   mii_cfg, 4))
-   return -1;
+   return -EIO;
mii_cfg.reset = 0;
if (netxen_nic_hw_write_wx(adapter,
NETXEN_NIU_GB_MII_MGMT_CONFIG(0),
   mii_cfg, 4))
-   return -1;
+   return -EIO;

*(netxen_crbword_t *)  address = 0;
address.reg_addr = reg;
address.phy_addr = phy;
if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR
(0),
   address, 4))
-   return -1;
+   return -EIO;
*(netxen_crbword_t *)  command = 0;/* turn off any prior
activity */
if (netxen_nic_hw_write_wx(adapter,
NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
   command, 4))
-   return -1;
+   return -EIO;
/* send read command */
command.read_cycle = 1;
if (netxen_nic_hw_write_wx(adapter,
NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
   command, 4))
-   return -1;
+   return -EIO;

*(netxen_crbword_t *)  status = 0;
do {
if (netxen_nic_hw_read_wx(adapter,

NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
  status, 4))
-   return -1;
+   return -EIO;
timeout++;
} while ((status.busy || status.notvalid)
  (timeout++  NETXEN_NIU_PHY_WAITMAX));
@@ -135,7 +119,7 @@
if (netxen_nic_hw_read_wx(adapter,
  NETXEN_NIU_GB_MII_MGMT_STATUS
(0),
  readval, 4))
-   return -1;
+   return -EIO;
result = 0;
} else
result = -1;
@@ -144,7 +128,7 @@
if (netxen_nic_hw_write_wx(adapter,
   NETXEN_NIU_GB_MAC_CONFIG_0
(0),
   mac_cfg0, 4))
-   return -1;
+   return -EIO;

return result;
 }
@@ -176,7 +160,7 @@
/* MII mgmt all goes through port 0 MAC interface, so it cannot
be in reset */
if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0
(0),
  mac_cfg0, 4))
-   return -1;
+   return -EIO;
if (mac_cfg0.soft_reset) {
struct netxen_niu_gb_mac_config_0_t temp;
*(netxen_crbword_t *)  temp = 0;
@@ -187,46 +171,46 @@
if (netxen_nic_hw_write_wx(adapter,
   NETXEN_NIU_GB_MAC_CONFIG_0
(0),
   temp, 4))
-   return -1;
+   return -EIO;
restore = 1;
}

*(netxen_crbword_t *)  command = 0;/* turn off any prior
activity */
if (netxen_nic_hw_write_wx(adapter,
NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
   command, 4))
-   return -1;
+   return -EIO;

*(netxen_crbword_t *)  address = 0;
address.reg_addr = reg;