Firewire networking assorted fixes
Subsystems (4)
cover Firewire networking assorted fixes
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
PATCH 1/5 firewire: ohci: restore GUID register on resume.
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?)
--- drivers/firewire/ohci.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/firewire/ohci.c +4 -0
@@ -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
Signature · 1 line
1.7.1
PATCH 2/5 firewire: ohci: restart ISO channels on resume
In reply to Maxim LevitskyISO 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.
--- drivers/firewire/ohci.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 48 insertions(+), 1 deletions(-)
drivers/firewire/ohci.c +48 -1
@@ -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
Signature · 1 line
1.7.1
PATCH 4/5 firewire: net: invalidate ARP entries for removed nodes.
In reply to Maxim LevitskyThis allows to be able to connect to nodes that disappered from the bus and after some time appeared again.
--- drivers/firewire/net.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/firewire/net.c +7 -0
@@ -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)) {
Signature · 1 line
1.7.1
PATCH 3/5 NET: ARP: allow to invalidate specific ARP entries
In reply to Maxim LevitskyIPv4 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.
--- include/net/arp.h | 1 + net/ipv4/arp.c | 29 ++++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-)
include/net/arp.h +1 -0
@@ -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 */
net/ipv4/arp.c +18 -11
@@ -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); }/*
Signature · 1 line
1.7.1
PATCH 5/5 firewire: net: ratelimit error messages
In reply to Maxim LevitskyThis patch ensures that firewire-net won't be able to flood the logs with errors by combining series of same errors together.
--- drivers/firewire/net.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-)
drivers/firewire/net.c +12 -4
@@ -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++; } }
Signature · 1 line
1.7.1
Quoted 5 lines · Maxim Levitsky
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