All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] Firewire networking assorted fixes
@ 2010-11-28  1:15 Maxim Levitsky
  2010-11-28  1:15 ` [PATCH 1/5] firewire: ohci: restore GUID register on resume Maxim Levitsky
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Maxim Levitsky @ 2010-11-28  1:15 UTC (permalink / raw)
  To: linux1394-devel; +Cc: Stefan Richter, netdev

Here is few patches to fix few annoying problems with firewire networking.

I need a feedback on patch #3 from netdev folks.

patch #2 implements initial version of IR/IR resume support.

Best regards,
	Maxim Levitsky


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/5] firewire: ohci: restore GUID register on resume.
  2010-11-28  1:15 [PATCH 0/5] Firewire networking assorted fixes Maxim Levitsky
@ 2010-11-28  1:15 ` Maxim Levitsky
  2010-11-28  1:15 ` [PATCH 2/5] firewire: ohci: restart ISO channels " Maxim Levitsky
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Maxim Levitsky @ 2010-11-28  1:15 UTC (permalink / raw)
  To: linux1394-devel; +Cc: Stefan Richter, netdev, Maxim Levitsky

Some lousy BIOSes, eg my Aspire 5720 BIOS forgets to restore
device GUID on resume from ram.

Fix that by programming GUID register on resume from ram
Since that register is one time programable according to spec,
that has no effect on systems that have sane BIOS (Are there any?)

Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
---
 drivers/firewire/ohci.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index 6dd56cd..cadd6af 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -3240,6 +3240,10 @@ static int pci_resume(struct pci_dev *dev)
 		return err;
 	}
 
+	/* Some bioses forget to reinitialize the GUID. Do that ourselves */
+	reg_write(ohci, OHCI1394_GUIDLo, ohci->card.guid & 0xFFFFFFFF);
+	reg_write(ohci, OHCI1394_GUIDHi, (ohci->card.guid >> 32) & 0xFFFFFFFF);
+
 	return ohci_enable(&ohci->card, NULL, 0);
 }
 #endif
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/5] firewire: ohci: restart ISO channels on resume
  2010-11-28  1:15 [PATCH 0/5] Firewire networking assorted fixes Maxim Levitsky
  2010-11-28  1:15 ` [PATCH 1/5] firewire: ohci: restore GUID register on resume Maxim Levitsky
@ 2010-11-28  1:15 ` Maxim Levitsky
  2010-11-28  1:15 ` [PATCH 3/5] NET: ARP: allow to invalidate specific ARP entries Maxim Levitsky
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Maxim Levitsky @ 2010-11-28  1:15 UTC (permalink / raw)
  To: linux1394-devel; +Cc: Stefan Richter, netdev, Maxim Levitsky

ISO streams are supposed to be not interrupted
on bus resets, and suspend resume can be though
as one big bus reset.

Of course users must as soon as they notice the
bus reset, revalidate the ISO channel with IRM.

Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
---
 drivers/firewire/ohci.c |   49 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 48 insertions(+), 1 deletions(-)

diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index cadd6af..9704b34 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -40,6 +40,7 @@
 #include <linux/spinlock.h>
 #include <linux/string.h>
 #include <linux/time.h>
+#include <linux/bitops.h>
 
 #include <asm/byteorder.h>
 #include <asm/page.h>
@@ -167,6 +168,9 @@ struct iso_context {
 	int excess_bytes;
 	void *header;
 	size_t header_length;
+
+	u8 sync;
+	u8 tags;
 };
 
 #define CONFIG_ROM_SIZE 1024
@@ -199,8 +203,11 @@ struct fw_ohci {
 
 	u32 it_context_mask;     /* unoccupied IT contexts */
 	struct iso_context *it_context_list;
+	u32 it_active_mask;
+
 	u64 ir_context_channels; /* unoccupied channels */
 	u32 ir_context_mask;     /* unoccupied IR contexts */
+	u32 ir_active_mask;	/*running IR contexts */
 	struct iso_context *ir_context_list;
 	u64 mc_channels; /* channels in use by the multichannel IR context */
 	bool mc_allocated;
@@ -2596,6 +2603,7 @@ static int ohci_start_iso(struct fw_iso_context *base,
 
 		reg_write(ohci, OHCI1394_IsoXmitIntEventClear, 1 << index);
 		reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, 1 << index);
+		ohci->it_active_mask |= (1 << index);
 		context_run(&ctx->context, match);
 		break;
 
@@ -2613,7 +2621,12 @@ static int ohci_start_iso(struct fw_iso_context *base,
 		reg_write(ohci, OHCI1394_IsoRecvIntEventClear, 1 << index);
 		reg_write(ohci, OHCI1394_IsoRecvIntMaskSet, 1 << index);
 		reg_write(ohci, CONTEXT_MATCH(ctx->context.regs), match);
+		ohci->ir_active_mask |= (1 << index);
 		context_run(&ctx->context, control);
+
+		ctx->sync = sync;
+		ctx->tags = tags;
+
 		break;
 	}
 
@@ -2630,12 +2643,14 @@ static int ohci_stop_iso(struct fw_iso_context *base)
 	case FW_ISO_CONTEXT_TRANSMIT:
 		index = ctx - ohci->it_context_list;
 		reg_write(ohci, OHCI1394_IsoXmitIntMaskClear, 1 << index);
+		ohci->it_active_mask &= ~(1 << index);
 		break;
 
 	case FW_ISO_CONTEXT_RECEIVE:
 	case FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL:
 		index = ctx - ohci->ir_context_list;
 		reg_write(ohci, OHCI1394_IsoRecvIntMaskClear, 1 << index);
+		ohci->ir_active_mask &= ~(1 << index);
 		break;
 	}
 	flush_writes(ohci);
@@ -2711,6 +2726,33 @@ static int ohci_set_iso_channels(struct fw_iso_context *base, u64 *channels)
 	return ret;
 }
 
+static int ohci_resume_iso(struct fw_ohci *ohci)
+{
+	int i, err;
+	struct iso_context *ctx;
+
+	for_each_set_bit(i, (unsigned long *)&ohci->ir_active_mask,
+					sizeof(ohci->ir_active_mask)) {
+		ctx = &ohci->ir_context_list[i];
+		err = ohci_start_iso(&ctx->base, 0, ctx->sync, ctx->tags);
+
+		if (err)
+			return err;
+	}
+
+	for_each_set_bit(i, (unsigned long *)&ohci->it_active_mask,
+					sizeof(ohci->it_active_mask)) {
+		ctx = &ohci->it_context_list[i];
+		err = ohci_start_iso(&ctx->base, 0, 0, 0);
+
+		if (err)
+			return err;
+	}
+
+
+	return 0;
+}
+
 static int queue_iso_transmit(struct iso_context *ctx,
 			      struct fw_iso_packet *packet,
 			      struct fw_iso_buffer *buffer,
@@ -3244,7 +3286,12 @@ static int pci_resume(struct pci_dev *dev)
 	reg_write(ohci, OHCI1394_GUIDLo, ohci->card.guid & 0xFFFFFFFF);
 	reg_write(ohci, OHCI1394_GUIDHi, (ohci->card.guid >> 32) & 0xFFFFFFFF);
 
-	return ohci_enable(&ohci->card, NULL, 0);
+	err = ohci_enable(&ohci->card, NULL, 0);
+
+	if (err)
+		return err;
+
+	return ohci_resume_iso(ohci);
 }
 #endif
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/5] NET: ARP: allow to invalidate specific ARP entries
  2010-11-28  1:15 [PATCH 0/5] Firewire networking assorted fixes Maxim Levitsky
  2010-11-28  1:15 ` [PATCH 1/5] firewire: ohci: restore GUID register on resume Maxim Levitsky
  2010-11-28  1:15 ` [PATCH 2/5] firewire: ohci: restart ISO channels " Maxim Levitsky
@ 2010-11-28  1:15 ` Maxim Levitsky
  2010-11-28  1:15 ` [PATCH 4/5] firewire: net: invalidate ARP entries for removed nodes Maxim Levitsky
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Maxim Levitsky @ 2010-11-28  1:15 UTC (permalink / raw)
  To: linux1394-devel; +Cc: Stefan Richter, netdev, Maxim Levitsky

IPv4 over firewire needs to be able to remove ARP entries
from cache that belong to nodes that are removed, because
IPv4 over firewire uses ARP packets for private information
about nodes.

This information becames invalid on node removal, thus
as soon as it is connected again, ARP packet should be sent
to it which is not done due to valid cache entry.

CC: netdev@vger.kernel.org
Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
---
 include/net/arp.h |    1 +
 net/ipv4/arp.c    |   29 ++++++++++++++++++-----------
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/include/net/arp.h b/include/net/arp.h
index f4cf6ce..91f0568 100644
--- a/include/net/arp.h
+++ b/include/net/arp.h
@@ -25,5 +25,6 @@ extern struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
 				  const unsigned char *src_hw,
 				  const unsigned char *target_hw);
 extern void arp_xmit(struct sk_buff *skb);
+int arp_invalidate(struct net_device *dev, __be32 ip);
 
 #endif	/* _ARP_H */
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index d8e540c..35b1272 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -1142,6 +1142,23 @@ static int arp_req_get(struct arpreq *r, struct net_device *dev)
 	return err;
 }
 
+int arp_invalidate(struct net_device *dev, __be32 ip)
+{
+	int err = -ENXIO;
+	struct neighbour *neigh = neigh_lookup(&arp_tbl, &ip, dev);
+
+	if (neigh) {
+		if (neigh->nud_state & ~NUD_NOARP)
+			err = neigh_update(neigh, NULL, NUD_FAILED,
+					   NEIGH_UPDATE_F_OVERRIDE|
+					   NEIGH_UPDATE_F_ADMIN);
+		neigh_release(neigh);
+	}
+
+	return err;
+}
+EXPORT_SYMBOL(arp_invalidate);
+
 static int arp_req_delete_public(struct net *net, struct arpreq *r,
 		struct net_device *dev)
 {
@@ -1162,7 +1179,6 @@ static int arp_req_delete(struct net *net, struct arpreq *r,
 {
 	int err;
 	__be32 ip;
-	struct neighbour *neigh;
 
 	if (r->arp_flags & ATF_PUBL)
 		return arp_req_delete_public(net, r, dev);
@@ -1180,16 +1196,7 @@ static int arp_req_delete(struct net *net, struct arpreq *r,
 		if (!dev)
 			return -EINVAL;
 	}
-	err = -ENXIO;
-	neigh = neigh_lookup(&arp_tbl, &ip, dev);
-	if (neigh) {
-		if (neigh->nud_state & ~NUD_NOARP)
-			err = neigh_update(neigh, NULL, NUD_FAILED,
-					   NEIGH_UPDATE_F_OVERRIDE|
-					   NEIGH_UPDATE_F_ADMIN);
-		neigh_release(neigh);
-	}
-	return err;
+	return arp_invalidate(dev, ip);
 }
 
 /*
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] firewire: net: invalidate ARP entries for removed nodes.
  2010-11-28  1:15 [PATCH 0/5] Firewire networking assorted fixes Maxim Levitsky
                   ` (2 preceding siblings ...)
  2010-11-28  1:15 ` [PATCH 3/5] NET: ARP: allow to invalidate specific ARP entries Maxim Levitsky
@ 2010-11-28  1:15 ` Maxim Levitsky
  2010-11-28  1:15 ` [PATCH 5/5] firewire: net: ratelimit error messages Maxim Levitsky
  2010-11-28  3:02 ` [PATCH 0/5] Firewire networking assorted fixes Maxim Levitsky
  5 siblings, 0 replies; 7+ messages in thread
From: Maxim Levitsky @ 2010-11-28  1:15 UTC (permalink / raw)
  To: linux1394-devel; +Cc: Stefan Richter, netdev, Maxim Levitsky

This allows to be able to connect to nodes that disappered
from the bus and after some time appeared again.

Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
---
 drivers/firewire/net.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index 1a467a9..d422519 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -189,6 +189,7 @@ struct fwnet_peer {
 	struct fwnet_device *dev;
 	u64 guid;
 	u64 fifo;
+	__be32 ip;
 
 	/* guarded by dev->lock */
 	struct list_head pd_list; /* received partial datagrams */
@@ -568,6 +569,8 @@ static int fwnet_finish_incoming_packet(struct net_device *net,
 				peer->speed = sspd;
 			if (peer->max_payload > max_payload)
 				peer->max_payload = max_payload;
+
+			peer->ip = arp1394->sip;
 		}
 		spin_unlock_irqrestore(&dev->lock, flags);
 
@@ -1443,6 +1446,7 @@ static int fwnet_add_peer(struct fwnet_device *dev,
 	peer->dev = dev;
 	peer->guid = (u64)device->config_rom[3] << 32 | device->config_rom[4];
 	peer->fifo = FWNET_NO_FIFO_ADDR;
+	peer->ip = 0;
 	INIT_LIST_HEAD(&peer->pd_list);
 	peer->pdg_size = 0;
 	peer->datagram_label = 0;
@@ -1558,6 +1562,9 @@ static int fwnet_remove(struct device *_dev)
 
 	mutex_lock(&fwnet_device_mutex);
 
+	if (dev->netdev && peer->ip)
+		arp_invalidate(dev->netdev, peer->ip);
+
 	fwnet_remove_peer(peer);
 
 	if (list_empty(&dev->peer_list)) {
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/5] firewire: net: ratelimit error messages
  2010-11-28  1:15 [PATCH 0/5] Firewire networking assorted fixes Maxim Levitsky
                   ` (3 preceding siblings ...)
  2010-11-28  1:15 ` [PATCH 4/5] firewire: net: invalidate ARP entries for removed nodes Maxim Levitsky
@ 2010-11-28  1:15 ` Maxim Levitsky
  2010-11-28  3:02 ` [PATCH 0/5] Firewire networking assorted fixes Maxim Levitsky
  5 siblings, 0 replies; 7+ messages in thread
From: Maxim Levitsky @ 2010-11-28  1:15 UTC (permalink / raw)
  To: linux1394-devel; +Cc: Stefan Richter, netdev, Maxim Levitsky

This patch ensures that firewire-net won't be able to flood
the logs with errors by combining series of same errors together.

Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
---
 drivers/firewire/net.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index d422519..ac563d6 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -999,15 +999,23 @@ static void fwnet_transmit_packet_failed(struct fwnet_packet_task *ptask)
 static void fwnet_write_complete(struct fw_card *card, int rcode,
 				 void *payload, size_t length, void *data)
 {
-	struct fwnet_packet_task *ptask;
-
-	ptask = data;
+	struct fwnet_packet_task *ptask = data;
+	static unsigned long j;
+	static int last_rcode, errors_skipped;
 
 	if (rcode == RCODE_COMPLETE) {
 		fwnet_transmit_packet_done(ptask);
 	} else {
-		fw_error("fwnet_write_complete: failed: %x\n", rcode);
 		fwnet_transmit_packet_failed(ptask);
+
+		if (printk_timed_ratelimit(&j,  1000) || rcode != last_rcode) {
+			fw_error("fwnet_write_complete: "
+				"failed: %x (skipped %d)\n", rcode, errors_skipped);
+
+			errors_skipped = 0;
+			last_rcode = rcode;
+		} else
+			errors_skipped++;
 	}
 }
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/5] Firewire networking assorted fixes
  2010-11-28  1:15 [PATCH 0/5] Firewire networking assorted fixes Maxim Levitsky
                   ` (4 preceding siblings ...)
  2010-11-28  1:15 ` [PATCH 5/5] firewire: net: ratelimit error messages Maxim Levitsky
@ 2010-11-28  3:02 ` Maxim Levitsky
  5 siblings, 0 replies; 7+ messages in thread
From: Maxim Levitsky @ 2010-11-28  3:02 UTC (permalink / raw)
  To: linux1394-devel; +Cc: netdev, Stefan Richter

On Sun, 2010-11-28 at 03:15 +0200, Maxim Levitsky wrote:
> Here is few patches to fix few annoying problems with firewire networking.
> 
> I need a feedback on patch #3 from netdev folks.
> 
> patch #2 implements initial version of IR/IR resume support.
Sorry for bad spelling and grammar in the changelogs and here, usually I
mange much better than that....




------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-11-28  3:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-28  1:15 [PATCH 0/5] Firewire networking assorted fixes Maxim Levitsky
2010-11-28  1:15 ` [PATCH 1/5] firewire: ohci: restore GUID register on resume Maxim Levitsky
2010-11-28  1:15 ` [PATCH 2/5] firewire: ohci: restart ISO channels " Maxim Levitsky
2010-11-28  1:15 ` [PATCH 3/5] NET: ARP: allow to invalidate specific ARP entries Maxim Levitsky
2010-11-28  1:15 ` [PATCH 4/5] firewire: net: invalidate ARP entries for removed nodes Maxim Levitsky
2010-11-28  1:15 ` [PATCH 5/5] firewire: net: ratelimit error messages Maxim Levitsky
2010-11-28  3:02 ` [PATCH 0/5] Firewire networking assorted fixes Maxim Levitsky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.