From patchwork Wed Dec 8 03:32:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 74625 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id DA45DB70AA for ; Wed, 8 Dec 2010 14:33:12 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754434Ab0LHDdH (ORCPT ); Tue, 7 Dec 2010 22:33:07 -0500 Received: from mail-bw0-f45.google.com ([209.85.214.45]:58258 "EHLO mail-bw0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754369Ab0LHDdG (ORCPT ); Tue, 7 Dec 2010 22:33:06 -0500 Received: by bwz16 with SMTP id 16so858480bwz.4 for ; Tue, 07 Dec 2010 19:33:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :in-reply-to:references:content-type:date:message-id:mime-version :x-mailer; bh=DHaDbiWaWKZtMc/QtQ68o/T2apOX6HM9T2jiXVfRJHw=; b=FYnZHFWebi3Z8JsAZ3VcdVwM0jjc387c4gwo0FuLI+d/F7prmcA2cJFdyrZ6v43AS0 kN1Lr4IrHh4FU2MMuE0YIZWCTKxkaXJFX2BTNP3KMEmF/wqfaosHPsEYX4gAC10OIar1 hp5JnC/OCrHlwoFtFAFuDOfQxDGWYo4VD4GTk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer; b=SOVILniyPN38HLox6a4FifeN7s0S54Rp2TCvLqMs5eYd+/iPU2A6quI+LthHHBikj9 6II+mVtc5JgnKd986ff9vSUK+kIzvlYuOzWPPWMzp2vznwtm1aqyw1ae4RBQBEPaN7/O OEpQpgyK7W/vMlpUljiNM+8HnlCx1GGPjm6ic= Received: by 10.204.75.148 with SMTP id y20mr1333623bkj.154.1291779183924; Tue, 07 Dec 2010 19:33:03 -0800 (PST) Received: from [10.42.43.18] ([77.125.105.54]) by mx.google.com with ESMTPS id a17sm50651bku.11.2010.12.07.19.32.59 (version=SSLv3 cipher=RC4-MD5); Tue, 07 Dec 2010 19:33:00 -0800 (PST) Subject: Re: [PATCH 0/5 V2] Firewire networking assorted fixes From: Maxim Levitsky To: linux1394-devel Cc: Stefan Richter , netdev@vger.kernel.org In-Reply-To: <1290996593-32416-1-git-send-email-maximlevitsky@gmail.com> References: <1290996593-32416-1-git-send-email-maximlevitsky@gmail.com> Date: Wed, 08 Dec 2010 05:32:57 +0200 Message-ID: <1291779177.32420.8.camel@maxim-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Mon, 2010-11-29 at 04:09 +0200, Maxim Levitsky wrote: > Hi, > > This is updated version of the patches. > I updated the changelogs, addressed comments on patch #2 > > Best regards, > Maxim Levitsky > Today I have achieved the ultimate goal, full support of firewire networking via NetworkManager. Currently it is patched with few hacks but much less that I expected. I also had to patch dhclient as it unfortunately sends raw packets together with hardware header (ethernet of course...) I will soon clean up these hacks to turn them into patches and send to developers. The kernel side needs only the attached patch. It adds the link state detection to firewire-net Just for fun, this is screenshot that proves that NM works: http://img210.imageshack.us/img210/6019/screenshotdjk.png Of course, I still need to clean up the patches to NM and dhclient, so more correctly I am not fully done yet. Best regards, Maxim Levitsky From d42274653bc06583871ec3230f8308236aff92c2 Mon Sep 17 00:00:00 2001 From: Maxim Levitsky Date: Wed, 8 Dec 2010 04:22:57 +0200 Subject: [PATCH] firewire: net: add carrier detection To make userland, eg NM work with firewire we need to be able if cable is plugged or not. Simple and correct way of doing that is just couning number of peers. No peers - no link and vise versa. Best regards, Maxim Levitsky --- drivers/firewire/net.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c index ac563d6..67bad9c 100644 --- a/drivers/firewire/net.c +++ b/drivers/firewire/net.c @@ -178,6 +178,7 @@ struct fwnet_device { /* Number of tx datagrams that have been queued but not yet acked */ int queued_datagrams; + int peer_count; struct list_head peer_list; struct fw_card *card; @@ -1408,6 +1409,10 @@ static int fwnet_change_mtu(struct net_device *net, int new_mtu) return 0; } +static const struct ethtool_ops fwnet_ethtool_ops = { + .get_link = ethtool_op_get_link, +}; + static const struct net_device_ops fwnet_netdev_ops = { .ndo_open = fwnet_open, .ndo_stop = fwnet_stop, @@ -1426,6 +1431,8 @@ static void fwnet_init_dev(struct net_device *net) net->hard_header_len = FWNET_HLEN; net->type = ARPHRD_IEEE1394; net->tx_queue_len = FWNET_TX_QUEUE_LEN; + net->ethtool_ops = &fwnet_ethtool_ops; + } /* caller must hold fwnet_device_mutex */ @@ -1467,6 +1474,7 @@ static int fwnet_add_peer(struct fwnet_device *dev, spin_lock_irq(&dev->lock); list_add_tail(&peer->peer_link, &dev->peer_list); + dev->peer_count++; spin_unlock_irq(&dev->lock); return 0; @@ -1538,6 +1546,9 @@ static int fwnet_probe(struct device *_dev) unregister_netdev(net); list_del(&dev->dev_link); } + + if (dev->peer_count > 1) + netif_carrier_on(net); out: if (ret && allocated_netdev) free_netdev(net); @@ -1553,6 +1564,7 @@ static void fwnet_remove_peer(struct fwnet_peer *peer) spin_lock_irq(&peer->dev->lock); list_del(&peer->peer_link); + peer->dev->peer_count--; spin_unlock_irq(&peer->dev->lock); list_for_each_entry_safe(pd, pd_next, &peer->pd_list, pd_link) @@ -1575,6 +1587,11 @@ static int fwnet_remove(struct device *_dev) fwnet_remove_peer(peer); + /* If we serve just one node, that means we lost link + with outer world */ + if (dev->peer_count == 1) + netif_carrier_off(dev->netdev); + if (list_empty(&dev->peer_list)) { net = dev->netdev; unregister_netdev(net); -- 1.7.1