This patch set completely overhauls the mv643xx_eth driver.
The most important change is probably the eradication of the hardware
abstraction layer code in the driver, but there's also a bunch of new
features, such as initial steps towards multiple RX/TX queues and TX
bandwidth control (global and per queue), proper support for newer
mv643xx_eth versions (where some of the registers have moved around a
bit), and support for operation without a PHY, e.g. in cases where the
ethernet port is directly (over (R)GMII) connected to an ethernet
switch chip.Any feedback appreciated.
--
I think you've removed some useful documentation here. Either keep the
Keep the blank line, IMHO.
[snip]
-Dale
--
I've folded the following patch into the patch. OK?
Index: linux-2.6.26-rc5/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.6.26-rc5.orig/drivers/net/mv643xx_eth.c
+++ linux-2.6.26-rc5/drivers/net/mv643xx_eth.c
@@ -454,6 +454,11 @@ static void rxq_refill(struct rx_queue *
RX_ENABLE_INTERRUPT;
wmb();+ /*
+ * The hardware automatically prepends 2 bytes of
+ * dummy data to each received packet, so that the
+ * IP header ends up 16-byte aligned.
+ */
skb_reserve(skb, 2);
}@@ -508,7 +513,11 @@ static int rxq_process(struct rx_queue *
/*
* Update statistics.
- * Note byte count includes 4 byte CRC count
+ *
+ * Note that the descriptor byte count includes 2 dummy
+ * bytes automatically inserted by the hardware at the
+ * start of the packet (which we don't count), and a 4
+ * byte CRC at the end of the packet (which we do count).
*/
stats->rx_packets++;
stats->rx_bytes += rx_desc->byte_cnt - 2;
@@ -999,6 +1008,7 @@ static int mv643xx_eth_nway_reset(struct
static u32 mv643xx_eth_get_link(struct net_device *dev)
{
struct mv643xx_eth_private *mp = netdev_priv(dev);
+
return mii_link_ok(&mp->mii);
}
--
Looks good.
-Dale
--
The ->rx_resource_err variable doesn't serve a useful purpose --
kill it.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 15 ---------------
1 files changed, 0 insertions(+), 15 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 16dee87..cce9686 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -311,8 +311,6 @@ struct mv643xx_eth_private {
u32 tx_sram_addr; /* Base address of tx sram area */
u32 tx_sram_size; /* Size of tx sram area */- int rx_resource_err; /* Rx ring resource error flag */
-
/* Tx/Rx rings managment indexes fields. For driver use *//* Next available and first returning Rx resource */
@@ -463,9 +461,6 @@ static FUNC_RET_STATUS rx_return_buff(struct mv643xx_eth_private *mep,
/* Move the used descriptor pointer to the next descriptor */
mep->rx_used_desc_q = (used_rx_desc + 1) % mep->rx_ring_size;- /* Any Rx return cancels the Rx resource error status */
- mep->rx_resource_err = 0;
-
spin_unlock_irqrestore(&mep->lock, flags);return ETH_OK;
@@ -522,10 +517,6 @@ static FUNC_RET_STATUS port_receive(struct mv643xx_eth_private *mep,
unsigned int command_status;
unsigned long flags;- /* Do not process Rx ring in case of Rx ring resource error */
- if (mep->rx_resource_err)
- return ETH_QUEUE_FULL;
-
spin_lock_irqsave(&mep->lock, flags);/* Get the Rx Desc ring 'curr and 'used' indexes */
@@ -560,10 +551,6 @@ static FUNC_RET_STATUS port_receive(struct mv643xx_eth_private *mep,
rx_next_curr_desc = (rx_curr_desc + 1) % mep->rx_ring_size;
mep->rx_curr_desc_q = rx_next_curr_desc;- /* Rx descriptors exhausted. Set the Rx ring resource error flag */
- if (rx_next_curr_desc == rx_used_desc)
- mep->rx_resource_err = 1;
-
spin_unlock_irqrestore(&mep->lock, flags);return ETH_OK;
@@ -1751,8 +1738,6 @@ static unsigned int set_tx_coal(struct mv643xx_eth_...
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Replace the nondescriptive names ETH_INT_UNMASK_ALL and
ETH_INT_UNMASK_ALL_EXT by names of the actual fields being masked
and unmasked in the various writes to the interrupt mask registers.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 61 +++++++++++++++++---------------------------
1 files changed, 24 insertions(+), 37 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index bdb03f3..ffdd3fc 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -97,7 +97,14 @@ static char mv643xx_driver_version[] = "1.0";
#define TXQ_COMMAND(p) (0x0448 + ((p) << 10))
#define TX_BW_MTU(p) (0x0458 + ((p) << 10))
#define INT_CAUSE(p) (0x0460 + ((p) << 10))
+#define INT_RX 0x00000804
+#define INT_EXT 0x00000002
#define INT_CAUSE_EXT(p) (0x0464 + ((p) << 10))
+#define INT_EXT_LINK 0x00100000
+#define INT_EXT_PHY 0x00010000
+#define INT_EXT_TX_ERROR_0 0x00000100
+#define INT_EXT_TX_0 0x00000001
+#define INT_EXT_TX 0x00000101
#define INT_MASK(p) (0x0468 + ((p) << 10))
#define INT_MASK_EXT(p) (0x046c + ((p) << 10))
#define TX_FIFO_URGENT_THRESHOLD(p) (0x0474 + ((p) << 10))
@@ -153,26 +160,6 @@ static char mv643xx_driver_version[] = "1.0";
#define PORT_DEFAULT_TRANSMIT_QUEUE_SIZE 800
#define PORT_DEFAULT_RECEIVE_QUEUE_SIZE 400-#define ETH_RX_QUEUES_ENABLED (1 << 0) /* use only Q0 for receive */
-#define ETH_TX_QUEUES_ENABLED (1 << 0) /* use only Q0 for transmit */
-
-#define ETH_INT_CAUSE_RX_DONE (ETH_RX_QUEUES_ENABLED << 2)
-#define ETH_INT_CAUSE_RX_ERROR (ETH_RX_QUEUES_ENABLED << 9)
-#define ETH_INT_CAUSE_RX (ETH_INT_CAUSE_RX_DONE | ETH_INT_CAUSE_RX_ERROR)
-#define ETH_INT_CAUSE_EXT 0x00000002
-#define ETH_INT_UNMASK_ALL (ETH_INT_CAUSE_RX | ETH_INT_CAUSE_EXT)
-
-#define ETH_INT_CAUSE_TX_DONE (ETH_TX_QUEUES_ENABLED << 0)
-#define ETH_INT_CAUSE_TX_ERROR (ETH_TX_QUEUES_ENABLED <&...
Oops, I missed this the first time. You have an extra space in each
[snip]
-Dale
--
Right, that's because they are possible values of that register,
instead of the definition of a new register. A couple of existing
drivers follow this format (e.g. look at b44.h or tg3.h), and I kind
of like it, because it groups things logically together.OK?
--
Yes, it makes sense. I think I'd use at least a couple of
spaces of indent though. But, I'm fine with it either way.Thanks,
-Dale
--
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
I'm not sure it's worth changing all the local vars from mp to mep,
but it's not a big deal.Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Well, you're right -- that change is retarded. I'll just pull
that out.
--
Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 18 +-----------------
1 files changed, 1 insertions(+), 17 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 835b85d..c04058c 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -34,34 +34,18 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include <linux/init.h>
-#include <linux/dma-mapping.h>
+
#include <linux/in.h>
-#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/udp.h>
#include <linux/etherdevice.h>
-
-#include <linux/bitops.h>
-#include <linux/delay.h>
#include <linux/ethtool.h>
#include <linux/platform_device.h>
-
#include <linux/module.h>
-#include <linux/kernel.h>
#include <linux/spinlock.h>
-#include <linux/workqueue.h>
#include <linux/mii.h>
-
#include <linux/mv643xx_eth.h>-#include <asm/io.h>
-#include <asm/types.h>
-#include <asm/pgtable.h>
-#include <asm/system.h>
-#include <asm/delay.h>
-#include <asm/dma-mapping.h>
-
static char mv643xx_driver_name[] = "mv643xx_eth";
static char mv643xx_driver_version[] = "1.0";--
1.5.3.4--
And this for dma_map_single, etc.
I didn't bother to check all the other includes being removed, but it
seems you may have been a bit overly aggressive.-Dale
--
I just deleted everything that didn't make it stop compile, which I
admit is a bit overzealous. :)I've attached a new patch below:
- linux/ip.h only contains struct iphdr/ip_auth_hdr/ip_esp_hdr/
ip_comp_hdr and various IP options and IP TOS-related things,
none of which we use.
- linux/bitops.h contains various BIT()/BIT_MASK()/etc defines and
find_{first,next}_*bit()/ffs/for_each_bit(), none of which we use.
- asm/pgtable.h contains low-level page table handling functions and
nothing of interest to the driver as far as I can tell.
- asm/delay.h isn't needed since we include linux/delay.h
- ditto for asm/dma-mapping.hOK?
From: Lennert Buytenhek <buytenh@wantstofly.org>
Date: Sun Jun 1 00:54:05 CEST 2008
Subject: mv643xx_eth: trim unnecessary includesSigned-off-by: Lennert Buytenhek <buytenh@marvell.com>
Index: linux-2.6.26-rc5/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.6.26-rc5.orig/drivers/net/mv643xx_eth.c
+++ linux-2.6.26-rc5/drivers/net/mv643xx_eth.c
@@ -34,33 +34,25 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+
#include <linux/init.h>
#include <linux/dma-mapping.h>
#include <linux/in.h>
-#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/udp.h>
#include <linux/etherdevice.h>
-
-#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/ethtool.h>
#include <linux/platform_device.h>
-
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/spinlock.h>
#include <linux/workqueue.h>
#include <linux/mii.h>
-
#include <linux/mv643xx_eth.h>
-
#include <asm/io.h>
#include <asm/types.h>
-#include <asm/pgtable.h>
#include <asm/system.h>
-#include <asm/delay.h>
-#include <asm/dma-ma...
Sounds good. (I missed that fact taht linux/delay.h and
linux/dma-mapping.h were still included.)--
This patch performs a reverse topological sort of all functions in
mv643xx_eth.c, so that we can get rid of all forward declarations,
and end up with a more understandable driver due to related functions
being grouped together.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 3438 ++++++++++++++++++++++-----------------------
1 files changed, 1646 insertions(+), 1792 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index b7915cd..835b85d 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -62,6 +62,9 @@
#include <asm/delay.h>
#include <asm/dma-mapping.h>+static char mv643xx_driver_name[] = "mv643xx_eth";
+static char mv643xx_driver_version[] = "1.0";
+
#define MV643XX_CHECKSUM_OFFLOAD_TX
#define MV643XX_NAPI
#define MV643XX_TX_FAST_REFILL
@@ -478,7 +481,21 @@ struct pkt_info {
struct sk_buff *return_info; /* User resource return information */
};-/* Ethernet port specific information */
+
+/* global *******************************************************************/
+struct mv643xx_shared_private {
+ void __iomem *eth_base;
+
+ /* used to protect SMI_REG, which is shared across ports */
+ spinlock_t phy_lock;
+
+ u32 win_protect;
+
+ unsigned int t_clk;
+};
+
+
+/* per-port *****************************************************************/
struct mv643xx_mib_counters {
u64 good_octets_received;
u32 bad_octets_received;
@@ -512,17 +529,6 @@ struct mv643xx_mib_counters {
u32 late_collision;
};-struct mv643xx_shared_private {
- void __iomem *eth_base;
-
- /* used to protect SMI_REG, which is shared across ports */
- spinlock_t phy_lock;
-
- u32 win_protect;
-
- unsigned int t_clk;
-};
-
struct mv643xx_private {
struct mv643xx_shared_private *shared;
int port_num; /* User Ethernet port number */
@@ -585,93 +591,135 @@ struct mv643xx_private {
struct mii_if_info mii;
};-/* Static function declarations...
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
--
Shorten the various oversized register names in mv643xx_eth.c, to
increase readability.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 204 +++++++++++++++++++++------------------------
1 files changed, 96 insertions(+), 108 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index c04058c..9a9218f 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -76,38 +76,38 @@ static char mv643xx_driver_version[] = "1.0";
/*
* Registers shared between all ports.
*/
-#define PHY_ADDR_REG 0x0000
-#define SMI_REG 0x0004
-#define WINDOW_BASE(i) (0x0200 + ((i) << 3))
-#define WINDOW_SIZE(i) (0x0204 + ((i) << 3))
-#define WINDOW_REMAP_HIGH(i) (0x0280 + ((i) << 2))
-#define WINDOW_BAR_ENABLE 0x0290
-#define WINDOW_PROTECT(i) (0x0294 + ((i) << 4))
+#define PHY_ADDR 0x0000
+#define SMI_REG 0x0004
+#define WINDOW_BASE(w) (0x0200 + ((w) << 3))
+#define WINDOW_SIZE(w) (0x0204 + ((w) << 3))
+#define WINDOW_REMAP_HIGH(w) (0x0280 + ((w) << 2))
+#define WINDOW_BAR_ENABLE 0x0290
+#define WINDOW_PROTECT(w) (0x0294 + ((w) << 4))/*
* Per-port registers.
*/
-#define PORT_CONFIG_REG(p) (0x0400 + ((p) << 10))
-#define PORT_CONFIG_EXTEND_REG(p) (0x0404 + ((p) << 10))
-#define MAC_ADDR_LOW(p) (0x0414 + ((p) << 10))
-#define MAC_ADDR_HIGH(p) (0x0418 + ((p) << 10))
-#define SDMA_CONFIG_REG(p) (0x041c + ((p) << 10))
-#define PORT_SERIAL_CONTROL_REG(p) (0x043c + ((p) << 10))
-#define PORT_STATUS_REG(p) (0x0444 + ((p) << 10))
-#define TRANSMIT_QUEUE_COMMAND_REG(p) (0x0448 + ((p) << 10))
-#define MAXIMUM_TRANSMIT_UNIT(p) (0x0458 + ((p) << 10))
-#define INTERRUPT_CAUSE_REG(p) (0x0460 + ((p) << 10))
-#define INTERRUPT_CAUSE_EXTEND_REG(p) (0x0464 + ((p) << 10))
-#define INTERRUPT_MASK_REG(p) (0x0468 + ((p) << 10))
-#defin...
Half of the functions in the mv643xx_eth driver are prefixed by
useless and baroque comment blocks on _what_ those functions do (which
is obvious from the code itself) rather than why, and there's no point
in keeping those comments around.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 552 ---------------------------------------------
1 files changed, 0 insertions(+), 552 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 15174b9..16dee87 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -436,26 +436,6 @@ static unsigned int mv643xx_eth_port_disable_tx(struct mv643xx_eth_private *mep)
/* rx ***********************************************************************/
static void mv643xx_eth_free_completed_tx_descs(struct net_device *dev);-/*
- * rx_return_buff - Returns a Rx buffer back to the Rx ring.
- *
- * DESCRIPTION:
- * This routine returns a Rx buffer back to the Rx ring. It retrieves the
- * next 'used' descriptor and attached the returned buffer to it.
- * In case the Rx ring was in "resource error" condition, where there are
- * no available Rx resources, the function resets the resource error flag.
- *
- * INPUT:
- * struct mv643xx_eth_private *mep Ethernet Port Control srtuct.
- * struct pkt_info *p_pkt_info Information on returned buffer.
- *
- * OUTPUT:
- * New available Rx resource in Rx descriptor ring.
- *
- * RETURN:
- * ETH_ERROR in case the routine can not access Rx desc ring.
- * ETH_OK otherwise.
- */
static FUNC_RET_STATUS rx_return_buff(struct mv643xx_eth_private *mep,
struct pkt_info *p_pkt_info)
{
@@ -491,14 +471,6 @@ static FUNC_RET_STATUS rx_return_buff(struct mv643xx_eth_private *mep,
return ETH_OK;
}-/*
- * mv643xx_eth_rx_refill_descs
- *
- * Fills / refills RX queue on a certain gigabit ethernet port
- *
- * Input : pointer to ethernet interface network device structure
- * Output : N/A
- */
static void ...
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
--
The only user of the ETH_MIB_VERY_LONG_NAME_HERE defines is the
eth_update_mib_counters() function. Get rid of the defines by
open-coding the register offsets in the latter.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 92 ++++++++++++++++----------------------------
1 files changed, 34 insertions(+), 58 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 3c5c992..075ee2a 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -160,42 +160,6 @@ static char mv643xx_driver_version[] = "1.0";
#define PORT_DEFAULT_TRANSMIT_QUEUE_SIZE 800
#define PORT_DEFAULT_RECEIVE_QUEUE_SIZE 400-/* Gigabit Ethernet Unit Global Registers */
-
-/* MIB Counters register definitions */
-#define ETH_MIB_GOOD_OCTETS_RECEIVED_LOW 0x0
-#define ETH_MIB_GOOD_OCTETS_RECEIVED_HIGH 0x4
-#define ETH_MIB_BAD_OCTETS_RECEIVED 0x8
-#define ETH_MIB_INTERNAL_MAC_TRANSMIT_ERR 0xc
-#define ETH_MIB_GOOD_FRAMES_RECEIVED 0x10
-#define ETH_MIB_BAD_FRAMES_RECEIVED 0x14
-#define ETH_MIB_BROADCAST_FRAMES_RECEIVED 0x18
-#define ETH_MIB_MULTICAST_FRAMES_RECEIVED 0x1c
-#define ETH_MIB_FRAMES_64_OCTETS 0x20
-#define ETH_MIB_FRAMES_65_TO_127_OCTETS 0x24
-#define ETH_MIB_FRAMES_128_TO_255_OCTETS 0x28
-#define ETH_MIB_FRAMES_256_TO_511_OCTETS 0x2c
-#define ETH_MIB_FRAMES_512_TO_1023_OCTETS 0x30
-#define ETH_MIB_FRAMES_1024_TO_MAX_OCTETS 0x34
-#define ETH_MIB_GOOD_OCTETS_SENT_LOW 0x38
-#define ETH_MIB_GOOD_OCTETS_SENT_HIGH 0x3c
-#define ETH_MIB_GOOD_FRAMES_SENT 0x40
-#define ETH_MIB_EXCESSIVE_COLLISION 0x44
-#define ETH_MIB_MULTICAST_FRAMES_SENT 0x48
-#define ETH_MIB_BROADCAST_FRAMES_SENT 0x4c
-#define ETH_MIB_UNREC_MAC_CONTROL_RECEIVED 0x50
-#define ETH_MIB_FC_SENT 0x54
-#define ETH_MIB_GOOD_FC_RECEIVED 0x58
-#define ETH_MIB_BAD_FC_RECEIVED 0x5c
-#define ETH_MIB_UNDERSIZE_RECEIVED 0x60
-#define ETH_MIB_FRAGMENTS_RECEIVED 0x64
-#define ETH_MIB_OVERSIZE_RECEIVED 0x68
-#define ETH_MIB_JABBER_RE...
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Get rid of RX_BUF_OFFSET (which is synonymous with ETH_HW_IP_ALIGN).
Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index b3f4fd8..3c5c992 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -160,9 +160,6 @@ static char mv643xx_driver_version[] = "1.0";
#define PORT_DEFAULT_TRANSMIT_QUEUE_SIZE 800
#define PORT_DEFAULT_RECEIVE_QUEUE_SIZE 400-/* Buffer offset from buffer pointer */
-#define RX_BUF_OFFSET 0x2
-
/* Gigabit Ethernet Unit Global Registers *//* MIB Counters register definitions */
@@ -682,9 +679,9 @@ static ETH_FUNC_RET_STATUS eth_port_receive(struct mv643xx_private *mp,
return ETH_END_OF_JOB;
}- p_pkt_info->byte_cnt = (p_rx_desc->byte_cnt) - RX_BUF_OFFSET;
+ p_pkt_info->byte_cnt = p_rx_desc->byte_cnt - ETH_HW_IP_ALIGN;
p_pkt_info->cmd_sts = command_status;
- p_pkt_info->buf_ptr = (p_rx_desc->buf_ptr) + RX_BUF_OFFSET;
+ p_pkt_info->buf_ptr = p_rx_desc->buf_ptr + ETH_HW_IP_ALIGN;
p_pkt_info->return_info = mp->rx_skb[rx_curr_desc];
p_pkt_info->l4i_chk = p_rx_desc->buf_size;--
1.5.3.4--
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 4b61acc..bdb03f3 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -153,8 +153,6 @@ static char mv643xx_driver_version[] = "1.0";
#define PORT_DEFAULT_TRANSMIT_QUEUE_SIZE 800
#define PORT_DEFAULT_RECEIVE_QUEUE_SIZE 400-#define DESC_SIZE 64
-
#define ETH_RX_QUEUES_ENABLED (1 << 0) /* use only Q0 for receive */
#define ETH_TX_QUEUES_ENABLED (1 << 0) /* use only Q0 for transmit */--
1.5.3.4--
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
The mv643xx_eth driver only ever changes bit 0 of the port config
register at run time, the rest of the register bits are fixed (and
always zero). Document the meaning of the chosen default value,
and get rid of all the defines for each of the individual bits.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 44 +++++++-------------------------------------
1 files changed, 7 insertions(+), 37 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 9a9218f..38ba365 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -109,39 +109,6 @@ static char mv643xx_driver_version[] = "1.0";
#define OTHER_MCAST_TABLE(p) (0x1500 + ((p) << 10))
#define UNICAST_TABLE(p) (0x1600 + ((p) << 10))-/* These macros describe Ethernet Port configuration reg (Px_cR) bits */
-#define UNICAST_NORMAL_MODE (0 << 0)
-#define UNICAST_PROMISCUOUS_MODE (1 << 0)
-#define DEFAULT_RX_QUEUE(queue) ((queue) << 1)
-#define DEFAULT_RX_ARP_QUEUE(queue) ((queue) << 4)
-#define RECEIVE_BC_IF_NOT_IP_OR_ARP (0 << 7)
-#define REJECT_BC_IF_NOT_IP_OR_ARP (1 << 7)
-#define RECEIVE_BC_IF_IP (0 << 8)
-#define REJECT_BC_IF_IP (1 << 8)
-#define RECEIVE_BC_IF_ARP (0 << 9)
-#define REJECT_BC_IF_ARP (1 << 9)
-#define TX_AM_NO_UPDATE_ERROR_SUMMARY (1 << 12)
-#define CAPTURE_TCP_FRAMES_DIS (0 << 14)
-#define CAPTURE_TCP_FRAMES_EN (1 << 14)
-#define CAPTURE_UDP_FRAMES_DIS (0 << 15)
-#define CAPTURE_UDP_FRAMES_EN (1 << 15)
-#define DEFAULT_RX_TCP_QUEUE(queue) ((queue) << 16)
-#define DEFAULT_RX_UDP_QUEUE(queue) ((queue) << 19)
-#define DEFAULT_RX_BPDU_QUEUE(queue) ((queue) << 22)
-
-#define PORT_CONFIG_DEFAULT_VALUE \
- UNICAST_NORMAL_MODE | \
- DEFAULT_RX_QUEUE(0) | \
- DEFAULT_RX_ARP_QUEUE(0) | \
- RECEIVE_BC_IF_NOT_IP_OR_ARP | \
- RECEIVE_BC_IF_IP | \
- RECEIVE_BC_IF_ARP | \
- ...
Except for the stupid cast, I think the meaning was clearer with the
Getting rid of the unused definitions is a good thing though.
-Dale
--
Right, I got a bit carried away. :-) How about this instead:
From: Lennert Buytenhek <buytenh@wantstofly.org>
Date: Sun Jun 1 01:22:06 CEST 2008
Subject: mv643xx_eth: get rid of individual port config register bit definesThe mv643xx_eth driver only ever changes bit 0 of the port config
register at run time, the rest of the register bits are fixed (and
always zero). Document the meaning of the chosen default value,
and get rid of all the defines for each of the individual bits.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Index: linux-2.6.26-rc5/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.6.26-rc5.orig/drivers/net/mv643xx_eth.c
+++ linux-2.6.26-rc5/drivers/net/mv643xx_eth.c
@@ -88,6 +88,7 @@ static char mv643xx_driver_version[] = "
* Per-port registers.
*/
#define PORT_CONFIG(p) (0x0400 + ((p) << 10))
+#define UNICAST_PROMISCUOUS_MODE 0x00000001
#define PORT_CONFIG_EXT(p) (0x0404 + ((p) << 10))
#define MAC_ADDR_LOW(p) (0x0414 + ((p) << 10))
#define MAC_ADDR_HIGH(p) (0x0418 + ((p) << 10))
@@ -109,39 +110,6 @@ static char mv643xx_driver_version[] = "
#define OTHER_MCAST_TABLE(p) (0x1500 + ((p) << 10))
#define UNICAST_TABLE(p) (0x1600 + ((p) << 10))-/* These macros describe Ethernet Port configuration reg (Px_cR) bits */
-#define UNICAST_NORMAL_MODE (0 << 0)
-#define UNICAST_PROMISCUOUS_MODE (1 << 0)
-#define DEFAULT_RX_QUEUE(queue) ((queue) << 1)
-#define DEFAULT_RX_ARP_QUEUE(queue) ((queue) << 4)
-#define RECEIVE_BC_IF_NOT_IP_OR_ARP (0 << 7)
-#define REJECT_BC_IF_NOT_IP_OR_ARP (1 << 7)
-#define RECEIVE_BC_IF_IP (0 << 8)
-#define REJECT_BC_IF_IP (1 << 8)
-#define RECEIVE_BC_IF_ARP (0 << 9)
-#define REJECT_BC_IF_ARP (1 << 9)
-#define TX_AM_NO_UPDATE_ERROR_SUMMARY (1 << 12)
-#define CAPTURE_TCP_FRAMES_DIS (0 << 14)
-#define CAPTURE_TCP_FRAMES_EN...
Looks good.
-Dale
--
Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 4b6c810..cd85222 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -47,7 +47,7 @@
#include <linux/mv643xx_eth.h>static char mv643xx_eth_driver_name[] = "mv643xx_eth";
-static char mv643xx_eth_driver_version[] = "1.0";
+static char mv643xx_eth_driver_version[] = "1.1";#define MV643XX_ETH_CHECKSUM_OFFLOAD_TX
#define MV643XX_ETH_NAPI
@@ -2551,8 +2551,8 @@ static void __exit mv643xx_eth_cleanup_module(void)
}
module_exit(mv643xx_eth_cleanup_module);-MODULE_AUTHOR("Rabeeh Khoury, Assaf Hoffman, Matthew Dharm, Manish Lachwani "
- "and Dale Farnsworth");
+MODULE_AUTHOR("Rabeeh Khoury, Assaf Hoffman, Matthew Dharm, "
+ "Manish Lachwani, Dale Farnsworth and Lennert Buytenhek");
MODULE_DESCRIPTION("Ethernet driver for Marvell MV643XX");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:" MV643XX_ETH_SHARED_NAME);
--
1.5.3.4--
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Split all TX queue related state into 'struct tx_queue', in
preparation for multiple TX queue support.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 510 ++++++++++++++++++++++-----------------------
1 files changed, 254 insertions(+), 256 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 39de2db..beeadcf 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -288,38 +288,30 @@ struct rx_queue {
struct timer_list rx_oom;
};-struct mv643xx_eth_private {
- struct mv643xx_eth_shared_private *shared;
- int port_num; /* User Ethernet port number */
-
- struct mv643xx_eth_shared_private *shared_smi;
-
- u32 tx_sram_addr; /* Base address of tx sram area */
- u32 tx_sram_size; /* Size of tx sram area */
-
- /* Tx/Rx rings managment indexes fields. For driver use */
-
- /* Next available and first returning Tx resource */
- int tx_curr_desc, tx_used_desc;
+struct tx_queue {
+ int tx_ring_size;-#ifdef MV643XX_ETH_TX_FAST_REFILL
- u32 tx_clean_threshold;
-#endif
+ int tx_desc_count;
+ int tx_curr_desc;
+ int tx_used_desc;struct tx_desc *tx_desc_area;
dma_addr_t tx_desc_dma;
int tx_desc_area_size;
struct sk_buff **tx_skb;
+};
+
+struct mv643xx_eth_private {
+ struct mv643xx_eth_shared_private *shared;
+ int port_num; /* User Ethernet port number */
+
+ struct mv643xx_eth_shared_private *shared_smi;struct work_struct tx_timeout_task;
struct net_device *dev;
struct mib_counters mib_counters;
spinlock_t lock;
- /* Size of Tx Ring per queue */
- int tx_ring_size;
- /* Number of tx descriptors in use */
- int tx_desc_count;u32 rx_int_coal;
u32 tx_int_coal;
@@ -333,6 +325,17 @@ struct mv643xx_eth_private {
int rx_desc_sram_size;
struct napi_struct napi;
struct rx_queue rxq[1];
+
+ /*
+ * TX state.
+ */
+ int default_tx_ring_size;
+ unsigned long tx_desc_sram_addr;
+ int tx_desc_sram_size;
+ struct tx...
Split all RX queue related state into 'struct rx_queue', in
preparation for multiple RX queue support.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 441 +++++++++++++++++++++++----------------------
1 files changed, 225 insertions(+), 216 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index beb4cf9..39de2db 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -65,13 +65,7 @@ static char mv643xx_eth_driver_version[] = "1.0";
#define MAX_DESCS_PER_SKB 1
#endif-#define ETH_VLAN_HLEN 4
-#define ETH_FCS_LEN 4
-#define ETH_HW_IP_ALIGN 2 /* hw aligns IP header */
-#define ETH_WRAPPER_LEN (ETH_HW_IP_ALIGN + ETH_HLEN + \
- ETH_VLAN_HLEN + ETH_FCS_LEN)
-#define ETH_RX_SKB_SIZE (dev->mtu + ETH_WRAPPER_LEN + \
- dma_get_cache_alignment())
+#define ETH_HW_IP_ALIGN 2/*
* Registers shared between all ports.
@@ -279,22 +273,32 @@ struct mib_counters {
u32 late_collision;
};+struct rx_queue {
+ int rx_ring_size;
+
+ int rx_desc_count;
+ int rx_curr_desc;
+ int rx_used_desc;
+
+ struct rx_desc *rx_desc_area;
+ dma_addr_t rx_desc_dma;
+ int rx_desc_area_size;
+ struct sk_buff **rx_skb;
+
+ struct timer_list rx_oom;
+};
+
struct mv643xx_eth_private {
struct mv643xx_eth_shared_private *shared;
int port_num; /* User Ethernet port number */struct mv643xx_eth_shared_private *shared_smi;
- u32 rx_sram_addr; /* Base address of rx sram area */
- u32 rx_sram_size; /* Size of rx sram area */
u32 tx_sram_addr; /* Base address of tx sram area */
u32 tx_sram_size; /* Size of tx sram area *//* Tx/Rx rings managment indexes fields. For driver use */
- /* Next available and first returning Rx resource */
- int rx_curr_desc, rx_used_desc;
-
/* Next available and first returning Tx resource */
int tx_curr_desc, tx_used_desc;@@ -302,11 +306,6 @@ struct mv643xx_eth_private {
u32 tx_clean_threshold;
#endif
...
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
As with the multiple RX queue support, allow the platform code to
specify that the hardware we are running on supports multiple TX
queues. This patch only uses the highest-numbered enabled queue
to send packets to for now, this can be extended later to enable
QoS and such.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 146 ++++++++++++++++++++++++++++++-------------
include/linux/mv643xx_eth.h | 3 +-
2 files changed, 105 insertions(+), 44 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 267768c..fd9e492 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -94,16 +94,16 @@ static char mv643xx_eth_driver_version[] = "1.0";
#define INT_EXT_PHY 0x00010000
#define INT_EXT_TX_ERROR_0 0x00000100
#define INT_EXT_TX_0 0x00000001
-#define INT_EXT_TX 0x00000101
+#define INT_EXT_TX 0x0000ffff
#define INT_MASK(p) (0x0468 + ((p) << 10))
#define INT_MASK_EXT(p) (0x046c + ((p) << 10))
#define TX_FIFO_URGENT_THRESHOLD(p) (0x0474 + ((p) << 10))
#define RXQ_CURRENT_DESC_PTR(p, q) (0x060c + ((p) << 10) + ((q) << 4))
#define RXQ_COMMAND(p) (0x0680 + ((p) << 10))
-#define TXQ_CURRENT_DESC_PTR(p) (0x06c0 + ((p) << 10))
-#define TXQ_BW_TOKENS(p) (0x0700 + ((p) << 10))
-#define TXQ_BW_CONF(p) (0x0704 + ((p) << 10))
-#define TXQ_BW_WRR_CONF(p) (0x0708 + ((p) << 10))
+#define TXQ_CURRENT_DESC_PTR(p, q) (0x06c0 + ((p) << 10) + ((q) << 2))
+#define TXQ_BW_TOKENS(p, q) (0x0700 + ((p) << 10) + ((q) << 4))
+#define TXQ_BW_CONF(p, q) (0x0704 + ((p) << 10) + ((q) << 4))
+#define TXQ_BW_WRR_CONF(p, q) (0x0708 + ((p) << 10) + ((q) << 4))
#define MIB_COUNTERS(p) (0x1000 + ((p) << 7))
#define SPECIAL_MCAST_TABLE(p) (0x1400 + ((p) << 10))
#define OTHER_MCAST_TABLE(p) (0x1500 + ((p) << 10))
@@ -294,6 +294,8 @@ struct rx_queue {
};
...
Nuke some Hungarian-esque variable naming conventions:
- p_ prefix for pointers
- _q suffix for variables dealing with rx/tx queue stateSigned-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 156 ++++++++++++++++++++++----------------------
1 files changed, 78 insertions(+), 78 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index cce9686..15a17e2 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -314,21 +314,21 @@ struct mv643xx_eth_private {
/* Tx/Rx rings managment indexes fields. For driver use *//* Next available and first returning Rx resource */
- int rx_curr_desc_q, rx_used_desc_q;
+ int rx_curr_desc, rx_used_desc;/* Next available and first returning Tx resource */
- int tx_curr_desc_q, tx_used_desc_q;
+ int tx_curr_desc, tx_used_desc;#ifdef MV643XX_ETH_TX_FAST_REFILL
u32 tx_clean_threshold;
#endif- struct rx_desc *p_rx_desc_area;
+ struct rx_desc *rx_desc_area;
dma_addr_t rx_desc_dma;
int rx_desc_area_size;
struct sk_buff **rx_skb;- struct tx_desc *p_tx_desc_area;
+ struct tx_desc *tx_desc_area;
dma_addr_t tx_desc_dma;
int tx_desc_area_size;
struct sk_buff **tx_skb;
@@ -435,31 +435,31 @@ static unsigned int mv643xx_eth_port_disable_tx(struct mv643xx_eth_private *mep)
static void mv643xx_eth_free_completed_tx_descs(struct net_device *dev);static FUNC_RET_STATUS rx_return_buff(struct mv643xx_eth_private *mep,
- struct pkt_info *p_pkt_info)
+ struct pkt_info *pkt_info)
{
int used_rx_desc; /* Where to return Rx resource */
- volatile struct rx_desc *p_used_rx_desc;
+ volatile struct rx_desc *rx_desc;
unsigned long flags;spin_lock_irqsave(&mep->lock, flags);
/* Get 'used' Rx descriptor */
- used_rx_desc = mep->rx_used_desc_q;
- p_used_rx_desc = &mep->p_rx_desc_area[used_rx_desc];
+ used_rx_desc = mep->rx_used_desc;
+ rx_desc = &mep->rx_desc_area[used_rx_desc];...
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Remove the write-only ->[rt]x_int_coal members from struct
mv643xx_eth_private. In the process, tweak the RX/TX interrupt
mitigation code so that it is compiled by default, and set the
default coalescing delays to 0 usec.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 29 ++++-------------------------
1 files changed, 4 insertions(+), 25 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index beeadcf..ef1c461 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -52,12 +52,6 @@ static char mv643xx_eth_driver_version[] = "1.0";
#define MV643XX_ETH_CHECKSUM_OFFLOAD_TX
#define MV643XX_ETH_NAPI
#define MV643XX_ETH_TX_FAST_REFILL
-#undef MV643XX_ETH_COAL
-
-#define MV643XX_ETH_TX_COAL 100
-#ifdef MV643XX_ETH_COAL
-#define MV643XX_ETH_RX_COAL 100
-#endif#ifdef MV643XX_ETH_CHECKSUM_OFFLOAD_TX
#define MAX_DESCS_PER_SKB (MAX_SKB_FRAGS + 1)
@@ -313,8 +307,6 @@ struct mv643xx_eth_private {
struct mib_counters mib_counters;
spinlock_t lock;- u32 rx_int_coal;
- u32 tx_int_coal;
struct mii_if_info mii;/*
@@ -1672,9 +1664,7 @@ static void port_start(struct net_device *dev)
}
}-#ifdef MV643XX_ETH_COAL
-static unsigned int set_rx_coal(struct mv643xx_eth_private *mep,
- unsigned int delay)
+static void set_rx_coal(struct mv643xx_eth_private *mep, unsigned int delay)
{
unsigned int port_num = mep->port_num;
unsigned int coal = ((mep->shared->t_clk / 1000000) * delay) / 64;
@@ -1684,20 +1674,14 @@ static unsigned int set_rx_coal(struct mv643xx_eth_private *mep,
((coal & 0x3fff) << 8) |
(rdl(mep, SDMA_CONFIG(port_num))
& 0xffc000ff));
-
- return coal;
}
-#endif-static unsigned int set_tx_coal(struct mv643xx_eth_private *mep,
- unsigned int delay)
+static void set_tx_coal(struct mv643xx_eth_private *mep, unsigned int delay)
{
unsigned int coal = ((mep->shared->t_clk / 1000000) * delay) /...
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
rx_return_buff() is also a remnant of the HAL layering that the
original mv643xx_eth driver used. Moving it into its caller kills
the last reference to FUNC_RET_STATUS/pkt_info.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 80 ++++++++++++++++-----------------------------
1 files changed, 28 insertions(+), 52 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 2fac2b6..a54c342 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -434,74 +434,50 @@ static unsigned int mv643xx_eth_port_disable_tx(struct mv643xx_eth_private *mep)
/* rx ***********************************************************************/
static void mv643xx_eth_free_completed_tx_descs(struct net_device *dev);-static FUNC_RET_STATUS rx_return_buff(struct mv643xx_eth_private *mep,
- struct pkt_info *pkt_info)
+static void mv643xx_eth_rx_refill_descs(struct net_device *dev)
{
- int used_rx_desc; /* Where to return Rx resource */
- volatile struct rx_desc *rx_desc;
+ struct mv643xx_eth_private *mep = netdev_priv(dev);
unsigned long flags;spin_lock_irqsave(&mep->lock, flags);
- /* Get 'used' Rx descriptor */
- used_rx_desc = mep->rx_used_desc;
- rx_desc = &mep->rx_desc_area[used_rx_desc];
-
- rx_desc->buf_ptr = pkt_info->buf_ptr;
- rx_desc->buf_size = pkt_info->byte_cnt;
- mep->rx_skb[used_rx_desc] = pkt_info->return_info;
-
- /* Flush the write pipe */
-
- /* Return the descriptor to DMA ownership */
- wmb();
- rx_desc->cmd_sts = BUFFER_OWNED_BY_DMA | RX_ENABLE_INTERRUPT;
- wmb();
-
- /* Move the used descriptor pointer to the next descriptor */
- mep->rx_used_desc = (used_rx_desc + 1) % mep->rx_ring_size;
-
- spin_unlock_irqrestore(&mep->lock, flags);
-
- return ETH_OK;
-}
-
-static void mv643xx_eth_rx_refill_descs(struct net_device *dev)
-{
- struct mv643xx_eth_private *mep = netdev_priv(dev);
- struct pkt_info pkt_inf...
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Newer hardware has a 16-bit instead of a 14-bit RX coalescing
count field in the SDMA_CONFIG register. This patch adds a run-time
check for which of the two we have, and adjusts further writes to the
rx coal count field accordingly.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 38 +++++++++++++++++++++++++++++++-------
1 files changed, 31 insertions(+), 7 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 8e4ca2b..4168a8a 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -240,6 +240,7 @@ struct mv643xx_eth_shared_private {
* Hardware-specific parameters.
*/
unsigned int t_clk;
+ int extended_rx_coal_limit;
};@@ -1796,14 +1797,22 @@ static void port_start(struct mv643xx_eth_private *mep)
static void set_rx_coal(struct mv643xx_eth_private *mep, unsigned int delay)
{
unsigned int coal = ((mep->shared->t_clk / 1000000) * delay) / 64;
+ u32 val;- if (coal > 0x3fff)
- coal = 0x3fff;
-
- wrl(mep, SDMA_CONFIG(mep->port_num),
- ((coal & 0x3fff) << 8) |
- (rdl(mep, SDMA_CONFIG(mep->port_num))
- & 0xffc000ff));
+ val = rdl(mep, SDMA_CONFIG(mep->port_num));
+ if (mep->shared->extended_rx_coal_limit) {
+ if (coal > 0xffff)
+ coal = 0xffff;
+ val &= ~0x023fff80;
+ val |= (coal & 0x8000) << 10;
+ val |= (coal & 0x7fff) << 7;
+ } else {
+ if (coal > 0x3fff)
+ coal = 0x3fff;
+ val &= ~0x003fff00;
+ val |= (coal & 0x3fff) << 8;
+ }
+ wrl(mep, SDMA_CONFIG(mep->port_num), val);
}static void set_tx_coal(struct mv643xx_eth_private *mep, unsigned int delay)
@@ -2068,6 +2077,20 @@ mv643xx_eth_conf_mbus_windows(struct mv643xx_eth_shared_private *mesp,
mesp->win_protect = win_protect;
}+static void infer_hw_params(struct mv643xx_eth_shared_private *mesp)
+{
+ /*
+ * Check whether we have a 14-bit coal limit field in bits
+ * [21:8], ...
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Under some conditions, the TXQ ('TX queue being served') bit can clear
before all packets queued for that TX queue have been transmitted.
This patch enables TXend interrupts, and uses those to re-kick TX
queues that claim to be idle but still have queued descriptors from
the interrupt handler.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 35 ++++++++++++++++++++++++++++++-----
1 files changed, 30 insertions(+), 5 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index fd9e492..8e4ca2b 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -87,6 +87,7 @@ static char mv643xx_eth_driver_version[] = "1.0";
#define TX_BW_MTU(p) (0x0458 + ((p) << 10))
#define TX_BW_BURST(p) (0x045c + ((p) << 10))
#define INT_CAUSE(p) (0x0460 + ((p) << 10))
+#define INT_TX_END 0x07f80000
#define INT_RX 0x0007fbfc
#define INT_EXT 0x00000002
#define INT_CAUSE_EXT(p) (0x0464 + ((p) << 10))
@@ -601,7 +602,7 @@ static int mv643xx_eth_poll(struct napi_struct *napi, int budget)
netif_rx_complete(mep->dev, napi);
wrl(mep, INT_CAUSE(mep->port_num), 0);
wrl(mep, INT_CAUSE_EXT(mep->port_num), 0);
- wrl(mep, INT_MASK(mep->port_num), INT_RX | INT_EXT);
+ wrl(mep, INT_MASK(mep->port_num), INT_TX_END | INT_RX | INT_EXT);
}return rx;
@@ -1603,8 +1604,10 @@ static irqreturn_t mv643xx_eth_irq(int irq, void *dev_id)
struct mv643xx_eth_private *mep = netdev_priv(dev);
u32 int_cause;
u32 int_cause_ext;
+ u32 txq_active;- int_cause = rdl(mep, INT_CAUSE(mep->port_num)) & (INT_RX | INT_EXT);
+ int_cause = rdl(mep, INT_CAUSE(mep->port_num)) &
+ (INT_TX_END | INT_RX | INT_EXT);
if (int_cause == 0)
return IRQ_NONE;@@ -1656,6 +1659,8 @@ static irqreturn_t mv643xx_eth_irq(int irq, void *dev_id)
}
#endif+ txq_active = rdl(mep, TXQ_COMMAND(mep->port_num));
+
/*
* TxBuffer or TxError set for a...
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Some SoCs have the TX bandwidth control registers in a slightly
different place. This patch detects that case at run time, and
re-directs accesses to those registers to the proper place at
run time if needed.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 37 ++++++++++++++++++++++++++++++++-----
1 files changed, 32 insertions(+), 5 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 4168a8a..a7c5421 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -99,6 +99,10 @@ static char mv643xx_eth_driver_version[] = "1.0";
#define INT_MASK(p) (0x0468 + ((p) << 10))
#define INT_MASK_EXT(p) (0x046c + ((p) << 10))
#define TX_FIFO_URGENT_THRESHOLD(p) (0x0474 + ((p) << 10))
+#define TXQ_FIX_PRIO_CONF_MOVED(p) (0x04dc + ((p) << 10))
+#define TX_BW_RATE_MOVED(p) (0x04e0 + ((p) << 10))
+#define TX_BW_MTU_MOVED(p) (0x04e8 + ((p) << 10))
+#define TX_BW_BURST_MOVED(p) (0x04ec + ((p) << 10))
#define RXQ_CURRENT_DESC_PTR(p, q) (0x060c + ((p) << 10) + ((q) << 4))
#define RXQ_COMMAND(p) (0x0680 + ((p) << 10))
#define TXQ_CURRENT_DESC_PTR(p, q) (0x06c0 + ((p) << 10) + ((q) << 2))
@@ -241,6 +245,7 @@ struct mv643xx_eth_shared_private {
*/
unsigned int t_clk;
int extended_rx_coal_limit;
+ int tx_bw_control_moved;
};@@ -813,9 +818,15 @@ static void tx_set_rate(struct mv643xx_eth_private *mep, int rate, int burst)
if (bucket_size > 65535)
bucket_size = 65535;- wrl(mep, TX_BW_RATE(mep->port_num), token_rate);
- wrl(mep, TX_BW_MTU(mep->port_num), mtu);
- wrl(mep, TX_BW_BURST(mep->port_num), bucket_size);
+ if (mep->shared->tx_bw_control_moved) {
+ wrl(mep, TX_BW_RATE_MOVED(mep->port_num), token_rate);
+ wrl(mep, TX_BW_MTU_MOVED(mep->port_num), mtu);
+ wrl(mep, TX_BW_BURST_MOVED(mep->port_num), bucket_size);
+ } else {
+ wrl(mep, TX_BW_RATE(mep->port_nu...
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
The port_receive() function is a remnant of the original mv643xx_eth
HAL split. This patch moves port_receive() into its caller, so that
the top and the bottom half of RX processing no longer communicate
via the HAL FUNC_RET_STATUS/pkt_info mechanism abstraction anymore.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 91 ++++++++++++++++-----------------------------
1 files changed, 32 insertions(+), 59 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 15a17e2..2fac2b6 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -509,64 +509,38 @@ static inline void mv643xx_eth_rx_refill_descs_timer_wrapper(unsigned long data)
mv643xx_eth_rx_refill_descs((struct net_device *)data);
}-static FUNC_RET_STATUS port_receive(struct mv643xx_eth_private *mep,
- struct pkt_info *pkt_info)
+static int mv643xx_eth_receive_queue(struct net_device *dev, int budget)
{
- int rx_next_curr_desc, rx_curr_desc, rx_used_desc;
- volatile struct rx_desc *rx_desc;
- unsigned int command_status;
- unsigned long flags;
-
- spin_lock_irqsave(&mep->lock, flags);
-
- /* Get the Rx Desc ring 'curr and 'used' indexes */
- rx_curr_desc = mep->rx_curr_desc;
- rx_used_desc = mep->rx_used_desc;
-
- rx_desc = &mep->rx_desc_area[rx_curr_desc];
-
- /* The following parameters are used to save readings from memory */
- command_status = rx_desc->cmd_sts;
- rmb();
+ struct mv643xx_eth_private *mep = netdev_priv(dev);
+ struct net_device_stats *stats = &dev->stats;
+ unsigned int received_packets = 0;- /* Nothing to receive... */
- if (command_status & BUFFER_OWNED_BY_DMA) {
- spin_unlock_irqrestore(&mep->lock, flags);
- return ETH_END_OF_JOB;
- }
+ while (budget-- > 0) {
+ struct sk_buff *skb;
+ volatile struct rx_desc *rx_desc;
+ unsigned int cmd_sts;
+ unsigned long flags;- pkt_info->byte_cnt = rx_desc->byte_cnt - ETH_HW_IP_AL...
Hooray!
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
The per-port mv643xx_eth_private struct had a private instance
of struct net_device_stats that was never ever written to, only
read (via the ethtool statistics interface). This patch gets
rid of the private instance, and tweaks the ethtool statistics
code in mv643xx_eth to use the statistics in struct net_device
instead.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 120 +++++++++++++++++++++++++--------------------
1 files changed, 66 insertions(+), 54 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index d68780a..b3be8fe 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -316,7 +316,6 @@ struct mv643xx_eth_private {struct net_device *dev;
struct napi_struct napi;
- struct net_device_stats stats;
struct mib_counters mib_counters;
spinlock_t lock;
/* Size of Tx Ring per queue */
@@ -876,55 +875,59 @@ static void update_mib_counters(struct mv643xx_eth_private *mep)
struct mv643xx_eth_stats {
char stat_string[ETH_GSTRING_LEN];
int sizeof_stat;
- int stat_offset;
+ int netdev_off;
+ int mep_off;
};-#define MV643XX_ETH_STAT(m) FIELD_SIZEOF(struct mv643xx_eth_private, m), \
- offsetof(struct mv643xx_eth_private, m)
-
-static const struct mv643xx_eth_stats mv643xx_eth_gstrings_stats[] = {
- { "rx_packets", MV643XX_ETH_STAT(stats.rx_packets) },
- { "tx_packets", MV643XX_ETH_STAT(stats.tx_packets) },
- { "rx_bytes", MV643XX_ETH_STAT(stats.rx_bytes) },
- { "tx_bytes", MV643XX_ETH_STAT(stats.tx_bytes) },
- { "rx_errors", MV643XX_ETH_STAT(stats.rx_errors) },
- { "tx_errors", MV643XX_ETH_STAT(stats.tx_errors) },
- { "rx_dropped", MV643XX_ETH_STAT(stats.rx_dropped) },
- { "tx_dropped", MV643XX_ETH_STAT(stats.tx_dropped) },
- { "good_octets_received", MV643XX_ETH_STAT(mib_counters.good_octets_received) },
- { "bad_octets_received", MV643XX_ETH_STAT(mib_counters.bad_octets_received) },
- { "internal_mac_transmit_err", MV643XX_ETH_STAT(mib_counters.int...
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Since they are no longer used, kill enum FUNC_RET_STATUS and
struct pkt_info (which were a rather roundabout way of communicating
RX/TX status within the same driver).Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 21 ---------------------
1 files changed, 0 insertions(+), 21 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index a54c342..d68780a 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -167,16 +167,6 @@ static char mv643xx_eth_driver_version[] = "1.0";
#define SMI_OPCODE_WRITE 0 /* Completion of Read */
#define SMI_OPCODE_READ 0x04000000 /* Operation is in progress */-/* typedefs */
-
-typedef enum _func_ret_status {
- ETH_OK, /* Returned as expected. */
- ETH_ERROR, /* Fundamental error. */
- ETH_RETRY, /* Could not process request. Try later.*/
- ETH_END_OF_JOB, /* Ring has nothing to process. */
- ETH_QUEUE_FULL, /* Ring resource error. */
- ETH_QUEUE_LAST_RESOURCE /* Ring resources about to exhaust. */
-} FUNC_RET_STATUS;/*
* RX/TX descriptors.
@@ -242,17 +232,6 @@ struct tx_desc {
#define TX_IHL_SHIFT 11-/* Unified struct for Rx and Tx operations. The user is not required to */
-/* be familier with neither Tx nor Rx descriptors. */
-struct pkt_info {
- unsigned short byte_cnt; /* Descriptor buffer byte count */
- unsigned short l4i_chk; /* Tx CPU provided TCP Checksum */
- unsigned int cmd_sts; /* Descriptor command status */
- dma_addr_t buf_ptr; /* Descriptor buffer pointer */
- struct sk_buff *return_info; /* User resource return information */
-};
-
-
/* global *******************************************************************/
struct mv643xx_eth_shared_private {
void __iomem *base;
--
1.5.3.4--
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Add an interface for the hardware's per-port and per-subqueue
TX rate control. In this stage, this is mainly so that we can
disable the bandwidth limits during initialisation of the port.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 104 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 103 insertions(+), 1 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index ff31cd8..24426fc 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -82,7 +82,10 @@ static char mv643xx_eth_driver_version[] = "1.0";
#define PORT_STATUS(p) (0x0444 + ((p) << 10))
#define TX_FIFO_EMPTY 0x00000400
#define TXQ_COMMAND(p) (0x0448 + ((p) << 10))
+#define TXQ_FIX_PRIO_CONF(p) (0x044c + ((p) << 10))
+#define TX_BW_RATE(p) (0x0450 + ((p) << 10))
#define TX_BW_MTU(p) (0x0458 + ((p) << 10))
+#define TX_BW_BURST(p) (0x045c + ((p) << 10))
#define INT_CAUSE(p) (0x0460 + ((p) << 10))
#define INT_RX 0x00000804
#define INT_EXT 0x00000002
@@ -98,6 +101,9 @@ static char mv643xx_eth_driver_version[] = "1.0";
#define RXQ_CURRENT_DESC_PTR(p) (0x060c + ((p) << 10))
#define RXQ_COMMAND(p) (0x0680 + ((p) << 10))
#define TXQ_CURRENT_DESC_PTR(p) (0x06c0 + ((p) << 10))
+#define TXQ_BW_TOKENS(p) (0x0700 + ((p) << 10))
+#define TXQ_BW_CONF(p) (0x0704 + ((p) << 10))
+#define TXQ_BW_WRR_CONF(p) (0x0708 + ((p) << 10))
#define MIB_COUNTERS(p) (0x1000 + ((p) << 7))
#define SPECIAL_MCAST_TABLE(p) (0x1400 + ((p) << 10))
#define OTHER_MCAST_TABLE(p) (0x1500 + ((p) << 10))
@@ -757,6 +763,95 @@ static int mv643xx_eth_xmit(struct sk_buff *skb, struct net_device *dev)
}+/* tx rate control **********************************************************/
+/*
+ * Set total maximum TX rate (shared by all TX queues for this port)
+ * to 'rate' bits per second, with a maximum burst of...
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Replace the 70-line crc8 computation (used for multicast address
filtering tables) by a 5-line version.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 95 ++++++++++-----------------------------------
1 files changed, 21 insertions(+), 74 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index b3be8fe..beb4cf9 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -1132,16 +1132,29 @@ static int mv643xx_eth_set_mac_address(struct net_device *dev, void *addr)
return 0;
}+static int addr_crc(unsigned char *addr)
+{
+ int crc = 0;
+ int i;
+
+ for (i = 0; i < 6; i++) {
+ int j;
+
+ crc = (crc ^ addr[i]) << 8;
+ for (j = 7; j >= 0; j--) {
+ if (crc & (0x100 << j))
+ crc ^= 0x107 << j;
+ }
+ }
+
+ return crc;
+}
+
static void mc_addr(struct mv643xx_eth_private *mep, unsigned char *addr)
{
unsigned int port_num = mep->port_num;
- unsigned int mac_h;
- unsigned int mac_l;
- unsigned char crc_result = 0;
int table;
- int mac_array[48];
- int crc[8];
- int i;
+ int crc;if ((addr[0] == 0x01) && (addr[1] == 0x00) &&
(addr[2] == 0x5E) && (addr[3] == 0x00) && (addr[4] == 0x00)) {
@@ -1150,76 +1163,10 @@ static void mc_addr(struct mv643xx_eth_private *mep, unsigned char *addr)
return;
}- /* Calculate CRC-8 out of the given address */
- mac_h = (addr[0] << 8) | (addr[1]);
- mac_l = (addr[2] << 24) | (addr[3] << 16) |
- (addr[4] << 8) | (addr[5] << 0);
-
- for (i = 0; i < 32; i++)
- mac_array[i] = (mac_l >> i) & 0x1;
- for (i = 32; i < 48; i++)
- mac_array[i] = (mac_h >> (i - 32)) & 0x1;
-
- crc[0] = mac_array[45] ^ mac_array[43] ^ mac_array[40] ^ mac_array[39] ^
- mac_array[35] ^ mac_array[34] ^ mac_array[31] ^ mac_array[30] ^
- mac_array[28] ^ mac_array[23] ^ mac_array[21] ^ mac_array[19] ^
- mac_ar...
The original looks like someone ported Verilog code to C.
--
E.g. the EASICS crc web tool (http://www.easics.com/webtools/crctool)
gives you pretty much that same code. :-)I.e.:
NewCRC[0] = D[45] ^ D[43] ^ D[40] ^ D[39] ^ D[35] ^ D[34] ^ D[31] ^
D[30] ^ D[28] ^ D[23] ^ D[21] ^ D[19] ^ D[18] ^ D[16] ^
D[14] ^ D[12] ^ D[8] ^ D[7] ^ D[6] ^ D[0] ^ C[0] ^
C[3] ^ C[5];
NewCRC[1] = D[46] ^ D[45] ^ D[44] ^ D[43] ^ D[41] ^ D[39] ^ D[36] ^
D[34] ^ D[32] ^ D[30] ^ D[29] ^ D[28] ^ D[24] ^ D[23] ^
D[22] ^ D[21] ^ D[20] ^ D[18] ^ D[17] ^ D[16] ^ D[15] ^
D[14] ^ D[13] ^ D[12] ^ D[9] ^ D[6] ^ D[1] ^ D[0] ^
C[1] ^ C[3] ^ C[4] ^ C[5] ^ C[6];versus mv643xx_eth's:
- crc[0] = mac_array[45] ^ mac_array[43] ^ mac_array[40] ^ mac_array[39] ^
- mac_array[35] ^ mac_array[34] ^ mac_array[31] ^ mac_array[30] ^
- mac_array[28] ^ mac_array[23] ^ mac_array[21] ^ mac_array[19] ^
- mac_array[18] ^ mac_array[16] ^ mac_array[14] ^ mac_array[12] ^
- mac_array[8] ^ mac_array[7] ^ mac_array[6] ^ mac_array[0];
-
- crc[1] = mac_array[46] ^ mac_array[45] ^ mac_array[44] ^ mac_array[43] ^
- mac_array[41] ^ mac_array[39] ^ mac_array[36] ^ mac_array[34] ^
- mac_array[32] ^ mac_array[30] ^ mac_array[29] ^ mac_array[28] ^
- mac_array[24] ^ mac_array[23] ^ mac_array[22] ^ mac_array[21] ^
- mac_array[20] ^ mac_array[18] ^ mac_array[17] ^ mac_array[16] ^
- mac_array[15] ^ mac_array[14] ^ mac_array[13] ^ mac_array[12] ^
- mac_array[9] ^ mac_array[6] ^ mac_array[1] ^ mac_array[0];
--
Wow!
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
During OOM, instead of stopping RX refill when the rx desc ring is
not empty, keep trying to refill the ring as long as it is not full
instead.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index a7c5421..0f8e79f 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -475,7 +475,7 @@ static void rxq_refill(struct rx_queue *rxq)
skb_reserve(skb, 2);
}- if (rxq->rx_desc_count == 0) {
+ if (rxq->rx_desc_count != rxq->rx_ring_size) {
rxq->rx_oom.expires = jiffies + (HZ / 10);
add_timer(&rxq->rx_oom);
}
--
1.5.3.4--
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
I'd add a comment referring to the weird behavior. Also, aren't
C++-style comments discouraged?-Dale
--
ACK. Let me pull out this patch for now and come up with a better one.
--
Remove the unused rx/tx descriptor field defines, and move the ones
that are actually used to the actual definitions of the rx/tx
descriptor format.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 82 +++++++++++++++-----------------------------
1 files changed, 28 insertions(+), 54 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 34bfdf6..ea1af64 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -167,57 +167,6 @@ static char mv643xx_driver_version[] = "1.0";
#define ETH_SMI_OPCODE_WRITE 0 /* Completion of Read */
#define ETH_SMI_OPCODE_READ 0x04000000 /* Operation is in progress */-/* Interrupt Cause Register Bit Definitions */
-
-/* SDMA command status fields macros */
-
-/* Tx & Rx descriptors status */
-#define ETH_ERROR_SUMMARY 0x00000001
-
-/* Tx & Rx descriptors command */
-#define ETH_BUFFER_OWNED_BY_DMA 0x80000000
-
-/* Tx descriptors status */
-#define ETH_LC_ERROR 0
-#define ETH_UR_ERROR 0x00000002
-#define ETH_RL_ERROR 0x00000004
-#define ETH_LLC_SNAP_FORMAT 0x00000200
-
-/* Rx descriptors status */
-#define ETH_OVERRUN_ERROR 0x00000002
-#define ETH_MAX_FRAME_LENGTH_ERROR 0x00000004
-#define ETH_RESOURCE_ERROR 0x00000006
-#define ETH_VLAN_TAGGED 0x00080000
-#define ETH_BPDU_FRAME 0x00100000
-#define ETH_UDP_FRAME_OVER_IP_V_4 0x00200000
-#define ETH_OTHER_FRAME_TYPE 0x00400000
-#define ETH_LAYER_2_IS_ETH_V_2 0x00800000
-#define ETH_FRAME_TYPE_IP_V_4 0x01000000
-#define ETH_FRAME_HEADER_OK 0x02000000
-#define ETH_RX_LAST_DESC 0x04000000
-#define ETH_RX_FIRST_DESC 0x08000000
-#define ETH_UNKNOWN_DESTINATION_ADDR 0x10000000
-#define ETH_RX_ENABLE_INTERRUPT 0x20000000
-#define ETH_LAYER_4_CHECKSUM_OK 0x40000000
-
-/* Rx descriptors byte count */
-#define ETH_FRAME_FRAGMENTED 0x00000004
-
-/* Tx descriptors command */
-#define ETH_LAYER_4_CHECKSUM_FIRST_DESC 0x00000400
-#define ETH_FR...
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Delete the defines for SDMA config register bit values that are
never used in the driver, to tidy up the code some more.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 21 ++++-----------------
1 files changed, 4 insertions(+), 17 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 210e7cc..8287cf0 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -109,37 +109,24 @@ static char mv643xx_driver_version[] = "1.0";
#define OTHER_MCAST_TABLE(p) (0x1500 + ((p) << 10))
#define UNICAST_TABLE(p) (0x1600 + ((p) << 10))-/* These macros describe Ethernet Port Sdma configuration reg (SDCR) bits */
-#define RIFB (1 << 0)
-#define RX_BURST_SIZE_1_64BIT (0 << 1)
-#define RX_BURST_SIZE_2_64BIT (1 << 1)
+
+/*
+ * SDMA configuration register.
+ */
#define RX_BURST_SIZE_4_64BIT (2 << 1)
-#define RX_BURST_SIZE_8_64BIT (3 << 1)
-#define RX_BURST_SIZE_16_64BIT (4 << 1)
#define BLM_RX_NO_SWAP (1 << 4)
-#define BLM_RX_BYTE_SWAP (0 << 4)
#define BLM_TX_NO_SWAP (1 << 5)
-#define BLM_TX_BYTE_SWAP (0 << 5)
-#define DESCRIPTORS_BYTE_SWAP (1 << 6)
-#define DESCRIPTORS_NO_SWAP (0 << 6)
-#define IPG_INT_RX(value) (((value) & 0x3fff) << 8)
-#define TX_BURST_SIZE_1_64BIT (0 << 22)
-#define TX_BURST_SIZE_2_64BIT (1 << 22)
#define TX_BURST_SIZE_4_64BIT (2 << 22)
-#define TX_BURST_SIZE_8_64BIT (3 << 22)
-#define TX_BURST_SIZE_16_64BIT (4 << 22)#if defined(__BIG_ENDIAN)
#define PORT_SDMA_CONFIG_DEFAULT_VALUE \
RX_BURST_SIZE_4_64BIT | \
- IPG_INT_RX(0) | \
TX_BURST_SIZE_4_64BIT
#elif defined(__LITTLE_ENDIAN)
#define PORT_SDMA_CONFIG_DEFAULT_VALUE \
RX_BURST_SIZE_4_64BIT | \
BLM_RX_NO_SWAP | \
BLM_TX_NO_SWAP | \
- IPG_INT_RX(0) | \
TX_BURST_SIZE_4_64BIT
#else
#error One of __BIG_ENDIAN or __LITTLE_ENDIAN m...
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
--
All except one of the port serial status register bit defines are
unused -- kill the unused ones.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 15 ++-------------
1 files changed, 2 insertions(+), 13 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 075ee2a..34bfdf6 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -94,6 +94,7 @@ static char mv643xx_driver_version[] = "1.0";
#define SDMA_CONFIG(p) (0x041c + ((p) << 10))
#define PORT_SERIAL_CONTROL(p) (0x043c + ((p) << 10))
#define PORT_STATUS(p) (0x0444 + ((p) << 10))
+#define TX_FIFO_EMPTY 0x00000400
#define TXQ_COMMAND(p) (0x0448 + ((p) << 10))
#define TX_BW_MTU(p) (0x0458 + ((p) << 10))
#define INT_CAUSE(p) (0x0460 + ((p) << 10))
@@ -160,18 +161,6 @@ static char mv643xx_driver_version[] = "1.0";
#define PORT_DEFAULT_TRANSMIT_QUEUE_SIZE 800
#define PORT_DEFAULT_RECEIVE_QUEUE_SIZE 400-/* Port serial status reg (PSR) */
-#define ETH_INTERFACE_PCM 0x00000001
-#define ETH_LINK_IS_UP 0x00000002
-#define ETH_PORT_AT_FULL_DUPLEX 0x00000004
-#define ETH_RX_FLOW_CTRL_ENABLED 0x00000008
-#define ETH_GMII_SPEED_1000 0x00000010
-#define ETH_MII_SPEED_100 0x00000020
-#define ETH_TX_IN_PROGRESS 0x00000080
-#define ETH_BYPASS_ACTIVE 0x00000100
-#define ETH_PORT_AT_PARTITION_STATE 0x00000200
-#define ETH_PORT_TX_FIFO_EMPTY 0x00000400
-
/* SMI reg */
#define ETH_SMI_BUSY 0x10000000 /* 0 - Write, 1 - Read */
#define ETH_SMI_READ_VALID 0x08000000 /* 0 - Write, 1 - Read */
@@ -462,7 +451,7 @@ static unsigned int mv643xx_eth_port_disable_tx(struct mv643xx_private *mp)
udelay(10);/* Wait for Tx FIFO to empty */
- while (rdl(mp, PORT_STATUS(port_num)) & ETH_PORT_TX_FIFO_EMPTY)
+ while (rdl(mp, PORT_STATUS(port_num)) & TX_FIFO_EMPTY)
udelay(10);
}--
1.5.3.4--
[snip]
Looks good otherwise.
-Dale
--
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
Over half of the port serial control register bit defines are never
used, and the PORT_SERIAL_CONTROL_DEFAULT_VALUE define is never used
either. Keep only those defines that are actually used.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 78 +++++++++------------------------------------
1 files changed, 15 insertions(+), 63 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 8287cf0..e4f0189 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -132,71 +132,23 @@ static char mv643xx_driver_version[] = "1.0";
#error One of __BIG_ENDIAN or __LITTLE_ENDIAN must be defined
#endif-/* These macros describe Ethernet Port serial control reg (PSCR) bits */
-#define SERIAL_PORT_DISABLE (0 << 0)
-#define SERIAL_PORT_ENABLE (1 << 0)
-#define DO_NOT_FORCE_LINK_PASS (0 << 1)
-#define FORCE_LINK_PASS (1 << 1)
-#define ENABLE_AUTO_NEG_FOR_DUPLX (0 << 2)
-#define DISABLE_AUTO_NEG_FOR_DUPLX (1 << 2)
-#define ENABLE_AUTO_NEG_FOR_FLOW_CTRL (0 << 3)
-#define DISABLE_AUTO_NEG_FOR_FLOW_CTRL (1 << 3)
-#define ADV_NO_FLOW_CTRL (0 << 4)
-#define ADV_SYMMETRIC_FLOW_CTRL (1 << 4)
-#define FORCE_FC_MODE_NO_PAUSE_DIS_TX (0 << 5)
-#define FORCE_FC_MODE_TX_PAUSE_DIS (1 << 5)
-#define FORCE_BP_MODE_NO_JAM (0 << 7)
-#define FORCE_BP_MODE_JAM_TX (1 << 7)
-#define FORCE_BP_MODE_JAM_TX_ON_RX_ERR (2 << 7)
-#define SERIAL_PORT_CONTROL_RESERVED (1 << 9)
-#define FORCE_LINK_FAIL (0 << 10)
-#define DO_NOT_FORCE_LINK_FAIL (1 << 10)
-#define RETRANSMIT_16_ATTEMPTS (0 << 11)
-#define RETRANSMIT_FOREVER (1 << 11)
-#define ENABLE_AUTO_NEG_SPEED_GMII (0 << 13)
-#define DISABLE_AUTO_NEG_SPEED_GMII (1 << 13)
-#define DTE_ADV_0 (0 << 14)
-#define DTE_ADV_1 (1 << 14)
-#define DISABLE_AUTO_NEG_BYPASS (0 << 15)
-#define EN...
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
The port config extend register is never changed at run time.
Document the meaning of the initial value, and delete the defines
for the individual bits in this register.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 16 ++++------------
1 files changed, 4 insertions(+), 12 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 38ba365..210e7cc 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -109,17 +109,6 @@ static char mv643xx_driver_version[] = "1.0";
#define OTHER_MCAST_TABLE(p) (0x1500 + ((p) << 10))
#define UNICAST_TABLE(p) (0x1600 + ((p) << 10))-/* These macros describe Ethernet Port configuration extend reg (Px_cXR) bits*/
-#define CLASSIFY_EN (1 << 0)
-#define SPAN_BPDU_PACKETS_AS_NORMAL (0 << 1)
-#define SPAN_BPDU_PACKETS_TO_RX_QUEUE_7 (1 << 1)
-#define PARTITION_DISABLE (0 << 2)
-#define PARTITION_ENABLE (1 << 2)
-
-#define PORT_CONFIG_EXTEND_DEFAULT_VALUE \
- SPAN_BPDU_PACKETS_AS_NORMAL | \
- PARTITION_DISABLE
-
/* These macros describe Ethernet Port Sdma configuration reg (SDCR) bits */
#define RIFB (1 << 0)
#define RX_BURST_SIZE_1_64BIT (0 << 1)
@@ -2199,7 +2188,10 @@ static void eth_port_start(struct net_device *dev)
*/
wrl(mp, PORT_CONFIG(port_num), 0x00000000);- wrl(mp, PORT_CONFIG_EXT(port_num), PORT_CONFIG_EXTEND_DEFAULT_VALUE);
+ /*
+ * Treat BPDUs as normal multicasts, and disable partition mode.
+ */
+ wrl(mp, PORT_CONFIG_EXT(port_num), 0x00000000);pscr = rdl(mp, PORT_SERIAL_CONTROL(port_num));
--
1.5.3.4--
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
--
None of the port status register bit defines are ever used in the
mv643xx_eth driver -- nuke them all.Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
---
drivers/net/mv643xx_eth.c | 14 --------------
1 files changed, 0 insertions(+), 14 deletions(-)diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index e4f0189..4b61acc 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -150,20 +150,6 @@ static char mv643xx_driver_version[] = "1.0";
#define FORCE_LINK_PASS (1 << 1)
#define SERIAL_PORT_ENABLE (1 << 0)-/* These macros describe Ethernet Serial Status reg (PSR) bits */
-#define PORT_STATUS_MODE_10_BIT (1 << 0)
-#define PORT_STATUS_LINK_UP (1 << 1)
-#define PORT_STATUS_FULL_DUPLEX (1 << 2)
-#define PORT_STATUS_FLOW_CONTROL (1 << 3)
-#define PORT_STATUS_GMII_1000 (1 << 4)
-#define PORT_STATUS_MII_100 (1 << 5)
-/* PSR bit 6 is undocumented */
-#define PORT_STATUS_TX_IN_PROGRESS (1 << 7)
-#define PORT_STATUS_AUTONEG_BYPASSED (1 << 8)
-#define PORT_STATUS_PARTITION (1 << 9)
-#define PORT_STATUS_TX_FIFO_EMPTY (1 << 10)
-/* PSR bits 11-31 are reserved */
-
#define PORT_DEFAULT_TRANSMIT_QUEUE_SIZE 800
#define PORT_DEFAULT_RECEIVE_QUEUE_SIZE 400--
1.5.3.4--
Acked-by: Dale Farnsworth <dale@farnsworth.org>
--
| Amit K. Arora | [RFC] Heads up on sys_fallocate() |
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| Linus Torvalds | Linux 2.6.25-rc4 |
| Greg KH | Linux 2.6.25.10 |
git: | |
| Gerrit Renker | [PATCH 15/37] dccp: Set per-connection CCIDs via socket options |
| David Miller | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| David Miller | [GIT]: Networking |
| Ilpo Järvinen | Re: Strange Application bug, race in MSG_PEEK complaints (was: Bug#513695: fetchma... |
