Skip to contentSkip to conversation

Mostly resending patches

PATCH In review Mark Einon 3 participants 30 messages Oct 18, 2011 – Oct 19, 2011 Staging

lore
Share & tools
lore

Mark Einon

author
#0 lore raw

cover Mostly resending patches

First 19 patches are resends requested by greg KH, the remaining 7 patches are code tidy ups.

Mark Einon (26):
staging: et131x: Put all .c files into one big file
staging: et131x: Move function declarations from et131x.h to et131x.c
staging: et131x: Move non-register defines from et131x.h to et131x.c
staging: et131x: move et1310_address_map.h contents into et131x.h
staging: et131x: move et1310_phy.h contents into et131x.h
staging: et131x: move et131x_adapter.h contents into et131x.c
staging: et131x: move et131x_defs.h contents into et131x.c
staging: et131x: move et1310_rx.h contents into et131x.c
staging: et131x: move et1310_tx.h contents into et131x.c
staging: et131x: Update TODO list - remove 'put driver into single file'
staging: et131x: Moving two extern inline functions to .c file
staging: et131x: Make rx_ring.fbr{0,1} share a common structure
staging: et131x: Fix issues when USE_FBR0 is not defined
staging: et131x: use dma_alloc... instead of pci_alloc...
staging: et131x: Match dma_alloc_ calls with dma_free_ calls
staging: et131x: Tidy up PCI device table definition
staging: et131x: on transmit, stop the queue if the next packet will fail
staging: et131x: Convert rest of pci memory management to dma api
staging: et131x: Remove unused defines
staging: et131x: Remove unused rx_ring.recv_buffer_pool
staging: et131x: Remove redundant et131x_reset_recv() call
staging: et131x: Remove call to find pci pm capability
staging: et131x: Remove unused rx_ring.recv_packet_pool
staging: et131x: Remove some forward declarations
staging: et131x: Remove forward declaration of et131x_adapter_setup
staging: et131x: Remove more forward declarations

 drivers/staging/et131x/Makefile             |   11 -
 drivers/staging/et131x/README               |    5 -
 drivers/staging/et131x/et1310_address_map.h | 1436 -------
 drivers/staging/et131x/et1310_eeprom.c      |  408 --
 drivers/staging/et131x/et1310_mac.c         |  654 ----
 drivers/staging/et131x/et1310_phy.c         |  375 --
 drivers/staging/et131x/et1310_phy.h         |  292 --
 drivers/staging/et131x/et1310_pm.c          |  204 -
 drivers/staging/et131x/et1310_rx.c          | 1160 ------
 drivers/staging/et131x/et1310_rx.h          |  245 --
 drivers/staging/et131x/et1310_tx.c          |  793 ----
 drivers/staging/et131x/et1310_tx.h          |  150 -
 drivers/staging/et131x/et131x.c             | 5527 +++++++++++++++++++++++++++
 drivers/staging/et131x/et131x.h             | 1718 ++++++++-
 drivers/staging/et131x/et131x_adapter.h     |  218 --
 drivers/staging/et131x/et131x_defs.h        |  128 -
 drivers/staging/et131x/et131x_ethtool.c     |  201 -
 drivers/staging/et131x/et131x_initpci.c     |  950 -----
 drivers/staging/et131x/et131x_isr.c         |  442 ---
 drivers/staging/et131x/et131x_netdev.c      |  662 ----
 20 files changed, 7142 insertions(+), 8437 deletions(-)
author
#1 lore raw

PATCH RESEND 1/26 staging: et131x: Put all .c files into one big file

Created one big .c file for the driver, moving the contents of all driver .c files into it.

---
 drivers/staging/et131x/Makefile         |   11 -
 drivers/staging/et131x/et1310_eeprom.c  |  408 ---
 drivers/staging/et131x/et1310_mac.c     |  654 ----
 drivers/staging/et131x/et1310_phy.c     |  375 ---
 drivers/staging/et131x/et1310_pm.c      |  204 --
 drivers/staging/et131x/et1310_rx.c      | 1160 -------
 drivers/staging/et131x/et1310_tx.c      |  793 -----
 drivers/staging/et131x/et131x.c         | 5042 +++++++++++++++++++++++++++++++
 drivers/staging/et131x/et131x.h         |   62 +-
 drivers/staging/et131x/et131x_ethtool.c |  201 --
 drivers/staging/et131x/et131x_initpci.c |  950 ------
 drivers/staging/et131x/et131x_isr.c     |  442 ---
 drivers/staging/et131x/et131x_netdev.c  |  662 ----
 13 files changed, 5102 insertions(+), 5862 deletions(-)
 delete mode 100644 drivers/staging/et131x/et1310_eeprom.c
 delete mode 100644 drivers/staging/et131x/et1310_mac.c
 delete mode 100644 drivers/staging/et131x/et1310_phy.c
 delete mode 100644 drivers/staging/et131x/et1310_pm.c
 delete mode 100644 drivers/staging/et131x/et1310_rx.c
 delete mode 100644 drivers/staging/et131x/et1310_tx.c
 create mode 100644 drivers/staging/et131x/et131x.c
 delete mode 100644 drivers/staging/et131x/et131x_ethtool.c
 delete mode 100644 drivers/staging/et131x/et131x_initpci.c
 delete mode 100644 drivers/staging/et131x/et131x_isr.c
 delete mode 100644 drivers/staging/et131x/et131x_netdev.c
drivers/staging/et131x/Makefile +0 -11
index 5ea0272..027ff94 100644
@@ -3,14 +3,3 @@
 #
 
 obj-$(CONFIG_ET131X) += et131x.o
-
-et131x-y :=	et1310_eeprom.o \
-		et1310_mac.o \
-		et1310_phy.o \
-		et1310_pm.o \
-		et1310_rx.o \
-		et1310_tx.o \
-		et131x_initpci.o \
-		et131x_ethtool.o \
-		et131x_isr.o \
-		et131x_netdev.o
drivers/staging/et131x/et1310_eeprom.c deleted +0 -0
deleted file mode 100644
index 20b9660..0000000
drivers/staging/et131x/et1310_mac.c deleted +0 -0
deleted file mode 100644
index 65179a3..0000000
drivers/staging/et131x/et1310_phy.c deleted +0 -0
deleted file mode 100644
index b809dd4..0000000
drivers/staging/et131x/et1310_pm.c deleted +0 -0
deleted file mode 100644
index 91d47dc..0000000
drivers/staging/et131x/et1310_rx.c deleted +0 -0
deleted file mode 100644
index 814922b..0000000
drivers/staging/et131x/et1310_tx.c deleted +0 -0
deleted file mode 100644
index cd12500..0000000
drivers/staging/et131x/et131x.c new file +5042 -0

2,986 lines not on this page · raw message

drivers/staging/et131x/et131x.h +60 -2

62 lines not on this page · raw message

drivers/staging/et131x/et131x_ethtool.c deleted +0 -0
deleted file mode 100644
index ff95a3e..0000000
drivers/staging/et131x/et131x_initpci.c deleted +0 -0
deleted file mode 100644
index 45ce832..0000000
drivers/staging/et131x/et131x_isr.c deleted +0 -0
deleted file mode 100644
index cf8665b..0000000
drivers/staging/et131x/et131x_netdev.c deleted +0 -0
deleted file mode 100644
index 62070cf..0000000

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.6.4

Part of the diff is not shown here. View the raw message.

#2 lore raw

Re: [PATCH 01/26] staging: et131x: Put all .c files into one big file

Quoted 4 lines · Mark Einon

Created one big .c file for the driver, moving the contents of all driver .c files into it.

Something is wrong here, when I try to apply this patch with git, I get the following errors:

$ git am -s ../s2
Applying: staging: et131x: Put all .c files into one big file
error: removal patch leaves file contents
error: drivers/staging/et131x/et1310_eeprom.c: patch does not apply
error: removal patch leaves file contents
error: drivers/staging/et131x/et1310_mac.c: patch does not apply
error: removal patch leaves file contents
error: drivers/staging/et131x/et1310_phy.c: patch does not apply
error: removal patch leaves file contents
error: drivers/staging/et131x/et1310_pm.c: patch does not apply
error: removal patch leaves file contents
error: drivers/staging/et131x/et1310_rx.c: patch does not apply
error: removal patch leaves file contents
error: drivers/staging/et131x/et1310_tx.c: patch does not apply
/home/gregkh/linux/work/staging/.git/rebase-apply/patch:70: new blank line at EOF.
+
error: removal patch leaves file contents
error: drivers/staging/et131x/et131x_ethtool.c: patch does not apply
error: removal patch leaves file contents
error: drivers/staging/et131x/et131x_initpci.c: patch does not apply
error: removal patch leaves file contents
error: drivers/staging/et131x/et131x_isr.c: patch does not apply
error: removal patch leaves file contents
error: drivers/staging/et131x/et131x_netdev.c: patch does not apply
Patch failed at 0001 staging: et131x: Put all .c files into one big file
When you have resolved this problem run "git am --resolved".
If you would prefer to skip this patch, instead run "git am --skip".
To restore the original branch and stop patching run "git am --abort".

Your patch is in the mbox called '../s2' above.

Care to resend it with the file actually deleted? How are you generating this patch?

And, when you resend the series, don't put the [RESEND] in the subject, I had to edit that out in order to apply them properly (which turned out to be a waste of time due to this patch not applying...)

thanks,

greg k-h

author
#3 lore raw

Re: [PATCH 01/26] staging: et131x: Put all .c files into one big file

Quoted 8 lines · Greg KH
Quoted 4 lines · Mark Einon

Created one big .c file for the driver, moving the contents of all driver .c files into it.

Something is wrong here, when I try to apply this patch with git, I get the following errors:

[...]

Quoted 7 lines

Care to resend it with the file actually deleted?  How are you generating this patch?

And, when you resend the series, don't put the [RESEND] in the subject, I had to edit that out in order to apply them properly (which turned out to be a waste of time due to this patch not applying...)

Apologies Greg, I didn't mean to waste your time.

I've used this command to generate the patch, in order not to include the entire file contents that have been deleted:

git format-patch -D <to-list> <patches>

I also assumed RESEND was commonly used for the purpose of resending patches. Is this not the case?

Cheers,

Mark

#4 lore raw

Re: [PATCH 01/26] staging: et131x: Put all .c files into one big file

Quoted 18 lines · Mark Einon
Quoted 8 lines · Greg KH
Quoted 4 lines · Mark Einon

Created one big .c file for the driver, moving the contents of all driver .c files into it.

Something is wrong here, when I try to apply this patch with git, I get the following errors:

[...]

Quoted 7 lines

Care to resend it with the file actually deleted?  How are you generating this patch?

And, when you resend the series, don't put the [RESEND] in the subject, I had to edit that out in order to apply them properly (which turned out to be a waste of time due to this patch not applying...)

Quoted 6 lines

Apologies Greg, I didn't mean to waste your time.

I've used this command to generate the patch, in order not to include the entire file contents that have been deleted:

git format-patch -D <to-list> <patches>

I use:
git format-patch -k -M

If you read the man page for git format-patch, you will see why "-D" does not work at all for this, and this is why I can't apply these patches, you are giving me something that is _known_ to not apply:

-D, --irreversible-delete
Omit the preimage for deletes, i.e. print only the header but not the diff between the preimage and /dev/null. The resulting patch is not meant to be applied with patch nor git apply; this is solely for people who want to just concentrate on reviewing the text after the change. In addition, the output obviously lack enough information to apply such a patch in reverse, even manually, hence the name of the option.

Quoted 2 lines

I also assumed RESEND was commonly used for the purpose of resending patches. Is this not the case?

Yes, but you did it this way:

	[RESEND][PATCH 02/XX]

and git will just strip off the first [] chunk when applying it. So unless I wanted the [PATCH...] portion in the changelog, I had to delete it by hand.

You can do:
[RESEND PATCH 03/XX]
and all would be almost ok, but when I sort the emails, it would break order.

So best is:
[PATCH 03/XX RESEND]
if you really need the RESEND comment. Personally, I would only do that in the [00/XX] patch as that's what counts here. You aren't resending because I ignored them, but because there was a problem with them, so you know I didn't apply those original ones.

hope this helps,

greg k-h

author
#5 lore raw

PATCH RESEND 2/26 staging: et131x: Move function declarations from et131x.h to et131x.c

In reply to Mark Einon

The function declarations in et131x.h are no longer used now all functions are in one file. Removed declarations from et131x.h and added any required forward declarations to et131x.c.

---
 drivers/staging/et131x/et131x.c |   31 ++++++++++++
 drivers/staging/et131x/et131x.h |  102 ---------------------------------------
 2 files changed, 31 insertions(+), 102 deletions(-)
drivers/staging/et131x/et131x.c +31 -0
index fdf6385..a038a37 100644
@@ -96,6 +96,37 @@ MODULE_LICENSE("Dual BSD/GPL");
 MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver "
 		   "for the ET1310 by Agere Systems");
 
+void et131x_error_timer_handler(unsigned long data);
+void et131x_enable_interrupts(struct et131x_adapter *adapter);
+void et131x_disable_interrupts(struct et131x_adapter *adapter);
+void et131x_align_allocated_memory(struct et131x_adapter *adapter,
+				   u64 *phys_addr,
+				   u64 *offset, u64 mask);
+void et131x_adapter_setup(struct et131x_adapter *adapter);
+void et131x_soft_reset(struct et131x_adapter *adapter);
+void et131x_isr_handler(struct work_struct *work);
+void et1310_setup_device_for_multicast(struct et131x_adapter *adapter);
+void et1310_setup_device_for_unicast(struct et131x_adapter *adapter);
+void et131x_up(struct net_device *netdev);
+void et131x_down(struct net_device *netdev);
+struct net_device *et131x_device_alloc(void);
+void et131x_enable_txrx(struct net_device *netdev);
+void et131x_disable_txrx(struct net_device *netdev);
+int et1310_in_phy_coma(struct et131x_adapter *adapter);
+void et1310_phy_access_mii_bit(struct et131x_adapter *adapter,
+			       u16 action,
+			       u16 regnum, u16 bitnum, u8 *value);
+int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr,
+	      u8 reg, u16 *value);
+int32_t et131x_mii_write(struct et131x_adapter *adapter,
+		u8 reg, u16 value);
+void et131x_rx_dma_memory_free(struct et131x_adapter *adapter);
+void et131x_rx_dma_disable(struct et131x_adapter *adapter);
+void et131x_rx_dma_enable(struct et131x_adapter *adapter);
+void et131x_reset_recv(struct et131x_adapter *adapter);
+void et131x_init_send(struct et131x_adapter *adapter);
+void et131x_tx_dma_enable(struct et131x_adapter *adapter);
+
 /* EEPROM functions */
 
 static int eeprom_wait_ready(struct pci_dev *pdev, u32 *status)
drivers/staging/et131x/et131x.h +0 -102

105 lines not on this page · raw message

Signature · 1 line
1.7.6.4
author
#6 lore raw

PATCH RESEND 3/26 staging: et131x: Move non-register defines from et131x.h to et131x.c

In reply to Mark Einon

Header file should only have register defines, moved non-register defines to et131x.c

---
 drivers/staging/et131x/et131x.c |   31 +++++++++++++++++++++++++++++++
 drivers/staging/et131x/et131x.h |   33 +--------------------------------
 2 files changed, 32 insertions(+), 32 deletions(-)
drivers/staging/et131x/et131x.c +31 -0
index a038a37..cad271b 100644
@@ -96,6 +96,37 @@ MODULE_LICENSE("Dual BSD/GPL");
 MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver "
 		   "for the ET1310 by Agere Systems");
 
+/* EEPROM defines */
+#define MAX_NUM_REGISTER_POLLS          1000
+#define MAX_NUM_WRITE_RETRIES           2
+
+/* MAC defines */
+#define COUNTER_WRAP_16_BIT 0x10000
+#define COUNTER_WRAP_12_BIT 0x1000
+
+/* PCI defines */
+#define INTERNAL_MEM_SIZE       0x400	/* 1024 of internal memory */
+#define INTERNAL_MEM_RX_OFFSET  0x1FF	/* 50%   Tx, 50%   Rx */
+
+/* ISR defines */
+/*
+ * For interrupts, normal running is:
+ *       rxdma_xfr_done, phy_interrupt, mac_stat_interrupt,
+ *       watchdog_interrupt & txdma_xfer_done
+ *
+ * In both cases, when flow control is enabled for either Tx or bi-direction,
+ * we additional enable rx_fbr0_low and rx_fbr1_low, so we know when the
+ * buffer rings are running low.
+ */
+#define INT_MASK_DISABLE            0xffffffff
+
+/* NOTE: Masking out MAC_STAT Interrupt for now...
+ * #define INT_MASK_ENABLE             0xfff6bf17
+ * #define INT_MASK_ENABLE_NO_FLOW     0xfff6bfd7
+ */
+#define INT_MASK_ENABLE             0xfffebf17
+#define INT_MASK_ENABLE_NO_FLOW     0xfffebfd7
+
 void et131x_error_timer_handler(unsigned long data);
 void et131x_enable_interrupts(struct et131x_adapter *adapter);
 void et131x_disable_interrupts(struct et131x_adapter *adapter);
drivers/staging/et131x/et131x.h +1 -32
index 71fd7fe..115d307 100644
@@ -49,7 +49,7 @@
 #define DRIVER_NAME "et131x"
 #define DRIVER_VERSION "v2.0"
 
-/* EEPROM defines */
+/* EEPROM registers */
 
 /* LBCIF Register Groups (addressed via 32-bit offsets) */
 #define LBCIF_DWORD0_GROUP       0xAC
@@ -77,34 +77,3 @@
 #define LBCIF_STATUS_CHECKSUM_ERROR     0x40
 #define LBCIF_STATUS_EEPROM_PRESENT     0x80
 
-/* Miscellaneous Constraints */
-#define MAX_NUM_REGISTER_POLLS          1000
-#define MAX_NUM_WRITE_RETRIES           2
-
-/* MAC defines */
-#define COUNTER_WRAP_16_BIT 0x10000
-#define COUNTER_WRAP_12_BIT 0x1000
-
-/* PCI defines */
-#define INTERNAL_MEM_SIZE       0x400	/* 1024 of internal memory */
-#define INTERNAL_MEM_RX_OFFSET  0x1FF	/* 50%   Tx, 50%   Rx */
-
-/* ISR defines */
-/*
- * For interrupts, normal running is:
- *       rxdma_xfr_done, phy_interrupt, mac_stat_interrupt,
- *       watchdog_interrupt & txdma_xfer_done
- *
- * In both cases, when flow control is enabled for either Tx or bi-direction,
- * we additional enable rx_fbr0_low and rx_fbr1_low, so we know when the
- * buffer rings are running low.
- */
-#define INT_MASK_DISABLE            0xffffffff
-
-/* NOTE: Masking out MAC_STAT Interrupt for now...
- * #define INT_MASK_ENABLE             0xfff6bf17
- * #define INT_MASK_ENABLE_NO_FLOW     0xfff6bfd7
- */
-#define INT_MASK_ENABLE             0xfffebf17
-#define INT_MASK_ENABLE_NO_FLOW     0xfffebfd7
-
Signature · 1 line
1.7.6.4
author
#7 lore raw

PATCH RESEND 4/26 staging: et131x: move et1310_address_map.h contents into et131x.h

In reply to Mark Einon

Move et1310_address_map.h register defines into et131x.h and delete et1310_address_map.h

---
 drivers/staging/et131x/et1310_address_map.h | 1436 ---------------------------
 drivers/staging/et131x/et1310_phy.h         |    2 -
 drivers/staging/et131x/et1310_rx.h          |    2 -
 drivers/staging/et131x/et131x.c             |    1 -
 drivers/staging/et131x/et131x.h             | 1370 +++++++++++++++++++++++++
 drivers/staging/et131x/et131x_adapter.h     |    1 -
 6 files changed, 1370 insertions(+), 1442 deletions(-)
 delete mode 100644 drivers/staging/et131x/et1310_address_map.h
drivers/staging/et131x/et1310_address_map.h deleted +0 -0
deleted file mode 100644
index b502ce3..0000000
drivers/staging/et131x/et1310_phy.h +0 -2
index 2803bdf..feb5761 100644
@@ -61,8 +61,6 @@
 #ifndef _ET1310_PHY_H_
 #define _ET1310_PHY_H_
 
-#include "et1310_address_map.h"
-
 /*
  * Defines for generic MII registers 0x00 -> 0x0F can be found in
  * include/linux/mii.h
drivers/staging/et131x/et1310_rx.h +0 -2
index a19fab9..b3b1bc9 100644
@@ -61,8 +61,6 @@
 #ifndef __ET1310_RX_H__
 #define __ET1310_RX_H__
 
-#include "et1310_address_map.h"
-
 #define USE_FBR0 true
 
 #ifdef USE_FBR0
drivers/staging/et131x/et131x.c +0 -1
index cad271b..60ff3bc 100644
@@ -85,7 +85,6 @@
 
 #include "et1310_phy.h"
 #include "et131x_adapter.h"
-#include "et1310_address_map.h"
 #include "et1310_tx.h"
 #include "et1310_rx.h"
 #include "et131x.h"
drivers/staging/et131x/et131x.h +1370 -0

1,373 lines not on this page · raw message

drivers/staging/et131x/et131x_adapter.h +0 -1
index b062e6d..74efdb0 100644
@@ -61,7 +61,6 @@
 #ifndef __ET131X_ADAPTER_H__
 #define __ET131X_ADAPTER_H__
 
-#include "et1310_address_map.h"
 #include "et1310_tx.h"
 #include "et1310_rx.h"
 
Signature · 1 line
1.7.6.4
author
#8 lore raw

PATCH RESEND 5/26 staging: et131x: move et1310_phy.h contents into et131x.h

In reply to Mark Einon

Move et1310_phy.h register defines into et131x.h and delete et1310_phy.h

---
 drivers/staging/et131x/et1310_phy.h |  290 -----------------------------------
 drivers/staging/et131x/et131x.c     |    1 -
 drivers/staging/et131x/et131x.h     |  227 +++++++++++++++++++++++++++
 3 files changed, 227 insertions(+), 291 deletions(-)
 delete mode 100644 drivers/staging/et131x/et1310_phy.h
drivers/staging/et131x/et1310_phy.h deleted +0 -0
deleted file mode 100644
index feb5761..0000000
drivers/staging/et131x/et131x.c +0 -1
index 60ff3bc..271ae31 100644
@@ -83,7 +83,6 @@
 #include <linux/random.h>
 #include <linux/phy.h>
 
-#include "et1310_phy.h"
 #include "et131x_adapter.h"
 #include "et1310_tx.h"
 #include "et1310_rx.h"
drivers/staging/et131x/et131x.h +227 -0

230 lines not on this page · raw message

Signature · 1 line
1.7.6.4
author
#9 lore raw

PATCH RESEND 6/26 staging: et131x: move et131x_adapter.h contents into et131x.c

In reply to Mark Einon

Move et131x_adapter.h contents into et131x.c and delete et131x_adapter.h

---
 drivers/staging/et131x/et131x.c         |  152 +++++++++++++++++++++-
 drivers/staging/et131x/et131x_adapter.h |  217 -------------------------------
 2 files changed, 151 insertions(+), 218 deletions(-)
 delete mode 100644 drivers/staging/et131x/et131x_adapter.h
drivers/staging/et131x/et131x.c +151 -1
index 271ae31..e88c277 100644
@@ -83,7 +83,6 @@
 #include <linux/random.h>
 #include <linux/phy.h>
 
-#include "et131x_adapter.h"
 #include "et1310_tx.h"
 #include "et1310_rx.h"
 #include "et131x.h"
@@ -125,6 +124,157 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver "
 #define INT_MASK_ENABLE             0xfffebf17
 #define INT_MASK_ENABLE_NO_FLOW     0xfffebfd7
 
+/* ADAPTER defines */
+/*
+ * Do not change these values: if changed, then change also in respective
+ * TXdma and Rxdma engines
+ */
+#define NUM_DESC_PER_RING_TX         512    /* TX Do not change these values */
+#define NUM_TCB                      64
+
+/*
+ * These values are all superseded by registry entries to facilitate tuning.
+ * Once the desired performance has been achieved, the optimal registry values
+ * should be re-populated to these #defines:
+ */
+#define NUM_TRAFFIC_CLASSES          1
+
+#define TX_ERROR_PERIOD             1000
+
+#define LO_MARK_PERCENT_FOR_PSR     15
+#define LO_MARK_PERCENT_FOR_RX      15
+
+/* RFD (Receive Frame Descriptor) */
+struct rfd {
+	struct list_head list_node;
+	struct sk_buff *skb;
+	u32 len;	/* total size of receive frame */
+	u16 bufferindex;
+	u8 ringindex;
+};
+
+/* Flow Control */
+#define FLOW_BOTH	0
+#define FLOW_TXONLY	1
+#define FLOW_RXONLY	2
+#define FLOW_NONE	3
+
+/* Struct to define some device statistics */
+struct ce_stats {
+	/* MIB II variables
+	 *
+	 * NOTE: atomic_t types are only guaranteed to store 24-bits; if we
+	 * MUST have 32, then we'll need another way to perform atomic
+	 * operations
+	 */
+	u32		unicast_pkts_rcvd;
+	atomic_t	unicast_pkts_xmtd;
+	u32		multicast_pkts_rcvd;
+	atomic_t	multicast_pkts_xmtd;
+	u32		broadcast_pkts_rcvd;
+	atomic_t	broadcast_pkts_xmtd;
+	u32		rcvd_pkts_dropped;
+
+	/* Tx Statistics. */
+	u32		tx_underflows;
+
+	u32		tx_collisions;
+	u32		tx_excessive_collisions;
+	u32		tx_first_collisions;
+	u32		tx_late_collisions;
+	u32		tx_max_pkt_errs;
+	u32		tx_deferred;
+
+	/* Rx Statistics. */
+	u32		rx_overflows;
+
+	u32		rx_length_errs;
+	u32		rx_align_errs;
+	u32		rx_crc_errs;
+	u32		rx_code_violations;
+	u32		rx_other_errs;
+
+	u32		synchronous_iterations;
+	u32		interrupt_status;
+};
+
+/* The private adapter structure */
+struct et131x_adapter {
+	struct net_device *netdev;
+	struct pci_dev *pdev;
+	struct mii_bus *mii_bus;
+	struct phy_device *phydev;
+	struct work_struct task;
+
+	/* Flags that indicate current state of the adapter */
+	u32 flags;
+
+	/* local link state, to determine if a state change has occurred */
+	int link;
+
+	/* Configuration  */
+	u8 rom_addr[ETH_ALEN];
+	u8 addr[ETH_ALEN];
+	bool has_eeprom;
+	u8 eeprom_data[2];
+
+	/* Spinlocks */
+	spinlock_t lock;
+
+	spinlock_t tcb_send_qlock;
+	spinlock_t tcb_ready_qlock;
+	spinlock_t send_hw_lock;
+
+	spinlock_t rcv_lock;
+	spinlock_t rcv_pend_lock;
+	spinlock_t fbr_lock;
+
+	spinlock_t phy_lock;
+
+	/* Packet Filter and look ahead size */
+	u32 packet_filter;
+
+	/* multicast list */
+	u32 multicast_addr_count;
+	u8 multicast_list[NIC_MAX_MCAST_LIST][ETH_ALEN];
+
+	/* Pointer to the device's PCI register space */
+	struct address_map __iomem *regs;
+
+	/* Registry parameters */
+	u8 wanted_flow;		/* Flow we want for 802.3x flow control */
+	u32 registry_jumbo_packet;	/* Max supported ethernet packet size */
+
+	/* Derived from the registry: */
+	u8 flowcontrol;		/* flow control validated by the far-end */
+
+	/* Minimize init-time */
+	struct timer_list error_timer;
+
+	/* variable putting the phy into coma mode when boot up with no cable
+	 * plugged in after 5 seconds
+	 */
+	u8 boot_coma;
+
+	/* Next two used to save power information at power down. This
+	 * information will be used during power up to set up parts of Power
+	 * Management in JAGCore
+	 */
+	u16 pdown_speed;
+	u8 pdown_duplex;
+
+	/* Tx Memory Variables */
+	struct tx_ring tx_ring;
+
+	/* Rx Memory Variables */
+	struct rx_ring rx_ring;
+
+	/* Stats */
+	struct ce_stats stats;
+
+	struct net_device_stats net_stats;
+};
+
 void et131x_error_timer_handler(unsigned long data);
 void et131x_enable_interrupts(struct et131x_adapter *adapter);
 void et131x_disable_interrupts(struct et131x_adapter *adapter);
drivers/staging/et131x/et131x_adapter.h deleted +0 -0
deleted file mode 100644
index 74efdb0..0000000
Signature · 1 line
1.7.6.4
author
#10 lore raw

PATCH RESEND 7/26 staging: et131x: move et131x_defs.h contents into et131x.c

In reply to Mark Einon

Move et131x_defs.h contents into et131x.c and delete et131x_defs.h

---
 drivers/staging/et131x/et131x.c      |   66 +++++++++++++++++-
 drivers/staging/et131x/et131x_defs.h |  128 ----------------------------------
 2 files changed, 64 insertions(+), 130 deletions(-)
 delete mode 100644 drivers/staging/et131x/et131x_defs.h
drivers/staging/et131x/et131x.c +64 -2
index e88c277..402ab7f 100644
@@ -53,8 +53,6 @@
  *
  */
 
-#include "et131x_defs.h"
-
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/module.h>
@@ -124,6 +122,70 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver "
 #define INT_MASK_ENABLE             0xfffebf17
 #define INT_MASK_ENABLE_NO_FLOW     0xfffebfd7
 
+/* General defines */
+/* Packet and header sizes */
+#define NIC_MIN_PACKET_SIZE	60
+
+/* Multicast list size */
+#define NIC_MAX_MCAST_LIST	128
+
+/* Supported Filters */
+#define ET131X_PACKET_TYPE_DIRECTED		0x0001
+#define ET131X_PACKET_TYPE_MULTICAST		0x0002
+#define ET131X_PACKET_TYPE_BROADCAST		0x0004
+#define ET131X_PACKET_TYPE_PROMISCUOUS		0x0008
+#define ET131X_PACKET_TYPE_ALL_MULTICAST	0x0010
+
+/* Tx Timeout */
+#define ET131X_TX_TIMEOUT	(1 * HZ)
+#define NIC_SEND_HANG_THRESHOLD	0
+
+/* MP_TCB flags */
+#define fMP_DEST_MULTI			0x00000001
+#define fMP_DEST_BROAD			0x00000002
+
+/* MP_ADAPTER flags */
+#define fMP_ADAPTER_RECV_LOOKASIDE	0x00000004
+#define fMP_ADAPTER_INTERRUPT_IN_USE	0x00000008
+#define fMP_ADAPTER_SECONDARY		0x00000010
+
+/* MP_SHARED flags */
+#define fMP_ADAPTER_SHUTDOWN		0x00100000
+#define fMP_ADAPTER_LOWER_POWER		0x00200000
+
+#define fMP_ADAPTER_NON_RECOVER_ERROR	0x00800000
+#define fMP_ADAPTER_RESET_IN_PROGRESS	0x01000000
+#define fMP_ADAPTER_NO_CABLE		0x02000000
+#define fMP_ADAPTER_HARDWARE_ERROR	0x04000000
+#define fMP_ADAPTER_REMOVE_IN_PROGRESS	0x08000000
+#define fMP_ADAPTER_HALT_IN_PROGRESS	0x10000000
+
+#define fMP_ADAPTER_FAIL_SEND_MASK	0x3ff00000
+#define fMP_ADAPTER_NOT_READY_MASK	0x3ff00000
+
+/* Some offsets in PCI config space that are actually used. */
+#define ET1310_PCI_MAX_PYLD		0x4C
+#define ET1310_PCI_MAC_ADDRESS		0xA4
+#define ET1310_PCI_EEPROM_STATUS	0xB2
+#define ET1310_PCI_ACK_NACK		0xC0
+#define ET1310_PCI_REPLAY		0xC2
+#define ET1310_PCI_L0L1LATENCY		0xCF
+
+/* PCI Vendor/Product IDs */
+#define ET131X_PCI_VENDOR_ID		0x11C1	/* Agere Systems */
+#define ET131X_PCI_DEVICE_ID_GIG	0xED00	/* ET1310 1000 Base-T 8 */
+#define ET131X_PCI_DEVICE_ID_FAST	0xED01	/* ET1310 100  Base-T */
+
+/* Define order of magnitude converter */
+#define NANO_IN_A_MICRO	1000
+
+#define PARM_RX_NUM_BUFS_DEF    4
+#define PARM_RX_TIME_INT_DEF    10
+#define PARM_RX_MEM_END_DEF     0x2bc
+#define PARM_TX_TIME_INT_DEF    40
+#define PARM_TX_NUM_BUFS_DEF    4
+#define PARM_DMA_CACHE_DEF      0
+
 /* ADAPTER defines */
 /*
  * Do not change these values: if changed, then change also in respective
drivers/staging/et131x/et131x_defs.h deleted +0 -0
deleted file mode 100644
index 872a5af..0000000
Signature · 1 line
1.7.6.4
author
#11 lore raw

PATCH RESEND 8/26 staging: et131x: move et1310_rx.h contents into et131x.c

In reply to Mark Einon

Move et1310_rx.h contents into et131x.c and delete et1310_rx.h

---
 drivers/staging/et131x/et1310_rx.h |  243 ------------------------------------
 drivers/staging/et131x/et131x.c    |  181 ++++++++++++++++++++++++++-
 2 files changed, 180 insertions(+), 244 deletions(-)
 delete mode 100644 drivers/staging/et131x/et1310_rx.h
drivers/staging/et131x/et1310_rx.h deleted +0 -0
deleted file mode 100644
index b3b1bc9..0000000
drivers/staging/et131x/et131x.c +180 -1

193 lines not on this page · raw message

Signature · 1 line
1.7.6.4
author
#12 lore raw

PATCH RESEND 9/26 staging: et131x: move et1310_tx.h contents into et131x.c

In reply to Mark Einon

Move et1310_tx.h contents into et131x.c and delete et1310_tx.h

---
 drivers/staging/et131x/et1310_tx.h |  150 ------------------------------------
 drivers/staging/et131x/et131x.c    |   87 ++++++++++++++++++++-
 2 files changed, 86 insertions(+), 151 deletions(-)
 delete mode 100644 drivers/staging/et131x/et1310_tx.h
drivers/staging/et131x/et1310_tx.h deleted +0 -0
deleted file mode 100644
index 82d06e9..0000000
drivers/staging/et131x/et131x.c +86 -1

99 lines not on this page · raw message

Signature · 1 line
1.7.6.4
author
#13 lore raw

PATCH RESEND 10/26 staging: et131x: Update TODO list - remove 'put driver into single file'

In reply to Mark Einon

Driver now resides in a single file with a separate header with registers, updated the README TODO list.

---
 drivers/staging/et131x/README |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/staging/et131x/README +0 -1
index c67f83e..a7b33dc 100644
@@ -8,7 +8,6 @@ Note, the powermanagement options were removed from the vendor provided
 driver as they did not build properly at the time.
 
 TODO:
-	- Put the driver into a single file, with a .h for the registers layout.
 	- rx_ring.fbr{0, 1} can probably share a common structure
 	- Use of kmem_cache seems a bit unusual
 	- Use dma_alloc_... in place of pci_alloc_...
Signature · 1 line
1.7.6.4
author
#14 lore raw

PATCH RESEND 11/26 staging: et131x: Moving two extern inline functions to .c file

In reply to Mark Einon

Two helper functions for adding 10bit/12bit umbers with wrapping are defined in the header. Moved them to the driver .c file.

---
 drivers/staging/et131x/et131x.c |   11 +++++++++++
 drivers/staging/et131x/et131x.h |   10 ----------
 2 files changed, 11 insertions(+), 10 deletions(-)
drivers/staging/et131x/et131x.c +11 -0
index 9596102..14f54e4 100644
@@ -2666,6 +2666,17 @@ void et131x_rx_dma_enable(struct et131x_adapter *adapter)
 	}
 }
 
+
+static inline void add_10bit(u32 *v, int n)
+{
+	*v = INDEX10(*v + n) | (*v & ET_DMA10_WRAP);
+}
+
+static inline void add_12bit(u32 *v, int n)
+{
+	*v = INDEX12(*v + n) | (*v & ET_DMA12_WRAP);
+}
+
 /**
  * nic_rx_pkts - Checks the hardware for available packets
  * @adapter: pointer to our adapter
drivers/staging/et131x/et131x.h +0 -10
index 84b274d..7eed3c8 100644
@@ -230,16 +230,6 @@ struct global_regs {				/* Location: */
 #define INDEX10(x)	((x) & ET_DMA10_MASK)
 #define INDEX4(x)	((x) & ET_DMA4_MASK)
 
-extern inline void add_10bit(u32 *v, int n)
-{
-	*v = INDEX10(*v + n) | (*v & ET_DMA10_WRAP);
-}
-
-extern inline void add_12bit(u32 *v, int n)
-{
-	*v = INDEX12(*v + n) | (*v & ET_DMA12_WRAP);
-}
-
 /*
  * 10bit DMA with wrap
  * txdma tx queue write address reg in txdma address map at 0x1010
Signature · 1 line
1.7.6.4
author
#15 lore raw

PATCH RESEND 12/26 staging: et131x: Make rx_ring.fbr{0,1} share a common structure

In reply to Mark Einon

Sharing a common structure by moving common structure items into fbr_lookup.

TODO - Currently will not work if USE_FBR0 = 0 as FBR1 uses fbr[1] which is removed in this case

---
 drivers/staging/et131x/et131x.c |  293 +++++++++++++++++++--------------------
 1 files changed, 140 insertions(+), 153 deletions(-)
drivers/staging/et131x/et131x.c +140 -153
index 14f54e4..0bc3e04 100644
@@ -185,13 +185,7 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver "
 #define PARM_DMA_CACHE_DEF      0
 
 /* RX defines */
-#define USE_FBR0 true
-
-#ifdef USE_FBR0
-/* #define FBR0_BUFFER_SIZE 256 */
-#endif
-
-/* #define FBR1_BUFFER_SIZE 2048 */
+#define USE_FBR0 1
 
 #define FBR_CHUNKS 32
 
@@ -200,14 +194,16 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver "
 /* number of RFDs - default and min */
 #ifdef USE_FBR0
 #define RFD_LOW_WATER_MARK	40
-#define NIC_MIN_NUM_RFD		64
 #define NIC_DEFAULT_NUM_RFD	1024
+#define NUM_FBRS		2
 #else
 #define RFD_LOW_WATER_MARK	20
-#define NIC_MIN_NUM_RFD		64
 #define NIC_DEFAULT_NUM_RFD	256
+#define NUM_FBRS		1
 #endif
 
+#define NIC_MIN_NUM_RFD		64
+
 #define NUM_PACKETS_HANDLED	256
 
 #define ALCATEL_BAD_STATUS	0xe47f0000
@@ -303,14 +299,24 @@ struct rx_status_block {
 };
 
 /*
- * Structure for look-up table holding free buffer ring pointers
+ * Structure for look-up table holding free buffer ring pointers, addresses
+ * and state.
  */
 struct fbr_lookup {
-	void *virt[MAX_DESC_PER_RING_RX];
-	void *buffer1[MAX_DESC_PER_RING_RX];
-	void *buffer2[MAX_DESC_PER_RING_RX];
-	u32 bus_high[MAX_DESC_PER_RING_RX];
-	u32 bus_low[MAX_DESC_PER_RING_RX];
+	void		*virt[MAX_DESC_PER_RING_RX];
+	void		*buffer1[MAX_DESC_PER_RING_RX];
+	void		*buffer2[MAX_DESC_PER_RING_RX];
+	u32		 bus_high[MAX_DESC_PER_RING_RX];
+	u32		 bus_low[MAX_DESC_PER_RING_RX];
+	void		*ring_virtaddr;
+	dma_addr_t	 ring_physaddr;
+	void		*mem_virtaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS];
+	dma_addr_t	 mem_physaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS];
+	uint64_t	 real_physaddr;
+	uint64_t	 offset;
+	u32		 local_full;
+	u32		 num_entries;
+	u32		 buffsize;
 };
 
 /*
@@ -318,27 +324,7 @@ struct fbr_lookup {
  * reference(s) to the rings
  */
 struct rx_ring {
-#ifdef USE_FBR0
-	void *fbr0_ring_virtaddr;
-	dma_addr_t fbr0_ring_physaddr;
-	void *fbr0_mem_virtaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS];
-	dma_addr_t fbr0_mem_physaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS];
-	uint64_t fbr0_real_physaddr;
-	uint64_t fbr0_offset;
-	u32 local_fbr0_full;
-	u32 fbr0_num_entries;
-	u32 fbr0_buffsize;
-#endif
-	void *fbr1_ring_virtaddr;
-	dma_addr_t fbr1_ring_physaddr;
-	void *fbr1_mem_virtaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS];
-	dma_addr_t fbr1_mem_physaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS];
-	uint64_t fbr1_real_physaddr;
-	uint64_t fbr1_offset;
-	struct fbr_lookup *fbr[2];	/* One per ring */
-	u32 local_fbr1_full;
-	u32 fbr1_num_entries;
-	u32 fbr1_buffsize;
+	struct fbr_lookup *fbr[NUM_FBRS];
 
 	void *ps_ring_virtaddr;
 	dma_addr_t ps_ring_physaddr;
@@ -1945,40 +1931,40 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
 
 	if (adapter->registry_jumbo_packet < 2048) {
 #ifdef USE_FBR0
-		rx_ring->fbr0_buffsize = 256;
-		rx_ring->fbr0_num_entries = 512;
+		rx_ring->fbr[0]->buffsize = 256;
+		rx_ring->fbr[0]->num_entries = 512;
 #endif
-		rx_ring->fbr1_buffsize = 2048;
-		rx_ring->fbr1_num_entries = 512;
+		rx_ring->fbr[1]->buffsize = 2048;
+		rx_ring->fbr[1]->num_entries = 512;
 	} else if (adapter->registry_jumbo_packet < 4096) {
 #ifdef USE_FBR0
-		rx_ring->fbr0_buffsize = 512;
-		rx_ring->fbr0_num_entries = 1024;
+		rx_ring->fbr[0]->buffsize = 512;
+		rx_ring->fbr[0]->num_entries = 1024;
 #endif
-		rx_ring->fbr1_buffsize = 4096;
-		rx_ring->fbr1_num_entries = 512;
+		rx_ring->fbr[1]->buffsize = 4096;
+		rx_ring->fbr[1]->num_entries = 512;
 	} else {
 #ifdef USE_FBR0
-		rx_ring->fbr0_buffsize = 1024;
-		rx_ring->fbr0_num_entries = 768;
+		rx_ring->fbr[0]->buffsize = 1024;
+		rx_ring->fbr[0]->num_entries = 768;
 #endif
-		rx_ring->fbr1_buffsize = 16384;
-		rx_ring->fbr1_num_entries = 128;
+		rx_ring->fbr[1]->buffsize = 16384;
+		rx_ring->fbr[1]->num_entries = 128;
 	}
 
 #ifdef USE_FBR0
-	adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr0_num_entries +
-	    adapter->rx_ring.fbr1_num_entries;
+	adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr[0]->num_entries +
+	    adapter->rx_ring.fbr[1]->num_entries;
 #else
-	adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr1_num_entries;
+	adapter->rx_ring.psr_num_entries = adapter->rx_ring.fbr[1]->num_entries;
 #endif
 
 	/* Allocate an area of memory for Free Buffer Ring 1 */
-	bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr1_num_entries) + 0xfff;
-	rx_ring->fbr1_ring_virtaddr = pci_alloc_consistent(adapter->pdev,
+	bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[1]->num_entries) + 0xfff;
+	rx_ring->fbr[1]->ring_virtaddr = pci_alloc_consistent(adapter->pdev,
 						bufsize,
-						&rx_ring->fbr1_ring_physaddr);
-	if (!rx_ring->fbr1_ring_virtaddr) {
+						&rx_ring->fbr[1]->ring_physaddr);
+	if (!rx_ring->fbr[1]->ring_virtaddr) {
 		dev_err(&adapter->pdev->dev,
 			  "Cannot alloc memory for Free Buffer Ring 1\n");
 		return -ENOMEM;
@@ -1991,24 +1977,24 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
 	 * are ever returned, make sure the high part is retrieved here
 	 * before storing the adjusted address.
 	 */
-	rx_ring->fbr1_real_physaddr = rx_ring->fbr1_ring_physaddr;
+	rx_ring->fbr[1]->real_physaddr = rx_ring->fbr[1]->ring_physaddr;
 
 	/* Align Free Buffer Ring 1 on a 4K boundary */
 	et131x_align_allocated_memory(adapter,
-				      &rx_ring->fbr1_real_physaddr,
-				      &rx_ring->fbr1_offset, 0x0FFF);
+				      &rx_ring->fbr[1]->real_physaddr,
+				      &rx_ring->fbr[1]->offset, 0x0FFF);
 
-	rx_ring->fbr1_ring_virtaddr =
-			(void *)((u8 *) rx_ring->fbr1_ring_virtaddr +
-			rx_ring->fbr1_offset);
+	rx_ring->fbr[1]->ring_virtaddr =
+			(void *)((u8 *) rx_ring->fbr[1]->ring_virtaddr +
+			rx_ring->fbr[1]->offset);
 
 #ifdef USE_FBR0
 	/* Allocate an area of memory for Free Buffer Ring 0 */
-	bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr0_num_entries) + 0xfff;
-	rx_ring->fbr0_ring_virtaddr = pci_alloc_consistent(adapter->pdev,
+	bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[0]->num_entries) + 0xfff;
+	rx_ring->fbr[0]->ring_virtaddr = pci_alloc_consistent(adapter->pdev,
 						bufsize,
-						&rx_ring->fbr0_ring_physaddr);
-	if (!rx_ring->fbr0_ring_virtaddr) {
+						&rx_ring->fbr[0]->ring_physaddr);
+	if (!rx_ring->fbr[0]->ring_virtaddr) {
 		dev_err(&adapter->pdev->dev,
 			  "Cannot alloc memory for Free Buffer Ring 0\n");
 		return -ENOMEM;
@@ -2021,18 +2007,18 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
 	 * are ever returned, make sure the high part is retrieved here before
 	 * storing the adjusted address.
 	 */
-	rx_ring->fbr0_real_physaddr = rx_ring->fbr0_ring_physaddr;
+	rx_ring->fbr[0]->real_physaddr = rx_ring->fbr[0]->ring_physaddr;
 
 	/* Align Free Buffer Ring 0 on a 4K boundary */
 	et131x_align_allocated_memory(adapter,
-				      &rx_ring->fbr0_real_physaddr,
-				      &rx_ring->fbr0_offset, 0x0FFF);
+				      &rx_ring->fbr[0]->real_physaddr,
+				      &rx_ring->fbr[0]->offset, 0x0FFF);
 
-	rx_ring->fbr0_ring_virtaddr =
-				(void *)((u8 *) rx_ring->fbr0_ring_virtaddr +
-				rx_ring->fbr0_offset);
+	rx_ring->fbr[0]->ring_virtaddr =
+			(void *)((u8 *) rx_ring->fbr[0]->ring_virtaddr +
+			rx_ring->fbr[0]->offset);
 #endif
-	for (i = 0; i < (rx_ring->fbr1_num_entries / FBR_CHUNKS); i++) {
+	for (i = 0; i < (rx_ring->fbr[1]->num_entries / FBR_CHUNKS); i++) {
 		u64 fbr1_offset;
 		u64 fbr1_tmp_physaddr;
 		u32 fbr1_align;
@@ -2044,25 +2030,25 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
 		 * the size of FBR0.  By allocating N buffers at once, we
 		 * reduce this overhead.
 		 */
-		if (rx_ring->fbr1_buffsize > 4096)
+		if (rx_ring->fbr[1]->buffsize > 4096)
 			fbr1_align = 4096;
 		else
-			fbr1_align = rx_ring->fbr1_buffsize;
+			fbr1_align = rx_ring->fbr[1]->buffsize;
 
 		fbr_chunksize =
-		    (FBR_CHUNKS * rx_ring->fbr1_buffsize) + fbr1_align - 1;
-		rx_ring->fbr1_mem_virtaddrs[i] =
+		    (FBR_CHUNKS * rx_ring->fbr[1]->buffsize) + fbr1_align - 1;
+		rx_ring->fbr[1]->mem_virtaddrs[i] =
 		    pci_alloc_consistent(adapter->pdev, fbr_chunksize,
-					 &rx_ring->fbr1_mem_physaddrs[i]);
+					 &rx_ring->fbr[1]->mem_physaddrs[i]);
 
-		if (!rx_ring->fbr1_mem_virtaddrs[i]) {
+		if (!rx_ring->fbr[1]->mem_virtaddrs[i]) {
 			dev_err(&adapter->pdev->dev,
 				"Could not alloc memory\n");
 			return -ENOMEM;
 		}
 
 		/* See NOTE in "Save Physical Address" comment above */
-		fbr1_tmp_physaddr = rx_ring->fbr1_mem_physaddrs[i];
+		fbr1_tmp_physaddr = rx_ring->fbr[1]->mem_physaddrs[i];
 
 		et131x_align_allocated_memory(adapter,
 					      &fbr1_tmp_physaddr,
@@ -2075,8 +2061,8 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
 			 * access later
 			 */
 			rx_ring->fbr[1]->virt[index] =
-			    (u8 *) rx_ring->fbr1_mem_virtaddrs[i] +
-			    (j * rx_ring->fbr1_buffsize) + fbr1_offset;
+			    (u8 *) rx_ring->fbr[1]->mem_virtaddrs[i] +
+			    (j * rx_ring->fbr[1]->buffsize) + fbr1_offset;
 
 			/* now store the physical address in the descriptor
 			 * so the device can access it
@@ -2086,7 +2072,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
 			rx_ring->fbr[1]->bus_low[index] =
 			    (u32) fbr1_tmp_physaddr;
 
-			fbr1_tmp_physaddr += rx_ring->fbr1_buffsize;
+			fbr1_tmp_physaddr += rx_ring->fbr[1]->buffsize;
 
 			rx_ring->fbr[1]->buffer1[index] =
 			    rx_ring->fbr[1]->virt[index];
@@ -2097,43 +2083,43 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
 
 #ifdef USE_FBR0
 	/* Same for FBR0 (if in use) */
-	for (i = 0; i < (rx_ring->fbr0_num_entries / FBR_CHUNKS); i++) {
+	for (i = 0; i < (rx_ring->fbr[0]->num_entries / FBR_CHUNKS); i++) {
 		u64 fbr0_offset;
 		u64 fbr0_tmp_physaddr;
 
 		fbr_chunksize =
-		    ((FBR_CHUNKS + 1) * rx_ring->fbr0_buffsize) - 1;
-		rx_ring->fbr0_mem_virtaddrs[i] =
+		    ((FBR_CHUNKS + 1) * rx_ring->fbr[0]->buffsize) - 1;
+		rx_ring->fbr[0]->mem_virtaddrs[i] =
 		    pci_alloc_consistent(adapter->pdev, fbr_chunksize,
-					 &rx_ring->fbr0_mem_physaddrs[i]);
+					 &rx_ring->fbr[0]->mem_physaddrs[i]);
 
-		if (!rx_ring->fbr0_mem_virtaddrs[i]) {
+		if (!rx_ring->fbr[0]->mem_virtaddrs[i]) {
 			dev_err(&adapter->pdev->dev,
 				"Could not alloc memory\n");
 			return -ENOMEM;
 		}
 
 		/* See NOTE in "Save Physical Address" comment above */
-		fbr0_tmp_physaddr = rx_ring->fbr0_mem_physaddrs[i];
+		fbr0_tmp_physaddr = rx_ring->fbr[0]->mem_physaddrs[i];
 
 		et131x_align_allocated_memory(adapter,
 					      &fbr0_tmp_physaddr,
 					      &fbr0_offset,
-					      rx_ring->fbr0_buffsize - 1);
+					      rx_ring->fbr[0]->buffsize - 1);
 
 		for (j = 0; j < FBR_CHUNKS; j++) {
 			u32 index = (i * FBR_CHUNKS) + j;
 
 			rx_ring->fbr[0]->virt[index] =
-			    (u8 *) rx_ring->fbr0_mem_virtaddrs[i] +
-			    (j * rx_ring->fbr0_buffsize) + fbr0_offset;
+			    (u8 *) rx_ring->fbr[0]->mem_virtaddrs[i] +
+			    (j * rx_ring->fbr[0]->buffsize) + fbr0_offset;
 
 			rx_ring->fbr[0]->bus_high[index] =
 			    (u32) (fbr0_tmp_physaddr >> 32);
 			rx_ring->fbr[0]->bus_low[index] =
 			    (u32) fbr0_tmp_physaddr;
 
-			fbr0_tmp_physaddr += rx_ring->fbr0_buffsize;
+			fbr0_tmp_physaddr += rx_ring->fbr[0]->buffsize;
 
 			rx_ring->fbr[0]->buffer1[index] =
 			    rx_ring->fbr[0]->virt[index];
@@ -2228,78 +2214,78 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter)
 	}
 
 	/* Free Free Buffer Ring 1 */
-	if (rx_ring->fbr1_ring_virtaddr) {
+	if (rx_ring->fbr[1]->ring_virtaddr) {
 		/* First the packet memory */
 		for (index = 0; index <
-		     (rx_ring->fbr1_num_entries / FBR_CHUNKS); index++) {
-			if (rx_ring->fbr1_mem_virtaddrs[index]) {
+		     (rx_ring->fbr[1]->num_entries / FBR_CHUNKS); index++) {
+			if (rx_ring->fbr[1]->mem_virtaddrs[index]) {
 				u32 fbr1_align;
 
-				if (rx_ring->fbr1_buffsize > 4096)
+				if (rx_ring->fbr[1]->buffsize > 4096)
 					fbr1_align = 4096;
 				else
-					fbr1_align = rx_ring->fbr1_buffsize;
+					fbr1_align = rx_ring->fbr[1]->buffsize;
 
 				bufsize =
-				    (rx_ring->fbr1_buffsize * FBR_CHUNKS) +
+				    (rx_ring->fbr[1]->buffsize * FBR_CHUNKS) +
 				    fbr1_align - 1;
 
 				pci_free_consistent(adapter->pdev,
 					bufsize,
-					rx_ring->fbr1_mem_virtaddrs[index],
-					rx_ring->fbr1_mem_physaddrs[index]);
+					rx_ring->fbr[1]->mem_virtaddrs[index],
+					rx_ring->fbr[1]->mem_physaddrs[index]);
 
-				rx_ring->fbr1_mem_virtaddrs[index] = NULL;
+				rx_ring->fbr[1]->mem_virtaddrs[index] = NULL;
 			}
 		}
 
 		/* Now the FIFO itself */
-		rx_ring->fbr1_ring_virtaddr = (void *)((u8 *)
-			rx_ring->fbr1_ring_virtaddr - rx_ring->fbr1_offset);
+		rx_ring->fbr[1]->ring_virtaddr = (void *)((u8 *)
+			rx_ring->fbr[1]->ring_virtaddr - rx_ring->fbr[1]->offset);
 
-		bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr1_num_entries)
+		bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[1]->num_entries)
 							    + 0xfff;
 
 		pci_free_consistent(adapter->pdev, bufsize,
-				    rx_ring->fbr1_ring_virtaddr,
-				    rx_ring->fbr1_ring_physaddr);
+				    rx_ring->fbr[1]->ring_virtaddr,
+				    rx_ring->fbr[1]->ring_physaddr);
 
-		rx_ring->fbr1_ring_virtaddr = NULL;
+		rx_ring->fbr[1]->ring_virtaddr = NULL;
 	}
 
 #ifdef USE_FBR0
 	/* Now the same for Free Buffer Ring 0 */
-	if (rx_ring->fbr0_ring_virtaddr) {
+	if (rx_ring->fbr[0]->ring_virtaddr) {
 		/* First the packet memory */
 		for (index = 0; index <
-		     (rx_ring->fbr0_num_entries / FBR_CHUNKS); index++) {
-			if (rx_ring->fbr0_mem_virtaddrs[index]) {
+		     (rx_ring->fbr[0]->num_entries / FBR_CHUNKS); index++) {
+			if (rx_ring->fbr[0]->mem_virtaddrs[index]) {
 				bufsize =
-				    (rx_ring->fbr0_buffsize *
+				    (rx_ring->fbr[0]->buffsize *
 				     (FBR_CHUNKS + 1)) - 1;
 
 				pci_free_consistent(adapter->pdev,
 					bufsize,
-					rx_ring->fbr0_mem_virtaddrs[index],
-					rx_ring->fbr0_mem_physaddrs[index]);
+					rx_ring->fbr[0]->mem_virtaddrs[index],
+					rx_ring->fbr[0]->mem_physaddrs[index]);
 
-				rx_ring->fbr0_mem_virtaddrs[index] = NULL;
+				rx_ring->fbr[0]->mem_virtaddrs[index] = NULL;
 			}
 		}
 
 		/* Now the FIFO itself */
-		rx_ring->fbr0_ring_virtaddr = (void *)((u8 *)
-			rx_ring->fbr0_ring_virtaddr - rx_ring->fbr0_offset);
+		rx_ring->fbr[0]->ring_virtaddr = (void *)((u8 *)
+			rx_ring->fbr[0]->ring_virtaddr - rx_ring->fbr[0]->offset);
 
-		bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr0_num_entries)
+		bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[0]->num_entries)
 							    + 0xfff;
 
 		pci_free_consistent(adapter->pdev,
 				    bufsize,
-				    rx_ring->fbr0_ring_virtaddr,
-				    rx_ring->fbr0_ring_physaddr);
+				    rx_ring->fbr[0]->ring_virtaddr,
+				    rx_ring->fbr[0]->ring_physaddr);
 
-		rx_ring->fbr0_ring_virtaddr = NULL;
+		rx_ring->fbr[0]->ring_virtaddr = NULL;
 	}
 #endif
 
@@ -2445,8 +2431,8 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *adapter)
 	rx_local->local_psr_full = 0;
 
 	/* Now's the best time to initialize FBR1 contents */
-	fbr_entry = (struct fbr_desc *) rx_local->fbr1_ring_virtaddr;
-	for (entry = 0; entry < rx_local->fbr1_num_entries; entry++) {
+	fbr_entry = (struct fbr_desc *) rx_local->fbr[1]->ring_virtaddr;
+	for (entry = 0; entry < rx_local->fbr[1]->num_entries; entry++) {
 		fbr_entry->addr_hi = rx_local->fbr[1]->bus_high[entry];
 		fbr_entry->addr_lo = rx_local->fbr[1]->bus_low[entry];
 		fbr_entry->word2 = entry;
@@ -2456,42 +2442,42 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *adapter)
 	/* Set the address and parameters of Free buffer ring 1 (and 0 if
 	 * required) into the 1310's registers
 	 */
-	writel((u32) (rx_local->fbr1_real_physaddr >> 32),
+	writel((u32) (rx_local->fbr[1]->real_physaddr >> 32),
 	       &rx_dma->fbr1_base_hi);
-	writel((u32) rx_local->fbr1_real_physaddr, &rx_dma->fbr1_base_lo);
-	writel(rx_local->fbr1_num_entries - 1, &rx_dma->fbr1_num_des);
+	writel((u32) rx_local->fbr[1]->real_physaddr, &rx_dma->fbr1_base_lo);
+	writel(rx_local->fbr[1]->num_entries - 1, &rx_dma->fbr1_num_des);
 	writel(ET_DMA10_WRAP, &rx_dma->fbr1_full_offset);
 
 	/* This variable tracks the free buffer ring 1 full position, so it
 	 * has to match the above.
 	 */
-	rx_local->local_fbr1_full = ET_DMA10_WRAP;
+	rx_local->fbr[1]->local_full = ET_DMA10_WRAP;
 	writel(
-	    ((rx_local->fbr1_num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1,
+	    ((rx_local->fbr[1]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1,
 	    &rx_dma->fbr1_min_des);
 
 #ifdef USE_FBR0
 	/* Now's the best time to initialize FBR0 contents */
-	fbr_entry = (struct fbr_desc *) rx_local->fbr0_ring_virtaddr;
-	for (entry = 0; entry < rx_local->fbr0_num_entries; entry++) {
+	fbr_entry = (struct fbr_desc *) rx_local->fbr[0]->ring_virtaddr;
+	for (entry = 0; entry < rx_local->fbr[0]->num_entries; entry++) {
 		fbr_entry->addr_hi = rx_local->fbr[0]->bus_high[entry];
 		fbr_entry->addr_lo = rx_local->fbr[0]->bus_low[entry];
 		fbr_entry->word2 = entry;
 		fbr_entry++;
 	}
 
-	writel((u32) (rx_local->fbr0_real_physaddr >> 32),
+	writel((u32) (rx_local->fbr[0]->real_physaddr >> 32),
 	       &rx_dma->fbr0_base_hi);
-	writel((u32) rx_local->fbr0_real_physaddr, &rx_dma->fbr0_base_lo);
-	writel(rx_local->fbr0_num_entries - 1, &rx_dma->fbr0_num_des);
+	writel((u32) rx_local->fbr[0]->real_physaddr, &rx_dma->fbr0_base_lo);
+	writel(rx_local->fbr[0]->num_entries - 1, &rx_dma->fbr0_num_des);
 	writel(ET_DMA10_WRAP, &rx_dma->fbr0_full_offset);
 
 	/* This variable tracks the free buffer ring 0 full position, so it
 	 * has to match the above.
 	 */
-	rx_local->local_fbr0_full = ET_DMA10_WRAP;
+	rx_local->fbr[0]->local_full = ET_DMA10_WRAP;
 	writel(
-	    ((rx_local->fbr0_num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1,
+	    ((rx_local->fbr[0]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1,
 	    &rx_dma->fbr0_min_des);
 #endif
 
@@ -2550,15 +2536,15 @@ static void nic_return_rfd(struct et131x_adapter *adapter, struct rfd *rfd)
 	 */
 	if (
 #ifdef USE_FBR0
-	    (ring_index == 0 && buff_index < rx_local->fbr0_num_entries) ||
+	    (ring_index == 0 && buff_index < rx_local->fbr[0]->num_entries) ||
 #endif
-	    (ring_index == 1 && buff_index < rx_local->fbr1_num_entries)) {
+	    (ring_index == 1 && buff_index < rx_local->fbr[1]->num_entries)) {
 		spin_lock_irqsave(&adapter->fbr_lock, flags);
 
 		if (ring_index == 1) {
 			struct fbr_desc *next =
-			    (struct fbr_desc *) (rx_local->fbr1_ring_virtaddr) +
-					 INDEX10(rx_local->local_fbr1_full);
+			    (struct fbr_desc *) (rx_local->fbr[1]->ring_virtaddr) +
+					 INDEX10(rx_local->fbr[1]->local_full);
 
 			/* Handle the Free Buffer Ring advancement here. Write
 			 * the PA / Buffer Index for the returned buffer into
@@ -2568,15 +2554,15 @@ static void nic_return_rfd(struct et131x_adapter *adapter, struct rfd *rfd)
 			next->addr_lo = rx_local->fbr[1]->bus_low[buff_index];
 			next->word2 = buff_index;
 
-			writel(bump_free_buff_ring(&rx_local->local_fbr1_full,
-				rx_local->fbr1_num_entries - 1),
+			writel(bump_free_buff_ring(&rx_local->fbr[1]->local_full,
+				rx_local->fbr[1]->num_entries - 1),
 				&rx_dma->fbr1_full_offset);
 		}
 #ifdef USE_FBR0
 		else {
 			struct fbr_desc *next = (struct fbr_desc *)
-				rx_local->fbr0_ring_virtaddr +
-					INDEX10(rx_local->local_fbr0_full);
+				rx_local->fbr[0]->ring_virtaddr +
+				    INDEX10(rx_local->fbr[0]->local_full);
 
 			/* Handle the Free Buffer Ring advancement here. Write
 			 * the PA / Buffer Index for the returned buffer into
@@ -2586,8 +2572,9 @@ static void nic_return_rfd(struct et131x_adapter *adapter, struct rfd *rfd)
 			next->addr_lo = rx_local->fbr[0]->bus_low[buff_index];
 			next->word2 = buff_index;
 
-			writel(bump_free_buff_ring(&rx_local->local_fbr0_full,
-					rx_local->fbr0_num_entries - 1),
+			writel(bump_free_buff_ring(
+					&rx_local->fbr[0]->local_full,
+					rx_local->fbr[0]->num_entries - 1),
 			       &rx_dma->fbr0_full_offset);
 		}
 #endif
@@ -2637,19 +2624,19 @@ void et131x_rx_dma_enable(struct et131x_adapter *adapter)
 	/* Setup the receive dma configuration register for normal operation */
 	u32 csr =  0x2000;	/* FBR1 enable */
 
-	if (adapter->rx_ring.fbr1_buffsize == 4096)
+	if (adapter->rx_ring.fbr[1]->buffsize == 4096)
 		csr |= 0x0800;
-	else if (adapter->rx_ring.fbr1_buffsize == 8192)
+	else if (adapter->rx_ring.fbr[1]->buffsize == 8192)
 		csr |= 0x1000;
-	else if (adapter->rx_ring.fbr1_buffsize == 16384)
+	else if (adapter->rx_ring.fbr[1]->buffsize == 16384)
 		csr |= 0x1800;
 #ifdef USE_FBR0
 	csr |= 0x0400;		/* FBR0 enable */
-	if (adapter->rx_ring.fbr0_buffsize == 256)
+	if (adapter->rx_ring.fbr[0]->buffsize == 256)
 		csr |= 0x0100;
-	else if (adapter->rx_ring.fbr0_buffsize == 512)
+	else if (adapter->rx_ring.fbr[0]->buffsize == 512)
 		csr |= 0x0200;
-	else if (adapter->rx_ring.fbr0_buffsize == 1024)
+	else if (adapter->rx_ring.fbr[0]->buffsize == 1024)
 		csr |= 0x0300;
 #endif
 	writel(csr, &adapter->regs->rxdma.csr);
@@ -2750,11 +2737,11 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
 #ifdef USE_FBR0
 	if (ring_index > 1 ||
 		(ring_index == 0 &&
-		buff_index > rx_local->fbr0_num_entries - 1) ||
+		buff_index > rx_local->fbr[0]->num_entries - 1) ||
 		(ring_index == 1 &&
-		buff_index > rx_local->fbr1_num_entries - 1))
+		buff_index > rx_local->fbr[1]->num_entries - 1))
 #else
-	if (ring_index != 1 || buff_index > rx_local->fbr1_num_entries - 1)
+	if (ring_index != 1 || buff_index > rx_local->fbr[1]->num_entries - 1)
 #endif
 	{
 		/* Illegal buffer or ring index cannot be used by S/W*/
Signature · 1 line
1.7.6.4
author
#16 lore raw

PATCH RESEND 13/26 staging: et131x: Fix issues when USE_FBR0 is not defined

In reply to Mark Einon

* Following on from making rx_ring.fbr use a common structure - reversed the fbr[] array indicies so that index 1 = FBR0 and index 0 = FBR1, which allows USE_FBR0 define to work.

* Also fixed up minor issues where indexes into the array were out of bounds in some places.

* Removed rx_ring.fbr common stuct TODO item from README

---
 drivers/staging/et131x/README   |    1 -
 drivers/staging/et131x/et131x.c |  304 ++++++++++++++++++++-------------------
 2 files changed, 158 insertions(+), 147 deletions(-)
drivers/staging/et131x/README +0 -1
index a7b33dc..1e0fcf4 100644
@@ -8,7 +8,6 @@ Note, the powermanagement options were removed from the vendor provided
 driver as they did not build properly at the time.
 
 TODO:
-	- rx_ring.fbr{0, 1} can probably share a common structure
 	- Use of kmem_cache seems a bit unusual
 	- Use dma_alloc_... in place of pci_alloc_...
 	- It's too late stopping the tx queue when there is no room for the current packet. The condition should be detected for the next packet.
drivers/staging/et131x/et131x.c +158 -146

585 lines not on this page · raw message

Signature · 1 line
1.7.6.4
author
#17 lore raw

PATCH RESEND 14/26 staging: et131x: use dma_alloc... instead of pci_alloc...

In reply to Mark Einon

Use dma_allocs instead of pci_allocs, so we can use GFP_KERNEL allocations.

Also removed this item from the TODO list

---
 drivers/staging/et131x/README   |    1 -
 drivers/staging/et131x/et131x.c |   39 ++++++++++++++++++++++-----------------
 2 files changed, 22 insertions(+), 18 deletions(-)
drivers/staging/et131x/README +0 -1
index 1e0fcf4..87b9360 100644
@@ -9,7 +9,6 @@ driver as they did not build properly at the time.
 
 TODO:
 	- Use of kmem_cache seems a bit unusual
-	- Use dma_alloc_... in place of pci_alloc_...
 	- It's too late stopping the tx queue when there is no room for the current packet. The condition should be detected for the next packet.
 	- PCI_VDEVICE ?
 
drivers/staging/et131x/et131x.c +22 -17
index 0fbb77d..06ba4a9 100644
@@ -1965,9 +1965,10 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
 
 	/* Allocate an area of memory for Free Buffer Ring 1 */
 	bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[0]->num_entries) + 0xfff;
-	rx_ring->fbr[0]->ring_virtaddr = pci_alloc_consistent(adapter->pdev,
-						bufsize,
-						&rx_ring->fbr[0]->ring_physaddr);
+	rx_ring->fbr[0]->ring_virtaddr = dma_alloc_coherent(&adapter->pdev->dev,
+					bufsize,
+					&rx_ring->fbr[0]->ring_physaddr,
+					GFP_KERNEL);
 	if (!rx_ring->fbr[0]->ring_virtaddr) {
 		dev_err(&adapter->pdev->dev,
 			  "Cannot alloc memory for Free Buffer Ring 1\n");
@@ -1995,9 +1996,10 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
 #ifdef USE_FBR0
 	/* Allocate an area of memory for Free Buffer Ring 0 */
 	bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[1]->num_entries) + 0xfff;
-	rx_ring->fbr[1]->ring_virtaddr = pci_alloc_consistent(adapter->pdev,
+	rx_ring->fbr[1]->ring_virtaddr = dma_alloc_coherent(&adapter->pdev->dev,
 						bufsize,
-						&rx_ring->fbr[1]->ring_physaddr);
+						&rx_ring->fbr[1]->ring_physaddr,
+						GFP_KERNEL);
 	if (!rx_ring->fbr[1]->ring_virtaddr) {
 		dev_err(&adapter->pdev->dev,
 			  "Cannot alloc memory for Free Buffer Ring 0\n");
@@ -2042,8 +2044,8 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
 		fbr_chunksize =
 		    (FBR_CHUNKS * rx_ring->fbr[0]->buffsize) + fbr1_align - 1;
 		rx_ring->fbr[0]->mem_virtaddrs[i] =
-		    pci_alloc_consistent(adapter->pdev, fbr_chunksize,
-					 &rx_ring->fbr[0]->mem_physaddrs[i]);
+		    dma_alloc_coherent(&adapter->pdev->dev, fbr_chunksize,
+					 &rx_ring->fbr[0]->mem_physaddrs[i], GFP_KERNEL);
 
 		if (!rx_ring->fbr[0]->mem_virtaddrs[i]) {
 			dev_err(&adapter->pdev->dev,
@@ -2094,8 +2096,8 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
 		fbr_chunksize =
 		    ((FBR_CHUNKS + 1) * rx_ring->fbr[1]->buffsize) - 1;
 		rx_ring->fbr[1]->mem_virtaddrs[i] =
-		    pci_alloc_consistent(adapter->pdev, fbr_chunksize,
-					 &rx_ring->fbr[1]->mem_physaddrs[i]);
+		    dma_alloc_coherent(&adapter->pdev->dev, fbr_chunksize,
+					 &rx_ring->fbr[1]->mem_physaddrs[i], GFP_KERNEL);
 
 		if (!rx_ring->fbr[1]->mem_virtaddrs[i]) {
 			dev_err(&adapter->pdev->dev,
@@ -2137,9 +2139,10 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
 	pktstat_ringsize =
 	    sizeof(struct pkt_stat_desc) * adapter->rx_ring.psr_num_entries;
 
-	rx_ring->ps_ring_virtaddr = pci_alloc_consistent(adapter->pdev,
+	rx_ring->ps_ring_virtaddr = dma_alloc_coherent(&adapter->pdev->dev,
 						  pktstat_ringsize,
-						  &rx_ring->ps_ring_physaddr);
+						  &rx_ring->ps_ring_physaddr,
+						  GFP_KERNEL);
 
 	if (!rx_ring->ps_ring_virtaddr) {
 		dev_err(&adapter->pdev->dev,
@@ -2157,9 +2160,10 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
 	 */
 
 	/* Allocate an area of memory for writeback of status information */
-	rx_ring->rx_status_block = pci_alloc_consistent(adapter->pdev,
+	rx_ring->rx_status_block = dma_alloc_coherent(&adapter->pdev->dev,
 					    sizeof(struct rx_status_block),
-					    &rx_ring->rx_status_bus);
+					    &rx_ring->rx_status_bus,
+					    GFP_KERNEL);
 	if (!rx_ring->rx_status_block) {
 		dev_err(&adapter->pdev->dev,
 			  "Cannot alloc memory for Status Block\n");
@@ -2992,8 +2996,8 @@ int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter)
 	 */
 	desc_size = (sizeof(struct tx_desc) * NUM_DESC_PER_RING_TX) + 4096 - 1;
 	tx_ring->tx_desc_ring =
-	    (struct tx_desc *) pci_alloc_consistent(adapter->pdev, desc_size,
-						    &tx_ring->tx_desc_ring_pa);
+	    (struct tx_desc *) dma_alloc_coherent(&adapter->pdev->dev, desc_size,
+						    &tx_ring->tx_desc_ring_pa, GFP_KERNEL);
 	if (!adapter->tx_ring.tx_desc_ring) {
 		dev_err(&adapter->pdev->dev,
 					"Cannot alloc memory for Tx Ring\n");
@@ -3008,9 +3012,10 @@ int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter)
 	 * storing the adjusted address.
 	 */
 	/* Allocate memory for the Tx status block */
-	tx_ring->tx_status = pci_alloc_consistent(adapter->pdev,
+	tx_ring->tx_status = dma_alloc_coherent(&adapter->pdev->dev,
 						    sizeof(u32),
-						    &tx_ring->tx_status_pa);
+						    &tx_ring->tx_status_pa,
+						    GFP_KERNEL);
 	if (!adapter->tx_ring.tx_status_pa) {
 		dev_err(&adapter->pdev->dev,
 				  "Cannot alloc memory for Tx status block\n");
Signature · 1 line
1.7.6.4
author
#18 lore raw

PATCH RESEND 15/26 staging: et131x: Match dma_alloc_ calls with dma_free_ calls

In reply to Mark Einon

Previous update was to replace pci_alloc with dma_alloc calls. I missed replacing the corresponding pci_free_ calls with the dma versions. Now done. Thanks to Denis Kirjanov <[email protected]> for pointing this out.

---
 drivers/staging/et131x/et131x.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
drivers/staging/et131x/et131x.c +8 -8
index 06ba4a9..28d54b3 100644
@@ -2238,7 +2238,7 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter)
 				    (rx_ring->fbr[0]->buffsize * FBR_CHUNKS) +
 				    fbr1_align - 1;
 
-				pci_free_consistent(adapter->pdev,
+				dma_free_coherent(&adapter->pdev->dev,
 					bufsize,
 					rx_ring->fbr[0]->mem_virtaddrs[index],
 					rx_ring->fbr[0]->mem_physaddrs[index]);
@@ -2254,7 +2254,7 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter)
 		bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[0]->num_entries)
 							    + 0xfff;
 
-		pci_free_consistent(adapter->pdev, bufsize,
+		dma_free_coherent(&adapter->pdev->dev, bufsize,
 				    rx_ring->fbr[0]->ring_virtaddr,
 				    rx_ring->fbr[0]->ring_physaddr);
 
@@ -2272,7 +2272,7 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter)
 				    (rx_ring->fbr[1]->buffsize *
 				     (FBR_CHUNKS + 1)) - 1;
 
-				pci_free_consistent(adapter->pdev,
+				dma_free_coherent(&adapter->pdev->dev,
 					bufsize,
 					rx_ring->fbr[1]->mem_virtaddrs[index],
 					rx_ring->fbr[1]->mem_physaddrs[index]);
@@ -2288,7 +2288,7 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter)
 		bufsize = (sizeof(struct fbr_desc) * rx_ring->fbr[1]->num_entries)
 							    + 0xfff;
 
-		pci_free_consistent(adapter->pdev,
+		dma_free_coherent(&adapter->pdev->dev,
 				    bufsize,
 				    rx_ring->fbr[1]->ring_virtaddr,
 				    rx_ring->fbr[1]->ring_physaddr);
@@ -2303,7 +2303,7 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter)
 		    sizeof(struct pkt_stat_desc) *
 		    adapter->rx_ring.psr_num_entries;
 
-		pci_free_consistent(adapter->pdev, pktstat_ringsize,
+		dma_free_coherent(&adapter->pdev->dev, pktstat_ringsize,
 				    rx_ring->ps_ring_virtaddr,
 				    rx_ring->ps_ring_physaddr);
 
@@ -2312,7 +2312,7 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter)
 
 	/* Free area of memory for the writeback of status information */
 	if (rx_ring->rx_status_block) {
-		pci_free_consistent(adapter->pdev,
+		dma_free_coherent(&adapter->pdev->dev,
 			sizeof(struct rx_status_block),
 			rx_ring->rx_status_block, rx_ring->rx_status_bus);
 		rx_ring->rx_status_block = NULL;
@@ -3038,7 +3038,7 @@ void et131x_tx_dma_memory_free(struct et131x_adapter *adapter)
 		/* Free memory relating to Tx rings here */
 		desc_size = (sizeof(struct tx_desc) * NUM_DESC_PER_RING_TX)
 								+ 4096 - 1;
-		pci_free_consistent(adapter->pdev,
+		dma_free_coherent(&adapter->pdev->dev,
 				    desc_size,
 				    adapter->tx_ring.tx_desc_ring,
 				    adapter->tx_ring.tx_desc_ring_pa);
@@ -3047,7 +3047,7 @@ void et131x_tx_dma_memory_free(struct et131x_adapter *adapter)
 
 	/* Free memory for the Tx status block */
 	if (adapter->tx_ring.tx_status) {
-		pci_free_consistent(adapter->pdev,
+		dma_free_coherent(&adapter->pdev->dev,
 				    sizeof(u32),
 				    adapter->tx_ring.tx_status,
 				    adapter->tx_ring.tx_status_pa);
Signature · 1 line
1.7.6.4
author
#19 lore raw

PATCH RESEND 16/26 staging: et131x: Tidy up PCI device table definition

In reply to Mark Einon

Used the convenience macros DEFINE_PCI_DEVICE_TABLE and PCI_VDEVICE to tidy up the device table definition.

Also remove the corresponding TODO item from the README.

---
 drivers/staging/et131x/README   |    1 -
 drivers/staging/et131x/et131x.c |   12 ++++--------
 2 files changed, 4 insertions(+), 9 deletions(-)
drivers/staging/et131x/README +0 -1
index 87b9360..0928eb5 100644
@@ -10,7 +10,6 @@ driver as they did not build properly at the time.
 TODO:
 	- Use of kmem_cache seems a bit unusual
 	- It's too late stopping the tx queue when there is no room for the current packet. The condition should be detected for the next packet.
-	- PCI_VDEVICE ?
 
 Please send patches to:
 	Greg Kroah-Hartman <[email protected]>
drivers/staging/et131x/et131x.c +4 -8
index 28d54b3..cc41111 100644
@@ -169,8 +169,7 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver "
 #define ET1310_PCI_REPLAY		0xC2
 #define ET1310_PCI_L0L1LATENCY		0xCF
 
-/* PCI Vendor/Product IDs */
-#define ET131X_PCI_VENDOR_ID		0x11C1	/* Agere Systems */
+/* PCI Product IDs */
 #define ET131X_PCI_DEVICE_ID_GIG	0xED00	/* ET1310 1000 Base-T 8 */
 #define ET131X_PCI_DEVICE_ID_FAST	0xED01	/* ET1310 100  Base-T */
 
@@ -4647,14 +4646,11 @@ static SIMPLE_DEV_PM_OPS(et131x_pm_ops, et131x_suspend, et131x_resume);
 #define ET131X_PM_OPS NULL
 #endif
 
-static struct pci_device_id et131x_pci_table[] __devinitdata = {
-	{ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_GIG, PCI_ANY_ID,
-	 PCI_ANY_ID, 0, 0, 0UL},
-	{ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_FAST, PCI_ANY_ID,
-	 PCI_ANY_ID, 0, 0, 0UL},
+static DEFINE_PCI_DEVICE_TABLE(et131x_pci_table) = {
+	{ PCI_VDEVICE(ATT, ET131X_PCI_DEVICE_ID_GIG), 0UL},
+	{ PCI_VDEVICE(ATT, ET131X_PCI_DEVICE_ID_FAST), 0UL},
 	{0,}
 };
-
 MODULE_DEVICE_TABLE(pci, et131x_pci_table);
 
 static struct pci_driver et131x_driver = {
Signature · 1 line
1.7.6.4
author
#20 lore raw

PATCH RESEND 17/26 staging: et131x: on transmit, stop the queue if the next packet will fail

In reply to Mark Einon

* Currently the tx queue is only stopped when the current packet fails. Check if the next packet will fail, and stop the queue if so.

* Removed associated item from TODO list in the README.

* Also minor fixup as adapter was being declared as null and immediately set to a value.

---
 drivers/staging/et131x/README   |    1 -
 drivers/staging/et131x/et131x.c |   13 ++++++-------
 2 files changed, 6 insertions(+), 8 deletions(-)
drivers/staging/et131x/README +0 -1
index 0928eb5..3458aa7 100644
@@ -9,7 +9,6 @@ driver as they did not build properly at the time.
 
 TODO:
 	- Use of kmem_cache seems a bit unusual
-	- It's too late stopping the tx queue when there is no room for the current packet. The condition should be detected for the next packet.
 
 Please send patches to:
 	Greg Kroah-Hartman <[email protected]>
drivers/staging/et131x/et131x.c +6 -7
index cc41111..993f93a 100644
@@ -3448,9 +3448,7 @@ static int send_packet(struct sk_buff *skb, struct et131x_adapter *adapter)
 int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev)
 {
 	int status = 0;
-	struct et131x_adapter *adapter = NULL;
-
-	adapter = netdev_priv(netdev);
+	struct et131x_adapter *adapter = netdev_priv(netdev);
 
 	/* Send these packets
 	 *
@@ -5347,6 +5345,11 @@ static void et131x_multicast(struct net_device *netdev)
 static int et131x_tx(struct sk_buff *skb, struct net_device *netdev)
 {
 	int status = 0;
+	struct et131x_adapter *adapter = netdev_priv(netdev);
+
+	/* stop the queue if it's getting full */
+	if(adapter->tx_ring.used >= NUM_TCB - 1 && !netif_queue_stopped(netdev))
+		netif_stop_queue(netdev);
 
 	/* Save the timestamp for the TX timeout watchdog */
 	netdev->trans_start = jiffies;
@@ -5357,10 +5360,6 @@ static int et131x_tx(struct sk_buff *skb, struct net_device *netdev)
 	/* Check status and manage the netif queue if necessary */
 	if (status != 0) {
 		if (status == -ENOMEM) {
-			/* Put the queue to sleep until resources are
-			 * available
-			 */
-			netif_stop_queue(netdev);
 			status = NETDEV_TX_BUSY;
 		} else {
 			status = NETDEV_TX_OK;
Signature · 1 line
1.7.6.4
author
#21 lore raw

PATCH RESEND 18/26 staging: et131x: Convert rest of pci memory management to dma api

In reply to Mark Einon

Replaced pci map/unmap and set_mask calls with their dma equivalents. Also updated comments to reflect this.

---
 drivers/staging/et131x/et131x.c |   56 +++++++++++++++++++-------------------
 1 files changed, 28 insertions(+), 28 deletions(-)
drivers/staging/et131x/et131x.c +28 -28
index 993f93a..1c11dfd 100644
@@ -1976,7 +1976,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
 
 	/* Save physical address
 	 *
-	 * NOTE: pci_alloc_consistent(), used above to alloc DMA regions,
+	 * NOTE: dma_alloc_coherent(), used above to alloc DMA regions,
 	 * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses
 	 * are ever returned, make sure the high part is retrieved here
 	 * before storing the adjusted address.
@@ -2007,7 +2007,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
 
 	/* Save physical address
 	 *
-	 * NOTE: pci_alloc_consistent(), used above to alloc DMA regions,
+	 * NOTE: dma_alloc_coherent(), used above to alloc DMA regions,
 	 * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses
 	 * are ever returned, make sure the high part is retrieved here before
 	 * storing the adjusted address.
@@ -2152,7 +2152,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
 	    (unsigned long) rx_ring->ps_ring_physaddr);
 
 	/*
-	 * NOTE : pci_alloc_consistent(), used above to alloc DMA regions,
+	 * NOTE : dma_alloc_coherent(), used above to alloc DMA regions,
 	 * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses
 	 * are ever returned, make sure the high part is retrieved here before
 	 * storing the adjusted address.
@@ -2172,7 +2172,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
 	printk(KERN_INFO "PRS %lx\n", (unsigned long)rx_ring->rx_status_bus);
 
 	/* Recv
-	 * pci_pool_create initializes a lookaside list. After successful
+	 * kmem_cache_create initializes a lookaside list. After successful
 	 * creation, nonpaged fixed-size blocks can be allocated from and
 	 * freed to the lookaside list.
 	 * RFDs will be allocated from this pool.
@@ -2408,7 +2408,7 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *adapter)
 
 	/* Load the completion writeback physical address
 	 *
-	 * NOTE : pci_alloc_consistent(), used above to alloc DMA regions,
+	 * NOTE : dma_alloc_coherent(), used above to alloc DMA regions,
 	 * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses
 	 * are ever returned, make sure the high part is retrieved here
 	 * before storing the adjusted address.
@@ -3005,7 +3005,7 @@ int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter)
 
 	/* Save physical address
 	 *
-	 * NOTE: pci_alloc_consistent(), used above to alloc DMA regions,
+	 * NOTE: dma_alloc_coherent(), used above to alloc DMA regions,
 	 * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses
 	 * are ever returned, make sure the high part is retrieved here before
 	 * storing the adjusted address.
@@ -3202,59 +3202,59 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)
 					skb->len - skb->data_len;
 
 				/* NOTE: Here, the dma_addr_t returned from
-				 * pci_map_single() is implicitly cast as a
+				 * dma_map_single() is implicitly cast as a
 				 * u32. Although dma_addr_t can be
 				 * 64-bit, the address returned by
-				 * pci_map_single() is always 32-bit
+				 * dma_map_single() is always 32-bit
 				 * addressable (as defined by the pci/dma
 				 * subsystem)
 				 */
 				desc[frag++].addr_lo =
-				    pci_map_single(adapter->pdev,
+				    dma_map_single(&adapter->pdev->dev,
 						   skb->data,
 						   skb->len -
 						   skb->data_len,
-						   PCI_DMA_TODEVICE);
+						   DMA_TO_DEVICE);
 			} else {
 				desc[frag].addr_hi = 0;
 				desc[frag].len_vlan =
 				    (skb->len - skb->data_len) / 2;
 
 				/* NOTE: Here, the dma_addr_t returned from
-				 * pci_map_single() is implicitly cast as a
+				 * dma_map_single() is implicitly cast as a
 				 * u32. Although dma_addr_t can be
 				 * 64-bit, the address returned by
-				 * pci_map_single() is always 32-bit
+				 * dma_map_single() is always 32-bit
 				 * addressable (as defined by the pci/dma
 				 * subsystem)
 				 */
 				desc[frag++].addr_lo =
-				    pci_map_single(adapter->pdev,
+				    dma_map_single(&adapter->pdev->dev,
 						   skb->data,
 						   ((skb->len -
 						     skb->data_len) / 2),
-						   PCI_DMA_TODEVICE);
+						   DMA_TO_DEVICE);
 				desc[frag].addr_hi = 0;
 
 				desc[frag].len_vlan =
 				    (skb->len - skb->data_len) / 2;
 
 				/* NOTE: Here, the dma_addr_t returned from
-				 * pci_map_single() is implicitly cast as a
+				 * dma_map_single() is implicitly cast as a
 				 * u32. Although dma_addr_t can be
 				 * 64-bit, the address returned by
-				 * pci_map_single() is always 32-bit
+				 * dma_map_single() is always 32-bit
 				 * addressable (as defined by the pci/dma
 				 * subsystem)
 				 */
 				desc[frag++].addr_lo =
-				    pci_map_single(adapter->pdev,
+				    dma_map_single(&adapter->pdev->dev,
 						   skb->data +
 						   ((skb->len -
 						     skb->data_len) / 2),
 						   ((skb->len -
 						     skb->data_len) / 2),
-						   PCI_DMA_TODEVICE);
+						   DMA_TO_DEVICE);
 			}
 		} else {
 			desc[frag].addr_hi = 0;
@@ -3262,17 +3262,17 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)
 					frags[i - 1].size;
 
 			/* NOTE: Here, the dma_addr_t returned from
-			 * pci_map_page() is implicitly cast as a u32.
+			 * dma_map_page() is implicitly cast as a u32.
 			 * Although dma_addr_t can be 64-bit, the address
-			 * returned by pci_map_page() is always 32-bit
+			 * returned by dma_map_page() is always 32-bit
 			 * addressable (as defined by the pci/dma subsystem)
 			 */
 			desc[frag++].addr_lo =
-			    pci_map_page(adapter->pdev,
+			    dma_map_page(&adapter->pdev->dev,
 					 frags[i - 1].page,
 					 frags[i - 1].page_offset,
 					 frags[i - 1].size,
-					 PCI_DMA_TODEVICE);
+					 DMA_TO_DEVICE);
 		}
 	}
 
@@ -3522,9 +3522,9 @@ static inline void free_send_packet(struct et131x_adapter *adapter,
 				    (adapter->tx_ring.tx_desc_ring +
 						INDEX10(tcb->index_start));
 
-			pci_unmap_single(adapter->pdev,
+			dma_unmap_single(&adapter->pdev->dev,
 					 desc->addr_lo,
-					 desc->len_vlan, PCI_DMA_TODEVICE);
+					 desc->len_vlan, DMA_TO_DEVICE);
 
 			add_10bit(&tcb->index_start, 1);
 			if (INDEX10(tcb->index_start) >=
@@ -4428,15 +4428,15 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev,
 	}
 
 	/* Check the DMA addressing support of this device */
-	if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
-		result = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
+	if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
+		result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
 		if (result) {
 			dev_err(&pdev->dev,
 			  "Unable to obtain 64 bit DMA for consistent allocations\n");
 			goto err_release_res;
 		}
-	} else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
-		result = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+	} else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
+		result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
 		if (result) {
 			dev_err(&pdev->dev,
 			  "Unable to obtain 32 bit DMA for consistent allocations\n");
Signature · 1 line
1.7.6.4
author
#22 lore raw

PATCH RESEND 19/26 staging: et131x: Remove unused defines

In reply to Mark Einon

Some defines are no longer referenced in the code, so removed them.

---
 drivers/staging/et131x/et131x.c |   11 -----------
 1 files changed, 0 insertions(+), 11 deletions(-)
drivers/staging/et131x/et131x.c +0 -11
index 1c11dfd..1efa27c 100644
@@ -145,21 +145,14 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver "
 /* MP_ADAPTER flags */
 #define fMP_ADAPTER_RECV_LOOKASIDE	0x00000004
 #define fMP_ADAPTER_INTERRUPT_IN_USE	0x00000008
-#define fMP_ADAPTER_SECONDARY		0x00000010
 
 /* MP_SHARED flags */
-#define fMP_ADAPTER_SHUTDOWN		0x00100000
 #define fMP_ADAPTER_LOWER_POWER		0x00200000
 
 #define fMP_ADAPTER_NON_RECOVER_ERROR	0x00800000
-#define fMP_ADAPTER_RESET_IN_PROGRESS	0x01000000
-#define fMP_ADAPTER_NO_CABLE		0x02000000
 #define fMP_ADAPTER_HARDWARE_ERROR	0x04000000
-#define fMP_ADAPTER_REMOVE_IN_PROGRESS	0x08000000
-#define fMP_ADAPTER_HALT_IN_PROGRESS	0x10000000
 
 #define fMP_ADAPTER_FAIL_SEND_MASK	0x3ff00000
-#define fMP_ADAPTER_NOT_READY_MASK	0x3ff00000
 
 /* Some offsets in PCI config space that are actually used. */
 #define ET1310_PCI_MAX_PYLD		0x4C
@@ -205,7 +198,6 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver "
 
 #define NUM_PACKETS_HANDLED	256
 
-#define ALCATEL_BAD_STATUS	0xe47f0000
 #define ALCATEL_MULTICAST_PKT	0x01000000
 #define ALCATEL_BROADCAST_PKT	0x02000000
 
@@ -452,8 +444,6 @@ struct tx_ring {
  * Once the desired performance has been achieved, the optimal registry values
  * should be re-populated to these #defines:
  */
-#define NUM_TRAFFIC_CLASSES          1
-
 #define TX_ERROR_PERIOD             1000
 
 #define LO_MARK_PERCENT_FOR_PSR     15
@@ -4715,7 +4705,6 @@ void et131x_disable_interrupts(struct et131x_adapter *adapter)
 	writel(INT_MASK_DISABLE, &adapter->regs->global.int_mask);
 }
 
-
 /**
  * et131x_isr - The Interrupt Service Routine for the driver.
  * @irq: the IRQ on which the interrupt was received.
Signature · 1 line
1.7.6.4
author
#23 lore raw

PATCH 20/26 staging: et131x: Remove unused rx_ring.recv_buffer_pool

In reply to Mark Einon

rx_ring.recv_buffer_pool is unused, even in the original driver code. Remove from stuct, and also remove some comments regarding it.

---
 drivers/staging/et131x/et131x.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
drivers/staging/et131x/et131x.c +0 -6
index 1efa27c..8c557cf 100644
@@ -329,8 +329,6 @@ struct rx_ring {
 	struct rx_status_block *rx_status_block;
 	dma_addr_t rx_status_bus;
 
-	struct list_head recv_buff_pool;
-
 	/* RECV */
 	struct list_head recv_list;
 	u32 num_ready_recv;
@@ -2307,10 +2305,6 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter)
 		rx_ring->rx_status_block = NULL;
 	}
 
-	/* Free receive buffer pool */
-
-	/* Free receive packet pool */
-
 	/* Destroy the lookaside (RFD) pool */
 	if (adapter->flags & fMP_ADAPTER_RECV_LOOKASIDE) {
 		kmem_cache_destroy(rx_ring->recv_lookaside);
Signature · 1 line
1.7.6.4
author
#24 lore raw

PATCH 21/26 staging: et131x: Remove redundant et131x_reset_recv() call

In reply to Mark Einon

This call doesn't do anything useful - only warns on the receive list being empty, so removed it.

---
 drivers/staging/et131x/et131x.c |   18 ------------------
 1 files changed, 0 insertions(+), 18 deletions(-)
drivers/staging/et131x/et131x.c +0 -18
index 8c557cf..f521e33 100644
@@ -605,7 +605,6 @@ int32_t et131x_mii_write(struct et131x_adapter *adapter,
 void et131x_rx_dma_memory_free(struct et131x_adapter *adapter);
 void et131x_rx_dma_disable(struct et131x_adapter *adapter);
 void et131x_rx_dma_enable(struct et131x_adapter *adapter);
-void et131x_reset_recv(struct et131x_adapter *adapter);
 void et131x_init_send(struct et131x_adapter *adapter);
 void et131x_tx_dma_enable(struct et131x_adapter *adapter);
 
@@ -1839,9 +1838,6 @@ void et1310_disable_phy_coma(struct et131x_adapter *adapter)
 	/* Re-initialize the send structures */
 	et131x_init_send(adapter);
 
-	/* Reset the RFD list and re-start RU  */
-	et131x_reset_recv(adapter);
-
 	/* Bring the device back to the state it was during init prior to
 	 * autonegotiation being complete.  This way, when we get the auto-neg
 	 * complete interrupt, we can complete init by calling ConfigMacREGS2.
@@ -2882,17 +2878,6 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
 }
 
 /**
- * et131x_reset_recv - Reset the receive list
- * @adapter: pointer to our adapter
- *
- * Assumption, Rcv spinlock has been acquired.
- */
-void et131x_reset_recv(struct et131x_adapter *adapter)
-{
-	WARN_ON(list_empty(&adapter->rx_ring.recv_list));
-}
-
-/**
  * et131x_handle_recv_interrupt - Interrupt handler for receive processing
  * @adapter: pointer to our adapter
  *
@@ -4251,9 +4236,6 @@ static void et131x_adjust_link(struct net_device *netdev)
 			/* Re-initialize the send structures */
 			et131x_init_send(adapter);
 
-			/* Reset the RFD list and re-start RU */
-			et131x_reset_recv(adapter);
-
 			/*
 			 * Bring the device back to the state it was during
 			 * init prior to autonegotiation being complete. This
Signature · 1 line
1.7.6.4
author
#25 lore raw

PATCH 22/26 staging: et131x: Remove call to find pci pm capability

In reply to Mark Einon

pci_find_capability is called, but not used and is now redundant as power management is handled elsewhere. Removed.

---
 drivers/staging/et131x/et131x.c |   14 --------------
 1 files changed, 0 insertions(+), 14 deletions(-)
drivers/staging/et131x/et131x.c +0 -14
index f521e33..9383c5c 100644
@@ -4356,7 +4356,6 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev,
 			       const struct pci_device_id *ent)
 {
 	int result;
-	int pm_cap;
 	struct net_device *netdev;
 	struct et131x_adapter *adapter;
 	int ii;
@@ -4380,19 +4379,6 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev,
 
 	pci_set_master(pdev);
 
-	/* Query PCI for Power Mgmt Capabilities
-	 *
-	 * NOTE: Now reading PowerMgmt in another location; is this still
-	 * needed?
-	 */
-	pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
-	if (!pm_cap) {
-		dev_err(&pdev->dev,
-			  "Cannot find Power Management capabilities\n");
-		result = -EIO;
-		goto err_release_res;
-	}
-
 	/* Check the DMA addressing support of this device */
 	if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
 		result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
Signature · 1 line
1.7.6.4
author
#26 lore raw

PATCH 23/26 staging: et131x: Remove unused rx_ring.recv_packet_pool

In reply to Mark Einon

tx_ring.recv_packet_pool is unused, even in the original driver code. Removed.

---
 drivers/staging/et131x/et131x.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/staging/et131x/et131x.c +0 -2
index 9383c5c..cf6f7a2 100644
@@ -337,8 +337,6 @@ struct rx_ring {
 
 	bool unfinished_receives;
 
-	struct list_head recv_packet_pool;
-
 	/* lookaside lists */
 	struct kmem_cache *recv_lookaside;
 };
Signature · 1 line
1.7.6.4
author
#27 lore raw

PATCH 24/26 staging: et131x: Remove some forward declarations

In reply to Mark Einon

Moved functions in et131x.c file to remove the following forward declarations:

et131x_align_allocated_memory
et131x_disable_interrupts
et131x_enable_interrupts
et131x_error_timer_handler

---
 drivers/staging/et131x/et131x.c |  126 ++++++++++++++++++--------------------
 1 files changed, 60 insertions(+), 66 deletions(-)
drivers/staging/et131x/et131x.c +60 -66
index cf6f7a2..8048d67 100644
@@ -576,12 +576,6 @@ struct et131x_adapter {
 	struct net_device_stats net_stats;
 };
 
-void et131x_error_timer_handler(unsigned long data);
-void et131x_enable_interrupts(struct et131x_adapter *adapter);
-void et131x_disable_interrupts(struct et131x_adapter *adapter);
-void et131x_align_allocated_memory(struct et131x_adapter *adapter,
-				   u64 *phys_addr,
-				   u64 *offset, u64 mask);
 void et131x_adapter_setup(struct et131x_adapter *adapter);
 void et131x_soft_reset(struct et131x_adapter *adapter);
 void et131x_isr_handler(struct work_struct *work);
@@ -1872,6 +1866,33 @@ static inline u32 bump_free_buff_ring(u32 *free_buff_ring, u32 limit)
 }
 
 /**
+ * et131x_align_allocated_memory - Align allocated memory on a given boundary
+ * @adapter: pointer to our adapter structure
+ * @phys_addr: pointer to Physical address
+ * @offset: pointer to the offset variable
+ * @mask: correct mask
+ */
+void et131x_align_allocated_memory(struct et131x_adapter *adapter,
+				   uint64_t *phys_addr,
+				   uint64_t *offset, uint64_t mask)
+{
+	uint64_t new_addr;
+
+	*offset = 0;
+
+	new_addr = *phys_addr & ~mask;
+
+	if (new_addr != *phys_addr) {
+		/* Move to next aligned block */
+		new_addr += mask + 1;
+		/* Return offset for adjusting virt addr */
+		*offset = new_addr - *phys_addr;
+		/* Return new physical address */
+		*phys_addr = new_addr;
+	}
+}
+
+/**
  * et131x_rx_dma_memory_alloc
  * @adapter: pointer to our private adapter structure
  *
@@ -3938,6 +3959,27 @@ static int et131x_pci_init(struct et131x_adapter *adapter,
 }
 
 /**
+ *	et131x_enable_interrupts	-	enable interrupt
+ *	@adapter: et131x device
+ *
+ *	Enable the appropriate interrupts on the ET131x according to our
+ *	configuration
+ */
+void et131x_enable_interrupts(struct et131x_adapter *adapter)
+{
+	u32 mask;
+
+	/* Enable all global interrupts */
+	if (adapter->flowcontrol == FLOW_TXONLY ||
+			    adapter->flowcontrol == FLOW_BOTH)
+		mask = INT_MASK_ENABLE;
+	else
+		mask = INT_MASK_ENABLE_NO_FLOW;
+
+	writel(mask, &adapter->regs->global.int_mask);
+}
+
+/**
  * et131x_error_timer_handler
  * @data: timer-specific variable; here a pointer to our adapter structure
  *
@@ -4071,33 +4113,6 @@ void et131x_soft_reset(struct et131x_adapter *adapter)
 }
 
 /**
- * et131x_align_allocated_memory - Align allocated memory on a given boundary
- * @adapter: pointer to our adapter structure
- * @phys_addr: pointer to Physical address
- * @offset: pointer to the offset variable
- * @mask: correct mask
- */
-void et131x_align_allocated_memory(struct et131x_adapter *adapter,
-				   uint64_t *phys_addr,
-				   uint64_t *offset, uint64_t mask)
-{
-	uint64_t new_addr;
-
-	*offset = 0;
-
-	new_addr = *phys_addr & ~mask;
-
-	if (new_addr != *phys_addr) {
-		/* Move to next aligned block */
-		new_addr += mask + 1;
-		/* Return offset for adjusting virt addr */
-		*offset = new_addr - *phys_addr;
-		/* Return new physical address */
-		*phys_addr = new_addr;
-	}
-}
-
-/**
  * et131x_adapter_memory_alloc
  * @adapter: pointer to our private adapter structure
  *
@@ -4339,6 +4354,18 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev,
 }
 
 /**
+ *	et131x_disable_interrupts	-	interrupt disable
+ *	@adapter: et131x device
+ *
+ *	Block all interrupts from the et131x device at the device itself
+ */
+void et131x_disable_interrupts(struct et131x_adapter *adapter)
+{
+	/* Disable all global interrupts */
+	writel(INT_MASK_DISABLE, &adapter->regs->global.int_mask);
+}
+
+/**
  * et131x_pci_setup - Perform device initialization
  * @pdev: a pointer to the device's pci_dev structure
  * @ent: this device's entry in the pci_device_id table
@@ -4633,39 +4660,6 @@ module_exit(et131x_cleanup_module);
 /* ISR functions */
 
 /**
- *	et131x_enable_interrupts	-	enable interrupt
- *	@adapter: et131x device
- *
- *	Enable the appropriate interrupts on the ET131x according to our
- *	configuration
- */
-void et131x_enable_interrupts(struct et131x_adapter *adapter)
-{
-	u32 mask;
-
-	/* Enable all global interrupts */
-	if (adapter->flowcontrol == FLOW_TXONLY ||
-			    adapter->flowcontrol == FLOW_BOTH)
-		mask = INT_MASK_ENABLE;
-	else
-		mask = INT_MASK_ENABLE_NO_FLOW;
-
-	writel(mask, &adapter->regs->global.int_mask);
-}
-
-/**
- *	et131x_disable_interrupts	-	interrupt disable
- *	@adapter: et131x device
- *
- *	Block all interrupts from the et131x device at the device itself
- */
-void et131x_disable_interrupts(struct et131x_adapter *adapter)
-{
-	/* Disable all global interrupts */
-	writel(INT_MASK_DISABLE, &adapter->regs->global.int_mask);
-}
-
-/**
  * et131x_isr - The Interrupt Service Routine for the driver.
  * @irq: the IRQ on which the interrupt was received.
  * @dev_id: device-specific info (here a pointer to a net_device struct)
Signature · 1 line
1.7.6.4
author
#28 lore raw

PATCH 25/26 staging: et131x: Remove forward declaration of et131x_adapter_setup

In reply to Mark Einon

Also associated function movements within et131x.c file

---
 drivers/staging/et131x/et131x.c |  445 +++++++++++++++++++--------------------
 1 files changed, 222 insertions(+), 223 deletions(-)
drivers/staging/et131x/et131x.c +222 -223
index 8048d67..2947635 100644
@@ -576,7 +576,6 @@ struct et131x_adapter {
 	struct net_device_stats net_stats;
 };
 
-void et131x_adapter_setup(struct et131x_adapter *adapter);
 void et131x_soft_reset(struct et131x_adapter *adapter);
 void et131x_isr_handler(struct work_struct *work);
 void et1310_setup_device_for_multicast(struct et131x_adapter *adapter);
@@ -1731,6 +1730,53 @@ void et131x_xcvr_init(struct et131x_adapter *adapter)
 	}
 }
 
+/**
+ * et131x_configure_global_regs	-	configure JAGCore global regs
+ * @adapter: pointer to our adapter structure
+ *
+ * Used to configure the global registers on the JAGCore
+ */
+void et131x_configure_global_regs(struct et131x_adapter *adapter)
+{
+	struct global_regs __iomem *regs = &adapter->regs->global;
+
+	writel(0, &regs->rxq_start_addr);
+	writel(INTERNAL_MEM_SIZE - 1, &regs->txq_end_addr);
+
+	if (adapter->registry_jumbo_packet < 2048) {
+		/* Tx / RxDMA and Tx/Rx MAC interfaces have a 1k word
+		 * block of RAM that the driver can split between Tx
+		 * and Rx as it desires.  Our default is to split it
+		 * 50/50:
+		 */
+		writel(PARM_RX_MEM_END_DEF, &regs->rxq_end_addr);
+		writel(PARM_RX_MEM_END_DEF + 1, &regs->txq_start_addr);
+	} else if (adapter->registry_jumbo_packet < 8192) {
+		/* For jumbo packets > 2k but < 8k, split 50-50. */
+		writel(INTERNAL_MEM_RX_OFFSET, &regs->rxq_end_addr);
+		writel(INTERNAL_MEM_RX_OFFSET + 1, &regs->txq_start_addr);
+	} else {
+		/* 9216 is the only packet size greater than 8k that
+		 * is available. The Tx buffer has to be big enough
+		 * for one whole packet on the Tx side. We'll make
+		 * the Tx 9408, and give the rest to Rx
+		 */
+		writel(0x01b3, &regs->rxq_end_addr);
+		writel(0x01b4, &regs->txq_start_addr);
+	}
+
+	/* Initialize the loopback register. Disable all loopbacks. */
+	writel(0, &regs->loopback);
+
+	/* MSI Register */
+	writel(0, &regs->msi_config);
+
+	/* By default, disable the watchdog timer.  It will be enabled when
+	 * a packet is queued.
+	 */
+	writel(0, &regs->watchdog_timer);
+}
+
 /* PM functions */
 
 /**
@@ -1749,6 +1795,181 @@ int et1310_in_phy_coma(struct et131x_adapter *adapter)
 }
 
 /**
+ * et131x_config_rx_dma_regs - Start of Rx_DMA init sequence
+ * @adapter: pointer to our adapter structure
+ */
+void et131x_config_rx_dma_regs(struct et131x_adapter *adapter)
+{
+	struct rxdma_regs __iomem *rx_dma = &adapter->regs->rxdma;
+	struct rx_ring *rx_local = &adapter->rx_ring;
+	struct fbr_desc *fbr_entry;
+	u32 entry;
+	u32 psr_num_des;
+	unsigned long flags;
+
+	/* Halt RXDMA to perform the reconfigure.  */
+	et131x_rx_dma_disable(adapter);
+
+	/* Load the completion writeback physical address
+	 *
+	 * NOTE : dma_alloc_coherent(), used above to alloc DMA regions,
+	 * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses
+	 * are ever returned, make sure the high part is retrieved here
+	 * before storing the adjusted address.
+	 */
+	writel((u32) ((u64)rx_local->rx_status_bus >> 32),
+	       &rx_dma->dma_wb_base_hi);
+	writel((u32) rx_local->rx_status_bus, &rx_dma->dma_wb_base_lo);
+
+	memset(rx_local->rx_status_block, 0, sizeof(struct rx_status_block));
+
+	/* Set the address and parameters of the packet status ring into the
+	 * 1310's registers
+	 */
+	writel((u32) ((u64)rx_local->ps_ring_physaddr >> 32),
+	       &rx_dma->psr_base_hi);
+	writel((u32) rx_local->ps_ring_physaddr, &rx_dma->psr_base_lo);
+	writel(rx_local->psr_num_entries - 1, &rx_dma->psr_num_des);
+	writel(0, &rx_dma->psr_full_offset);
+
+	psr_num_des = readl(&rx_dma->psr_num_des) & 0xFFF;
+	writel((psr_num_des * LO_MARK_PERCENT_FOR_PSR) / 100,
+	       &rx_dma->psr_min_des);
+
+	spin_lock_irqsave(&adapter->rcv_lock, flags);
+
+	/* These local variables track the PSR in the adapter structure */
+	rx_local->local_psr_full = 0;
+
+	/* Now's the best time to initialize FBR1 contents */
+	fbr_entry = (struct fbr_desc *) rx_local->fbr[0]->ring_virtaddr;
+	for (entry = 0; entry < rx_local->fbr[0]->num_entries; entry++) {
+		fbr_entry->addr_hi = rx_local->fbr[0]->bus_high[entry];
+		fbr_entry->addr_lo = rx_local->fbr[0]->bus_low[entry];
+		fbr_entry->word2 = entry;
+		fbr_entry++;
+	}
+
+	/* Set the address and parameters of Free buffer ring 1 (and 0 if
+	 * required) into the 1310's registers
+	 */
+	writel((u32) (rx_local->fbr[0]->real_physaddr >> 32),
+	       &rx_dma->fbr1_base_hi);
+	writel((u32) rx_local->fbr[0]->real_physaddr, &rx_dma->fbr1_base_lo);
+	writel(rx_local->fbr[0]->num_entries - 1, &rx_dma->fbr1_num_des);
+	writel(ET_DMA10_WRAP, &rx_dma->fbr1_full_offset);
+
+	/* This variable tracks the free buffer ring 1 full position, so it
+	 * has to match the above.
+	 */
+	rx_local->fbr[0]->local_full = ET_DMA10_WRAP;
+	writel(
+	    ((rx_local->fbr[0]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1,
+	    &rx_dma->fbr1_min_des);
+
+#ifdef USE_FBR0
+	/* Now's the best time to initialize FBR0 contents */
+	fbr_entry = (struct fbr_desc *) rx_local->fbr[1]->ring_virtaddr;
+	for (entry = 0; entry < rx_local->fbr[1]->num_entries; entry++) {
+		fbr_entry->addr_hi = rx_local->fbr[1]->bus_high[entry];
+		fbr_entry->addr_lo = rx_local->fbr[1]->bus_low[entry];
+		fbr_entry->word2 = entry;
+		fbr_entry++;
+	}
+
+	writel((u32) (rx_local->fbr[1]->real_physaddr >> 32),
+	       &rx_dma->fbr0_base_hi);
+	writel((u32) rx_local->fbr[1]->real_physaddr, &rx_dma->fbr0_base_lo);
+	writel(rx_local->fbr[1]->num_entries - 1, &rx_dma->fbr0_num_des);
+	writel(ET_DMA10_WRAP, &rx_dma->fbr0_full_offset);
+
+	/* This variable tracks the free buffer ring 0 full position, so it
+	 * has to match the above.
+	 */
+	rx_local->fbr[1]->local_full = ET_DMA10_WRAP;
+	writel(
+	    ((rx_local->fbr[1]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1,
+	    &rx_dma->fbr0_min_des);
+#endif
+
+	/* Program the number of packets we will receive before generating an
+	 * interrupt.
+	 * For version B silicon, this value gets updated once autoneg is
+	 *complete.
+	 */
+	writel(PARM_RX_NUM_BUFS_DEF, &rx_dma->num_pkt_done);
+
+	/* The "time_done" is not working correctly to coalesce interrupts
+	 * after a given time period, but rather is giving us an interrupt
+	 * regardless of whether we have received packets.
+	 * This value gets updated once autoneg is complete.
+	 */
+	writel(PARM_RX_TIME_INT_DEF, &rx_dma->max_pkt_time);
+
+	spin_unlock_irqrestore(&adapter->rcv_lock, flags);
+}
+
+/**
+ * et131x_config_tx_dma_regs - Set up the tx dma section of the JAGCore.
+ * @adapter: pointer to our private adapter structure
+ *
+ * Configure the transmit engine with the ring buffers we have created
+ * and prepare it for use.
+ */
+void et131x_config_tx_dma_regs(struct et131x_adapter *adapter)
+{
+	struct txdma_regs __iomem *txdma = &adapter->regs->txdma;
+
+	/* Load the hardware with the start of the transmit descriptor ring. */
+	writel((u32) ((u64)adapter->tx_ring.tx_desc_ring_pa >> 32),
+	       &txdma->pr_base_hi);
+	writel((u32) adapter->tx_ring.tx_desc_ring_pa,
+	       &txdma->pr_base_lo);
+
+	/* Initialise the transmit DMA engine */
+	writel(NUM_DESC_PER_RING_TX - 1, &txdma->pr_num_des);
+
+	/* Load the completion writeback physical address */
+	writel((u32)((u64)adapter->tx_ring.tx_status_pa >> 32),
+						&txdma->dma_wb_base_hi);
+	writel((u32)adapter->tx_ring.tx_status_pa, &txdma->dma_wb_base_lo);
+
+	*adapter->tx_ring.tx_status = 0;
+
+	writel(0, &txdma->service_request);
+	adapter->tx_ring.send_idx = 0;
+}
+
+/**
+ * et131x_adapter_setup - Set the adapter up as per cassini+ documentation
+ * @adapter: pointer to our private adapter structure
+ *
+ * Returns 0 on success, errno on failure (as defined in errno.h)
+ */
+void et131x_adapter_setup(struct et131x_adapter *adapter)
+{
+	/* Configure the JAGCore */
+	et131x_configure_global_regs(adapter);
+
+	et1310_config_mac_regs1(adapter);
+
+	/* Configure the MMC registers */
+	/* All we need to do is initialize the Memory Control Register */
+	writel(ET_MMC_ENABLE, &adapter->regs->mmc.mmc_ctrl);
+
+	et1310_config_rxmac_regs(adapter);
+	et1310_config_txmac_regs(adapter);
+
+	et131x_config_rx_dma_regs(adapter);
+	et131x_config_tx_dma_regs(adapter);
+
+	et1310_config_macstat_regs(adapter);
+
+	et1310_phy_power_down(adapter, 0);
+	et131x_xcvr_init(adapter);
+}
+
+/**
  * et1310_enable_phy_coma - called when network cable is unplugged
  * @adapter: pointer to our adapter structure
  *
@@ -2390,121 +2611,6 @@ int et131x_init_recv(struct et131x_adapter *adapter)
 }
 
 /**
- * et131x_config_rx_dma_regs - Start of Rx_DMA init sequence
- * @adapter: pointer to our adapter structure
- */
-void et131x_config_rx_dma_regs(struct et131x_adapter *adapter)
-{
-	struct rxdma_regs __iomem *rx_dma = &adapter->regs->rxdma;
-	struct rx_ring *rx_local = &adapter->rx_ring;
-	struct fbr_desc *fbr_entry;
-	u32 entry;
-	u32 psr_num_des;
-	unsigned long flags;
-
-	/* Halt RXDMA to perform the reconfigure.  */
-	et131x_rx_dma_disable(adapter);
-
-	/* Load the completion writeback physical address
-	 *
-	 * NOTE : dma_alloc_coherent(), used above to alloc DMA regions,
-	 * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses
-	 * are ever returned, make sure the high part is retrieved here
-	 * before storing the adjusted address.
-	 */
-	writel((u32) ((u64)rx_local->rx_status_bus >> 32),
-	       &rx_dma->dma_wb_base_hi);
-	writel((u32) rx_local->rx_status_bus, &rx_dma->dma_wb_base_lo);
-
-	memset(rx_local->rx_status_block, 0, sizeof(struct rx_status_block));
-
-	/* Set the address and parameters of the packet status ring into the
-	 * 1310's registers
-	 */
-	writel((u32) ((u64)rx_local->ps_ring_physaddr >> 32),
-	       &rx_dma->psr_base_hi);
-	writel((u32) rx_local->ps_ring_physaddr, &rx_dma->psr_base_lo);
-	writel(rx_local->psr_num_entries - 1, &rx_dma->psr_num_des);
-	writel(0, &rx_dma->psr_full_offset);
-
-	psr_num_des = readl(&rx_dma->psr_num_des) & 0xFFF;
-	writel((psr_num_des * LO_MARK_PERCENT_FOR_PSR) / 100,
-	       &rx_dma->psr_min_des);
-
-	spin_lock_irqsave(&adapter->rcv_lock, flags);
-
-	/* These local variables track the PSR in the adapter structure */
-	rx_local->local_psr_full = 0;
-
-	/* Now's the best time to initialize FBR1 contents */
-	fbr_entry = (struct fbr_desc *) rx_local->fbr[0]->ring_virtaddr;
-	for (entry = 0; entry < rx_local->fbr[0]->num_entries; entry++) {
-		fbr_entry->addr_hi = rx_local->fbr[0]->bus_high[entry];
-		fbr_entry->addr_lo = rx_local->fbr[0]->bus_low[entry];
-		fbr_entry->word2 = entry;
-		fbr_entry++;
-	}
-
-	/* Set the address and parameters of Free buffer ring 1 (and 0 if
-	 * required) into the 1310's registers
-	 */
-	writel((u32) (rx_local->fbr[0]->real_physaddr >> 32),
-	       &rx_dma->fbr1_base_hi);
-	writel((u32) rx_local->fbr[0]->real_physaddr, &rx_dma->fbr1_base_lo);
-	writel(rx_local->fbr[0]->num_entries - 1, &rx_dma->fbr1_num_des);
-	writel(ET_DMA10_WRAP, &rx_dma->fbr1_full_offset);
-
-	/* This variable tracks the free buffer ring 1 full position, so it
-	 * has to match the above.
-	 */
-	rx_local->fbr[0]->local_full = ET_DMA10_WRAP;
-	writel(
-	    ((rx_local->fbr[0]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1,
-	    &rx_dma->fbr1_min_des);
-
-#ifdef USE_FBR0
-	/* Now's the best time to initialize FBR0 contents */
-	fbr_entry = (struct fbr_desc *) rx_local->fbr[1]->ring_virtaddr;
-	for (entry = 0; entry < rx_local->fbr[1]->num_entries; entry++) {
-		fbr_entry->addr_hi = rx_local->fbr[1]->bus_high[entry];
-		fbr_entry->addr_lo = rx_local->fbr[1]->bus_low[entry];
-		fbr_entry->word2 = entry;
-		fbr_entry++;
-	}
-
-	writel((u32) (rx_local->fbr[1]->real_physaddr >> 32),
-	       &rx_dma->fbr0_base_hi);
-	writel((u32) rx_local->fbr[1]->real_physaddr, &rx_dma->fbr0_base_lo);
-	writel(rx_local->fbr[1]->num_entries - 1, &rx_dma->fbr0_num_des);
-	writel(ET_DMA10_WRAP, &rx_dma->fbr0_full_offset);
-
-	/* This variable tracks the free buffer ring 0 full position, so it
-	 * has to match the above.
-	 */
-	rx_local->fbr[1]->local_full = ET_DMA10_WRAP;
-	writel(
-	    ((rx_local->fbr[1]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1,
-	    &rx_dma->fbr0_min_des);
-#endif
-
-	/* Program the number of packets we will receive before generating an
-	 * interrupt.
-	 * For version B silicon, this value gets updated once autoneg is
-	 *complete.
-	 */
-	writel(PARM_RX_NUM_BUFS_DEF, &rx_dma->num_pkt_done);
-
-	/* The "time_done" is not working correctly to coalesce interrupts
-	 * after a given time period, but rather is giving us an interrupt
-	 * regardless of whether we have received packets.
-	 * This value gets updated once autoneg is complete.
-	 */
-	writel(PARM_RX_TIME_INT_DEF, &rx_dma->max_pkt_time);
-
-	spin_unlock_irqrestore(&adapter->rcv_lock, flags);
-}
-
-/**
  * et131x_set_rx_dma_timer - Set the heartbeat timer according to line rate.
  * @adapter: pointer to our adapter structure
  */
@@ -3046,37 +3152,6 @@ void et131x_tx_dma_memory_free(struct et131x_adapter *adapter)
 }
 
 /**
- * et131x_config_tx_dma_regs - Set up the tx dma section of the JAGCore.
- * @adapter: pointer to our private adapter structure
- *
- * Configure the transmit engine with the ring buffers we have created
- * and prepare it for use.
- */
-void et131x_config_tx_dma_regs(struct et131x_adapter *adapter)
-{
-	struct txdma_regs __iomem *txdma = &adapter->regs->txdma;
-
-	/* Load the hardware with the start of the transmit descriptor ring. */
-	writel((u32) ((u64)adapter->tx_ring.tx_desc_ring_pa >> 32),
-	       &txdma->pr_base_hi);
-	writel((u32) adapter->tx_ring.tx_desc_ring_pa,
-	       &txdma->pr_base_lo);
-
-	/* Initialise the transmit DMA engine */
-	writel(NUM_DESC_PER_RING_TX - 1, &txdma->pr_num_des);
-
-	/* Load the completion writeback physical address */
-	writel((u32)((u64)adapter->tx_ring.tx_status_pa >> 32),
-						&txdma->dma_wb_base_hi);
-	writel((u32)adapter->tx_ring.tx_status_pa, &txdma->dma_wb_base_lo);
-
-	*adapter->tx_ring.tx_status = 0;
-
-	writel(0, &txdma->service_request);
-	adapter->tx_ring.send_idx = 0;
-}
-
-/**
  * et131x_tx_dma_disable - Stop of Tx_DMA on the ET1310
  * @adapter: pointer to our adapter structure
  */
@@ -4022,82 +4097,6 @@ void et131x_error_timer_handler(unsigned long data)
 }
 
 /**
- * et131x_configure_global_regs	-	configure JAGCore global regs
- * @adapter: pointer to our adapter structure
- *
- * Used to configure the global registers on the JAGCore
- */
-void et131x_configure_global_regs(struct et131x_adapter *adapter)
-{
-	struct global_regs __iomem *regs = &adapter->regs->global;
-
-	writel(0, &regs->rxq_start_addr);
-	writel(INTERNAL_MEM_SIZE - 1, &regs->txq_end_addr);
-
-	if (adapter->registry_jumbo_packet < 2048) {
-		/* Tx / RxDMA and Tx/Rx MAC interfaces have a 1k word
-		 * block of RAM that the driver can split between Tx
-		 * and Rx as it desires.  Our default is to split it
-		 * 50/50:
-		 */
-		writel(PARM_RX_MEM_END_DEF, &regs->rxq_end_addr);
-		writel(PARM_RX_MEM_END_DEF + 1, &regs->txq_start_addr);
-	} else if (adapter->registry_jumbo_packet < 8192) {
-		/* For jumbo packets > 2k but < 8k, split 50-50. */
-		writel(INTERNAL_MEM_RX_OFFSET, &regs->rxq_end_addr);
-		writel(INTERNAL_MEM_RX_OFFSET + 1, &regs->txq_start_addr);
-	} else {
-		/* 9216 is the only packet size greater than 8k that
-		 * is available. The Tx buffer has to be big enough
-		 * for one whole packet on the Tx side. We'll make
-		 * the Tx 9408, and give the rest to Rx
-		 */
-		writel(0x01b3, &regs->rxq_end_addr);
-		writel(0x01b4, &regs->txq_start_addr);
-	}
-
-	/* Initialize the loopback register. Disable all loopbacks. */
-	writel(0, &regs->loopback);
-
-	/* MSI Register */
-	writel(0, &regs->msi_config);
-
-	/* By default, disable the watchdog timer.  It will be enabled when
-	 * a packet is queued.
-	 */
-	writel(0, &regs->watchdog_timer);
-}
-
-/**
- * et131x_adapter_setup - Set the adapter up as per cassini+ documentation
- * @adapter: pointer to our private adapter structure
- *
- * Returns 0 on success, errno on failure (as defined in errno.h)
- */
-void et131x_adapter_setup(struct et131x_adapter *adapter)
-{
-	/* Configure the JAGCore */
-	et131x_configure_global_regs(adapter);
-
-	et1310_config_mac_regs1(adapter);
-
-	/* Configure the MMC registers */
-	/* All we need to do is initialize the Memory Control Register */
-	writel(ET_MMC_ENABLE, &adapter->regs->mmc.mmc_ctrl);
-
-	et1310_config_rxmac_regs(adapter);
-	et1310_config_txmac_regs(adapter);
-
-	et131x_config_rx_dma_regs(adapter);
-	et131x_config_tx_dma_regs(adapter);
-
-	et1310_config_macstat_regs(adapter);
-
-	et1310_phy_power_down(adapter, 0);
-	et131x_xcvr_init(adapter);
-}
-
-/**
  * et131x_soft_reset - Issue a soft reset to the hardware, complete for ET1310
  * @adapter: pointer to our private adapter structure
  */
Signature · 1 line
1.7.6.4
author
#29 lore raw

PATCH 26/26 staging: et131x: Remove more forward declarations

In reply to Mark Einon

Moved functions in et131x.c file to remove the following forward declarations:

et131x_soft_reset
et131x_isr_handler
et131x_device_alloc

---
 drivers/staging/et131x/et131x.c |  505 +++++++++++++++++++--------------------
 1 files changed, 251 insertions(+), 254 deletions(-)
drivers/staging/et131x/et131x.c +251 -254
index 2947635..44fff21 100644
@@ -576,13 +576,10 @@ struct et131x_adapter {
 	struct net_device_stats net_stats;
 };
 
-void et131x_soft_reset(struct et131x_adapter *adapter);
-void et131x_isr_handler(struct work_struct *work);
 void et1310_setup_device_for_multicast(struct et131x_adapter *adapter);
 void et1310_setup_device_for_unicast(struct et131x_adapter *adapter);
 void et131x_up(struct net_device *netdev);
 void et131x_down(struct net_device *netdev);
-struct net_device *et131x_device_alloc(void);
 void et131x_enable_txrx(struct net_device *netdev);
 void et131x_disable_txrx(struct net_device *netdev);
 int et1310_in_phy_coma(struct et131x_adapter *adapter);
@@ -1970,6 +1967,21 @@ void et131x_adapter_setup(struct et131x_adapter *adapter)
 }
 
 /**
+ * et131x_soft_reset - Issue a soft reset to the hardware, complete for ET1310
+ * @adapter: pointer to our private adapter structure
+ */
+void et131x_soft_reset(struct et131x_adapter *adapter)
+{
+	/* Disable MAC Core */
+	writel(0xc00f0000, &adapter->regs->mac.cfg1);
+
+	/* Set everything to a reset value */
+	writel(0x7F, &adapter->regs->global.sw_reset);
+	writel(0x000f0000, &adapter->regs->mac.cfg1);
+	writel(0x00000000, &adapter->regs->mac.cfg1);
+}
+
+/**
  * et1310_enable_phy_coma - called when network cable is unplugged
  * @adapter: pointer to our adapter structure
  *
@@ -4097,21 +4109,6 @@ void et131x_error_timer_handler(unsigned long data)
 }
 
 /**
- * et131x_soft_reset - Issue a soft reset to the hardware, complete for ET1310
- * @adapter: pointer to our private adapter structure
- */
-void et131x_soft_reset(struct et131x_adapter *adapter)
-{
-	/* Disable MAC Core */
-	writel(0xc00f0000, &adapter->regs->mac.cfg1);
-
-	/* Set everything to a reset value */
-	writel(0x7F, &adapter->regs->global.sw_reset);
-	writel(0x000f0000, &adapter->regs->mac.cfg1);
-	writel(0x00000000, &adapter->regs->mac.cfg1);
-}
-
-/**
  * et131x_adapter_memory_alloc
  * @adapter: pointer to our private adapter structure
  *
@@ -4365,200 +4362,6 @@ void et131x_disable_interrupts(struct et131x_adapter *adapter)
 }
 
 /**
- * et131x_pci_setup - Perform device initialization
- * @pdev: a pointer to the device's pci_dev structure
- * @ent: this device's entry in the pci_device_id table
- *
- * Returns 0 on success, errno on failure (as defined in errno.h)
- *
- * Registered in the pci_driver structure, this function is called when the
- * PCI subsystem finds a new PCI device which matches the information
- * contained in the pci_device_id table. This routine is the equivalent to
- * a device insertion routine.
- */
-static int __devinit et131x_pci_setup(struct pci_dev *pdev,
-			       const struct pci_device_id *ent)
-{
-	int result;
-	struct net_device *netdev;
-	struct et131x_adapter *adapter;
-	int ii;
-
-	result = pci_enable_device(pdev);
-	if (result) {
-		dev_err(&pdev->dev, "pci_enable_device() failed\n");
-		goto err_out;
-	}
-
-	/* Perform some basic PCI checks */
-	if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
-		dev_err(&pdev->dev, "Can't find PCI device's base address\n");
-		goto err_disable;
-	}
-
-	if (pci_request_regions(pdev, DRIVER_NAME)) {
-		dev_err(&pdev->dev, "Can't get PCI resources\n");
-		goto err_disable;
-	}
-
-	pci_set_master(pdev);
-
-	/* Check the DMA addressing support of this device */
-	if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
-		result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
-		if (result) {
-			dev_err(&pdev->dev,
-			  "Unable to obtain 64 bit DMA for consistent allocations\n");
-			goto err_release_res;
-		}
-	} else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
-		result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
-		if (result) {
-			dev_err(&pdev->dev,
-			  "Unable to obtain 32 bit DMA for consistent allocations\n");
-			goto err_release_res;
-		}
-	} else {
-		dev_err(&pdev->dev, "No usable DMA addressing method\n");
-		result = -EIO;
-		goto err_release_res;
-	}
-
-	/* Allocate netdev and private adapter structs */
-	netdev = et131x_device_alloc();
-	if (!netdev) {
-		dev_err(&pdev->dev, "Couldn't alloc netdev struct\n");
-		result = -ENOMEM;
-		goto err_release_res;
-	}
-
-	SET_NETDEV_DEV(netdev, &pdev->dev);
-	et131x_set_ethtool_ops(netdev);
-
-	adapter = et131x_adapter_init(netdev, pdev);
-
-	/* Initialise the PCI setup for the device */
-	et131x_pci_init(adapter, pdev);
-
-	/* Map the bus-relative registers to system virtual memory */
-	adapter->regs = pci_ioremap_bar(pdev, 0);
-	if (!adapter->regs) {
-		dev_err(&pdev->dev, "Cannot map device registers\n");
-		result = -ENOMEM;
-		goto err_free_dev;
-	}
-
-	/* If Phy COMA mode was enabled when we went down, disable it here. */
-	writel(ET_PMCSR_INIT,  &adapter->regs->global.pm_csr);
-
-	/* Issue a global reset to the et1310 */
-	et131x_soft_reset(adapter);
-
-	/* Disable all interrupts (paranoid) */
-	et131x_disable_interrupts(adapter);
-
-	/* Allocate DMA memory */
-	result = et131x_adapter_memory_alloc(adapter);
-	if (result) {
-		dev_err(&pdev->dev, "Could not alloc adapater memory (DMA)\n");
-		goto err_iounmap;
-	}
-
-	/* Init send data structures */
-	et131x_init_send(adapter);
-
-	/* Set up the task structure for the ISR's deferred handler */
-	INIT_WORK(&adapter->task, et131x_isr_handler);
-
-	/* Copy address into the net_device struct */
-	memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN);
-
-	/* Init variable for counting how long we do not have link status */
-	adapter->boot_coma = 0;
-	et1310_disable_phy_coma(adapter);
-
-	/* Setup the mii_bus struct */
-	adapter->mii_bus = mdiobus_alloc();
-	if (!adapter->mii_bus) {
-		dev_err(&pdev->dev, "Alloc of mii_bus struct failed\n");
-		goto err_mem_free;
-	}
-
-	adapter->mii_bus->name = "et131x_eth_mii";
-	snprintf(adapter->mii_bus->id, MII_BUS_ID_SIZE, "%x",
-		(adapter->pdev->bus->number << 8) | adapter->pdev->devfn);
-	adapter->mii_bus->priv = netdev;
-	adapter->mii_bus->read = et131x_mdio_read;
-	adapter->mii_bus->write = et131x_mdio_write;
-	adapter->mii_bus->reset = et131x_mdio_reset;
-	adapter->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
-	if (!adapter->mii_bus->irq) {
-		dev_err(&pdev->dev, "mii_bus irq allocation failed\n");
-		goto err_mdio_free;
-	}
-
-	for (ii = 0; ii < PHY_MAX_ADDR; ii++)
-		adapter->mii_bus->irq[ii] = PHY_POLL;
-
-	if (mdiobus_register(adapter->mii_bus)) {
-		dev_err(&pdev->dev, "failed to register MII bus\n");
-		mdiobus_free(adapter->mii_bus);
-		goto err_mdio_free_irq;
-	}
-
-	if (et131x_mii_probe(netdev)) {
-		dev_err(&pdev->dev, "failed to probe MII bus\n");
-		goto err_mdio_unregister;
-	}
-
-	/* Setup et1310 as per the documentation */
-	et131x_adapter_setup(adapter);
-
-	/* We can enable interrupts now
-	 *
-	 *  NOTE - Because registration of interrupt handler is done in the
-	 *         device's open(), defer enabling device interrupts to that
-	 *         point
-	 */
-
-	/* Register the net_device struct with the Linux network layer */
-	result = register_netdev(netdev);
-	if (result != 0) {
-		dev_err(&pdev->dev, "register_netdev() failed\n");
-		goto err_mdio_unregister;
-	}
-
-	/* Register the net_device struct with the PCI subsystem. Save a copy
-	 * of the PCI config space for this device now that the device has
-	 * been initialized, just in case it needs to be quickly restored.
-	 */
-	pci_set_drvdata(pdev, netdev);
-	pci_save_state(adapter->pdev);
-
-	return result;
-
-err_mdio_unregister:
-	mdiobus_unregister(adapter->mii_bus);
-err_mdio_free_irq:
-	kfree(adapter->mii_bus->irq);
-err_mdio_free:
-	mdiobus_free(adapter->mii_bus);
-err_mem_free:
-	et131x_adapter_memory_free(adapter);
-err_iounmap:
-	iounmap(adapter->regs);
-err_free_dev:
-	pci_dev_put(pdev);
-	free_netdev(netdev);
-err_release_res:
-	pci_release_regions(pdev);
-err_disable:
-	pci_disable_device(pdev);
-err_out:
-	return result;
-}
-
-/**
  * et131x_pci_remove
  * @pdev: a pointer to the device's pci_dev structure
  *
@@ -4614,48 +4417,6 @@ static int et131x_resume(struct device *dev)
 	return 0;
 }
 
-static SIMPLE_DEV_PM_OPS(et131x_pm_ops, et131x_suspend, et131x_resume);
-#define ET131X_PM_OPS (&et131x_pm_ops)
-#else
-#define ET131X_PM_OPS NULL
-#endif
-
-static DEFINE_PCI_DEVICE_TABLE(et131x_pci_table) = {
-	{ PCI_VDEVICE(ATT, ET131X_PCI_DEVICE_ID_GIG), 0UL},
-	{ PCI_VDEVICE(ATT, ET131X_PCI_DEVICE_ID_FAST), 0UL},
-	{0,}
-};
-MODULE_DEVICE_TABLE(pci, et131x_pci_table);
-
-static struct pci_driver et131x_driver = {
-	.name		= DRIVER_NAME,
-	.id_table	= et131x_pci_table,
-	.probe		= et131x_pci_setup,
-	.remove		= __devexit_p(et131x_pci_remove),
-	.driver.pm	= ET131X_PM_OPS,
-};
-
-/**
- * et131x_init_module - The "main" entry point called on driver initialization
- *
- * Returns 0 on success, errno on failure (as defined in errno.h)
- */
-static int __init et131x_init_module(void)
-{
-	return pci_register_driver(&et131x_driver);
-}
-
-/**
- * et131x_cleanup_module - The entry point called on driver cleanup
- */
-static void __exit et131x_cleanup_module(void)
-{
-	pci_unregister_driver(&et131x_driver);
-}
-
-module_init(et131x_init_module);
-module_exit(et131x_cleanup_module);
-
 /* ISR functions */
 
 /**
@@ -5528,3 +5289,239 @@ struct net_device *et131x_device_alloc(void)
 	return netdev;
 }
 
+/**
+ * et131x_pci_setup - Perform device initialization
+ * @pdev: a pointer to the device's pci_dev structure
+ * @ent: this device's entry in the pci_device_id table
+ *
+ * Returns 0 on success, errno on failure (as defined in errno.h)
+ *
+ * Registered in the pci_driver structure, this function is called when the
+ * PCI subsystem finds a new PCI device which matches the information
+ * contained in the pci_device_id table. This routine is the equivalent to
+ * a device insertion routine.
+ */
+static int __devinit et131x_pci_setup(struct pci_dev *pdev,
+			       const struct pci_device_id *ent)
+{
+	int result;
+	struct net_device *netdev;
+	struct et131x_adapter *adapter;
+	int ii;
+
+	result = pci_enable_device(pdev);
+	if (result) {
+		dev_err(&pdev->dev, "pci_enable_device() failed\n");
+		goto err_out;
+	}
+
+	/* Perform some basic PCI checks */
+	if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
+		dev_err(&pdev->dev, "Can't find PCI device's base address\n");
+		goto err_disable;
+	}
+
+	if (pci_request_regions(pdev, DRIVER_NAME)) {
+		dev_err(&pdev->dev, "Can't get PCI resources\n");
+		goto err_disable;
+	}
+
+	pci_set_master(pdev);
+
+	/* Check the DMA addressing support of this device */
+	if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
+		result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
+		if (result) {
+			dev_err(&pdev->dev,
+			  "Unable to obtain 64 bit DMA for consistent allocations\n");
+			goto err_release_res;
+		}
+	} else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
+		result = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
+		if (result) {
+			dev_err(&pdev->dev,
+			  "Unable to obtain 32 bit DMA for consistent allocations\n");
+			goto err_release_res;
+		}
+	} else {
+		dev_err(&pdev->dev, "No usable DMA addressing method\n");
+		result = -EIO;
+		goto err_release_res;
+	}
+
+	/* Allocate netdev and private adapter structs */
+	netdev = et131x_device_alloc();
+	if (!netdev) {
+		dev_err(&pdev->dev, "Couldn't alloc netdev struct\n");
+		result = -ENOMEM;
+		goto err_release_res;
+	}
+
+	SET_NETDEV_DEV(netdev, &pdev->dev);
+	et131x_set_ethtool_ops(netdev);
+
+	adapter = et131x_adapter_init(netdev, pdev);
+
+	/* Initialise the PCI setup for the device */
+	et131x_pci_init(adapter, pdev);
+
+	/* Map the bus-relative registers to system virtual memory */
+	adapter->regs = pci_ioremap_bar(pdev, 0);
+	if (!adapter->regs) {
+		dev_err(&pdev->dev, "Cannot map device registers\n");
+		result = -ENOMEM;
+		goto err_free_dev;
+	}
+
+	/* If Phy COMA mode was enabled when we went down, disable it here. */
+	writel(ET_PMCSR_INIT,  &adapter->regs->global.pm_csr);
+
+	/* Issue a global reset to the et1310 */
+	et131x_soft_reset(adapter);
+
+	/* Disable all interrupts (paranoid) */
+	et131x_disable_interrupts(adapter);
+
+	/* Allocate DMA memory */
+	result = et131x_adapter_memory_alloc(adapter);
+	if (result) {
+		dev_err(&pdev->dev, "Could not alloc adapater memory (DMA)\n");
+		goto err_iounmap;
+	}
+
+	/* Init send data structures */
+	et131x_init_send(adapter);
+
+	/* Set up the task structure for the ISR's deferred handler */
+	INIT_WORK(&adapter->task, et131x_isr_handler);
+
+	/* Copy address into the net_device struct */
+	memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN);
+
+	/* Init variable for counting how long we do not have link status */
+	adapter->boot_coma = 0;
+	et1310_disable_phy_coma(adapter);
+
+	/* Setup the mii_bus struct */
+	adapter->mii_bus = mdiobus_alloc();
+	if (!adapter->mii_bus) {
+		dev_err(&pdev->dev, "Alloc of mii_bus struct failed\n");
+		goto err_mem_free;
+	}
+
+	adapter->mii_bus->name = "et131x_eth_mii";
+	snprintf(adapter->mii_bus->id, MII_BUS_ID_SIZE, "%x",
+		(adapter->pdev->bus->number << 8) | adapter->pdev->devfn);
+	adapter->mii_bus->priv = netdev;
+	adapter->mii_bus->read = et131x_mdio_read;
+	adapter->mii_bus->write = et131x_mdio_write;
+	adapter->mii_bus->reset = et131x_mdio_reset;
+	adapter->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
+	if (!adapter->mii_bus->irq) {
+		dev_err(&pdev->dev, "mii_bus irq allocation failed\n");
+		goto err_mdio_free;
+	}
+
+	for (ii = 0; ii < PHY_MAX_ADDR; ii++)
+		adapter->mii_bus->irq[ii] = PHY_POLL;
+
+	if (mdiobus_register(adapter->mii_bus)) {
+		dev_err(&pdev->dev, "failed to register MII bus\n");
+		mdiobus_free(adapter->mii_bus);
+		goto err_mdio_free_irq;
+	}
+
+	if (et131x_mii_probe(netdev)) {
+		dev_err(&pdev->dev, "failed to probe MII bus\n");
+		goto err_mdio_unregister;
+	}
+
+	/* Setup et1310 as per the documentation */
+	et131x_adapter_setup(adapter);
+
+	/* We can enable interrupts now
+	 *
+	 *  NOTE - Because registration of interrupt handler is done in the
+	 *         device's open(), defer enabling device interrupts to that
+	 *         point
+	 */
+
+	/* Register the net_device struct with the Linux network layer */
+	result = register_netdev(netdev);
+	if (result != 0) {
+		dev_err(&pdev->dev, "register_netdev() failed\n");
+		goto err_mdio_unregister;
+	}
+
+	/* Register the net_device struct with the PCI subsystem. Save a copy
+	 * of the PCI config space for this device now that the device has
+	 * been initialized, just in case it needs to be quickly restored.
+	 */
+	pci_set_drvdata(pdev, netdev);
+	pci_save_state(adapter->pdev);
+
+	return result;
+
+err_mdio_unregister:
+	mdiobus_unregister(adapter->mii_bus);
+err_mdio_free_irq:
+	kfree(adapter->mii_bus->irq);
+err_mdio_free:
+	mdiobus_free(adapter->mii_bus);
+err_mem_free:
+	et131x_adapter_memory_free(adapter);
+err_iounmap:
+	iounmap(adapter->regs);
+err_free_dev:
+	pci_dev_put(pdev);
+	free_netdev(netdev);
+err_release_res:
+	pci_release_regions(pdev);
+err_disable:
+	pci_disable_device(pdev);
+err_out:
+	return result;
+}
+
+static SIMPLE_DEV_PM_OPS(et131x_pm_ops, et131x_suspend, et131x_resume);
+#define ET131X_PM_OPS (&et131x_pm_ops)
+#else
+#define ET131X_PM_OPS NULL
+#endif
+
+static DEFINE_PCI_DEVICE_TABLE(et131x_pci_table) = {
+	{ PCI_VDEVICE(ATT, ET131X_PCI_DEVICE_ID_GIG), 0UL},
+	{ PCI_VDEVICE(ATT, ET131X_PCI_DEVICE_ID_FAST), 0UL},
+	{0,}
+};
+MODULE_DEVICE_TABLE(pci, et131x_pci_table);
+
+static struct pci_driver et131x_driver = {
+	.name		= DRIVER_NAME,
+	.id_table	= et131x_pci_table,
+	.probe		= et131x_pci_setup,
+	.remove		= __devexit_p(et131x_pci_remove),
+	.driver.pm	= ET131X_PM_OPS,
+};
+
+/**
+ * et131x_init_module - The "main" entry point called on driver initialization
+ *
+ * Returns 0 on success, errno on failure (as defined in errno.h)
+ */
+static int __init et131x_init_module(void)
+{
+	return pci_register_driver(&et131x_driver);
+}
+
+/**
+ * et131x_cleanup_module - The entry point called on driver cleanup
+ */
+static void __exit et131x_cleanup_module(void)
+{
+	pci_unregister_driver(&et131x_driver);
+}
+
+module_init(et131x_init_module);
+module_exit(et131x_cleanup_module);
+
Signature · 1 line
1.7.6.4