Skip to contentSkip to conversation

Implement NAPI in et131x

PATCH In review Mark Einon 5 participants 22 messages Aug 20, 2014 – Aug 31, 2014

Subsystems (3)
lore
Share & tools
lore

Mark Einon

author
#0 lore raw

cover Implement NAPI in et131x

Let's put a NAPI on this baby...

NAPI support was identified by Dave Miller <[email protected]> as a must to get this driver out of staging. This patchset first tidies up the code enough to make adding NAPI easier, and the final patch mostly adds the 'boilerplate' NAPI code as described by:

http://www.linuxfoundation.org/collaborate/workgroups/networking/napi

The code has been tested on hardware, with no issues found to date.

**GregKH** - this patchset is based upon my previous bugfix 'Fix errors caused by phydev->addr accesses' which is currently only on your staging-linus branch, not staging-next - so won't apply cleanly in it's current state. Please let me know if I need to do anything about this.

Cheers,

Mark

---
Mark Einon (8):
staging: et131x: Use eth_mac_addr() instead of duplicating the
functionality
staging: et131x: Don't handle rx/tx packets when changing mtu
staging: et131x: Use for loop to initialise contiguous registers to
zero
staging: et131x: Use for loop to initialise contiguous macstat
registers to zero
staging: et131x: Remove unnecessary i2c_wack variable
staging: et131x: Rename NUM_PACKETS_HANDLED to MAX_PACKETS_HANDLED
staging: et131x: Fix ET_INTR_TXDMA_ISR register name typo
staging: et131x: Implement NAPI support

 drivers/staging/et131x/README   |   1 -
 drivers/staging/et131x/et131x.c | 271 ++++++++++------------------------------
 drivers/staging/et131x/et131x.h |  96 +-------------
 3 files changed, 69 insertions(+), 299 deletions(-)
Signature · 1 line
2.1.0
author
#1 lore raw

PATCH 1/8 staging: et131x: Use eth_mac_addr() instead of duplicating the functionality

There's already working code to set the mac address, so let's use it.

---
 drivers/staging/et131x/et131x.c | 53 +----------------------------------------
 1 file changed, 1 insertion(+), 52 deletions(-)
drivers/staging/et131x/et131x.c +1 -52
index 831b7c6..ac6700b 100644
@@ -4468,57 +4468,6 @@ static int et131x_change_mtu(struct net_device *netdev, int new_mtu)
 	return result;
 }
 
-/* et131x_set_mac_addr - handler to change the MAC address for the device */
-static int et131x_set_mac_addr(struct net_device *netdev, void *new_mac)
-{
-	int result = 0;
-	struct et131x_adapter *adapter = netdev_priv(netdev);
-	struct sockaddr *address = new_mac;
-
-	if (adapter == NULL)
-		return -ENODEV;
-
-	/* Make sure the requested MAC is valid */
-	if (!is_valid_ether_addr(address->sa_data))
-		return -EADDRNOTAVAIL;
-
-	et131x_disable_txrx(netdev);
-	et131x_handle_send_interrupt(adapter);
-	et131x_handle_recv_interrupt(adapter);
-
-	/* Set the new MAC */
-	/* netdev->set_mac_address  = &new_mac; */
-
-	memcpy(netdev->dev_addr, address->sa_data, netdev->addr_len);
-
-	netdev_info(netdev, "Setting MAC address to %pM\n",
-		    netdev->dev_addr);
-
-	/* Free Rx DMA memory */
-	et131x_adapter_memory_free(adapter);
-
-	et131x_soft_reset(adapter);
-
-	/* Alloc and init Rx DMA memory */
-	result = et131x_adapter_memory_alloc(adapter);
-	if (result != 0) {
-		dev_err(&adapter->pdev->dev,
-			"Change MAC failed; couldn't re-alloc DMA memory\n");
-		return result;
-	}
-
-	et131x_init_send(adapter);
-
-	et131x_hwaddr_init(adapter);
-
-	/* Init the device with the new settings */
-	et131x_adapter_setup(adapter);
-
-	et131x_enable_txrx(netdev);
-
-	return result;
-}
-
 static const struct net_device_ops et131x_netdev_ops = {
 	.ndo_open		= et131x_open,
 	.ndo_stop		= et131x_close,
@@ -4526,7 +4475,7 @@ static const struct net_device_ops et131x_netdev_ops = {
 	.ndo_set_rx_mode	= et131x_multicast,
 	.ndo_tx_timeout		= et131x_tx_timeout,
 	.ndo_change_mtu		= et131x_change_mtu,
-	.ndo_set_mac_address	= et131x_set_mac_addr,
+	.ndo_set_mac_address	= eth_mac_addr,
 	.ndo_validate_addr	= eth_validate_addr,
 	.ndo_get_stats		= et131x_stats,
 	.ndo_do_ioctl		= et131x_ioctl,
Signature · 1 line
2.1.0
author
#2 lore raw

PATCH 2/8 staging: et131x: Don't handle rx/tx packets when changing mtu

In reply to Mark Einon

There's no need to handle any rx/tx interrupts in the middle of an mtu change, so don't.

After this change, receive and transmit interrupts are only handled in one place, which paves the way to using NAPI.

---
 drivers/staging/et131x/et131x.c | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/et131x/et131x.c +0 -2
index ac6700b..fffe763 100644
@@ -4434,8 +4434,6 @@ static int et131x_change_mtu(struct net_device *netdev, int new_mtu)
 		return -EINVAL;
 
 	et131x_disable_txrx(netdev);
-	et131x_handle_send_interrupt(adapter);
-	et131x_handle_recv_interrupt(adapter);
 
 	/* Set the new MTU */
 	netdev->mtu = new_mtu;
Signature · 1 line
2.1.0
author
#3 lore raw

PATCH 3/8 staging: et131x: Use for loop to initialise contiguous registers to zero

In reply to Mark Einon

Replace a long list of contiguous writel() calls with a for loop iterating over the same values.

---
 drivers/staging/et131x/et131x.c | 27 +++------------------------
 1 file changed, 3 insertions(+), 24 deletions(-)
drivers/staging/et131x/et131x.c +3 -24
index fffe763..44cc684 100644
@@ -1138,6 +1138,7 @@ static void et1310_config_rxmac_regs(struct et131x_adapter *adapter)
 	u32 sa_lo;
 	u32 sa_hi = 0;
 	u32 pf_ctrl = 0;
+	u32 *wolw;
 
 	/* Disable the MAC while it is being configured (also disable WOL) */
 	writel(0x8, &rxmac->ctrl);
@@ -1151,30 +1152,8 @@ static void et1310_config_rxmac_regs(struct et131x_adapter *adapter)
 	 * its default Values of 0x00000000 because there are not WOL masks
 	 * as of this time.
 	 */
-	writel(0, &rxmac->mask0_word0);
-	writel(0, &rxmac->mask0_word1);
-	writel(0, &rxmac->mask0_word2);
-	writel(0, &rxmac->mask0_word3);
-
-	writel(0, &rxmac->mask1_word0);
-	writel(0, &rxmac->mask1_word1);
-	writel(0, &rxmac->mask1_word2);
-	writel(0, &rxmac->mask1_word3);
-
-	writel(0, &rxmac->mask2_word0);
-	writel(0, &rxmac->mask2_word1);
-	writel(0, &rxmac->mask2_word2);
-	writel(0, &rxmac->mask2_word3);
-
-	writel(0, &rxmac->mask3_word0);
-	writel(0, &rxmac->mask3_word1);
-	writel(0, &rxmac->mask3_word2);
-	writel(0, &rxmac->mask3_word3);
-
-	writel(0, &rxmac->mask4_word0);
-	writel(0, &rxmac->mask4_word1);
-	writel(0, &rxmac->mask4_word2);
-	writel(0, &rxmac->mask4_word3);
+	for (wolw = &rxmac->mask0_word0; wolw <= &rxmac->mask4_word3; wolw++)
+		writel(0, wolw);
 
 	/* Lets setup the WOL Source Address */
 	sa_lo = (adapter->addr[2] << ET_RX_WOL_LO_SA3_SHIFT) |
Signature · 1 line
2.1.0
maintainer
#4 lore raw

Re: [PATCH 3/8] staging: et131x: Use for loop to initialise contiguous registers to zero

Quoted 40 lines · Mark Einon

Replace a long list of contiguous writel() calls with a for loop iterating over the same values.

---
 drivers/staging/et131x/et131x.c | 27 +++------------------------
 1 file changed, 3 insertions(+), 24 deletions(-)
drivers/staging/et131x/et131x.c +1 -16
index fffe763..44cc684 100644
@@ -1138,6 +1138,7 @@ static void et1310_config_rxmac_regs(struct et131x_adapter *adapter)
 	u32 sa_lo;
 	u32 sa_hi = 0;
 	u32 pf_ctrl = 0;
+	u32 *wolw;
 
 	/* Disable the MAC while it is being configured (also disable WOL) */
 	writel(0x8, &rxmac->ctrl);
@@ -1151,30 +1152,8 @@ static void et1310_config_rxmac_regs(struct et131x_adapter *adapter)
 	 * its default Values of 0x00000000 because there are not WOL masks
 	 * as of this time.
 	 */
-	writel(0, &rxmac->mask0_word0);
-	writel(0, &rxmac->mask0_word1);
-	writel(0, &rxmac->mask0_word2);
-	writel(0, &rxmac->mask0_word3);
-
-	writel(0, &rxmac->mask1_word0);
-	writel(0, &rxmac->mask1_word1);
-	writel(0, &rxmac->mask1_word2);
-	writel(0, &rxmac->mask1_word3);
-
-	writel(0, &rxmac->mask2_word0);
-	writel(0, &rxmac->mask2_word1);
-	writel(0, &rxmac->mask2_word2);
-	writel(0, &rxmac->mask2_word3);
-
-	writel(0, &rxmac->mask3_word0);

drivers/staging/et131x/et131x.c static void et1310_config_rxmac_regs(struct et131x_adapter *adapter) · line 1156

Quoted 10 lines
drivers/staging/et131x/et131x.c +2 -8
-	writel(0, &rxmac->mask3_word1);
-	writel(0, &rxmac->mask3_word2);
-	writel(0, &rxmac->mask3_word3);
-
-	writel(0, &rxmac->mask4_word0);
-	writel(0, &rxmac->mask4_word1);
-	writel(0, &rxmac->mask4_word2);
-	writel(0, &rxmac->mask4_word3);
+	for (wolw = &rxmac->mask0_word0; wolw <= &rxmac->mask4_word3; wolw++)
+		writel(0, wolw);

You are now only writing to all locations 1 time, instead of 4 times, like before, are you sure that is ok? Hardware is flaky, sometimes it wants to be written to multiple times...

greg k-h

author
#5 lore raw

Re: [PATCH 3/8] staging: et131x: Use for loop to initialise contiguous registers to zero

Quoted 47 lines · Greg KH
Quoted 46 lines · Mark Einon

Replace a long list of contiguous writel() calls with a for loop iterating over the same values.

---
 drivers/staging/et131x/et131x.c | 27 +++------------------------
 1 file changed, 3 insertions(+), 24 deletions(-)
drivers/staging/et131x/et131x.c +1 -22
index fffe763..44cc684 100644
@@ -1138,6 +1138,7 @@ static void et1310_config_rxmac_regs(struct et131x_adapter *adapter)
 	u32 sa_lo;
 	u32 sa_hi = 0;
 	u32 pf_ctrl = 0;
+	u32 *wolw;
 
 	/* Disable the MAC while it is being configured (also disable WOL) */
 	writel(0x8, &rxmac->ctrl);
@@ -1151,30 +1152,8 @@ static void et1310_config_rxmac_regs(struct et131x_adapter *adapter)
 	 * its default Values of 0x00000000 because there are not WOL masks
 	 * as of this time.
 	 */
-	writel(0, &rxmac->mask0_word0);
-	writel(0, &rxmac->mask0_word1);
-	writel(0, &rxmac->mask0_word2);
-	writel(0, &rxmac->mask0_word3);
-
-	writel(0, &rxmac->mask1_word0);
-	writel(0, &rxmac->mask1_word1);
-	writel(0, &rxmac->mask1_word2);
-	writel(0, &rxmac->mask1_word3);
-
-	writel(0, &rxmac->mask2_word0);
-	writel(0, &rxmac->mask2_word1);
-	writel(0, &rxmac->mask2_word2);
-	writel(0, &rxmac->mask2_word3);
-
-	writel(0, &rxmac->mask3_word0);
-	writel(0, &rxmac->mask3_word1);
-	writel(0, &rxmac->mask3_word2);
-	writel(0, &rxmac->mask3_word3);
-
-	writel(0, &rxmac->mask4_word0);
-	writel(0, &rxmac->mask4_word1);
Quoted 8 lines

drivers/staging/et131x/et131x.c static void et1310_config_rxmac_regs(struct et131x_adapter *adapter) · line 1156

Quoted 4 lines
drivers/staging/et131x/et131x.c +2 -2
-	writel(0, &rxmac->mask4_word2);
-	writel(0, &rxmac->mask4_word3);
+	for (wolw = &rxmac->mask0_word0; wolw <= &rxmac->mask4_word3; wolw++)
+		writel(0, wolw);

You are now only writing to all locations 1 time, instead of 4 times, like before, are you sure that is ok? Hardware is flaky, sometimes it wants to be written to multiple times...

Hi Greg,

Thanks for the review.

As far as my understanding goes, the new code is equivalent to the old code - it's a little confusing that the name refers to a word, but the masks are all 32 bit values, and the loop iterates over the contiguous list of masks found in txmac_regs (et131x.h:891 - the masks are also unused in the driver after being set).

Or am I missing something here?

Cheers,

Mark

maintainer
#6 lore raw

Re: [PATCH 3/8] staging: et131x: Use for loop to initialise contiguous registers to zero

Quoted 61 lines · Mark Einon
Quoted 47 lines · Greg KH
Quoted 46 lines · Mark Einon

Replace a long list of contiguous writel() calls with a for loop iterating over the same values.

---
 drivers/staging/et131x/et131x.c | 27 +++------------------------
 1 file changed, 3 insertions(+), 24 deletions(-)
drivers/staging/et131x/et131x.c +1 -22
index fffe763..44cc684 100644
@@ -1138,6 +1138,7 @@ static void et1310_config_rxmac_regs(struct et131x_adapter *adapter)
 	u32 sa_lo;
 	u32 sa_hi = 0;
 	u32 pf_ctrl = 0;
+	u32 *wolw;
 
 	/* Disable the MAC while it is being configured (also disable WOL) */
 	writel(0x8, &rxmac->ctrl);
@@ -1151,30 +1152,8 @@ static void et1310_config_rxmac_regs(struct et131x_adapter *adapter)
 	 * its default Values of 0x00000000 because there are not WOL masks
 	 * as of this time.
 	 */
-	writel(0, &rxmac->mask0_word0);
-	writel(0, &rxmac->mask0_word1);
-	writel(0, &rxmac->mask0_word2);
-	writel(0, &rxmac->mask0_word3);
-
-	writel(0, &rxmac->mask1_word0);
-	writel(0, &rxmac->mask1_word1);
-	writel(0, &rxmac->mask1_word2);
-	writel(0, &rxmac->mask1_word3);
-
-	writel(0, &rxmac->mask2_word0);
-	writel(0, &rxmac->mask2_word1);
-	writel(0, &rxmac->mask2_word2);
-	writel(0, &rxmac->mask2_word3);
-
-	writel(0, &rxmac->mask3_word0);
-	writel(0, &rxmac->mask3_word1);
-	writel(0, &rxmac->mask3_word2);
-	writel(0, &rxmac->mask3_word3);
-
-	writel(0, &rxmac->mask4_word0);
-	writel(0, &rxmac->mask4_word1);
Quoted 8 lines

drivers/staging/et131x/et131x.c static void et1310_config_rxmac_regs(struct et131x_adapter *adapter) · line 1156

Quoted 4 lines
drivers/staging/et131x/et131x.c +2 -2
-	writel(0, &rxmac->mask4_word2);
-	writel(0, &rxmac->mask4_word3);
+	for (wolw = &rxmac->mask0_word0; wolw <= &rxmac->mask4_word3; wolw++)
+		writel(0, wolw);

You are now only writing to all locations 1 time, instead of 4 times, like before, are you sure that is ok? Hardware is flaky, sometimes it wants to be written to multiple times...

Hi Greg,

Thanks for the review.

Quoted 7 lines

As far as my understanding goes, the new code is equivalent to the old code - it's a little confusing that the name refers to a word, but the masks are all 32 bit values, and the loop iterates over the contiguous list of masks found in txmac_regs (et131x.h:891 - the masks are also unused in the driver after being set).

Or am I missing something here?

No, I was wrong, sorry, your explanation makes sense, sorry for the noise.

greg k-h

author
#7 lore raw

PATCH 4/8 staging: et131x: Use for loop to initialise contiguous macstat registers to zero

In reply to Mark Einon

Replace a long list of contiguous writel() calls with a for loop iterating over the same address values.

Also remove redundant comments on the macstat registers, the variable names are good enough.

---
 drivers/staging/et131x/et131x.c | 59 +++----------------------
 drivers/staging/et131x/et131x.h | 96 +----------------------------------------
 2 files changed, 7 insertions(+), 148 deletions(-)
drivers/staging/et131x/et131x.c +6 -53
index 44cc684..fc18e8d 100644
@@ -1257,60 +1257,13 @@ static void et1310_config_txmac_regs(struct et131x_adapter *adapter)
 
 static void et1310_config_macstat_regs(struct et131x_adapter *adapter)
 {
-	struct macstat_regs __iomem *macstat =
-		&adapter->regs->macstat;
+	struct macstat_regs __iomem *macstat = &adapter->regs->macstat;
+	u32 *reg;
 
-	/* Next we need to initialize all the macstat registers to zero on
-	 * the device.
-	 */
-	writel(0, &macstat->txrx_0_64_byte_frames);
-	writel(0, &macstat->txrx_65_127_byte_frames);
-	writel(0, &macstat->txrx_128_255_byte_frames);
-	writel(0, &macstat->txrx_256_511_byte_frames);
-	writel(0, &macstat->txrx_512_1023_byte_frames);
-	writel(0, &macstat->txrx_1024_1518_byte_frames);
-	writel(0, &macstat->txrx_1519_1522_gvln_frames);
-
-	writel(0, &macstat->rx_bytes);
-	writel(0, &macstat->rx_packets);
-	writel(0, &macstat->rx_fcs_errs);
-	writel(0, &macstat->rx_multicast_packets);
-	writel(0, &macstat->rx_broadcast_packets);
-	writel(0, &macstat->rx_control_frames);
-	writel(0, &macstat->rx_pause_frames);
-	writel(0, &macstat->rx_unknown_opcodes);
-	writel(0, &macstat->rx_align_errs);
-	writel(0, &macstat->rx_frame_len_errs);
-	writel(0, &macstat->rx_code_errs);
-	writel(0, &macstat->rx_carrier_sense_errs);
-	writel(0, &macstat->rx_undersize_packets);
-	writel(0, &macstat->rx_oversize_packets);
-	writel(0, &macstat->rx_fragment_packets);
-	writel(0, &macstat->rx_jabbers);
-	writel(0, &macstat->rx_drops);
-
-	writel(0, &macstat->tx_bytes);
-	writel(0, &macstat->tx_packets);
-	writel(0, &macstat->tx_multicast_packets);
-	writel(0, &macstat->tx_broadcast_packets);
-	writel(0, &macstat->tx_pause_frames);
-	writel(0, &macstat->tx_deferred);
-	writel(0, &macstat->tx_excessive_deferred);
-	writel(0, &macstat->tx_single_collisions);
-	writel(0, &macstat->tx_multiple_collisions);
-	writel(0, &macstat->tx_late_collisions);
-	writel(0, &macstat->tx_excessive_collisions);
-	writel(0, &macstat->tx_total_collisions);
-	writel(0, &macstat->tx_pause_honored_frames);
-	writel(0, &macstat->tx_drops);
-	writel(0, &macstat->tx_jabbers);
-	writel(0, &macstat->tx_fcs_errs);
-	writel(0, &macstat->tx_control_frames);
-	writel(0, &macstat->tx_oversize_frames);
-	writel(0, &macstat->tx_undersize_frames);
-	writel(0, &macstat->tx_fragments);
-	writel(0, &macstat->carry_reg1);
-	writel(0, &macstat->carry_reg2);
+	/* initialize all the macstat registers to zero on the device  */
+	for (reg = &macstat->txrx_0_64_byte_frames;
+	     reg <= &macstat->carry_reg2; reg++)
+		writel(0, reg);
 
 	/* Unmask any counters that we want to track the overflow of.
 	 * Initially this will be all counters.  It may become clear later
drivers/staging/et131x/et131x.h +1 -95

149 lines not on this page · raw message

Signature · 1 line
2.1.0
#8 lore raw

RE: [PATCH 4/8] staging: et131x: Use for loop to initialise contiguous macstat registers to zero

From: Mark Einon

Quoted 5 lines

Replace a long list of contiguous writel() calls with a for loop iterating over the same address values.

Also remove redundant comments on the macstat registers, the variable names are good enough.

...

Quoted 1 line
drivers/staging/et131x/et131x.c +0 -1
-	writel(0, &macstat->txrx_0_64_byte_frames);

...

Quoted 5 lines
drivers/staging/et131x/et131x.c +4 -1
-	writel(0, &macstat->carry_reg2);
+	/* initialize all the macstat registers to zero on the device  */
+	for (reg = &macstat->txrx_0_64_byte_frames;
+	     reg <= &macstat->carry_reg2; reg++)
+		writel(0, reg);

...

drivers/staging/et131x/et131x.h struct mac_regs { /* Location: */ · line 1264

Quoted 9 lines

struct macstat_regs { /* Location: */

drivers/staging/et131x/et131x.h +1 -3
 	u32 pad[32];			/*  0x6000 - 607C */
 
-	/* Tx/Rx 0-64 Byte Frame Counter */
+	/* counters */
 	u32 txrx_0_64_byte_frames;	/*  0x6080 */
-
-	/* Tx/Rx 65-127 Byte Frame Counter */
 	u32 txrx_65_127_byte_frames;	/*  0x6084 */

I think it would be best to also convert the stats counters to an array.

David

author
#9 lore raw

Re: [PATCH 4/8] staging: et131x: Use for loop to initialise contiguous macstat registers to zero

Quoted 18 lines · David Laight

From: Mark Einon

Quoted 5 lines

Replace a long list of contiguous writel() calls with a for loop iterating over the same address values.

Also remove redundant comments on the macstat registers, the variable names are good enough.

...

Quoted 1 line
drivers/staging/et131x/et131x.c +0 -1
-	writel(0, &macstat->txrx_0_64_byte_frames);

...

Quoted 5 lines
drivers/staging/et131x/et131x.c +4 -1
-	writel(0, &macstat->carry_reg2);
+	/* initialize all the macstat registers to zero on the device  */
+	for (reg = &macstat->txrx_0_64_byte_frames;
+	     reg <= &macstat->carry_reg2; reg++)
+		writel(0, reg);

...

Quoted 3 lines

struct macstat_regs { /* Location: */
u32 pad[32]; /* 0x6000 - 607C */

Quoted 8 lines

drivers/staging/et131x/et131x.h struct mac_regs { /* Location: */ · line 1264

Quoted 6 lines
drivers/staging/et131x/et131x.h +1 -3
-	/* Tx/Rx 0-64 Byte Frame Counter */
+	/* counters */
 	u32 txrx_0_64_byte_frames;	/*  0x6080 */
-
-	/* Tx/Rx 65-127 Byte Frame Counter */
 	u32 txrx_65_127_byte_frames;	/*  0x6084 */

I think it would be best to also convert the stats counters to an array.

Hi David, thanks for the review.

There's other code that accesses these registers individually, taking into account carries - so I don't think using an array would change much, as we'd still need a way of identifying individual indices.

Cheers,

Mark

author
#10 lore raw

PATCH 5/8 staging: et131x: Remove unnecessary i2c_wack variable

In reply to Mark Einon

i2c_wack is only used to implement a while(1) loop, so let's remove it.

---
 drivers/staging/et131x/et131x.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/staging/et131x/et131x.c +4 -6
index fc18e8d..551b250 100644
@@ -573,7 +573,6 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data)
 	int index = 0;
 	int retries;
 	int err = 0;
-	int i2c_wack = 0;
 	int writeok = 0;
 	u32 status;
 	u32 val = 0;
@@ -599,8 +598,6 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data)
 			LBCIF_CONTROL_LBCIF_ENABLE | LBCIF_CONTROL_I2C_WRITE))
 		return -EIO;
 
-	i2c_wack = 1;
-
 	/* Prepare EEPROM address for Step 3 */
 
 	for (retries = 0; retries < MAX_NUM_WRITE_RETRIES; retries++) {
@@ -656,9 +653,9 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data)
 	 */
 	udelay(10);
 
-	while (i2c_wack) {
+	while (1) {
 		if (pci_write_config_byte(pdev, LBCIF_CONTROL_REGISTER,
-			LBCIF_CONTROL_LBCIF_ENABLE))
+					  LBCIF_CONTROL_LBCIF_ENABLE))
 			writeok = 0;
 
 		/* Do read until internal ACK_ERROR goes away meaning write
@@ -670,7 +667,8 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data)
 					       addr);
 			do {
 				pci_read_config_dword(pdev,
-					LBCIF_DATA_REGISTER, &val);
+						      LBCIF_DATA_REGISTER,
+						      &val);
 			} while ((val & 0x00010000) == 0);
 		} while (val & 0x00040000);
 
Signature · 1 line
2.1.0
#11 lore raw

Re: [PATCH 5/8] staging: et131x: Remove unnecessary i2c_wack variable

drivers/staging/et131x/et131x.c static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data) · line 671

Quoted 5 lines · Mark Einon
                        do {
                                pci_read_config_dword(pdev,
drivers/staging/et131x/et131x.c +2 -1
-                                       LBCIF_DATA_REGISTER, &val);
+                                                     LBCIF_DATA_REGISTER,
+                                                     &val);

This seems to be an unrelated change.

author
#12 lore raw

Re: [PATCH 5/8] staging: et131x: Remove unnecessary i2c_wack variable

Quoted 9 lines · Fabio Estevam

drivers/staging/et131x/et131x.c static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data) · line 671

Quoted 5 lines · Mark Einon
                        do {
                                pci_read_config_dword(pdev,
drivers/staging/et131x/et131x.c +2 -1
-                                       LBCIF_DATA_REGISTER, &val);
+                                                     LBCIF_DATA_REGISTER,
+                                                     &val);

This seems to be an unrelated change.

Hi Fabio, thanks for the review.

It's a space alignment of parameters to go with the previous change, to keep wrapping consistent in the file:

- while (i2c_wack) {
+ while (1) {
if (pci_write_config_byte(pdev, LBCIF_CONTROL_REGISTER,
- LBCIF_CONTROL_LBCIF_ENABLE))
+ LBCIF_CONTROL_LBCIF_ENABLE))

So what are you saying - are you just commenting, document it, put it in a seperate patch?

Cheers,

Mark

#13 lore raw

Re: [PATCH 5/8] staging: et131x: Remove unnecessary i2c_wack variable

Hi Mark,

Quoted 12 lines · Mark Einon

Hi Fabio, thanks for the review.

It's a space alignment of parameters to go with the previous change, to keep wrapping consistent in the file:

drivers/staging/et131x/et131x.c +2 -2
-       while (i2c_wack) {
+       while (1) {
                if (pci_write_config_byte(pdev, LBCIF_CONTROL_REGISTER,
-                       LBCIF_CONTROL_LBCIF_ENABLE))
+                                         LBCIF_CONTROL_LBCIF_ENABLE))
Quoted 2 lines

So what are you saying - are you just commenting, document it, put it in a seperate patch?

Yes, it would be better if this part was part of a separate patch.

author
#14 lore raw

Re: [PATCH 5/8] staging: et131x: Remove unnecessary i2c_wack variable

Quoted 16 lines · Fabio Estevam

Hi Mark,

Quoted 12 lines · Mark Einon

Hi Fabio, thanks for the review.

It's a space alignment of parameters to go with the previous change, to keep wrapping consistent in the file:

drivers/staging/et131x/et131x.c +2 -2
-       while (i2c_wack) {
+       while (1) {
                if (pci_write_config_byte(pdev, LBCIF_CONTROL_REGISTER,
-                       LBCIF_CONTROL_LBCIF_ENABLE))
+                                         LBCIF_CONTROL_LBCIF_ENABLE))
Quoted 4 lines
Quoted 2 lines

So what are you saying - are you just commenting, document it, put it in a seperate patch?

Yes, it would be better if this part was part of a separate patch.

Ok, I'll remove the indenting changes and sned them in a future patch. I'll submit a revised v2 of this one.

Cheers,

Mark

author
#15 lore raw

PATCH 6/8 staging: et131x: Rename NUM_PACKETS_HANDLED to MAX_PACKETS_HANDLED

In reply to Mark Einon

To better describe it's use as a hard limit.

---
 drivers/staging/et131x/et131x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/et131x/et131x.c +3 -3
index 551b250..df83ea3 100644
@@ -179,7 +179,7 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver for the ET1310 by Agere S
 #define NIC_DEFAULT_NUM_RFD	1024
 #define NUM_FBRS		2
 
-#define NUM_PACKETS_HANDLED	256
+#define MAX_PACKETS_HANDLED	256
 
 #define ALCATEL_MULTICAST_PKT	0x01000000
 #define ALCATEL_BROADCAST_PKT	0x02000000
@@ -2557,7 +2557,7 @@ static void et131x_handle_recv_interrupt(struct et131x_adapter *adapter)
 	struct rx_ring *rx_ring = &adapter->rx_ring;
 
 	/* Process up to available RFD's */
-	while (count < NUM_PACKETS_HANDLED) {
+	while (count < MAX_PACKETS_HANDLED) {
 		if (list_empty(&rx_ring->recv_list)) {
 			WARN_ON(rx_ring->num_ready_recv != 0);
 			done = false;
@@ -2589,7 +2589,7 @@ static void et131x_handle_recv_interrupt(struct et131x_adapter *adapter)
 		count++;
 	}
 
-	if (count == NUM_PACKETS_HANDLED || !done) {
+	if (count == MAX_PACKETS_HANDLED || !done) {
 		rx_ring->unfinished_receives = true;
 		writel(PARM_TX_TIME_INT_DEF * NANO_IN_A_MICRO,
 		       &adapter->regs->global.watchdog_timer);
Signature · 1 line
2.1.0
author
#16 lore raw

PATCH 7/8 staging: et131x: Fix ET_INTR_TXDMA_ISR register name typo

In reply to Mark Einon

We actually mean to clear the ET_INTR_TXDMA_ISR reg after handling a completed transfer, not the ET_INTR_TXDMA_ERR reg, which should get handled immediately after.

---
 drivers/staging/et131x/et131x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/et131x/et131x.c +1 -1
index df83ea3..bf9ac15 100644
@@ -3891,7 +3891,7 @@ static void et131x_isr_handler(struct work_struct *work)
 	if (status & ET_INTR_RXDMA_XFR_DONE)
 		et131x_handle_recv_interrupt(adapter);
 
-	status &= ~(ET_INTR_TXDMA_ERR | ET_INTR_RXDMA_XFR_DONE);
+	status &= ~(ET_INTR_TXDMA_ISR | ET_INTR_RXDMA_XFR_DONE);
 
 	if (!status)
 		goto out;
Signature · 1 line
2.1.0
author
#17 lore raw

PATCH 8/8 staging: et131x: Implement NAPI support

In reply to Mark Einon

This implements NAPI support for et131x by:

-adding a napi_struct to the private adapter struct -changing netfif_rx_skb() call to netif_receive_skb() -changing et131x_handle_recv_interrupt() to et131x_handle_recv_pkts()
and taking a budget allocation.
-changing et131x_handle_send_interrupt() to et131x_handle_send_pkts() -replacing bottom half workqueue with poll function which handles
send & receive of skbs.
-adding various other necessary standard napi calls.

Also remove this item from the README TODO list.

---
 drivers/staging/et131x/README   |   1 -
 drivers/staging/et131x/et131x.c | 116 ++++++++++++++++++----------------------
 2 files changed, 52 insertions(+), 65 deletions(-)
drivers/staging/et131x/README +0 -1
index 3befc45..05555a3 100644
@@ -10,7 +10,6 @@ driver as they did not build properly at the time.
 TODO:
 	- Look at reducing the number of spinlocks
 	- Simplify code in nic_rx_pkts(), when determining multicast_pkts_rcvd
-	- Implement NAPI support
 	- In et131x_tx(), don't return NETDEV_TX_BUSY, just drop the packet with kfree_skb().
 	- Reduce the number of split lines by careful consideration of variable names etc.
 
drivers/staging/et131x/et131x.c +52 -64

219 lines not on this page · raw message

Signature · 1 line
2.1.0
#18 lore raw

Re: [PATCH 8/8] staging: et131x: Implement NAPI support

drivers/staging/et131x/et131x.c static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) · line 2561

Quoted 3 lines · On Wed, 20 Aug 2014 23:17:58 +0100 Mark Einon <[email protected]> wrote:
drivers/staging/et131x/et131x.c +2 -0
+	if (budget > MAX_PACKETS_HANDLED)
+		limit = MAX_PACKETS_HANDLED;

Why this artificial restriction?

author
#19 lore raw

Re: [PATCH 8/8] staging: et131x: Implement NAPI support

Quoted 8 lines · Stephen Hemminger

drivers/staging/et131x/et131x.c static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) · line 2561

Quoted 3 lines · On Wed, 20 Aug 2014 23:17:58 +0100 Mark Einon <[email protected]> wrote:
drivers/staging/et131x/et131x.c +2 -0
+	if (budget > MAX_PACKETS_HANDLED)
+		limit = MAX_PACKETS_HANDLED;

Why this artificial restriction?

Hi Stephen, thanks for the review.

It's a restriction that was in the original driver code, and I'm being cautious. I don't have much documentation for the device, and I haven't yet figured a way to test the limit so I can play with removing it. If you have any suggestions on how to do that, I'd be happy to hear them.

Cheers,

Mark

#20 lore raw

Re: [PATCH 8/8] staging: et131x: Implement NAPI support

In reply to Mark Einon

drivers/staging/et131x/et131x.c static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) · line 2557

Quoted 4 lines · On Wed, 20 Aug 2014 23:17:58 +0100 Mark Einon <[email protected]> wrote:
drivers/staging/et131x/et131x.c +3 -1
-	bool done = true;
+	int count = 0;
+	int limit = budget;
+	bool not_done = false;

Don't use negative variables. Better to keep the original done variable.

author
#21 lore raw

Re: [PATCH 8/8] staging: et131x: Implement NAPI support

Quoted 9 lines · Stephen Hemminger

drivers/staging/et131x/et131x.c static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) · line 2557

Quoted 4 lines · On Wed, 20 Aug 2014 23:17:58 +0100 Mark Einon <[email protected]> wrote:
drivers/staging/et131x/et131x.c +3 -1
-	bool done = true;
+	int count = 0;
+	int limit = budget;
+	bool not_done = false;

Don't use negative variables. Better to keep the original done variable.

Fair comment, I'll send a v2.

Cheers,

Mark